96?Ga:Xa},Ja=function(e,t,n){var r;if(t){var o=t.shouldForwardProp;r=e.__emotion_forwardProp&&o?function(t){return e.__emotion_forwardProp(t)&&o(t)}:o}return"function"!==typeof r&&n&&(r=e.__emotion_forwardProp),r},Qa=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;$a(t,n,r);La((function(){return Ka(t,n,r)}));return null},Za=function e(n,r){var o,a,i=n.__emotion_real===n,s=i&&n.__emotion_base||n;void 0!==r&&(o=r.label,a=r.target);var c=Ja(n,r,i),l=c||Ya(s),u=!l("as");return function(){var d=arguments,f=i&&void 0!==n.__emotion_styles?n.__emotion_styles.slice(0):[];if(void 0!==o&&f.push("label:"+o+";"),null==d[0]||void 0===d[0].raw)f.push.apply(f,d);else{0,f.push(d[0][0]);for(var p=d.length,h=1;h1?n-1:0),o=1;o` or ``");return e}function xi(){var e=lo(),t=bi();return Zt(Zt({},e),{},{theme:t})}yi.displayName="VStack";var wi=n(77),ki=["styleConfig"];function Si(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.styleConfig,a=tn(r,ki),i=xi(),s=i.theme,c=i.colorMode,l=e?fo(s,"components.".concat(e)):void 0,u=o||l,d=hn({theme:s,colorMode:c},null!=(n=null==u?void 0:u.defaultProps)?n:{},ho(uo(a,["children"]))),f=(0,t.useRef)({});if(u){var p=ro(u),h=p(d),v=wi(f.current,h);v||(f.current=h)}return f.current}function Ei(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Si(e,t)}function Ci(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Si(e,t)}var _i=["className"],Oi=nn((function(e,t){var n=Ei("Heading",e),r=oo(e),o=(r.className,tn(r,_i));return(0,li.jsx)(ci.h2,Zt(Zt({ref:t,className:on("chakra-heading",e.className)},o),{},{__css:n}))}));function ji(e,t){return"".concat(e," returned `undefined`. Seems you forgot to wrap component within ").concat(t)}function Pi(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.name,r=e.strict,o=void 0===r||r,a=e.hookName,i=void 0===a?"useContext":a,s=e.providerName,c=void 0===s?"Provider":s,l=e.errorMessage,u=(0,t.createContext)(void 0);function d(){var e,n=(0,t.useContext)(u);if(!n&&o){var r=new Error(null!=l?l:ji(i,c));throw r.name="ContextError",null==(e=Error.captureStackTrace)||e.call(Error,r,d),r}return n}return u.displayName=n,[u.Provider,d,u]}function Ti(e,t){if(null!=e)if("function"!==typeof e)try{e.current=t}catch(n){throw new Error("Cannot assign value '".concat(t,"' to ref '").concat(e,"'"))}else e(t)}function Ai(){for(var e=arguments.length,t=new Array(e),n=0;n\" "}),2),Di=Ni[0],Fi=Ni[1],Li=u(Pi({strict:!1,name:"FormControlContext"}),2),zi=Li[0],Bi=Li[1];var Vi=nn((function(e,n){var r=Ci("Form",e),o=function(e){var n=e.id,r=e.isRequired,o=e.isInvalid,a=e.isDisabled,i=e.isReadOnly,s=tn(e,Mi),c=(0,t.useId)(),l=n||"field-".concat(c),d="".concat(l,"-label"),f="".concat(l,"-feedback"),p="".concat(l,"-helptext"),h=u((0,t.useState)(!1),2),v=h[0],m=h[1],g=u((0,t.useState)(!1),2),y=g[0],b=g[1],x=u((0,t.useState)(!1),2),w=x[0],k=x[1],S=(0,t.useCallback)((function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Zt(Zt({id:p},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{ref:Ai(e,(function(e){e&&b(!0)}))})}),[p]),E=(0,t.useCallback)((function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Zt(Zt({},n),{},{ref:r,"data-focus":un(w),"data-disabled":un(a),"data-invalid":un(o),"data-readonly":un(i),id:null!=(e=n.id)?e:d,htmlFor:null!=(t=n.htmlFor)?t:l})}),[l,a,w,o,i,d]),C=(0,t.useCallback)((function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Zt(Zt({id:f},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{ref:Ai(e,(function(e){e&&m(!0)})),"aria-live":"polite"})}),[f]),_=(0,t.useCallback)((function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Zt(Zt(Zt({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),s),{},{ref:e,role:"group"})}),[s]),O=(0,t.useCallback)((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Zt(Zt({},e),{},{ref:t,role:"presentation","aria-hidden":!0,children:e.children||"*"})}),[]);return{isRequired:!!r,isInvalid:!!o,isReadOnly:!!i,isDisabled:!!a,isFocused:!!w,onFocus:function(){return k(!0)},onBlur:function(){return k(!1)},hasFeedbackText:v,setHasFeedbackText:m,hasHelpText:y,setHasHelpText:b,id:l,labelId:d,feedbackId:f,helpTextId:p,htmlProps:s,getHelpTextProps:S,getErrorMessageProps:C,getRootProps:_,getLabelProps:E,getRequiredIndicatorProps:O}}(oo(e)),a=o.getRootProps,i=(o.htmlProps,tn(o,Ii)),s=on("chakra-form-control",e.className);return(0,li.jsx)(zi,{value:i,children:(0,li.jsx)(Di,{value:r,children:(0,li.jsx)(ci.div,Zt(Zt({},a({},n)),{},{className:s,__css:r.container}))})})}));Vi.displayName="FormControl";var Hi=nn((function(e,t){var n=Bi(),r=Fi(),o=on("chakra-form__helper-text",e.className);return(0,li.jsx)(ci.div,Zt(Zt({},null==n?void 0:n.getHelpTextProps(e,t)),{},{__css:r.helperText,className:o}))}));Hi.displayName="FormHelperText";var Ui=["className","children","requiredIndicator","optionalIndicator"],Wi=nn((function(e,t){var n,r=Ei("FormLabel",e),o=oo(e),a=(o.className,o.children),i=o.requiredIndicator,s=void 0===i?(0,li.jsx)(qi,{}):i,c=o.optionalIndicator,l=void 0===c?null:c,u=tn(o,Ui),d=Bi(),f=null!=(n=null==d?void 0:d.getLabelProps(u,t))?n:Zt({ref:t},u);return(0,li.jsxs)(ci.label,Zt(Zt({},f),{},{className:on("chakra-form__label",o.className),__css:Zt({display:"block",textAlign:"start"},r),children:[a,(null==d?void 0:d.isRequired)?s:l]}))}));Wi.displayName="FormLabel";var qi=nn((function(e,t){var n=Bi(),r=Fi();if(!(null==n?void 0:n.isRequired))return null;var o=on("chakra-form__required-indicator",e.className);return(0,li.jsx)(ci.span,Zt(Zt({},null==n?void 0:n.getRequiredIndicatorProps(e,t)),{},{__css:r.requiredIndicator,className:o}))}));qi.displayName="RequiredIndicator";var $i=["isDisabled","isInvalid","isReadOnly","isRequired"],Ki=["id","disabled","readOnly","required","isRequired","isInvalid","isReadOnly","isDisabled","onFocus","onBlur"];function Gi(e){var t=Xi(e),n=t.isDisabled,r=t.isInvalid,o=t.isReadOnly,a=t.isRequired;return Zt(Zt({},tn(t,$i)),{},{disabled:n,readOnly:o,required:a,"aria-invalid":dn(r),"aria-required":dn(a),"aria-readonly":dn(o)})}function Xi(e){var t,n,r,o=Bi(),a=e.id,i=e.disabled,s=e.readOnly,c=e.required,l=e.isRequired,u=e.isInvalid,d=e.isReadOnly,f=e.isDisabled,p=e.onFocus,h=e.onBlur,v=tn(e,Ki),m=e["aria-describedby"]?[e["aria-describedby"]]:[];return(null==o?void 0:o.hasFeedbackText)&&(null==o?void 0:o.isInvalid)&&m.push(o.feedbackId),(null==o?void 0:o.hasHelpText)&&m.push(o.helpTextId),Zt(Zt({},v),{},{"aria-describedby":m.join(" ")||void 0,id:null!=a?a:null==o?void 0:o.id,isDisabled:null!=(t=null!=i?i:f)?t:null==o?void 0:o.isDisabled,isReadOnly:null!=(n=null!=s?s:d)?n:null==o?void 0:o.isReadOnly,isRequired:null!=(r=null!=c?c:l)?r:null==o?void 0:o.isRequired,isInvalid:null!=u?u:null==o?void 0:o.isInvalid,onFocus:fn(null==o?void 0:o.onFocus,p),onBlur:fn(null==o?void 0:o.onBlur,h)})}var Yi=["htmlSize"],Ji=nn((function(e,t){var n=e.htmlSize,r=tn(e,Yi),o=Ci("Input",r),a=Gi(oo(r)),i=on("chakra-input",e.className);return(0,li.jsx)(ci.input,Zt(Zt({size:n},a),{},{__css:o.field,ref:t,className:i}))}));Ji.displayName="Input",Ji.id="Input";var Qi=["as","viewBox","color","focusable","children","className","__css"],Zi={path:(0,li.jsxs)("g",{stroke:"currentColor",strokeWidth:"1.5",children:[(0,li.jsx)("path",{strokeLinecap:"round",fill:"none",d:"M9,9a3,3,0,1,1,4,2.829,1.5,1.5,0,0,0-1,1.415V14.25"}),(0,li.jsx)("path",{fill:"currentColor",strokeLinecap:"round",d:"M12,17.25a.375.375,0,1,0,.375.375A.375.375,0,0,0,12,17.25h0"}),(0,li.jsx)("circle",{fill:"none",strokeMiterlimit:"10",cx:"12",cy:"12",r:"11.25"})]}),viewBox:"0 0 24 24"},es=nn((function(e,t){var n=e.as,r=e.viewBox,o=e.color,a=void 0===o?"currentColor":o,i=e.focusable,s=void 0!==i&&i,c=e.children,l=e.className,u=e.__css,d=tn(e,Qi),f=on("chakra-icon",l),p=Ei("Icon",e),h={ref:t,focusable:s,className:f,__css:Zt(Zt({w:"1em",h:"1em",display:"inline-block",lineHeight:"1em",flexShrink:0,color:a},u),p)},v=null!=r?r:Zi.viewBox;if(n&&"string"!==typeof n)return(0,li.jsx)(ci.svg,Zt(Zt({as:n},h),d));var m=null!=c?c:Zi.path;return(0,li.jsx)(ci.svg,Zt(Zt(Zt({verticalAlign:"middle",viewBox:v},h),d),{},{children:m}))}));es.displayName="Icon";var ts=u(Pi({name:"FormErrorStylesContext",errorMessage:"useFormErrorStyles returned is 'undefined'. Seems you forgot to wrap the components in \"\" "}),2),ns=ts[0],rs=ts[1],os=nn((function(e,t){var n=Ci("FormError",e),r=oo(e),o=Bi();return(null==o?void 0:o.isInvalid)?(0,li.jsx)(ns,{value:n,children:(0,li.jsx)(ci.div,Zt(Zt({},null==o?void 0:o.getErrorMessageProps(r,t)),{},{className:on("chakra-form__error-message",e.className),__css:Zt({display:"flex",alignItems:"center"},n.text)}))}):null}));os.displayName="FormErrorMessage";var as=nn((function(e,t){var n=rs(),r=Bi();if(!(null==r?void 0:r.isInvalid))return null;var o=on("chakra-form__error-icon",e.className);return(0,li.jsx)(es,Zt(Zt({ref:t,"aria-hidden":!0},e),{},{__css:n.icon,className:o,children:(0,li.jsx)("path",{fill:"currentColor",d:"M11.983,0a12.206,12.206,0,0,0-8.51,3.653A11.8,11.8,0,0,0,0,12.207,11.779,11.779,0,0,0,11.8,24h.214A12.111,12.111,0,0,0,24,11.791h0A11.766,11.766,0,0,0,11.983,0ZM10.5,16.542a1.476,1.476,0,0,1,1.449-1.53h.027a1.527,1.527,0,0,1,1.523,1.47,1.475,1.475,0,0,1-1.449,1.53h-.027A1.529,1.529,0,0,1,10.5,16.542ZM11,12.5v-6a1,1,0,0,1,2,0v6a1,1,0,1,1-2,0Z"})}))}));as.displayName="FormErrorIcon";var is=["className","align","decoration","casing"],ss=nn((function(e,t){var n=Ei("Text",e),r=oo(e),o=(r.className,r.align,r.decoration,r.casing,tn(r,is)),a=function(e){var t=Object.assign({},e);for(var n in t)void 0===t[n]&&delete t[n];return t}({textAlign:e.align,textDecoration:e.decoration,textTransform:e.casing});return(0,li.jsx)(ci.p,Zt(Zt(Zt({ref:t,className:on("chakra-text",e.className)},a),o),{},{__css:n}))}));ss.displayName="Text";var cs=["className","isExternal"],ls=nn((function(e,t){var n=Ei("Link",e),r=oo(e),o=r.className,a=r.isExternal,i=tn(r,cs);return(0,li.jsx)(ci.a,Zt(Zt({target:a?"_blank":void 0,rel:a?"noopener":void 0,ref:t,className:on("chakra-link",o)},i),{},{__css:n}))}));ls.displayName="Link";var us=u(Pi({strict:!1,name:"ButtonGroupContext"}),2),ds=(us[0],us[1]),fs=["children","className"];function ps(e){var n=e.children,r=e.className,o=tn(e,fs),a=(0,t.isValidElement)(n)?(0,t.cloneElement)(n,{"aria-hidden":!0,focusable:!1}):n,i=on("chakra-button__icon",r);return(0,li.jsx)(ci.span,Zt(Zt({display:"inline-flex",alignSelf:"center",flexShrink:0},o),{},{className:i,children:a}))}ps.displayName="ButtonIcon";n(110);var hs=Va((function(e,n){var r=e.styles,o=Da([r],void 0,(0,t.useContext)(Ha)),a=(0,t.useRef)();return za((function(){var e=n.key+"-global",t=new n.sheet.constructor({key:e,nonce:n.sheet.nonce,container:n.sheet.container,speedy:n.sheet.isSpeedy}),r=!1,i=document.querySelector('style[data-emotion="'+e+" "+o.name+'"]');return n.sheet.tags.length&&(t.before=n.sheet.tags[0]),null!==i&&(r=!0,i.setAttribute("data-emotion",e),t.hydrate([i])),a.current=[t,r],function(){t.flush()}}),[n]),za((function(){var e=a.current,t=e[0];if(e[1])e[1]=!1;else{if(void 0!==o.next&&Ka(n,o.next,!0),t.tags.length){var r=t.tags[t.tags.length-1].nextElementSibling;t.before=r,t.flush()}n.insert("",o,t,!1)}}),[n,o.name]),null}));function vs(){for(var e=arguments.length,t=new Array(e),n=0;n-1};var uc=function(e,t){var n=this.__data__,r=ac(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function dc(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991},El={};El["[object Float32Array]"]=El["[object Float64Array]"]=El["[object Int8Array]"]=El["[object Int16Array]"]=El["[object Int32Array]"]=El["[object Uint8Array]"]=El["[object Uint8ClampedArray]"]=El["[object Uint16Array]"]=El["[object Uint32Array]"]=!0,El["[object Arguments]"]=El["[object Array]"]=El["[object ArrayBuffer]"]=El["[object Boolean]"]=El["[object DataView]"]=El["[object Date]"]=El["[object Error]"]=El["[object Function]"]=El["[object Map]"]=El["[object Number]"]=El["[object Object]"]=El["[object RegExp]"]=El["[object Set]"]=El["[object String]"]=El["[object WeakMap]"]=!1;var Cl=function(e){return Ys(e)&&Sl(e.length)&&!!El[Ks(e)]};var _l=function(e){return function(t){return e(t)}},Ol="object"==typeof exports&&exports&&!exports.nodeType&&exports,jl=Ol&&"object"==typeof module&&module&&!module.nodeType&&module,Pl=jl&&jl.exports===Ol&&Ns.process,Tl=function(){try{var e=jl&&jl.require&&jl.require("util").types;return e||Pl&&Pl.binding&&Pl.binding("util")}catch(t){}}(),Al=Tl,Rl=Al&&Al.isTypedArray,Ml=Rl?_l(Rl):Cl,Il=Object.prototype.hasOwnProperty;var Nl=function(e,t){var n=vl(e),r=!n&&hl(e),o=!n&&!r&&xl(e),a=!n&&!r&&!o&&Ml(e),i=n||r||o||a,s=i?cl(e.length,String):[],c=s.length;for(var l in e)!t&&!Il.call(e,l)||i&&("length"==l||o&&("offset"==l||"parent"==l)||a&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||kl(l,c))||s.push(l);return s},Dl=Object.prototype;var Fl=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Dl)},Ll=Gs(Object.keys,Object),zl=Object.prototype.hasOwnProperty;var Bl=function(e){if(!Fl(e))return Ll(e);var t=[];for(var n in Object(e))zl.call(e,n)&&"constructor"!=n&&t.push(n);return t};var Vl=function(e){return null!=e&&Sl(e.length)&&!yc(e)};var Hl=function(e){return Vl(e)?Nl(e):Bl(e)};var Ul=function(e,t){return e&&sl(t,Hl(t),e)};var Wl=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t},ql=Object.prototype.hasOwnProperty;var $l=function(e){if(!gc(e))return Wl(e);var t=Fl(e),n=[];for(var r in e)("constructor"!=r||!t&&ql.call(e,r))&&n.push(r);return n};var Kl=function(e){return Vl(e)?Nl(e,!0):$l(e)};var Gl=function(e,t){return e&&sl(t,Kl(t),e)},Xl="object"==typeof exports&&exports&&!exports.nodeType&&exports,Yl=Xl&&"object"==typeof module&&module&&!module.nodeType&&module,Jl=Yl&&Yl.exports===Xl?Fs.Buffer:void 0,Ql=Jl?Jl.allocUnsafe:void 0;var Zl=function(e,t){if(t)return e.slice();var n=e.length,r=Ql?Ql(n):new e.constructor(n);return e.copy(r),r};var eu=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n=0||(o[n]=e[n]);return o}function Cd(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var _d=function(e){return Array.isArray(e)&&0===e.length},Od=function(e){return"function"===typeof e},jd=function(e){return null!==e&&"object"===typeof e},Pd=function(e){return String(Math.floor(Number(e)))===e},Td=function(e){return"[object String]"===Object.prototype.toString.call(e)},Ad=function(e){return 0===t.Children.count(e)},Rd=function(e){return jd(e)&&Od(e.then)};function Md(e,t,n,r){void 0===r&&(r=0);for(var o=bd(t);e&&r=0?[]:{}}}return(0===a?e:o)[i[a]]===n?e:(void 0===n?delete o[i[a]]:o[i[a]]=n,0===a&&void 0===n&&delete r[i[a]],r)}function Nd(e,t,n,r){void 0===n&&(n=new WeakMap),void 0===r&&(r={});for(var o=0,a=Object.keys(e);o=n.length)break;a=n[o++]}else{if((o=n.next()).done)break;a=o.value}var i=a;Md(t,i.path)||(t=Id(t,i.path,i.message))}}return t}(n)):t(n)}))}))}),[p.validationSchema]),C=(0,t.useCallback)((function(e,t){return new Promise((function(n){return n(b.current[e].validate(t))}))}),[]),_=(0,t.useCallback)((function(e){var t=Object.keys(b.current).filter((function(e){return Od(b.current[e].validate)})),n=t.length>0?t.map((function(t){return C(t,Md(e,t))})):[Promise.resolve("DO_NOT_DELETE_YOU_WILL_BE_FIRED")];return Promise.all(n).then((function(e){return e.reduce((function(e,n,r){return"DO_NOT_DELETE_YOU_WILL_BE_FIRED"===n||n&&(e=Id(e,t[r],n)),e}),{})}))}),[C]),O=(0,t.useCallback)((function(e){return Promise.all([_(e),p.validationSchema?E(e):{},p.validate?S(e):{}]).then((function(e){var t=e[0],n=e[1],r=e[2];return Is.all([t,n,r],{arrayMerge:qd})}))}),[p.validate,p.validationSchema,_,S,E]),j=Kd((function(e){return void 0===e&&(e=w.values),k({type:"SET_ISVALIDATING",payload:!0}),O(e).then((function(e){return y.current&&(k({type:"SET_ISVALIDATING",payload:!1}),k({type:"SET_ERRORS",payload:e})),e}))}));(0,t.useEffect)((function(){s&&!0===y.current&&js()(h.current,p.initialValues)&&j(h.current)}),[s,j]);var P=(0,t.useCallback)((function(e){var t=e&&e.values?e.values:h.current,n=e&&e.errors?e.errors:v.current?v.current:p.initialErrors||{},r=e&&e.touched?e.touched:m.current?m.current:p.initialTouched||{},o=e&&e.status?e.status:g.current?g.current:p.initialStatus;h.current=t,v.current=n,m.current=r,g.current=o;var a=function(){k({type:"RESET_FORM",payload:{isSubmitting:!!e&&!!e.isSubmitting,errors:n,touched:r,status:o,values:t,isValidating:!!e&&!!e.isValidating,submitCount:e&&e.submitCount&&"number"===typeof e.submitCount?e.submitCount:0}})};if(p.onReset){var i=p.onReset(w.values,G);Rd(i)?i.then(a):a()}else a()}),[p.initialErrors,p.initialStatus,p.initialTouched]);(0,t.useEffect)((function(){!0!==y.current||js()(h.current,p.initialValues)||(u&&(h.current=p.initialValues,P()),s&&j(h.current))}),[u,p.initialValues,P,s,j]),(0,t.useEffect)((function(){u&&!0===y.current&&!js()(v.current,p.initialErrors)&&(v.current=p.initialErrors||Bd,k({type:"SET_ERRORS",payload:p.initialErrors||Bd}))}),[u,p.initialErrors]),(0,t.useEffect)((function(){u&&!0===y.current&&!js()(m.current,p.initialTouched)&&(m.current=p.initialTouched||Vd,k({type:"SET_TOUCHED",payload:p.initialTouched||Vd}))}),[u,p.initialTouched]),(0,t.useEffect)((function(){u&&!0===y.current&&!js()(g.current,p.initialStatus)&&(g.current=p.initialStatus,k({type:"SET_STATUS",payload:p.initialStatus}))}),[u,p.initialStatus,p.initialTouched]);var T=Kd((function(e){if(b.current[e]&&Od(b.current[e].validate)){var t=Md(w.values,e),n=b.current[e].validate(t);return Rd(n)?(k({type:"SET_ISVALIDATING",payload:!0}),n.then((function(e){return e})).then((function(t){k({type:"SET_FIELD_ERROR",payload:{field:e,value:t}}),k({type:"SET_ISVALIDATING",payload:!1})}))):(k({type:"SET_FIELD_ERROR",payload:{field:e,value:n}}),Promise.resolve(n))}return p.validationSchema?(k({type:"SET_ISVALIDATING",payload:!0}),E(w.values,e).then((function(e){return e})).then((function(t){k({type:"SET_FIELD_ERROR",payload:{field:e,value:t[e]}}),k({type:"SET_ISVALIDATING",payload:!1})}))):Promise.resolve()})),A=(0,t.useCallback)((function(e,t){var n=t.validate;b.current[e]={validate:n}}),[]),R=(0,t.useCallback)((function(e){delete b.current[e]}),[]),M=Kd((function(e,t){return k({type:"SET_TOUCHED",payload:e}),(void 0===t?a:t)?j(w.values):Promise.resolve()})),I=(0,t.useCallback)((function(e){k({type:"SET_ERRORS",payload:e})}),[]),N=Kd((function(e,t){var n=Od(e)?e(w.values):e;return k({type:"SET_VALUES",payload:n}),(void 0===t?r:t)?j(n):Promise.resolve()})),D=(0,t.useCallback)((function(e,t){k({type:"SET_FIELD_ERROR",payload:{field:e,value:t}})}),[]),F=Kd((function(e,t,n){return k({type:"SET_FIELD_VALUE",payload:{field:e,value:t}}),(void 0===n?r:n)?j(Id(w.values,e,t)):Promise.resolve()})),L=(0,t.useCallback)((function(e,t){var n,r=t,o=e;if(!Td(e)){e.persist&&e.persist();var a=e.target?e.target:e.currentTarget,i=a.type,s=a.name,c=a.id,l=a.value,u=a.checked,d=(a.outerHTML,a.options),f=a.multiple;r=t||(s||c),o=/number|range/.test(i)?(n=parseFloat(l),isNaN(n)?"":n):/checkbox/.test(i)?function(e,t,n){if("boolean"===typeof e)return Boolean(t);var r=[],o=!1,a=-1;if(Array.isArray(e))r=e,o=(a=e.indexOf(n))>=0;else if(!n||"true"==n||"false"==n)return Boolean(t);if(t&&n&&!o)return r.concat(n);if(!o)return r;return r.slice(0,a).concat(r.slice(a+1))}(Md(w.values,r),u,l):d&&f?function(e){return Array.from(e).filter((function(e){return e.selected})).map((function(e){return e.value}))}(d):l}r&&F(r,o)}),[F,w.values]),z=Kd((function(e){if(Td(e))return function(t){return L(t,e)};L(e)})),B=Kd((function(e,t,n){return void 0===t&&(t=!0),k({type:"SET_FIELD_TOUCHED",payload:{field:e,value:t}}),(void 0===n?a:n)?j(w.values):Promise.resolve()})),V=(0,t.useCallback)((function(e,t){e.persist&&e.persist();var n=e.target,r=n.name,o=n.id,a=(n.outerHTML,t||(r||o));B(a,!0)}),[B]),H=Kd((function(e){if(Td(e))return function(t){return V(t,e)};V(e)})),U=(0,t.useCallback)((function(e){Od(e)?k({type:"SET_FORMIK_STATE",payload:e}):k({type:"SET_FORMIK_STATE",payload:function(){return e}})}),[]),W=(0,t.useCallback)((function(e){k({type:"SET_STATUS",payload:e})}),[]),q=(0,t.useCallback)((function(e){k({type:"SET_ISSUBMITTING",payload:e})}),[]),$=Kd((function(){return k({type:"SUBMIT_ATTEMPT"}),j().then((function(e){var t=e instanceof Error;if(!t&&0===Object.keys(e).length){var n;try{if(void 0===(n=X()))return}catch(r){throw r}return Promise.resolve(n).then((function(e){return y.current&&k({type:"SUBMIT_SUCCESS"}),e})).catch((function(e){if(y.current)throw k({type:"SUBMIT_FAILURE"}),e}))}if(y.current&&(k({type:"SUBMIT_FAILURE"}),t))throw e}))})),K=Kd((function(e){e&&e.preventDefault&&Od(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&Od(e.stopPropagation)&&e.stopPropagation(),$().catch((function(e){console.warn("Warning: An unhandled error was caught from submitForm()",e)}))})),G={resetForm:P,validateForm:j,validateField:T,setErrors:I,setFieldError:D,setFieldTouched:B,setFieldValue:F,setStatus:W,setSubmitting:q,setTouched:M,setValues:N,setFormikState:U,submitForm:$},X=Kd((function(){return d(w.values,G)})),Y=Kd((function(e){e&&e.preventDefault&&Od(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&Od(e.stopPropagation)&&e.stopPropagation(),P()})),J=(0,t.useCallback)((function(e){return{value:Md(w.values,e),error:Md(w.errors,e),touched:!!Md(w.touched,e),initialValue:Md(h.current,e),initialTouched:!!Md(m.current,e),initialError:Md(v.current,e)}}),[w.errors,w.touched,w.values]),Q=(0,t.useCallback)((function(e){return{setValue:function(t,n){return F(e,t,n)},setTouched:function(t,n){return B(e,t,n)},setError:function(t){return D(e,t)}}}),[F,B,D]),Z=(0,t.useCallback)((function(e){var t=jd(e),n=t?e.name:e,r=Md(w.values,n),o={name:n,value:r,onChange:z,onBlur:H};if(t){var a=e.type,i=e.value,s=e.as,c=e.multiple;"checkbox"===a?void 0===i?o.checked=!!r:(o.checked=!(!Array.isArray(r)||!~r.indexOf(i)),o.value=i):"radio"===a?(o.checked=r===i,o.value=i):"select"===s&&c&&(o.value=o.value||[],o.multiple=!0)}return o}),[H,z,w.values]),ee=(0,t.useMemo)((function(){return!js()(h.current,w.values)}),[h.current,w.values]),te=(0,t.useMemo)((function(){return"undefined"!==typeof c?ee?w.errors&&0===Object.keys(w.errors).length:!1!==c&&Od(c)?c(p):c:w.errors&&0===Object.keys(w.errors).length}),[c,ee,w.errors,p]);return kd({},w,{initialValues:h.current,initialErrors:v.current,initialTouched:m.current,initialStatus:g.current,handleBlur:H,handleChange:z,handleReset:Y,handleSubmit:K,resetForm:P,setErrors:I,setFormikState:U,setFieldTouched:B,setFieldValue:F,setFieldError:D,setStatus:W,setSubmitting:q,setTouched:M,setValues:N,submitForm:$,validateForm:j,validateField:T,isValid:te,dirty:ee,unregisterField:R,registerField:A,getFieldProps:Z,getFieldMeta:J,getFieldHelpers:Q,validateOnBlur:a,validateOnChange:r,validateOnMount:s})}function Ud(e){var n=Hd(e),r=e.component,o=e.children,a=e.render,i=e.innerRef;return(0,t.useImperativeHandle)(i,(function(){return n})),(0,t.createElement)(Fd,{value:n},r?(0,t.createElement)(r,n):a?a(n):o?Od(o)?o(n):Ad(o)?null:t.Children.only(o):null)}function Wd(e){var t=Array.isArray(e)?[]:{};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=String(n);!0===Array.isArray(e[r])?t[r]=e[r].map((function(e){return!0===Array.isArray(e)||nc(e)?Wd(e):""!==e?e:void 0})):nc(e[r])?t[r]=Wd(e[r]):t[r]=""!==e[r]?e[r]:void 0}return t}function qd(e,t,n){var r=e.slice();return t.forEach((function(t,o){if("undefined"===typeof r[o]){var a=!1!==n.clone&&n.isMergeableObject(t);r[o]=a?Is(Array.isArray(t)?[]:{},t,n):t}else n.isMergeableObject(t)?r[o]=Is(e[o],t,n):-1===e.indexOf(t)&&r.push(t)})),r}var $d="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?t.useLayoutEffect:t.useEffect;function Kd(e){var n=(0,t.useRef)(e);return $d((function(){n.current=e})),(0,t.useCallback)((function(){for(var e=arguments.length,t=new Array(e),r=0;re?t:e}),0);return Array.from(kd({},e,{length:t+1}))}return[]},Qd=function(e){function n(t){var n;return(n=e.call(this,t)||this).updateArrayField=function(e,t,r){var o=n.props,a=o.name;(0,o.formik.setFormikState)((function(n){var o="function"===typeof r?r:e,i="function"===typeof t?t:e,s=Id(n.values,a,e(Md(n.values,a))),c=r?o(Md(n.errors,a)):void 0,l=t?i(Md(n.touched,a)):void 0;return _d(c)&&(c=void 0),_d(l)&&(l=void 0),kd({},n,{values:s,errors:r?Id(n.errors,a,c):n.errors,touched:t?Id(n.touched,a,l):n.touched})}))},n.push=function(e){return n.updateArrayField((function(t){return[].concat(Jd(t),[wd(e)])}),!1,!1)},n.handlePush=function(e){return function(){return n.push(e)}},n.swap=function(e,t){return n.updateArrayField((function(n){return function(e,t,n){var r=Jd(e),o=r[t];return r[t]=r[n],r[n]=o,r}(n,e,t)}),!0,!0)},n.handleSwap=function(e,t){return function(){return n.swap(e,t)}},n.move=function(e,t){return n.updateArrayField((function(n){return function(e,t,n){var r=Jd(e),o=r[t];return r.splice(t,1),r.splice(n,0,o),r}(n,e,t)}),!0,!0)},n.handleMove=function(e,t){return function(){return n.move(e,t)}},n.insert=function(e,t){return n.updateArrayField((function(n){return Yd(n,e,t)}),(function(t){return Yd(t,e,null)}),(function(t){return Yd(t,e,null)}))},n.handleInsert=function(e,t){return function(){return n.insert(e,t)}},n.replace=function(e,t){return n.updateArrayField((function(n){return function(e,t,n){var r=Jd(e);return r[t]=n,r}(n,e,t)}),!1,!1)},n.handleReplace=function(e,t){return function(){return n.replace(e,t)}},n.unshift=function(e){var t=-1;return n.updateArrayField((function(n){var r=n?[e].concat(n):[e];return t<0&&(t=r.length),r}),(function(e){var n=e?[null].concat(e):[null];return t<0&&(t=n.length),n}),(function(e){var n=e?[null].concat(e):[null];return t<0&&(t=n.length),n})),t},n.handleUnshift=function(e){return function(){return n.unshift(e)}},n.handleRemove=function(e){return function(){return n.remove(e)}},n.handlePop=function(){return function(){return n.pop()}},n.remove=n.remove.bind(Cd(n)),n.pop=n.pop.bind(Cd(n)),n}Sd(n,e);var r=n.prototype;return r.componentDidUpdate=function(e){this.props.validateOnChange&&this.props.formik.validateOnChange&&!js()(Md(e.formik.values,e.name),Md(this.props.formik.values,this.props.name))&&this.props.formik.validateForm(this.props.formik.values)},r.remove=function(e){var t;return this.updateArrayField((function(n){var r=n?Jd(n):[];return t||(t=r[e]),Od(r.splice)&&r.splice(e,1),r}),!0,!0),t},r.pop=function(){var e;return this.updateArrayField((function(t){var n=t;return e||(e=n&&n.pop&&n.pop()),n}),!0,!0),e},r.render=function(){var e={push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},n=this.props,r=n.component,o=n.render,a=n.children,i=n.name,s=kd({},e,{form:Ed(n.formik,["validate","validationSchema"]),name:i});return r?(0,t.createElement)(r,s):o?o(s):a?"function"===typeof a?a(s):Ad(a)?null:t.Children.only(a):null},n}(t.Component);Qd.defaultProps={validateOnChange:!0};t.Component,t.Component;var Zd=function(e){return(0,li.jsxs)(es,Zt(Zt({viewBox:"0 0 344.83 200"},e),{},{children:[(0,li.jsx)("path",{d:"M238.29,60.5c.43.75,1.21.2,1.82,0,17.63-4.33,35.28-3.19,52.79.63A137.45,137.45,0,0,1,330.16,75c1.78,1,17.19,25.73,14.09,27.23,3.3-1.6-8.7,13.45-8.7,13.45s-32.6,20.15-43.92,27.05c-17.57,10.7-33.75,24.14-48.81,39.8-12.32,12.81-23.74,26.77-32.37,44A139.48,139.48,0,0,0,200.8,252c-1.21,4.35-1.47,4.29-4.7,2.06-12.4-8.52-25-16.45-38.2-22.84-13.93-6.73-23.45-11.78-38.09-14.92-15.2-3.25-35.22-4.19-50.65-2.93a134.32,134.32,0,0,0-38.72,8.75,113.7,113.7,0,0,0-26,14.93A10.12,10.12,0,0,1,3,238.14c-.87.44-1.66,2.15-2.66,1-.77-.92.1-2.2.32-3.3a207.12,207.12,0,0,1,12.73-40.33c7.41-17.19,16.43-32.88,28-45.88,4.18-4.69,6.38-9.67,5.77-16.89-.53-6.2.38-12.51-.47-18.74a1.72,1.72,0,0,1,.75-2c2.28,3.58,4,7.72,6.35,11.32a118.47,118.47,0,0,0,20,23.3c10.93,10,23.25,16,35.85,21.29,12.41,5.21,24.77,10.57,36.61,17.67S169,200.89,178.69,212c2.88,3.3,17.34,24.54,19.75,20.76,9.65-15.2,25.36-61.86,91.54-113.88,16.93-13.31,21.44-18.13,24.3-19.49a14.89,14.89,0,0,0-4.2-4C289.54,82,267.91,74.89,244.72,76.86c-3.78.32-7.55,1-11.32,1.51a6.15,6.15,0,0,0-4.6,3.52c-3.66,6.69-6.74,13.84-10.06,20.8-8.18,17.15-42.19,87.55-43.51,85.56-1.81-2.74,1.24-6.68,5.27-16.78,8.15-20.41,32.42-92.35,35-97.14a4.37,4.37,0,0,0-.45-5.49,75.72,75.72,0,0,0-21.72-18.79c-13-7.81-16.66-9.44-23.82-10.9-1.29-.27-5.2-18.32-4.21-19.25s.74-.47,10.25,2.39a89.68,89.68,0,0,1,24.65,11.78,78.27,78.27,0,0,1,23.59,24.3"}),(0,li.jsx)("path",{d:"M160,51c-2.62-10.54.79-23.4-6.52-31.85C140.45,3.48,128.22-.75,102,.1c-44.69,1.46-70.16,71-52.62,100.43,15.62,36.92,61.57,58.6,98.14,40,11.09-7.15,3.77-26.7,5.77-38.3C156.5,85.12,163.45,69.59,160,51Z"})]}))},ef=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(t){a(t)}}function s(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},tf=function(e){var t;return t=e||("undefined"===typeof fetch?function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&void 0!==arguments[1]?arguments[1]:"FunctionsError",i=arguments.length>2?arguments[2]:void 0;return h(this,n),of((r=S(o=t.call(this,e)),w(n.prototype)),"name",a,r,!0),o.context=i,o}return y(n)}(A(Error)),ff=function(e){x(n,e);var t=C(n);function n(e){return h(this,n),t.call(this,"Failed to send a request to the Edge Function","FunctionsFetchError",e)}return y(n)}(df),pf=function(e){x(n,e);var t=C(n);function n(e){return h(this,n),t.call(this,"Relay Error invoking the Edge Function","FunctionsRelayError",e)}return y(n)}(df),hf=function(e){x(n,e);var t=C(n);function n(e){return h(this,n),t.call(this,"Edge Function returned a non-2xx status code","FunctionsHttpError",e)}return y(n)}(df),vf=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(t){a(t)}}function s(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},mf=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.headers,o=void 0===r?{}:r,a=n.customFetch;h(this,e),this.url=t,this.headers=o,this.fetch=tf(a)}return y(e,[{key:"setAuth",value:function(e){this.headers.Authorization="Bearer ".concat(e)}},{key:"invoke",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return vf(this,void 0,void 0,_().mark((function r(){var o,a,i,s,c,l,u,d;return _().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,o=n.headers,a=n.body,i={},a&&(o&&!Object.prototype.hasOwnProperty.call(o,"Content-Type")||!o)&&("undefined"!==typeof Blob&&a instanceof Blob||a instanceof ArrayBuffer?(i["Content-Type"]="application/octet-stream",s=a):"string"===typeof a?(i["Content-Type"]="text/plain",s=a):"undefined"!==typeof FormData&&a instanceof FormData?s=a:(i["Content-Type"]="application/json",s=JSON.stringify(a))),r.next=6,this.fetch("".concat(this.url,"/").concat(e),{method:"POST",headers:Object.assign(Object.assign(Object.assign({},i),this.headers),o),body:s}).catch((function(e){throw new ff(e)}));case 6:if(c=r.sent,!(l=c.headers.get("x-relay-error"))||"true"!==l){r.next=10;break}throw new pf(c);case 10:if(c.ok){r.next=12;break}throw new hf(c);case 12:if("application/json"!==(u=(null!==(t=c.headers.get("Content-Type"))&&void 0!==t?t:"text/plain").split(";")[0].trim())){r.next=19;break}return r.next=16,c.json();case 16:d=r.sent,r.next=34;break;case 19:if("application/octet-stream"!==u){r.next=25;break}return r.next=22,c.blob();case 22:d=r.sent,r.next=34;break;case 25:if("multipart/form-data"!==u){r.next=31;break}return r.next=28,c.formData();case 28:d=r.sent,r.next=34;break;case 31:return r.next=33,c.text();case 33:d=r.sent;case 34:return r.abrupt("return",{data:d,error:null});case 37:return r.prev=37,r.t0=r.catch(0),r.abrupt("return",{data:null,error:r.t0});case 40:case"end":return r.stop()}}),r,this,[[0,37]])})))}}]),e}(),gf=n(255),yf=n.n(gf),bf=function(){function e(t){h(this,e),this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=t.headers,this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=t.shouldThrowOnError,this.signal=t.signal,this.allowEmpty=t.allowEmpty,t.fetch?this.fetch=t.fetch:"undefined"===typeof fetch?this.fetch=yf():this.fetch=fetch}return y(e,[{key:"throwOnError",value:function(){return this.shouldThrowOnError=!0,this}},{key:"then",value:function(e,t){var n=this;void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),"GET"!==this.method&&"HEAD"!==this.method&&(this.headers["Content-Type"]="application/json");var r=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(function(){var e=j(_().mark((function e(t){var r,o,a,i,s,c,l,u,d,f,p,h,v;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null,s=null,c=null,l=t.status,u=t.statusText,!t.ok){e.next=16;break}if("HEAD"===n.method){e.next=11;break}return e.next=9,t.text();case 9:""===(d=e.sent)||(s="text/csv"===n.headers.Accept||n.headers.Accept&&n.headers.Accept.includes("application/vnd.pgrst.plan+text")?d:JSON.parse(d));case 11:f=null===(r=n.headers.Prefer)||void 0===r?void 0:r.match(/count=(exact|planned|estimated)/),p=null===(o=t.headers.get("content-range"))||void 0===o?void 0:o.split("/"),f&&p&&p.length>1&&(c=parseInt(p[1])),e.next=23;break;case 16:return e.next=18,t.text();case 18:h=e.sent;try{i=JSON.parse(h),Array.isArray(i)&&404===t.status&&(s=[],i=null,l=200,u="OK")}catch(Cg){404===t.status&&""===h?(l=204,u="No Content"):i={message:h}}if(i&&n.allowEmpty&&(null===(a=null===i||void 0===i?void 0:i.details)||void 0===a?void 0:a.includes("Results contain 0 rows"))&&(i=null,l=200,u="OK"),!i||!n.shouldThrowOnError){e.next=23;break}throw i;case 23:return v={error:i,data:s,count:c,status:l,statusText:u},e.abrupt("return",v);case 25:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());return this.shouldThrowOnError||(r=r.catch((function(e){return{error:{message:"FetchError: ".concat(e.message),details:"",hint:"",code:e.code||""},data:null,count:null,status:0,statusText:""}}))),r.then(e,t)}}]),e}(),xf=function(e){x(n,e);var t=C(n);function n(){return h(this,n),t.apply(this,arguments)}return y(n,[{key:"select",value:function(e){var t=!1,n=(null!==e&&void 0!==e?e:"*").split("").map((function(e){return/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)})).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}},{key:"order",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.ascending,r=void 0===n||n,o=t.nullsFirst,a=t.foreignTable,i=a?"".concat(a,".order"):"order",s=this.url.searchParams.get(i);return this.url.searchParams.set(i,"".concat(s?"".concat(s,","):"").concat(e,".").concat(r?"asc":"desc").concat(void 0===o?"":o?".nullsfirst":".nullslast")),this}},{key:"limit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.foreignTable,r="undefined"===typeof n?"limit":"".concat(n,".limit");return this.url.searchParams.set(r,"".concat(e)),this}},{key:"range",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.foreignTable,o="undefined"===typeof r?"offset":"".concat(r,".offset"),a="undefined"===typeof r?"limit":"".concat(r,".limit");return this.url.searchParams.set(o,"".concat(e)),this.url.searchParams.set(a,"".concat(t-e+1)),this}},{key:"abortSignal",value:function(e){return this.signal=e,this}},{key:"single",value:function(){return this.headers.Accept="application/vnd.pgrst.object+json",this}},{key:"maybeSingle",value:function(){return this.headers.Accept="application/vnd.pgrst.object+json",this.allowEmpty=!0,this}},{key:"csv",value:function(){return this.headers.Accept="text/csv",this}},{key:"geojson",value:function(){return this.headers.Accept="application/geo+json",this}},{key:"explain",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.analyze,n=void 0!==t&&t,r=e.verbose,o=void 0!==r&&r,a=e.settings,i=void 0!==a&&a,s=e.buffers,c=void 0!==s&&s,l=e.wal,u=void 0!==l&&l,d=e.format,f=void 0===d?"text":d,p=[n?"analyze":null,o?"verbose":null,i?"settings":null,c?"buffers":null,u?"wal":null].filter(Boolean).join("|"),h=this.headers.Accept;return this.headers.Accept="application/vnd.pgrst.plan+".concat(f,'; for="').concat(h,'"; options=').concat(p,";"),this}},{key:"rollback",value:function(){var e;return(null!==(e=this.headers.Prefer)&&void 0!==e?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}},{key:"returns",value:function(){return this}}]),n}(bf),wf=function(e){x(n,e);var t=C(n);function n(){return h(this,n),t.apply(this,arguments)}return y(n,[{key:"eq",value:function(e,t){return this.url.searchParams.append(e,"eq.".concat(t)),this}},{key:"neq",value:function(e,t){return this.url.searchParams.append(e,"neq.".concat(t)),this}},{key:"gt",value:function(e,t){return this.url.searchParams.append(e,"gt.".concat(t)),this}},{key:"gte",value:function(e,t){return this.url.searchParams.append(e,"gte.".concat(t)),this}},{key:"lt",value:function(e,t){return this.url.searchParams.append(e,"lt.".concat(t)),this}},{key:"lte",value:function(e,t){return this.url.searchParams.append(e,"lte.".concat(t)),this}},{key:"like",value:function(e,t){return this.url.searchParams.append(e,"like.".concat(t)),this}},{key:"ilike",value:function(e,t){return this.url.searchParams.append(e,"ilike.".concat(t)),this}},{key:"is",value:function(e,t){return this.url.searchParams.append(e,"is.".concat(t)),this}},{key:"in",value:function(e,t){var n=t.map((function(e){return"string"===typeof e&&new RegExp("[,()]").test(e)?'"'.concat(e,'"'):"".concat(e)})).join(",");return this.url.searchParams.append(e,"in.(".concat(n,")")),this}},{key:"contains",value:function(e,t){return"string"===typeof t?this.url.searchParams.append(e,"cs.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cs.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cs.".concat(JSON.stringify(t))),this}},{key:"containedBy",value:function(e,t){return"string"===typeof t?this.url.searchParams.append(e,"cd.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cd.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cd.".concat(JSON.stringify(t))),this}},{key:"rangeGt",value:function(e,t){return this.url.searchParams.append(e,"sr.".concat(t)),this}},{key:"rangeGte",value:function(e,t){return this.url.searchParams.append(e,"nxl.".concat(t)),this}},{key:"rangeLt",value:function(e,t){return this.url.searchParams.append(e,"sl.".concat(t)),this}},{key:"rangeLte",value:function(e,t){return this.url.searchParams.append(e,"nxr.".concat(t)),this}},{key:"rangeAdjacent",value:function(e,t){return this.url.searchParams.append(e,"adj.".concat(t)),this}},{key:"overlaps",value:function(e,t){return"string"===typeof t?this.url.searchParams.append(e,"ov.".concat(t)):this.url.searchParams.append(e,"ov.{".concat(t.join(","),"}")),this}},{key:"textSearch",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.config,o=n.type,a="";"plain"===o?a="pl":"phrase"===o?a="ph":"websearch"===o&&(a="w");var i=void 0===r?"":"(".concat(r,")");return this.url.searchParams.append(e,"".concat(a,"fts").concat(i,".").concat(t)),this}},{key:"match",value:function(e){var t=this;return Object.entries(e).forEach((function(e){var n=u(e,2),r=n[0],o=n[1];t.url.searchParams.append(r,"eq.".concat(o))})),this}},{key:"not",value:function(e,t,n){return this.url.searchParams.append(e,"not.".concat(t,".").concat(n)),this}},{key:"or",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.foreignTable,r=n?"".concat(n,".or"):"or";return this.url.searchParams.append(r,"(".concat(e,")")),this}},{key:"filter",value:function(e,t,n){return this.url.searchParams.append(e,"".concat(t,".").concat(n)),this}}]),n}(xf),kf=function(){function e(t,n){var r=n.headers,o=void 0===r?{}:r,a=n.schema,i=n.fetch;h(this,e),this.url=t,this.headers=o,this.schema=a,this.fetch=i}return y(e,[{key:"select",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.head,r=void 0!==n&&n,o=t.count,a=r?"HEAD":"GET",i=!1,s=(null!==e&&void 0!==e?e:"*").split("").map((function(e){return/\s/.test(e)&&!i?"":('"'===e&&(i=!i),e)})).join("");return this.url.searchParams.set("select",s),o&&(this.headers.Prefer="count=".concat(o)),new wf({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}},{key:"insert",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.count,r="POST",o=[],a=e;if(n&&o.push("count=".concat(n)),this.headers.Prefer&&o.unshift(this.headers.Prefer),this.headers.Prefer=o.join(","),Array.isArray(e)){var i=e.reduce((function(e,t){return e.concat(Object.keys(t))}),[]);if(i.length>0){var s=p(new Set(i)).map((function(e){return'"'.concat(e,'"')}));this.url.searchParams.set("columns",s.join(","))}}return new wf({method:r,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:this.fetch,allowEmpty:!1})}},{key:"upsert",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.onConflict,r=t.ignoreDuplicates,o=void 0!==r&&r,a=t.count,i="POST",s=["resolution=".concat(o?"ignore":"merge","-duplicates")];void 0!==n&&this.url.searchParams.set("on_conflict",n);var c=e;return a&&s.push("count=".concat(a)),this.headers.Prefer&&s.unshift(this.headers.Prefer),this.headers.Prefer=s.join(","),new wf({method:i,url:this.url,headers:this.headers,schema:this.schema,body:c,fetch:this.fetch,allowEmpty:!1})}},{key:"update",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.count,r="PATCH",o=[],a=e;return n&&o.push("count=".concat(n)),this.headers.Prefer&&o.unshift(this.headers.Prefer),this.headers.Prefer=o.join(","),new wf({method:r,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:this.fetch,allowEmpty:!1})}},{key:"delete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.count,n="DELETE",r=[];return t&&r.push("count=".concat(t)),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),new wf({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}]),e}(),Sf={"X-Client-Info":"postgrest-js/".concat("1.3.0")},Ef=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.headers,o=void 0===r?{}:r,a=n.schema,i=n.fetch;h(this,e),this.url=t,this.headers=Object.assign(Object.assign({},Sf),o),this.schema=a,this.fetch=i}return y(e,[{key:"from",value:function(e){var t=new URL("".concat(this.url,"/").concat(e));return new kf(t,{headers:Object.assign({},this.headers),schema:this.schema,fetch:this.fetch})}},{key:"rpc",value:function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=o.head,i=void 0!==a&&a,s=o.count,c=new URL("".concat(this.url,"/rpc/").concat(e));i?(t="HEAD",Object.entries(r).forEach((function(e){var t=u(e,2),n=t[0],r=t[1];c.searchParams.append(n,"".concat(r))}))):(t="POST",n=r);var l=Object.assign({},this.headers);return s&&(l.Prefer="count=".concat(s)),new wf({method:t,url:c,headers:l,schema:this.schema,body:n,fetch:this.fetch,allowEmpty:!1})}}]),e}(),Cf=n(87),_f={"X-Client-Info":"realtime-js/".concat("2.4.0")},Of=1e4;!function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"}(af||(af={})),function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"}(sf||(sf={})),function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"}(cf||(cf={})),function(e){e.websocket="websocket"}(lf||(lf={})),function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"}(uf||(uf={}));var jf,Pf=function(){function e(t,n){h(this,e),this.callback=t,this.timerCalc=n,this.timer=void 0,this.tries=0,this.callback=t,this.timerCalc=n}return y(e,[{key:"reset",value:function(){this.tries=0,clearTimeout(this.timer)}},{key:"scheduleTimeout",value:function(){var e=this;clearTimeout(this.timer),this.timer=setTimeout((function(){e.tries=e.tries+1,e.callback()}),this.timerCalc(this.tries+1))}}]),e}(),Tf=function(){function e(){h(this,e),this.HEADER_LENGTH=1}return y(e,[{key:"decode",value:function(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t("string"===typeof e?JSON.parse(e):{})}},{key:"_binaryDecode",value:function(e){var t=new DataView(e),n=new TextDecoder;return this._decodeBroadcast(e,t,n)}},{key:"_decodeBroadcast",value:function(e,t,n){var r=t.getUint8(1),o=t.getUint8(2),a=this.HEADER_LENGTH+2,i=n.decode(e.slice(a,a+r));a+=r;var s=n.decode(e.slice(a,a+o));return a+=o,{ref:null,topic:i,event:s,payload:JSON.parse(n.decode(e.slice(a,e.byteLength)))}}}]),e}(),Af=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Of;h(this,e),this.channel=t,this.event=n,this.payload=r,this.timeout=o,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null,this.rateLimited=!1}return y(e,[{key:"resend",value:function(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}},{key:"send",value:function(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,"rate limited"===this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()})&&(this.rateLimited=!0))}},{key:"updatePayload",value:function(e){this.payload=Object.assign(Object.assign({},this.payload),e)}},{key:"receive",value:function(e,t){var n;return this._hasReceived(e)&&t(null===(n=this.receivedResp)||void 0===n?void 0:n.response),this.recHooks.push({status:e,callback:t}),this}},{key:"startTimeout",value:function(){var e=this;if(!this.timeoutTimer){this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);this.channel._on(this.refEvent,{},(function(t){e._cancelRefEvent(),e._cancelTimeout(),e.receivedResp=t,e._matchReceive(t)})),this.timeoutTimer=setTimeout((function(){e.trigger("timeout",{})}),this.timeout)}}},{key:"trigger",value:function(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}},{key:"destroy",value:function(){this._cancelRefEvent(),this._cancelTimeout()}},{key:"_cancelRefEvent",value:function(){this.refEvent&&this.channel._off(this.refEvent,{})}},{key:"_cancelTimeout",value:function(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}},{key:"_matchReceive",value:function(e){var t=e.status,n=e.response;this.recHooks.filter((function(e){return e.status===t})).forEach((function(e){return e.callback(n)}))}},{key:"_hasReceived",value:function(e){return this.receivedResp&&this.receivedResp.status===e}}]),e}();!function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"}(jf||(jf={}));var Rf,Mf=function(){function e(t,n){var r=this;h(this,e),this.channel=t,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}};var o=(null===n||void 0===n?void 0:n.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(o.state,{},(function(t){var n=r.caller,o=n.onJoin,a=n.onLeave,i=n.onSync;r.joinRef=r.channel._joinRef(),r.state=e.syncState(r.state,t,o,a),r.pendingDiffs.forEach((function(t){r.state=e.syncDiff(r.state,t,o,a)})),r.pendingDiffs=[],i()})),this.channel._on(o.diff,{},(function(t){var n=r.caller,o=n.onJoin,a=n.onLeave,i=n.onSync;r.inPendingSyncState()?r.pendingDiffs.push(t):(r.state=e.syncDiff(r.state,t,o,a),i())})),this.onJoin((function(e,t,n){r.channel._trigger("presence",{event:"join",key:e,currentPresences:t,newPresences:n})})),this.onLeave((function(e,t,n){r.channel._trigger("presence",{event:"leave",key:e,currentPresences:t,leftPresences:n})})),this.onSync((function(){r.channel._trigger("presence",{event:"sync"})}))}return y(e,[{key:"onJoin",value:function(e){this.caller.onJoin=e}},{key:"onLeave",value:function(e){this.caller.onLeave=e}},{key:"onSync",value:function(e){this.caller.onSync=e}},{key:"inPendingSyncState",value:function(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}],[{key:"syncState",value:function(e,t,n,r){var o=this.cloneDeep(e),a=this.transformState(t),i={},s={};return this.map(o,(function(e,t){a[e]||(s[e]=t)})),this.map(a,(function(e,t){var n=o[e];if(n){var r=t.map((function(e){return e.presence_ref})),a=n.map((function(e){return e.presence_ref})),c=t.filter((function(e){return a.indexOf(e.presence_ref)<0})),l=n.filter((function(e){return r.indexOf(e.presence_ref)<0}));c.length>0&&(i[e]=c),l.length>0&&(s[e]=l)}else i[e]=t})),this.syncDiff(o,{joins:i,leaves:s},n,r)}},{key:"syncDiff",value:function(e,t,n,r){var o=this,a={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)},i=a.joins,s=a.leaves;return n||(n=function(){}),r||(r=function(){}),this.map(i,(function(t,r){var a,i=null!==(a=e[t])&&void 0!==a?a:[];if(e[t]=o.cloneDeep(r),i.length>0){var s,c=e[t].map((function(e){return e.presence_ref})),l=i.filter((function(e){return c.indexOf(e.presence_ref)<0}));(s=e[t]).unshift.apply(s,p(l))}n(t,i,r)})),this.map(s,(function(t,n){var o=e[t];if(o){var a=n.map((function(e){return e.presence_ref}));o=o.filter((function(e){return a.indexOf(e.presence_ref)<0})),e[t]=o,r(t,o,n),0===o.length&&delete e[t]}})),e}},{key:"map",value:function(e,t){return Object.getOwnPropertyNames(e).map((function(n){return t(n,e[n])}))}},{key:"transformState",value:function(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((function(t,n){var r=e[n];return t[n]="metas"in r?r.metas.map((function(e){return e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e})):r,t}),{})}},{key:"cloneDeep",value:function(e){return JSON.parse(JSON.stringify(e))}}]),e}();!function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"}(Rf||(Rf={}));var If,Nf,Df,Ff=function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=null!==(n=r.skipTypes)&&void 0!==n?n:[];return Object.keys(t).reduce((function(n,r){return n[r]=Lf(r,e,t,o),n}),{})},Lf=function(e,t,n,r){var o=t.find((function(t){return t.name===e})),a=null===o||void 0===o?void 0:o.type,i=n[e];return a&&!r.includes(a)?zf(a,i):Bf(i)},zf=function(e,t){if("_"===e.charAt(0)){var n=e.slice(1,e.length);return Wf(t,n)}switch(e){case Rf.bool:return Vf(t);case Rf.float4:case Rf.float8:case Rf.int2:case Rf.int4:case Rf.int8:case Rf.numeric:case Rf.oid:return Hf(t);case Rf.json:case Rf.jsonb:return Uf(t);case Rf.timestamp:return qf(t);case Rf.abstime:case Rf.date:case Rf.daterange:case Rf.int4range:case Rf.int8range:case Rf.money:case Rf.reltime:case Rf.text:case Rf.time:case Rf.timestamptz:case Rf.timetz:case Rf.tsrange:case Rf.tstzrange:default:return Bf(t)}},Bf=function(e){return e},Vf=function(e){switch(e){case"t":return!0;case"f":return!1;default:return e}},Hf=function(e){if("string"===typeof e){var t=parseFloat(e);if(!Number.isNaN(t))return t}return e},Uf=function(e){if("string"===typeof e)try{return JSON.parse(e)}catch(t){return console.log("JSON parse error: ".concat(t)),e}return e},Wf=function(e,t){if("string"!==typeof e)return e;var n=e.length-1,r=e[n];if("{"===e[0]&&"}"===r){var o,a=e.slice(1,n);try{o=JSON.parse("["+a+"]")}catch(i){o=a?a.split(","):[]}return o.map((function(e){return zf(t,e)}))}return e},qf=function(e){return"string"===typeof e?e.replace(" ","T"):e},$f=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(t){a(t)}}function s(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))};!function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"}(If||(If={})),function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes"}(Nf||(Nf={})),function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"}(Df||(Df={}));var Kf=function(){function e(t){var n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}},o=arguments.length>2?arguments[2]:void 0;h(this,e),this.topic=t,this.params=r,this.socket=o,this.bindings={},this.state=sf.closed,this.joinedOnce=!1,this.pushBuffer=[],this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},r.config),this.timeout=this.socket.timeout,this.joinPush=new Af(this,cf.join,this.params,this.timeout),this.rejoinTimer=new Pf((function(){return n._rejoinUntilConnected()}),this.socket.reconnectAfterMs),this.joinPush.receive("ok",(function(){n.state=sf.joined,n.rejoinTimer.reset(),n.pushBuffer.forEach((function(e){return e.send()})),n.pushBuffer=[]})),this._onClose((function(){n.rejoinTimer.reset(),n.socket.log("channel","close ".concat(n.topic," ").concat(n._joinRef())),n.state=sf.closed,n.socket._remove(n)})),this._onError((function(e){n._isLeaving()||n._isClosed()||(n.socket.log("channel","error ".concat(n.topic),e),n.state=sf.errored,n.rejoinTimer.scheduleTimeout())})),this.joinPush.receive("timeout",(function(){n._isJoining()&&(n.socket.log("channel","timeout ".concat(n.topic),n.joinPush.timeout),n.state=sf.errored,n.rejoinTimer.scheduleTimeout())})),this._on(cf.reply,{},(function(e,t){n._trigger(n._replyEventName(t),e)})),this.presence=new Mf(this)}return y(e,[{key:"subscribe",value:function(e){var t,n,r=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.timeout;if(this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";var a=this.params.config,i=a.broadcast,s=a.presence;this._onError((function(t){return e&&e("CHANNEL_ERROR",t)})),this._onClose((function(){return e&&e("CLOSED")}));var c={},l={broadcast:i,presence:s,postgres_changes:null!==(n=null===(t=this.bindings.postgres_changes)||void 0===t?void 0:t.map((function(e){return e.filter})))&&void 0!==n?n:[]};return this.socket.accessToken&&(c.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:l},c)),this.joinedOnce=!0,this._rejoin(o),this.joinPush.receive("ok",(function(t){var n,o=t.postgres_changes;if(r.socket.accessToken&&r.socket.setAuth(r.socket.accessToken),void 0!==o){for(var a=r.bindings.postgres_changes,i=null!==(n=null===a||void 0===a?void 0:a.length)&&void 0!==n?n:0,s=[],c=0;c1&&void 0!==arguments[1]?arguments[1]:{};return $f(this,void 0,void 0,_().mark((function n(){return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n,this)})))}},{key:"untrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return $f(this,void 0,void 0,_().mark((function t(){return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.send({type:"presence",event:"untrack"},e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"on",value:function(e,t,n){return this._on(e,t,n)}},{key:"send",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(r){var o,a,i,s=t._push(e.type,e,n.timeout||t.timeout);s.rateLimited&&r("rate limited"),"broadcast"!==e.type||(null===(i=null===(a=null===(o=t.params)||void 0===o?void 0:o.config)||void 0===a?void 0:a.broadcast)||void 0===i?void 0:i.ack)||r("ok"),s.receive("ok",(function(){return r("ok")})),s.receive("timeout",(function(){return r("timed out")}))}))}},{key:"updateJoinPayload",value:function(e){this.joinPush.updatePayload(e)}},{key:"unsubscribe",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this.state=sf.leaving;var n=function(){e.socket.log("channel","leave ".concat(e.topic)),e._trigger(cf.close,"leave",e._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise((function(r){var o=new Af(e,cf.leave,{},t);o.receive("ok",(function(){n(),r("ok")})).receive("timeout",(function(){n(),r("timed out")})).receive("error",(function(){r("error")})),o.send(),e._canPush()||o.trigger("ok",{})}))}},{key:"_push",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.timeout;if(!this.joinedOnce)throw"tried to push '".concat(e,"' to '").concat(this.topic,"' before joining. Use channel.subscribe() before pushing events");var r=new Af(this,e,t,n);return this._canPush()?r.send():(r.startTimeout(),this.pushBuffer.push(r)),r}},{key:"_onMessage",value:function(e,t,n){return t}},{key:"_isMember",value:function(e){return this.topic===e}},{key:"_joinRef",value:function(){return this.joinPush.ref}},{key:"_trigger",value:function(e,t,n){var r,o,a=this,i=e.toLocaleLowerCase(),s=cf.close,c=cf.error,l=cf.leave,u=cf.join;if(!(n&&[s,c,l,u].indexOf(i)>=0&&n!==this._joinRef())){var d=this._onMessage(i,t,n);if(t&&!d)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(i)?null===(r=this.bindings.postgres_changes)||void 0===r||r.filter((function(e){var t,n,r;return"*"===(null===(t=e.filter)||void 0===t?void 0:t.event)||(null===(r=null===(n=e.filter)||void 0===n?void 0:n.event)||void 0===r?void 0:r.toLocaleLowerCase())===i})).map((function(e){return e.callback(d,n)})):null===(o=this.bindings[i])||void 0===o||o.filter((function(e){var n,r,o,a,s,c;if(["broadcast","presence","postgres_changes"].includes(i)){if("id"in e){var l=e.id,u=null===(n=e.filter)||void 0===n?void 0:n.event;return l&&(null===(r=t.ids)||void 0===r?void 0:r.includes(l))&&("*"===u||(null===u||void 0===u?void 0:u.toLocaleLowerCase())===(null===(o=t.data)||void 0===o?void 0:o.type.toLocaleLowerCase()))}var d=null===(s=null===(a=null===e||void 0===e?void 0:e.filter)||void 0===a?void 0:a.event)||void 0===s?void 0:s.toLocaleLowerCase();return"*"===d||d===(null===(c=null===t||void 0===t?void 0:t.event)||void 0===c?void 0:c.toLocaleLowerCase())}return e.type.toLocaleLowerCase()===i})).map((function(e){if("object"===typeof d&&"ids"in d){var t=d.data,r={schema:t.schema,table:t.table,commit_timestamp:t.commit_timestamp,eventType:t.type,new:{},old:{},errors:t.errors};d=Object.assign(Object.assign({},r),a._getPayloadRecords(t))}e.callback(d,n)}))}}},{key:"_isClosed",value:function(){return this.state===sf.closed}},{key:"_isJoined",value:function(){return this.state===sf.joined}},{key:"_isJoining",value:function(){return this.state===sf.joining}},{key:"_isLeaving",value:function(){return this.state===sf.leaving}},{key:"_replyEventName",value:function(e){return"chan_reply_".concat(e)}},{key:"_on",value:function(e,t,n){var r=e.toLocaleLowerCase(),o={type:r,filter:t,callback:n};return this.bindings[r]?this.bindings[r].push(o):this.bindings[r]=[o],this}},{key:"_off",value:function(t,n){var r=t.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter((function(t){var o;return!((null===(o=t.type)||void 0===o?void 0:o.toLocaleLowerCase())===r&&e.isEqual(t.filter,n))})),this}},{key:"_rejoinUntilConnected",value:function(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}},{key:"_onClose",value:function(e){this._on(cf.close,{},e)}},{key:"_onError",value:function(e){this._on(cf.error,{},(function(t){return e(t)}))}},{key:"_canPush",value:function(){return this.socket.isConnected()&&this._isJoined()}},{key:"_rejoin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=sf.joining,this.joinPush.resend(e))}},{key:"_getPayloadRecords",value:function(e){var t={new:{},old:{}};return"INSERT"!==e.type&&"UPDATE"!==e.type||(t.new=Ff(e.columns,e.record)),"UPDATE"!==e.type&&"DELETE"!==e.type||(t.old=Ff(e.columns,e.old_record)),t}}],[{key:"isEqual",value:function(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n in e)if(e[n]!==t[n])return!1;return!0}}]),e}(),Gf=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(t){a(t)}}function s(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},Xf=function(){},Yf=function(){function e(t,n){var r,o=this;h(this,e),this.accessToken=null,this.channels=[],this.endPoint="",this.headers=_f,this.params={},this.timeout=Of,this.transport=Cf.w3cwebsocket,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=Xf,this.conn=null,this.sendBuffer=[],this.serializer=new Tf,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.eventsPerSecondLimitMs=100,this.inThrottle=!1,this.endPoint="".concat(t,"/").concat(lf.websocket),(null===n||void 0===n?void 0:n.params)&&(this.params=n.params),(null===n||void 0===n?void 0:n.headers)&&(this.headers=Object.assign(Object.assign({},this.headers),n.headers)),(null===n||void 0===n?void 0:n.timeout)&&(this.timeout=n.timeout),(null===n||void 0===n?void 0:n.logger)&&(this.logger=n.logger),(null===n||void 0===n?void 0:n.transport)&&(this.transport=n.transport),(null===n||void 0===n?void 0:n.heartbeatIntervalMs)&&(this.heartbeatIntervalMs=n.heartbeatIntervalMs);var a=null===(r=null===n||void 0===n?void 0:n.params)||void 0===r?void 0:r.eventsPerSecond;a&&(this.eventsPerSecondLimitMs=Math.floor(1e3/a)),this.reconnectAfterMs=(null===n||void 0===n?void 0:n.reconnectAfterMs)?n.reconnectAfterMs:function(e){return[1e3,2e3,5e3,1e4][e-1]||1e4},this.encode=(null===n||void 0===n?void 0:n.encode)?n.encode:function(e,t){return t(JSON.stringify(e))},this.decode=(null===n||void 0===n?void 0:n.decode)?n.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new Pf((function(){return Gf(o,void 0,void 0,_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.disconnect(),this.connect();case 2:case"end":return e.stop()}}),e,this)})))}),this.reconnectAfterMs)}return y(e,[{key:"connect",value:function(){var e=this;this.conn||(this.conn=new this.transport(this._endPointURL(),[],null,this.headers),this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=function(){return e._onConnOpen()},this.conn.onerror=function(t){return e._onConnError(t)},this.conn.onmessage=function(t){return e._onConnMessage(t)},this.conn.onclose=function(t){return e._onConnClose(t)}))}},{key:"disconnect",value:function(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,null!==t&&void 0!==t?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}},{key:"getChannels",value:function(){return this.channels}},{key:"removeChannel",value:function(e){var t=this;return e.unsubscribe().then((function(e){return 0===t.channels.length&&t.disconnect(),e}))}},{key:"removeAllChannels",value:function(){var e=this;return Promise.all(this.channels.map((function(e){return e.unsubscribe()}))).then((function(t){return e.disconnect(),t}))}},{key:"log",value:function(e,t,n){this.logger(e,t,n)}},{key:"connectionState",value:function(){switch(this.conn&&this.conn.readyState){case af.connecting:return uf.Connecting;case af.open:return uf.Open;case af.closing:return uf.Closing;default:return uf.Closed}}},{key:"isConnected",value:function(){return this.connectionState()===uf.Open}},{key:"channel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}};this.isConnected()||this.connect();var n=new Kf("realtime:".concat(e),t,this);return this.channels.push(n),n}},{key:"push",value:function(e){var t=this,n=e.topic,r=e.event,o=e.payload,a=e.ref,i=function(){t.encode(e,(function(e){var n;null===(n=t.conn)||void 0===n||n.send(e)}))};if(this.log("push","".concat(n," ").concat(r," (").concat(a,")"),o),this.isConnected())if(["broadcast","presence","postgres_changes"].includes(r)){if(this._throttle(i)())return"rate limited"}else i();else this.sendBuffer.push(i)}},{key:"setAuth",value:function(e){this.accessToken=e,this.channels.forEach((function(t){e&&t.updateJoinPayload({access_token:e}),t.joinedOnce&&t._isJoined()&&t._push(cf.access_token,{access_token:e})}))}},{key:"_makeRef",value:function(){var e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}},{key:"_leaveOpenTopic",value:function(e){var t=this.channels.find((function(t){return t.topic===e&&(t._isJoined()||t._isJoining())}));t&&(this.log("transport",'leaving duplicate topic "'.concat(e,'"')),t.unsubscribe())}},{key:"_remove",value:function(e){this.channels=this.channels.filter((function(t){return t._joinRef()!==e._joinRef()}))}},{key:"_endPointURL",value:function(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:"1.0.0"}))}},{key:"_onConnMessage",value:function(e){var t=this;this.decode(e.data,(function(e){var n=e.topic,r=e.event,o=e.payload,a=e.ref;(a&&a===t.pendingHeartbeatRef||r===(null===o||void 0===o?void 0:o.type))&&(t.pendingHeartbeatRef=null),t.log("receive","".concat(o.status||""," ").concat(n," ").concat(r," ").concat(a&&"("+a+")"||""),o),t.channels.filter((function(e){return e._isMember(n)})).forEach((function(e){return e._trigger(r,o,a)})),t.stateChangeCallbacks.message.forEach((function(t){return t(e)}))}))}},{key:"_onConnOpen",value:function(){var e=this;this.log("transport","connected to ".concat(this._endPointURL())),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval((function(){return e._sendHeartbeat()}),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach((function(e){return e()}))}},{key:"_onConnClose",value:function(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach((function(t){return t(e)}))}},{key:"_onConnError",value:function(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach((function(t){return t(e)}))}},{key:"_triggerChanError",value:function(){this.channels.forEach((function(e){return e._trigger(cf.error)}))}},{key:"_appendParams",value:function(e,t){if(0===Object.keys(t).length)return e;var n=e.match(/\?/)?"&":"?",r=new URLSearchParams(t);return"".concat(e).concat(n).concat(r)}},{key:"_flushSendBuffer",value:function(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach((function(e){return e()})),this.sendBuffer=[])}},{key:"_sendHeartbeat",value:function(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef)return this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),void(null===(e=this.conn)||void 0===e||e.close(1e3,"hearbeat timeout"));this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}},{key:"_throttle",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.eventsPerSecondLimitMs;return function(){return!!t.inThrottle||(e(),n>0&&(t.inThrottle=!0,setTimeout((function(){t.inThrottle=!1}),n)),!1)}}}]),e}(),Jf=function(e){x(n,e);var t=C(n);function n(e){var r;return h(this,n),(r=t.call(this,e)).__isStorageError=!0,r.name="StorageError",r}return y(n)}(A(Error));function Qf(e){return"object"===typeof e&&null!==e&&"__isStorageError"in e}var Zf=function(e){x(n,e);var t=C(n);function n(e,r){var o;return h(this,n),(o=t.call(this,e)).name="StorageApiError",o.status=r,o}return y(n,[{key:"toJSON",value:function(){return{name:this.name,message:this.message,status:this.status}}}]),n}(Jf),ep=function(e){x(n,e);var t=C(n);function n(e,r){var o;return h(this,n),(o=t.call(this,e)).name="StorageUnknownError",o.originalError=r,o}return y(n)}(Jf),tp=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(t){a(t)}}function s(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},np=function(e){var t;return t=e||("undefined"===typeof fetch?function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0;h(this,e),this.url=t,this.headers=n,this.bucketId=r,this.fetch=np(o)}return y(e,[{key:"uploadOrUpdate",value:function(e,t,n,r){return fp(this,void 0,void 0,_().mark((function o(){var a,i,s,c,l,u,d;return _().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,i=Object.assign(Object.assign({},hp),r),s=Object.assign(Object.assign({},this.headers),"POST"===e&&{"x-upsert":String(i.upsert)}),"undefined"!==typeof Blob&&n instanceof Blob?((a=new FormData).append("cacheControl",i.cacheControl),a.append("",n)):"undefined"!==typeof FormData&&n instanceof FormData?(a=n).append("cacheControl",i.cacheControl):(a=n,s["cache-control"]="max-age=".concat(i.cacheControl),s["content-type"]=i.contentType),c=this._removeEmptyFolders(t),l=this._getFinalPath(c),o.next=8,this.fetch("".concat(this.url,"/object/").concat(l),{method:e,body:a,headers:s});case 8:if(!(u=o.sent).ok){o.next=13;break}return o.abrupt("return",{data:{path:c},error:null});case 13:return o.next=15,u.json();case 15:return d=o.sent,o.abrupt("return",{data:null,error:d});case 17:o.next=24;break;case 19:if(o.prev=19,o.t0=o.catch(0),!Qf(o.t0)){o.next=23;break}return o.abrupt("return",{data:null,error:o.t0});case 23:throw o.t0;case 24:case"end":return o.stop()}}),o,this,[[0,19]])})))}},{key:"upload",value:function(e,t,n){return fp(this,void 0,void 0,_().mark((function r(){return _().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.uploadOrUpdate("POST",e,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"update",value:function(e,t,n){return fp(this,void 0,void 0,_().mark((function r(){return _().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.uploadOrUpdate("PUT",e,t,n));case 1:case"end":return r.stop()}}),r,this)})))}},{key:"move",value:function(e,t){return fp(this,void 0,void 0,_().mark((function n(){var r;return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,lp(this.fetch,"".concat(this.url,"/object/move"),{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers});case 3:return r=n.sent,n.abrupt("return",{data:r,error:null});case 7:if(n.prev=7,n.t0=n.catch(0),!Qf(n.t0)){n.next=11;break}return n.abrupt("return",{data:null,error:n.t0});case 11:throw n.t0;case 12:case"end":return n.stop()}}),n,this,[[0,7]])})))}},{key:"copy",value:function(e,t){return fp(this,void 0,void 0,_().mark((function n(){var r;return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,lp(this.fetch,"".concat(this.url,"/object/copy"),{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers});case 3:return r=n.sent,n.abrupt("return",{data:{path:r.Key},error:null});case 7:if(n.prev=7,n.t0=n.catch(0),!Qf(n.t0)){n.next=11;break}return n.abrupt("return",{data:null,error:n.t0});case 11:throw n.t0;case 12:case"end":return n.stop()}}),n,this,[[0,7]])})))}},{key:"createSignedUrl",value:function(e,t,n){return fp(this,void 0,void 0,_().mark((function r(){var o,a,i,s;return _().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,o=this._getFinalPath(e),r.next=4,lp(this.fetch,"".concat(this.url,"/object/sign/").concat(o),Object.assign({expiresIn:t},(null===n||void 0===n?void 0:n.transform)?{transform:n.transform}:{}),{headers:this.headers});case 4:return a=r.sent,i=(null===n||void 0===n?void 0:n.download)?"&download=".concat(!0===n.download?"":n.download):"",s=encodeURI("".concat(this.url).concat(a.signedURL).concat(i)),a={signedUrl:s},r.abrupt("return",{data:a,error:null});case 11:if(r.prev=11,r.t0=r.catch(0),!Qf(r.t0)){r.next=15;break}return r.abrupt("return",{data:null,error:r.t0});case 15:throw r.t0;case 16:case"end":return r.stop()}}),r,this,[[0,11]])})))}},{key:"createSignedUrls",value:function(e,t,n){return fp(this,void 0,void 0,_().mark((function r(){var o,a,i=this;return _().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,lp(this.fetch,"".concat(this.url,"/object/sign/").concat(this.bucketId),{expiresIn:t,paths:e},{headers:this.headers});case 3:return o=r.sent,a=(null===n||void 0===n?void 0:n.download)?"&download=".concat(!0===n.download?"":n.download):"",r.abrupt("return",{data:o.map((function(e){return Object.assign(Object.assign({},e),{signedUrl:e.signedURL?encodeURI("".concat(i.url).concat(e.signedURL).concat(a)):null})})),error:null});case 8:if(r.prev=8,r.t0=r.catch(0),!Qf(r.t0)){r.next=12;break}return r.abrupt("return",{data:null,error:r.t0});case 12:throw r.t0;case 13:case"end":return r.stop()}}),r,this,[[0,8]])})))}},{key:"download",value:function(e,t){return fp(this,void 0,void 0,_().mark((function n(){var r,o,a,i,s,c,l;return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r="undefined"!==typeof(null===t||void 0===t?void 0:t.transform),o=r?"render/image/authenticated":"object",a=this.transformOptsToQueryString((null===t||void 0===t?void 0:t.transform)||{}),i=a?"?".concat(a):"",n.prev=4,s=this._getFinalPath(e),n.next=8,cp(this.fetch,"".concat(this.url,"/").concat(o,"/").concat(s).concat(i),{headers:this.headers,noResolveJson:!0});case 8:return c=n.sent,n.next=11,c.blob();case 11:return l=n.sent,n.abrupt("return",{data:l,error:null});case 15:if(n.prev=15,n.t0=n.catch(4),!Qf(n.t0)){n.next=19;break}return n.abrupt("return",{data:null,error:n.t0});case 19:throw n.t0;case 20:case"end":return n.stop()}}),n,this,[[4,15]])})))}},{key:"getPublicUrl",value:function(e,t){var n=this._getFinalPath(e),r=[],o=(null===t||void 0===t?void 0:t.download)?"download=".concat(!0===t.download?"":t.download):"";""!==o&&r.push(o);var a="undefined"!==typeof(null===t||void 0===t?void 0:t.transform)?"render/image":"object",i=this.transformOptsToQueryString((null===t||void 0===t?void 0:t.transform)||{});""!==i&&r.push(i);var s=r.join("&");return""!==s&&(s="?".concat(s)),{data:{publicUrl:encodeURI("".concat(this.url,"/").concat(a,"/public/").concat(n).concat(s))}}}},{key:"remove",value:function(e){return fp(this,void 0,void 0,_().mark((function t(){var n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,dp(this.fetch,"".concat(this.url,"/object/").concat(this.bucketId),{prefixes:e},{headers:this.headers});case 3:return n=t.sent,t.abrupt("return",{data:n,error:null});case 7:if(t.prev=7,t.t0=t.catch(0),!Qf(t.t0)){t.next=11;break}return t.abrupt("return",{data:null,error:t.t0});case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,this,[[0,7]])})))}},{key:"list",value:function(e,t,n){return fp(this,void 0,void 0,_().mark((function r(){var o,a;return _().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,o=Object.assign(Object.assign(Object.assign({},pp),t),{prefix:e||""}),r.next=4,lp(this.fetch,"".concat(this.url,"/object/list/").concat(this.bucketId),o,{headers:this.headers},n);case 4:return a=r.sent,r.abrupt("return",{data:a,error:null});case 8:if(r.prev=8,r.t0=r.catch(0),!Qf(r.t0)){r.next=12;break}return r.abrupt("return",{data:null,error:r.t0});case 12:throw r.t0;case 13:case"end":return r.stop()}}),r,this,[[0,8]])})))}},{key:"_getFinalPath",value:function(e){return"".concat(this.bucketId,"/").concat(e)}},{key:"_removeEmptyFolders",value:function(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}},{key:"transformOptsToQueryString",value:function(e){var t=[];return e.width&&t.push("width=".concat(e.width)),e.height&&t.push("height=".concat(e.height)),e.resize&&t.push("resize=".concat(e.resize)),e.format&&t.push("format=".concat(e.format)),e.quality&&t.push("quality=".concat(e.quality)),t.join("&")}}]),e}(),mp={"X-Client-Info":"storage-js/".concat("2.3.0")},gp=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(t){a(t)}}function s(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},yp=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;h(this,e),this.url=t,this.headers=Object.assign(Object.assign({},mp),n),this.fetch=np(r)}return y(e,[{key:"listBuckets",value:function(){return gp(this,void 0,void 0,_().mark((function e(){var t;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,cp(this.fetch,"".concat(this.url,"/bucket"),{headers:this.headers});case 3:return t=e.sent,e.abrupt("return",{data:t,error:null});case 7:if(e.prev=7,e.t0=e.catch(0),!Qf(e.t0)){e.next=11;break}return e.abrupt("return",{data:null,error:e.t0});case 11:throw e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,7]])})))}},{key:"getBucket",value:function(e){return gp(this,void 0,void 0,_().mark((function t(){var n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,cp(this.fetch,"".concat(this.url,"/bucket/").concat(e),{headers:this.headers});case 3:return n=t.sent,t.abrupt("return",{data:n,error:null});case 7:if(t.prev=7,t.t0=t.catch(0),!Qf(t.t0)){t.next=11;break}return t.abrupt("return",{data:null,error:t.t0});case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,this,[[0,7]])})))}},{key:"createBucket",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{public:!1};return gp(this,void 0,void 0,_().mark((function n(){var r;return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,lp(this.fetch,"".concat(this.url,"/bucket"),{id:e,name:e,public:t.public},{headers:this.headers});case 3:return r=n.sent,n.abrupt("return",{data:r,error:null});case 7:if(n.prev=7,n.t0=n.catch(0),!Qf(n.t0)){n.next=11;break}return n.abrupt("return",{data:null,error:n.t0});case 11:throw n.t0;case 12:case"end":return n.stop()}}),n,this,[[0,7]])})))}},{key:"updateBucket",value:function(e,t){return gp(this,void 0,void 0,_().mark((function n(){var r;return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,up(this.fetch,"".concat(this.url,"/bucket/").concat(e),{id:e,name:e,public:t.public},{headers:this.headers});case 3:return r=n.sent,n.abrupt("return",{data:r,error:null});case 7:if(n.prev=7,n.t0=n.catch(0),!Qf(n.t0)){n.next=11;break}return n.abrupt("return",{data:null,error:n.t0});case 11:throw n.t0;case 12:case"end":return n.stop()}}),n,this,[[0,7]])})))}},{key:"emptyBucket",value:function(e){return gp(this,void 0,void 0,_().mark((function t(){var n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,lp(this.fetch,"".concat(this.url,"/bucket/").concat(e,"/empty"),{},{headers:this.headers});case 3:return n=t.sent,t.abrupt("return",{data:n,error:null});case 7:if(t.prev=7,t.t0=t.catch(0),!Qf(t.t0)){t.next=11;break}return t.abrupt("return",{data:null,error:t.t0});case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,this,[[0,7]])})))}},{key:"deleteBucket",value:function(e){return gp(this,void 0,void 0,_().mark((function t(){var n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,dp(this.fetch,"".concat(this.url,"/bucket/").concat(e),{},{headers:this.headers});case 3:return n=t.sent,t.abrupt("return",{data:n,error:null});case 7:if(t.prev=7,t.t0=t.catch(0),!Qf(t.t0)){t.next=11;break}return t.abrupt("return",{data:null,error:t.t0});case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,this,[[0,7]])})))}}]),e}(),bp=function(e){x(n,e);var t=C(n);function n(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;return h(this,n),t.call(this,e,r,o)}return y(n,[{key:"from",value:function(e){return new vp(this.url,this.headers,e,this.fetch)}}]),n}(yp),xp={"X-Client-Info":"supabase-js/".concat("2.5.0")},wp=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(t){a(t)}}function s(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},kp=function(e){var t;return t=e||("undefined"===typeof fetch?yf():fetch),function(){return t.apply(void 0,arguments)}},Sp=function(e,t,n){var r=kp(n),o="undefined"===typeof Headers?gf.Headers:Headers;return function(n,a){return wp(void 0,void 0,void 0,_().mark((function i(){var s,c,l;return _().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,t();case 2:if(i.t1=s=i.sent,i.t0=null!==i.t1,!i.t0){i.next=6;break}i.t0=void 0!==s;case 6:if(!i.t0){i.next=10;break}i.t2=s,i.next=11;break;case 10:i.t2=e;case 11:return c=i.t2,(l=new o(null===a||void 0===a?void 0:a.headers)).has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization","Bearer ".concat(c)),i.abrupt("return",r(n,Object.assign(Object.assign({},a),{headers:l})));case 16:case"end":return i.stop()}}),i)})))}};var Ep=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(t){a(t)}}function s(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))};var Cp=function(){return"undefined"!==typeof document};function _p(e,t){var n;t||(t=(null===(n=null===window||void 0===window?void 0:window.location)||void 0===n?void 0:n.href)||""),e=e.replace(/[\[\]]/g,"\\$&");var r=new RegExp("[?]"+e+"(=([^]*)|&|#|$)").exec(t);return r?r[2]?decodeURIComponent(r[2].replace(/\+/g," ")):"":null}var Op=function(e){var t;return t=e||("undefined"===typeof fetch?function(){for(var e=arguments.length,t=new Array(e),r=0;r>4,n=(15&o)<<4|(a=s.indexOf(e.charAt(l++)))>>2,r=(3&a)<<6|(i=s.indexOf(e.charAt(l++))),c+=String.fromCharCode(t),64!=a&&0!=n&&(c+=String.fromCharCode(n)),64!=i&&0!=r&&(c+=String.fromCharCode(r));return c}(n))}function Rp(e){return new Promise((function(t){setTimeout((function(){return t(null)}),e)}))}function Mp(e,t){var n=this;return new Promise((function(r,o){Ep(n,void 0,void 0,_().mark((function n(){var a,i;return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:a=0;case 1:if(!(a<1/0)){n.next=19;break}return n.prev=2,n.next=5,e(a);case 5:if(i=n.sent,t(a,null,i)){n.next=9;break}return r(i),n.abrupt("return");case 9:n.next=16;break;case 11:if(n.prev=11,n.t0=n.catch(2),t(a,n.t0)){n.next=16;break}return o(n.t0),n.abrupt("return");case 16:a++,n.next=1;break;case 19:case"end":return n.stop()}}),n,null,[[2,11]])})))}))}Tp.promiseConstructor=Promise;var Ip=function(e){x(n,e);var t=C(n);function n(e,r){var o;return h(this,n),(o=t.call(this,e)).__isAuthError=!0,o.name="AuthError",o.status=r,o}return y(n)}(A(Error));function Np(e){return"object"===typeof e&&null!==e&&"__isAuthError"in e}var Dp=function(e){x(n,e);var t=C(n);function n(e,r){var o;return h(this,n),(o=t.call(this,e,r)).name="AuthApiError",o.status=r,o}return y(n,[{key:"toJSON",value:function(){return{name:this.name,message:this.message,status:this.status}}}]),n}(Ip);function Fp(e){return Np(e)&&"AuthApiError"===e.name}var Lp=function(e){x(n,e);var t=C(n);function n(e,r){var o;return h(this,n),(o=t.call(this,e)).name="AuthUnknownError",o.originalError=r,o}return y(n)}(Ip),zp=function(e){x(n,e);var t=C(n);function n(e,r,o){var a;return h(this,n),(a=t.call(this,e)).name=r,a.status=o,a}return y(n,[{key:"toJSON",value:function(){return{name:this.name,message:this.message,status:this.status}}}]),n}(Ip),Bp=function(e){x(n,e);var t=C(n);function n(){return h(this,n),t.call(this,"Auth session missing!","AuthSessionMissingError",400)}return y(n)}(zp),Vp=function(e){x(n,e);var t=C(n);function n(e){return h(this,n),t.call(this,e,"AuthInvalidCredentialsError",400)}return y(n)}(zp),Hp=function(e){x(n,e);var t=C(n);function n(e){var r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return h(this,n),(r=t.call(this,e,"AuthImplicitGrantRedirectError",500)).details=null,r.details=o,r}return y(n,[{key:"toJSON",value:function(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}]),n}(zp),Up=function(e){x(n,e);var t=C(n);function n(e,r){return h(this,n),t.call(this,e,"AuthRetryableFetchError",r)}return y(n)}(zp),Wp=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(t){a(t)}}function s(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))},qp=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o1&&void 0!==arguments[1]?arguments[1]:{};return nh(this,void 0,void 0,_().mark((function n(){return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,Xp(this.fetch,"POST","".concat(this.url,"/invite"),{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:Qp});case 3:return n.abrupt("return",n.sent);case 6:if(n.prev=6,n.t0=n.catch(0),!Np(n.t0)){n.next=10;break}return n.abrupt("return",{data:{user:null},error:n.t0});case 10:throw n.t0;case 11:case"end":return n.stop()}}),n,this,[[0,6]])})))}},{key:"generateLink",value:function(e){return nh(this,void 0,void 0,_().mark((function t(){var n,r,o;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n=e.options,r=rh(e,["options"]),o=Object.assign(Object.assign({},r),n),"newEmail"in r&&(o.new_email=null===r||void 0===r?void 0:r.newEmail,delete o.newEmail),t.next=6,Xp(this.fetch,"POST","".concat(this.url,"/admin/generate_link"),{body:o,headers:this.headers,xform:eh,redirectTo:null===n||void 0===n?void 0:n.redirectTo});case 6:return t.abrupt("return",t.sent);case 9:if(t.prev=9,t.t0=t.catch(0),!Np(t.t0)){t.next=13;break}return t.abrupt("return",{data:{properties:null,user:null},error:t.t0});case 13:throw t.t0;case 14:case"end":return t.stop()}}),t,this,[[0,9]])})))}},{key:"createUser",value:function(e){return nh(this,void 0,void 0,_().mark((function t(){return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Xp(this.fetch,"POST","".concat(this.url,"/admin/users"),{body:e,headers:this.headers,xform:Qp});case 3:return t.abrupt("return",t.sent);case 6:if(t.prev=6,t.t0=t.catch(0),!Np(t.t0)){t.next=10;break}return t.abrupt("return",{data:{user:null},error:t.t0});case 10:throw t.t0;case 11:case"end":return t.stop()}}),t,this,[[0,6]])})))}},{key:"listUsers",value:function(e){var t,n,r,o,a,i,s;return nh(this,void 0,void 0,_().mark((function c(){var l,u,d,f,p;return _().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,l={nextPage:null,lastPage:0,total:0},c.next=4,Xp(this.fetch,"GET","".concat(this.url,"/admin/users"),{headers:this.headers,noResolveJson:!0,query:{page:null!==(n=null===(t=null===e||void 0===e?void 0:e.page)||void 0===t?void 0:t.toString())&&void 0!==n?n:"",per_page:null!==(o=null===(r=null===e||void 0===e?void 0:e.perPage)||void 0===r?void 0:r.toString())&&void 0!==o?o:""},xform:th});case 4:if(!(u=c.sent).error){c.next=7;break}throw u.error;case 7:return c.next=9,u.json();case 9:return d=c.sent,f=null!==(a=u.headers.get("x-total-count"))&&void 0!==a?a:0,(p=null!==(s=null===(i=u.headers.get("link"))||void 0===i?void 0:i.split(","))&&void 0!==s?s:[]).length>0&&(p.forEach((function(e){var t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),n=JSON.parse(e.split(";")[1].split("=")[1]);l["".concat(n,"Page")]=t})),l.total=parseInt(f)),c.abrupt("return",{data:Object.assign(Object.assign({},d),l),error:null});case 16:if(c.prev=16,c.t0=c.catch(0),!Np(c.t0)){c.next=20;break}return c.abrupt("return",{data:{users:[]},error:c.t0});case 20:throw c.t0;case 21:case"end":return c.stop()}}),c,this,[[0,16]])})))}},{key:"getUserById",value:function(e){return nh(this,void 0,void 0,_().mark((function t(){return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Xp(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e),{headers:this.headers,xform:Qp});case 3:return t.abrupt("return",t.sent);case 6:if(t.prev=6,t.t0=t.catch(0),!Np(t.t0)){t.next=10;break}return t.abrupt("return",{data:{user:null},error:t.t0});case 10:throw t.t0;case 11:case"end":return t.stop()}}),t,this,[[0,6]])})))}},{key:"updateUserById",value:function(e,t){return nh(this,void 0,void 0,_().mark((function n(){return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,Xp(this.fetch,"PUT","".concat(this.url,"/admin/users/").concat(e),{body:t,headers:this.headers,xform:Qp});case 3:return n.abrupt("return",n.sent);case 6:if(n.prev=6,n.t0=n.catch(0),!Np(n.t0)){n.next=10;break}return n.abrupt("return",{data:{user:null},error:n.t0});case 10:throw n.t0;case 11:case"end":return n.stop()}}),n,this,[[0,6]])})))}},{key:"deleteUser",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return nh(this,void 0,void 0,_().mark((function n(){return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,Xp(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e),{headers:this.headers,body:{should_soft_delete:t},xform:Qp});case 3:return n.abrupt("return",n.sent);case 6:if(n.prev=6,n.t0=n.catch(0),!Np(n.t0)){n.next=10;break}return n.abrupt("return",{data:{user:null},error:n.t0});case 10:throw n.t0;case 11:case"end":return n.stop()}}),n,this,[[0,6]])})))}},{key:"_listFactors",value:function(e){return nh(this,void 0,void 0,_().mark((function t(){var n,r,o;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Xp(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e.userId,"/factors"),{headers:this.headers,xform:function(e){return{data:{factors:e},error:null}}});case 3:return n=t.sent,r=n.data,o=n.error,t.abrupt("return",{data:r,error:o});case 9:if(t.prev=9,t.t0=t.catch(0),!Np(t.t0)){t.next=13;break}return t.abrupt("return",{data:null,error:t.t0});case 13:throw t.t0;case 14:case"end":return t.stop()}}),t,this,[[0,9]])})))}},{key:"_deleteFactor",value:function(e){return nh(this,void 0,void 0,_().mark((function t(){var n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Xp(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e.userId,"/factors/").concat(e.id),{headers:this.headers});case 3:return n=t.sent,t.abrupt("return",{data:n,error:null});case 7:if(t.prev=7,t.t0=t.catch(0),!Np(t.t0)){t.next=11;break}return t.abrupt("return",{data:null,error:t.t0});case 11:throw t.t0;case 12:case"end":return t.stop()}}),t,this,[[0,7]])})))}}]),e}(),ah={"X-Client-Info":"gotrue-js/".concat("2.10.0")},ih={getItem:function(e){return Cp()?globalThis.localStorage.getItem(e):null},setItem:function(e,t){Cp()&&globalThis.localStorage.setItem(e,t)},removeItem:function(e){Cp()&&globalThis.localStorage.removeItem(e)}},sh=ih;var ch=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(t){a(t)}}function s(e){try{c(r.throw(e))}catch(t){a(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}c((r=r.apply(e,t||[])).next())}))};!function(){if("object"!==typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"undefined"!==typeof self&&(self.globalThis=self)}}();var lh={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:ah},uh=1e4,dh=function(){function e(t){h(this,e),this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0;var n=Object.assign(Object.assign({},lh),t);this.inMemorySession=null,this.storageKey=n.storageKey,this.autoRefreshToken=n.autoRefreshToken,this.persistSession=n.persistSession,this.storage=n.storage||sh,this.admin=new oh({url:n.url,headers:n.headers,fetch:n.fetch}),this.url=n.url,this.headers=n.headers,this.fetch=Op(n.fetch),this.detectSessionInUrl=n.detectSessionInUrl,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.initialize()}return y(e,[{key:"initialize",value:function(){return this.initializePromise||(this.initializePromise=this._initialize()),this.initializePromise}},{key:"_initialize",value:function(){return ch(this,void 0,void 0,_().mark((function e(){var t,n,r,o,a;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.initializePromise){e.next=2;break}return e.abrupt("return",this.initializePromise);case 2:if(e.prev=2,!this.detectSessionInUrl||!this._isImplicitGrantFlow()){e.next=19;break}return e.next=6,this._getSessionFromUrl();case 6:if(t=e.sent,n=t.data,!(r=t.error)){e.next=13;break}return e.next=12,this._removeSession();case 12:return e.abrupt("return",{error:r});case 13:return o=n.session,a=n.redirectType,e.next=16,this._saveSession(o);case 16:return this._notifyAllSubscribers("SIGNED_IN",o),"recovery"===a&&this._notifyAllSubscribers("PASSWORD_RECOVERY",o),e.abrupt("return",{error:null});case 19:return e.next=21,this._recoverAndRefresh();case 21:return e.abrupt("return",{error:null});case 24:if(e.prev=24,e.t0=e.catch(2),!Np(e.t0)){e.next=28;break}return e.abrupt("return",{error:e.t0});case 28:return e.abrupt("return",{error:new Lp("Unexpected error during initialization",e.t0)});case 29:return e.prev=29,e.next=32,this._handleVisibilityChange();case 32:return e.finish(29);case 33:case"end":return e.stop()}}),e,this,[[2,24,29,33]])})))}},{key:"signUp",value:function(e){var t,n;return ch(this,void 0,void 0,_().mark((function r(){var o,a,i,s,c,l,u,d,f,p,h,v;return _().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,this._removeSession();case 3:if(!("email"in e)){r.next=10;break}return a=e.email,i=e.password,s=e.options,r.next=7,Xp(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,redirectTo:null===s||void 0===s?void 0:s.emailRedirectTo,body:{email:a,password:i,data:null!==(t=null===s||void 0===s?void 0:s.data)&&void 0!==t?t:{},gotrue_meta_security:{captcha_token:null===s||void 0===s?void 0:s.captchaToken}},xform:Jp});case 7:o=r.sent,r.next=18;break;case 10:if(!("phone"in e)){r.next=17;break}return c=e.phone,l=e.password,u=e.options,r.next=14,Xp(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,body:{phone:c,password:l,data:null!==(n=null===u||void 0===u?void 0:u.data)&&void 0!==n?n:{},gotrue_meta_security:{captcha_token:null===u||void 0===u?void 0:u.captchaToken}},xform:Jp});case 14:o=r.sent,r.next=18;break;case 17:throw new Vp("You must provide either an email or phone number and a password");case 18:if(f=(d=o).data,!(p=d.error)&&f){r.next=21;break}return r.abrupt("return",{data:{user:null,session:null},error:p});case 21:if(h=f.session,v=f.user,!f.session){r.next=27;break}return r.next=26,this._saveSession(f.session);case 26:this._notifyAllSubscribers("SIGNED_IN",h);case 27:return r.abrupt("return",{data:{user:v,session:h},error:null});case 30:if(r.prev=30,r.t0=r.catch(0),!Np(r.t0)){r.next=34;break}return r.abrupt("return",{data:{user:null,session:null},error:r.t0});case 34:throw r.t0;case 35:case"end":return r.stop()}}),r,this,[[0,30]])})))}},{key:"signInWithPassword",value:function(e){var t,n;return ch(this,void 0,void 0,_().mark((function r(){var o,a,i,s,c,l,u,d,f,p;return _().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,this._removeSession();case 3:if(!("email"in e)){r.next=10;break}return a=e.email,i=e.password,s=e.options,r.next=7,Xp(this.fetch,"POST","".concat(this.url,"/token?grant_type=password"),{headers:this.headers,body:{email:a,password:i,data:null!==(t=null===s||void 0===s?void 0:s.data)&&void 0!==t?t:{},gotrue_meta_security:{captcha_token:null===s||void 0===s?void 0:s.captchaToken}},xform:Jp});case 7:o=r.sent,r.next=18;break;case 10:if(!("phone"in e)){r.next=17;break}return c=e.phone,l=e.password,u=e.options,r.next=14,Xp(this.fetch,"POST","".concat(this.url,"/token?grant_type=password"),{headers:this.headers,body:{phone:c,password:l,data:null!==(n=null===u||void 0===u?void 0:u.data)&&void 0!==n?n:{},gotrue_meta_security:{captcha_token:null===u||void 0===u?void 0:u.captchaToken}},xform:Jp});case 14:o=r.sent,r.next=18;break;case 17:throw new Vp("You must provide either an email or phone number and a password");case 18:if(f=(d=o).data,!(p=d.error)&&f){r.next=21;break}return r.abrupt("return",{data:{user:null,session:null},error:p});case 21:if(!f.session){r.next=25;break}return r.next=24,this._saveSession(f.session);case 24:this._notifyAllSubscribers("SIGNED_IN",f.session);case 25:return r.abrupt("return",{data:f,error:p});case 28:if(r.prev=28,r.t0=r.catch(0),!Np(r.t0)){r.next=32;break}return r.abrupt("return",{data:{user:null,session:null},error:r.t0});case 32:throw r.t0;case 33:case"end":return r.stop()}}),r,this,[[0,28]])})))}},{key:"signInWithOAuth",value:function(e){var t,n,r,o;return ch(this,void 0,void 0,_().mark((function a(){return _().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._removeSession();case 2:return a.abrupt("return",this._handleProviderSignIn(e.provider,{redirectTo:null===(t=e.options)||void 0===t?void 0:t.redirectTo,scopes:null===(n=e.options)||void 0===n?void 0:n.scopes,queryParams:null===(r=e.options)||void 0===r?void 0:r.queryParams,skipBrowserRedirect:null===(o=e.options)||void 0===o?void 0:o.skipBrowserRedirect}));case 3:case"end":return a.stop()}}),a,this)})))}},{key:"signInWithOtp",value:function(e){var t,n,r,o;return ch(this,void 0,void 0,_().mark((function a(){var i,s,c,l,u,d,f,p;return _().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,this._removeSession();case 3:if(!("email"in e)){a.next=10;break}return i=e.email,s=e.options,a.next=7,Xp(this.fetch,"POST","".concat(this.url,"/otp"),{headers:this.headers,body:{email:i,data:null!==(t=null===s||void 0===s?void 0:s.data)&&void 0!==t?t:{},create_user:null===(n=null===s||void 0===s?void 0:s.shouldCreateUser)||void 0===n||n,gotrue_meta_security:{captcha_token:null===s||void 0===s?void 0:s.captchaToken}},redirectTo:null===s||void 0===s?void 0:s.emailRedirectTo});case 7:return c=a.sent,l=c.error,a.abrupt("return",{data:{user:null,session:null},error:l});case 10:if(!("phone"in e)){a.next=17;break}return u=e.phone,d=e.options,a.next=14,Xp(this.fetch,"POST","".concat(this.url,"/otp"),{headers:this.headers,body:{phone:u,data:null!==(r=null===d||void 0===d?void 0:d.data)&&void 0!==r?r:{},create_user:null===(o=null===d||void 0===d?void 0:d.shouldCreateUser)||void 0===o||o,gotrue_meta_security:{captcha_token:null===d||void 0===d?void 0:d.captchaToken}}});case 14:return f=a.sent,p=f.error,a.abrupt("return",{data:{user:null,session:null},error:p});case 17:throw new Vp("You must provide either an email or phone number.");case 20:if(a.prev=20,a.t0=a.catch(0),!Np(a.t0)){a.next=24;break}return a.abrupt("return",{data:{user:null,session:null},error:a.t0});case 24:throw a.t0;case 25:case"end":return a.stop()}}),a,this,[[0,20]])})))}},{key:"verifyOtp",value:function(e){var t,n;return ch(this,void 0,void 0,_().mark((function r(){var o,a,i,s,c;return _().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,this._removeSession();case 3:return r.next=5,Xp(this.fetch,"POST","".concat(this.url,"/verify"),{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:null===(t=e.options)||void 0===t?void 0:t.captchaToken}}),redirectTo:null===(n=e.options)||void 0===n?void 0:n.redirectTo,xform:Jp});case 5:if(o=r.sent,a=o.data,!(i=o.error)){r.next=10;break}throw i;case 10:if(a){r.next=12;break}throw"An error occurred on token verification.";case 12:if(s=a.session,c=a.user,!(null===s||void 0===s?void 0:s.access_token)){r.next=18;break}return r.next=17,this._saveSession(s);case 17:this._notifyAllSubscribers("SIGNED_IN",s);case 18:return r.abrupt("return",{data:{user:c,session:s},error:null});case 21:if(r.prev=21,r.t0=r.catch(0),!Np(r.t0)){r.next=25;break}return r.abrupt("return",{data:{user:null,session:null},error:r.t0});case 25:throw r.t0;case 26:case"end":return r.stop()}}),r,this,[[0,21]])})))}},{key:"signInWithSSO",value:function(e){var t,n,r;return ch(this,void 0,void 0,_().mark((function o(){return _().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,this._removeSession();case 3:return o.next=5,Xp(this.fetch,"POST","".concat(this.url,"/sso"),{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:null!==(n=null===(t=e.options)||void 0===t?void 0:t.redirectTo)&&void 0!==n?n:void 0}),(null===(r=null===e||void 0===e?void 0:e.options)||void 0===r?void 0:r.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0}),headers:this.headers,xform:Zp});case 5:return o.abrupt("return",o.sent);case 8:if(o.prev=8,o.t0=o.catch(0),!Np(o.t0)){o.next=12;break}return o.abrupt("return",{data:null,error:o.t0});case 12:throw o.t0;case 13:case"end":return o.stop()}}),o,this,[[0,8]])})))}},{key:"getSession",value:function(){return ch(this,void 0,void 0,_().mark((function e(){var t,n,r,o,a;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.initializePromise;case 2:if(t=null,!this.persistSession){e.next=16;break}return e.next=6,jp(this.storage,this.storageKey);case 6:if(null===(n=e.sent)){e.next=14;break}if(!this._isValidSession(n)){e.next=12;break}t=n,e.next=14;break;case 12:return e.next=14,this._removeSession();case 14:e.next=17;break;case 16:t=this.inMemorySession;case 17:if(t){e.next=19;break}return e.abrupt("return",{data:{session:null},error:null});case 19:if(!!t.expires_at&&t.expires_at<=Date.now()/1e3){e.next=22;break}return e.abrupt("return",{data:{session:t},error:null});case 22:return e.next=24,this._callRefreshToken(t.refresh_token);case 24:if(r=e.sent,o=r.session,!(a=r.error)){e.next=29;break}return e.abrupt("return",{data:{session:null},error:a});case 29:return e.abrupt("return",{data:{session:o},error:null});case 30:case"end":return e.stop()}}),e,this)})))}},{key:"getUser",value:function(e){var t,n;return ch(this,void 0,void 0,_().mark((function r(){var o,a,i;return _().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,e){r.next=10;break}return r.next=4,this.getSession();case 4:if(o=r.sent,a=o.data,!(i=o.error)){r.next=9;break}throw i;case 9:e=null!==(n=null===(t=a.session)||void 0===t?void 0:t.access_token)&&void 0!==n?n:void 0;case 10:return r.next=12,Xp(this.fetch,"GET","".concat(this.url,"/user"),{headers:this.headers,jwt:e,xform:Qp});case 12:return r.abrupt("return",r.sent);case 15:if(r.prev=15,r.t0=r.catch(0),!Np(r.t0)){r.next=19;break}return r.abrupt("return",{data:{user:null},error:r.t0});case 19:throw r.t0;case 20:case"end":return r.stop()}}),r,this,[[0,15]])})))}},{key:"updateUser",value:function(e){return ch(this,void 0,void 0,_().mark((function t(){var n,r,o,a,i,s,c;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.getSession();case 3:if(n=t.sent,r=n.data,!(o=n.error)){t.next=8;break}throw o;case 8:if(r.session){t.next=10;break}throw new Bp;case 10:return a=r.session,t.next=13,Xp(this.fetch,"PUT","".concat(this.url,"/user"),{headers:this.headers,body:e,jwt:a.access_token,xform:Qp});case 13:if(i=t.sent,s=i.data,!(c=i.error)){t.next=18;break}throw c;case 18:return a.user=s.user,t.next=21,this._saveSession(a);case 21:return this._notifyAllSubscribers("USER_UPDATED",a),t.abrupt("return",{data:{user:a.user},error:null});case 25:if(t.prev=25,t.t0=t.catch(0),!Np(t.t0)){t.next=29;break}return t.abrupt("return",{data:{user:null},error:t.t0});case 29:throw t.t0;case 30:case"end":return t.stop()}}),t,this,[[0,25]])})))}},{key:"_decodeJWT",value:function(e){return Ap(e)}},{key:"setSession",value:function(e){return ch(this,void 0,void 0,_().mark((function t(){var n,r,o,a,i,s,c,l,u,d,f;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,e.access_token&&e.refresh_token){t.next=3;break}throw new Bp;case 3:if(n=Date.now()/1e3,r=n,o=!0,a=null,(i=Ap(e.access_token)).exp&&(r=i.exp,o=r<=n),!o){t.next=22;break}return t.next=12,this._callRefreshToken(e.refresh_token);case 12:if(s=t.sent,c=s.session,!(l=s.error)){t.next=17;break}return t.abrupt("return",{data:{user:null,session:null},error:l});case 17:if(c){t.next=19;break}return t.abrupt("return",{data:{user:null,session:null},error:null});case 19:a=c,t.next=33;break;case 22:return t.next=24,this.getUser(e.access_token);case 24:if(u=t.sent,d=u.data,!(f=u.error)){t.next=29;break}throw f;case 29:return a={access_token:e.access_token,refresh_token:e.refresh_token,user:d.user,token_type:"bearer",expires_in:r-n,expires_at:r},t.next=32,this._saveSession(a);case 32:this._notifyAllSubscribers("SIGNED_IN",a);case 33:return t.abrupt("return",{data:{user:a.user,session:a},error:null});case 36:if(t.prev=36,t.t0=t.catch(0),!Np(t.t0)){t.next=40;break}return t.abrupt("return",{data:{session:null,user:null},error:t.t0});case 40:throw t.t0;case 41:case"end":return t.stop()}}),t,this,[[0,36]])})))}},{key:"refreshSession",value:function(e){var t;return ch(this,void 0,void 0,_().mark((function n(){var r,o,a,i,s,c;return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,e){n.next=10;break}return n.next=4,this.getSession();case 4:if(r=n.sent,o=r.data,!(a=r.error)){n.next=9;break}throw a;case 9:e=null!==(t=o.session)&&void 0!==t?t:void 0;case 10:if(null===e||void 0===e?void 0:e.refresh_token){n.next=12;break}throw new Bp;case 12:return n.next=14,this._callRefreshToken(e.refresh_token);case 14:if(i=n.sent,s=i.session,!(c=i.error)){n.next=19;break}return n.abrupt("return",{data:{user:null,session:null},error:c});case 19:if(s){n.next=21;break}return n.abrupt("return",{data:{user:null,session:null},error:null});case 21:return n.abrupt("return",{data:{user:s.user,session:s},error:null});case 24:if(n.prev=24,n.t0=n.catch(0),!Np(n.t0)){n.next=28;break}return n.abrupt("return",{data:{user:null,session:null},error:n.t0});case 28:throw n.t0;case 29:case"end":return n.stop()}}),n,this,[[0,24]])})))}},{key:"_getSessionFromUrl",value:function(){return ch(this,void 0,void 0,_().mark((function e(){var t,n,r,o,a,i,s,c,l,u,d,f,p,h,v,m,g;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,Cp()){e.next=3;break}throw new Hp("No browser detected.");case 3:if(this._isImplicitGrantFlow()){e.next=5;break}throw new Hp("Not a valid implicit grant flow url.");case 5:if(!(t=_p("error_description"))){e.next=14;break}if(n=_p("error_code")){e.next=10;break}throw new Hp("No error_code detected.");case 10:if(r=_p("error")){e.next=13;break}throw new Hp("No error detected.");case 13:throw new Hp(t,{error:r,code:n});case 14:if(o=_p("provider_token"),a=_p("provider_refresh_token"),i=_p("access_token")){e.next=19;break}throw new Hp("No access_token detected.");case 19:if(s=_p("expires_in")){e.next=22;break}throw new Hp("No expires_in detected.");case 22:if(c=_p("refresh_token")){e.next=25;break}throw new Hp("No refresh_token detected.");case 25:if(l=_p("token_type")){e.next=28;break}throw new Hp("No token_type detected.");case 28:return u=Math.round(Date.now()/1e3),d=u+parseInt(s),e.next=32,this.getUser(i);case 32:if(f=e.sent,p=f.data,!(h=f.error)){e.next=37;break}throw h;case 37:return v=p.user,m={provider_token:o,provider_refresh_token:a,access_token:i,expires_in:parseInt(s),expires_at:d,refresh_token:c,token_type:l,user:v},g=_p("type"),window.location.replace(window.location.href.split("#")[0]),e.abrupt("return",{data:{session:m,redirectType:g},error:null});case 44:if(e.prev=44,e.t0=e.catch(0),!Np(e.t0)){e.next=48;break}return e.abrupt("return",{data:{session:null,redirectType:null},error:e.t0});case 48:throw e.t0;case 49:case"end":return e.stop()}}),e,this,[[0,44]])})))}},{key:"_isImplicitGrantFlow",value:function(){return Cp()&&(Boolean(_p("access_token"))||Boolean(_p("error_description")))}},{key:"signOut",value:function(){var e;return ch(this,void 0,void 0,_().mark((function t(){var n,r,o,a,i,s;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getSession();case 2:if(n=t.sent,r=n.data,!(o=n.error)){t.next=7;break}return t.abrupt("return",{error:o});case 7:if(!(a=null===(e=r.session)||void 0===e?void 0:e.access_token)){t.next=16;break}return t.next=11,this.admin.signOut(a);case 11:if(i=t.sent,!(s=i.error)){t.next=16;break}if(Fp(s)&&(404===s.status||401===s.status)){t.next=16;break}return t.abrupt("return",{error:s});case 16:return t.next=18,this._removeSession();case 18:return this._notifyAllSubscribers("SIGNED_OUT",null),t.abrupt("return",{error:null});case 20:case"end":return t.stop()}}),t,this)})))}},{key:"onAuthStateChange",value:function(e){var t=this,n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)})),r={id:n,callback:e,unsubscribe:function(){t.stateChangeEmitters.delete(n)}};return this.stateChangeEmitters.set(n,r),{data:{subscription:r}}}},{key:"resetPasswordForEmail",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ch(this,void 0,void 0,_().mark((function n(){return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,Xp(this.fetch,"POST","".concat(this.url,"/recover"),{body:{email:e,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo});case 3:return n.abrupt("return",n.sent);case 6:if(n.prev=6,n.t0=n.catch(0),!Np(n.t0)){n.next=10;break}return n.abrupt("return",{data:null,error:n.t0});case 10:throw n.t0;case 11:case"end":return n.stop()}}),n,this,[[0,6]])})))}},{key:"_refreshAccessToken",value:function(e){return ch(this,void 0,void 0,_().mark((function t(){var n,r=this;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n=Date.now(),t.next=4,Mp((function(t){return ch(r,void 0,void 0,_().mark((function n(){return _().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Rp(200*t);case 2:return n.next=4,Xp(this.fetch,"POST","".concat(this.url,"/token?grant_type=refresh_token"),{body:{refresh_token:e},headers:this.headers,xform:Jp});case 4:return n.abrupt("return",n.sent);case 5:case"end":return n.stop()}}),n,this)})))}),(function(e,t,r){return r&&r.error&&r.error instanceof Up&&Date.now()+200*(e+1)-n1&&void 0!==arguments[1]?arguments[1]:{},n=this._getUrlForProvider(e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return Cp()&&!t.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}},{key:"_recoverAndRefresh",value:function(){var e;return ch(this,void 0,void 0,_().mark((function t(){var n,r,o,a;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,jp(this.storage,this.storageKey);case 3:if(n=t.sent,this._isValidSession(n)){t.next=9;break}if(null===n){t.next=8;break}return t.next=8,this._removeSession();case 8:return t.abrupt("return");case 9:if(r=Math.round(Date.now()/1e3),!((null!==(e=n.expires_at)&&void 0!==e?e:1/0)