@srimandir/old-dosha-calculator 8.0.18 → 8.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
- (function(Ae,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],k):(Ae=typeof globalThis<"u"?globalThis:Ae||self,k(Ae.OldDoshaCalculator={},Ae.React,Ae.ReactDOM))})(this,(function(Ae,k,xt){"use strict";var Nu=Ae=>{throw TypeError(Ae)};var Ru=(Ae,k,xt)=>k.has(Ae)||Nu("Cannot "+xt);var dt=(Ae,k,xt)=>(Ru(Ae,k,"read from private field"),xt?xt.call(Ae):k.get(Ae)),Iu=(Ae,k,xt)=>k.has(Ae)?Nu("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(Ae):k.set(Ae,xt),ji=(Ae,k,xt,Os)=>(Ru(Ae,k,"write to private field"),Os?Os.call(Ae,xt):k.set(Ae,xt),xt);var We,Ct;function Os(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const O=Os(k),Lu=Os(xt);var hn={exports:{}},Ps={};var Oi;function $u(){if(Oi)return Ps;Oi=1;var t=k,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,n=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function i(o,l,c){var u,p={},f=null,h=null;c!==void 0&&(f=""+c),l.key!==void 0&&(f=""+l.key),l.ref!==void 0&&(h=l.ref);for(u in l)s.call(l,u)&&!a.hasOwnProperty(u)&&(p[u]=l[u]);if(o&&o.defaultProps)for(u in l=o.defaultProps,l)p[u]===void 0&&(p[u]=l[u]);return{$$typeof:e,type:o,key:f,ref:h,props:p,_owner:n.current}}return Ps.Fragment=r,Ps.jsx=i,Ps.jsxs=i,Ps}var Ns={};var Pi;function Mu(){return Pi||(Pi=1,process.env.NODE_ENV!=="production"&&(function(){var t=k,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),y=Symbol.iterator,g="@@iterator";function v(w){if(w===null||typeof w!="object")return null;var D=y&&w[y]||w[g];return typeof D=="function"?D:null}var C=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(w){{for(var D=arguments.length,H=new Array(D>1?D-1:0),fe=1;fe<D;fe++)H[fe-1]=arguments[fe];S("error",w,H)}}function S(w,D,H){{var fe=C.ReactDebugCurrentFrame,Oe=fe.getStackAddendum();Oe!==""&&(D+="%s",H=H.concat([Oe]));var Ie=H.map(function(Ce){return String(Ce)});Ie.unshift("Warning: "+D),Function.prototype.apply.call(console[w],console,Ie)}}var E=!1,T=!1,N=!1,L=!1,ue=!1,re;re=Symbol.for("react.module.reference");function je(w){return!!(typeof w=="string"||typeof w=="function"||w===s||w===a||ue||w===n||w===c||w===u||L||w===h||E||T||N||typeof w=="object"&&w!==null&&(w.$$typeof===f||w.$$typeof===p||w.$$typeof===i||w.$$typeof===o||w.$$typeof===l||w.$$typeof===re||w.getModuleId!==void 0))}function Se(w,D,H){var fe=w.displayName;if(fe)return fe;var Oe=D.displayName||D.name||"";return Oe!==""?H+"("+Oe+")":H}function F(w){return w.displayName||"Context"}function X(w){if(w==null)return null;if(typeof w.tag=="number"&&_("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof w=="function")return w.displayName||w.name||null;if(typeof w=="string")return w;switch(w){case s:return"Fragment";case r:return"Portal";case a:return"Profiler";case n:return"StrictMode";case c:return"Suspense";case u:return"SuspenseList"}if(typeof w=="object")switch(w.$$typeof){case o:var D=w;return F(D)+".Consumer";case i:var H=w;return F(H._context)+".Provider";case l:return Se(w,w.render,"ForwardRef");case p:var fe=w.displayName||null;return fe!==null?fe:X(w.type)||"Memo";case f:{var Oe=w,Ie=Oe._payload,Ce=Oe._init;try{return X(Ce(Ie))}catch{return null}}}return null}var W=Object.assign,oe=0,ye,ne,de,G,j,z,Z;function se(){}se.__reactDisabledLog=!0;function he(){{if(oe===0){ye=console.log,ne=console.info,de=console.warn,G=console.error,j=console.group,z=console.groupCollapsed,Z=console.groupEnd;var w={configurable:!0,enumerable:!0,value:se,writable:!0};Object.defineProperties(console,{info:w,log:w,warn:w,error:w,group:w,groupCollapsed:w,groupEnd:w})}oe++}}function le(){{if(oe--,oe===0){var w={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},w,{value:ye}),info:W({},w,{value:ne}),warn:W({},w,{value:de}),error:W({},w,{value:G}),group:W({},w,{value:j}),groupCollapsed:W({},w,{value:z}),groupEnd:W({},w,{value:Z})})}oe<0&&_("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=C.ReactCurrentDispatcher,ce;function tt(w,D,H){{if(ce===void 0)try{throw Error()}catch(Oe){var fe=Oe.stack.trim().match(/\n( *(at )?)/);ce=fe&&fe[1]||""}return`
1
+ (function(Ae,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],k):(Ae=typeof globalThis<"u"?globalThis:Ae||self,k(Ae.OldDoshaCalculator={},Ae.React,Ae.ReactDOM))})(this,(function(Ae,k,xt){"use strict";var Ou=Ae=>{throw TypeError(Ae)};var Pu=(Ae,k,xt)=>k.has(Ae)||Ou("Cannot "+xt);var dt=(Ae,k,xt)=>(Pu(Ae,k,"read from private field"),xt?xt.call(Ae):k.get(Ae)),Nu=(Ae,k,xt)=>k.has(Ae)?Ou("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(Ae):k.set(Ae,xt),ji=(Ae,k,xt,js)=>(Pu(Ae,k,"write to private field"),js?js.call(Ae,xt):k.set(Ae,xt),xt);var We,Ct;function js(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const O=js(k),Iu=js(xt);var dn={exports:{}},Os={};var Oi;function Du(){if(Oi)return Os;Oi=1;var t=k,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,n=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function i(o,l,c){var d,f={},p=null,h=null;c!==void 0&&(p=""+c),l.key!==void 0&&(p=""+l.key),l.ref!==void 0&&(h=l.ref);for(d in l)s.call(l,d)&&!a.hasOwnProperty(d)&&(f[d]=l[d]);if(o&&o.defaultProps)for(d in l=o.defaultProps,l)f[d]===void 0&&(f[d]=l[d]);return{$$typeof:e,type:o,key:p,ref:h,props:f,_owner:n.current}}return Os.Fragment=r,Os.jsx=i,Os.jsxs=i,Os}var Ps={};var Pi;function Lu(){return Pi||(Pi=1,process.env.NODE_ENV!=="production"&&(function(){var t=k,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),g=Symbol.iterator,y="@@iterator";function v(w){if(w===null||typeof w!="object")return null;var D=g&&w[g]||w[y];return typeof D=="function"?D:null}var C=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(w){{for(var D=arguments.length,H=new Array(D>1?D-1:0),fe=1;fe<D;fe++)H[fe-1]=arguments[fe];S("error",w,H)}}function S(w,D,H){{var fe=C.ReactDebugCurrentFrame,Oe=fe.getStackAddendum();Oe!==""&&(D+="%s",H=H.concat([Oe]));var Ie=H.map(function(Ce){return String(Ce)});Ie.unshift("Warning: "+D),Function.prototype.apply.call(console[w],console,Ie)}}var E=!1,T=!1,N=!1,L=!1,ue=!1,re;re=Symbol.for("react.module.reference");function je(w){return!!(typeof w=="string"||typeof w=="function"||w===s||w===a||ue||w===n||w===c||w===d||L||w===h||E||T||N||typeof w=="object"&&w!==null&&(w.$$typeof===p||w.$$typeof===f||w.$$typeof===i||w.$$typeof===o||w.$$typeof===l||w.$$typeof===re||w.getModuleId!==void 0))}function Se(w,D,H){var fe=w.displayName;if(fe)return fe;var Oe=D.displayName||D.name||"";return Oe!==""?H+"("+Oe+")":H}function F(w){return w.displayName||"Context"}function X(w){if(w==null)return null;if(typeof w.tag=="number"&&_("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof w=="function")return w.displayName||w.name||null;if(typeof w=="string")return w;switch(w){case s:return"Fragment";case r:return"Portal";case a:return"Profiler";case n:return"StrictMode";case c:return"Suspense";case d:return"SuspenseList"}if(typeof w=="object")switch(w.$$typeof){case o:var D=w;return F(D)+".Consumer";case i:var H=w;return F(H._context)+".Provider";case l:return Se(w,w.render,"ForwardRef");case f:var fe=w.displayName||null;return fe!==null?fe:X(w.type)||"Memo";case p:{var Oe=w,Ie=Oe._payload,Ce=Oe._init;try{return X(Ce(Ie))}catch{return null}}}return null}var W=Object.assign,oe=0,ye,ne,de,G,j,z,Z;function se(){}se.__reactDisabledLog=!0;function he(){{if(oe===0){ye=console.log,ne=console.info,de=console.warn,G=console.error,j=console.group,z=console.groupCollapsed,Z=console.groupEnd;var w={configurable:!0,enumerable:!0,value:se,writable:!0};Object.defineProperties(console,{info:w,log:w,warn:w,error:w,group:w,groupCollapsed:w,groupEnd:w})}oe++}}function le(){{if(oe--,oe===0){var w={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},w,{value:ye}),info:W({},w,{value:ne}),warn:W({},w,{value:de}),error:W({},w,{value:G}),group:W({},w,{value:j}),groupCollapsed:W({},w,{value:z}),groupEnd:W({},w,{value:Z})})}oe<0&&_("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=C.ReactCurrentDispatcher,ce;function tt(w,D,H){{if(ce===void 0)try{throw Error()}catch(Oe){var fe=Oe.stack.trim().match(/\n( *(at )?)/);ce=fe&&fe[1]||""}return`
2
2
  `+ce+w}}var Je=!1,Le;{var ut=typeof WeakMap=="function"?WeakMap:Map;Le=new ut}function qt(w,D){if(!w||Je)return"";{var H=Le.get(w);if(H!==void 0)return H}var fe;Je=!0;var Oe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ie;Ie=ae.current,ae.current=null,he();try{if(D){var Ce=function(){throw Error()};if(Object.defineProperty(Ce.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ce,[])}catch(wt){fe=wt}Reflect.construct(w,[],Ce)}else{try{Ce.call()}catch(wt){fe=wt}w.call(Ce.prototype)}}else{try{throw Error()}catch(wt){fe=wt}w()}}catch(wt){if(wt&&fe&&typeof wt.stack=="string"){for(var ke=wt.stack.split(`
3
3
  `),pt=fe.stack.split(`
4
4
  `),Ke=ke.length-1,Ge=pt.length-1;Ke>=1&&Ge>=0&&ke[Ke]!==pt[Ge];)Ge--;for(;Ke>=1&&Ge>=0;Ke--,Ge--)if(ke[Ke]!==pt[Ge]){if(Ke!==1||Ge!==1)do if(Ke--,Ge--,Ge<0||ke[Ke]!==pt[Ge]){var $t=`
5
- `+ke[Ke].replace(" at new "," at ");return w.displayName&&$t.includes("<anonymous>")&&($t=$t.replace("<anonymous>",w.displayName)),typeof w=="function"&&Le.set(w,$t),$t}while(Ke>=1&&Ge>=0);break}}}finally{Je=!1,ae.current=Ie,le(),Error.prepareStackTrace=Oe}var js=w?w.displayName||w.name:"",Yr=js?tt(js):"";return typeof w=="function"&&Le.set(w,Yr),Yr}function lt(w,D,H){return qt(w,!1)}function sr(w){var D=w.prototype;return!!(D&&D.isReactComponent)}function rt(w,D,H){if(w==null)return"";if(typeof w=="function")return qt(w,sr(w));if(typeof w=="string")return tt(w);switch(w){case c:return tt("Suspense");case u:return tt("SuspenseList")}if(typeof w=="object")switch(w.$$typeof){case l:return lt(w.render);case p:return rt(w.type,D,H);case f:{var fe=w,Oe=fe._payload,Ie=fe._init;try{return rt(Ie(Oe),D,H)}catch{}}}return""}var Dt=Object.prototype.hasOwnProperty,ht={},Gt=C.ReactDebugCurrentFrame;function Et(w){if(w){var D=w._owner,H=rt(w.type,w._source,D?D.type:null);Gt.setExtraStackFrame(H)}else Gt.setExtraStackFrame(null)}function Jt(w,D,H,fe,Oe){{var Ie=Function.call.bind(Dt);for(var Ce in w)if(Ie(w,Ce)){var ke=void 0;try{if(typeof w[Ce]!="function"){var pt=Error((fe||"React class")+": "+H+" type `"+Ce+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof w[Ce]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw pt.name="Invariant Violation",pt}ke=w[Ce](D,Ce,fe,H,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ke){ke=Ke}ke&&!(ke instanceof Error)&&(Et(Oe),_("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",fe||"React class",H,Ce,typeof ke),Et(null)),ke instanceof Error&&!(ke.message in ht)&&(ht[ke.message]=!0,Et(Oe),_("Failed %s type: %s",H,ke.message),Et(null))}}}var Tt=Array.isArray;function Lt(w){return Tt(w)}function ft(w){{var D=typeof Symbol=="function"&&Symbol.toStringTag,H=D&&w[Symbol.toStringTag]||w.constructor.name||"Object";return H}}function Pr(w){try{return Nr(w),!1}catch{return!0}}function Nr(w){return""+w}function qe(w){if(Pr(w))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ft(w)),Nr(w)}var vt=C.ReactCurrentOwner,Rr={key:!0,ref:!0,__self:!0,__source:!0},br,nr;function As(w){if(Dt.call(w,"ref")){var D=Object.getOwnPropertyDescriptor(w,"ref").get;if(D&&D.isReactWarning)return!1}return w.ref!==void 0}function U(w){if(Dt.call(w,"key")){var D=Object.getOwnPropertyDescriptor(w,"key").get;if(D&&D.isReactWarning)return!1}return w.key!==void 0}function m(w,D){typeof w.ref=="string"&&vt.current}function b(w,D){{var H=function(){br||(br=!0,_("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",D))};H.isReactWarning=!0,Object.defineProperty(w,"key",{get:H,configurable:!0})}}function x(w,D){{var H=function(){nr||(nr=!0,_("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",D))};H.isReactWarning=!0,Object.defineProperty(w,"ref",{get:H,configurable:!0})}}var A=function(w,D,H,fe,Oe,Ie,Ce){var ke={$$typeof:e,type:w,key:D,ref:H,props:Ce,_owner:Ie};return ke._store={},Object.defineProperty(ke._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ke,"_self",{configurable:!1,enumerable:!1,writable:!1,value:fe}),Object.defineProperty(ke,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Oe}),Object.freeze&&(Object.freeze(ke.props),Object.freeze(ke)),ke};function P(w,D,H,fe,Oe){{var Ie,Ce={},ke=null,pt=null;H!==void 0&&(qe(H),ke=""+H),U(D)&&(qe(D.key),ke=""+D.key),As(D)&&(pt=D.ref,m(D,Oe));for(Ie in D)Dt.call(D,Ie)&&!Rr.hasOwnProperty(Ie)&&(Ce[Ie]=D[Ie]);if(w&&w.defaultProps){var Ke=w.defaultProps;for(Ie in Ke)Ce[Ie]===void 0&&(Ce[Ie]=Ke[Ie])}if(ke||pt){var Ge=typeof w=="function"?w.displayName||w.name||"Unknown":w;ke&&b(Ce,Ge),pt&&x(Ce,Ge)}return A(w,ke,pt,Oe,fe,vt.current,Ce)}}var I=C.ReactCurrentOwner,M=C.ReactDebugCurrentFrame;function R(w){if(w){var D=w._owner,H=rt(w.type,w._source,D?D.type:null);M.setExtraStackFrame(H)}else M.setExtraStackFrame(null)}var J;J=!1;function ee(w){return typeof w=="object"&&w!==null&&w.$$typeof===e}function _e(){{if(I.current){var w=X(I.current.type);if(w)return`
5
+ `+ke[Ke].replace(" at new "," at ");return w.displayName&&$t.includes("<anonymous>")&&($t=$t.replace("<anonymous>",w.displayName)),typeof w=="function"&&Le.set(w,$t),$t}while(Ke>=1&&Ge>=0);break}}}finally{Je=!1,ae.current=Ie,le(),Error.prepareStackTrace=Oe}var As=w?w.displayName||w.name:"",Zr=As?tt(As):"";return typeof w=="function"&&Le.set(w,Zr),Zr}function lt(w,D,H){return qt(w,!1)}function sr(w){var D=w.prototype;return!!(D&&D.isReactComponent)}function rt(w,D,H){if(w==null)return"";if(typeof w=="function")return qt(w,sr(w));if(typeof w=="string")return tt(w);switch(w){case c:return tt("Suspense");case d:return tt("SuspenseList")}if(typeof w=="object")switch(w.$$typeof){case l:return lt(w.render);case f:return rt(w.type,D,H);case p:{var fe=w,Oe=fe._payload,Ie=fe._init;try{return rt(Ie(Oe),D,H)}catch{}}}return""}var Dt=Object.prototype.hasOwnProperty,ht={},Gt=C.ReactDebugCurrentFrame;function Et(w){if(w){var D=w._owner,H=rt(w.type,w._source,D?D.type:null);Gt.setExtraStackFrame(H)}else Gt.setExtraStackFrame(null)}function Jt(w,D,H,fe,Oe){{var Ie=Function.call.bind(Dt);for(var Ce in w)if(Ie(w,Ce)){var ke=void 0;try{if(typeof w[Ce]!="function"){var pt=Error((fe||"React class")+": "+H+" type `"+Ce+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof w[Ce]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw pt.name="Invariant Violation",pt}ke=w[Ce](D,Ce,fe,H,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ke){ke=Ke}ke&&!(ke instanceof Error)&&(Et(Oe),_("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",fe||"React class",H,Ce,typeof ke),Et(null)),ke instanceof Error&&!(ke.message in ht)&&(ht[ke.message]=!0,Et(Oe),_("Failed %s type: %s",H,ke.message),Et(null))}}}var Tt=Array.isArray;function Lt(w){return Tt(w)}function ft(w){{var D=typeof Symbol=="function"&&Symbol.toStringTag,H=D&&w[Symbol.toStringTag]||w.constructor.name||"Object";return H}}function Pr(w){try{return Nr(w),!1}catch{return!0}}function Nr(w){return""+w}function qe(w){if(Pr(w))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ft(w)),Nr(w)}var vt=C.ReactCurrentOwner,Rr={key:!0,ref:!0,__self:!0,__source:!0},br,nr;function Ts(w){if(Dt.call(w,"ref")){var D=Object.getOwnPropertyDescriptor(w,"ref").get;if(D&&D.isReactWarning)return!1}return w.ref!==void 0}function U(w){if(Dt.call(w,"key")){var D=Object.getOwnPropertyDescriptor(w,"key").get;if(D&&D.isReactWarning)return!1}return w.key!==void 0}function m(w,D){typeof w.ref=="string"&&vt.current}function b(w,D){{var H=function(){br||(br=!0,_("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",D))};H.isReactWarning=!0,Object.defineProperty(w,"key",{get:H,configurable:!0})}}function x(w,D){{var H=function(){nr||(nr=!0,_("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",D))};H.isReactWarning=!0,Object.defineProperty(w,"ref",{get:H,configurable:!0})}}var A=function(w,D,H,fe,Oe,Ie,Ce){var ke={$$typeof:e,type:w,key:D,ref:H,props:Ce,_owner:Ie};return ke._store={},Object.defineProperty(ke._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ke,"_self",{configurable:!1,enumerable:!1,writable:!1,value:fe}),Object.defineProperty(ke,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Oe}),Object.freeze&&(Object.freeze(ke.props),Object.freeze(ke)),ke};function P(w,D,H,fe,Oe){{var Ie,Ce={},ke=null,pt=null;H!==void 0&&(qe(H),ke=""+H),U(D)&&(qe(D.key),ke=""+D.key),Ts(D)&&(pt=D.ref,m(D,Oe));for(Ie in D)Dt.call(D,Ie)&&!Rr.hasOwnProperty(Ie)&&(Ce[Ie]=D[Ie]);if(w&&w.defaultProps){var Ke=w.defaultProps;for(Ie in Ke)Ce[Ie]===void 0&&(Ce[Ie]=Ke[Ie])}if(ke||pt){var Ge=typeof w=="function"?w.displayName||w.name||"Unknown":w;ke&&b(Ce,Ge),pt&&x(Ce,Ge)}return A(w,ke,pt,Oe,fe,vt.current,Ce)}}var I=C.ReactCurrentOwner,M=C.ReactDebugCurrentFrame;function R(w){if(w){var D=w._owner,H=rt(w.type,w._source,D?D.type:null);M.setExtraStackFrame(H)}else M.setExtraStackFrame(null)}var J;J=!1;function ee(w){return typeof w=="object"&&w!==null&&w.$$typeof===e}function _e(){{if(I.current){var w=X(I.current.type);if(w)return`
6
6
 
7
7
  Check the render method of \``+w+"`."}return""}}function Ze(w){return""}var te={};function we(w){{var D=_e();if(!D){var H=typeof w=="string"?w:w.displayName||w.name;H&&(D=`
8
8
 
9
- Check the top-level render call using <`+H+">.")}return D}}function ve(w,D){{if(!w._store||w._store.validated||w.key!=null)return;w._store.validated=!0;var H=we(D);if(te[H])return;te[H]=!0;var fe="";w&&w._owner&&w._owner!==I.current&&(fe=" It was passed a child from "+X(w._owner.type)+"."),R(w),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',H,fe),R(null)}}function $e(w,D){{if(typeof w!="object")return;if(Lt(w))for(var H=0;H<w.length;H++){var fe=w[H];ee(fe)&&ve(fe,D)}else if(ee(w))w._store&&(w._store.validated=!0);else if(w){var Oe=v(w);if(typeof Oe=="function"&&Oe!==w.entries)for(var Ie=Oe.call(w),Ce;!(Ce=Ie.next()).done;)ee(Ce.value)&&ve(Ce.value,D)}}}function st(w){{var D=w.type;if(D==null||typeof D=="string")return;var H;if(typeof D=="function")H=D.propTypes;else if(typeof D=="object"&&(D.$$typeof===l||D.$$typeof===p))H=D.propTypes;else return;if(H){var fe=X(D);Jt(H,w.props,"prop",fe,w)}else if(D.PropTypes!==void 0&&!J){J=!0;var Oe=X(D);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Oe||"Unknown")}typeof D.getDefaultProps=="function"&&!D.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function At(w){{for(var D=Object.keys(w.props),H=0;H<D.length;H++){var fe=D[H];if(fe!=="children"&&fe!=="key"){R(w),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",fe),R(null);break}}w.ref!==null&&(R(w),_("Invalid attribute `ref` supplied to `React.Fragment`."),R(null))}}var ar={};function bt(w,D,H,fe,Oe,Ie){{var Ce=je(w);if(!Ce){var ke="";(w===void 0||typeof w=="object"&&w!==null&&Object.keys(w).length===0)&&(ke+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var pt=Ze();pt?ke+=pt:ke+=_e();var Ke;w===null?Ke="null":Lt(w)?Ke="array":w!==void 0&&w.$$typeof===e?(Ke="<"+(X(w.type)||"Unknown")+" />",ke=" Did you accidentally export a JSX literal instead of a component?"):Ke=typeof w,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ke,ke)}var Ge=P(w,D,H,Oe,Ie);if(Ge==null)return Ge;if(Ce){var $t=D.children;if($t!==void 0)if(fe)if(Lt($t)){for(var js=0;js<$t.length;js++)$e($t[js],w);Object.freeze&&Object.freeze($t)}else _("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else $e($t,w)}if(Dt.call(D,"key")){var Yr=X(w),wt=Object.keys(D).filter(function(kb){return kb!=="key"}),Ai=wt.length>0?"{key: someKey, "+wt.join(": ..., ")+": ...}":"{key: someKey}";if(!ar[Yr+Ai]){var _b=wt.length>0?"{"+wt.join(": ..., ")+": ...}":"{}";_(`A props object containing a "key" prop is being spread into JSX:
9
+ Check the top-level render call using <`+H+">.")}return D}}function ve(w,D){{if(!w._store||w._store.validated||w.key!=null)return;w._store.validated=!0;var H=we(D);if(te[H])return;te[H]=!0;var fe="";w&&w._owner&&w._owner!==I.current&&(fe=" It was passed a child from "+X(w._owner.type)+"."),R(w),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',H,fe),R(null)}}function $e(w,D){{if(typeof w!="object")return;if(Lt(w))for(var H=0;H<w.length;H++){var fe=w[H];ee(fe)&&ve(fe,D)}else if(ee(w))w._store&&(w._store.validated=!0);else if(w){var Oe=v(w);if(typeof Oe=="function"&&Oe!==w.entries)for(var Ie=Oe.call(w),Ce;!(Ce=Ie.next()).done;)ee(Ce.value)&&ve(Ce.value,D)}}}function st(w){{var D=w.type;if(D==null||typeof D=="string")return;var H;if(typeof D=="function")H=D.propTypes;else if(typeof D=="object"&&(D.$$typeof===l||D.$$typeof===f))H=D.propTypes;else return;if(H){var fe=X(D);Jt(H,w.props,"prop",fe,w)}else if(D.PropTypes!==void 0&&!J){J=!0;var Oe=X(D);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Oe||"Unknown")}typeof D.getDefaultProps=="function"&&!D.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function At(w){{for(var D=Object.keys(w.props),H=0;H<D.length;H++){var fe=D[H];if(fe!=="children"&&fe!=="key"){R(w),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",fe),R(null);break}}w.ref!==null&&(R(w),_("Invalid attribute `ref` supplied to `React.Fragment`."),R(null))}}var ar={};function bt(w,D,H,fe,Oe,Ie){{var Ce=je(w);if(!Ce){var ke="";(w===void 0||typeof w=="object"&&w!==null&&Object.keys(w).length===0)&&(ke+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var pt=Ze();pt?ke+=pt:ke+=_e();var Ke;w===null?Ke="null":Lt(w)?Ke="array":w!==void 0&&w.$$typeof===e?(Ke="<"+(X(w.type)||"Unknown")+" />",ke=" Did you accidentally export a JSX literal instead of a component?"):Ke=typeof w,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ke,ke)}var Ge=P(w,D,H,Oe,Ie);if(Ge==null)return Ge;if(Ce){var $t=D.children;if($t!==void 0)if(fe)if(Lt($t)){for(var As=0;As<$t.length;As++)$e($t[As],w);Object.freeze&&Object.freeze($t)}else _("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else $e($t,w)}if(Dt.call(D,"key")){var Zr=X(w),wt=Object.keys(D).filter(function(vb){return vb!=="key"}),Ai=wt.length>0?"{key: someKey, "+wt.join(": ..., ")+": ...}":"{key: someKey}";if(!ar[Zr+Ai]){var yb=wt.length>0?"{"+wt.join(": ..., ")+": ...}":"{}";_(`A props object containing a "key" prop is being spread into JSX:
10
10
  let props = %s;
11
11
  <%s {...props} />
12
12
  React keys must be passed directly to JSX without using spread:
13
13
  let props = %s;
14
- <%s key={someKey} {...props} />`,Ai,Yr,_b,Yr),ar[Yr+Ai]=!0}}return w===s?At(Ge):st(Ge),Ge}}function ir(w,D,H){return bt(w,D,H,!0)}function bb(w,D,H){return bt(w,D,H,!1)}var wb=bb,xb=ir;Ns.Fragment=s,Ns.jsx=wb,Ns.jsxs=xb})()),Ns}var Ni;function Fu(){return Ni||(Ni=1,process.env.NODE_ENV==="production"?hn.exports=$u():hn.exports=Mu()),hn.exports}var d=Fu();const fa={all_fields_filled:"all_fields_filled",fields_not_filled:"fields_not_filled",puja_clicked:"puja_clicked"},nt=(t,e)=>{typeof window<"u"&&console.log("Track Event:",t,e)},Uu=()=>{if(typeof window>"u")return{};const t=new URLSearchParams(window.location.search);return{utm_source:t.get("utm_source"),utm_medium:t.get("utm_medium"),utm_campaign:t.get("utm_campaign"),utm_term:t.get("utm_term"),utm_content:t.get("utm_content")}},pe=t=>typeof t=="string",Rs=()=>{let t,e;const r=new Promise((s,n)=>{t=s,e=n});return r.resolve=t,r.reject=e,r},Ri=t=>t==null?"":""+t,Bu=(t,e,r)=>{t.forEach(s=>{e[s]&&(r[s]=e[s])})},Vu=/###/g,Ii=t=>t&&t.indexOf("###")>-1?t.replace(Vu,"."):t,Di=t=>!t||pe(t),Is=(t,e,r)=>{const s=pe(e)?e.split("."):e;let n=0;for(;n<s.length-1;){if(Di(t))return{};const a=Ii(s[n]);!t[a]&&r&&(t[a]=new r),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++n}return Di(t)?{}:{obj:t,k:Ii(s[n])}},Li=(t,e,r)=>{const{obj:s,k:n}=Is(t,e,Object);if(s!==void 0||e.length===1){s[n]=r;return}let a=e[e.length-1],i=e.slice(0,e.length-1),o=Is(t,i,Object);for(;o.obj===void 0&&i.length;)a=`${i[i.length-1]}.${a}`,i=i.slice(0,i.length-1),o=Is(t,i,Object),o&&o.obj&&typeof o.obj[`${o.k}.${a}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${a}`]=r},Ku=(t,e,r,s)=>{const{obj:n,k:a}=Is(t,e,Object);n[a]=n[a]||[],n[a].push(r)},fn=(t,e)=>{const{obj:r,k:s}=Is(t,e);if(r)return r[s]},zu=(t,e,r)=>{const s=fn(t,r);return s!==void 0?s:fn(e,r)},$i=(t,e,r)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in t?pe(t[s])||t[s]instanceof String||pe(e[s])||e[s]instanceof String?r&&(t[s]=e[s]):$i(t[s],e[s],r):t[s]=e[s]);return t},Xr=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Hu={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Wu=t=>pe(t)?t.replace(/[&<>"'\/]/g,e=>Hu[e]):t;class qu{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const r=this.regExpMap.get(e);if(r!==void 0)return r;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}const Gu=[" ",",","?","!",";"],Ju=new qu(20),Zu=(t,e,r)=>{e=e||"",r=r||"";const s=Gu.filter(i=>e.indexOf(i)<0&&r.indexOf(i)<0);if(s.length===0)return!0;const n=Ju.getRegExp(`(${s.map(i=>i==="?"?"\\?":i).join("|")})`);let a=!n.test(t);if(!a){const i=t.indexOf(r);i>0&&!n.test(t.substring(0,i))&&(a=!0)}return a},pa=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return t[e];const s=e.split(r);let n=t;for(let a=0;a<s.length;){if(!n||typeof n!="object")return;let i,o="";for(let l=a;l<s.length;++l)if(l!==a&&(o+=r),o+=s[l],i=n[o],i!==void 0){if(["string","number","boolean"].indexOf(typeof i)>-1&&l<s.length-1)continue;a+=l-a+1;break}n=i}return n},pn=t=>t&&t.replace("_","-"),Yu={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console&&console[t]&&console[t].apply(console,e)}};class mn{constructor(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,r)}init(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=e||Yu,this.options=r,this.debug=r.debug}log(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return this.forward(r,"log","",!0)}warn(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return this.forward(r,"warn","",!0)}error(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return this.forward(r,"error","")}deprecate(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return this.forward(r,"warn","WARNING DEPRECATED: ",!0)}forward(e,r,s,n){return n&&!this.debug?null:(pe(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[r](e))}create(e){return new mn(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new mn(this.logger,e)}}var Zt=new mn;class gn{constructor(){this.observers={}}on(e,r){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const n=this.observers[s].get(r)||0;this.observers[s].set(r,n+1)}),this}off(e,r){if(this.observers[e]){if(!r){delete this.observers[e];return}this.observers[e].delete(r)}}emit(e){for(var r=arguments.length,s=new Array(r>1?r-1:0),n=1;n<r;n++)s[n-1]=arguments[n];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(i=>{let[o,l]=i;for(let c=0;c<l;c++)o(...s)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(i=>{let[o,l]=i;for(let c=0;c<l;c++)o.apply(o,[e,...s])})}}class Mi extends gn{constructor(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const r=this.options.ns.indexOf(e);r>-1&&this.options.ns.splice(r,1)}getResource(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,i=n.ignoreJSONStructure!==void 0?n.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,r],s&&(Array.isArray(s)?o.push(...s):pe(s)&&a?o.push(...s.split(a)):o.push(s)));const l=fn(this.data,o);return!l&&!r&&!s&&e.indexOf(".")>-1&&(e=o[0],r=o[1],s=o.slice(2).join(".")),l||!i||!pe(s)?l:pa(this.data&&this.data[e]&&this.data[e][r],s,a)}addResource(e,r,s,n){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let o=[e,r];s&&(o=o.concat(i?s.split(i):s)),e.indexOf(".")>-1&&(o=e.split("."),n=r,r=o[1]),this.addNamespaces(r),Li(this.data,o,n),a.silent||this.emit("added",e,r,s,n)}addResources(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const a in s)(pe(s[a])||Array.isArray(s[a]))&&this.addResource(e,r,a,s[a],{silent:!0});n.silent||this.emit("added",e,r,s)}addResourceBundle(e,r,s,n,a){let i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},o=[e,r];e.indexOf(".")>-1&&(o=e.split("."),n=s,s=r,r=o[1]),this.addNamespaces(r);let l=fn(this.data,o)||{};i.skipCopy||(s=JSON.parse(JSON.stringify(s))),n?$i(l,s,a):l={...l,...s},Li(this.data,o,l),i.silent||this.emit("added",e,r,s)}removeResourceBundle(e,r){this.hasResourceBundle(e,r)&&delete this.data[e][r],this.removeNamespaces(r),this.emit("removed",e,r)}hasResourceBundle(e,r){return this.getResource(e,r)!==void 0}getResourceBundle(e,r){return r||(r=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(e,r)}:this.getResource(e,r)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const r=this.getDataByLanguage(e);return!!(r&&Object.keys(r)||[]).find(n=>r[n]&&Object.keys(r[n]).length>0)}toJSON(){return this.data}}var Fi={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,r,s,n){return t.forEach(a=>{this.processors[a]&&(e=this.processors[a].process(e,r,s,n))}),e}};const Ui={};class yn extends gn{constructor(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Bu(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Zt.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const s=this.resolve(e,r);return s&&s.res!==void 0}extractFromKey(e,r){let s=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const n=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let a=r.ns||this.options.defaultNS||[];const i=s&&e.indexOf(s)>-1,o=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!Zu(e,s,n);if(i&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:pe(a)?[a]:a};const c=e.split(s);(s!==n||s===n&&this.options.ns.indexOf(c[0])>-1)&&(a=c.shift()),e=c.join(n)}return{key:e,namespaces:pe(a)?[a]:a}}translate(e,r,s){if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:i,namespaces:o}=this.extractFromKey(e[e.length-1],r),l=o[o.length-1],c=r.lng||this.language,u=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c&&c.toLowerCase()==="cimode"){if(u){const E=r.nsSeparator||this.options.nsSeparator;return n?{res:`${l}${E}${i}`,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:`${l}${E}${i}`}return n?{res:i,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:i}const p=this.resolve(e,r);let f=p&&p.res;const h=p&&p.usedKey||i,y=p&&p.exactUsedKey||i,g=Object.prototype.toString.apply(f),v=["[object Number]","[object Function]","[object RegExp]"],C=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,_=!this.i18nFormat||this.i18nFormat.handleAsObject,S=!pe(f)&&typeof f!="boolean"&&typeof f!="number";if(_&&f&&S&&v.indexOf(g)<0&&!(pe(C)&&Array.isArray(f))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const E=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,f,{...r,ns:o}):`key '${i} (${this.language})' returned an object instead of string.`;return n?(p.res=E,p.usedParams=this.getUsedParamsDetails(r),p):E}if(a){const E=Array.isArray(f),T=E?[]:{},N=E?y:h;for(const L in f)if(Object.prototype.hasOwnProperty.call(f,L)){const ue=`${N}${a}${L}`;T[L]=this.translate(ue,{...r,joinArrays:!1,ns:o}),T[L]===ue&&(T[L]=f[L])}f=T}}else if(_&&pe(C)&&Array.isArray(f))f=f.join(C),f&&(f=this.extendTranslation(f,e,r,s));else{let E=!1,T=!1;const N=r.count!==void 0&&!pe(r.count),L=yn.hasDefaultValue(r),ue=N?this.pluralResolver.getSuffix(c,r.count,r):"",re=r.ordinal&&N?this.pluralResolver.getSuffix(c,r.count,{ordinal:!1}):"",je=N&&!r.ordinal&&r.count===0&&this.pluralResolver.shouldUseIntlApi(),Se=je&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${ue}`]||r[`defaultValue${re}`]||r.defaultValue;!this.isValidLookup(f)&&L&&(E=!0,f=Se),this.isValidLookup(f)||(T=!0,f=i);const X=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&T?void 0:f,W=L&&Se!==f&&this.options.updateMissing;if(T||E||W){if(this.logger.log(W?"updateKey":"missingKey",c,l,i,W?Se:f),a){const de=this.resolve(i,{...r,keySeparator:!1});de&&de.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let oe=[];const ye=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ye&&ye[0])for(let de=0;de<ye.length;de++)oe.push(ye[de]);else this.options.saveMissingTo==="all"?oe=this.languageUtils.toResolveHierarchy(r.lng||this.language):oe.push(r.lng||this.language);const ne=(de,G,j)=>{const z=L&&j!==f?j:X;this.options.missingKeyHandler?this.options.missingKeyHandler(de,l,G,z,W,r):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(de,l,G,z,W,r),this.emit("missingKey",de,l,G,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?oe.forEach(de=>{const G=this.pluralResolver.getSuffixes(de,r);je&&r[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(j=>{ne([de],i+j,r[`defaultValue${j}`]||Se)})}):ne(oe,i,Se))}f=this.extendTranslation(f,e,r,p,s),T&&f===i&&this.options.appendNamespaceToMissingKey&&(f=`${l}:${i}`),(T||E)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${i}`:i,E?f:void 0):f=this.options.parseMissingKeyHandler(f))}return n?(p.res=f,p.usedParams=this.getUsedParamsDetails(r),p):f}extendTranslation(e,r,s,n,a){var i=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const c=pe(e)&&(s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let p=s.replace&&!pe(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(p={...this.options.interpolation.defaultVariables,...p}),e=this.interpolator.interpolate(e,p,s.lng||this.language||n.usedLng,s),c){const f=e.match(this.interpolator.nestingRegexp),h=f&&f.length;u<h&&(s.nest=!1)}!s.lng&&this.options.compatibilityAPI!=="v1"&&n&&n.res&&(s.lng=this.language||n.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var f=arguments.length,h=new Array(f),y=0;y<f;y++)h[y]=arguments[y];return a&&a[0]===h[0]&&!s.context?(i.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${r[0]}`),null):i.translate(...h,r)},s)),s.interpolation&&this.interpolator.reset()}const o=s.postProcess||this.options.postProcess,l=pe(o)?[o]:o;return e!=null&&l&&l.length&&s.applyPostProcessor!==!1&&(e=Fi.handle(l,e,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),e}resolve(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s,n,a,i,o;return pe(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(s))return;const c=this.extractFromKey(l,r),u=c.key;n=u;let p=c.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const f=r.count!==void 0&&!pe(r.count),h=f&&!r.ordinal&&r.count===0&&this.pluralResolver.shouldUseIntlApi(),y=r.context!==void 0&&(pe(r.context)||typeof r.context=="number")&&r.context!=="",g=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);p.forEach(v=>{this.isValidLookup(s)||(o=v,!Ui[`${g[0]}-${v}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(o)&&(Ui[`${g[0]}-${v}`]=!0,this.logger.warn(`key "${n}" for languages "${g.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),g.forEach(C=>{if(this.isValidLookup(s))return;i=C;const _=[u];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(_,u,C,v,r);else{let E;f&&(E=this.pluralResolver.getSuffix(C,r.count,r));const T=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(f&&(_.push(u+E),r.ordinal&&E.indexOf(N)===0&&_.push(u+E.replace(N,this.options.pluralSeparator)),h&&_.push(u+T)),y){const L=`${u}${this.options.contextSeparator}${r.context}`;_.push(L),f&&(_.push(L+E),r.ordinal&&E.indexOf(N)===0&&_.push(L+E.replace(N,this.options.pluralSeparator)),h&&_.push(L+T))}}let S;for(;S=_.pop();)this.isValidLookup(s)||(a=S,s=this.getResource(C,v,S,r))}))})}),{res:s,usedKey:n,exactUsedKey:a,usedLng:i,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,r,s,n):this.resourceStore.getResource(e,r,s,n)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!pe(e.replace);let n=s?e.replace:e;if(s&&typeof e.count<"u"&&(n.count=e.count),this.options.interpolation.defaultVariables&&(n={...this.options.interpolation.defaultVariables,...n}),!s){n={...n};for(const a of r)delete n[a]}return n}static hasDefaultValue(e){const r="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&r===s.substring(0,r.length)&&e[s]!==void 0)return!0;return!1}}const ma=t=>t.charAt(0).toUpperCase()+t.slice(1);class Bi{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Zt.create("languageUtils")}getScriptPartFromCode(e){if(e=pn(e),!e||e.indexOf("-")<0)return null;const r=e.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(e){if(e=pn(e),!e||e.indexOf("-")<0)return e;const r=e.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(e){if(pe(e)&&e.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let n=Intl.getCanonicalLocales(e)[0];if(n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n)return n}catch{}const r=["hans","hant","latn","cyrl","cans","mong","arab"];let s=e.split("-");return this.options.lowerCaseLng?s=s.map(n=>n.toLowerCase()):s.length===2?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),r.indexOf(s[1].toLowerCase())>-1&&(s[1]=ma(s[1].toLowerCase()))):s.length===3&&(s[0]=s[0].toLowerCase(),s[1].length===2&&(s[1]=s[1].toUpperCase()),s[0]!=="sgn"&&s[2].length===2&&(s[2]=s[2].toUpperCase()),r.indexOf(s[1].toLowerCase())>-1&&(s[1]=ma(s[1].toLowerCase())),r.indexOf(s[2].toLowerCase())>-1&&(s[2]=ma(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let r;return e.forEach(s=>{if(r)return;const n=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(n))&&(r=n)}),!r&&this.options.supportedLngs&&e.forEach(s=>{if(r)return;const n=this.getLanguagePartFromCode(s);if(this.isSupportedCode(n))return r=n;r=this.options.supportedLngs.find(a=>{if(a===n)return a;if(!(a.indexOf("-")<0&&n.indexOf("-")<0)&&(a.indexOf("-")>0&&n.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===n||a.indexOf(n)===0&&n.length>1))return a})}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(e,r){if(!e)return[];if(typeof e=="function"&&(e=e(r)),pe(e)&&(e=[e]),Array.isArray(e))return e;if(!r)return e.default||[];let s=e[r];return s||(s=e[this.getScriptPartFromCode(r)]),s||(s=e[this.formatLanguageCode(r)]),s||(s=e[this.getLanguagePartFromCode(r)]),s||(s=e.default),s||[]}toResolveHierarchy(e,r){const s=this.getFallbackCodes(r||this.options.fallbackLng||[],e),n=[],a=i=>{i&&(this.isSupportedCode(i)?n.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return pe(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):pe(e)&&a(this.formatLanguageCode(e)),s.forEach(i=>{n.indexOf(i)<0&&a(this.formatLanguageCode(i))}),n}}let Xu=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Qu={1:t=>+(t>1),2:t=>+(t!=1),3:t=>0,4:t=>t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2,5:t=>t==0?0:t==1?1:t==2?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5,6:t=>t==1?0:t>=2&&t<=4?1:2,7:t=>t==1?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2,8:t=>t==1?0:t==2?1:t!=8&&t!=11?2:3,9:t=>+(t>=2),10:t=>t==1?0:t==2?1:t<7?2:t<11?3:4,11:t=>t==1||t==11?0:t==2||t==12?1:t>2&&t<20?2:3,12:t=>+(t%10!=1||t%100==11),13:t=>+(t!==0),14:t=>t==1?0:t==2?1:t==3?2:3,15:t=>t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2,16:t=>t%10==1&&t%100!=11?0:t!==0?1:2,17:t=>t==1||t%10==1&&t%100!=11?0:1,18:t=>t==0?0:t==1?1:2,19:t=>t==1?0:t==0||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3,20:t=>t==1?0:t==0||t%100>0&&t%100<20?1:2,21:t=>t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0,22:t=>t==1?0:t==2?1:(t<0||t>10)&&t%10==0?2:3};const ed=["v1","v2","v3"],td=["v4"],Vi={zero:0,one:1,two:2,few:3,many:4,other:5},rd=()=>{const t={};return Xu.forEach(e=>{e.lngs.forEach(r=>{t[r]={numbers:e.nr,plurals:Qu[e.fc]}})}),t};class sd{constructor(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=r,this.logger=Zt.create("pluralResolver"),(!this.options.compatibilityJSON||td.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=rd(),this.pluralRulesCache={}}addRule(e,r){this.rules[e]=r}clearCache(){this.pluralRulesCache={}}getRule(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi()){const s=pn(e==="dev"?"en":e),n=r.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:s,type:n});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let i;try{i=new Intl.PluralRules(s,{type:n})}catch{if(!e.match(/-|_/))return;const l=this.languageUtils.getLanguagePartFromCode(e);i=this.getRule(l,r)}return this.pluralRulesCache[a]=i,i}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}needsPlural(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=this.getRule(e,r);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}getPluralFormsOfKey(e,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,s).map(n=>`${r}${n}`)}getSuffixes(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=this.getRule(e,r);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort((n,a)=>Vi[n]-Vi[a]).map(n=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${n}`):s.numbers.map(n=>this.getSuffix(e,n,r)):[]}getSuffix(e,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const n=this.getRule(e,s);return n?this.shouldUseIntlApi()?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${n.select(r)}`:this.getSuffixRetroCompatible(n,r):(this.logger.warn(`no plural rule found for: ${e}`),"")}getSuffixRetroCompatible(e,r){const s=e.noAbs?e.plurals(r):e.plurals(Math.abs(r));let n=e.numbers[s];this.options.simplifyPluralSuffix&&e.numbers.length===2&&e.numbers[0]===1&&(n===2?n="plural":n===1&&(n=""));const a=()=>this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString();return this.options.compatibilityJSON==="v1"?n===1?"":typeof n=="number"?`_plural_${n.toString()}`:a():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&e.numbers.length===2&&e.numbers[0]===1?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}shouldUseIntlApi(){return!ed.includes(this.options.compatibilityJSON)}}const Ki=function(t,e,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=zu(t,e,r);return!a&&n&&pe(r)&&(a=pa(t,r,s),a===void 0&&(a=pa(e,r,s))),a},ga=t=>t.replace(/\$/g,"$$$$");class nd{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Zt.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||(r=>r),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const{escape:r,escapeValue:s,useRawValueToEscape:n,prefix:a,prefixEscaped:i,suffix:o,suffixEscaped:l,formatSeparator:c,unescapeSuffix:u,unescapePrefix:p,nestingPrefix:f,nestingPrefixEscaped:h,nestingSuffix:y,nestingSuffixEscaped:g,nestingOptionsSeparator:v,maxReplaces:C,alwaysFormat:_}=e.interpolation;this.escape=r!==void 0?r:Wu,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=n!==void 0?n:!1,this.prefix=a?Xr(a):i||"{{",this.suffix=o?Xr(o):l||"}}",this.formatSeparator=c||",",this.unescapePrefix=u?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=f?Xr(f):h||Xr("$t("),this.nestingSuffix=y?Xr(y):g||Xr(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=C||1e3,this.alwaysFormat=_!==void 0?_:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(r,s)=>r&&r.source===s?(r.lastIndex=0,r):new RegExp(s,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,r,s,n){let a,i,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=h=>{if(h.indexOf(this.formatSeparator)<0){const C=Ki(r,l,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,s,{...n,...r,interpolationkey:h}):C}const y=h.split(this.formatSeparator),g=y.shift().trim(),v=y.join(this.formatSeparator).trim();return this.format(Ki(r,l,g,this.options.keySeparator,this.options.ignoreJSONStructure),v,s,{...n,...r,interpolationkey:g})};this.resetRegExp();const u=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,p=n&&n.interpolation&&n.interpolation.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>ga(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?ga(this.escape(h)):ga(h)}].forEach(h=>{for(o=0;a=h.regex.exec(e);){const y=a[1].trim();if(i=c(y),i===void 0)if(typeof u=="function"){const v=u(e,a,n);i=pe(v)?v:""}else if(n&&Object.prototype.hasOwnProperty.call(n,y))i="";else if(p){i=a[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${e}`),i="";else!pe(i)&&!this.useRawValueToEscape&&(i=Ri(i));const g=h.safeValue(i);if(e=e.replace(a[0],g),p?(h.regex.lastIndex+=i.length,h.regex.lastIndex-=a[0].length):h.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n,a,i;const o=(l,c)=>{const u=this.nestingOptionsSeparator;if(l.indexOf(u)<0)return l;const p=l.split(new RegExp(`${u}[ ]*{`));let f=`{${p[1]}`;l=p[0],f=this.interpolate(f,i);const h=f.match(/'/g),y=f.match(/"/g);(h&&h.length%2===0&&!y||y.length%2!==0)&&(f=f.replace(/'/g,'"'));try{i=JSON.parse(f),c&&(i={...c,...i})}catch(g){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,g),`${l}${u}${f}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,l};for(;n=this.nestingRegexp.exec(e);){let l=[];i={...s},i=i.replace&&!pe(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;let c=!1;if(n[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(n[1])){const u=n[1].split(this.formatSeparator).map(p=>p.trim());n[1]=u.shift(),l=u,c=!0}if(a=r(o.call(this,n[1].trim(),i),i),a&&n[0]===e&&!pe(a))return a;pe(a)||(a=Ri(a)),a||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),a=""),c&&(a=l.reduce((u,p)=>this.format(u,p,s.lng,{...s,interpolationkey:n[1].trim()}),a.trim())),e=e.replace(n[0],a),this.regexp.lastIndex=0}return e}}const ad=t=>{let e=t.toLowerCase().trim();const r={};if(t.indexOf("(")>-1){const s=t.split("(");e=s[0].toLowerCase().trim();const n=s[1].substring(0,s[1].length-1);e==="currency"&&n.indexOf(":")<0?r.currency||(r.currency=n.trim()):e==="relativetime"&&n.indexOf(":")<0?r.range||(r.range=n.trim()):n.split(";").forEach(i=>{if(i){const[o,...l]=i.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),u=o.trim();r[u]||(r[u]=c),c==="false"&&(r[u]=!1),c==="true"&&(r[u]=!0),isNaN(c)||(r[u]=parseInt(c,10))}})}return{formatName:e,formatOptions:r}},Qr=t=>{const e={};return(r,s,n)=>{let a=n;n&&n.interpolationkey&&n.formatParams&&n.formatParams[n.interpolationkey]&&n[n.interpolationkey]&&(a={...a,[n.interpolationkey]:void 0});const i=s+JSON.stringify(a);let o=e[i];return o||(o=t(pn(s),n),e[i]=o),o(r)}};class id{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Zt.create("formatter"),this.options=e,this.formats={number:Qr((r,s)=>{const n=new Intl.NumberFormat(r,{...s});return a=>n.format(a)}),currency:Qr((r,s)=>{const n=new Intl.NumberFormat(r,{...s,style:"currency"});return a=>n.format(a)}),datetime:Qr((r,s)=>{const n=new Intl.DateTimeFormat(r,{...s});return a=>n.format(a)}),relativetime:Qr((r,s)=>{const n=new Intl.RelativeTimeFormat(r,{...s});return a=>n.format(a,s.range||"day")}),list:Qr((r,s)=>{const n=new Intl.ListFormat(r,{...s});return a=>n.format(a)})},this.init(e)}init(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=r.interpolation.formatSeparator||","}add(e,r){this.formats[e.toLowerCase().trim()]=r}addCached(e,r){this.formats[e.toLowerCase().trim()]=Qr(r)}format(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const a=r.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(o=>o.indexOf(")")>-1)){const o=a.findIndex(l=>l.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,o)].join(this.formatSeparator)}return a.reduce((o,l)=>{const{formatName:c,formatOptions:u}=ad(l);if(this.formats[c]){let p=o;try{const f=n&&n.formatParams&&n.formatParams[n.interpolationkey]||{},h=f.locale||f.lng||n.locale||n.lng||s;p=this.formats[c](o,h,{...u,...n,...f})}catch(f){this.logger.warn(f)}return p}else this.logger.warn(`there was no format function for ${c}`);return o},e)}}const od=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class ld extends gn{constructor(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=r,this.services=s,this.languageUtils=s.languageUtils,this.options=n,this.logger=Zt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(s,n.backend,n)}queueLoad(e,r,s,n){const a={},i={},o={},l={};return e.forEach(c=>{let u=!0;r.forEach(p=>{const f=`${c}|${p}`;!s.reload&&this.store.hasResourceBundle(c,p)?this.state[f]=2:this.state[f]<0||(this.state[f]===1?i[f]===void 0&&(i[f]=!0):(this.state[f]=1,u=!1,i[f]===void 0&&(i[f]=!0),a[f]===void 0&&(a[f]=!0),l[p]===void 0&&(l[p]=!0)))}),u||(o[c]=!0)}),(Object.keys(a).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(a),pending:Object.keys(i),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,r,s){const n=e.split("|"),a=n[0],i=n[1];r&&this.emit("failedLoading",a,i,r),!r&&s&&this.store.addResourceBundle(a,i,s,void 0,void 0,{skipCopy:!0}),this.state[e]=r?-1:2,r&&s&&(this.state[e]=0);const o={};this.queue.forEach(l=>{Ku(l.loaded,[a],i),od(l,e),r&&l.errors.push(r),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(c=>{o[c]||(o[c]={});const u=l.loaded[c];u.length&&u.forEach(p=>{o[c][p]===void 0&&(o[c][p]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,i=arguments.length>5?arguments[5]:void 0;if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:r,fcName:s,tried:n,wait:a,callback:i});return}this.readingCalls++;const o=(c,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(c&&u&&n<this.maxRetries){setTimeout(()=>{this.read.call(this,e,r,s,n+1,a*2,i)},a);return}i(c,u)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const c=l(e,r);c&&typeof c.then=="function"?c.then(u=>o(null,u)).catch(o):o(null,c)}catch(c){o(c)}return}return l(e,r,o)}prepareLoading(e,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();pe(e)&&(e=this.languageUtils.toResolveHierarchy(e)),pe(r)&&(r=[r]);const a=this.queueLoad(e,r,s,n);if(!a.toLoad.length)return a.pending.length||n(),null;a.toLoad.forEach(i=>{this.loadOne(i)})}load(e,r,s){this.prepareLoading(e,r,{},s)}reload(e,r,s){this.prepareLoading(e,r,{reload:!0},s)}loadOne(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const s=e.split("|"),n=s[0],a=s[1];this.read(n,a,"read",void 0,void 0,(i,o)=>{i&&this.logger.warn(`${r}loading namespace ${a} for language ${n} failed`,i),!i&&o&&this.logger.log(`${r}loaded namespace ${a} for language ${n}`,o),this.loaded(e,i,o)})}saveMissing(e,r,s,n,a){let i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(r)){this.logger.warn(`did not save key "${s}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if(this.backend&&this.backend.create){const l={...i,isUpdate:a},c=this.backend.create.bind(this.backend);if(c.length<6)try{let u;c.length===5?u=c(e,r,s,n,l):u=c(e,r,s,n),u&&typeof u.then=="function"?u.then(p=>o(null,p)).catch(o):o(null,u)}catch(u){o(u)}else c(e,r,s,n,o,l)}!e||!e[0]||this.store.addResource(e[0],r,s,n)}}}const zi=()=>({debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),pe(t[1])&&(e.defaultValue=t[1]),pe(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const r=t[3]||t[2];Object.keys(r).forEach(s=>{e[s]=r[s]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Hi=t=>(pe(t.ns)&&(t.ns=[t.ns]),pe(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),pe(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&t.supportedLngs.indexOf("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),vn=()=>{},cd=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(r=>{typeof t[r]=="function"&&(t[r]=t[r].bind(t))})};class Ds extends gn{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Hi(e),this.services={},this.logger=Zt,this.modules={external:[]},cd(this),r&&!this.isInitialized&&!e.isClone){if(!this.options.initImmediate)return this.init(e,r),this;setTimeout(()=>{this.init(e,r)},0)}}init(){var e=this;let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof r=="function"&&(s=r,r={}),!r.defaultNS&&r.defaultNS!==!1&&r.ns&&(pe(r.ns)?r.defaultNS=r.ns:r.ns.indexOf("translation")<0&&(r.defaultNS=r.ns[0]));const n=zi();this.options={...n,...this.options,...Hi(r)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...n.interpolation,...this.options.interpolation}),r.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=r.keySeparator),r.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=r.nsSeparator);const a=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?Zt.init(a(this.modules.logger),this.options):Zt.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:typeof Intl<"u"&&(u=id);const p=new Bi(this.options);this.store=new Mi(this.options.resources,this.options);const f=this.services;f.logger=Zt,f.resourceStore=this.store,f.languageUtils=p,f.pluralResolver=new sd(p,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===n.interpolation.format)&&(f.formatter=a(u),f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new nd(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new ld(a(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",function(h){for(var y=arguments.length,g=new Array(y>1?y-1:0),v=1;v<y;v++)g[v-1]=arguments[v];e.emit(h,...g)}),this.modules.languageDetector&&(f.languageDetector=a(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=a(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new yn(this.services,this.options),this.translator.on("*",function(h){for(var y=arguments.length,g=new Array(y>1?y-1:0),v=1;v<y;v++)g[v-1]=arguments[v];e.emit(h,...g)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,s||(s=vn),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(u=>{this[u]=function(){return e.store[u](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=function(){return e.store[u](...arguments),e}});const l=Rs(),c=()=>{const u=(p,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),s(p,f)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),l}loadResources(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vn;const n=pe(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if(n&&n.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const a=[],i=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(c=>{c!=="cimode"&&a.indexOf(c)<0&&a.push(c)})};n?i(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>i(l)),this.options.preload&&this.options.preload.forEach(o=>i(o)),this.services.backendConnector.load(a,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(o)})}else s(null)}reloadResources(e,r,s){const n=Rs();return typeof e=="function"&&(s=e,e=void 0),typeof r=="function"&&(s=r,r=void 0),e||(e=this.languages),r||(r=this.options.ns),s||(s=vn),this.services.backendConnector.reload(e,r,a=>{n.resolve(),s(a)}),n}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Fi.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let r=0;r<this.languages.length;r++){const s=this.languages[r];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}}changeLanguage(e,r){var s=this;this.isLanguageChangingTo=e;const n=Rs();this.emit("languageChanging",e);const a=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},i=(l,c)=>{c?(a(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,n.resolve(function(){return s.t(...arguments)}),r&&r(l,function(){return s.t(...arguments)})},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=pe(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);c&&(this.language||a(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(c)),this.loadResources(c,u=>{i(u,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),n}getFixedT(e,r,s){var n=this;const a=function(i,o){let l;if(typeof o!="object"){for(var c=arguments.length,u=new Array(c>2?c-2:0),p=2;p<c;p++)u[p-2]=arguments[p];l=n.options.overloadTranslationOptionHandler([i,o].concat(u))}else l={...o};l.lng=l.lng||a.lng,l.lngs=l.lngs||a.lngs,l.ns=l.ns||a.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||a.keyPrefix);const f=n.options.keySeparator||".";let h;return l.keyPrefix&&Array.isArray(i)?h=i.map(y=>`${l.keyPrefix}${f}${y}`):h=l.keyPrefix?`${l.keyPrefix}${f}${i}`:i,n.t(h,l)};return pe(e)?a.lng=e:a.lngs=e,a.ns=r,a.keyPrefix=s,a}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=r.lng||this.resolvedLanguage||this.languages[0],n=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const i=(o,l)=>{const c=this.services.backendConnector.state[`${o}|${l}`];return c===-1||c===0||c===2};if(r.precheck){const o=r.precheck(this,i);if(o!==void 0)return o}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(s,e)&&(!n||i(a,e)))}loadNamespaces(e,r){const s=Rs();return this.options.ns?(pe(e)&&(e=[e]),e.forEach(n=>{this.options.ns.indexOf(n)<0&&this.options.ns.push(n)}),this.loadResources(n=>{s.resolve(),r&&r(n)}),s):(r&&r(),Promise.resolve())}loadLanguages(e,r){const s=Rs();pe(e)&&(e=[e]);const n=this.options.preload||[],a=e.filter(i=>n.indexOf(i)<0&&this.services.languageUtils.isSupportedCode(i));return a.length?(this.options.preload=n.concat(a),this.loadResources(i=>{s.resolve(),r&&r(i)}),s):(r&&r(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";const r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=this.services&&this.services.languageUtils||new Bi(zi());return r.indexOf(s.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return new Ds(e,r)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vn;const s=e.forkResourceStore;s&&delete e.forkResourceStore;const n={...this.options,...e,isClone:!0},a=new Ds(n);return(e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(o=>{a[o]=this[o]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},s&&(a.store=new Mi(this.store.data,n),a.services.resourceStore=a.store),a.translator=new yn(a.services,n),a.translator.on("*",function(o){for(var l=arguments.length,c=new Array(l>1?l-1:0),u=1;u<l;u++)c[u-1]=arguments[u];a.emit(o,...c)}),a.init(n,r),a.translator.options=n,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Re=Ds.createInstance();Re.createInstance=Ds.createInstance,Re.createInstance,Re.dir,Re.init,Re.loadResources,Re.reloadResources,Re.use,Re.changeLanguage,Re.getFixedT,Re.t,Re.exists,Re.setDefaultNamespace,Re.hasLoadedNamespace,Re.loadNamespaces,Re.loadLanguages;function ud(){if(console&&console.warn){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];Ir(e[0])&&(e[0]=`react-i18next:: ${e[0]}`),console.warn(...e)}}const Wi={};function ya(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];Ir(e[0])&&Wi[e[0]]||(Ir(e[0])&&(Wi[e[0]]=new Date),ud(...e))}const qi=(t,e)=>()=>{if(t.isInitialized)e();else{const r=()=>{setTimeout(()=>{t.off("initialized",r)},0),e()};t.on("initialized",r)}},Gi=(t,e,r)=>{t.loadNamespaces(e,qi(t,r))},Ji=(t,e,r,s)=>{Ir(r)&&(r=[r]),r.forEach(n=>{t.options.ns.indexOf(n)<0&&t.options.ns.push(n)}),t.loadLanguages(e,qi(t,s))},dd=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=e.languages[0],n=e.options?e.options.fallbackLng:!1,a=e.languages[e.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const i=(o,l)=>{const c=e.services.backendConnector.state[`${o}|${l}`];return c===-1||c===2};return r.bindI18n&&r.bindI18n.indexOf("languageChanging")>-1&&e.services.backendConnector.backend&&e.isLanguageChangingTo&&!i(e.isLanguageChangingTo,t)?!1:!!(e.hasResourceBundle(s,t)||!e.services.backendConnector.backend||e.options.resources&&!e.options.partialBundledLanguages||i(s,t)&&(!n||i(a,t)))},hd=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!e.languages||!e.languages.length?(ya("i18n.languages were undefined or empty",e.languages),!0):e.options.ignoreJSONStructure!==void 0?e.hasLoadedNamespace(t,{lng:r.lng,precheck:(n,a)=>{if(r.bindI18n&&r.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!a(n.isLanguageChangingTo,t))return!1}}):dd(t,e,r)},Ir=t=>typeof t=="string",fd=t=>typeof t=="object"&&t!==null,pd=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,md={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},gd=t=>md[t];let va={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:t=>t.replace(pd,gd)};const yd=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};va={...va,...t}},vd=()=>va;let Zi;const bd=t=>{Zi=t},wd=()=>Zi,xd={type:"3rdParty",init(t){yd(t.options.react),bd(t)}},_d=k.createContext();class kd{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces=()=>Object.keys(this.usedNamespaces)}const Sd=(t,e)=>{const r=k.useRef();return k.useEffect(()=>{r.current=t},[t,e]),r.current},Yi=(t,e,r,s)=>t.getFixedT(e,r,s),Cd=(t,e,r,s)=>k.useCallback(Yi(t,e,r,s),[t,e,r,s]),Ls=function(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:r}=e,{i18n:s,defaultNS:n}=k.useContext(_d)||{},a=r||s||wd();if(a&&!a.reportNamespaces&&(a.reportNamespaces=new kd),!a){ya("You will need to pass in an i18next instance by using initReactI18next");const E=(N,L)=>Ir(L)?L:fd(L)&&Ir(L.defaultValue)?L.defaultValue:Array.isArray(N)?N[N.length-1]:N,T=[E,{},!1];return T.t=E,T.i18n={},T.ready=!1,T}a.options.react&&a.options.react.wait!==void 0&&ya("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const i={...vd(),...a.options.react,...e},{useSuspense:o,keyPrefix:l}=i;let c=n||a.options&&a.options.defaultNS;c=Ir(c)?[c]:c||["translation"],a.reportNamespaces.addUsedNamespaces&&a.reportNamespaces.addUsedNamespaces(c);const u=(a.isInitialized||a.initializedStoreOnce)&&c.every(E=>hd(E,a,i)),p=Cd(a,e.lng||null,i.nsMode==="fallback"?c:c[0],l),f=()=>p,h=()=>Yi(a,e.lng||null,i.nsMode==="fallback"?c:c[0],l),[y,g]=k.useState(f);let v=c.join();e.lng&&(v=`${e.lng}${v}`);const C=Sd(v),_=k.useRef(!0);k.useEffect(()=>{const{bindI18n:E,bindI18nStore:T}=i;_.current=!0,!u&&!o&&(e.lng?Ji(a,e.lng,c,()=>{_.current&&g(h)}):Gi(a,c,()=>{_.current&&g(h)})),u&&C&&C!==v&&_.current&&g(h);const N=()=>{_.current&&g(h)};return E&&a&&a.on(E,N),T&&a&&a.store.on(T,N),()=>{_.current=!1,E&&a&&E.split(" ").forEach(L=>a.off(L,N)),T&&a&&T.split(" ").forEach(L=>a.store.off(L,N))}},[a,v]),k.useEffect(()=>{_.current&&u&&g(f)},[a,l,u]);const S=[y,a,u];if(S.t=y,S.i18n=a,S.ready=u,u||!u&&!o)return S;throw new Promise(E=>{e.lng?Ji(a,e.lng,c,()=>E()):Gi(a,c,()=>E())})};function Ed(){return typeof window>"u"?"en":window.location.pathname.split("/").filter(Boolean)[0]==="hi"?"hi":"en"}const Td=Ed(),Ad={en:{translation:{common:{switchToHindi:"Switch to Hindi",switchToEnglish:"Switch to English",next:"Next",back:"Back",bookNow:"Book Now",mySolutionFinder:"My Solution Finder"},index:{heroTitlePart1:"Find Your Perfect",heroTitlePart2:"Spiritual Solution",heroSubtitle:"Get personalized puja recommendations to guide your spiritual practice.",cta:"My Solution Finder",clickHere:"Click here"},trust:{trust1:"Results verified by India's top astrologers",trust2:"Based on Vedic principles & precise planetary positions",trust3:"Trusted by 30 Lakh+ users"},reviews:{heading:"What Our Devotees Say",subheading:"Trusted by thousands of families across India"},footer:{description:"Sri Mandir has brought religious services to the masses in India by connecting devotees, pundits, and temples. Partnering with over 50 renowned temples, we provide exclusive pujas and offering services performed by expert pandits and share videos of the completed puja rituals.",company:"Company",ourServices:"Our Services",services:{puja:"Puja",chadhava:"Chadhava",panchang:"Panchang",temples:"Temples"},ourAddress:"Our Address",address:"Firstprinciple AppsForBharat Pvt. Ltd. 435, 1st Floor 17th Cross, 19th Main Rd, above Axis Bank, Sector 4, HSR Layout, Bengaluru, Karnataka 560102",aboutUs:"About Us",contactUs:"Contact Us",privacyPolicy:"Privacy Policy",terms:"Terms and Conditions",copyright:"© 2025 Sri Mandir. All rights reserved."},trustBadge:{tagline:"India's most trusted devotion app",downloads:"3 Cr.+ downloads"},solutionFinder:{title:"My Solution Finder",description:"My Solution Finder is a 4-step tool that recommends the most suitable puja based on your birth details and life concerns. Enter your date of birth, select the area for which you need blessings, and receive personalised puja recommendations. With one click, book the puja that's right for you.",enterDob:"Enter your DOB",day:"Day",month:"Month",year:"Year",readingMap:"Reading Your Celestial Map...",astrologicalDetails:"Your Astrological Details",yourRashi:"Your Rashi",yourMoolank:"Your Moolank",selectAreasHeading:"What area of life do you need blessings for?",selectAreasSub:"You can select multiple areas",areas:{health:"Health",career:"Career",love:"Love / Relationships",family:"Family Issues",finances:"Finances",peace:"Peace of Mind",child:"Child Well-being"},recommendedTitle:"Your Recommended Pujas",basedOn:"Based on your birth details and selected areas: {{areas}}",noPujas:"No specific pujas found for your selected areas. Please try selecting different areas."},dosha:{heroTitle:"Find Puja Remedy for your Life Problems",heroSubtitle:"Analyse your kundli to find out which doshas (if any) appear in your Vedic chart—and see devotional remedies.",whatIsDosha:"What is a dosha?",whatIsDoshaAnswer:"In Vedic astrology, a dosha is a specific planetary pattern believed to create challenges or imbalances in life.",whyImportant:"Why is it important?",whyImportantAnswer:"Identifying doshas helps you understand potential friction points and explore time-tested, gentle remedies.",howImpact:"How can it impact life?",howImpactAnswer:"Traditionally, doshas are linked to areas like relationships, career, health, and peace of mind—always interpreted with discretion.",calculatorTitle:"Vedic Dosha Calculator",calculatorDesc:"Discover potential doshas in your birth chart based on classical Jyotish principles",refresh:"Refresh",name:"Name",enterName:"Enter your name",gender:"Gender",selectGender:"Select gender",requestExpertCallback:"Request call back from our expert",male:"Male",female:"Female",dateOfBirth:"Select Date of Birth",timeOfBirth:"Exact Time of Birth",unknownTime:"I don't know my birth time",dontKnowTime:"I don't know my birth time",timeFormat:"Format: hh:mm AM/PM",unknownTimeWarning:"⚠️ Without exact birth time, accuracy will be reduced. We'll run Moon-based checks only.",placeOfBirth:"Place of Birth (City)",enterPlace:"e.g. Jaipur, Mumbai, Varanasi",typeChars:"Type 2+ characters",placePlaceholder:"e.g. Jaipur, Mumbai, Varanasi",edit:"Edit",latitude:"Latitude",longitude:"Longitude",timeZone:"Time Zone (India)",privacyNote:"🔒 Privacy: We don't store your details server-side unless you generate a share link.",privacyPlace:"🔒 We only use your input to look up the place; nothing is stored.",calculating:"Calculating...",calculateButton:"Calculate My Doshas",disclaimer:"⚠️ This is an educational tool based on classical Jyotish rules; not medical, legal, or financial advice.",formRefreshed:"Form refreshed",locationSelected:"Location selected. Time zone: Asia/Kolkata",enterTimeError:"Please enter birth time or mark it as unknown",calculationSuccess:"Doshas calculated successfully!",calculationError:"Failed to calculate doshas. Please try again.",problemAreaLabel:"Which is the biggest problem area of your life?",problemAreaHint:"Max 100 characters",problemAreaOtherPlaceholder:"Please describe your problem",selectProblems:"Select your problems",problemsSelected:"{{count}} problems selected"},resultTitle:"Your Dosha Analysis",resultPageTitle:"Your Dosha Analysis Results",resultPageSubtitle:"Based on your birth details and planetary positions",resultSomeDoshas:"Some Doshas Have Been Detected",resultNoDoshas:"No Major Doshas Found",resultNoDoshasDesc:"Your birth chart shows no major doshas.",resultMangal:"Mangal Dosha",resultKaalSarp:"Kaal Sarp Dosha",resultPitra:"Pitra Dosha",resultSadeSati:"Shani Sade Sati",resultStatusPresent:"Present",resultStatusAbsent:"Absent",resultStatusInactive:"Inactive",resultExplanation:"Explanation",resultRemedies:"Remedies",resultEditForm:"Edit details",drDoshaOf:"Dosha {{index}} of {{total}}",drStatus:"Status",drSeverity:"Severity",drSeverityHigh:"High",drSeverityMedium:"Medium",drSeverityLow:"Low",drPhase:"Phase",drWhyMarked:"Why is this dosha marked in your kundli?",drViewKundli:"View Kundli",drBasedOnPositions:"Based on planetary positions in your chart",drPhaseMeaning:"Phase Meaning",drPhaseRising:"Rising Phase (1st 2.5 years): Initial challenges begin",drPhasePeak:"Peak Phase (middle 2.5 years): Most intense period",drPhaseSetting:"Setting Phase (last 2.5 years): Challenges gradually ease",drPlanetaryPositions:"Planetary Positions",drImpactIfPresent:"Impact If Present",drHowPujaHelps:"How this Puja will help",drFomoLine:"Results are based on Vedic astrology principles. Consult an expert for personalized guidance.",drFeedbackContact:"Have questions? Contact us at",drDetailedAnalysis:"Detailed Analysis & Remedies",drBasedOnChart:"Based on your birth chart calculations",drStatusPresent:"Present",drStatusAbsent:"Absent",drStatusInactive:"Inactive",drStatusNullified:"Nullified",drExplanation:"Explanation",drWhyPresent:"Why Present",drWhyAbsent:"Why Absent",drImpact:"Impact",drTraditionalRemedies:"Traditional Remedies",drOtherDoshas:"Other Doshas",drOtherDoshasStatusActive:"Additional doshas detected in your chart",drOtherDoshasStatusNone:"No other doshas found",drOtherGrahan:"Grahan Dosha",drOtherShrapit:"Shrapit Dosha",drOtherGuruChandal:"Guru Chandal Dosha",drOtherPunarphoo:"Punarphoo Dosha",drOtherKemadruma:"Kemadruma Dosha",drOtherGandmool:"Gandmool Dosha",drOtherKalathra:"Kalathra Dosha",drOtherVishDaridra:"Vish Daridra Dosha",drOtherKetuNaga:"Ketu Naga Dosha",drOtherNavagraha:"Navagraha Dosha",drOtherGrahanDesc:"Occurs when Rahu-Ketu eclipse the Sun or Moon; traditionally linked to sudden challenges or hidden fears.",drOtherShrapitDesc:"Saturn-Rahu conjunction in any house; often framed as ancestral karmic debts requiring resolution.",drOtherGuruChandalDesc:"Jupiter afflicted by Rahu/Ketu; can cause conflict between higher wisdom and material desires.",drOtherPunarphooDesc:"Saturn-Moon affliction indicating recurring emotional cycles or repeated patterns.",drOtherKemadrumaDesc:"Moon isolated from benefic support; can indicate periods of emotional vulnerability.",drOtherGandmoolDesc:"Birth in specific Moon nakshatras (Ashwini, Revati, etc.); traditionally requires special rituals.",drOtherKalathraDec:"Affliction in 7th house or its lord; primarily associated with partnership and marriage themes.",drOtherVishDaridraDesc:"Mars-Saturn challenging aspect creating tension between action and caution.",drOtherKetuNagaDesc:"Ketu-related serpent energy; linked to spiritual transformation and past-life patterns.",drOtherNavagrahaDesc:"Multiple planetary afflictions suggesting need for comprehensive planetary peace rituals.",drOtherGrahanImpact:"Sudden setbacks, hidden anxieties, or eclipse-related sensitivities may arise; emotional ups and downs.",drOtherShrapitImpact:"Ancestral obligations, recurring obstacles, or karmic lessons that demand patience and resolution.",drOtherGuruChandalImpact:"Judgment issues, mentor problems, or misalignment between promises and outcomes in spiritual/ethical matters.",drOtherPunarphooImpact:"Emotional cycles repeating; relationships or situations may loop back requiring renewed effort.",drOtherKemadrumaImpact:"Periods of emotional isolation or lack of support; resilience needed during vulnerable phases.",drOtherGandmoolImpact:"Birth nakshatra challenges; traditional remedies advised for smoother life transitions.",drOtherKalathraImpact:"Partnership friction, marriage delays, or 7th house matters requiring attention and patience.",drOtherVishDaridraImpact:"Action-caution conflict; financial strain or Mars-Saturn tension creating stop-start patterns.",drOtherKetuNagaImpact:"Spiritual restlessness, past-life echoes, or serpent-energy themes needing acknowledgment.",drOtherNavagrahaImpact:"Multiple planetary imbalances creating varied life challenges; comprehensive remedies recommended.",drOtherGrahanRemedies:`Chant Rahu-Ketu mantras during eclipses
14
+ <%s key={someKey} {...props} />`,Ai,Zr,yb,Zr),ar[Zr+Ai]=!0}}return w===s?At(Ge):st(Ge),Ge}}function ir(w,D,H){return bt(w,D,H,!0)}function pb(w,D,H){return bt(w,D,H,!1)}var mb=pb,gb=ir;Ps.Fragment=s,Ps.jsx=mb,Ps.jsxs=gb})()),Ps}var Ni;function $u(){return Ni||(Ni=1,process.env.NODE_ENV==="production"?dn.exports=Du():dn.exports=Lu()),dn.exports}var u=$u();const ha={all_fields_filled:"all_fields_filled",fields_not_filled:"fields_not_filled",puja_clicked:"puja_clicked"},nt=(t,e)=>{typeof window<"u"&&console.log("Track Event:",t,e)},Mu=()=>{if(typeof window>"u")return{};const t=new URLSearchParams(window.location.search);return{utm_source:t.get("utm_source"),utm_medium:t.get("utm_medium"),utm_campaign:t.get("utm_campaign"),utm_term:t.get("utm_term"),utm_content:t.get("utm_content")}},pe=t=>typeof t=="string",Ns=()=>{let t,e;const r=new Promise((s,n)=>{t=s,e=n});return r.resolve=t,r.reject=e,r},Ri=t=>t==null?"":""+t,Fu=(t,e,r)=>{t.forEach(s=>{e[s]&&(r[s]=e[s])})},Uu=/###/g,Ii=t=>t&&t.indexOf("###")>-1?t.replace(Uu,"."):t,Di=t=>!t||pe(t),Rs=(t,e,r)=>{const s=pe(e)?e.split("."):e;let n=0;for(;n<s.length-1;){if(Di(t))return{};const a=Ii(s[n]);!t[a]&&r&&(t[a]=new r),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++n}return Di(t)?{}:{obj:t,k:Ii(s[n])}},Li=(t,e,r)=>{const{obj:s,k:n}=Rs(t,e,Object);if(s!==void 0||e.length===1){s[n]=r;return}let a=e[e.length-1],i=e.slice(0,e.length-1),o=Rs(t,i,Object);for(;o.obj===void 0&&i.length;)a=`${i[i.length-1]}.${a}`,i=i.slice(0,i.length-1),o=Rs(t,i,Object),o&&o.obj&&typeof o.obj[`${o.k}.${a}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${a}`]=r},Bu=(t,e,r,s)=>{const{obj:n,k:a}=Rs(t,e,Object);n[a]=n[a]||[],n[a].push(r)},hn=(t,e)=>{const{obj:r,k:s}=Rs(t,e);if(r)return r[s]},Vu=(t,e,r)=>{const s=hn(t,r);return s!==void 0?s:hn(e,r)},$i=(t,e,r)=>{for(const s in e)s!=="__proto__"&&s!=="constructor"&&(s in t?pe(t[s])||t[s]instanceof String||pe(e[s])||e[s]instanceof String?r&&(t[s]=e[s]):$i(t[s],e[s],r):t[s]=e[s]);return t},Yr=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ku={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const zu=t=>pe(t)?t.replace(/[&<>"'\/]/g,e=>Ku[e]):t;class Hu{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const r=this.regExpMap.get(e);if(r!==void 0)return r;const s=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,s),this.regExpQueue.push(e),s}}const Wu=[" ",",","?","!",";"],qu=new Hu(20),Gu=(t,e,r)=>{e=e||"",r=r||"";const s=Wu.filter(i=>e.indexOf(i)<0&&r.indexOf(i)<0);if(s.length===0)return!0;const n=qu.getRegExp(`(${s.map(i=>i==="?"?"\\?":i).join("|")})`);let a=!n.test(t);if(!a){const i=t.indexOf(r);i>0&&!n.test(t.substring(0,i))&&(a=!0)}return a},fa=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return t[e];const s=e.split(r);let n=t;for(let a=0;a<s.length;){if(!n||typeof n!="object")return;let i,o="";for(let l=a;l<s.length;++l)if(l!==a&&(o+=r),o+=s[l],i=n[o],i!==void 0){if(["string","number","boolean"].indexOf(typeof i)>-1&&l<s.length-1)continue;a+=l-a+1;break}n=i}return n},fn=t=>t&&t.replace("_","-"),Ju={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console&&console[t]&&console[t].apply(console,e)}};class pn{constructor(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,r)}init(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=e||Ju,this.options=r,this.debug=r.debug}log(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return this.forward(r,"log","",!0)}warn(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return this.forward(r,"warn","",!0)}error(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return this.forward(r,"error","")}deprecate(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return this.forward(r,"warn","WARNING DEPRECATED: ",!0)}forward(e,r,s,n){return n&&!this.debug?null:(pe(e[0])&&(e[0]=`${s}${this.prefix} ${e[0]}`),this.logger[r](e))}create(e){return new pn(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new pn(this.logger,e)}}var Zt=new pn;class mn{constructor(){this.observers={}}on(e,r){return e.split(" ").forEach(s=>{this.observers[s]||(this.observers[s]=new Map);const n=this.observers[s].get(r)||0;this.observers[s].set(r,n+1)}),this}off(e,r){if(this.observers[e]){if(!r){delete this.observers[e];return}this.observers[e].delete(r)}}emit(e){for(var r=arguments.length,s=new Array(r>1?r-1:0),n=1;n<r;n++)s[n-1]=arguments[n];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(i=>{let[o,l]=i;for(let c=0;c<l;c++)o(...s)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(i=>{let[o,l]=i;for(let c=0;c<l;c++)o.apply(o,[e,...s])})}}class Mi extends mn{constructor(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const r=this.options.ns.indexOf(e);r>-1&&this.options.ns.splice(r,1)}getResource(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const a=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,i=n.ignoreJSONStructure!==void 0?n.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,r],s&&(Array.isArray(s)?o.push(...s):pe(s)&&a?o.push(...s.split(a)):o.push(s)));const l=hn(this.data,o);return!l&&!r&&!s&&e.indexOf(".")>-1&&(e=o[0],r=o[1],s=o.slice(2).join(".")),l||!i||!pe(s)?l:fa(this.data&&this.data[e]&&this.data[e][r],s,a)}addResource(e,r,s,n){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const i=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let o=[e,r];s&&(o=o.concat(i?s.split(i):s)),e.indexOf(".")>-1&&(o=e.split("."),n=r,r=o[1]),this.addNamespaces(r),Li(this.data,o,n),a.silent||this.emit("added",e,r,s,n)}addResources(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const a in s)(pe(s[a])||Array.isArray(s[a]))&&this.addResource(e,r,a,s[a],{silent:!0});n.silent||this.emit("added",e,r,s)}addResourceBundle(e,r,s,n,a){let i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},o=[e,r];e.indexOf(".")>-1&&(o=e.split("."),n=s,s=r,r=o[1]),this.addNamespaces(r);let l=hn(this.data,o)||{};i.skipCopy||(s=JSON.parse(JSON.stringify(s))),n?$i(l,s,a):l={...l,...s},Li(this.data,o,l),i.silent||this.emit("added",e,r,s)}removeResourceBundle(e,r){this.hasResourceBundle(e,r)&&delete this.data[e][r],this.removeNamespaces(r),this.emit("removed",e,r)}hasResourceBundle(e,r){return this.getResource(e,r)!==void 0}getResourceBundle(e,r){return r||(r=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(e,r)}:this.getResource(e,r)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const r=this.getDataByLanguage(e);return!!(r&&Object.keys(r)||[]).find(n=>r[n]&&Object.keys(r[n]).length>0)}toJSON(){return this.data}}var Fi={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,r,s,n){return t.forEach(a=>{this.processors[a]&&(e=this.processors[a].process(e,r,s,n))}),e}};const Ui={};class gn extends mn{constructor(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Fu(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Zt.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const s=this.resolve(e,r);return s&&s.res!==void 0}extractFromKey(e,r){let s=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;s===void 0&&(s=":");const n=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let a=r.ns||this.options.defaultNS||[];const i=s&&e.indexOf(s)>-1,o=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!Gu(e,s,n);if(i&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:pe(a)?[a]:a};const c=e.split(s);(s!==n||s===n&&this.options.ns.indexOf(c[0])>-1)&&(a=c.shift()),e=c.join(n)}return{key:e,namespaces:pe(a)?[a]:a}}translate(e,r,s){if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:i,namespaces:o}=this.extractFromKey(e[e.length-1],r),l=o[o.length-1],c=r.lng||this.language,d=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c&&c.toLowerCase()==="cimode"){if(d){const E=r.nsSeparator||this.options.nsSeparator;return n?{res:`${l}${E}${i}`,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:`${l}${E}${i}`}return n?{res:i,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:i}const f=this.resolve(e,r);let p=f&&f.res;const h=f&&f.usedKey||i,g=f&&f.exactUsedKey||i,y=Object.prototype.toString.apply(p),v=["[object Number]","[object Function]","[object RegExp]"],C=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,_=!this.i18nFormat||this.i18nFormat.handleAsObject,S=!pe(p)&&typeof p!="boolean"&&typeof p!="number";if(_&&p&&S&&v.indexOf(y)<0&&!(pe(C)&&Array.isArray(p))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const E=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,p,{...r,ns:o}):`key '${i} (${this.language})' returned an object instead of string.`;return n?(f.res=E,f.usedParams=this.getUsedParamsDetails(r),f):E}if(a){const E=Array.isArray(p),T=E?[]:{},N=E?g:h;for(const L in p)if(Object.prototype.hasOwnProperty.call(p,L)){const ue=`${N}${a}${L}`;T[L]=this.translate(ue,{...r,joinArrays:!1,ns:o}),T[L]===ue&&(T[L]=p[L])}p=T}}else if(_&&pe(C)&&Array.isArray(p))p=p.join(C),p&&(p=this.extendTranslation(p,e,r,s));else{let E=!1,T=!1;const N=r.count!==void 0&&!pe(r.count),L=gn.hasDefaultValue(r),ue=N?this.pluralResolver.getSuffix(c,r.count,r):"",re=r.ordinal&&N?this.pluralResolver.getSuffix(c,r.count,{ordinal:!1}):"",je=N&&!r.ordinal&&r.count===0&&this.pluralResolver.shouldUseIntlApi(),Se=je&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${ue}`]||r[`defaultValue${re}`]||r.defaultValue;!this.isValidLookup(p)&&L&&(E=!0,p=Se),this.isValidLookup(p)||(T=!0,p=i);const X=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&T?void 0:p,W=L&&Se!==p&&this.options.updateMissing;if(T||E||W){if(this.logger.log(W?"updateKey":"missingKey",c,l,i,W?Se:p),a){const de=this.resolve(i,{...r,keySeparator:!1});de&&de.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let oe=[];const ye=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ye&&ye[0])for(let de=0;de<ye.length;de++)oe.push(ye[de]);else this.options.saveMissingTo==="all"?oe=this.languageUtils.toResolveHierarchy(r.lng||this.language):oe.push(r.lng||this.language);const ne=(de,G,j)=>{const z=L&&j!==p?j:X;this.options.missingKeyHandler?this.options.missingKeyHandler(de,l,G,z,W,r):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(de,l,G,z,W,r),this.emit("missingKey",de,l,G,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?oe.forEach(de=>{const G=this.pluralResolver.getSuffixes(de,r);je&&r[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(j=>{ne([de],i+j,r[`defaultValue${j}`]||Se)})}):ne(oe,i,Se))}p=this.extendTranslation(p,e,r,f,s),T&&p===i&&this.options.appendNamespaceToMissingKey&&(p=`${l}:${i}`),(T||E)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${i}`:i,E?p:void 0):p=this.options.parseMissingKeyHandler(p))}return n?(f.res=p,f.usedParams=this.getUsedParamsDetails(r),f):p}extendTranslation(e,r,s,n,a){var i=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...s},s.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init({...s,interpolation:{...this.options.interpolation,...s.interpolation}});const c=pe(e)&&(s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(c){const p=e.match(this.interpolator.nestingRegexp);d=p&&p.length}let f=s.replace&&!pe(s.replace)?s.replace:s;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),e=this.interpolator.interpolate(e,f,s.lng||this.language||n.usedLng,s),c){const p=e.match(this.interpolator.nestingRegexp),h=p&&p.length;d<h&&(s.nest=!1)}!s.lng&&this.options.compatibilityAPI!=="v1"&&n&&n.res&&(s.lng=this.language||n.usedLng),s.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var p=arguments.length,h=new Array(p),g=0;g<p;g++)h[g]=arguments[g];return a&&a[0]===h[0]&&!s.context?(i.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${r[0]}`),null):i.translate(...h,r)},s)),s.interpolation&&this.interpolator.reset()}const o=s.postProcess||this.options.postProcess,l=pe(o)?[o]:o;return e!=null&&l&&l.length&&s.applyPostProcessor!==!1&&(e=Fi.handle(l,e,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(s)},...s}:s,this)),e}resolve(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s,n,a,i,o;return pe(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(s))return;const c=this.extractFromKey(l,r),d=c.key;n=d;let f=c.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=r.count!==void 0&&!pe(r.count),h=p&&!r.ordinal&&r.count===0&&this.pluralResolver.shouldUseIntlApi(),g=r.context!==void 0&&(pe(r.context)||typeof r.context=="number")&&r.context!=="",y=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);f.forEach(v=>{this.isValidLookup(s)||(o=v,!Ui[`${y[0]}-${v}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(o)&&(Ui[`${y[0]}-${v}`]=!0,this.logger.warn(`key "${n}" for languages "${y.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach(C=>{if(this.isValidLookup(s))return;i=C;const _=[d];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(_,d,C,v,r);else{let E;p&&(E=this.pluralResolver.getSuffix(C,r.count,r));const T=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(_.push(d+E),r.ordinal&&E.indexOf(N)===0&&_.push(d+E.replace(N,this.options.pluralSeparator)),h&&_.push(d+T)),g){const L=`${d}${this.options.contextSeparator}${r.context}`;_.push(L),p&&(_.push(L+E),r.ordinal&&E.indexOf(N)===0&&_.push(L+E.replace(N,this.options.pluralSeparator)),h&&_.push(L+T))}}let S;for(;S=_.pop();)this.isValidLookup(s)||(a=S,s=this.getResource(C,v,S,r))}))})}),{res:s,usedKey:n,exactUsedKey:a,usedLng:i,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,r,s,n):this.resourceStore.getResource(e,r,s,n)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],s=e.replace&&!pe(e.replace);let n=s?e.replace:e;if(s&&typeof e.count<"u"&&(n.count=e.count),this.options.interpolation.defaultVariables&&(n={...this.options.interpolation.defaultVariables,...n}),!s){n={...n};for(const a of r)delete n[a]}return n}static hasDefaultValue(e){const r="defaultValue";for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&r===s.substring(0,r.length)&&e[s]!==void 0)return!0;return!1}}const pa=t=>t.charAt(0).toUpperCase()+t.slice(1);class Bi{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Zt.create("languageUtils")}getScriptPartFromCode(e){if(e=fn(e),!e||e.indexOf("-")<0)return null;const r=e.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(e){if(e=fn(e),!e||e.indexOf("-")<0)return e;const r=e.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(e){if(pe(e)&&e.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let n=Intl.getCanonicalLocales(e)[0];if(n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n)return n}catch{}const r=["hans","hant","latn","cyrl","cans","mong","arab"];let s=e.split("-");return this.options.lowerCaseLng?s=s.map(n=>n.toLowerCase()):s.length===2?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),r.indexOf(s[1].toLowerCase())>-1&&(s[1]=pa(s[1].toLowerCase()))):s.length===3&&(s[0]=s[0].toLowerCase(),s[1].length===2&&(s[1]=s[1].toUpperCase()),s[0]!=="sgn"&&s[2].length===2&&(s[2]=s[2].toUpperCase()),r.indexOf(s[1].toLowerCase())>-1&&(s[1]=pa(s[1].toLowerCase())),r.indexOf(s[2].toLowerCase())>-1&&(s[2]=pa(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let r;return e.forEach(s=>{if(r)return;const n=this.formatLanguageCode(s);(!this.options.supportedLngs||this.isSupportedCode(n))&&(r=n)}),!r&&this.options.supportedLngs&&e.forEach(s=>{if(r)return;const n=this.getLanguagePartFromCode(s);if(this.isSupportedCode(n))return r=n;r=this.options.supportedLngs.find(a=>{if(a===n)return a;if(!(a.indexOf("-")<0&&n.indexOf("-")<0)&&(a.indexOf("-")>0&&n.indexOf("-")<0&&a.substring(0,a.indexOf("-"))===n||a.indexOf(n)===0&&n.length>1))return a})}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(e,r){if(!e)return[];if(typeof e=="function"&&(e=e(r)),pe(e)&&(e=[e]),Array.isArray(e))return e;if(!r)return e.default||[];let s=e[r];return s||(s=e[this.getScriptPartFromCode(r)]),s||(s=e[this.formatLanguageCode(r)]),s||(s=e[this.getLanguagePartFromCode(r)]),s||(s=e.default),s||[]}toResolveHierarchy(e,r){const s=this.getFallbackCodes(r||this.options.fallbackLng||[],e),n=[],a=i=>{i&&(this.isSupportedCode(i)?n.push(i):this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`))};return pe(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):pe(e)&&a(this.formatLanguageCode(e)),s.forEach(i=>{n.indexOf(i)<0&&a(this.formatLanguageCode(i))}),n}}let Zu=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Yu={1:t=>+(t>1),2:t=>+(t!=1),3:t=>0,4:t=>t%10==1&&t%100!=11?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2,5:t=>t==0?0:t==1?1:t==2?2:t%100>=3&&t%100<=10?3:t%100>=11?4:5,6:t=>t==1?0:t>=2&&t<=4?1:2,7:t=>t==1?0:t%10>=2&&t%10<=4&&(t%100<10||t%100>=20)?1:2,8:t=>t==1?0:t==2?1:t!=8&&t!=11?2:3,9:t=>+(t>=2),10:t=>t==1?0:t==2?1:t<7?2:t<11?3:4,11:t=>t==1||t==11?0:t==2||t==12?1:t>2&&t<20?2:3,12:t=>+(t%10!=1||t%100==11),13:t=>+(t!==0),14:t=>t==1?0:t==2?1:t==3?2:3,15:t=>t%10==1&&t%100!=11?0:t%10>=2&&(t%100<10||t%100>=20)?1:2,16:t=>t%10==1&&t%100!=11?0:t!==0?1:2,17:t=>t==1||t%10==1&&t%100!=11?0:1,18:t=>t==0?0:t==1?1:2,19:t=>t==1?0:t==0||t%100>1&&t%100<11?1:t%100>10&&t%100<20?2:3,20:t=>t==1?0:t==0||t%100>0&&t%100<20?1:2,21:t=>t%100==1?1:t%100==2?2:t%100==3||t%100==4?3:0,22:t=>t==1?0:t==2?1:(t<0||t>10)&&t%10==0?2:3};const Xu=["v1","v2","v3"],Qu=["v4"],Vi={zero:0,one:1,two:2,few:3,many:4,other:5},ed=()=>{const t={};return Zu.forEach(e=>{e.lngs.forEach(r=>{t[r]={numbers:e.nr,plurals:Yu[e.fc]}})}),t};class td{constructor(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=r,this.logger=Zt.create("pluralResolver"),(!this.options.compatibilityJSON||Qu.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=ed(),this.pluralRulesCache={}}addRule(e,r){this.rules[e]=r}clearCache(){this.pluralRulesCache={}}getRule(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi()){const s=fn(e==="dev"?"en":e),n=r.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:s,type:n});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let i;try{i=new Intl.PluralRules(s,{type:n})}catch{if(!e.match(/-|_/))return;const l=this.languageUtils.getLanguagePartFromCode(e);i=this.getRule(l,r)}return this.pluralRulesCache[a]=i,i}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}needsPlural(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=this.getRule(e,r);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}getPluralFormsOfKey(e,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,s).map(n=>`${r}${n}`)}getSuffixes(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=this.getRule(e,r);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort((n,a)=>Vi[n]-Vi[a]).map(n=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${n}`):s.numbers.map(n=>this.getSuffix(e,n,r)):[]}getSuffix(e,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const n=this.getRule(e,s);return n?this.shouldUseIntlApi()?`${this.options.prepend}${s.ordinal?`ordinal${this.options.prepend}`:""}${n.select(r)}`:this.getSuffixRetroCompatible(n,r):(this.logger.warn(`no plural rule found for: ${e}`),"")}getSuffixRetroCompatible(e,r){const s=e.noAbs?e.plurals(r):e.plurals(Math.abs(r));let n=e.numbers[s];this.options.simplifyPluralSuffix&&e.numbers.length===2&&e.numbers[0]===1&&(n===2?n="plural":n===1&&(n=""));const a=()=>this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString();return this.options.compatibilityJSON==="v1"?n===1?"":typeof n=="number"?`_plural_${n.toString()}`:a():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&e.numbers.length===2&&e.numbers[0]===1?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}shouldUseIntlApi(){return!Xu.includes(this.options.compatibilityJSON)}}const Ki=function(t,e,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=Vu(t,e,r);return!a&&n&&pe(r)&&(a=fa(t,r,s),a===void 0&&(a=fa(e,r,s))),a},ma=t=>t.replace(/\$/g,"$$$$");class rd{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Zt.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||(r=>r),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const{escape:r,escapeValue:s,useRawValueToEscape:n,prefix:a,prefixEscaped:i,suffix:o,suffixEscaped:l,formatSeparator:c,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:C,alwaysFormat:_}=e.interpolation;this.escape=r!==void 0?r:zu,this.escapeValue=s!==void 0?s:!0,this.useRawValueToEscape=n!==void 0?n:!1,this.prefix=a?Yr(a):i||"{{",this.suffix=o?Yr(o):l||"}}",this.formatSeparator=c||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?Yr(p):h||Yr("$t("),this.nestingSuffix=g?Yr(g):y||Yr(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=C||1e3,this.alwaysFormat=_!==void 0?_:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(r,s)=>r&&r.source===s?(r.lastIndex=0,r):new RegExp(s,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,r,s,n){let a,i,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=h=>{if(h.indexOf(this.formatSeparator)<0){const C=Ki(r,l,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,s,{...n,...r,interpolationkey:h}):C}const g=h.split(this.formatSeparator),y=g.shift().trim(),v=g.join(this.formatSeparator).trim();return this.format(Ki(r,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),v,s,{...n,...r,interpolationkey:y})};this.resetRegExp();const d=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,f=n&&n.interpolation&&n.interpolation.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>ma(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?ma(this.escape(h)):ma(h)}].forEach(h=>{for(o=0;a=h.regex.exec(e);){const g=a[1].trim();if(i=c(g),i===void 0)if(typeof d=="function"){const v=d(e,a,n);i=pe(v)?v:""}else if(n&&Object.prototype.hasOwnProperty.call(n,g))i="";else if(f){i=a[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${e}`),i="";else!pe(i)&&!this.useRawValueToEscape&&(i=Ri(i));const y=h.safeValue(i);if(e=e.replace(a[0],y),f?(h.regex.lastIndex+=i.length,h.regex.lastIndex-=a[0].length):h.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n,a,i;const o=(l,c)=>{const d=this.nestingOptionsSeparator;if(l.indexOf(d)<0)return l;const f=l.split(new RegExp(`${d}[ ]*{`));let p=`{${f[1]}`;l=f[0],p=this.interpolate(p,i);const h=p.match(/'/g),g=p.match(/"/g);(h&&h.length%2===0&&!g||g.length%2!==0)&&(p=p.replace(/'/g,'"'));try{i=JSON.parse(p),c&&(i={...c,...i})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,y),`${l}${d}${p}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,l};for(;n=this.nestingRegexp.exec(e);){let l=[];i={...s},i=i.replace&&!pe(i.replace)?i.replace:i,i.applyPostProcessor=!1,delete i.defaultValue;let c=!1;if(n[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(n[1])){const d=n[1].split(this.formatSeparator).map(f=>f.trim());n[1]=d.shift(),l=d,c=!0}if(a=r(o.call(this,n[1].trim(),i),i),a&&n[0]===e&&!pe(a))return a;pe(a)||(a=Ri(a)),a||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),a=""),c&&(a=l.reduce((d,f)=>this.format(d,f,s.lng,{...s,interpolationkey:n[1].trim()}),a.trim())),e=e.replace(n[0],a),this.regexp.lastIndex=0}return e}}const sd=t=>{let e=t.toLowerCase().trim();const r={};if(t.indexOf("(")>-1){const s=t.split("(");e=s[0].toLowerCase().trim();const n=s[1].substring(0,s[1].length-1);e==="currency"&&n.indexOf(":")<0?r.currency||(r.currency=n.trim()):e==="relativetime"&&n.indexOf(":")<0?r.range||(r.range=n.trim()):n.split(";").forEach(i=>{if(i){const[o,...l]=i.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),d=o.trim();r[d]||(r[d]=c),c==="false"&&(r[d]=!1),c==="true"&&(r[d]=!0),isNaN(c)||(r[d]=parseInt(c,10))}})}return{formatName:e,formatOptions:r}},Xr=t=>{const e={};return(r,s,n)=>{let a=n;n&&n.interpolationkey&&n.formatParams&&n.formatParams[n.interpolationkey]&&n[n.interpolationkey]&&(a={...a,[n.interpolationkey]:void 0});const i=s+JSON.stringify(a);let o=e[i];return o||(o=t(fn(s),n),e[i]=o),o(r)}};class nd{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Zt.create("formatter"),this.options=e,this.formats={number:Xr((r,s)=>{const n=new Intl.NumberFormat(r,{...s});return a=>n.format(a)}),currency:Xr((r,s)=>{const n=new Intl.NumberFormat(r,{...s,style:"currency"});return a=>n.format(a)}),datetime:Xr((r,s)=>{const n=new Intl.DateTimeFormat(r,{...s});return a=>n.format(a)}),relativetime:Xr((r,s)=>{const n=new Intl.RelativeTimeFormat(r,{...s});return a=>n.format(a,s.range||"day")}),list:Xr((r,s)=>{const n=new Intl.ListFormat(r,{...s});return a=>n.format(a)})},this.init(e)}init(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=r.interpolation.formatSeparator||","}add(e,r){this.formats[e.toLowerCase().trim()]=r}addCached(e,r){this.formats[e.toLowerCase().trim()]=Xr(r)}format(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const a=r.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(o=>o.indexOf(")")>-1)){const o=a.findIndex(l=>l.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,o)].join(this.formatSeparator)}return a.reduce((o,l)=>{const{formatName:c,formatOptions:d}=sd(l);if(this.formats[c]){let f=o;try{const p=n&&n.formatParams&&n.formatParams[n.interpolationkey]||{},h=p.locale||p.lng||n.locale||n.lng||s;f=this.formats[c](o,h,{...d,...n,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${c}`);return o},e)}}const ad=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class id extends mn{constructor(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=r,this.services=s,this.languageUtils=s.languageUtils,this.options=n,this.logger=Zt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(s,n.backend,n)}queueLoad(e,r,s,n){const a={},i={},o={},l={};return e.forEach(c=>{let d=!0;r.forEach(f=>{const p=`${c}|${f}`;!s.reload&&this.store.hasResourceBundle(c,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?i[p]===void 0&&(i[p]=!0):(this.state[p]=1,d=!1,i[p]===void 0&&(i[p]=!0),a[p]===void 0&&(a[p]=!0),l[f]===void 0&&(l[f]=!0)))}),d||(o[c]=!0)}),(Object.keys(a).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(a),pending:Object.keys(i),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,r,s){const n=e.split("|"),a=n[0],i=n[1];r&&this.emit("failedLoading",a,i,r),!r&&s&&this.store.addResourceBundle(a,i,s,void 0,void 0,{skipCopy:!0}),this.state[e]=r?-1:2,r&&s&&(this.state[e]=0);const o={};this.queue.forEach(l=>{Bu(l.loaded,[a],i),ad(l,e),r&&l.errors.push(r),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(c=>{o[c]||(o[c]={});const d=l.loaded[c];d.length&&d.forEach(f=>{o[c][f]===void 0&&(o[c][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,r,s){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,i=arguments.length>5?arguments[5]:void 0;if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:r,fcName:s,tried:n,wait:a,callback:i});return}this.readingCalls++;const o=(c,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(c&&d&&n<this.maxRetries){setTimeout(()=>{this.read.call(this,e,r,s,n+1,a*2,i)},a);return}i(c,d)},l=this.backend[s].bind(this.backend);if(l.length===2){try{const c=l(e,r);c&&typeof c.then=="function"?c.then(d=>o(null,d)).catch(o):o(null,c)}catch(c){o(c)}return}return l(e,r,o)}prepareLoading(e,r){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();pe(e)&&(e=this.languageUtils.toResolveHierarchy(e)),pe(r)&&(r=[r]);const a=this.queueLoad(e,r,s,n);if(!a.toLoad.length)return a.pending.length||n(),null;a.toLoad.forEach(i=>{this.loadOne(i)})}load(e,r,s){this.prepareLoading(e,r,{},s)}reload(e,r,s){this.prepareLoading(e,r,{reload:!0},s)}loadOne(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const s=e.split("|"),n=s[0],a=s[1];this.read(n,a,"read",void 0,void 0,(i,o)=>{i&&this.logger.warn(`${r}loading namespace ${a} for language ${n} failed`,i),!i&&o&&this.logger.log(`${r}loaded namespace ${a} for language ${n}`,o),this.loaded(e,i,o)})}saveMissing(e,r,s,n,a){let i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(r)){this.logger.warn(`did not save key "${s}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(s==null||s==="")){if(this.backend&&this.backend.create){const l={...i,isUpdate:a},c=this.backend.create.bind(this.backend);if(c.length<6)try{let d;c.length===5?d=c(e,r,s,n,l):d=c(e,r,s,n),d&&typeof d.then=="function"?d.then(f=>o(null,f)).catch(o):o(null,d)}catch(d){o(d)}else c(e,r,s,n,o,l)}!e||!e[0]||this.store.addResource(e[0],r,s,n)}}}const zi=()=>({debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),pe(t[1])&&(e.defaultValue=t[1]),pe(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const r=t[3]||t[2];Object.keys(r).forEach(s=>{e[s]=r[s]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Hi=t=>(pe(t.ns)&&(t.ns=[t.ns]),pe(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),pe(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&t.supportedLngs.indexOf("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),yn=()=>{},od=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(r=>{typeof t[r]=="function"&&(t[r]=t[r].bind(t))})};class Is extends mn{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Hi(e),this.services={},this.logger=Zt,this.modules={external:[]},od(this),r&&!this.isInitialized&&!e.isClone){if(!this.options.initImmediate)return this.init(e,r),this;setTimeout(()=>{this.init(e,r)},0)}}init(){var e=this;let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof r=="function"&&(s=r,r={}),!r.defaultNS&&r.defaultNS!==!1&&r.ns&&(pe(r.ns)?r.defaultNS=r.ns:r.ns.indexOf("translation")<0&&(r.defaultNS=r.ns[0]));const n=zi();this.options={...n,...this.options,...Hi(r)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...n.interpolation,...this.options.interpolation}),r.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=r.keySeparator),r.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=r.nsSeparator);const a=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Zt.init(a(this.modules.logger),this.options):Zt.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:typeof Intl<"u"&&(d=nd);const f=new Bi(this.options);this.store=new Mi(this.options.resources,this.options);const p=this.services;p.logger=Zt,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new td(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),d&&(!this.options.interpolation.format||this.options.interpolation.format===n.interpolation.format)&&(p.formatter=a(d),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new rd(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new id(a(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var g=arguments.length,y=new Array(g>1?g-1:0),v=1;v<g;v++)y[v-1]=arguments[v];e.emit(h,...y)}),this.modules.languageDetector&&(p.languageDetector=a(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=a(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new gn(this.services,this.options),this.translator.on("*",function(h){for(var g=arguments.length,y=new Array(g>1?g-1:0),v=1;v<g;v++)y[v-1]=arguments[v];e.emit(h,...y)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,s||(s=yn),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=function(){return e.store[d](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=function(){return e.store[d](...arguments),e}});const l=Ns(),c=()=>{const d=(f,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(p),s(f,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),l}loadResources(e){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:yn;const n=pe(e)?e:this.language;if(typeof e=="function"&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if(n&&n.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return s();const a=[],i=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(c=>{c!=="cimode"&&a.indexOf(c)<0&&a.push(c)})};n?i(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>i(l)),this.options.preload&&this.options.preload.forEach(o=>i(o)),this.services.backendConnector.load(a,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),s(o)})}else s(null)}reloadResources(e,r,s){const n=Ns();return typeof e=="function"&&(s=e,e=void 0),typeof r=="function"&&(s=r,r=void 0),e||(e=this.languages),r||(r=this.options.ns),s||(s=yn),this.services.backendConnector.reload(e,r,a=>{n.resolve(),s(a)}),n}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Fi.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let r=0;r<this.languages.length;r++){const s=this.languages[r];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}}changeLanguage(e,r){var s=this;this.isLanguageChangingTo=e;const n=Ns();this.emit("languageChanging",e);const a=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},i=(l,c)=>{c?(a(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,n.resolve(function(){return s.t(...arguments)}),r&&r(l,function(){return s.t(...arguments)})},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=pe(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);c&&(this.language||a(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(c)),this.loadResources(c,d=>{i(d,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),n}getFixedT(e,r,s){var n=this;const a=function(i,o){let l;if(typeof o!="object"){for(var c=arguments.length,d=new Array(c>2?c-2:0),f=2;f<c;f++)d[f-2]=arguments[f];l=n.options.overloadTranslationOptionHandler([i,o].concat(d))}else l={...o};l.lng=l.lng||a.lng,l.lngs=l.lngs||a.lngs,l.ns=l.ns||a.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||s||a.keyPrefix);const p=n.options.keySeparator||".";let h;return l.keyPrefix&&Array.isArray(i)?h=i.map(g=>`${l.keyPrefix}${p}${g}`):h=l.keyPrefix?`${l.keyPrefix}${p}${i}`:i,n.t(h,l)};return pe(e)?a.lng=e:a.lngs=e,a.ns=r,a.keyPrefix=s,a}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const s=r.lng||this.resolvedLanguage||this.languages[0],n=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const i=(o,l)=>{const c=this.services.backendConnector.state[`${o}|${l}`];return c===-1||c===0||c===2};if(r.precheck){const o=r.precheck(this,i);if(o!==void 0)return o}return!!(this.hasResourceBundle(s,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(s,e)&&(!n||i(a,e)))}loadNamespaces(e,r){const s=Ns();return this.options.ns?(pe(e)&&(e=[e]),e.forEach(n=>{this.options.ns.indexOf(n)<0&&this.options.ns.push(n)}),this.loadResources(n=>{s.resolve(),r&&r(n)}),s):(r&&r(),Promise.resolve())}loadLanguages(e,r){const s=Ns();pe(e)&&(e=[e]);const n=this.options.preload||[],a=e.filter(i=>n.indexOf(i)<0&&this.services.languageUtils.isSupportedCode(i));return a.length?(this.options.preload=n.concat(a),this.loadResources(i=>{s.resolve(),r&&r(i)}),s):(r&&r(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";const r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],s=this.services&&this.services.languageUtils||new Bi(zi());return r.indexOf(s.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return new Is(e,r)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:yn;const s=e.forkResourceStore;s&&delete e.forkResourceStore;const n={...this.options,...e,isClone:!0},a=new Is(n);return(e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(o=>{a[o]=this[o]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},s&&(a.store=new Mi(this.store.data,n),a.services.resourceStore=a.store),a.translator=new gn(a.services,n),a.translator.on("*",function(o){for(var l=arguments.length,c=new Array(l>1?l-1:0),d=1;d<l;d++)c[d-1]=arguments[d];a.emit(o,...c)}),a.init(n,r),a.translator.options=n,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Re=Is.createInstance();Re.createInstance=Is.createInstance,Re.createInstance,Re.dir,Re.init,Re.loadResources,Re.reloadResources,Re.use,Re.changeLanguage,Re.getFixedT,Re.t,Re.exists,Re.setDefaultNamespace,Re.hasLoadedNamespace,Re.loadNamespaces,Re.loadLanguages;function ld(){if(console&&console.warn){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];Ir(e[0])&&(e[0]=`react-i18next:: ${e[0]}`),console.warn(...e)}}const Wi={};function ga(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];Ir(e[0])&&Wi[e[0]]||(Ir(e[0])&&(Wi[e[0]]=new Date),ld(...e))}const qi=(t,e)=>()=>{if(t.isInitialized)e();else{const r=()=>{setTimeout(()=>{t.off("initialized",r)},0),e()};t.on("initialized",r)}},Gi=(t,e,r)=>{t.loadNamespaces(e,qi(t,r))},Ji=(t,e,r,s)=>{Ir(r)&&(r=[r]),r.forEach(n=>{t.options.ns.indexOf(n)<0&&t.options.ns.push(n)}),t.loadLanguages(e,qi(t,s))},cd=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=e.languages[0],n=e.options?e.options.fallbackLng:!1,a=e.languages[e.languages.length-1];if(s.toLowerCase()==="cimode")return!0;const i=(o,l)=>{const c=e.services.backendConnector.state[`${o}|${l}`];return c===-1||c===2};return r.bindI18n&&r.bindI18n.indexOf("languageChanging")>-1&&e.services.backendConnector.backend&&e.isLanguageChangingTo&&!i(e.isLanguageChangingTo,t)?!1:!!(e.hasResourceBundle(s,t)||!e.services.backendConnector.backend||e.options.resources&&!e.options.partialBundledLanguages||i(s,t)&&(!n||i(a,t)))},ud=function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!e.languages||!e.languages.length?(ga("i18n.languages were undefined or empty",e.languages),!0):e.options.ignoreJSONStructure!==void 0?e.hasLoadedNamespace(t,{lng:r.lng,precheck:(n,a)=>{if(r.bindI18n&&r.bindI18n.indexOf("languageChanging")>-1&&n.services.backendConnector.backend&&n.isLanguageChangingTo&&!a(n.isLanguageChangingTo,t))return!1}}):cd(t,e,r)},Ir=t=>typeof t=="string",dd=t=>typeof t=="object"&&t!==null,hd=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,fd={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},pd=t=>fd[t];let ya={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:t=>t.replace(hd,pd)};const md=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ya={...ya,...t}},gd=()=>ya;let Zi;const yd=t=>{Zi=t},vd=()=>Zi,bd={type:"3rdParty",init(t){md(t.options.react),yd(t)}},wd=k.createContext();class xd{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces=()=>Object.keys(this.usedNamespaces)}const _d=(t,e)=>{const r=k.useRef();return k.useEffect(()=>{r.current=t},[t,e]),r.current},Yi=(t,e,r,s)=>t.getFixedT(e,r,s),kd=(t,e,r,s)=>k.useCallback(Yi(t,e,r,s),[t,e,r,s]),Ds=function(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:r}=e,{i18n:s,defaultNS:n}=k.useContext(wd)||{},a=r||s||vd();if(a&&!a.reportNamespaces&&(a.reportNamespaces=new xd),!a){ga("You will need to pass in an i18next instance by using initReactI18next");const E=(N,L)=>Ir(L)?L:dd(L)&&Ir(L.defaultValue)?L.defaultValue:Array.isArray(N)?N[N.length-1]:N,T=[E,{},!1];return T.t=E,T.i18n={},T.ready=!1,T}a.options.react&&a.options.react.wait!==void 0&&ga("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const i={...gd(),...a.options.react,...e},{useSuspense:o,keyPrefix:l}=i;let c=n||a.options&&a.options.defaultNS;c=Ir(c)?[c]:c||["translation"],a.reportNamespaces.addUsedNamespaces&&a.reportNamespaces.addUsedNamespaces(c);const d=(a.isInitialized||a.initializedStoreOnce)&&c.every(E=>ud(E,a,i)),f=kd(a,e.lng||null,i.nsMode==="fallback"?c:c[0],l),p=()=>f,h=()=>Yi(a,e.lng||null,i.nsMode==="fallback"?c:c[0],l),[g,y]=k.useState(p);let v=c.join();e.lng&&(v=`${e.lng}${v}`);const C=_d(v),_=k.useRef(!0);k.useEffect(()=>{const{bindI18n:E,bindI18nStore:T}=i;_.current=!0,!d&&!o&&(e.lng?Ji(a,e.lng,c,()=>{_.current&&y(h)}):Gi(a,c,()=>{_.current&&y(h)})),d&&C&&C!==v&&_.current&&y(h);const N=()=>{_.current&&y(h)};return E&&a&&a.on(E,N),T&&a&&a.store.on(T,N),()=>{_.current=!1,E&&a&&E.split(" ").forEach(L=>a.off(L,N)),T&&a&&T.split(" ").forEach(L=>a.store.off(L,N))}},[a,v]),k.useEffect(()=>{_.current&&d&&y(p)},[a,l,d]);const S=[g,a,d];if(S.t=g,S.i18n=a,S.ready=d,d||!d&&!o)return S;throw new Promise(E=>{e.lng?Ji(a,e.lng,c,()=>E()):Gi(a,c,()=>E())})};function Sd(){return typeof window>"u"?"en":window.location.pathname.split("/").filter(Boolean)[0]==="hi"?"hi":"en"}const Cd=Sd(),Ed={en:{translation:{common:{switchToHindi:"Switch to Hindi",switchToEnglish:"Switch to English",next:"Next",back:"Back",bookNow:"Book Now",mySolutionFinder:"My Solution Finder"},index:{heroTitlePart1:"Find Your Perfect",heroTitlePart2:"Spiritual Solution",heroSubtitle:"Get personalized puja recommendations to guide your spiritual practice.",cta:"My Solution Finder",clickHere:"Click here"},trust:{trust1:"Results verified by India's top astrologers",trust2:"Based on Vedic principles & precise planetary positions",trust3:"Trusted by 30 Lakh+ users"},reviews:{heading:"What Our Devotees Say",subheading:"Trusted by thousands of families across India"},footer:{description:"Sri Mandir has brought religious services to the masses in India by connecting devotees, pundits, and temples. Partnering with over 50 renowned temples, we provide exclusive pujas and offering services performed by expert pandits and share videos of the completed puja rituals.",company:"Company",ourServices:"Our Services",services:{puja:"Puja",chadhava:"Chadhava",panchang:"Panchang",temples:"Temples"},ourAddress:"Our Address",address:"Firstprinciple AppsForBharat Pvt. Ltd. 435, 1st Floor 17th Cross, 19th Main Rd, above Axis Bank, Sector 4, HSR Layout, Bengaluru, Karnataka 560102",aboutUs:"About Us",contactUs:"Contact Us",privacyPolicy:"Privacy Policy",terms:"Terms and Conditions",copyright:"© 2025 Sri Mandir. All rights reserved."},trustBadge:{tagline:"India's most trusted devotion app",downloads:"3 Cr.+ downloads"},solutionFinder:{title:"My Solution Finder",description:"My Solution Finder is a 4-step tool that recommends the most suitable puja based on your birth details and life concerns. Enter your date of birth, select the area for which you need blessings, and receive personalised puja recommendations. With one click, book the puja that's right for you.",enterDob:"Enter your DOB",day:"Day",month:"Month",year:"Year",readingMap:"Reading Your Celestial Map...",astrologicalDetails:"Your Astrological Details",yourRashi:"Your Rashi",yourMoolank:"Your Moolank",selectAreasHeading:"What area of life do you need blessings for?",selectAreasSub:"You can select multiple areas",areas:{health:"Health",career:"Career",love:"Love / Relationships",family:"Family Issues",finances:"Finances",peace:"Peace of Mind",child:"Child Well-being"},recommendedTitle:"Your Recommended Pujas",basedOn:"Based on your birth details and selected areas: {{areas}}",noPujas:"No specific pujas found for your selected areas. Please try selecting different areas."},dosha:{heroTitle:"Find Puja Remedy for your Life Problems",heroSubtitle:"Analyse your kundli to find out which doshas (if any) appear in your Vedic chart—and see devotional remedies.",whatIsDosha:"What is a dosha?",whatIsDoshaAnswer:"In Vedic astrology, a dosha is a specific planetary pattern believed to create challenges or imbalances in life.",whyImportant:"Why is it important?",whyImportantAnswer:"Identifying doshas helps you understand potential friction points and explore time-tested, gentle remedies.",howImpact:"How can it impact life?",howImpactAnswer:"Traditionally, doshas are linked to areas like relationships, career, health, and peace of mind—always interpreted with discretion.",calculatorTitle:"Vedic Dosha Calculator",calculatorDesc:"Discover potential doshas in your birth chart based on classical Jyotish principles",refresh:"Refresh",name:"Name",enterName:"Enter your name",gender:"Gender",selectGender:"Select gender",requestExpertCallback:"Request call back from our expert",male:"Male",female:"Female",dateOfBirth:"Select Date of Birth",timeOfBirth:"Exact Time of Birth",unknownTime:"I don't know my birth time",dontKnowTime:"I don't know my birth time",timeFormat:"Format: hh:mm AM/PM",unknownTimeWarning:"⚠️ Without exact birth time, accuracy will be reduced. We'll run Moon-based checks only.",placeOfBirth:"Place of Birth (City)",enterPlace:"e.g. Jaipur, Mumbai, Varanasi",typeChars:"Type 2+ characters",placePlaceholder:"e.g. Jaipur, Mumbai, Varanasi",edit:"Edit",latitude:"Latitude",longitude:"Longitude",timeZone:"Time Zone (India)",privacyNote:"🔒 Privacy: We don't store your details server-side unless you generate a share link.",privacyPlace:"🔒 We only use your input to look up the place; nothing is stored.",calculating:"Calculating...",calculateButton:"Calculate My Doshas",disclaimer:"⚠️ This is an educational tool based on classical Jyotish rules; not medical, legal, or financial advice.",formRefreshed:"Form refreshed",locationSelected:"Location selected. Time zone: Asia/Kolkata",enterTimeError:"Please enter birth time or mark it as unknown",calculationSuccess:"Doshas calculated successfully!",calculationError:"Failed to calculate doshas. Please try again.",problemAreaLabel:"Which is the biggest problem area of your life?",problemAreaHint:"Max 100 characters",problemAreaOtherPlaceholder:"Please describe your problem",selectProblems:"Select your problems",problemsSelected:"{{count}} problems selected"},resultTitle:"Your Dosha Analysis",resultPageTitle:"Your Dosha Analysis Results",resultPageSubtitle:"Based on your birth details and planetary positions",resultSomeDoshas:"Some Doshas Have Been Detected",resultNoDoshas:"No Major Doshas Found",resultNoDoshasDesc:"Your birth chart shows no major doshas.",resultMangal:"Mangal Dosha",resultKaalSarp:"Kaal Sarp Dosha",resultPitra:"Pitra Dosha",resultSadeSati:"Shani Sade Sati",resultStatusPresent:"Present",resultStatusAbsent:"Absent",resultStatusInactive:"Inactive",resultExplanation:"Explanation",resultRemedies:"Remedies",resultEditForm:"Edit details",drDoshaOf:"Dosha {{index}} of {{total}}",drStatus:"Status",drSeverity:"Severity",drSeverityHigh:"High",drSeverityMedium:"Medium",drSeverityLow:"Low",drPhase:"Phase",drWhyMarked:"Why is this dosha marked in your kundli?",drViewKundli:"View Kundli",drBasedOnPositions:"Based on planetary positions in your chart",drPhaseMeaning:"Phase Meaning",drPhaseRising:"Rising Phase (1st 2.5 years): Initial challenges begin",drPhasePeak:"Peak Phase (middle 2.5 years): Most intense period",drPhaseSetting:"Setting Phase (last 2.5 years): Challenges gradually ease",drPlanetaryPositions:"Planetary Positions",drImpactIfPresent:"Impact If Present",drHowPujaHelps:"How this Puja will help",drFomoLine:"Results are based on Vedic astrology principles. Consult an expert for personalized guidance.",drFeedbackContact:"Have questions? Contact us at",drDetailedAnalysis:"Detailed Analysis & Remedies",drBasedOnChart:"Based on your birth chart calculations",drStatusPresent:"Present",drStatusAbsent:"Absent",drStatusInactive:"Inactive",drStatusNullified:"Nullified",drExplanation:"Explanation",drWhyPresent:"Why Present",drWhyAbsent:"Why Absent",drImpact:"Impact",drTraditionalRemedies:"Traditional Remedies",drOtherDoshas:"Other Doshas",drOtherDoshasStatusActive:"Additional doshas detected in your chart",drOtherDoshasStatusNone:"No other doshas found",drOtherGrahan:"Grahan Dosha",drOtherShrapit:"Shrapit Dosha",drOtherGuruChandal:"Guru Chandal Dosha",drOtherPunarphoo:"Punarphoo Dosha",drOtherKemadruma:"Kemadruma Dosha",drOtherGandmool:"Gandmool Dosha",drOtherKalathra:"Kalathra Dosha",drOtherVishDaridra:"Vish Daridra Dosha",drOtherKetuNaga:"Ketu Naga Dosha",drOtherNavagraha:"Navagraha Dosha",drOtherGrahanDesc:"Occurs when Rahu-Ketu eclipse the Sun or Moon; traditionally linked to sudden challenges or hidden fears.",drOtherShrapitDesc:"Saturn-Rahu conjunction in any house; often framed as ancestral karmic debts requiring resolution.",drOtherGuruChandalDesc:"Jupiter afflicted by Rahu/Ketu; can cause conflict between higher wisdom and material desires.",drOtherPunarphooDesc:"Saturn-Moon affliction indicating recurring emotional cycles or repeated patterns.",drOtherKemadrumaDesc:"Moon isolated from benefic support; can indicate periods of emotional vulnerability.",drOtherGandmoolDesc:"Birth in specific Moon nakshatras (Ashwini, Revati, etc.); traditionally requires special rituals.",drOtherKalathraDec:"Affliction in 7th house or its lord; primarily associated with partnership and marriage themes.",drOtherVishDaridraDesc:"Mars-Saturn challenging aspect creating tension between action and caution.",drOtherKetuNagaDesc:"Ketu-related serpent energy; linked to spiritual transformation and past-life patterns.",drOtherNavagrahaDesc:"Multiple planetary afflictions suggesting need for comprehensive planetary peace rituals.",drOtherGrahanImpact:"Sudden setbacks, hidden anxieties, or eclipse-related sensitivities may arise; emotional ups and downs.",drOtherShrapitImpact:"Ancestral obligations, recurring obstacles, or karmic lessons that demand patience and resolution.",drOtherGuruChandalImpact:"Judgment issues, mentor problems, or misalignment between promises and outcomes in spiritual/ethical matters.",drOtherPunarphooImpact:"Emotional cycles repeating; relationships or situations may loop back requiring renewed effort.",drOtherKemadrumaImpact:"Periods of emotional isolation or lack of support; resilience needed during vulnerable phases.",drOtherGandmoolImpact:"Birth nakshatra challenges; traditional remedies advised for smoother life transitions.",drOtherKalathraImpact:"Partnership friction, marriage delays, or 7th house matters requiring attention and patience.",drOtherVishDaridraImpact:"Action-caution conflict; financial strain or Mars-Saturn tension creating stop-start patterns.",drOtherKetuNagaImpact:"Spiritual restlessness, past-life echoes, or serpent-energy themes needing acknowledgment.",drOtherNavagrahaImpact:"Multiple planetary imbalances creating varied life challenges; comprehensive remedies recommended.",drOtherGrahanRemedies:`Chant Rahu-Ketu mantras during eclipses
15
15
  Donate to eclipse-related charities
16
16
  Wear Gomed or Cat's Eye after consultation
17
17
  Perform Grahan Shanti puja`,drOtherShrapitRemedies:`Worship Shani and Rahu on Saturdays
@@ -119,32 +119,32 @@ Protects from impulsive decisions and heated confrontations.`,drPujaRecommendati
119
119
  परामर्श के बाद मूंगा रत्न पहनें`,drPujaBenefitsMangal:`संघर्ष और अस्थिरता पैदा करने वाली आक्रामक मंगल ऊर्जा को शांत करती है।
120
120
  मंगल को शांत करने के लिए हवन से बाधाओं को कम करती है।
121
121
  रिश्तों और पारिवारिक जीवन में सामंजस्य को मजबूत करती है।
122
- आवेगपूर्ण निर्णयों और गरमागरम टकराव से बचाती है।`,drPujaRecommendation:"पूजा अनुशंसा",drNoPujaAvailable:"इस दोष के लिए कोई विशेष पूजा उपलब्ध नहीं है",doshaResults:{summary:"आपका दोष सारांश",detailedAnalysis:"विस्तृत विश्लेषण और उपचार",basedOnChart:"आपके जन्म चार्ट गणना के आधार पर",status:"स्थिति",severity:"गंभीरता",type:"प्रकार",phase:"चरण",explanation:"व्याख्या",placements:"स्थान",planetaryPositions:"ग्रहों की स्थिति",whyPresent:"क्यों उपस्थित है",whyAbsent:"क्यों अनुपस्थित है",impact:"प्रभाव",traditionalRemedies:"पारंपरिक उपचार",sriMandirRemedies:"श्री मंदिर की पेशकश किए गए उपचार",upcomingPujas:"आगामी पूजाएं उपलब्ध",disclaimer:"हम स्थापित ज्योतिषीय नियमों का पालन करते हैं, परंतु दोष की व्याख्या विभिन्न ज्योतिषियों में भिन्न हो सकती है। यदि आप अन्य दृष्टिकोण जानना चाहें तो किसी विश्वसनीय ज्योतिषी से परामर्श करें।",educationalTool:"⚠️ यह लोकप्रिय ज्योतिष नियमों पर आधारित एक शैक्षिक उपकरण है। विवेक के साथ व्याख्या करें।",statusValues:{present:"उपस्थित",absent:"अनुपस्थित",inactive:"निष्क्रिय",active:"सक्रिय",suggested:"सुझाया गया",someDoshasActive:"कुछ दोष सक्रिय",noDoshasFound:"कोई दोष नहीं मिला"},severityValues:{high:"उच्च",medium:"मध्यम",low:"निम्न"},mangal:{name:"मंगल दोष (मांगलिक)",description:"मंगल (मांगलिक/कुजा) दोष — कुछ घरों में मंगल से जुड़ा; पारंपरिक रूप से रिश्तों में घर्षण और निर्णायकता से जुड़ा है।",impact:"करीबी रिश्तों में घर्षण की अधिक संभावना, अधीरता/क्रोध के झटके, या विवाह या साझेदारी में देरी और रुक-रुक कर शुरुआत।",remedies:["प्रतिदिन हनुमान चालीसा का पाठ करें","मंगलवार को व्रत रखें","लाल दाल या कपड़े का दान करें","परामर्श के बाद मूंगा रत्न पहनें"]},kaalSarp:{name:"काल सर्प दोष",description:"काल सर्प दोष — सभी ग्रह राहु और केतु के बीच फंसे; अक्सर आंतरिक तनाव और परिवर्तन के पैटर्न के रूप में तैयार किया जाता है।",impact:"आंतरिक बेचैनी और आवधिक असफलताओं का एक पैटर्न; प्रयास के बावजूद योजनाएं अवरुद्ध या विलंबित हो सकती हैं, अतिरिक्त दृढ़ता की आवश्यकता है।",remedies:["प्रतिदिन 108 बार महा मृत्युंजय मंत्र का जाप करें","नियमित रूप से आवारा कुत्तों को खाना खिलाएं","सांप कल्याण या नाग मंदिरों में दान करें","घर में चांदी का नाग रखें"]},pitra:{name:"पितृ दोष",description:"पितृ (पितृ) दोष — 9वें घर और सूर्य-नोड लिंक के आसपास पारंपरिक संकेतक; कर्तव्यों, वंश और मार्गदर्शन से जुड़े।",impact:"परिवार या बड़ों के प्रति बार-बार कर्तव्य/दायित्व; अपराधबोध, विवाद, या विरासत के मुद्दे सामने आ सकते हैं और समाधान की मांग कर सकते हैं।",remedies:["तिथियों पर श्राद्ध समारोह करें","अमावस्या को जरूरतमंदों को भोजन कराएं","पितृ गायत्री मंत्र का पाठ करें","प्रतिदिन सुबह पूर्वजों को जल अर्पित करें"]},sadeSati:{name:"शनि साढ़े साती",description:"शनि साढ़े साती — जन्म चंद्रमा के पड़ोस में शनि का संक्रमण; अनुशासन और धैर्य पर जोर देने वाला 7.5 साल का चक्र।",impact:"भारी जिम्मेदारियां, धीमी प्रगति, और धैर्य की परीक्षा; गति के बजाय लगातार अनुशासन के साथ परिणाम आते हैं।",remedies:["शनिवार को शनि मंत्र का जाप करें","शनिवार को सरसों के तेल का दीपक जलाएं","तिल, कंबल जैसी काली वस्तुओं का दान करें","कौवों को खिलाएं और विकलांगों की सेवा करें"]},otherDoshas:{title:"अन्य दोष",rahuKetu:{name:"राहु–केतु / ग्रहण दोष",whatItIs:"सूर्य या चंद्रमा राहु/केतु के साथ निकट संरेखित (ग्रहण पैटर्न); अक्सर ग्रहण दोष कहा जाता है।",impact:"मिजाज में बदलाव, विचलन, और चिंता; प्रयास के बावजूद योजनाएं ग्रहण या विलंबित महसूस हो सकती हैं।",remedies:["माइंडफुलनेस और स्थिर दिनचर्या अपनाएं","प्राणायाम और श्वास अभ्यास करें","ग्रहण के दिनों में दान करें"]},shrapit:{name:"श्रापित दोष (शनि–राहु)",whatItIs:"शनि और राहु एक साथ या मजबूत पारस्परिक दृष्टि में।",impact:"बार-बार बाधाएं, कर्म विलंब, भारी कर्तव्य; प्रगति धीरे-धीरे आती है।",remedies:["शनिवार को अनुशासन और व्रत रखें","सेवा और विनम्रता का अभ्यास करें","शनि चालीसा का पाठ करें"]},guruChandal:{name:"गुरु चांडाल दोष (बृहस्पति–राहु/केतु)",whatItIs:"बृहस्पति राहु या केतु के साथ।",impact:"निर्णय/गुरु मुद्दे; वादे बनाम परिणाम गलत संरेखित हो सकते हैं।",remedies:["अच्छे गुरुओं के साथ अध्ययन करें","किताबें या शिक्षा वस्तुओं का दान करें","गुरु बीज मंत्र का जाप करें"]},punarphoo:{name:"पुनर्फू दोष (शनि–चंद्र)",whatItIs:"चंद्रमा शनि के साथ या तंग शनि प्रभाव के तहत।",impact:"चालू-बंद परिणाम, भावनात्मक भारीपन; धैर्य की मांग करने वाली देरी।",remedies:["सोमवार को शांत ध्यान करें","शिवलिंग पर जल चढ़ाएं","परामर्श के बाद मोती पहनें"]},kemadruma:{name:"केमद्रुम योग (चंद्र अलग-थलग)",whatItIs:"चंद्रमा बिना दोनों तरफ ग्रह पड़ोसियों के (शास्त्रीय अलगाव)।",impact:"अलगाव की भावनाएं; उतार-चढ़ाव समर्थन या वित्त।",remedies:["नियमित रूप से सामुदायिक सेवा करें","कृतज्ञता अनुष्ठान करें","बिस्तर के पास पानी से भरा चांदी का कटोरा रखें"]},gandmool:{name:"गण्डमूल दोष (विशिष्ट नक्षत्रों में चंद्र)",whatItIs:"अश्विनी, अश्लेषा, मघा, ज्येष्ठा, मूल, या रेवती में चंद्रमा।",impact:"संवेदनशील शुरुआत; सचेत संस्कारों और मार्गदर्शन की आवश्यकता है।",remedies:["परिवार के आशीर्वाद और बड़ों का मार्गदर्शन लें","सोमवार को चंद्र मंत्र का पाठ करें"]},kalathra:{name:"कलात्र दोष (7वां घर/साथी पीड़ा)",whatItIs:"7वें घर, इसके स्वामी, या शुक्र पर मजबूत अशुभ प्रभाव।",impact:"रिश्ते में घर्षण, देरी, या ब्रेक; साझेदारी सबक।",remedies:["शुक्रवार को सद्भाव अनुष्ठान करें","परामर्श के बाद हीरा या सफेद नीलम पहनें","सफेद वस्तुओं का दान करें"]},vishDaridra:{name:"विष/दरिद्र योग (मंगल–शनि कठोर संयोजन)",whatItIs:"मुख्य घरों में तंग मंगल–शनि संयोजन/दृष्टि।",impact:"रुक-रुक कर परिणाम; ड्राइव और संयम के बीच संघर्ष।",remedies:["संरचित और धैर्यवान प्रयास करें","हनुमान चालीसा का पाठ करें","संघर्ष से बचें और क्षमा का अभ्यास करें"]},ketuNaga:{name:"केतु/नाग (सर्प) दोष (गैर-काल सर्प)",whatItIs:"मुख्य घरों में केतु या पूर्ण काल सर्प पैटर्न के बिना चंद्र/शुक्र को पीड़ित करना।",impact:"अलगाव विषय; रिश्ते में ठंडापन बनाम आध्यात्मिक खिंचाव।",remedies:["जहां पारंपरिक हो नाग मंदिर जाएं","स्थिर भक्ति दिनचर्या बनाए रखें","चींटियों और पक्षियों को खिलाएं"]},navagraha:{name:"नवग्रह शांति (व्यापक सुझाव)",whatItIs:"सामान्य ग्रह तनाव जब कई छोटे झंडे एक साथ दिखाई देते हैं।",impact:"जीवन के क्षेत्रों में फैली बाधाएं; संतुलित शांति से लाभ।",remedies:["संतुलित अनुशासन बनाए रखें","घर पर नियमित सरल पूजा करें","नवग्रह मंदिर जाएं"]}}}}}};Re.use(xd).init({resources:Ad,lng:Td,fallbackLng:"en",interpolation:{escapeValue:!1}}),Re.on("languageChanged",t=>{if(typeof window>"u")return;const{pathname:e,search:r,hash:s}=window.location,n=e.split("/").filter(Boolean);n[0]==="en"||n[0]==="hi"?n[0]=t:n.unshift(t);const i="/"+n.join("/")+r+s;i!==e+r+s&&(window.location.href=i)});var jd={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Od=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),at=(t,e)=>{const r=k.forwardRef(({color:s="currentColor",size:n=24,strokeWidth:a=2,absoluteStrokeWidth:i,className:o="",children:l,...c},u)=>k.createElement("svg",{ref:u,...jd,width:n,height:n,stroke:s,strokeWidth:i?Number(a)*24/Number(n):a,className:["lucide",`lucide-${Od(t)}`,o].join(" "),...c},[...e.map(([p,f])=>k.createElement(p,f)),...Array.isArray(l)?l:[l]]));return r.displayName=`${t}`,r};const $s=at("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Pd=at("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const Nd=at("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const Rd=at("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Id=at("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const Xi=at("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Dd=at("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);const Ld=at("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const $d=at("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);const Md=at("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);const Qi=at("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Fd=at("MapPin",[["path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z",key:"2oe9fu"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);const Ud=at("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);const Bd=at("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);const Vd=at("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);const Kd=at("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const zd=at("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]),Dr=t=>{const{priority:e,fetchPriority:r,width:s,height:n,...a}=t;return k.createElement("img",{...a,width:s??1,height:n??1,decoding:"async",loading:a.loading??(e?"eager":"lazy"),...r&&{fetchPriority:r}})},Hd="https://srm-cdn.a4b.io/yoda/1770362904947.svg";function eo({analytics:t,isGlobal:e}={}){const{t:r}=Ls(),s=(Re.language||"").toLowerCase().startsWith("hi"),n=()=>{const a=s?"en":"hi";t?.trackLanguageClicked?.(a,!0),Re.changeLanguage(a),t?.trackLanguageChanged?.(a,!0)};return d.jsx("header",{className:"sticky top-0 z-50",style:{backgroundColor:"#FFFCEF"},children:d.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between max-w-2xl",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Dr,{src:Hd,alt:"Sri Mandir",width:32,height:32,loading:"eager",priority:!0}),d.jsxs("div",{className:"flex flex-col",children:[d.jsx("span",{style:{color:"#502D14",fontFamily:'"Plus Jakarta Sans", sans-serif',fontSize:"16px",fontWeight:600,lineHeight:"20px"},children:s?"श्री मंदिर":"Sri Mandir"}),d.jsx("span",{style:{color:"#502D14",fontFamily:'"Plus Jakarta Sans", sans-serif',fontSize:"10px",fontWeight:400,lineHeight:"16px"},children:s?"3 करोड़+ ऐप डाउनलोड":"3 crore+ app downloads"})]})]}),!e&&d.jsxs("button",{onClick:n,className:"flex items-center justify-center gap-1.5 py-2 rounded-lg text-white text-sm font-medium hover:opacity-90 transition-colors",style:{backgroundColor:"#E13A44",borderRadius:"8px",width:"100px"},"aria-label":s?"Switch to English":"हिंदी में बदलें",children:[d.jsx(Ld,{className:"w-5 h-5"}),d.jsx("span",{children:s?"English":"हिंदी"})]})]})})}var Ms=t=>t.type==="checkbox",bn=t=>t.type==="file",wr=t=>t instanceof Date,Ye=t=>t==null;const ba=t=>typeof t=="object";var Ue=t=>!Ye(t)&&!Array.isArray(t)&&ba(t)&&!wr(t),Wd=t=>Ue(t)&&t.target?Ms(t.target)?t.target.checked:bn(t.target)?t.target.files:t.target.value:t;const qd=/[.[\]'"]/;var es=t=>t.split(qd).filter(Boolean),Gd=(t,e)=>e.split(".").some((r,s,n)=>!isNaN(Number(r))&&t.has(n.slice(0,s).join("."))),wn=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Fe(t){if(t===null||typeof t!="object")return t;if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(wn&&(t instanceof Blob||e))return t;const r=Array.isArray(t);if(!r&&t.constructor!==Object)return t;const s=r?[]:Object.create(Object.getPrototypeOf(t));for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=Fe(t[n]));return s}const ts={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},Mt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ft={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},to="root",wa=["__proto__","constructor","prototype"],Jd=/^\w*$/;var Lr=t=>Jd.test(t),Pe=t=>t===void 0,V=(t,e,r)=>{if(!e||!Ue(t))return r;const s=Lr(e)?[e]:es(e);if(s.some(a=>wa.includes(a)))return r;const n=s.reduce((a,i)=>Ye(a)?void 0:a[i],t);return Pe(n)||n===t?Pe(t[e])?r:t[e]:n},Yt=t=>typeof t=="boolean",jt=t=>typeof t=="function",Ne=(t,e,r)=>{let s=-1;const n=Lr(e)?[e]:es(e),a=n.length,i=a-1;for(;++s<a;){const o=n[s];let l=r;if(s!==i){const c=t[o];l=Ue(c)||Array.isArray(c)?c:isNaN(+n[s+1])?{}:[]}if(wa.includes(o))return;t[o]=l,t=t[o]}};const Zd=k.createContext(null);Zd.displayName="HookFormControlContext";var Yd=(t,e,r,s=!0)=>{const n={};for(const a in t)Object.defineProperty(n,a,{get:()=>{const i=a;return e._proxyFormState[i]!==Mt.all&&(e._proxyFormState[i]=!s||Mt.all),t[i]}});return n};const Xd=wn?k.useLayoutEffect:k.useEffect;var Qd=t=>{const e=t.constructor&&t.constructor.prototype;return Ue(e)&&e.hasOwnProperty("isPrototypeOf")},xa=t=>Ye(t)||!ba(t);const ro=(t,e)=>e.length===0&&!Array.isArray(t)&&!Qd(t);function Ut(t,e,r=new WeakMap){if(t===e)return!0;if(xa(t)||xa(e))return Object.is(t,e);if(wr(t)&&wr(e))return Object.is(t.getTime(),e.getTime());const s=Object.keys(t),n=Object.keys(e);if(s.length!==n.length)return!1;if(ro(t,s)||ro(e,n))return Object.is(t,e);if(!s.length&&Array.isArray(t)!==Array.isArray(e))return!1;const a=r.get(t);if(a&&a.has(e))return!0;if(a)a.add(e);else{const i=new WeakSet;i.add(e),r.set(t,i)}for(const i of s){const o=t[i];if(!(i in e))return!1;if(i!=="ref"){const l=e[i];if(wr(o)&&wr(l)||(Ue(o)||Array.isArray(o))&&(Ue(l)||Array.isArray(l))?!Ut(o,l,r):!Object.is(o,l))return!1}}return!0}function eh(t){const e=k.useRef(!1),r=k.useRef(!1),s=k.useRef(void 0),n=k.useRef(0);n.current++,r.current;const a=k.useCallback((o,l,c)=>{if(o&&(e.current||r.current&&n.current>1)){const u=l();Ut(s.current,u)||c(u)}e.current=!0},[]),i=k.useCallback((o,l)=>{o&&(s.current=Fe(l()))},[]);return{resyncIfNeeded:a,snapshot:i}}var Xe=t=>typeof t=="string",th=(t,e,r,s,n)=>Xe(t)?(s&&e.watch.add(t),V(r,t,n)):Array.isArray(t)?t.map(a=>(s&&e.watch.add(a),V(r,a,V(n,a)))):(s&&(e.watchAll=!0),r),xn=t=>({isOnSubmit:!t||t===Mt.onSubmit,isOnBlur:t===Mt.onBlur,isOnChange:t===Mt.onChange,isOnAll:t===Mt.all,isOnTouch:t===Mt.onTouched}),_a=(t,e,r)=>{if(r)return!1;if(e.watchAll||e.watch.has(t))return!0;for(const s of e.watch)if(t.startsWith(s)&&t.charAt(s.length)===".")return!0;return!1};const Fs=(t,e,r,s)=>{for(const n of r||Object.keys(t)){if(n==="_f")continue;const a=r?V(t,n):t[n];if(a){const{_f:i}=a;if(i){if(i.refs&&i.refs[0]&&e(i.refs[0],n)&&!s)return!0;if(i.ref&&e(i.ref,i.name)&&!s)return!0;if(Fs(a,e))break}else if((Ue(a)||Array.isArray(a))&&Fs(a,e))break}}};var so=(t,e,r)=>{const s=V(t,r),n=Array.isArray(s)?s:[];return Ne(n,to,e[r]),Ne(t,r,n),t},it=t=>Ue(t)&&!Object.keys(t).length,_n=t=>{if(!wn)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},ka=t=>t.type==="radio",kn=t=>t instanceof RegExp,no=(t,e,r,s,n)=>e?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[s]:n||!0}}:{};const ao={value:!1,isValid:!1},io={value:!0,isValid:!0};var oo=t=>{if(!Array.isArray(t))return ao;if(t.length>1){const r=t.filter(s=>s&&s.checked&&!s.disabled).map(s=>s.value);return{value:r,isValid:!!r.length}}const e=t[0];return!e||!e.checked||e.disabled?ao:!e.attributes||!("value"in e.attributes)||Pe(e.value)||e.value===""?io:{value:e.value,isValid:!0}};const lo={isValid:!1,value:null};var co=t=>Array.isArray(t)?t.reduce((e,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:e,lo):lo;function uo(t,e,r="validate"){if(Xe(t)||Array.isArray(t)&&t.every(Xe)||Yt(t)&&!t)return{type:r,message:Xe(t)?t:"",ref:e}}var rs=t=>Ue(t)&&!kn(t)?t:{value:t,message:""},ho=async(t,e,r,s,n,a)=>{const{ref:i,refs:o,required:l,maxLength:c,minLength:u,min:p,max:f,pattern:h,validate:y,name:g,valueAsNumber:v,mount:C}=t._f,_=V(r,g);if(!C||e.has(g))return{};const S=o?o[0]:i,E=X=>{if(n&&S.reportValidity){const W=Yt(X)?"":X||"";o?o.forEach(oe=>oe.setCustomValidity(W)):S.setCustomValidity(W),S.reportValidity()}},T={},N=ka(i),L=Ms(i),ue=N||L,re=(v||bn(i))&&Pe(i.value)&&Pe(_)||_n(i)&&i.value===""||_===""||Array.isArray(_)&&!_.length,je=no.bind(null,g,s,T),Se=(X,W,oe,ye=Ft.maxLength,ne=Ft.minLength)=>{const de=X?W:oe;T[g]={type:X?ye:ne,message:de,ref:i,...je(X?ye:ne,de)}};if(a?!Array.isArray(_)||!_.length:l&&(!ue&&(re||Ye(_))||Yt(_)&&!_||L&&!oo(o).isValid||N&&!co(o).isValid)){const{value:X,message:W}=Xe(l)?{value:!!l,message:l}:rs(l);if(X&&(T[g]={type:Ft.required,message:W,ref:S,...je(Ft.required,W)},!s))return E(W),T}if(!re&&(!Ye(p)||!Ye(f))){let X,W;const oe=rs(f),ye=rs(p);if(!Ye(_)&&!wr(_)&&!isNaN(_)){const ne=i.valueAsNumber||_&&+_;Ye(oe.value)||(X=ne>oe.value),Ye(ye.value)||(W=ne<ye.value)}else{const ne=i.valueAsDate||new Date(_),de=z=>new Date(new Date().toDateString()+" "+z),G=i.type=="time",j=i.type=="week";Xe(oe.value)&&_&&(X=G?de(_)>de(oe.value):j?_>oe.value:ne>new Date(oe.value)),Xe(ye.value)&&_&&(W=G?de(_)<de(ye.value):j?_<ye.value:ne<new Date(ye.value))}if((X||W)&&(Se(!!X,oe.message,ye.message,Ft.max,Ft.min),!s))return E(T[g].message),T}if((c||u)&&!re&&(Xe(_)||a&&Array.isArray(_))){const X=rs(c),W=rs(u),oe=!Ye(X.value)&&_.length>+X.value,ye=!Ye(W.value)&&_.length<+W.value;if((oe||ye)&&(Se(oe,X.message,W.message),!s))return E(T[g].message),T}if(h&&!re&&Xe(_)){const{value:X,message:W}=rs(h);if(kn(X)&&!_.match(X)&&(T[g]={type:Ft.pattern,message:W,ref:i,...je(Ft.pattern,W)},!s))return E(W),T}if(y){if(jt(y)){const X=await y(_,r),W=uo(X,S);if(W&&(T[g]={...W,...je(Ft.validate,W.message)},!s))return E(W.message),T}else if(Ue(y)){let X={};for(const W in y){if(!it(X)&&!s)break;const oe=uo(await y[W](_,r),S,W);oe&&(X={...oe,...je(W,oe.message)},E(oe.message),s&&(T[g]=X))}if(!it(X)&&(T[g]={ref:S,...X},!s))return T}}const F=T[g];return E(F?F.message:!0),T},Sn=t=>Array.isArray(t)?t:[t],fo=t=>Array.isArray(t)?t.filter(Boolean):[];function rh(t,e){const r=e.length-1;let s=0;for(;s<r;){if(Ye(t)){t=void 0;break}t=t[e[s]],s++}return t}function sh(t){for(const e in t)if(t.hasOwnProperty(e)&&!Pe(t[e]))return!1;return!0}function Ve(t,e){if(Xe(e)&&Object.prototype.hasOwnProperty.call(t,e))return delete t[e],t;const r=Array.isArray(e)?e:Lr(e)?[e]:es(e);if(r.some(i=>wa.includes(String(i))))return t;const s=r.length===1?t:rh(t,r),n=r.length-1,a=r[n];return s&&delete s[a],n!==0&&(Ue(s)&&it(s)||Array.isArray(s)&&sh(s))&&Ve(t,r.slice(0,-1)),t}const nh=k.createContext(null);nh.displayName="HookFormContext";var po=()=>{let t=[];return{get observers(){return t},next:n=>{for(const a of t)a.next&&a.next(n)},subscribe:n=>(t.push(n),{unsubscribe:()=>{t=t.filter(a=>a!==n)}}),unsubscribe:()=>{t=[]}}};function mo(t,e){const r={};for(const s in t)if(t.hasOwnProperty(s)){const n=t[s],a=e[s];if(n&&Ue(n)&&a){const i=mo(n,a);Ue(i)&&(r[s]=i)}else t[s]&&(r[s]=a)}return r}const go=(t,e)=>t!==null&&ba(t)&&Object.prototype.hasOwnProperty.call(t,e);var ah=(t,e)=>{if(!e)return!1;let r=t;for(const s of Lr(e)?[e]:es(e)){if(!go(r,s))return go(t,e);r=r[s]}return!0},yo=t=>t.type==="select-multiple",ih=t=>ka(t)||Ms(t),Sa=t=>_n(t)&&t.isConnected;function vo(t){return Array.isArray(t)||Ue(t)}function bo(t,e,r="",s=[]){for(const n in t){const a=r?`${r}.${n}`:n,i=t[n];vo(i)&&vo(V(e,a))?bo(i,e,a,s):s.push(a)}return s}var oh=t=>{for(const e in t)if(jt(t[e]))return!0;return!1};function wo(t){return Array.isArray(t)||Ue(t)&&!oh(t)}function xo(t){return!!(t&&"_f"in t)}function _o(t){return Array.isArray(t)?!t.some(e=>!Pe(e)):!Object.keys(t).length}function Ca(t,e){Array.isArray(t)?t[e]=void 0:delete t[e]}function Ea(t,e={},r){for(const s in t){const n=t[s],a=r&&r[s];wo(n)&&(!Array.isArray(n)||!xo(a))?(e[s]=Array.isArray(n)?[]:{},Ea(n,e[s],a),_o(e[s])&&Ca(e,s)):Pe(n)||(e[s]=!0)}return e}function $r(t,e,r,s){r||(r=Ea(e,{},s));for(const n in t){const a=t[n],i=s&&s[n];wo(a)&&(!Array.isArray(a)||!xo(i))?(Pe(e)||xa(r[n])?r[n]=Ea(a,Array.isArray(a)?[]:{},i):$r(a,Ye(e)?{}:e[n],r[n],i),_o(r[n])&&Ca(r,n)):Ut(a,e[n])?Ca(r,n):r[n]=!0}return r}var lh=(t,e)=>{const r=e.split("."),s=[];let n=r[0];for(let a=1;a<r.length;n+="."+r[a++])!isNaN(+r[a])&&t.has(n)&&s.push(`${n}.${r[a]}`);return s},ko=(t,{valueAsNumber:e,valueAsDate:r,setValueAs:s})=>Pe(t)?t:e?t===""?NaN:t&&+t:r&&Xe(t)?new Date(t):s?s(t):t;function So(t){const e=t.ref;return bn(e)?e.files:ka(e)?co(t.refs).value:yo(e)?[...e.selectedOptions].map(({value:r})=>r):Ms(e)?oo(t.refs).value:ko(e.value,t)}var ch=(t,e,r,s)=>{const n={};for(const a of t){const i=V(e,a);i&&Ne(n,a,i._f)}return{criteriaMode:r,names:[...t],fields:n,shouldUseNativeValidation:s}},Us=t=>Pe(t)?t:kn(t)?t.source:Ue(t)?kn(t.value)?t.value.source:t.value:t;const Co="AsyncFunction";var uh=t=>{if(!t||!t.validate)return!1;if(jt(t.validate))return t.validate.constructor.name===Co;if(Ue(t.validate)){for(const e in t.validate)if(t.validate[e].constructor.name===Co)return!0}return!1},dh=t=>t.mount&&(t.required||!Pe(t.required)&&t.required!==!1||!Pe(t.min)||!Pe(t.max)||!Pe(t.maxLength)||!Pe(t.minLength)||t.pattern||t.validate);function Eo(t,e,r){const s=V(t,r);if(s||Lr(r))return{error:s,name:r};const n=r.split(".");for(;n.length;){const a=n.join("."),i=V(e,a),o=V(t,a);if(i&&!Array.isArray(i)&&r!==a)return{name:r};if(o&&o.type)return{name:a,error:o};if(o&&o.root&&o.root.type)return{name:`${a}.root`,error:o.root};n.pop()}return{name:r}}var hh=(t,e,r,s)=>{r(t);const n=Object.keys(t).filter(a=>a!=="name");return!n.length||s&&n.length>=Object.keys(e).length||n.find(a=>e[a]===(!s||Mt.all))},fh=(t,e,r)=>!t||!e||t===e||Sn(t).some(s=>s&&(r?s===e||s.startsWith(e+"."):s.startsWith(e)||e.startsWith(s))),ph=(t,e,r,s,n)=>n.isOnAll?!1:!r&&n.isOnTouch?!(e||t):(r?s.isOnBlur:n.isOnBlur)?!t:(r?s.isOnChange:n.isOnChange)?t:!0,mh=(t,e)=>{const r=V(t,e);!fo(r).length&&!r?.root&&Ve(t,e)};const gh={mode:Mt.onSubmit,reValidateMode:Mt.onChange,shouldFocusError:!0},Ta="form",yh=(t,e)=>{for(const r in t)r in e||delete t[r];Object.assign(t,e)},To={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function vh(t={}){let e={...gh,...t},r={...Fe(To),isLoading:jt(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1},s={},n=Ue(e.defaultValues)||Ue(e.values)?Fe(e.defaultValues||e.values)||{}:{},a=e.shouldUnregister?{}:Fe(n),i={action:!1,actionArrayLengths:new Map,mount:!1,watch:!1,keepIsValid:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const l={},c={};let u=0,p=xn(e.mode),f=xn(e.reValidateMode);const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},y={...h};let g={...y};const v={array:po(),state:po()};let C=0;const _=e.criteriaMode===Mt.all,S=(m,b)=>x=>{clearTimeout(c[m]),c[m]=setTimeout(b,x)},E=async m=>{if(!i.keepIsValid&&!e.disabled&&(y.isValid||g.isValid||m)){const b=++C;let x;e.resolver?(x=it((await oe()).errors),b===C&&T()):x=await de({fields:s,onlyCheckValid:!0,eventType:ts.VALID}),b===C&&x!==r.isValid&&v.state.next({isValid:x})}},T=(m,b)=>{!e.disabled&&(y.isValidating||y.validatingFields||g.isValidating||g.validatingFields)&&((m||o.mount).forEach(x=>{x&&(b?Ne(r.validatingFields,x,b):Ve(r.validatingFields,x))}),v.state.next({validatingFields:r.validatingFields,isValidating:!it(r.validatingFields)}))},N=()=>{r.dirtyFields=$r(n,a,void 0,s)},L=(m,b=[],x,A,P=!0,I=!0)=>{if(A&&x&&!e.disabled){i.action=!0;const M=V(s,m);if(i.actionArrayLengths.has(m)||i.actionArrayLengths.set(m,Array.isArray(M)?M.length:0),I&&Array.isArray(M)){const ee=x(M,A.argA,A.argB);P&&Ne(s,m,ee)}const R=V(r.errors,m);if(I&&Array.isArray(R)){const ee=R.root,_e=x(R,A.argA,A.argB)||R;ee&&(_e.root=ee),P&&Ne(r.errors,m,_e),mh(r.errors,m)}const J=V(r.touchedFields,m);if((y.touchedFields||g.touchedFields)&&I&&Array.isArray(J)){const ee=x(J,A.argA,A.argB);P&&Ne(r.touchedFields,m,ee)}(y.dirtyFields||g.dirtyFields)&&N(),v.state.next({name:m,isDirty:j(m,b),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Ne(a,m,b)},ue=(m,b)=>{Ne(r.errors,m,b),r.errors={...r.errors},v.state.next({errors:r.errors})},re=m=>{r.errors=m,v.state.next({errors:r.errors,isValid:!1})},je=m=>{const b=Lr(m)?[m]:es(m);let x=a,A=n;for(let P=0;P<b.length-1;P++){const I=b[P];if(x=Ye(x)?x:x[I],A=Ye(A)?A:A[I],x===null&&A!==null)return!0}return!1},Se=m=>{if(!i.actionArrayLengths.size)return!1;const b=Lr(m)?[m]:es(m);let x=a,A="",P=-1,I=0;for(let M=0;M<b.length;M++){if(Ye(x))return!1;const R=b[M];if(A=A?`${A}.${R}`:R,Array.isArray(x)&&+R>=x.length)return P===-1?!1:M===P?+R<I:!0;i.actionArrayLengths.has(A)&&(P=M+1,I=i.actionArrayLengths.get(A)),x=x[R]}return!1},F=(m,b,x,A)=>{const P=V(s,m);if(P){if(je(m)||Se(m))return;const I=Pe(V(a,m)),M=V(a,m,Pe(x)?V(n,m):x);Pe(M)||A&&A.defaultChecked||b?Ne(a,m,b?M:So(P._f)):se(m,M),i.mount&&!i.action&&(E(),I&&r.isDirty&&(y.isDirty||g.isDirty)&&(j()||(r.isDirty=!1,v.state.next({...r}))),t.shouldUnregister&&I&&!Pe(V(a,m))&&_a(m,o)&&(i.watch=!0))}},X=(m,b,x,A,P)=>{let I=!1,M=!1;const R={name:m};if(!e.disabled||A===!0){if(!x||A){const J=Ut(V(n,m),b);(y.isDirty||g.isDirty)&&(M=r.isDirty,r.isDirty=R.isDirty=!J||j(),I=M!==R.isDirty),M=!!V(r.dirtyFields,m),J!==r.isDirty?yh(r.dirtyFields,$r(n,a,void 0,s)):J?Ve(r.dirtyFields,m):Ne(r.dirtyFields,m,!0),R.dirtyFields=r.dirtyFields,I=I||(y.dirtyFields||g.dirtyFields)&&M!==!J}if(x){const J=V(r.touchedFields,m);J||(Ne(r.touchedFields,m,x),R.touchedFields=r.touchedFields,I=I||(y.touchedFields||g.touchedFields)&&J!==x)}I&&P&&v.state.next(R)}return I?R:{}},W=(m,b,x,A)=>{const P=V(r.errors,m),I=(y.isValid||g.isValid)&&Yt(b)&&r.isValid!==b;if(e.delayError&&x?(l[m]=S(m,()=>ue(m,x)),l[m](e.delayError)):(clearTimeout(c[m]),delete l[m],x?Ne(r.errors,m,x):Ve(r.errors,m),r.errors={...r.errors}),(x?!Ut(P,x):P)||!it(A)||I){const M={...A,...I&&Yt(b)?{isValid:b}:{},errors:r.errors,name:m};v.state.next(M)}},oe=async m=>(T(m,!0),await e.resolver(a,e.context,ch(m||o.mount,s,e.criteriaMode,e.shouldUseNativeValidation))),ye=async m=>{const{errors:b}=await oe(m);if(T(m),m){for(const x of m){const A=V(b,x);A?o.array.has(x)&&Ue(A)&&!Object.keys(A).some(P=>!Number.isNaN(Number(P)))?so(r.errors,{[x]:A},x):Ne(r.errors,x,A):Ve(r.errors,x)}r.errors={...r.errors}}else r.errors=b;return b},ne=async({name:m,eventType:b})=>{if(t.validate){const x=await t.validate({formValues:a,formState:r,name:m,eventType:b});if(Ue(x))for(const A in x){const P=x[A];P&&rt(`${Ta}.${A}`,{message:Xe(P.message)?P.message:"",type:P.type||Ft.validate})}else Xe(x)||!x?rt(Ta,{message:x||"",type:Ft.validate}):sr(Ta);return x}return!0},de=async({fields:m,onlyCheckValid:b,name:x,eventType:A,context:P={valid:!0,runRootValidation:!1}})=>{if(t.validate&&(P.runRootValidation=!0,!await ne({name:x,eventType:A})&&(P.valid=!1,b)))return P.valid;for(const I in m){const M=m[I];if(M){const{_f:R,...J}=M;if(R){const ee=o.array.has(R.name),_e=M._f&&uh(M._f),Ze=y.validatingFields||y.isValidating||g.validatingFields||g.isValidating;_e&&Ze&&T([R.name],!0);const te=await ho(M,o.disabled,a,_,e.shouldUseNativeValidation&&!b,ee);if(_e&&Ze&&T([R.name]),te[R.name]&&(P.valid=!1,b)||(!b&&(V(te,R.name)?ee?so(r.errors,te,R.name):Ne(r.errors,R.name,te[R.name]):Ve(r.errors,R.name)),t.shouldUseNativeValidation&&te[R.name]))break}!it(J)&&await de({context:P,onlyCheckValid:b,fields:J,name:I,eventType:A})}}return P.valid},G=()=>{for(const m of o.unMount){const b=V(s,m);b&&(b._f.refs?b._f.refs.every(x=>!Sa(x)):!Sa(b._f.ref))&&Et(m)}o.unMount=new Set},j=(m,b)=>(m&&b&&Ne(a,m,b),!Ut(i.mount?a:n,n)),z=(m,b,x)=>th(m,o,{...i.mount?a:Pe(b)||Xe(m)?n:b},x,b),Z=m=>fo(V(i.mount?a:n,m,e.shouldUnregister?V(n,m,[]):[])),se=(m,b,x={},A=!1,P=!1,I=!1)=>{const M=V(s,m);let R=b;if(M){const J=M._f;J&&(!J.disabled&&Ne(a,m,ko(b,J)),R=_n(J.ref)&&Ye(b)?"":b,yo(J.ref)?[...J.ref.options].forEach(ee=>ee.selected=R.includes(ee.value)):J.refs?Ms(J.ref)?J.refs.forEach(ee=>{(!ee.defaultChecked||!ee.disabled)&&(Array.isArray(R)?ee.checked=!!R.find(_e=>_e===ee.value):ee.checked=R===ee.value||!!R)}):J.refs.forEach(ee=>ee.checked=ee.value===R):bn(J.ref)?J.ref.value="":(J.ref.value=R,!J.ref.type&&!P&&!I&&v.state.next({name:m,values:A?a:Fe(a)})))}(x.shouldDirty||x.shouldTouch)&&X(m,R,x.shouldTouch,x.shouldDirty,!P),x.shouldValidate&&Le(m,{delayError:x.delayError})},he=(m,b,x,A=!1,P=!1,I=!1)=>{o.array.has(m)&&v.array.next({name:m,values:A?a:Fe(a)});for(const M in b){if(!b.hasOwnProperty(M))continue;const R=b[M],J=m+"."+M,ee=V(s,J);(o.array.has(m)||Ue(R)||ee&&!ee._f)&&!wr(R)?he(J,R,x,A,P,I):se(J,R,x,A,P,I)}},le=(m,b,x,A,P=!1)=>{const I=V(s,m),M=o.array.has(m),R=A?b:Fe(b),J=V(a,m),ee=Ut(J,R);if(ee||Ne(a,m,R),M)v.array.next({name:m,values:A?a:Fe(a)}),(y.isDirty||y.dirtyFields||g.isDirty||g.dirtyFields)&&x.shouldDirty&&(N(),P||v.state.next({name:m,dirtyFields:r.dirtyFields,isDirty:j(m,R)}));else{const _e=Array.isArray(R)&&!R.length||it(R),Ze=!ee&&!P;!I||I._f||Ye(R)||_e?se(m,R,x,A,P,Ze):he(m,R,x,A,P,Ze)}if(!ee&&!P){const _e=_a(m,o),Ze=A?a:Fe(a);if(v.state.next({..._e&&r,name:i.mount||_e?m:void 0,values:Ze}),!M)for(const te of lh(o.array,m))v.state.next({name:te,values:Ze})}},ae=(m,b,x={})=>le(m,b,x,!1),ce=(m,b={})=>{const x=jt(m)?m(a):m;if(!Ut(a,x)){a={...a,...x};for(const A of o.mount)ah(x,A)&&le(A,V(x,A),b,!0,!0);v.state.next({...r,name:void 0,type:void 0,...u?{values:a}:{}}),b.shouldValidate&&E()}},tt=async m=>{i.mount=!0;const b=m.target;let x=b.name,A=!0;const P=V(s,x),I=M=>{A=Number.isNaN(M)||wr(M)&&isNaN(M.getTime())||Ut(M,V(a,x,M))};if(P){let M,R;const J=b.type?So(P._f):Wd(m),ee=m.type===ts.BLUR||m.type===ts.FOCUS_OUT,_e=!dh(P._f)&&!t.validate&&!e.resolver&&!V(r.errors,x)&&!P._f.deps,Ze=_e||ph(ee,V(r.touchedFields,x),r.isSubmitted,f,p),te=_a(x,o,ee);if(Ne(a,x,Fe(J)),ee){if(!b||!b.readOnly){P._f.onBlur&&P._f.onBlur(m);const $e=l[x];$e&&$e(0)}}else P._f.onChange&&P._f.onChange(m);const we=X(x,J,ee),ve=!it(we)||te;if(!ee&&v.state.next({name:x,type:m.type,...u?{values:Fe(a)}:{}}),Ze)return(!_e||!r.isValid)&&(y.isValid||g.isValid)&&(e.mode==="onBlur"?ee&&E():ee||E()),ve&&v.state.next({name:x,...te?{}:we});if(!e.resolver&&t.validate&&await ne({name:x,eventType:m.type}),!ee&&te&&v.state.next({...r}),e.resolver){const{errors:$e}=await oe([x]);if(T([x]),I(J),!A){!it(we)&&v.state.next(we);return}const st=Eo(r.errors,s,x),At=Eo($e,s,st.name||x);M=At.error,x=At.name,R=it($e)}else T([x],!0),M=(await ho(P,o.disabled,a,_,e.shouldUseNativeValidation))[x],T([x]),I(J),A&&(M?R=!1:(y.isValid||g.isValid)&&(R=await de({fields:s,onlyCheckValid:!0,name:x,eventType:m.type})));A&&(P._f.deps&&(!Array.isArray(P._f.deps)||P._f.deps.length>0)&&Le(P._f.deps),W(x,R,M,we))}},Je=(m,b)=>{if(V(r.errors,b)&&m.focus)return m.focus(),1},Le=async(m,b={})=>{let x,A;const P=Sn(m);if(e.resolver){const I=await ye(Pe(m)?m:P);x=it(I),A=m?!P.some(M=>V(I,M)):x}else m?(A=(await Promise.all(P.map(async I=>{const M=V(s,I);return await de({fields:M&&M._f?{[I]:M}:M,eventType:ts.TRIGGER})}))).every(Boolean),!(!A&&!r.isValid)&&E()):A=x=await de({fields:s,name:m,eventType:ts.TRIGGER});if(b.delayError&&e.delayError&&Xe(m)){const I=V(r.errors,m);I?(Ve(r.errors,m),l[m]=S(m,()=>ue(m,I)),l[m](e.delayError)):(clearTimeout(c[m]),delete l[m])}if(b.shouldTouch)for(const I of m?P:o.mount)!o.array.has(I)&&Ne(r.touchedFields,I,!0);return v.state.next({...!Xe(m)||(y.isValid||g.isValid)&&x!==r.isValid?{}:{name:m},...e.resolver||!m?{isValid:x}:{},...b.shouldTouch&&(y.touchedFields||g.touchedFields)?{touchedFields:r.touchedFields}:{},errors:r.errors}),b.shouldFocus&&!A&&Fs(s,Je,m?P:o.mount),A},ut=(m,b)=>{let x={...i.mount?a:n};return b&&(x=mo(b.dirtyFields?r.dirtyFields:r.touchedFields,x)),Pe(m)?x:Xe(m)?V(x,m):m.map(A=>V(x,A))},qt=m=>Pe(m)?{...r.errors}:Xe(m)?V(r.errors,m):m.map(b=>V(r.errors,b)),lt=(m,b)=>{const x=b||r,A=V(x.errors,m);return{invalid:!!A,isDirty:!!V(x.dirtyFields,m),error:A,isValidating:!!V(r.validatingFields,m),isTouched:!!V(x.touchedFields,m)}},sr=m=>{const b=m?Sn(m):void 0;b?.forEach(x=>Ve(r.errors,x)),b?b.forEach(x=>{v.state.next({name:x,errors:r.errors})}):(r.errors={},v.state.next({errors:r.errors}))},rt=(m,b,x)=>{const A=(V(s,m,{_f:{}})._f||{}).ref,P=V(r.errors,m)||{},{ref:I,message:M,type:R,...J}=P;Ne(r.errors,m,{...J,...b,ref:A}),v.state.next({name:m,errors:r.errors,isValid:!1}),x&&x.shouldFocus&&A&&A.focus&&A.focus()},Dt=(m,b)=>{if(jt(m)){u++;const{unsubscribe:x}=v.state.subscribe({next:P=>"values"in P&&m(P.values||z(void 0,b),P)});let A=!1;return{unsubscribe:()=>{A||(A=!0,u--,x())}}}return z(m,b,!0)},ht=m=>{var b;const x=!!(!((b=m.formState)===null||b===void 0)&&b.values);x&&u++;const{unsubscribe:A}=v.state.subscribe({next:I=>{if(fh(m.name,I.name,m.exact)&&hh(I,m.formState||y,br,m.reRenderRoot)){const M={...a};m.callback({values:M,...r,...I,defaultValues:n})}}});if(!x)return A;let P=!1;return()=>{P||(P=!0,u--,A())}},Gt=m=>(i.mount=!0,g={...g,...m.formState},ht({...m,formState:{...h,...m.formState}})),Et=(m,b={})=>{for(const x of m?Sn(m):o.mount)o.mount.delete(x),o.array.delete(x),b.keepValue||(Ve(s,x),Ve(a,x)),!b.keepError&&Ve(r.errors,x),!b.keepDirty&&Ve(r.dirtyFields,x),!b.keepTouched&&Ve(r.touchedFields,x),!b.keepIsValidating&&Ve(r.validatingFields,x),!e.shouldUnregister&&!b.keepDefaultValue&&Ve(n,x);u&&v.state.next({values:Fe(a)}),v.state.next({...r,...b.keepDirty?{}:{isDirty:j()}}),!b.keepIsValid&&E()},Jt=({disabled:m,name:b})=>{if(Yt(m)&&i.mount||m||o.disabled.has(b)){const P=o.disabled.has(b)!==!!m;m?o.disabled.add(b):o.disabled.delete(b),P&&i.mount&&!i.action&&E()}},Tt=(m,b={})=>{let x=V(s,m);const A=Yt(b.disabled)||Yt(e.disabled),P=!o.registerName.has(m)&&x&&x._f&&!x._f.mount;return Ne(s,m,{...x||{},_f:{...x&&x._f?x._f:{ref:{name:m}},name:m,mount:!0,...b}}),o.mount.add(m),x&&!P?Jt({disabled:Yt(b.disabled)?b.disabled:e.disabled,name:m}):F(m,!0,b.value),{...A?{disabled:b.disabled||e.disabled}:{},...e.progressive?{required:!!b.required,min:Us(b.min),max:Us(b.max),minLength:Us(b.minLength),maxLength:Us(b.maxLength),pattern:Us(b.pattern)}:{},name:m,onChange:tt,onBlur:tt,ref:I=>{if(I){o.registerName.add(m),Tt(m,b),o.registerName.delete(m),x=V(s,m);const M=Pe(I.value)&&I.querySelectorAll&&I.querySelectorAll("input,select,textarea")[0]||I,R=ih(M),J=x._f.refs||[];if(R?J.find(_e=>_e===M):M===x._f.ref)return;const ee={...x._f};R?(ee.refs=[...J.filter(Sa),M,...Array.isArray(V(n,m))?[{}]:[]],ee.ref={type:M.type,name:m}):(ee.ref=M,delete ee.refs),Ne(s,m,{_f:ee}),F(m,!1,void 0,M)}else x=V(s,m,{}),x._f&&(x._f.mount=!1),(e.shouldUnregister||b.shouldUnregister)&&!(Gd(o.array,m)&&i.action)&&o.unMount.add(m)}}},Lt=()=>e.shouldFocusError&&!e.shouldUseNativeValidation&&Fs(s,Je,o.mount),ft=m=>{Yt(m)&&(v.state.next({disabled:m}),Fs(s,(b,x)=>{const A=V(s,x);A&&(b.disabled=A._f.disabled||m,Array.isArray(A._f.refs)&&A._f.refs.forEach(P=>{P.disabled=A._f.disabled||m}))},0,!1))},Pr=(m,b)=>async x=>{let A,P;x&&(x.preventDefault&&x.preventDefault(),x.persist&&x.persist());let I=Fe(a);if(v.state.next({isSubmitting:!0}),e.resolver){const{errors:M,values:R}=await oe();T(),r.errors=M,I=Fe(R)}else await de({fields:s,eventType:ts.SUBMIT});if(o.disabled.size)for(const M of o.disabled)Ve(I,M);if(Ve(r.errors,to),it(r.errors)){v.state.next({errors:{}});try{A=await m(I,x)}catch(M){P=M}}else b&&await b({...r.errors},x),Lt(),setTimeout(Lt);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:it(r.errors)&&!P,submitCount:r.submitCount+1,errors:r.errors}),P)throw P;return A},Nr=(m,b={})=>{V(s,m)&&(Pe(b.defaultValue)?ae(m,Fe(V(n,m))):(ae(m,b.defaultValue),Ne(n,m,Fe(b.defaultValue))),b.keepTouched||Ve(r.touchedFields,m),b.keepDirty||(Ve(r.dirtyFields,m),r.isDirty=b.defaultValue?j(m,Fe(V(n,m))):j()),b.keepError||(Ve(r.errors,m),E()),v.state.next({...r}))},qe=(m,b={})=>{const x=m?Fe(m):n,A=Fe(x),P=it(m),I=A,M=s;if(b.keepDefaultValues||(n=x),!b.keepValues){if(b.keepDirtyValues){const R=new Set([...o.mount,...bo($r(n,a,void 0,M),r.dirtyFields)]);for(const J of R){const ee=V(r.dirtyFields,J),_e=V(a,J),Ze=V(I,J);ee&&!Pe(_e)?Ne(I,J,_e):!ee&&!Pe(Ze)&&ae(J,Ze)}}else{if(wn&&Pe(m))for(const R of o.mount){const J=V(s,R);if(J&&J._f){const ee=Array.isArray(J._f.refs)?J._f.refs[0]:J._f.ref;if(_n(ee)){const _e=ee.closest("form");if(_e){_e.reset();break}}}}if(b.keepFieldsRef)for(const R of o.mount)ae(R,V(I,R));else s={}}if(e.shouldUnregister){if(a=b.keepDefaultValues?Fe(n):{},b.keepFieldsRef)for(const R of o.mount)Ne(a,R,V(I,R))}else a=Fe(I);v.array.next({values:{...I}}),v.state.next({name:void 0,type:void 0,values:{...I}})}o={mount:b.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!y.isValid||!!b.keepIsValid||!!b.keepDirtyValues||!e.shouldUnregister&&!it(I),i.watch=!!e.shouldUnregister,i.keepIsValid=!!b.keepIsValid,i.action=!1,i.actionArrayLengths.clear(),b.keepErrors||(r.errors={}),v.state.next({submitCount:b.keepSubmitCount?r.submitCount:0,isDirty:P?!1:b.keepDirty?r.isDirty:b.keepValues?j():!!(b.keepDefaultValues&&!Ut(m,n)),isSubmitted:b.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:P?{}:b.keepDirtyValues?b.keepDefaultValues&&a?$r(n,a,void 0,M):r.dirtyFields:b.keepDefaultValues&&m?$r(n,m,void 0,M):b.keepDirty?r.dirtyFields:{},touchedFields:b.keepTouched?r.touchedFields:{},errors:b.keepErrors?r.errors:{},isSubmitSuccessful:b.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:n})},vt=(m,b)=>qe(jt(m)?m(a):m,{...e.resetOptions,...b}),Rr=(m,b={})=>{const x=V(s,m),A=x&&x._f;if(A){const P=A.refs?A.refs[0]:A.ref;P.focus&&setTimeout(()=>{P.focus(),b.shouldSelect&&jt(P.select)&&P.select()})}},br=m=>{const{name:b,type:x,values:A,...P}=m;r={...r,...P}};v.state.subscribe({next:br});const U={control:{register:Tt,unregister:Et,getFieldState:lt,handleSubmit:Pr,setError:rt,_subscribe:ht,_runSchema:oe,_updateIsValidating:T,_focusError:Lt,_getWatch:z,_getDirty:j,_setValid:E,_setFieldArray:L,_setDisabledField:Jt,_setErrors:re,_getFieldArray:Z,_reset:qe,_resetDefaultValues:()=>jt(e.defaultValues)&&e.defaultValues().then(m=>{vt(m,e.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:G,_disableForm:ft,_subjects:v,_proxyFormState:y,get _fields(){return s},get _formValues(){return a},get _state(){return i},set _state(m){i=m},get _defaultValues(){return n},get _names(){return o},set _names(m){o=m},get _formState(){return r},get _options(){return e},set _options(m){e={...e,...m},p=xn(e.mode),f=xn(e.reValidateMode)}},subscribe:Gt,trigger:Le,register:Tt,handleSubmit:Pr,watch:Dt,setValue:ae,setValues:ce,getValues:ut,getErrors:qt,reset:vt,resetField:Nr,resetDefaultValues:(m,b={})=>{if(n=Fe(m),!b.keepDirty){const x=$r(n,a,void 0,s);r.dirtyFields=x,r.isDirty=!it(x)}b.keepIsValid||E(),v.state.next({...r,defaultValues:n})},clearErrors:sr,unregister:Et,setError:rt,setFocus:Rr,getFieldState:lt};return{...U,formControl:U}}function bh(t={}){const e=k.useRef(void 0),r=k.useRef(void 0),s=k.useRef(t.formControl),[n,a]=k.useState(()=>({...Fe(To),isLoading:jt(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1,defaultValues:jt(t.defaultValues)?void 0:t.defaultValues}));if(!e.current||t.formControl&&s.current!==t.formControl)if(s.current=t.formControl,t.formControl)e.current={...t.formControl,formState:n},t.defaultValues&&!jt(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:c,...u}=vh(t);e.current={...u,formState:n}}const i=e.current.control;i._options=t;const{resyncIfNeeded:o,snapshot:l}=eh();return Xd(()=>{const c=()=>({...i._formState,defaultValues:i._defaultValues});o(!0,c,a);const u=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState,defaultValues:i._defaultValues}),reRenderRoot:!0});return a(p=>({...p,isReady:!0})),i._formState.isReady=!0,()=>{u(),l(!0,c)}},[i,o,l]),k.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),k.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),k.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),k.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),k.useEffect(()=>{if(i._proxyFormState.isDirty){const c=i._getDirty();c!==n.isDirty&&i._subjects.state.next({isDirty:c})}},[i,n.isDirty]),k.useEffect(()=>{var c;t.values&&!Ut(t.values,r.current)?(i._reset(t.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((c=i._options.resetOptions)===null||c===void 0)&&c.keepIsValid||i._setValid(),r.current=t.values,a(u=>({...u}))):i._resetDefaultValues()},[i,t.values]),k.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),e.current.formState=k.useMemo(()=>Yd(n,i),[i,n]),e.current}const Ao=(t,e,r)=>{if(t&&"reportValidity"in t){const s=V(r,e);t.setCustomValidity(s&&s.message||""),t.reportValidity()}},jo=(t,e)=>{for(const r in e.fields){const s=e.fields[r];s&&s.ref&&"reportValidity"in s.ref?Ao(s.ref,r,t):s.refs&&s.refs.forEach(n=>Ao(n,r,t))}},wh=(t,e)=>{e.shouldUseNativeValidation&&jo(t,e);const r={};for(const s in t){const n=V(e.fields,s),a=Object.assign(t[s]||{},{ref:n&&n.ref});if(xh(e.names||Object.keys(t),s)){const i=Object.assign({},V(r,s));Ne(i,"root",a),Ne(r,s,i)}else Ne(r,s,a)}return r},xh=(t,e)=>t.some(r=>r.startsWith(e+"."));var _h=function(t,e){for(var r={};t.length;){var s=t[0],n=s.code,a=s.message,i=s.path.join(".");if(!r[i])if("unionErrors"in s){var o=s.unionErrors[0].errors[0];r[i]={message:o.message,type:o.code}}else r[i]={message:a,type:n};if("unionErrors"in s&&s.unionErrors.forEach(function(u){return u.errors.forEach(function(p){return t.push(p)})}),e){var l=r[i].types,c=l&&l[s.code];r[i]=no(i,e,r,n,c?[].concat(c,s.message):s.message)}t.shift()}return r},kh=function(t,e,r){return r===void 0&&(r={}),function(s,n,a){try{return Promise.resolve((function(i,o){try{var l=Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](s,e)).then(function(c){return a.shouldUseNativeValidation&&jo({},a),{errors:{},values:r.raw?s:c}})}catch(c){return o(c)}return l&&l.then?l.then(void 0,o):l})(0,function(i){if((function(o){return Array.isArray(o?.errors)})(i))return{values:{},errors:wh(_h(i.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}}},Te;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},t.getValidEnumValues=n=>{const a=t.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return t.objectValues(i)},t.objectValues=n=>t.objectKeys(n).map(function(a){return n[a]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},t.find=(n,a)=>{for(const i of n)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=s,t.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(Te||(Te={}));var Oo;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Oo||(Oo={}));const Y=Te.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),xr=t=>{switch(typeof t){case"undefined":return Y.undefined;case"string":return Y.string;case"number":return Number.isNaN(t)?Y.nan:Y.number;case"boolean":return Y.boolean;case"function":return Y.function;case"bigint":return Y.bigint;case"symbol":return Y.symbol;case"object":return Array.isArray(t)?Y.array:t===null?Y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Y.promise:typeof Map<"u"&&t instanceof Map?Y.map:typeof Set<"u"&&t instanceof Set?Y.set:typeof Date<"u"&&t instanceof Date?Y.date:Y.object;default:return Y.unknown}},$=Te.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class or extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(r(i));else{let o=s,l=0;for(;l<i.path.length;){const c=i.path[l];l===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(r(i))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return n(this),s}static assert(e){if(!(e instanceof or))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Te.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},s=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];r[a]=r[a]||[],r[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:r}}get formErrors(){return this.flatten()}}or.create=t=>new or(t);const Aa=(t,e)=>{let r;switch(t.code){case $.invalid_type:t.received===Y.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case $.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Te.jsonStringifyReplacer)}`;break;case $.unrecognized_keys:r=`Unrecognized key(s) in object: ${Te.joinValues(t.keys,", ")}`;break;case $.invalid_union:r="Invalid input";break;case $.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Te.joinValues(t.options)}`;break;case $.invalid_enum_value:r=`Invalid enum value. Expected ${Te.joinValues(t.options)}, received '${t.received}'`;break;case $.invalid_arguments:r="Invalid function arguments";break;case $.invalid_return_type:r="Invalid function return type";break;case $.invalid_date:r="Invalid date";break;case $.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Te.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case $.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case $.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case $.custom:r="Invalid input";break;case $.invalid_intersection_types:r="Intersection results could not be merged";break;case $.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case $.not_finite:r="Number must be finite";break;default:r=e.defaultError,Te.assertNever(t)}return{message:r}};let Sh=Aa;function Ch(){return Sh}const Eh=t=>{const{data:e,path:r,errorMaps:s,issueData:n}=t,a=[...r,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="";const l=s.filter(c=>!!c).slice().reverse();for(const c of l)o=c(i,{data:e,defaultError:o}).message;return{...n,path:a,message:o}};function K(t,e){const r=Ch(),s=Eh({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Aa?void 0:Aa].filter(n=>!!n)});t.common.issues.push(s)}class _t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const s=[];for(const n of r){if(n.status==="aborted")return me;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,r){const s=[];for(const n of r){const a=await n.key,i=await n.value;s.push({key:a,value:i})}return _t.mergeObjectSync(e,s)}static mergeObjectSync(e,r){const s={};for(const n of r){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return me;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const me=Object.freeze({status:"aborted"}),Bs=t=>({status:"dirty",value:t}),Ot=t=>({status:"valid",value:t}),Po=t=>t.status==="aborted",No=t=>t.status==="dirty",ss=t=>t.status==="valid",Cn=t=>typeof Promise<"u"&&t instanceof Promise;var Q;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Q||(Q={}));class _r{constructor(e,r,s,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ro=(t,e)=>{if(ss(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new or(t.common.issues);return this._error=r,this._error}}};function xe(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:s,description:n}=t;if(e&&(r||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{const{message:l}=t;return i.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:n}}class Ee{get description(){return this._def.description}_getType(e){return xr(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:xr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new _t,ctx:{common:e.parent.common,data:e.data,parsedType:xr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Cn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const s=this.safeParse(e,r);if(s.success)return s.data;throw s.error}safeParse(e,r){const s={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xr(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Ro(s,n)}"~validate"(e){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xr(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:r});return ss(s)?{value:s.value}:{issues:r.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(s=>ss(s)?{value:s.value}:{issues:r.common.issues})}async parseAsync(e,r){const s=await this.safeParseAsync(e,r);if(s.success)return s.data;throw s.error}async safeParseAsync(e,r){const s={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xr(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(Cn(n)?n:Promise.resolve(n));return Ro(s,a)}refine(e,r){const s=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:$.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof r=="function"?r(s,n):r),!1))}_refinement(e){return new os({schema:this,typeName:ge.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Cr.create(this,this._def)}nullable(){return ls.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xt.create(this)}promise(){return jn.create(this,this._def)}or(e){return Tn.create([this,e],this._def)}and(e){return An.create(this,e,this._def)}transform(e){return new os({...xe(this._def),schema:this,typeName:ge.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Na({...xe(this._def),innerType:this,defaultValue:r,typeName:ge.ZodDefault})}brand(){return new Jh({typeName:ge.ZodBranded,type:this,...xe(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Ra({...xe(this._def),innerType:this,catchValue:r,typeName:ge.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ia.create(this,e)}readonly(){return Da.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Th=/^c[^\s-]{8,}$/i,Ah=/^[0-9a-z]+$/,jh=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Oh=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ph=/^[a-z0-9_-]{21}$/i,Nh=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rh=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ih=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Dh="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ja;const Lh=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$h=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Mh=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Fh=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Uh=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Bh=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Io="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Vh=new RegExp(`^${Io}$`);function Do(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Kh(t){return new RegExp(`^${Do(t)}$`)}function zh(t){let e=`${Io}T${Do(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Hh(t,e){return!!((e==="v4"||!e)&&Lh.test(t)||(e==="v6"||!e)&&Mh.test(t))}function Wh(t,e){if(!Nh.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const s=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function qh(t,e){return!!((e==="v4"||!e)&&$h.test(t)||(e==="v6"||!e)&&Fh.test(t))}class kr extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Y.string){const a=this._getOrReturnCtx(e);return K(a,{code:$.invalid_type,expected:Y.string,received:a.parsedType}),me}const s=new _t;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:$.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:$.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?K(n,{code:$.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&K(n,{code:$.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Ih.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"email",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")ja||(ja=new RegExp(Dh,"u")),ja.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"emoji",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Oh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"uuid",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Ph.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"nanoid",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Th.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cuid",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Ah.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cuid2",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")jh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"ulid",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),K(n,{validation:"url",code:$.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"regex",code:$.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?zh(a).test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Vh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Kh(a).test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Rh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"duration",code:$.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Hh(e.data,a.version)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"ip",code:$.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Wh(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"jwt",code:$.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?qh(e.data,a.version)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cidr",code:$.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Uh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"base64",code:$.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Bh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"base64url",code:$.invalid_string,message:a.message}),s.dirty()):Te.assertNever(a);return{status:s.value,value:e.data}}_regex(e,r,s){return this.refinement(n=>e.test(n),{validation:r,code:$.invalid_string,...Q.errToObj(s)})}_addCheck(e){return new kr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Q.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Q.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Q.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Q.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Q.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Q.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Q.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Q.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Q.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Q.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Q.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Q.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Q.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Q.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Q.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Q.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Q.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Q.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Q.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Q.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Q.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Q.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Q.errToObj(r)})}nonempty(e){return this.min(1,Q.errToObj(e))}trim(){return new kr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new kr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new kr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}kr.create=t=>new kr({checks:[],typeName:ge.ZodString,coerce:t?.coerce??!1,...xe(t)});function Gh(t,e){const r=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=r>s?r:s,a=Number.parseInt(t.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/10**n}class ns extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Y.number){const a=this._getOrReturnCtx(e);return K(a,{code:$.invalid_type,expected:Y.number,received:a.parsedType}),me}let s;const n=new _t;for(const a of this._def.checks)a.kind==="int"?Te.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{code:$.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Gh(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{code:$.not_finite,message:a.message}),n.dirty()):Te.assertNever(a);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,s,n){return new ns({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:s,message:Q.toString(n)}]})}_addCheck(e){return new ns({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Q.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Q.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Q.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Q.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Te.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(r===null||s.value>r)&&(r=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(r)&&Number.isFinite(e)}}ns.create=t=>new ns({checks:[],typeName:ge.ZodNumber,coerce:t?.coerce||!1,...xe(t)});class Vs extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Y.bigint)return this._getInvalidInput(e);let s;const n=new _t;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):Te.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return K(r,{code:$.invalid_type,expected:Y.bigint,received:r.parsedType}),me}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,s,n){return new Vs({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:s,message:Q.toString(n)}]})}_addCheck(e){return new Vs({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Vs.create=t=>new Vs({checks:[],typeName:ge.ZodBigInt,coerce:t?.coerce??!1,...xe(t)});class Oa extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Y.boolean){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.boolean,received:s.parsedType}),me}return Ot(e.data)}}Oa.create=t=>new Oa({typeName:ge.ZodBoolean,coerce:t?.coerce||!1,...xe(t)});class En extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Y.date){const a=this._getOrReturnCtx(e);return K(a,{code:$.invalid_type,expected:Y.date,received:a.parsedType}),me}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return K(a,{code:$.invalid_date}),me}const s=new _t;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:$.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:$.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):Te.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new En({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Q.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Q.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}En.create=t=>new En({checks:[],coerce:t?.coerce||!1,typeName:ge.ZodDate,...xe(t)});class Lo extends Ee{_parse(e){if(this._getType(e)!==Y.symbol){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.symbol,received:s.parsedType}),me}return Ot(e.data)}}Lo.create=t=>new Lo({typeName:ge.ZodSymbol,...xe(t)});class $o extends Ee{_parse(e){if(this._getType(e)!==Y.undefined){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.undefined,received:s.parsedType}),me}return Ot(e.data)}}$o.create=t=>new $o({typeName:ge.ZodUndefined,...xe(t)});class Mo extends Ee{_parse(e){if(this._getType(e)!==Y.null){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.null,received:s.parsedType}),me}return Ot(e.data)}}Mo.create=t=>new Mo({typeName:ge.ZodNull,...xe(t)});class Fo extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return Ot(e.data)}}Fo.create=t=>new Fo({typeName:ge.ZodAny,...xe(t)});class Uo extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ot(e.data)}}Uo.create=t=>new Uo({typeName:ge.ZodUnknown,...xe(t)});class Sr extends Ee{_parse(e){const r=this._getOrReturnCtx(e);return K(r,{code:$.invalid_type,expected:Y.never,received:r.parsedType}),me}}Sr.create=t=>new Sr({typeName:ge.ZodNever,...xe(t)});class Bo extends Ee{_parse(e){if(this._getType(e)!==Y.undefined){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.void,received:s.parsedType}),me}return Ot(e.data)}}Bo.create=t=>new Bo({typeName:ge.ZodVoid,...xe(t)});class Xt extends Ee{_parse(e){const{ctx:r,status:s}=this._processInputParams(e),n=this._def;if(r.parsedType!==Y.array)return K(r,{code:$.invalid_type,expected:Y.array,received:r.parsedType}),me;if(n.exactLength!==null){const i=r.data.length>n.exactLength.value,o=r.data.length<n.exactLength.value;(i||o)&&(K(r,{code:i?$.too_big:$.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(K(r,{code:$.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(K(r,{code:$.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>n.type._parseAsync(new _r(r,i,r.path,o)))).then(i=>_t.mergeArray(s,i));const a=[...r.data].map((i,o)=>n.type._parseSync(new _r(r,i,r.path,o)));return _t.mergeArray(s,a)}get element(){return this._def.type}min(e,r){return new Xt({...this._def,minLength:{value:e,message:Q.toString(r)}})}max(e,r){return new Xt({...this._def,maxLength:{value:e,message:Q.toString(r)}})}length(e,r){return new Xt({...this._def,exactLength:{value:e,message:Q.toString(r)}})}nonempty(e){return this.min(1,e)}}Xt.create=(t,e)=>new Xt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ge.ZodArray,...xe(e)});function as(t){if(t instanceof ze){const e={};for(const r in t.shape){const s=t.shape[r];e[r]=Cr.create(as(s))}return new ze({...t._def,shape:()=>e})}else return t instanceof Xt?new Xt({...t._def,type:as(t.element)}):t instanceof Cr?Cr.create(as(t.unwrap())):t instanceof ls?ls.create(as(t.unwrap())):t instanceof Mr?Mr.create(t.items.map(e=>as(e))):t}class ze extends Ee{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=Te.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==Y.object){const c=this._getOrReturnCtx(e);return K(c,{code:$.invalid_type,expected:Y.object,received:c.parsedType}),me}const{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Sr&&this._def.unknownKeys==="strip"))for(const c in n.data)i.includes(c)||o.push(c);const l=[];for(const c of i){const u=a[c],p=n.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new _r(n,p,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Sr){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of o)l.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict")o.length>0&&(K(n,{code:$.unrecognized_keys,keys:o}),s.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of o){const p=n.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new _r(n,p,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const p=await u.key,f=await u.value;c.push({key:p,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>_t.mergeObjectSync(s,c)):_t.mergeObjectSync(s,l)}get shape(){return this._def.shape()}strict(e){return Q.errToObj,new ze({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,s)=>{const n=this._def.errorMap?.(r,s).message??s.defaultError;return r.code==="unrecognized_keys"?{message:Q.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new ze({...this._def,unknownKeys:"strip"})}passthrough(){return new ze({...this._def,unknownKeys:"passthrough"})}extend(e){return new ze({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ze({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ge.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new ze({...this._def,catchall:e})}pick(e){const r={};for(const s of Te.objectKeys(e))e[s]&&this.shape[s]&&(r[s]=this.shape[s]);return new ze({...this._def,shape:()=>r})}omit(e){const r={};for(const s of Te.objectKeys(this.shape))e[s]||(r[s]=this.shape[s]);return new ze({...this._def,shape:()=>r})}deepPartial(){return as(this)}partial(e){const r={};for(const s of Te.objectKeys(this.shape)){const n=this.shape[s];e&&!e[s]?r[s]=n:r[s]=n.optional()}return new ze({...this._def,shape:()=>r})}required(e){const r={};for(const s of Te.objectKeys(this.shape))if(e&&!e[s])r[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof Cr;)a=a._def.innerType;r[s]=a}return new ze({...this._def,shape:()=>r})}keyof(){return Ho(Te.objectKeys(this.shape))}}ze.create=(t,e)=>new ze({shape:()=>t,unknownKeys:"strip",catchall:Sr.create(),typeName:ge.ZodObject,...xe(e)}),ze.strictCreate=(t,e)=>new ze({shape:()=>t,unknownKeys:"strict",catchall:Sr.create(),typeName:ge.ZodObject,...xe(e)}),ze.lazycreate=(t,e)=>new ze({shape:t,unknownKeys:"strip",catchall:Sr.create(),typeName:ge.ZodObject,...xe(e)});class Tn extends Ee{_parse(e){const{ctx:r}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new or(o.ctx.common.issues));return K(r,{code:$.invalid_union,unionErrors:i}),me}if(r.common.async)return Promise.all(s.map(async a=>{const i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const l of s){const c={...r,common:{...r.common,issues:[]},parent:null},u=l._parseSync({data:r.data,path:r.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(l=>new or(l));return K(r,{code:$.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}Tn.create=(t,e)=>new Tn({options:t,typeName:ge.ZodUnion,...xe(e)});function Pa(t,e){const r=xr(t),s=xr(e);if(t===e)return{valid:!0,data:t};if(r===Y.object&&s===Y.object){const n=Te.objectKeys(e),a=Te.objectKeys(t).filter(o=>n.indexOf(o)!==-1),i={...t,...e};for(const o of a){const l=Pa(t[o],e[o]);if(!l.valid)return{valid:!1};i[o]=l.data}return{valid:!0,data:i}}else if(r===Y.array&&s===Y.array){if(t.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<t.length;a++){const i=t[a],o=e[a],l=Pa(i,o);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return r===Y.date&&s===Y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class An extends Ee{_parse(e){const{status:r,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Po(a)||Po(i))return me;const o=Pa(a.value,i.value);return o.valid?((No(a)||No(i))&&r.dirty(),{status:r.value,value:o.data}):(K(s,{code:$.invalid_intersection_types}),me)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}An.create=(t,e,r)=>new An({left:t,right:e,typeName:ge.ZodIntersection,...xe(r)});class Mr extends Ee{_parse(e){const{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==Y.array)return K(s,{code:$.invalid_type,expected:Y.array,received:s.parsedType}),me;if(s.data.length<this._def.items.length)return K(s,{code:$.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&s.data.length>this._def.items.length&&(K(s,{code:$.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...s.data].map((i,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new _r(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>_t.mergeArray(r,i)):_t.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Mr({...this._def,rest:e})}}Mr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Mr({items:t,typeName:ge.ZodTuple,rest:null,...xe(e)})};class Vo extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==Y.map)return K(s,{code:$.invalid_type,expected:Y.map,received:s.parsedType}),me;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,l],c)=>({key:n._parse(new _r(s,o,s.path,[c,"key"])),value:a._parse(new _r(s,l,s.path,[c,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of i){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return me;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(c.value,u.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const l of i){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return me;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(c.value,u.value)}return{status:r.value,value:o}}}}Vo.create=(t,e,r)=>new Vo({valueType:e,keyType:t,typeName:ge.ZodMap,...xe(r)});class Ks extends Ee{_parse(e){const{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==Y.set)return K(s,{code:$.invalid_type,expected:Y.set,received:s.parsedType}),me;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(K(s,{code:$.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(K(s,{code:$.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());const a=this._def.valueType;function i(l){const c=new Set;for(const u of l){if(u.status==="aborted")return me;u.status==="dirty"&&r.dirty(),c.add(u.value)}return{status:r.value,value:c}}const o=[...s.data.values()].map((l,c)=>a._parse(new _r(s,l,s.path,c)));return s.common.async?Promise.all(o).then(l=>i(l)):i(o)}min(e,r){return new Ks({...this._def,minSize:{value:e,message:Q.toString(r)}})}max(e,r){return new Ks({...this._def,maxSize:{value:e,message:Q.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Ks.create=(t,e)=>new Ks({valueType:t,minSize:null,maxSize:null,typeName:ge.ZodSet,...xe(e)});class Ko extends Ee{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Ko.create=(t,e)=>new Ko({getter:t,typeName:ge.ZodLazy,...xe(e)});class zo extends Ee{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return K(r,{received:r.data,code:$.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}zo.create=(t,e)=>new zo({value:t,typeName:ge.ZodLiteral,...xe(e)});function Ho(t,e){return new is({values:t,typeName:ge.ZodEnum,...xe(e)})}class is extends Ee{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),s=this._def.values;return K(r,{expected:Te.joinValues(s),received:r.parsedType,code:$.invalid_type}),me}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),s=this._def.values;return K(r,{received:r.data,code:$.invalid_enum_value,options:s}),me}return Ot(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return is.create(e,{...this._def,...r})}exclude(e,r=this._def){return is.create(this.options.filter(s=>!e.includes(s)),{...this._def,...r})}}is.create=Ho;class Wo extends Ee{_parse(e){const r=Te.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==Y.string&&s.parsedType!==Y.number){const n=Te.objectValues(r);return K(s,{expected:Te.joinValues(n),received:s.parsedType,code:$.invalid_type}),me}if(this._cache||(this._cache=new Set(Te.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=Te.objectValues(r);return K(s,{received:s.data,code:$.invalid_enum_value,options:n}),me}return Ot(e.data)}get enum(){return this._def.values}}Wo.create=(t,e)=>new Wo({values:t,typeName:ge.ZodNativeEnum,...xe(e)});class jn extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==Y.promise&&r.common.async===!1)return K(r,{code:$.invalid_type,expected:Y.promise,received:r.parsedType}),me;const s=r.parsedType===Y.promise?r.data:Promise.resolve(r.data);return Ot(s.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}}jn.create=(t,e)=>new jn({type:t,typeName:ge.ZodPromise,...xe(e)});class os extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ge.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{K(s,i),i.fatal?r.abort():r.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(r.value==="aborted")return me;const l=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return l.status==="aborted"?me:l.status==="dirty"||r.value==="dirty"?Bs(l.value):l});{if(r.value==="aborted")return me;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?me:o.status==="dirty"||r.value==="dirty"?Bs(o.value):o}}if(n.type==="refinement"){const i=o=>{const l=n.refinement(o,a);if(s.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?me:(o.status==="dirty"&&r.dirty(),i(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?me:(o.status==="dirty"&&r.dirty(),i(o.value).then(()=>({status:r.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ss(i))return me;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>ss(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:r.value,value:o})):me);Te.assertNever(n)}}os.create=(t,e,r)=>new os({schema:t,typeName:ge.ZodEffects,effect:e,...xe(r)}),os.createWithPreprocess=(t,e,r)=>new os({schema:e,effect:{type:"preprocess",transform:t},typeName:ge.ZodEffects,...xe(r)});class Cr extends Ee{_parse(e){return this._getType(e)===Y.undefined?Ot(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Cr.create=(t,e)=>new Cr({innerType:t,typeName:ge.ZodOptional,...xe(e)});class ls extends Ee{_parse(e){return this._getType(e)===Y.null?Ot(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ls.create=(t,e)=>new ls({innerType:t,typeName:ge.ZodNullable,...xe(e)});class Na extends Ee{_parse(e){const{ctx:r}=this._processInputParams(e);let s=r.data;return r.parsedType===Y.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Na.create=(t,e)=>new Na({innerType:t,typeName:ge.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...xe(e)});class Ra extends Ee{_parse(e){const{ctx:r}=this._processInputParams(e),s={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Cn(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new or(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new or(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ra.create=(t,e)=>new Ra({innerType:t,typeName:ge.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...xe(e)});class qo extends Ee{_parse(e){if(this._getType(e)!==Y.nan){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.nan,received:s.parsedType}),me}return{status:"valid",value:e.data}}}qo.create=t=>new qo({typeName:ge.ZodNaN,...xe(t)});class Jh extends Ee{_parse(e){const{ctx:r}=this._processInputParams(e),s=r.data;return this._def.type._parse({data:s,path:r.path,parent:r})}unwrap(){return this._def.type}}class Ia extends Ee{_parse(e){const{status:r,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?me:a.status==="dirty"?(r.dirty(),Bs(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?me:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,r){return new Ia({in:e,out:r,typeName:ge.ZodPipeline})}}class Da extends Ee{_parse(e){const r=this._def.innerType._parse(e),s=n=>(ss(n)&&(n.value=Object.freeze(n.value)),n);return Cn(r)?r.then(n=>s(n)):s(r)}unwrap(){return this._def.innerType}}Da.create=(t,e)=>new Da({innerType:t,typeName:ge.ZodReadonly,...xe(e)});var ge;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ge||(ge={}));const Fr=kr.create,Go=ns.create,Zh=Oa.create;Sr.create,Xt.create;const Yh=ze.create;Tn.create,An.create,Mr.create;const Jo=is.create;jn.create,Cr.create,ls.create;var Xh=Object.defineProperty,La=(t,e)=>Xh(t,"name",{value:e,configurable:!0});function $a(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}La($a,"setRef");function Zo(...t){return e=>{let r=!1;const s=t.map(n=>{const a=$a(n,e);return!r&&typeof a=="function"&&(r=!0),a});if(r)return()=>{for(let n=0;n<s.length;n++){const a=s[n];typeof a=="function"?a():$a(t[n],null)}}}}La(Zo,"composeRefs");function lr(...t){return O.useCallback(Zo(...t),t)}La(lr,"useComposedRefs");var Qh=Object.defineProperty,Bt=(t,e)=>Qh(t,"name",{value:e,configurable:!0});function Ur(t){const e=O.forwardRef((r,s)=>{let{children:n,...a}=r,i=null,o=!1;const l=[];Ma(n)&&typeof On=="function"&&(n=On(n._payload)),O.Children.forEach(n,f=>{if(el(f)){o=!0;const h=f;let y="child"in h.props?h.props.child:h.props.children;Ma(y)&&typeof On=="function"&&(y=On(y._payload)),i=rf(h,y),l.push(i?.props?.children)}else l.push(f)}),i?i=O.cloneElement(i,void 0,l):!o&&O.Children.count(n)===1&&O.isValidElement(n)&&(i=n);const c=i?Qo(i):void 0,u=lr(s,c);if(!i){if(n||n===0)throw new Error(o?af(t):nf(t));return n}const p=Xo(a,i.props??{});return i.type!==O.Fragment&&(p.ref=s?u:c),O.cloneElement(i,p)});return e.displayName=`${t}.Slot`,e}Bt(Ur,"createSlot");var ef=Ur("Slot"),Yo=Symbol.for("radix.slottable");function tf(t){const e=Bt(r=>"child"in r?r.children(r.child):r.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=Yo,e}Bt(tf,"createSlottable");var rf=Bt((t,e)=>{if("child"in t.props){const r=t.props.child;return O.isValidElement(r)?O.cloneElement(r,void 0,t.props.children(r.props.children)):null}return O.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function Xo(t,e){const r={...e};for(const s in e){const n=t[s],a=e[s];/^on[A-Z]/.test(s)?n&&a?r[s]=(...o)=>{const l=a(...o);return n(...o),l}:n&&(r[s]=n):s==="style"?r[s]={...n,...a}:s==="className"&&(r[s]=[n,a].filter(Boolean).join(" "))}return{...t,...r}}Bt(Xo,"mergeProps");function Qo(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}Bt(Qo,"getElementRef");function el(t){return O.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Yo}Bt(el,"isSlottable");var sf=Symbol.for("react.lazy");function Ma(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===sf&&"_payload"in t&&tl(t._payload)}Bt(Ma,"isLazyComponent");function tl(t){return typeof t=="object"&&t!==null&&"then"in t}Bt(tl,"isPromiseLike");var nf=Bt(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),af=Bt(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),On=O[" use ".trim().toString()];function rl(t){var e,r,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(e=0;e<n;e++)t[e]&&(r=rl(t[e]))&&(s&&(s+=" "),s+=r)}else for(r in t)t[r]&&(s&&(s+=" "),s+=r);return s}function sl(){for(var t,e,r=0,s="",n=arguments.length;r<n;r++)(t=arguments[r])&&(e=rl(t))&&(s&&(s+=" "),s+=e);return s}const nl=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,al=sl,il=(t,e)=>r=>{var s;if(e?.variants==null)return al(t,r?.class,r?.className);const{variants:n,defaultVariants:a}=e,i=Object.keys(n).map(c=>{const u=r?.[c],p=a?.[c];if(u===null)return null;const f=nl(u)||nl(p);return n[c][f]}),o=r&&Object.entries(r).reduce((c,u)=>{let[p,f]=u;return f===void 0||(c[p]=f),c},{}),l=e==null||(s=e.compoundVariants)===null||s===void 0?void 0:s.reduce((c,u)=>{let{class:p,className:f,...h}=u;return Object.entries(h).every(y=>{let[g,v]=y;return Array.isArray(v)?v.includes({...a,...o}[g]):{...a,...o}[g]===v})?[...c,p,f]:c},[]);return al(t,i,l,r?.class,r?.className)},Fa="-",of=t=>{const e=cf(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:s}=t;return{getClassGroupId:i=>{const o=i.split(Fa);return o[0]===""&&o.length!==1&&o.shift(),ol(o,e)||lf(i)},getConflictingClassGroupIds:(i,o)=>{const l=r[i]||[];return o&&s[i]?[...l,...s[i]]:l}}},ol=(t,e)=>{if(t.length===0)return e.classGroupId;const r=t[0],s=e.nextPart.get(r),n=s?ol(t.slice(1),s):void 0;if(n)return n;if(e.validators.length===0)return;const a=t.join(Fa);return e.validators.find(({validator:i})=>i(a))?.classGroupId},ll=/^\[(.+)\]$/,lf=t=>{if(ll.test(t)){const e=ll.exec(t)[1],r=e?.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},cf=t=>{const{theme:e,prefix:r}=t,s={nextPart:new Map,validators:[]};return df(Object.entries(t.classGroups),r).forEach(([a,i])=>{Ua(i,s,a,e)}),s},Ua=(t,e,r,s)=>{t.forEach(n=>{if(typeof n=="string"){const a=n===""?e:cl(e,n);a.classGroupId=r;return}if(typeof n=="function"){if(uf(n)){Ua(n(s),e,r,s);return}e.validators.push({validator:n,classGroupId:r});return}Object.entries(n).forEach(([a,i])=>{Ua(i,cl(e,a),r,s)})})},cl=(t,e)=>{let r=t;return e.split(Fa).forEach(s=>{r.nextPart.has(s)||r.nextPart.set(s,{nextPart:new Map,validators:[]}),r=r.nextPart.get(s)}),r},uf=t=>t.isThemeGetter,df=(t,e)=>e?t.map(([r,s])=>{const n=s.map(a=>typeof a=="string"?e+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([i,o])=>[e+i,o])):a);return[r,n]}):t,hf=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,s=new Map;const n=(a,i)=>{r.set(a,i),e++,e>t&&(e=0,s=r,r=new Map)};return{get(a){let i=r.get(a);if(i!==void 0)return i;if((i=s.get(a))!==void 0)return n(a,i),i},set(a,i){r.has(a)?r.set(a,i):n(a,i)}}},ul="!",ff=t=>{const{separator:e,experimentalParseClassName:r}=t,s=e.length===1,n=e[0],a=e.length,i=o=>{const l=[];let c=0,u=0,p;for(let v=0;v<o.length;v++){let C=o[v];if(c===0){if(C===n&&(s||o.slice(v,v+a)===e)){l.push(o.slice(u,v)),u=v+a;continue}if(C==="/"){p=v;continue}}C==="["?c++:C==="]"&&c--}const f=l.length===0?o:o.substring(u),h=f.startsWith(ul),y=h?f.substring(1):f,g=p&&p>u?p-u:void 0;return{modifiers:l,hasImportantModifier:h,baseClassName:y,maybePostfixModifierPosition:g}};return r?o=>r({className:o,parseClassName:i}):i},pf=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(s=>{s[0]==="["?(e.push(...r.sort(),s),r=[]):r.push(s)}),e.push(...r.sort()),e},mf=t=>({cache:hf(t.cacheSize),parseClassName:ff(t),...of(t)}),gf=/\s+/,yf=(t,e)=>{const{parseClassName:r,getClassGroupId:s,getConflictingClassGroupIds:n}=e,a=[],i=t.trim().split(gf);let o="";for(let l=i.length-1;l>=0;l-=1){const c=i[l],{modifiers:u,hasImportantModifier:p,baseClassName:f,maybePostfixModifierPosition:h}=r(c);let y=!!h,g=s(y?f.substring(0,h):f);if(!g){if(!y){o=c+(o.length>0?" "+o:o);continue}if(g=s(f),!g){o=c+(o.length>0?" "+o:o);continue}y=!1}const v=pf(u).join(":"),C=p?v+ul:v,_=C+g;if(a.includes(_))continue;a.push(_);const S=n(g,y);for(let E=0;E<S.length;++E){const T=S[E];a.push(C+T)}o=c+(o.length>0?" "+o:o)}return o};function vf(){let t=0,e,r,s="";for(;t<arguments.length;)(e=arguments[t++])&&(r=dl(e))&&(s&&(s+=" "),s+=r);return s}const dl=t=>{if(typeof t=="string")return t;let e,r="";for(let s=0;s<t.length;s++)t[s]&&(e=dl(t[s]))&&(r&&(r+=" "),r+=e);return r};function bf(t,...e){let r,s,n,a=i;function i(l){const c=e.reduce((u,p)=>p(u),t());return r=mf(c),s=r.cache.get,n=r.cache.set,a=o,o(l)}function o(l){const c=s(l);if(c)return c;const u=yf(l,r);return n(l,u),u}return function(){return a(vf.apply(null,arguments))}}const Me=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},hl=/^\[(?:([a-z-]+):)?(.+)\]$/i,wf=/^\d+\/\d+$/,xf=new Set(["px","full","screen"]),_f=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,kf=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Sf=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Cf=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ef=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,cr=t=>cs(t)||xf.has(t)||wf.test(t),Er=t=>us(t,"length",If),cs=t=>!!t&&!Number.isNaN(Number(t)),Ba=t=>us(t,"number",cs),zs=t=>!!t&&Number.isInteger(Number(t)),Tf=t=>t.endsWith("%")&&cs(t.slice(0,-1)),be=t=>hl.test(t),Tr=t=>_f.test(t),Af=new Set(["length","size","percentage"]),jf=t=>us(t,Af,fl),Of=t=>us(t,"position",fl),Pf=new Set(["image","url"]),Nf=t=>us(t,Pf,Lf),Rf=t=>us(t,"",Df),Hs=()=>!0,us=(t,e,r)=>{const s=hl.exec(t);return s?s[1]?typeof e=="string"?s[1]===e:e.has(s[1]):r(s[2]):!1},If=t=>kf.test(t)&&!Sf.test(t),fl=()=>!1,Df=t=>Cf.test(t),Lf=t=>Ef.test(t),$f=bf(()=>{const t=Me("colors"),e=Me("spacing"),r=Me("blur"),s=Me("brightness"),n=Me("borderColor"),a=Me("borderRadius"),i=Me("borderSpacing"),o=Me("borderWidth"),l=Me("contrast"),c=Me("grayscale"),u=Me("hueRotate"),p=Me("invert"),f=Me("gap"),h=Me("gradientColorStops"),y=Me("gradientColorStopPositions"),g=Me("inset"),v=Me("margin"),C=Me("opacity"),_=Me("padding"),S=Me("saturate"),E=Me("scale"),T=Me("sepia"),N=Me("skew"),L=Me("space"),ue=Me("translate"),re=()=>["auto","contain","none"],je=()=>["auto","hidden","clip","visible","scroll"],Se=()=>["auto",be,e],F=()=>[be,e],X=()=>["",cr,Er],W=()=>["auto",cs,be],oe=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ye=()=>["solid","dashed","dotted","double","none"],ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],de=()=>["start","end","center","between","around","evenly","stretch"],G=()=>["","0",be],j=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[cs,be];return{cacheSize:500,separator:":",theme:{colors:[Hs],spacing:[cr,Er],blur:["none","",Tr,be],brightness:z(),borderColor:[t],borderRadius:["none","","full",Tr,be],borderSpacing:F(),borderWidth:X(),contrast:z(),grayscale:G(),hueRotate:z(),invert:G(),gap:F(),gradientColorStops:[t],gradientColorStopPositions:[Tf,Er],inset:Se(),margin:Se(),opacity:z(),padding:F(),saturate:z(),scale:z(),sepia:G(),skew:z(),space:F(),translate:F()},classGroups:{aspect:[{aspect:["auto","square","video",be]}],container:["container"],columns:[{columns:[Tr]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...oe(),be]}],overflow:[{overflow:je()}],"overflow-x":[{"overflow-x":je()}],"overflow-y":[{"overflow-y":je()}],overscroll:[{overscroll:re()}],"overscroll-x":[{"overscroll-x":re()}],"overscroll-y":[{"overscroll-y":re()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",zs,be]}],basis:[{basis:Se()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",be]}],grow:[{grow:G()}],shrink:[{shrink:G()}],order:[{order:["first","last","none",zs,be]}],"grid-cols":[{"grid-cols":[Hs]}],"col-start-end":[{col:["auto",{span:["full",zs,be]},be]}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":[Hs]}],"row-start-end":[{row:["auto",{span:[zs,be]},be]}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",be]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",be]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...de()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...de(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...de(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[_]}],px:[{px:[_]}],py:[{py:[_]}],ps:[{ps:[_]}],pe:[{pe:[_]}],pt:[{pt:[_]}],pr:[{pr:[_]}],pb:[{pb:[_]}],pl:[{pl:[_]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[L]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[L]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",be,e]}],"min-w":[{"min-w":[be,e,"min","max","fit"]}],"max-w":[{"max-w":[be,e,"none","full","min","max","fit","prose",{screen:[Tr]},Tr]}],h:[{h:[be,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[be,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[be,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[be,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Tr,Er]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Ba]}],"font-family":[{font:[Hs]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",be]}],"line-clamp":[{"line-clamp":["none",cs,Ba]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",cr,be]}],"list-image":[{"list-image":["none",be]}],"list-style-type":[{list:["none","disc","decimal",be]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[C]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[C]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ye(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",cr,Er]}],"underline-offset":[{"underline-offset":["auto",cr,be]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",be]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",be]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[C]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...oe(),Of]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",jf]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Nf]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[y]}],"gradient-via-pos":[{via:[y]}],"gradient-to-pos":[{to:[y]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[C]}],"border-style":[{border:[...ye(),"hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[C]}],"divide-style":[{divide:ye()}],"border-color":[{border:[n]}],"border-color-x":[{"border-x":[n]}],"border-color-y":[{"border-y":[n]}],"border-color-s":[{"border-s":[n]}],"border-color-e":[{"border-e":[n]}],"border-color-t":[{"border-t":[n]}],"border-color-r":[{"border-r":[n]}],"border-color-b":[{"border-b":[n]}],"border-color-l":[{"border-l":[n]}],"divide-color":[{divide:[n]}],"outline-style":[{outline:["",...ye()]}],"outline-offset":[{"outline-offset":[cr,be]}],"outline-w":[{outline:[cr,Er]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[C]}],"ring-offset-w":[{"ring-offset":[cr,Er]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Tr,Rf]}],"shadow-color":[{shadow:[Hs]}],opacity:[{opacity:[C]}],"mix-blend":[{"mix-blend":[...ne(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ne()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[s]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Tr,be]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[p]}],saturate:[{saturate:[S]}],sepia:[{sepia:[T]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[p]}],"backdrop-opacity":[{"backdrop-opacity":[C]}],"backdrop-saturate":[{"backdrop-saturate":[S]}],"backdrop-sepia":[{"backdrop-sepia":[T]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",be]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",be]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",be]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[E]}],"scale-x":[{"scale-x":[E]}],"scale-y":[{"scale-y":[E]}],rotate:[{rotate:[zs,be]}],"translate-x":[{"translate-x":[ue]}],"translate-y":[{"translate-y":[ue]}],"skew-x":[{"skew-x":[N]}],"skew-y":[{"skew-y":[N]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",be]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",be]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",be]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[cr,Er,Ba]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function Pn(...t){return $f(sl(t))}const Mf=il("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Br=O.forwardRef(({className:t,variant:e,size:r,asChild:s=!1,...n},a)=>{const i=s?ef:"button";return d.jsx(i,{className:Pn(Mf({variant:e,size:r,className:t})),ref:a,...n})});Br.displayName="Button";const ds=O.forwardRef(({className:t,type:e,...r},s)=>d.jsx("input",{type:e,className:Pn("flex h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:s,...r}));ds.displayName="Input";var Ff=Object.defineProperty,Uf=(t,e)=>Ff(t,"name",{value:e,configurable:!0}),Bf=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],hs=Bf.reduce((t,e)=>{const r=Ur(`Primitive.${e}`),s=O.forwardRef((n,a)=>{const{asChild:i,...o}=n,l=i?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(l,{...o,ref:a})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{});function Vf(t,e){t&&Lu.flushSync(()=>t.dispatchEvent(e))}Uf(Vf,"dispatchDiscreteCustomEvent");var Kf=Object.defineProperty,zf=(t,e)=>Kf(t,"name",{value:e,configurable:!0}),Hf=O.forwardRef(zf(function(e,r){return d.jsx(hs.label,{...e,ref:r,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(e.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}})},"Label")),pl=Hf;const Wf=il("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Vr=O.forwardRef(({className:t,...e},r)=>d.jsx(pl,{ref:r,className:Pn(Wf(),t),...e}));Vr.displayName=pl.displayName;var qf=Object.defineProperty,fs=(t,e)=>qf(t,"name",{value:e,configurable:!0}),ml=!!(typeof window<"u"&&window.document&&window.document.createElement);function Va(t,e,{checkForDefaultPrevented:r=!0}={}){return fs(function(n){if(t?.(n),r===!1||!n||!n.defaultPrevented)return e?.(n)},"handleEvent")}fs(Va,"composeEventHandlers");function Gf(t){if(!ml)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}fs(Gf,"getOwnerWindow");function Ka(t){if(!ml)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}fs(Ka,"getOwnerDocument");function gl(t,e=!1){const{activeElement:r}=Ka(t);if(!r?.nodeName)return null;if(yl(r)&&r.contentDocument)return gl(r.contentDocument.body,e);if(e){const s=r.getAttribute("aria-activedescendant");if(s){const n=Ka(r).getElementById(s);if(n)return n}}return r}fs(gl,"getActiveElement");function yl(t){return t.tagName==="IFRAME"}fs(yl,"isFrame");var Jf=Object.defineProperty,Pt=(t,e)=>Jf(t,"name",{value:e,configurable:!0});function Zf(t,e){const r=O.createContext(e);r.displayName=t+"Context";const s=Pt(a=>{const{children:i,...o}=a,l=O.useMemo(()=>o,Object.values(o));return d.jsx(r.Provider,{value:l,children:i})},"Provider");s.displayName=t+"Provider";function n(a,i={}){const{optional:o=!1}=i,l=O.useContext(r);if(l)return l;if(e!==void 0)return e;if(!o)throw new Error(`\`${a}\` must be used within \`${t}\``)}return Pt(n,"useContext"),[s,n]}Pt(Zf,"createContext");function Ws(t,e=[]){let r=[];function s(a,i){const o=O.createContext(i);o.displayName=a+"Context";const l=r.length;r=[...r,i];const c=Pt(p=>{const{scope:f,children:h,...y}=p,g=f?.[t]?.[l]||o,v=O.useMemo(()=>y,Object.values(y));return d.jsx(g.Provider,{value:v,children:h})},"Provider");c.displayName=a+"Provider";function u(p,f,h={}){const{optional:y=!1}=h,g=f?.[t]?.[l]||o,v=O.useContext(g);if(v)return v;if(i!==void 0)return i;if(!y)throw new Error(`\`${p}\` must be used within \`${a}\``)}return Pt(u,"useContext"),[c,u]}Pt(s,"createContext");const n=Pt(()=>{const a=r.map(i=>O.createContext(i));return Pt(function(o){const l=o?.[t]||a;return O.useMemo(()=>({[`__scope${t}`]:{...o,[t]:l}}),[o,l])},"useScope")},"createScope");return n.scopeName=t,[s,vl(n,...e)]}Pt(Ws,"createContextScope");function vl(...t){const e=t[0];if(t.length===1)return e;const r=Pt(()=>{const s=t.map(n=>({useScope:n(),scopeName:n.scopeName}));return Pt(function(a){const i=s.reduce((o,{useScope:l,scopeName:c})=>{const p=l(a)[`__scope${c}`];return{...o,...p}},{});return O.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])},"useComposedScopes")},"createScope");return r.scopeName=e.scopeName,r}Pt(vl,"composeContextScopes");var ps=globalThis?.document?O.useLayoutEffect:()=>{},Yf=Object.defineProperty,Xf=(t,e)=>Yf(t,"name",{value:e,configurable:!0}),bl=O[" useEffectEvent ".trim().toString()],wl=O[" useInsertionEffect ".trim().toString()];function xl(t){if(typeof bl=="function")return bl(t);const e=O.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof wl=="function"?wl(()=>{e.current=t}):ps(()=>{e.current=t}),O.useMemo(()=>((...r)=>e.current?.(...r)),[])}Xf(xl,"useEffectEvent");var Qf=Object.defineProperty,qs=(t,e)=>Qf(t,"name",{value:e,configurable:!0}),ep=O[" useInsertionEffect ".trim().toString()]||ps;function Nn({prop:t,defaultProp:e,onChange:r=qs(()=>{},"onChange"),caller:s}){const[n,a,i]=_l({defaultProp:e,onChange:r}),o=t!==void 0,l=o?t:n,c=O.useCallback(u=>{if(o){const p=kl(u)?u(t):u;p!==t&&i.current?.(p)}else a(u)},[o,t,a,i]);return[l,c]}qs(Nn,"useControllableState");function _l({defaultProp:t,onChange:e}){const[r,s]=O.useState(t),n=O.useRef(r),a=O.useRef(e);return ep(()=>{a.current=e},[e]),O.useEffect(()=>{n.current!==r&&(a.current?.(r),n.current=r)},[r,n]),[r,s,a]}qs(_l,"useUncontrolledState");function kl(t){return typeof t=="function"}qs(kl,"isFunction");var Sl=Symbol("RADIX:SYNC_STATE");function tp(t,e,r,s){const{prop:n,defaultProp:a,onChange:i,caller:o}=e,l=n!==void 0,c=xl(i),u=[{...r,state:a}];s&&u.push(s);const[p,f]=O.useReducer((v,C)=>{if(C.type===Sl)return{...v,state:C.state};const _=t(v,C);return l&&!Object.is(_.state,v.state)&&c(_.state),_},...u),h=p.state,y=O.useRef(h);O.useEffect(()=>{y.current!==h&&(y.current=h,l||c(h))},[h,y,l]);const g=O.useMemo(()=>n!==void 0?{...p,state:n}:p,[p,n]);return O.useEffect(()=>{l&&!Object.is(n,p.state)&&f({type:Sl,state:n})},[n,p.state,l]),[g,f]}qs(tp,"useControllableStateReducer");var rp=Object.defineProperty,ur=(t,e)=>rp(t,"name",{value:e,configurable:!0});function Cl(t,e){return O.useReducer((r,s)=>e[r][s]??r,t)}ur(Cl,"useStateMachine");var sp=ur(t=>{const{present:e,children:r}=t,s=El(e),n=typeof r=="function"?r({present:s.isPresent}):O.Children.only(r),a=Tl(s.ref,Al(n));return typeof r=="function"||s.isPresent?O.cloneElement(n,{ref:a}):null},"Presence");function El(t){const[e,r]=O.useState(),s=O.useRef(null),n=O.useRef(t),a=O.useRef("none"),i=O.useRef(void 0),o=t?"mounted":"unmounted",[l,c]=Cl(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return O.useEffect(()=>{l==="mounted"?(a.current=i.current??ms(s.current),i.current=void 0):a.current="none"},[l]),ps(()=>{const u=s.current,p=n.current;if(p!==t){const h=a.current,y=ms(u);t?(i.current=y,c("MOUNT")):y==="none"||u?.display==="none"?c("UNMOUNT"):c(p&&h!==y?"ANIMATION_OUT":"UNMOUNT"),n.current=t}},[t,c]),ps(()=>{if(e){let u;const p=e.ownerDocument.defaultView??window,f=ur(y=>{const v=ms(s.current).includes(CSS.escape(y.animationName));if(y.target===e&&v&&(c("ANIMATION_END"),!n.current)){const C=e.style.animationFillMode;e.style.animationFillMode="forwards",u=p.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=C)})}},"handleAnimationEnd"),h=ur(y=>{y.target===e&&(a.current=ms(s.current))},"handleAnimationStart");return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",f),e.addEventListener("animationend",f),()=>{p.clearTimeout(u),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",f),e.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:O.useCallback(u=>{if(u){const p=getComputedStyle(u);s.current=p,i.current=ms(p)}else s.current=null;r(u)},[])}}ur(El,"usePresence");function za(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}ur(za,"setRef");function Tl(...t){const e=O.useRef(t);return e.current=t,O.useCallback(r=>{const s=e.current;let n=!1;const a=s.map(i=>{const o=za(i,r);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<a.length;i++){const o=a[i];typeof o=="function"?o():za(s[i],null)}}},[])}ur(Tl,"useStableComposedRefs");function ms(t){return t?.animationName||"none"}ur(ms,"getAnimationName");function Al(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}ur(Al,"getElementRef");var np=Object.defineProperty,ap=(t,e)=>np(t,"name",{value:e,configurable:!0}),ip=O[" useId ".trim().toString()]||(()=>{}),op=0;function Ha(t){const[e,r]=O.useState(ip());return ps(()=>{t||r(s=>s??String(op++))},[t]),t||(e?`radix-${e}`:"")}ap(Ha,"useId");var lp=Object.defineProperty,Gs=(t,e)=>lp(t,"name",{value:e,configurable:!0}),Wa="Collapsible",[cp,jl]=Ws(Wa),[up,qa]=cp(Wa),dp=O.forwardRef(Gs(function(e,r){const{__scopeCollapsible:s,open:n,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[c,u]=Nn({prop:n,defaultProp:a??!1,onChange:o,caller:Wa});return d.jsx(up,{scope:s,disabled:i,contentId:Ha(),open:c,onOpenToggle:O.useCallback(()=>u(p=>!p),[u]),children:d.jsx(hs.div,{"data-state":Rn(c),"data-disabled":i?"":void 0,...l,ref:r})})},"Collapsible")),hp="CollapsibleTrigger",fp=O.forwardRef(Gs(function(e,r){const{__scopeCollapsible:s,...n}=e,a=qa(hp,s);return d.jsx(hs.button,{type:"button","aria-controls":a.open?a.contentId:void 0,"aria-expanded":a.open||!1,"data-state":Rn(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:r,onClick:Va(e.onClick,a.onOpenToggle)})},"CollapsibleTrigger")),Ol="CollapsibleContent",Pl=O.forwardRef(Gs(function(e,r){const{forceMount:s,...n}=e,a=qa(Ol,e.__scopeCollapsible);return d.jsx(sp,{present:s||a.open,children:({present:i})=>d.jsx(pp,{...n,ref:r,present:i})})},"CollapsibleContent")),pp=O.forwardRef(Gs(function(e,r){const{__scopeCollapsible:s,present:n,children:a,...i}=e,o=qa(Ol,s),[l,c]=O.useState(n),u=O.useRef(null),p=lr(r,u),f=O.useRef(0),h=f.current,y=O.useRef(0),g=y.current,v=o.open||l,C=O.useRef(v),_=O.useRef(void 0);return O.useEffect(()=>{const S=requestAnimationFrame(()=>C.current=!1);return()=>cancelAnimationFrame(S)},[]),ps(()=>{const S=u.current;if(S){_.current=_.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const E=S.getBoundingClientRect();f.current=E.height,y.current=E.width,C.current||(S.style.transitionDuration=_.current.transitionDuration,S.style.animationName=_.current.animationName),c(n)}},[o.open,n]),d.jsx(hs.div,{"data-state":Rn(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!v,...i,ref:p,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:v&&a})},"CollapsibleContentImpl"));function Rn(t){return t?"open":"closed"}Gs(Rn,"getState");var Nl=dp,mp=fp,gp=Pl;const yp=Nl,vp=Pl;var bp=t=>{switch(t){case"success":return _p;case"info":return Sp;case"warning":return kp;case"error":return Cp;default:return null}},wp=Array(12).fill(0),xp=({visible:t,className:e})=>k.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},k.createElement("div",{className:"sonner-spinner"},wp.map((r,s)=>k.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),_p=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),kp=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Sp=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Cp=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Ep=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},k.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),k.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Tp=()=>{let[t,e]=k.useState(document.hidden);return k.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},Ga=1,Ap=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:r,...s}=t,n=typeof t?.id=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:Ga++,a=this.toasts.find(o=>o.id===n),i=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(n)&&this.dismissedToasts.delete(n),a?this.toasts=this.toasts.map(o=>o.id===n?(this.publish({...o,...t,id:n,title:r}),{...o,...t,id:n,dismissible:i,title:r}):o):this.addToast({title:r,...s,dismissible:i,id:n}),n},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(r=>r({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let r;e.loading!==void 0&&(r=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let s=t instanceof Promise?t:t(),n=r!==void 0,a,i=s.then(async l=>{if(a=["resolve",l],k.isValidElement(l))n=!1,this.create({id:r,type:"default",message:l});else if(Op(l)&&!l.ok){n=!1;let c=typeof e.error=="function"?await e.error(`HTTP error! status: ${l.status}`):e.error,u=typeof e.description=="function"?await e.description(`HTTP error! status: ${l.status}`):e.description;this.create({id:r,type:"error",message:c,description:u})}else if(e.success!==void 0){n=!1;let c=typeof e.success=="function"?await e.success(l):e.success,u=typeof e.description=="function"?await e.description(l):e.description;this.create({id:r,type:"success",message:c,description:u})}}).catch(async l=>{if(a=["reject",l],e.error!==void 0){n=!1;let c=typeof e.error=="function"?await e.error(l):e.error,u=typeof e.description=="function"?await e.description(l):e.description;this.create({id:r,type:"error",message:c,description:u})}}).finally(()=>{var l;n&&(this.dismiss(r),r=void 0),(l=e.finally)==null||l.call(e)}),o=()=>new Promise((l,c)=>i.then(()=>a[0]==="reject"?c(a[1]):l(a[1])).catch(c));return typeof r!="string"&&typeof r!="number"?{unwrap:o}:Object.assign(r,{unwrap:o})},this.custom=(t,e)=>{let r=e?.id||Ga++;return this.create({jsx:t(r),id:r,...e}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},mt=new Ap,jp=(t,e)=>{let r=e?.id||Ga++;return mt.addToast({title:t,...e,id:r}),r},Op=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Pp=jp,Np=()=>mt.toasts,Rp=()=>mt.getActiveToasts(),gs=Object.assign(Pp,{success:mt.success,info:mt.info,warning:mt.warning,error:mt.error,custom:mt.custom,message:mt.message,promise:mt.promise,dismiss:mt.dismiss,loading:mt.loading},{getHistory:Np,getToasts:Rp});function Ip(t,{insertAt:e}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",e==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=t:s.appendChild(document.createTextNode(t))}Ip(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
123
- `);function In(t){return t.label!==void 0}var Dp=3,Lp="32px",$p="16px",Rl=4e3,Mp=356,Fp=14,Up=20,Bp=200;function Vt(...t){return t.filter(Boolean).join(" ")}function Vp(t){let[e,r]=t.split("-"),s=[];return e&&s.push(e),r&&s.push(r),s}var Kp=t=>{var e,r,s,n,a,i,o,l,c,u,p;let{invert:f,toast:h,unstyled:y,interacting:g,setHeights:v,visibleToasts:C,heights:_,index:S,toasts:E,expanded:T,removeToast:N,defaultRichColors:L,closeButton:ue,style:re,cancelButtonStyle:je,actionButtonStyle:Se,className:F="",descriptionClassName:X="",duration:W,position:oe,gap:ye,loadingIcon:ne,expandByDefault:de,classNames:G,icons:j,closeButtonAriaLabel:z="Close toast",pauseWhenPageIsHidden:Z}=t,[se,he]=k.useState(null),[le,ae]=k.useState(null),[ce,tt]=k.useState(!1),[Je,Le]=k.useState(!1),[ut,qt]=k.useState(!1),[lt,sr]=k.useState(!1),[rt,Dt]=k.useState(!1),[ht,Gt]=k.useState(0),[Et,Jt]=k.useState(0),Tt=k.useRef(h.duration||W||Rl),Lt=k.useRef(null),ft=k.useRef(null),Pr=S===0,Nr=S+1<=C,qe=h.type,vt=h.dismissible!==!1,Rr=h.className||"",br=h.descriptionClassName||"",nr=k.useMemo(()=>_.findIndex(te=>te.toastId===h.id)||0,[_,h.id]),As=k.useMemo(()=>{var te;return(te=h.closeButton)!=null?te:ue},[h.closeButton,ue]),U=k.useMemo(()=>h.duration||W||Rl,[h.duration,W]),m=k.useRef(0),b=k.useRef(0),x=k.useRef(0),A=k.useRef(null),[P,I]=oe.split("-"),M=k.useMemo(()=>_.reduce((te,we,ve)=>ve>=nr?te:te+we.height,0),[_,nr]),R=Tp(),J=h.invert||f,ee=qe==="loading";b.current=k.useMemo(()=>nr*ye+M,[nr,M]),k.useEffect(()=>{Tt.current=U},[U]),k.useEffect(()=>{tt(!0)},[]),k.useEffect(()=>{let te=ft.current;if(te){let we=te.getBoundingClientRect().height;return Jt(we),v(ve=>[{toastId:h.id,height:we,position:h.position},...ve]),()=>v(ve=>ve.filter($e=>$e.toastId!==h.id))}},[v,h.id]),k.useLayoutEffect(()=>{if(!ce)return;let te=ft.current,we=te.style.height;te.style.height="auto";let ve=te.getBoundingClientRect().height;te.style.height=we,Jt(ve),v($e=>$e.find(st=>st.toastId===h.id)?$e.map(st=>st.toastId===h.id?{...st,height:ve}:st):[{toastId:h.id,height:ve,position:h.position},...$e])},[ce,h.title,h.description,v,h.id]);let _e=k.useCallback(()=>{Le(!0),Gt(b.current),v(te=>te.filter(we=>we.toastId!==h.id)),setTimeout(()=>{N(h)},Bp)},[h,N,v,b]);k.useEffect(()=>{if(h.promise&&qe==="loading"||h.duration===1/0||h.type==="loading")return;let te;return T||g||Z&&R?(()=>{if(x.current<m.current){let we=new Date().getTime()-m.current;Tt.current=Tt.current-we}x.current=new Date().getTime()})():Tt.current!==1/0&&(m.current=new Date().getTime(),te=setTimeout(()=>{var we;(we=h.onAutoClose)==null||we.call(h,h),_e()},Tt.current)),()=>clearTimeout(te)},[T,g,h,qe,Z,R,_e]),k.useEffect(()=>{h.delete&&_e()},[_e,h.delete]);function Ze(){var te,we,ve;return j!=null&&j.loading?k.createElement("div",{className:Vt(G?.loader,(te=h?.classNames)==null?void 0:te.loader,"sonner-loader"),"data-visible":qe==="loading"},j.loading):ne?k.createElement("div",{className:Vt(G?.loader,(we=h?.classNames)==null?void 0:we.loader,"sonner-loader"),"data-visible":qe==="loading"},ne):k.createElement(xp,{className:Vt(G?.loader,(ve=h?.classNames)==null?void 0:ve.loader),visible:qe==="loading"})}return k.createElement("li",{tabIndex:0,ref:ft,className:Vt(F,Rr,G?.toast,(e=h?.classNames)==null?void 0:e.toast,G?.default,G?.[qe],(r=h?.classNames)==null?void 0:r[qe]),"data-sonner-toast":"","data-rich-colors":(s=h.richColors)!=null?s:L,"data-styled":!(h.jsx||h.unstyled||y),"data-mounted":ce,"data-promise":!!h.promise,"data-swiped":rt,"data-removed":Je,"data-visible":Nr,"data-y-position":P,"data-x-position":I,"data-index":S,"data-front":Pr,"data-swiping":ut,"data-dismissible":vt,"data-type":qe,"data-invert":J,"data-swipe-out":lt,"data-swipe-direction":le,"data-expanded":!!(T||de&&ce),style:{"--index":S,"--toasts-before":S,"--z-index":E.length-S,"--offset":`${Je?ht:b.current}px`,"--initial-height":de?"auto":`${Et}px`,...re,...h.style},onDragEnd:()=>{qt(!1),he(null),A.current=null},onPointerDown:te=>{ee||!vt||(Lt.current=new Date,Gt(b.current),te.target.setPointerCapture(te.pointerId),te.target.tagName!=="BUTTON"&&(qt(!0),A.current={x:te.clientX,y:te.clientY}))},onPointerUp:()=>{var te,we,ve,$e;if(lt||!vt)return;A.current=null;let st=Number(((te=ft.current)==null?void 0:te.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),At=Number(((we=ft.current)==null?void 0:we.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ar=new Date().getTime()-((ve=Lt.current)==null?void 0:ve.getTime()),bt=se==="x"?st:At,ir=Math.abs(bt)/ar;if(Math.abs(bt)>=Up||ir>.11){Gt(b.current),($e=h.onDismiss)==null||$e.call(h,h),ae(se==="x"?st>0?"right":"left":At>0?"down":"up"),_e(),sr(!0),Dt(!1);return}qt(!1),he(null)},onPointerMove:te=>{var we,ve,$e,st;if(!A.current||!vt||((we=window.getSelection())==null?void 0:we.toString().length)>0)return;let At=te.clientY-A.current.y,ar=te.clientX-A.current.x,bt=(ve=t.swipeDirections)!=null?ve:Vp(oe);!se&&(Math.abs(ar)>1||Math.abs(At)>1)&&he(Math.abs(ar)>Math.abs(At)?"x":"y");let ir={x:0,y:0};se==="y"?(bt.includes("top")||bt.includes("bottom"))&&(bt.includes("top")&&At<0||bt.includes("bottom")&&At>0)&&(ir.y=At):se==="x"&&(bt.includes("left")||bt.includes("right"))&&(bt.includes("left")&&ar<0||bt.includes("right")&&ar>0)&&(ir.x=ar),(Math.abs(ir.x)>0||Math.abs(ir.y)>0)&&Dt(!0),($e=ft.current)==null||$e.style.setProperty("--swipe-amount-x",`${ir.x}px`),(st=ft.current)==null||st.style.setProperty("--swipe-amount-y",`${ir.y}px`)}},As&&!h.jsx?k.createElement("button",{"aria-label":z,"data-disabled":ee,"data-close-button":!0,onClick:ee||!vt?()=>{}:()=>{var te;_e(),(te=h.onDismiss)==null||te.call(h,h)},className:Vt(G?.closeButton,(n=h?.classNames)==null?void 0:n.closeButton)},(a=j?.close)!=null?a:Ep):null,h.jsx||k.isValidElement(h.title)?h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title:k.createElement(k.Fragment,null,qe||h.icon||h.promise?k.createElement("div",{"data-icon":"",className:Vt(G?.icon,(i=h?.classNames)==null?void 0:i.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||Ze():null,h.type!=="loading"?h.icon||j?.[qe]||bp(qe):null):null,k.createElement("div",{"data-content":"",className:Vt(G?.content,(o=h?.classNames)==null?void 0:o.content)},k.createElement("div",{"data-title":"",className:Vt(G?.title,(l=h?.classNames)==null?void 0:l.title)},typeof h.title=="function"?h.title():h.title),h.description?k.createElement("div",{"data-description":"",className:Vt(X,br,G?.description,(c=h?.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),k.isValidElement(h.cancel)?h.cancel:h.cancel&&In(h.cancel)?k.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||je,onClick:te=>{var we,ve;In(h.cancel)&&vt&&((ve=(we=h.cancel).onClick)==null||ve.call(we,te),_e())},className:Vt(G?.cancelButton,(u=h?.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,k.isValidElement(h.action)?h.action:h.action&&In(h.action)?k.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||Se,onClick:te=>{var we,ve;In(h.action)&&((ve=(we=h.action).onClick)==null||ve.call(we,te),!te.defaultPrevented&&_e())},className:Vt(G?.actionButton,(p=h?.classNames)==null?void 0:p.actionButton)},h.action.label):null))};function Il(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function zp(t,e){let r={};return[t,e].forEach((s,n)=>{let a=n===1,i=a?"--mobile-offset":"--offset",o=a?$p:Lp;function l(c){["top","right","bottom","left"].forEach(u=>{r[`${i}-${u}`]=typeof c=="number"?`${c}px`:c})}typeof s=="number"||typeof s=="string"?l(s):typeof s=="object"?["top","right","bottom","left"].forEach(c=>{s[c]===void 0?r[`${i}-${c}`]=o:r[`${i}-${c}`]=typeof s[c]=="number"?`${s[c]}px`:s[c]}):l(o)}),r}k.forwardRef(function(t,e){let{invert:r,position:s="bottom-right",hotkey:n=["altKey","KeyT"],expand:a,closeButton:i,className:o,offset:l,mobileOffset:c,theme:u="light",richColors:p,duration:f,style:h,visibleToasts:y=Dp,toastOptions:g,dir:v=Il(),gap:C=Fp,loadingIcon:_,icons:S,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:T}=t,[N,L]=k.useState([]),ue=k.useMemo(()=>Array.from(new Set([s].concat(N.filter(Z=>Z.position).map(Z=>Z.position)))),[N,s]),[re,je]=k.useState([]),[Se,F]=k.useState(!1),[X,W]=k.useState(!1),[oe,ye]=k.useState(u!=="system"?u:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ne=k.useRef(null),de=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),G=k.useRef(null),j=k.useRef(!1),z=k.useCallback(Z=>{L(se=>{var he;return(he=se.find(le=>le.id===Z.id))!=null&&he.delete||mt.dismiss(Z.id),se.filter(({id:le})=>le!==Z.id)})},[]);return k.useEffect(()=>mt.subscribe(Z=>{if(Z.dismiss){L(se=>se.map(he=>he.id===Z.id?{...he,delete:!0}:he));return}setTimeout(()=>{xt.flushSync(()=>{L(se=>{let he=se.findIndex(le=>le.id===Z.id);return he!==-1?[...se.slice(0,he),{...se[he],...Z},...se.slice(he+1)]:[Z,...se]})})})}),[]),k.useEffect(()=>{if(u!=="system"){ye(u);return}if(u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ye("dark"):ye("light")),typeof window>"u")return;let Z=window.matchMedia("(prefers-color-scheme: dark)");try{Z.addEventListener("change",({matches:se})=>{ye(se?"dark":"light")})}catch{Z.addListener(({matches:he})=>{try{ye(he?"dark":"light")}catch(le){console.error(le)}})}},[u]),k.useEffect(()=>{N.length<=1&&F(!1)},[N]),k.useEffect(()=>{let Z=se=>{var he,le;n.every(ae=>se[ae]||se.code===ae)&&(F(!0),(he=ne.current)==null||he.focus()),se.code==="Escape"&&(document.activeElement===ne.current||(le=ne.current)!=null&&le.contains(document.activeElement))&&F(!1)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[n]),k.useEffect(()=>{if(ne.current)return()=>{G.current&&(G.current.focus({preventScroll:!0}),G.current=null,j.current=!1)}},[ne.current]),k.createElement("section",{ref:e,"aria-label":`${E} ${de}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},ue.map((Z,se)=>{var he;let[le,ae]=Z.split("-");return N.length?k.createElement("ol",{key:Z,dir:v==="auto"?Il():v,tabIndex:-1,ref:ne,className:o,"data-sonner-toaster":!0,"data-theme":oe,"data-y-position":le,"data-lifted":Se&&N.length>1&&!a,"data-x-position":ae,style:{"--front-toast-height":`${((he=re[0])==null?void 0:he.height)||0}px`,"--width":`${Mp}px`,"--gap":`${C}px`,...h,...zp(l,c)},onBlur:ce=>{j.current&&!ce.currentTarget.contains(ce.relatedTarget)&&(j.current=!1,G.current&&(G.current.focus({preventScroll:!0}),G.current=null))},onFocus:ce=>{ce.target instanceof HTMLElement&&ce.target.dataset.dismissible==="false"||j.current||(j.current=!0,G.current=ce.relatedTarget)},onMouseEnter:()=>F(!0),onMouseMove:()=>F(!0),onMouseLeave:()=>{X||F(!1)},onDragEnd:()=>F(!1),onPointerDown:ce=>{ce.target instanceof HTMLElement&&ce.target.dataset.dismissible==="false"||W(!0)},onPointerUp:()=>W(!1)},N.filter(ce=>!ce.position&&se===0||ce.position===Z).map((ce,tt)=>{var Je,Le;return k.createElement(Kp,{key:ce.id,icons:S,index:tt,toast:ce,defaultRichColors:p,duration:(Je=g?.duration)!=null?Je:f,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:y,closeButton:(Le=g?.closeButton)!=null?Le:i,interacting:X,position:Z,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,removeToast:z,toasts:N.filter(ut=>ut.position==ce.position),heights:re.filter(ut=>ut.position==ce.position),setHeights:je,expandByDefault:a,gap:C,loadingIcon:_,expanded:Se,pauseWhenPageIsHidden:T,swipeDirections:t.swipeDirections})})):null}))});const dr=O.forwardRef(({className:t="",...e},r)=>d.jsx("div",{ref:r,className:`rounded-lg border border-border bg-card text-card-foreground shadow-sm ${t}`,...e}));dr.displayName="Card";const Kr=O.forwardRef(({className:t="",...e},r)=>d.jsx("div",{ref:r,className:`flex flex-col space-y-1.5 p-6 ${t}`,...e}));Kr.displayName="CardHeader";const zr=O.forwardRef(({className:t="",...e},r)=>d.jsx("h3",{ref:r,className:`text-2xl font-semibold leading-none tracking-tight ${t}`,...e}));zr.displayName="CardTitle";const Dn=O.forwardRef(({className:t="",...e},r)=>d.jsx("p",{ref:r,className:`text-sm text-muted-foreground ${t}`,...e}));Dn.displayName="CardDescription";const Ar=O.forwardRef(({className:t="",...e},r)=>d.jsx("div",{ref:r,className:`p-6 pt-0 ${t}`,...e}));Ar.displayName="CardContent";const Ln=O.forwardRef(({className:t="",variant:e="default",...r},s)=>{const n={default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input"};return d.jsx("div",{ref:s,className:`inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 ${n[e]} ${t}`,...r})});Ln.displayName="Badge";var Hp=Object.defineProperty,Qe=(t,e)=>Hp(t,"name",{value:e,configurable:!0});function Dl(t){const e=t+"CollectionProvider",[r,s]=Ws(e),[n,a]=r(e,{collectionRef:{current:null},itemMap:new Map}),i=Qe(g=>{const{scope:v,children:C}=g,_=O.useRef(null),S=O.useRef(new Map).current;return d.jsx(n,{scope:v,itemMap:S,collectionRef:_,children:C})},"CollectionProvider");i.displayName=e;const o=t+"CollectionSlot",l=Ur(o),c=O.forwardRef((g,v)=>{const{scope:C,children:_}=g,S=a(o,C),E=lr(v,S.collectionRef);return d.jsx(l,{ref:E,children:_})});c.displayName=o;const u=t+"CollectionItemSlot",p="data-radix-collection-item",f=Ur(u),h=O.forwardRef((g,v)=>{const{scope:C,children:_,...S}=g,E=O.useRef(null),T=lr(v,E),N=a(u,C);return O.useEffect(()=>(N.itemMap.set(E,{ref:E,...S}),()=>{N.itemMap.delete(E)})),d.jsx(f,{[p]:"",ref:T,children:_})});h.displayName=u;function y(g){const v=a(t+"CollectionConsumer",g);return O.useCallback(()=>{const _=v.collectionRef.current;if(!_)return[];const S=Array.from(_.querySelectorAll(`[${p}]`));return Array.from(v.itemMap.values()).sort((N,L)=>S.indexOf(N.ref.current)-S.indexOf(L.ref.current))},[v.collectionRef,v.itemMap])}return Qe(y,"useCollection"),[{Provider:i,Slot:c,ItemSlot:h},y,s]}Qe(Dl,"createCollection");var Ll=new WeakMap,Ja=(Ct=class extends Map{constructor(r){super(r);Iu(this,We);ji(this,We,[...super.keys()]),Ll.set(this,!0)}set(r,s){return Ll.get(this)&&(this.has(r)?dt(this,We)[dt(this,We).indexOf(r)]=r:dt(this,We).push(r)),super.set(r,s),this}insert(r,s,n){const a=this.has(s),i=dt(this,We).length,o=Za(r);let l=o>=0?o:i+o;const c=l<0||l>=i?-1:l;if(c===this.size||a&&c===this.size-1||c===-1)return this.set(s,n),this;const u=this.size+(a?0:1);o<0&&l++;const p=[...dt(this,We)];let f,h=!1;for(let y=l;y<u;y++)if(l===y){let g=p[y];p[y]===s&&(g=p[y+1]),a&&this.delete(s),f=this.get(g),this.set(s,n)}else{!h&&p[y-1]===s&&(h=!0);const g=p[h?y:y-1],v=f;f=this.get(g),this.delete(g),this.set(g,v)}return this}with(r,s,n){const a=new Ct(this);return a.insert(r,s,n),a}before(r){const s=dt(this,We).indexOf(r)-1;if(!(s<0))return this.entryAt(s)}setBefore(r,s,n){const a=dt(this,We).indexOf(r);return a===-1?this:this.insert(a,s,n)}after(r){let s=dt(this,We).indexOf(r);if(s=s===-1||s===this.size-1?-1:s+1,s!==-1)return this.entryAt(s)}setAfter(r,s,n){const a=dt(this,We).indexOf(r);return a===-1?this:this.insert(a+1,s,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return ji(this,We,[]),super.clear()}delete(r){const s=super.delete(r);return s&&dt(this,We).splice(dt(this,We).indexOf(r),1),s}deleteAt(r){const s=this.keyAt(r);return s!==void 0?this.delete(s):!1}at(r){const s=$n(dt(this,We),r);if(s!==void 0)return this.get(s)}entryAt(r){const s=$n(dt(this,We),r);if(s!==void 0)return[s,this.get(s)]}indexOf(r){return dt(this,We).indexOf(r)}keyAt(r){return $n(dt(this,We),r)}from(r,s){const n=this.indexOf(r);if(n===-1)return;let a=n+s;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.at(a)}keyFrom(r,s){const n=this.indexOf(r);if(n===-1)return;let a=n+s;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.keyAt(a)}find(r,s){let n=0;for(const a of this){if(Reflect.apply(r,s,[a,n,this]))return a;n++}}findIndex(r,s){let n=0;for(const a of this){if(Reflect.apply(r,s,[a,n,this]))return n;n++}return-1}filter(r,s){const n=[];let a=0;for(const i of this)Reflect.apply(r,s,[i,a,this])&&n.push(i),a++;return new Ct(n)}map(r,s){const n=[];let a=0;for(const i of this)n.push([i[0],Reflect.apply(r,s,[i,a,this])]),a++;return new Ct(n)}reduce(...r){const[s,n]=r;let a=0,i=n??this.at(0);for(const o of this)a===0&&r.length===1?i=o:i=Reflect.apply(s,this,[i,o,a,this]),a++;return i}reduceRight(...r){const[s,n]=r;let a=n??this.at(-1);for(let i=this.size-1;i>=0;i--){const o=this.at(i);i===this.size-1&&r.length===1?a=o:a=Reflect.apply(s,this,[a,o,i,this])}return a}toSorted(r){const s=[...this.entries()].sort(r);return new Ct(s)}toReversed(){const r=new Ct;for(let s=this.size-1;s>=0;s--){const n=this.keyAt(s),a=this.get(n);r.set(n,a)}return r}toSpliced(...r){const s=[...this.entries()];return s.splice(...r),new Ct(s)}slice(r,s){const n=new Ct;let a=this.size-1;if(r===void 0)return n;r<0&&(r=r+this.size),s!==void 0&&s>0&&(a=s-1);for(let i=r;i<=a;i++){const o=this.keyAt(i),l=this.get(o);n.set(o,l)}return n}every(r,s){let n=0;for(const a of this){if(!Reflect.apply(r,s,[a,n,this]))return!1;n++}return!0}some(r,s){let n=0;for(const a of this){if(Reflect.apply(r,s,[a,n,this]))return!0;n++}return!1}},We=new WeakMap,Qe(Ct,"OrderedDict"),Ct);function $n(t,e){if("at"in Array.prototype)return Array.prototype.at.call(t,e);const r=$l(t,e);return r===-1?void 0:t[r]}Qe($n,"at");function $l(t,e){const r=t.length,s=Za(e),n=s>=0?s:r+s;return n<0||n>=r?-1:n}Qe($l,"toSafeIndex");function Za(t){return t!==t||t===0?0:Math.trunc(t)}Qe(Za,"toSafeInteger");function Wp(t){const e=t+"CollectionProvider",[r,s]=Ws(e),[n,a]=r(e,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Ja,setItemMap:Qe(()=>{},"setItemMap")}),i=Qe(({state:S,...E})=>S?d.jsx(l,{...E,state:S}):d.jsx(o,{...E}),"CollectionProvider");i.displayName=e;const o=Qe(S=>{const E=v();return d.jsx(l,{...S,state:E})},"CollectionInit");o.displayName=e+"Init";const l=Qe(S=>{const{scope:E,children:T,state:N}=S,L=O.useRef(null),[ue,re]=O.useState(null),je=lr(L,re),[Se,F]=N;return O.useEffect(()=>{if(!ue)return;const X=Ul(()=>{});return X.observe(ue,{childList:!0,subtree:!0}),()=>{X.disconnect()}},[ue]),d.jsx(n,{scope:E,itemMap:Se,setItemMap:F,collectionRef:je,collectionRefObject:L,collectionElement:ue,children:T})},"CollectionProviderImpl");l.displayName=e+"Impl";const c=t+"CollectionSlot",u=Ur(c),p=O.forwardRef((S,E)=>{const{scope:T,children:N}=S,L=a(c,T),ue=lr(E,L.collectionRef);return d.jsx(u,{ref:ue,children:N})});p.displayName=c;const f=t+"CollectionItemSlot",h="data-radix-collection-item",y=Ur(f),g=O.forwardRef((S,E)=>{const{scope:T,children:N,...L}=S,ue=O.useRef(null),[re,je]=O.useState(null),Se=lr(E,ue,je),F=a(f,T),{setItemMap:X}=F,W=O.useRef(L);Ml(W.current,L)||(W.current=L);const oe=W.current;return O.useEffect(()=>{const ye=oe;return X(ne=>re?ne.has(re)?ne.set(re,{...ye,element:re}).toSorted(Ya):(ne.set(re,{...ye,element:re}),ne.toSorted(Ya)):ne),()=>{X(ne=>!re||!ne.has(re)?ne:(ne.delete(re),new Ja(ne)))}},[re,oe,X]),d.jsx(y,{[h]:"",ref:Se,children:N})});g.displayName=f;function v(){return O.useState(new Ja)}Qe(v,"useInitCollection");function C(S){const{itemMap:E}=a(t+"CollectionConsumer",S);return E}return Qe(C,"useCollection"),[{Provider:i,Slot:p,ItemSlot:g},{createCollectionScope:s,useCollection:C,useInitCollection:v}]}Qe(Wp,"createCollection");function Ml(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t==null||e==null)return!1;const r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;for(const n of r)if(!Object.prototype.hasOwnProperty.call(e,n)||t[n]!==e[n])return!1;return!0}Qe(Ml,"shallowEqual");function Fl(t,e){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}Qe(Fl,"isElementPreceding");function Ya(t,e){return!t[1].element||!e[1].element?0:Fl(t[1].element,e[1].element)?-1:1}Qe(Ya,"sortByDocumentPosition");function Ul(t){return new MutationObserver(r=>{for(const s of r)if(s.type==="childList"){t();return}})}Qe(Ul,"getChildListObserver");var qp=Object.defineProperty,Gp=(t,e)=>qp(t,"name",{value:e,configurable:!0}),Jp=O.createContext(void 0);function Bl(t){const e=O.useContext(Jp);return t||e||"ltr"}Gp(Bl,"useDirection");var Zp=Object.defineProperty,kt=(t,e)=>Zp(t,"name",{value:e,configurable:!0}),Qt="Accordion",Yp=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Xa,Xp,Qp]=Dl(Qt),[Mn,Eb]=Ws(Qt,[Qp,jl]),Qa=jl(),em=O.forwardRef(kt(function(e,r){const{type:s,...n}=e,a=n,i=n;return d.jsx(Xa.Provider,{scope:e.__scopeAccordion,children:s==="multiple"?d.jsx(nm,{...i,ref:r}):d.jsx(sm,{...a,ref:r})})},"Accordion")),[Vl,tm]=Mn(Qt),[Kl,rm]=Mn(Qt,{collapsible:!1}),sm=O.forwardRef(kt(function(e,r){const{value:s,defaultValue:n,onValueChange:a=kt(()=>{},"onValueChange"),collapsible:i=!1,...o}=e,[l,c]=Nn({prop:s,defaultProp:n??"",onChange:a,caller:Qt});return d.jsx(Vl,{scope:e.__scopeAccordion,value:O.useMemo(()=>l?[l]:[],[l]),onItemOpen:c,onItemClose:O.useCallback(()=>i&&c(""),[i,c]),children:d.jsx(Kl,{scope:e.__scopeAccordion,collapsible:i,children:d.jsx(zl,{...o,ref:r})})})},"AccordionImplSingle")),nm=O.forwardRef(kt(function(e,r){const{value:s,defaultValue:n,onValueChange:a=kt(()=>{},"onValueChange"),...i}=e,[o,l]=Nn({prop:s,defaultProp:n??[],onChange:a,caller:Qt}),c=O.useCallback(p=>l((f=[])=>[...f,p]),[l]),u=O.useCallback(p=>l((f=[])=>f.filter(h=>h!==p)),[l]);return d.jsx(Vl,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:u,children:d.jsx(Kl,{scope:e.__scopeAccordion,collapsible:!0,children:d.jsx(zl,{...i,ref:r})})})},"AccordionImplMultiple")),[am,Fn]=Mn(Qt),zl=O.forwardRef(kt(function(e,r){const{__scopeAccordion:s,disabled:n,dir:a,orientation:i="vertical",...o}=e,l=O.useRef(null),c=lr(l,r),u=Xp(s),f=Bl(a)==="ltr",h=Va(e.onKeyDown,y=>{if(!Yp.includes(y.key))return;const g=y.target,v=u().filter(re=>!re.ref.current?.disabled),C=v.findIndex(re=>re.ref.current===g),_=v.length;if(C===-1)return;y.preventDefault();let S=C;const E=0,T=_-1,N=kt(()=>{S=C+1,S>T&&(S=E)},"moveNext"),L=kt(()=>{S=C-1,S<E&&(S=T)},"movePrev");switch(y.key){case"Home":S=E;break;case"End":S=T;break;case"ArrowRight":i==="horizontal"&&(f?N():L());break;case"ArrowDown":i==="vertical"&&N();break;case"ArrowLeft":i==="horizontal"&&(f?L():N());break;case"ArrowUp":i==="vertical"&&L();break}const ue=S%_;v[ue].ref.current?.focus()});return d.jsx(am,{scope:s,disabled:n,direction:a,orientation:i,children:d.jsx(Xa.Slot,{scope:s,children:d.jsx(hs.div,{...o,"data-orientation":i,ref:c,onKeyDown:n?void 0:h})})})},"AccordionImpl")),ei="AccordionItem",[im,ti]=Mn(ei),om=O.forwardRef(kt(function(e,r){const{__scopeAccordion:s,value:n,...a}=e,i=Fn(ei,s),o=tm(ei,s),l=Qa(s),c=Ha(),u=n&&o.value.includes(n)||!1,p=i.disabled||e.disabled;return d.jsx(im,{scope:s,open:u,disabled:p,triggerId:c,children:d.jsx(Nl,{"data-orientation":i.orientation,"data-state":ri(u),...l,...a,ref:r,disabled:p,open:u,onOpenChange:f=>{f?o.onItemOpen(n):o.onItemClose(n)}})})},"AccordionItem")),lm="AccordionHeader",cm=O.forwardRef(kt(function(e,r){const{__scopeAccordion:s,...n}=e,a=Fn(Qt,s),i=ti(lm,s);return d.jsx(hs.h3,{"data-orientation":a.orientation,"data-state":ri(i.open),"data-disabled":i.disabled?"":void 0,...n,ref:r})},"AccordionHeader")),Hl="AccordionTrigger",um=O.forwardRef(kt(function(e,r){const{__scopeAccordion:s,...n}=e,a=Fn(Qt,s),i=ti(Hl,s),o=rm(Hl,s),l=Qa(s);return d.jsx(Xa.ItemSlot,{scope:s,children:d.jsx(mp,{"aria-disabled":i.open&&!o.collapsible||void 0,"data-orientation":a.orientation,id:i.triggerId,...l,...n,ref:r})})},"AccordionTrigger")),dm="AccordionContent",hm=O.forwardRef(kt(function(e,r){const{__scopeAccordion:s,...n}=e,a=Fn(Qt,s),i=ti(dm,s),o=Qa(s);return d.jsx(gp,{role:"region","aria-labelledby":i.triggerId,"data-orientation":a.orientation,...o,...n,ref:r,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})},"AccordionContent"));function ri(t){return t?"open":"closed"}kt(ri,"getState");var fm=em,pm=om,mm=cm,Wl=um,ql=hm;const si=t=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[d.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),d.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),d.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),Gl=t=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[d.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),d.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),Un=t=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),d.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),gm=t=>d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:d.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),ym=t=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[d.jsx("path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"}),d.jsx("path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"}),d.jsx("path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"})]}),vm=t=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[d.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),d.jsx("circle",{cx:"9",cy:"7",r:"4"}),d.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),d.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),bm=t=>d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:d.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),wm=t=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[d.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),d.jsx("polyline",{points:"5 12 12 5 19 12"})]}),Jl=t=>d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:d.jsx("polyline",{points:"6 9 12 15 18 9"})}),Zl=t=>d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:d.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),xm=t=>d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[d.jsx("polyline",{points:"1 4 1 10 7 10"}),d.jsx("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),Yl=fm,ni=O.forwardRef(({className:t="",...e},r)=>d.jsx(pm,{ref:r,className:`border-b ${t}`,...e}));ni.displayName="AccordionItem";const ai=O.forwardRef(({className:t="",children:e,...r},s)=>d.jsx(mm,{className:"flex",children:d.jsxs(Wl,{ref:s,className:`flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180 ${t}`,...r,children:[e,d.jsx(Jl,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));ai.displayName=Wl.displayName;const ii=O.forwardRef(({className:t="",children:e,...r},s)=>d.jsx(ql,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:d.jsx("div",{className:`pb-4 pt-0 ${t}`,children:e})}));ii.displayName=ql.displayName;function hr({className:t,...e}){return d.jsx("div",{className:Pn("animate-pulse rounded-md bg-muted",t),...e})}const oi=new Map,Xl=1800*1e3;function _m(t,e,r){return`D1|${e}|svg|${t.day}-${t.month}-${t.year}-${t.hour}-${t.minute}-${t.lat}-${t.lon}-${t.tzone}|${r}`}function km(t){const e=oi.get(t);if(e&&Date.now()-e.timestamp<Xl)return e.svg;try{const r=sessionStorage.getItem(`kundali_${t}`);if(r){const s=JSON.parse(r);if(Date.now()-s.timestamp<Xl)return oi.set(t,s),s.svg;sessionStorage.removeItem(`kundali_${t}`)}}catch{}return null}function Sm(t,e){const r={svg:e,timestamp:Date.now()};oi.set(t,r);try{sessionStorage.setItem(`kundali_${t}`,JSON.stringify(r))}catch{}}function Cm(t){try{const r=new DOMParser().parseFromString(t,"image/svg+xml"),s=r.querySelector("svg");return s?(s.removeAttribute("width"),s.removeAttribute("height"),s.getAttribute("viewBox")||s.setAttribute("viewBox","0 0 350 350"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),s.setAttribute("style","width:100%;height:auto;display:block;"),new XMLSerializer().serializeToString(r)):t}catch(e){return console.error("[kundaliChart] SVG transform error:",e),t}}async function Em(t,e){const{birthDetails:r,chartType:s,language:n,signal:a}=e,i=_m(r,s,n),o=km(i);if(o)return o;const l=await t.functions.invoke("get-kundali-chart",{body:{...r,chartType:s,language:n}});if(a?.aborted)throw new DOMException("Aborted","AbortError");if(l.error)throw new Error(l.error.message||"Failed to fetch kundali chart");const c=l.data?.data?.svg;if(!c)throw new Error("No SVG data in response");const u=Cm(c);return Sm(i,u),u}function Tm({birthDetails:t,supabase:e,language:r,t:s}){const[n,a]=k.useState("North"),[i,o]=k.useState("idle"),[l,c]=k.useState(""),u=k.useRef(null),p=k.useRef(null),h=(r||"").toLowerCase().startsWith("hi")?"hi":"en",y=k.useCallback(async C=>{u.current&&u.current.abort();const _=new AbortController;u.current=_,o("loading");try{const S=await Em(e,{birthDetails:t,chartType:C,language:h,signal:_.signal});_.signal.aborted||(c(S),o("success"))}catch(S){if(S instanceof Error&&S.name==="AbortError")return;console.error("[KundaliCard] Fetch error:",S),_.signal.aborted||o("error")}},[t,e,h]);k.useEffect(()=>(y(n),()=>{u.current&&u.current.abort()}),[n,y]);const g=C=>{C!==n&&a(C)},v=()=>{y(n)};return d.jsxs(dr,{ref:p,className:"spiritual-glow border border-primary/10",children:[d.jsxs(Kr,{className:"pb-3",children:[d.jsx(zr,{className:"text-xl font-bold",children:s("drYourKundali")}),d.jsxs("div",{className:"flex gap-2 mt-3 pt-2",children:[d.jsx(Br,{type:"button",size:"sm",variant:n==="North"?"default":"outline",className:"rounded-full px-4",onClick:()=>g("North"),children:s("kundaliChartNorth")}),d.jsx(Br,{type:"button",size:"sm",variant:n==="South"?"default":"outline",className:"rounded-full px-4",onClick:()=>g("South"),children:s("kundaliChartSouth")})]})]}),d.jsx(Ar,{children:d.jsxs("div",{className:"w-full max-w-[360px] mx-auto",children:[i==="loading"&&d.jsx(hr,{className:"w-full aspect-square rounded-lg"}),i==="success"&&l&&d.jsx("div",{className:"w-full aspect-square",dangerouslySetInnerHTML:{__html:l}}),i==="error"&&d.jsxs("div",{className:"w-full aspect-square flex flex-col items-center justify-center bg-muted/30 rounded-lg border border-border",children:[d.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:s("kundaliChartLoadError")}),d.jsxs(Br,{type:"button",variant:"outline",size:"sm",onClick:v,className:"gap-2",children:[d.jsx(xm,{className:"w-4 h-4"}),s("kundaliChartRetry")]})]})]})})]})}const Ql=[{type:"kaal-sarp",detailKey:"kaalSarp",nameKey:"drKaalSarpName",descKey:"drKaalSarpDesc",impactKey:"drKaalSarpImpact",remediesKey:"drKaalSarpRemedies",benefitsKey:"drPujaBenefitsKaalSarp",icon:ym,summaryKey:"kaalSarp",severityKey:"kaalSarpSeverity"},{type:"pitra",detailKey:"pitra",nameKey:"drPitraName",descKey:"drPitraDesc",impactKey:"drPitraImpact",remediesKey:"drPitraRemedies",benefitsKey:"drPujaBenefitsPitra",icon:vm,summaryKey:"pitra",severityKey:"pitraSeverity"},{type:"shani",detailKey:"sadeSati",nameKey:"drSadeSatiName",descKey:"drSadeSatiDesc",impactKey:"drSadeSatiImpact",remediesKey:"drSadeSatiRemedies",benefitsKey:"drPujaBenefitsShani",icon:bm,summaryKey:"shaniSadeSati",severityKey:"sadeSatiSeverity"},{type:"mangal",detailKey:"mangal",nameKey:"drMangalName",descKey:"drMangalDesc",impactKey:"drMangalImpact",remediesKey:"drMangalRemedies",benefitsKey:"drPujaBenefitsMangal",icon:gm,summaryKey:"mangal",severityKey:"mangalSeverity"}];function Nt(t){if(!t)return!1;const e=t.toLowerCase();return e==="present"||e==="active"||e==="partial"||e==="suggested"}function Bn(t){return t?t.toLowerCase().includes("nullified"):!1}function ec(t,e){if(Array.isArray(t)){const r=t.find(a=>(a.name??a.type)===e);if(!r)return;const s=typeof r.remedies=="string"?r.remedies:Array.isArray(r.remedies)?r.remedies.join(`
122
+ आवेगपूर्ण निर्णयों और गरमागरम टकराव से बचाती है।`,drPujaRecommendation:"पूजा अनुशंसा",drNoPujaAvailable:"इस दोष के लिए कोई विशेष पूजा उपलब्ध नहीं है",doshaResults:{summary:"आपका दोष सारांश",detailedAnalysis:"विस्तृत विश्लेषण और उपचार",basedOnChart:"आपके जन्म चार्ट गणना के आधार पर",status:"स्थिति",severity:"गंभीरता",type:"प्रकार",phase:"चरण",explanation:"व्याख्या",placements:"स्थान",planetaryPositions:"ग्रहों की स्थिति",whyPresent:"क्यों उपस्थित है",whyAbsent:"क्यों अनुपस्थित है",impact:"प्रभाव",traditionalRemedies:"पारंपरिक उपचार",sriMandirRemedies:"श्री मंदिर की पेशकश किए गए उपचार",upcomingPujas:"आगामी पूजाएं उपलब्ध",disclaimer:"हम स्थापित ज्योतिषीय नियमों का पालन करते हैं, परंतु दोष की व्याख्या विभिन्न ज्योतिषियों में भिन्न हो सकती है। यदि आप अन्य दृष्टिकोण जानना चाहें तो किसी विश्वसनीय ज्योतिषी से परामर्श करें।",educationalTool:"⚠️ यह लोकप्रिय ज्योतिष नियमों पर आधारित एक शैक्षिक उपकरण है। विवेक के साथ व्याख्या करें।",statusValues:{present:"उपस्थित",absent:"अनुपस्थित",inactive:"निष्क्रिय",active:"सक्रिय",suggested:"सुझाया गया",someDoshasActive:"कुछ दोष सक्रिय",noDoshasFound:"कोई दोष नहीं मिला"},severityValues:{high:"उच्च",medium:"मध्यम",low:"निम्न"},mangal:{name:"मंगल दोष (मांगलिक)",description:"मंगल (मांगलिक/कुजा) दोष — कुछ घरों में मंगल से जुड़ा; पारंपरिक रूप से रिश्तों में घर्षण और निर्णायकता से जुड़ा है।",impact:"करीबी रिश्तों में घर्षण की अधिक संभावना, अधीरता/क्रोध के झटके, या विवाह या साझेदारी में देरी और रुक-रुक कर शुरुआत।",remedies:["प्रतिदिन हनुमान चालीसा का पाठ करें","मंगलवार को व्रत रखें","लाल दाल या कपड़े का दान करें","परामर्श के बाद मूंगा रत्न पहनें"]},kaalSarp:{name:"काल सर्प दोष",description:"काल सर्प दोष — सभी ग्रह राहु और केतु के बीच फंसे; अक्सर आंतरिक तनाव और परिवर्तन के पैटर्न के रूप में तैयार किया जाता है।",impact:"आंतरिक बेचैनी और आवधिक असफलताओं का एक पैटर्न; प्रयास के बावजूद योजनाएं अवरुद्ध या विलंबित हो सकती हैं, अतिरिक्त दृढ़ता की आवश्यकता है।",remedies:["प्रतिदिन 108 बार महा मृत्युंजय मंत्र का जाप करें","नियमित रूप से आवारा कुत्तों को खाना खिलाएं","सांप कल्याण या नाग मंदिरों में दान करें","घर में चांदी का नाग रखें"]},pitra:{name:"पितृ दोष",description:"पितृ (पितृ) दोष — 9वें घर और सूर्य-नोड लिंक के आसपास पारंपरिक संकेतक; कर्तव्यों, वंश और मार्गदर्शन से जुड़े।",impact:"परिवार या बड़ों के प्रति बार-बार कर्तव्य/दायित्व; अपराधबोध, विवाद, या विरासत के मुद्दे सामने आ सकते हैं और समाधान की मांग कर सकते हैं।",remedies:["तिथियों पर श्राद्ध समारोह करें","अमावस्या को जरूरतमंदों को भोजन कराएं","पितृ गायत्री मंत्र का पाठ करें","प्रतिदिन सुबह पूर्वजों को जल अर्पित करें"]},sadeSati:{name:"शनि साढ़े साती",description:"शनि साढ़े साती — जन्म चंद्रमा के पड़ोस में शनि का संक्रमण; अनुशासन और धैर्य पर जोर देने वाला 7.5 साल का चक्र।",impact:"भारी जिम्मेदारियां, धीमी प्रगति, और धैर्य की परीक्षा; गति के बजाय लगातार अनुशासन के साथ परिणाम आते हैं।",remedies:["शनिवार को शनि मंत्र का जाप करें","शनिवार को सरसों के तेल का दीपक जलाएं","तिल, कंबल जैसी काली वस्तुओं का दान करें","कौवों को खिलाएं और विकलांगों की सेवा करें"]},otherDoshas:{title:"अन्य दोष",rahuKetu:{name:"राहु–केतु / ग्रहण दोष",whatItIs:"सूर्य या चंद्रमा राहु/केतु के साथ निकट संरेखित (ग्रहण पैटर्न); अक्सर ग्रहण दोष कहा जाता है।",impact:"मिजाज में बदलाव, विचलन, और चिंता; प्रयास के बावजूद योजनाएं ग्रहण या विलंबित महसूस हो सकती हैं।",remedies:["माइंडफुलनेस और स्थिर दिनचर्या अपनाएं","प्राणायाम और श्वास अभ्यास करें","ग्रहण के दिनों में दान करें"]},shrapit:{name:"श्रापित दोष (शनि–राहु)",whatItIs:"शनि और राहु एक साथ या मजबूत पारस्परिक दृष्टि में।",impact:"बार-बार बाधाएं, कर्म विलंब, भारी कर्तव्य; प्रगति धीरे-धीरे आती है।",remedies:["शनिवार को अनुशासन और व्रत रखें","सेवा और विनम्रता का अभ्यास करें","शनि चालीसा का पाठ करें"]},guruChandal:{name:"गुरु चांडाल दोष (बृहस्पति–राहु/केतु)",whatItIs:"बृहस्पति राहु या केतु के साथ।",impact:"निर्णय/गुरु मुद्दे; वादे बनाम परिणाम गलत संरेखित हो सकते हैं।",remedies:["अच्छे गुरुओं के साथ अध्ययन करें","किताबें या शिक्षा वस्तुओं का दान करें","गुरु बीज मंत्र का जाप करें"]},punarphoo:{name:"पुनर्फू दोष (शनि–चंद्र)",whatItIs:"चंद्रमा शनि के साथ या तंग शनि प्रभाव के तहत।",impact:"चालू-बंद परिणाम, भावनात्मक भारीपन; धैर्य की मांग करने वाली देरी।",remedies:["सोमवार को शांत ध्यान करें","शिवलिंग पर जल चढ़ाएं","परामर्श के बाद मोती पहनें"]},kemadruma:{name:"केमद्रुम योग (चंद्र अलग-थलग)",whatItIs:"चंद्रमा बिना दोनों तरफ ग्रह पड़ोसियों के (शास्त्रीय अलगाव)।",impact:"अलगाव की भावनाएं; उतार-चढ़ाव समर्थन या वित्त।",remedies:["नियमित रूप से सामुदायिक सेवा करें","कृतज्ञता अनुष्ठान करें","बिस्तर के पास पानी से भरा चांदी का कटोरा रखें"]},gandmool:{name:"गण्डमूल दोष (विशिष्ट नक्षत्रों में चंद्र)",whatItIs:"अश्विनी, अश्लेषा, मघा, ज्येष्ठा, मूल, या रेवती में चंद्रमा।",impact:"संवेदनशील शुरुआत; सचेत संस्कारों और मार्गदर्शन की आवश्यकता है।",remedies:["परिवार के आशीर्वाद और बड़ों का मार्गदर्शन लें","सोमवार को चंद्र मंत्र का पाठ करें"]},kalathra:{name:"कलात्र दोष (7वां घर/साथी पीड़ा)",whatItIs:"7वें घर, इसके स्वामी, या शुक्र पर मजबूत अशुभ प्रभाव।",impact:"रिश्ते में घर्षण, देरी, या ब्रेक; साझेदारी सबक।",remedies:["शुक्रवार को सद्भाव अनुष्ठान करें","परामर्श के बाद हीरा या सफेद नीलम पहनें","सफेद वस्तुओं का दान करें"]},vishDaridra:{name:"विष/दरिद्र योग (मंगल–शनि कठोर संयोजन)",whatItIs:"मुख्य घरों में तंग मंगल–शनि संयोजन/दृष्टि।",impact:"रुक-रुक कर परिणाम; ड्राइव और संयम के बीच संघर्ष।",remedies:["संरचित और धैर्यवान प्रयास करें","हनुमान चालीसा का पाठ करें","संघर्ष से बचें और क्षमा का अभ्यास करें"]},ketuNaga:{name:"केतु/नाग (सर्प) दोष (गैर-काल सर्प)",whatItIs:"मुख्य घरों में केतु या पूर्ण काल सर्प पैटर्न के बिना चंद्र/शुक्र को पीड़ित करना।",impact:"अलगाव विषय; रिश्ते में ठंडापन बनाम आध्यात्मिक खिंचाव।",remedies:["जहां पारंपरिक हो नाग मंदिर जाएं","स्थिर भक्ति दिनचर्या बनाए रखें","चींटियों और पक्षियों को खिलाएं"]},navagraha:{name:"नवग्रह शांति (व्यापक सुझाव)",whatItIs:"सामान्य ग्रह तनाव जब कई छोटे झंडे एक साथ दिखाई देते हैं।",impact:"जीवन के क्षेत्रों में फैली बाधाएं; संतुलित शांति से लाभ।",remedies:["संतुलित अनुशासन बनाए रखें","घर पर नियमित सरल पूजा करें","नवग्रह मंदिर जाएं"]}}}}}};Re.use(bd).init({resources:Ed,lng:Cd,fallbackLng:"en",interpolation:{escapeValue:!1}}),Re.on("languageChanged",t=>{if(typeof window>"u")return;const{pathname:e,search:r,hash:s}=window.location,n=e.split("/").filter(Boolean);n[0]==="en"||n[0]==="hi"?n[0]=t:n.unshift(t);const i="/"+n.join("/")+r+s;i!==e+r+s&&(window.location.href=i)});var Td={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Ad=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),at=(t,e)=>{const r=k.forwardRef(({color:s="currentColor",size:n=24,strokeWidth:a=2,absoluteStrokeWidth:i,className:o="",children:l,...c},d)=>k.createElement("svg",{ref:d,...Td,width:n,height:n,stroke:s,strokeWidth:i?Number(a)*24/Number(n):a,className:["lucide",`lucide-${Ad(t)}`,o].join(" "),...c},[...e.map(([f,p])=>k.createElement(f,p)),...Array.isArray(l)?l:[l]]));return r.displayName=`${t}`,r};const Ls=at("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const jd=at("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);const Od=at("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const Pd=at("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Nd=at("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const Xi=at("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Rd=at("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);const Id=at("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const Dd=at("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);const Ld=at("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);const Qi=at("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const $d=at("MapPin",[["path",{d:"M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z",key:"2oe9fu"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);const Md=at("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);const Fd=at("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);const Ud=at("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);const Bd=at("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const Vd=at("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]),Dr=t=>{const{priority:e,fetchPriority:r,width:s,height:n,...a}=t;return k.createElement("img",{...a,width:s??1,height:n??1,decoding:"async",loading:a.loading??(e?"eager":"lazy"),...r&&{fetchPriority:r}})},Kd="https://srm-cdn.a4b.io/yoda/1770362904947.svg";function eo({analytics:t,isGlobal:e}={}){const{t:r}=Ds(),s=(Re.language||"").toLowerCase().startsWith("hi"),n=()=>{const a=s?"en":"hi";t?.trackLanguageClicked?.(a,!0),Re.changeLanguage(a),t?.trackLanguageChanged?.(a,!0)};return u.jsx("header",{className:"sticky top-0 z-50",style:{backgroundColor:"#FFFCEF"},children:u.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between max-w-2xl",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Dr,{src:Kd,alt:"Sri Mandir",width:32,height:32,loading:"eager",priority:!0}),u.jsxs("div",{className:"flex flex-col",children:[u.jsx("span",{style:{color:"#502D14",fontFamily:'"Plus Jakarta Sans", sans-serif',fontSize:"16px",fontWeight:600,lineHeight:"20px"},children:s?"श्री मंदिर":"Sri Mandir"}),u.jsx("span",{style:{color:"#502D14",fontFamily:'"Plus Jakarta Sans", sans-serif',fontSize:"10px",fontWeight:400,lineHeight:"16px"},children:s?"3 करोड़+ ऐप डाउनलोड":"3 crore+ app downloads"})]})]}),!e&&u.jsxs("button",{onClick:n,className:"flex items-center justify-center gap-1.5 py-2 rounded-lg text-white text-sm font-medium hover:opacity-90 transition-colors",style:{backgroundColor:"#E13A44",borderRadius:"8px",width:"100px"},"aria-label":s?"Switch to English":"हिंदी में बदलें",children:[u.jsx(Id,{className:"w-5 h-5"}),u.jsx("span",{children:s?"English":"हिंदी"})]})]})})}var $s=t=>t.type==="checkbox",vn=t=>t.type==="file",wr=t=>t instanceof Date,Ye=t=>t==null;const va=t=>typeof t=="object";var Ue=t=>!Ye(t)&&!Array.isArray(t)&&va(t)&&!wr(t),zd=t=>Ue(t)&&t.target?$s(t.target)?t.target.checked:vn(t.target)?t.target.files:t.target.value:t;const Hd=/[.[\]'"]/;var Qr=t=>t.split(Hd).filter(Boolean),Wd=(t,e)=>e.split(".").some((r,s,n)=>!isNaN(Number(r))&&t.has(n.slice(0,s).join("."))),bn=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Fe(t){if(t===null||typeof t!="object")return t;if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(bn&&(t instanceof Blob||e))return t;const r=Array.isArray(t);if(!r&&t.constructor!==Object)return t;const s=r?[]:Object.create(Object.getPrototypeOf(t));for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=Fe(t[n]));return s}const es={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},Mt={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ft={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},to="root",ba=["__proto__","constructor","prototype"],qd=/^\w*$/;var Lr=t=>qd.test(t),Pe=t=>t===void 0,V=(t,e,r)=>{if(!e||!Ue(t))return r;const s=Lr(e)?[e]:Qr(e);if(s.some(a=>ba.includes(a)))return r;const n=s.reduce((a,i)=>Ye(a)?void 0:a[i],t);return Pe(n)||n===t?Pe(t[e])?r:t[e]:n},Yt=t=>typeof t=="boolean",jt=t=>typeof t=="function",Ne=(t,e,r)=>{let s=-1;const n=Lr(e)?[e]:Qr(e),a=n.length,i=a-1;for(;++s<a;){const o=n[s];let l=r;if(s!==i){const c=t[o];l=Ue(c)||Array.isArray(c)?c:isNaN(+n[s+1])?{}:[]}if(ba.includes(o))return;t[o]=l,t=t[o]}};const Gd=k.createContext(null);Gd.displayName="HookFormControlContext";var Jd=(t,e,r,s=!0)=>{const n={};for(const a in t)Object.defineProperty(n,a,{get:()=>{const i=a;return e._proxyFormState[i]!==Mt.all&&(e._proxyFormState[i]=!s||Mt.all),t[i]}});return n};const Zd=bn?k.useLayoutEffect:k.useEffect;var Yd=t=>{const e=t.constructor&&t.constructor.prototype;return Ue(e)&&e.hasOwnProperty("isPrototypeOf")},wa=t=>Ye(t)||!va(t);const ro=(t,e)=>e.length===0&&!Array.isArray(t)&&!Yd(t);function Ut(t,e,r=new WeakMap){if(t===e)return!0;if(wa(t)||wa(e))return Object.is(t,e);if(wr(t)&&wr(e))return Object.is(t.getTime(),e.getTime());const s=Object.keys(t),n=Object.keys(e);if(s.length!==n.length)return!1;if(ro(t,s)||ro(e,n))return Object.is(t,e);if(!s.length&&Array.isArray(t)!==Array.isArray(e))return!1;const a=r.get(t);if(a&&a.has(e))return!0;if(a)a.add(e);else{const i=new WeakSet;i.add(e),r.set(t,i)}for(const i of s){const o=t[i];if(!(i in e))return!1;if(i!=="ref"){const l=e[i];if(wr(o)&&wr(l)||(Ue(o)||Array.isArray(o))&&(Ue(l)||Array.isArray(l))?!Ut(o,l,r):!Object.is(o,l))return!1}}return!0}function Xd(t){const e=k.useRef(!1),r=k.useRef(!1),s=k.useRef(void 0),n=k.useRef(0);n.current++,r.current;const a=k.useCallback((o,l,c)=>{if(o&&(e.current||r.current&&n.current>1)){const d=l();Ut(s.current,d)||c(d)}e.current=!0},[]),i=k.useCallback((o,l)=>{o&&(s.current=Fe(l()))},[]);return{resyncIfNeeded:a,snapshot:i}}var Xe=t=>typeof t=="string",Qd=(t,e,r,s,n)=>Xe(t)?(s&&e.watch.add(t),V(r,t,n)):Array.isArray(t)?t.map(a=>(s&&e.watch.add(a),V(r,a,V(n,a)))):(s&&(e.watchAll=!0),r),wn=t=>({isOnSubmit:!t||t===Mt.onSubmit,isOnBlur:t===Mt.onBlur,isOnChange:t===Mt.onChange,isOnAll:t===Mt.all,isOnTouch:t===Mt.onTouched}),xa=(t,e,r)=>{if(r)return!1;if(e.watchAll||e.watch.has(t))return!0;for(const s of e.watch)if(t.startsWith(s)&&t.charAt(s.length)===".")return!0;return!1};const Ms=(t,e,r,s)=>{for(const n of r||Object.keys(t)){if(n==="_f")continue;const a=r?V(t,n):t[n];if(a){const{_f:i}=a;if(i){if(i.refs&&i.refs[0]&&e(i.refs[0],n)&&!s)return!0;if(i.ref&&e(i.ref,i.name)&&!s)return!0;if(Ms(a,e))break}else if((Ue(a)||Array.isArray(a))&&Ms(a,e))break}}};var so=(t,e,r)=>{const s=V(t,r),n=Array.isArray(s)?s:[];return Ne(n,to,e[r]),Ne(t,r,n),t},it=t=>Ue(t)&&!Object.keys(t).length,xn=t=>{if(!bn)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},_a=t=>t.type==="radio",_n=t=>t instanceof RegExp,no=(t,e,r,s,n)=>e?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[s]:n||!0}}:{};const ao={value:!1,isValid:!1},io={value:!0,isValid:!0};var oo=t=>{if(!Array.isArray(t))return ao;if(t.length>1){const r=t.filter(s=>s&&s.checked&&!s.disabled).map(s=>s.value);return{value:r,isValid:!!r.length}}const e=t[0];return!e||!e.checked||e.disabled?ao:!e.attributes||!("value"in e.attributes)||Pe(e.value)||e.value===""?io:{value:e.value,isValid:!0}};const lo={isValid:!1,value:null};var co=t=>Array.isArray(t)?t.reduce((e,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:e,lo):lo;function uo(t,e,r="validate"){if(Xe(t)||Array.isArray(t)&&t.every(Xe)||Yt(t)&&!t)return{type:r,message:Xe(t)?t:"",ref:e}}var ts=t=>Ue(t)&&!_n(t)?t:{value:t,message:""},ho=async(t,e,r,s,n,a)=>{const{ref:i,refs:o,required:l,maxLength:c,minLength:d,min:f,max:p,pattern:h,validate:g,name:y,valueAsNumber:v,mount:C}=t._f,_=V(r,y);if(!C||e.has(y))return{};const S=o?o[0]:i,E=X=>{if(n&&S.reportValidity){const W=Yt(X)?"":X||"";o?o.forEach(oe=>oe.setCustomValidity(W)):S.setCustomValidity(W),S.reportValidity()}},T={},N=_a(i),L=$s(i),ue=N||L,re=(v||vn(i))&&Pe(i.value)&&Pe(_)||xn(i)&&i.value===""||_===""||Array.isArray(_)&&!_.length,je=no.bind(null,y,s,T),Se=(X,W,oe,ye=Ft.maxLength,ne=Ft.minLength)=>{const de=X?W:oe;T[y]={type:X?ye:ne,message:de,ref:i,...je(X?ye:ne,de)}};if(a?!Array.isArray(_)||!_.length:l&&(!ue&&(re||Ye(_))||Yt(_)&&!_||L&&!oo(o).isValid||N&&!co(o).isValid)){const{value:X,message:W}=Xe(l)?{value:!!l,message:l}:ts(l);if(X&&(T[y]={type:Ft.required,message:W,ref:S,...je(Ft.required,W)},!s))return E(W),T}if(!re&&(!Ye(f)||!Ye(p))){let X,W;const oe=ts(p),ye=ts(f);if(!Ye(_)&&!wr(_)&&!isNaN(_)){const ne=i.valueAsNumber||_&&+_;Ye(oe.value)||(X=ne>oe.value),Ye(ye.value)||(W=ne<ye.value)}else{const ne=i.valueAsDate||new Date(_),de=z=>new Date(new Date().toDateString()+" "+z),G=i.type=="time",j=i.type=="week";Xe(oe.value)&&_&&(X=G?de(_)>de(oe.value):j?_>oe.value:ne>new Date(oe.value)),Xe(ye.value)&&_&&(W=G?de(_)<de(ye.value):j?_<ye.value:ne<new Date(ye.value))}if((X||W)&&(Se(!!X,oe.message,ye.message,Ft.max,Ft.min),!s))return E(T[y].message),T}if((c||d)&&!re&&(Xe(_)||a&&Array.isArray(_))){const X=ts(c),W=ts(d),oe=!Ye(X.value)&&_.length>+X.value,ye=!Ye(W.value)&&_.length<+W.value;if((oe||ye)&&(Se(oe,X.message,W.message),!s))return E(T[y].message),T}if(h&&!re&&Xe(_)){const{value:X,message:W}=ts(h);if(_n(X)&&!_.match(X)&&(T[y]={type:Ft.pattern,message:W,ref:i,...je(Ft.pattern,W)},!s))return E(W),T}if(g){if(jt(g)){const X=await g(_,r),W=uo(X,S);if(W&&(T[y]={...W,...je(Ft.validate,W.message)},!s))return E(W.message),T}else if(Ue(g)){let X={};for(const W in g){if(!it(X)&&!s)break;const oe=uo(await g[W](_,r),S,W);oe&&(X={...oe,...je(W,oe.message)},E(oe.message),s&&(T[y]=X))}if(!it(X)&&(T[y]={ref:S,...X},!s))return T}}const F=T[y];return E(F?F.message:!0),T},kn=t=>Array.isArray(t)?t:[t],fo=t=>Array.isArray(t)?t.filter(Boolean):[];function eh(t,e){const r=e.length-1;let s=0;for(;s<r;){if(Ye(t)){t=void 0;break}t=t[e[s]],s++}return t}function th(t){for(const e in t)if(t.hasOwnProperty(e)&&!Pe(t[e]))return!1;return!0}function Ve(t,e){if(Xe(e)&&Object.prototype.hasOwnProperty.call(t,e))return delete t[e],t;const r=Array.isArray(e)?e:Lr(e)?[e]:Qr(e);if(r.some(i=>ba.includes(String(i))))return t;const s=r.length===1?t:eh(t,r),n=r.length-1,a=r[n];return s&&delete s[a],n!==0&&(Ue(s)&&it(s)||Array.isArray(s)&&th(s))&&Ve(t,r.slice(0,-1)),t}const rh=k.createContext(null);rh.displayName="HookFormContext";var po=()=>{let t=[];return{get observers(){return t},next:n=>{for(const a of t)a.next&&a.next(n)},subscribe:n=>(t.push(n),{unsubscribe:()=>{t=t.filter(a=>a!==n)}}),unsubscribe:()=>{t=[]}}};function mo(t,e){const r={};for(const s in t)if(t.hasOwnProperty(s)){const n=t[s],a=e[s];if(n&&Ue(n)&&a){const i=mo(n,a);Ue(i)&&(r[s]=i)}else t[s]&&(r[s]=a)}return r}const go=(t,e)=>t!==null&&va(t)&&Object.prototype.hasOwnProperty.call(t,e);var sh=(t,e)=>{if(!e)return!1;let r=t;for(const s of Lr(e)?[e]:Qr(e)){if(!go(r,s))return go(t,e);r=r[s]}return!0},yo=t=>t.type==="select-multiple",nh=t=>_a(t)||$s(t),ka=t=>xn(t)&&t.isConnected;function vo(t){return Array.isArray(t)||Ue(t)}function bo(t,e,r="",s=[]){for(const n in t){const a=r?`${r}.${n}`:n,i=t[n];vo(i)&&vo(V(e,a))?bo(i,e,a,s):s.push(a)}return s}var ah=t=>{for(const e in t)if(jt(t[e]))return!0;return!1};function wo(t){return Array.isArray(t)||Ue(t)&&!ah(t)}function xo(t){return!!(t&&"_f"in t)}function _o(t){return Array.isArray(t)?!t.some(e=>!Pe(e)):!Object.keys(t).length}function Sa(t,e){Array.isArray(t)?t[e]=void 0:delete t[e]}function Ca(t,e={},r){for(const s in t){const n=t[s],a=r&&r[s];wo(n)&&(!Array.isArray(n)||!xo(a))?(e[s]=Array.isArray(n)?[]:{},Ca(n,e[s],a),_o(e[s])&&Sa(e,s)):Pe(n)||(e[s]=!0)}return e}function $r(t,e,r,s){r||(r=Ca(e,{},s));for(const n in t){const a=t[n],i=s&&s[n];wo(a)&&(!Array.isArray(a)||!xo(i))?(Pe(e)||wa(r[n])?r[n]=Ca(a,Array.isArray(a)?[]:{},i):$r(a,Ye(e)?{}:e[n],r[n],i),_o(r[n])&&Sa(r,n)):Ut(a,e[n])?Sa(r,n):r[n]=!0}return r}var ih=(t,e)=>{const r=e.split("."),s=[];let n=r[0];for(let a=1;a<r.length;n+="."+r[a++])!isNaN(+r[a])&&t.has(n)&&s.push(`${n}.${r[a]}`);return s},ko=(t,{valueAsNumber:e,valueAsDate:r,setValueAs:s})=>Pe(t)?t:e?t===""?NaN:t&&+t:r&&Xe(t)?new Date(t):s?s(t):t;function So(t){const e=t.ref;return vn(e)?e.files:_a(e)?co(t.refs).value:yo(e)?[...e.selectedOptions].map(({value:r})=>r):$s(e)?oo(t.refs).value:ko(e.value,t)}var oh=(t,e,r,s)=>{const n={};for(const a of t){const i=V(e,a);i&&Ne(n,a,i._f)}return{criteriaMode:r,names:[...t],fields:n,shouldUseNativeValidation:s}},Fs=t=>Pe(t)?t:_n(t)?t.source:Ue(t)?_n(t.value)?t.value.source:t.value:t;const Co="AsyncFunction";var lh=t=>{if(!t||!t.validate)return!1;if(jt(t.validate))return t.validate.constructor.name===Co;if(Ue(t.validate)){for(const e in t.validate)if(t.validate[e].constructor.name===Co)return!0}return!1},ch=t=>t.mount&&(t.required||!Pe(t.required)&&t.required!==!1||!Pe(t.min)||!Pe(t.max)||!Pe(t.maxLength)||!Pe(t.minLength)||t.pattern||t.validate);function Eo(t,e,r){const s=V(t,r);if(s||Lr(r))return{error:s,name:r};const n=r.split(".");for(;n.length;){const a=n.join("."),i=V(e,a),o=V(t,a);if(i&&!Array.isArray(i)&&r!==a)return{name:r};if(o&&o.type)return{name:a,error:o};if(o&&o.root&&o.root.type)return{name:`${a}.root`,error:o.root};n.pop()}return{name:r}}var uh=(t,e,r,s)=>{r(t);const n=Object.keys(t).filter(a=>a!=="name");return!n.length||s&&n.length>=Object.keys(e).length||n.find(a=>e[a]===(!s||Mt.all))},dh=(t,e,r)=>!t||!e||t===e||kn(t).some(s=>s&&(r?s===e||s.startsWith(e+"."):s.startsWith(e)||e.startsWith(s))),hh=(t,e,r,s,n)=>n.isOnAll?!1:!r&&n.isOnTouch?!(e||t):(r?s.isOnBlur:n.isOnBlur)?!t:(r?s.isOnChange:n.isOnChange)?t:!0,fh=(t,e)=>{const r=V(t,e);!fo(r).length&&!r?.root&&Ve(t,e)};const ph={mode:Mt.onSubmit,reValidateMode:Mt.onChange,shouldFocusError:!0},Ea="form",mh=(t,e)=>{for(const r in t)r in e||delete t[r];Object.assign(t,e)},To={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function gh(t={}){let e={...ph,...t},r={...Fe(To),isLoading:jt(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1},s={},n=Ue(e.defaultValues)||Ue(e.values)?Fe(e.defaultValues||e.values)||{}:{},a=e.shouldUnregister?{}:Fe(n),i={action:!1,actionArrayLengths:new Map,mount:!1,watch:!1,keepIsValid:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const l={},c={};let d=0,f=wn(e.mode),p=wn(e.reValidateMode);const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},g={...h};let y={...g};const v={array:po(),state:po()};let C=0;const _=e.criteriaMode===Mt.all,S=(m,b)=>x=>{clearTimeout(c[m]),c[m]=setTimeout(b,x)},E=async m=>{if(!i.keepIsValid&&!e.disabled&&(g.isValid||y.isValid||m)){const b=++C;let x;e.resolver?(x=it((await oe()).errors),b===C&&T()):x=await de({fields:s,onlyCheckValid:!0,eventType:es.VALID}),b===C&&x!==r.isValid&&v.state.next({isValid:x})}},T=(m,b)=>{!e.disabled&&(g.isValidating||g.validatingFields||y.isValidating||y.validatingFields)&&((m||o.mount).forEach(x=>{x&&(b?Ne(r.validatingFields,x,b):Ve(r.validatingFields,x))}),v.state.next({validatingFields:r.validatingFields,isValidating:!it(r.validatingFields)}))},N=()=>{r.dirtyFields=$r(n,a,void 0,s)},L=(m,b=[],x,A,P=!0,I=!0)=>{if(A&&x&&!e.disabled){i.action=!0;const M=V(s,m);if(i.actionArrayLengths.has(m)||i.actionArrayLengths.set(m,Array.isArray(M)?M.length:0),I&&Array.isArray(M)){const ee=x(M,A.argA,A.argB);P&&Ne(s,m,ee)}const R=V(r.errors,m);if(I&&Array.isArray(R)){const ee=R.root,_e=x(R,A.argA,A.argB)||R;ee&&(_e.root=ee),P&&Ne(r.errors,m,_e),fh(r.errors,m)}const J=V(r.touchedFields,m);if((g.touchedFields||y.touchedFields)&&I&&Array.isArray(J)){const ee=x(J,A.argA,A.argB);P&&Ne(r.touchedFields,m,ee)}(g.dirtyFields||y.dirtyFields)&&N(),v.state.next({name:m,isDirty:j(m,b),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Ne(a,m,b)},ue=(m,b)=>{Ne(r.errors,m,b),r.errors={...r.errors},v.state.next({errors:r.errors})},re=m=>{r.errors=m,v.state.next({errors:r.errors,isValid:!1})},je=m=>{const b=Lr(m)?[m]:Qr(m);let x=a,A=n;for(let P=0;P<b.length-1;P++){const I=b[P];if(x=Ye(x)?x:x[I],A=Ye(A)?A:A[I],x===null&&A!==null)return!0}return!1},Se=m=>{if(!i.actionArrayLengths.size)return!1;const b=Lr(m)?[m]:Qr(m);let x=a,A="",P=-1,I=0;for(let M=0;M<b.length;M++){if(Ye(x))return!1;const R=b[M];if(A=A?`${A}.${R}`:R,Array.isArray(x)&&+R>=x.length)return P===-1?!1:M===P?+R<I:!0;i.actionArrayLengths.has(A)&&(P=M+1,I=i.actionArrayLengths.get(A)),x=x[R]}return!1},F=(m,b,x,A)=>{const P=V(s,m);if(P){if(je(m)||Se(m))return;const I=Pe(V(a,m)),M=V(a,m,Pe(x)?V(n,m):x);Pe(M)||A&&A.defaultChecked||b?Ne(a,m,b?M:So(P._f)):se(m,M),i.mount&&!i.action&&(E(),I&&r.isDirty&&(g.isDirty||y.isDirty)&&(j()||(r.isDirty=!1,v.state.next({...r}))),t.shouldUnregister&&I&&!Pe(V(a,m))&&xa(m,o)&&(i.watch=!0))}},X=(m,b,x,A,P)=>{let I=!1,M=!1;const R={name:m};if(!e.disabled||A===!0){if(!x||A){const J=Ut(V(n,m),b);(g.isDirty||y.isDirty)&&(M=r.isDirty,r.isDirty=R.isDirty=!J||j(),I=M!==R.isDirty),M=!!V(r.dirtyFields,m),J!==r.isDirty?mh(r.dirtyFields,$r(n,a,void 0,s)):J?Ve(r.dirtyFields,m):Ne(r.dirtyFields,m,!0),R.dirtyFields=r.dirtyFields,I=I||(g.dirtyFields||y.dirtyFields)&&M!==!J}if(x){const J=V(r.touchedFields,m);J||(Ne(r.touchedFields,m,x),R.touchedFields=r.touchedFields,I=I||(g.touchedFields||y.touchedFields)&&J!==x)}I&&P&&v.state.next(R)}return I?R:{}},W=(m,b,x,A)=>{const P=V(r.errors,m),I=(g.isValid||y.isValid)&&Yt(b)&&r.isValid!==b;if(e.delayError&&x?(l[m]=S(m,()=>ue(m,x)),l[m](e.delayError)):(clearTimeout(c[m]),delete l[m],x?Ne(r.errors,m,x):Ve(r.errors,m),r.errors={...r.errors}),(x?!Ut(P,x):P)||!it(A)||I){const M={...A,...I&&Yt(b)?{isValid:b}:{},errors:r.errors,name:m};v.state.next(M)}},oe=async m=>(T(m,!0),await e.resolver(a,e.context,oh(m||o.mount,s,e.criteriaMode,e.shouldUseNativeValidation))),ye=async m=>{const{errors:b}=await oe(m);if(T(m),m){for(const x of m){const A=V(b,x);A?o.array.has(x)&&Ue(A)&&!Object.keys(A).some(P=>!Number.isNaN(Number(P)))?so(r.errors,{[x]:A},x):Ne(r.errors,x,A):Ve(r.errors,x)}r.errors={...r.errors}}else r.errors=b;return b},ne=async({name:m,eventType:b})=>{if(t.validate){const x=await t.validate({formValues:a,formState:r,name:m,eventType:b});if(Ue(x))for(const A in x){const P=x[A];P&&rt(`${Ea}.${A}`,{message:Xe(P.message)?P.message:"",type:P.type||Ft.validate})}else Xe(x)||!x?rt(Ea,{message:x||"",type:Ft.validate}):sr(Ea);return x}return!0},de=async({fields:m,onlyCheckValid:b,name:x,eventType:A,context:P={valid:!0,runRootValidation:!1}})=>{if(t.validate&&(P.runRootValidation=!0,!await ne({name:x,eventType:A})&&(P.valid=!1,b)))return P.valid;for(const I in m){const M=m[I];if(M){const{_f:R,...J}=M;if(R){const ee=o.array.has(R.name),_e=M._f&&lh(M._f),Ze=g.validatingFields||g.isValidating||y.validatingFields||y.isValidating;_e&&Ze&&T([R.name],!0);const te=await ho(M,o.disabled,a,_,e.shouldUseNativeValidation&&!b,ee);if(_e&&Ze&&T([R.name]),te[R.name]&&(P.valid=!1,b)||(!b&&(V(te,R.name)?ee?so(r.errors,te,R.name):Ne(r.errors,R.name,te[R.name]):Ve(r.errors,R.name)),t.shouldUseNativeValidation&&te[R.name]))break}!it(J)&&await de({context:P,onlyCheckValid:b,fields:J,name:I,eventType:A})}}return P.valid},G=()=>{for(const m of o.unMount){const b=V(s,m);b&&(b._f.refs?b._f.refs.every(x=>!ka(x)):!ka(b._f.ref))&&Et(m)}o.unMount=new Set},j=(m,b)=>(m&&b&&Ne(a,m,b),!Ut(i.mount?a:n,n)),z=(m,b,x)=>Qd(m,o,{...i.mount?a:Pe(b)||Xe(m)?n:b},x,b),Z=m=>fo(V(i.mount?a:n,m,e.shouldUnregister?V(n,m,[]):[])),se=(m,b,x={},A=!1,P=!1,I=!1)=>{const M=V(s,m);let R=b;if(M){const J=M._f;J&&(!J.disabled&&Ne(a,m,ko(b,J)),R=xn(J.ref)&&Ye(b)?"":b,yo(J.ref)?[...J.ref.options].forEach(ee=>ee.selected=R.includes(ee.value)):J.refs?$s(J.ref)?J.refs.forEach(ee=>{(!ee.defaultChecked||!ee.disabled)&&(Array.isArray(R)?ee.checked=!!R.find(_e=>_e===ee.value):ee.checked=R===ee.value||!!R)}):J.refs.forEach(ee=>ee.checked=ee.value===R):vn(J.ref)?J.ref.value="":(J.ref.value=R,!J.ref.type&&!P&&!I&&v.state.next({name:m,values:A?a:Fe(a)})))}(x.shouldDirty||x.shouldTouch)&&X(m,R,x.shouldTouch,x.shouldDirty,!P),x.shouldValidate&&Le(m,{delayError:x.delayError})},he=(m,b,x,A=!1,P=!1,I=!1)=>{o.array.has(m)&&v.array.next({name:m,values:A?a:Fe(a)});for(const M in b){if(!b.hasOwnProperty(M))continue;const R=b[M],J=m+"."+M,ee=V(s,J);(o.array.has(m)||Ue(R)||ee&&!ee._f)&&!wr(R)?he(J,R,x,A,P,I):se(J,R,x,A,P,I)}},le=(m,b,x,A,P=!1)=>{const I=V(s,m),M=o.array.has(m),R=A?b:Fe(b),J=V(a,m),ee=Ut(J,R);if(ee||Ne(a,m,R),M)v.array.next({name:m,values:A?a:Fe(a)}),(g.isDirty||g.dirtyFields||y.isDirty||y.dirtyFields)&&x.shouldDirty&&(N(),P||v.state.next({name:m,dirtyFields:r.dirtyFields,isDirty:j(m,R)}));else{const _e=Array.isArray(R)&&!R.length||it(R),Ze=!ee&&!P;!I||I._f||Ye(R)||_e?se(m,R,x,A,P,Ze):he(m,R,x,A,P,Ze)}if(!ee&&!P){const _e=xa(m,o),Ze=A?a:Fe(a);if(v.state.next({..._e&&r,name:i.mount||_e?m:void 0,values:Ze}),!M)for(const te of ih(o.array,m))v.state.next({name:te,values:Ze})}},ae=(m,b,x={})=>le(m,b,x,!1),ce=(m,b={})=>{const x=jt(m)?m(a):m;if(!Ut(a,x)){a={...a,...x};for(const A of o.mount)sh(x,A)&&le(A,V(x,A),b,!0,!0);v.state.next({...r,name:void 0,type:void 0,...d?{values:a}:{}}),b.shouldValidate&&E()}},tt=async m=>{i.mount=!0;const b=m.target;let x=b.name,A=!0;const P=V(s,x),I=M=>{A=Number.isNaN(M)||wr(M)&&isNaN(M.getTime())||Ut(M,V(a,x,M))};if(P){let M,R;const J=b.type?So(P._f):zd(m),ee=m.type===es.BLUR||m.type===es.FOCUS_OUT,_e=!ch(P._f)&&!t.validate&&!e.resolver&&!V(r.errors,x)&&!P._f.deps,Ze=_e||hh(ee,V(r.touchedFields,x),r.isSubmitted,p,f),te=xa(x,o,ee);if(Ne(a,x,Fe(J)),ee){if(!b||!b.readOnly){P._f.onBlur&&P._f.onBlur(m);const $e=l[x];$e&&$e(0)}}else P._f.onChange&&P._f.onChange(m);const we=X(x,J,ee),ve=!it(we)||te;if(!ee&&v.state.next({name:x,type:m.type,...d?{values:Fe(a)}:{}}),Ze)return(!_e||!r.isValid)&&(g.isValid||y.isValid)&&(e.mode==="onBlur"?ee&&E():ee||E()),ve&&v.state.next({name:x,...te?{}:we});if(!e.resolver&&t.validate&&await ne({name:x,eventType:m.type}),!ee&&te&&v.state.next({...r}),e.resolver){const{errors:$e}=await oe([x]);if(T([x]),I(J),!A){!it(we)&&v.state.next(we);return}const st=Eo(r.errors,s,x),At=Eo($e,s,st.name||x);M=At.error,x=At.name,R=it($e)}else T([x],!0),M=(await ho(P,o.disabled,a,_,e.shouldUseNativeValidation))[x],T([x]),I(J),A&&(M?R=!1:(g.isValid||y.isValid)&&(R=await de({fields:s,onlyCheckValid:!0,name:x,eventType:m.type})));A&&(P._f.deps&&(!Array.isArray(P._f.deps)||P._f.deps.length>0)&&Le(P._f.deps),W(x,R,M,we))}},Je=(m,b)=>{if(V(r.errors,b)&&m.focus)return m.focus(),1},Le=async(m,b={})=>{let x,A;const P=kn(m);if(e.resolver){const I=await ye(Pe(m)?m:P);x=it(I),A=m?!P.some(M=>V(I,M)):x}else m?(A=(await Promise.all(P.map(async I=>{const M=V(s,I);return await de({fields:M&&M._f?{[I]:M}:M,eventType:es.TRIGGER})}))).every(Boolean),!(!A&&!r.isValid)&&E()):A=x=await de({fields:s,name:m,eventType:es.TRIGGER});if(b.delayError&&e.delayError&&Xe(m)){const I=V(r.errors,m);I?(Ve(r.errors,m),l[m]=S(m,()=>ue(m,I)),l[m](e.delayError)):(clearTimeout(c[m]),delete l[m])}if(b.shouldTouch)for(const I of m?P:o.mount)!o.array.has(I)&&Ne(r.touchedFields,I,!0);return v.state.next({...!Xe(m)||(g.isValid||y.isValid)&&x!==r.isValid?{}:{name:m},...e.resolver||!m?{isValid:x}:{},...b.shouldTouch&&(g.touchedFields||y.touchedFields)?{touchedFields:r.touchedFields}:{},errors:r.errors}),b.shouldFocus&&!A&&Ms(s,Je,m?P:o.mount),A},ut=(m,b)=>{let x={...i.mount?a:n};return b&&(x=mo(b.dirtyFields?r.dirtyFields:r.touchedFields,x)),Pe(m)?x:Xe(m)?V(x,m):m.map(A=>V(x,A))},qt=m=>Pe(m)?{...r.errors}:Xe(m)?V(r.errors,m):m.map(b=>V(r.errors,b)),lt=(m,b)=>{const x=b||r,A=V(x.errors,m);return{invalid:!!A,isDirty:!!V(x.dirtyFields,m),error:A,isValidating:!!V(r.validatingFields,m),isTouched:!!V(x.touchedFields,m)}},sr=m=>{const b=m?kn(m):void 0;b?.forEach(x=>Ve(r.errors,x)),b?b.forEach(x=>{v.state.next({name:x,errors:r.errors})}):(r.errors={},v.state.next({errors:r.errors}))},rt=(m,b,x)=>{const A=(V(s,m,{_f:{}})._f||{}).ref,P=V(r.errors,m)||{},{ref:I,message:M,type:R,...J}=P;Ne(r.errors,m,{...J,...b,ref:A}),v.state.next({name:m,errors:r.errors,isValid:!1}),x&&x.shouldFocus&&A&&A.focus&&A.focus()},Dt=(m,b)=>{if(jt(m)){d++;const{unsubscribe:x}=v.state.subscribe({next:P=>"values"in P&&m(P.values||z(void 0,b),P)});let A=!1;return{unsubscribe:()=>{A||(A=!0,d--,x())}}}return z(m,b,!0)},ht=m=>{var b;const x=!!(!((b=m.formState)===null||b===void 0)&&b.values);x&&d++;const{unsubscribe:A}=v.state.subscribe({next:I=>{if(dh(m.name,I.name,m.exact)&&uh(I,m.formState||g,br,m.reRenderRoot)){const M={...a};m.callback({values:M,...r,...I,defaultValues:n})}}});if(!x)return A;let P=!1;return()=>{P||(P=!0,d--,A())}},Gt=m=>(i.mount=!0,y={...y,...m.formState},ht({...m,formState:{...h,...m.formState}})),Et=(m,b={})=>{for(const x of m?kn(m):o.mount)o.mount.delete(x),o.array.delete(x),b.keepValue||(Ve(s,x),Ve(a,x)),!b.keepError&&Ve(r.errors,x),!b.keepDirty&&Ve(r.dirtyFields,x),!b.keepTouched&&Ve(r.touchedFields,x),!b.keepIsValidating&&Ve(r.validatingFields,x),!e.shouldUnregister&&!b.keepDefaultValue&&Ve(n,x);d&&v.state.next({values:Fe(a)}),v.state.next({...r,...b.keepDirty?{}:{isDirty:j()}}),!b.keepIsValid&&E()},Jt=({disabled:m,name:b})=>{if(Yt(m)&&i.mount||m||o.disabled.has(b)){const P=o.disabled.has(b)!==!!m;m?o.disabled.add(b):o.disabled.delete(b),P&&i.mount&&!i.action&&E()}},Tt=(m,b={})=>{let x=V(s,m);const A=Yt(b.disabled)||Yt(e.disabled),P=!o.registerName.has(m)&&x&&x._f&&!x._f.mount;return Ne(s,m,{...x||{},_f:{...x&&x._f?x._f:{ref:{name:m}},name:m,mount:!0,...b}}),o.mount.add(m),x&&!P?Jt({disabled:Yt(b.disabled)?b.disabled:e.disabled,name:m}):F(m,!0,b.value),{...A?{disabled:b.disabled||e.disabled}:{},...e.progressive?{required:!!b.required,min:Fs(b.min),max:Fs(b.max),minLength:Fs(b.minLength),maxLength:Fs(b.maxLength),pattern:Fs(b.pattern)}:{},name:m,onChange:tt,onBlur:tt,ref:I=>{if(I){o.registerName.add(m),Tt(m,b),o.registerName.delete(m),x=V(s,m);const M=Pe(I.value)&&I.querySelectorAll&&I.querySelectorAll("input,select,textarea")[0]||I,R=nh(M),J=x._f.refs||[];if(R?J.find(_e=>_e===M):M===x._f.ref)return;const ee={...x._f};R?(ee.refs=[...J.filter(ka),M,...Array.isArray(V(n,m))?[{}]:[]],ee.ref={type:M.type,name:m}):(ee.ref=M,delete ee.refs),Ne(s,m,{_f:ee}),F(m,!1,void 0,M)}else x=V(s,m,{}),x._f&&(x._f.mount=!1),(e.shouldUnregister||b.shouldUnregister)&&!(Wd(o.array,m)&&i.action)&&o.unMount.add(m)}}},Lt=()=>e.shouldFocusError&&!e.shouldUseNativeValidation&&Ms(s,Je,o.mount),ft=m=>{Yt(m)&&(v.state.next({disabled:m}),Ms(s,(b,x)=>{const A=V(s,x);A&&(b.disabled=A._f.disabled||m,Array.isArray(A._f.refs)&&A._f.refs.forEach(P=>{P.disabled=A._f.disabled||m}))},0,!1))},Pr=(m,b)=>async x=>{let A,P;x&&(x.preventDefault&&x.preventDefault(),x.persist&&x.persist());let I=Fe(a);if(v.state.next({isSubmitting:!0}),e.resolver){const{errors:M,values:R}=await oe();T(),r.errors=M,I=Fe(R)}else await de({fields:s,eventType:es.SUBMIT});if(o.disabled.size)for(const M of o.disabled)Ve(I,M);if(Ve(r.errors,to),it(r.errors)){v.state.next({errors:{}});try{A=await m(I,x)}catch(M){P=M}}else b&&await b({...r.errors},x),Lt(),setTimeout(Lt);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:it(r.errors)&&!P,submitCount:r.submitCount+1,errors:r.errors}),P)throw P;return A},Nr=(m,b={})=>{V(s,m)&&(Pe(b.defaultValue)?ae(m,Fe(V(n,m))):(ae(m,b.defaultValue),Ne(n,m,Fe(b.defaultValue))),b.keepTouched||Ve(r.touchedFields,m),b.keepDirty||(Ve(r.dirtyFields,m),r.isDirty=b.defaultValue?j(m,Fe(V(n,m))):j()),b.keepError||(Ve(r.errors,m),E()),v.state.next({...r}))},qe=(m,b={})=>{const x=m?Fe(m):n,A=Fe(x),P=it(m),I=A,M=s;if(b.keepDefaultValues||(n=x),!b.keepValues){if(b.keepDirtyValues){const R=new Set([...o.mount,...bo($r(n,a,void 0,M),r.dirtyFields)]);for(const J of R){const ee=V(r.dirtyFields,J),_e=V(a,J),Ze=V(I,J);ee&&!Pe(_e)?Ne(I,J,_e):!ee&&!Pe(Ze)&&ae(J,Ze)}}else{if(bn&&Pe(m))for(const R of o.mount){const J=V(s,R);if(J&&J._f){const ee=Array.isArray(J._f.refs)?J._f.refs[0]:J._f.ref;if(xn(ee)){const _e=ee.closest("form");if(_e){_e.reset();break}}}}if(b.keepFieldsRef)for(const R of o.mount)ae(R,V(I,R));else s={}}if(e.shouldUnregister){if(a=b.keepDefaultValues?Fe(n):{},b.keepFieldsRef)for(const R of o.mount)Ne(a,R,V(I,R))}else a=Fe(I);v.array.next({values:{...I}}),v.state.next({name:void 0,type:void 0,values:{...I}})}o={mount:b.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!g.isValid||!!b.keepIsValid||!!b.keepDirtyValues||!e.shouldUnregister&&!it(I),i.watch=!!e.shouldUnregister,i.keepIsValid=!!b.keepIsValid,i.action=!1,i.actionArrayLengths.clear(),b.keepErrors||(r.errors={}),v.state.next({submitCount:b.keepSubmitCount?r.submitCount:0,isDirty:P?!1:b.keepDirty?r.isDirty:b.keepValues?j():!!(b.keepDefaultValues&&!Ut(m,n)),isSubmitted:b.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:P?{}:b.keepDirtyValues?b.keepDefaultValues&&a?$r(n,a,void 0,M):r.dirtyFields:b.keepDefaultValues&&m?$r(n,m,void 0,M):b.keepDirty?r.dirtyFields:{},touchedFields:b.keepTouched?r.touchedFields:{},errors:b.keepErrors?r.errors:{},isSubmitSuccessful:b.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:n})},vt=(m,b)=>qe(jt(m)?m(a):m,{...e.resetOptions,...b}),Rr=(m,b={})=>{const x=V(s,m),A=x&&x._f;if(A){const P=A.refs?A.refs[0]:A.ref;P.focus&&setTimeout(()=>{P.focus(),b.shouldSelect&&jt(P.select)&&P.select()})}},br=m=>{const{name:b,type:x,values:A,...P}=m;r={...r,...P}};v.state.subscribe({next:br});const U={control:{register:Tt,unregister:Et,getFieldState:lt,handleSubmit:Pr,setError:rt,_subscribe:ht,_runSchema:oe,_updateIsValidating:T,_focusError:Lt,_getWatch:z,_getDirty:j,_setValid:E,_setFieldArray:L,_setDisabledField:Jt,_setErrors:re,_getFieldArray:Z,_reset:qe,_resetDefaultValues:()=>jt(e.defaultValues)&&e.defaultValues().then(m=>{vt(m,e.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:G,_disableForm:ft,_subjects:v,_proxyFormState:g,get _fields(){return s},get _formValues(){return a},get _state(){return i},set _state(m){i=m},get _defaultValues(){return n},get _names(){return o},set _names(m){o=m},get _formState(){return r},get _options(){return e},set _options(m){e={...e,...m},f=wn(e.mode),p=wn(e.reValidateMode)}},subscribe:Gt,trigger:Le,register:Tt,handleSubmit:Pr,watch:Dt,setValue:ae,setValues:ce,getValues:ut,getErrors:qt,reset:vt,resetField:Nr,resetDefaultValues:(m,b={})=>{if(n=Fe(m),!b.keepDirty){const x=$r(n,a,void 0,s);r.dirtyFields=x,r.isDirty=!it(x)}b.keepIsValid||E(),v.state.next({...r,defaultValues:n})},clearErrors:sr,unregister:Et,setError:rt,setFocus:Rr,getFieldState:lt};return{...U,formControl:U}}function yh(t={}){const e=k.useRef(void 0),r=k.useRef(void 0),s=k.useRef(t.formControl),[n,a]=k.useState(()=>({...Fe(To),isLoading:jt(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1,defaultValues:jt(t.defaultValues)?void 0:t.defaultValues}));if(!e.current||t.formControl&&s.current!==t.formControl)if(s.current=t.formControl,t.formControl)e.current={...t.formControl,formState:n},t.defaultValues&&!jt(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:c,...d}=gh(t);e.current={...d,formState:n}}const i=e.current.control;i._options=t;const{resyncIfNeeded:o,snapshot:l}=Xd();return Zd(()=>{const c=()=>({...i._formState,defaultValues:i._defaultValues});o(!0,c,a);const d=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState,defaultValues:i._defaultValues}),reRenderRoot:!0});return a(f=>({...f,isReady:!0})),i._formState.isReady=!0,()=>{d(),l(!0,c)}},[i,o,l]),k.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),k.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode)},[i,t.mode,t.reValidateMode]),k.useEffect(()=>{t.errors&&(i._setErrors(t.errors),i._focusError())},[i,t.errors]),k.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),k.useEffect(()=>{if(i._proxyFormState.isDirty){const c=i._getDirty();c!==n.isDirty&&i._subjects.state.next({isDirty:c})}},[i,n.isDirty]),k.useEffect(()=>{var c;t.values&&!Ut(t.values,r.current)?(i._reset(t.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((c=i._options.resetOptions)===null||c===void 0)&&c.keepIsValid||i._setValid(),r.current=t.values,a(d=>({...d}))):i._resetDefaultValues()},[i,t.values]),k.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),e.current.formState=k.useMemo(()=>Jd(n,i),[i,n]),e.current}const Ao=(t,e,r)=>{if(t&&"reportValidity"in t){const s=V(r,e);t.setCustomValidity(s&&s.message||""),t.reportValidity()}},jo=(t,e)=>{for(const r in e.fields){const s=e.fields[r];s&&s.ref&&"reportValidity"in s.ref?Ao(s.ref,r,t):s.refs&&s.refs.forEach(n=>Ao(n,r,t))}},vh=(t,e)=>{e.shouldUseNativeValidation&&jo(t,e);const r={};for(const s in t){const n=V(e.fields,s),a=Object.assign(t[s]||{},{ref:n&&n.ref});if(bh(e.names||Object.keys(t),s)){const i=Object.assign({},V(r,s));Ne(i,"root",a),Ne(r,s,i)}else Ne(r,s,a)}return r},bh=(t,e)=>t.some(r=>r.startsWith(e+"."));var wh=function(t,e){for(var r={};t.length;){var s=t[0],n=s.code,a=s.message,i=s.path.join(".");if(!r[i])if("unionErrors"in s){var o=s.unionErrors[0].errors[0];r[i]={message:o.message,type:o.code}}else r[i]={message:a,type:n};if("unionErrors"in s&&s.unionErrors.forEach(function(d){return d.errors.forEach(function(f){return t.push(f)})}),e){var l=r[i].types,c=l&&l[s.code];r[i]=no(i,e,r,n,c?[].concat(c,s.message):s.message)}t.shift()}return r},xh=function(t,e,r){return r===void 0&&(r={}),function(s,n,a){try{return Promise.resolve((function(i,o){try{var l=Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](s,e)).then(function(c){return a.shouldUseNativeValidation&&jo({},a),{errors:{},values:r.raw?s:c}})}catch(c){return o(c)}return l&&l.then?l.then(void 0,o):l})(0,function(i){if((function(o){return Array.isArray(o?.errors)})(i))return{values:{},errors:vh(wh(i.errors,!a.shouldUseNativeValidation&&a.criteriaMode==="all"),a)};throw i}))}catch(i){return Promise.reject(i)}}},Te;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},t.getValidEnumValues=n=>{const a=t.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return t.objectValues(i)},t.objectValues=n=>t.objectKeys(n).map(function(a){return n[a]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},t.find=(n,a)=>{for(const i of n)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=s,t.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(Te||(Te={}));var Oo;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Oo||(Oo={}));const Y=Te.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),xr=t=>{switch(typeof t){case"undefined":return Y.undefined;case"string":return Y.string;case"number":return Number.isNaN(t)?Y.nan:Y.number;case"boolean":return Y.boolean;case"function":return Y.function;case"bigint":return Y.bigint;case"symbol":return Y.symbol;case"object":return Array.isArray(t)?Y.array:t===null?Y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Y.promise:typeof Map<"u"&&t instanceof Map?Y.map:typeof Set<"u"&&t instanceof Set?Y.set:typeof Date<"u"&&t instanceof Date?Y.date:Y.object;default:return Y.unknown}},$=Te.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class or extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(r(i));else{let o=s,l=0;for(;l<i.path.length;){const c=i.path[l];l===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(r(i))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return n(this),s}static assert(e){if(!(e instanceof or))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Te.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},s=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];r[a]=r[a]||[],r[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:r}}get formErrors(){return this.flatten()}}or.create=t=>new or(t);const Ta=(t,e)=>{let r;switch(t.code){case $.invalid_type:t.received===Y.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case $.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Te.jsonStringifyReplacer)}`;break;case $.unrecognized_keys:r=`Unrecognized key(s) in object: ${Te.joinValues(t.keys,", ")}`;break;case $.invalid_union:r="Invalid input";break;case $.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Te.joinValues(t.options)}`;break;case $.invalid_enum_value:r=`Invalid enum value. Expected ${Te.joinValues(t.options)}, received '${t.received}'`;break;case $.invalid_arguments:r="Invalid function arguments";break;case $.invalid_return_type:r="Invalid function return type";break;case $.invalid_date:r="Invalid date";break;case $.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Te.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case $.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case $.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case $.custom:r="Invalid input";break;case $.invalid_intersection_types:r="Intersection results could not be merged";break;case $.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case $.not_finite:r="Number must be finite";break;default:r=e.defaultError,Te.assertNever(t)}return{message:r}};let _h=Ta;function kh(){return _h}const Sh=t=>{const{data:e,path:r,errorMaps:s,issueData:n}=t,a=[...r,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="";const l=s.filter(c=>!!c).slice().reverse();for(const c of l)o=c(i,{data:e,defaultError:o}).message;return{...n,path:a,message:o}};function K(t,e){const r=kh(),s=Sh({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ta?void 0:Ta].filter(n=>!!n)});t.common.issues.push(s)}class _t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const s=[];for(const n of r){if(n.status==="aborted")return me;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,r){const s=[];for(const n of r){const a=await n.key,i=await n.value;s.push({key:a,value:i})}return _t.mergeObjectSync(e,s)}static mergeObjectSync(e,r){const s={};for(const n of r){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return me;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const me=Object.freeze({status:"aborted"}),Us=t=>({status:"dirty",value:t}),Ot=t=>({status:"valid",value:t}),Po=t=>t.status==="aborted",No=t=>t.status==="dirty",rs=t=>t.status==="valid",Sn=t=>typeof Promise<"u"&&t instanceof Promise;var Q;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Q||(Q={}));class _r{constructor(e,r,s,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ro=(t,e)=>{if(rs(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new or(t.common.issues);return this._error=r,this._error}}};function xe(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:s,description:n}=t;if(e&&(r||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{const{message:l}=t;return i.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:n}}class Ee{get description(){return this._def.description}_getType(e){return xr(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:xr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new _t,ctx:{common:e.parent.common,data:e.data,parsedType:xr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Sn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const s=this.safeParse(e,r);if(s.success)return s.data;throw s.error}safeParse(e,r){const s={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xr(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Ro(s,n)}"~validate"(e){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xr(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:r});return rs(s)?{value:s.value}:{issues:r.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(s=>rs(s)?{value:s.value}:{issues:r.common.issues})}async parseAsync(e,r){const s=await this.safeParseAsync(e,r);if(s.success)return s.data;throw s.error}async safeParseAsync(e,r){const s={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xr(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(Sn(n)?n:Promise.resolve(n));return Ro(s,a)}refine(e,r){const s=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:$.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof r=="function"?r(s,n):r),!1))}_refinement(e){return new is({schema:this,typeName:ge.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Cr.create(this,this._def)}nullable(){return os.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xt.create(this)}promise(){return An.create(this,this._def)}or(e){return En.create([this,e],this._def)}and(e){return Tn.create(this,e,this._def)}transform(e){return new is({...xe(this._def),schema:this,typeName:ge.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Pa({...xe(this._def),innerType:this,defaultValue:r,typeName:ge.ZodDefault})}brand(){return new qh({typeName:ge.ZodBranded,type:this,...xe(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Na({...xe(this._def),innerType:this,catchValue:r,typeName:ge.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ra.create(this,e)}readonly(){return Ia.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ch=/^c[^\s-]{8,}$/i,Eh=/^[0-9a-z]+$/,Th=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ah=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,jh=/^[a-z0-9_-]{21}$/i,Oh=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ph=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Nh=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Rh="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Aa;const Ih=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Dh=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Lh=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,$h=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Mh=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Fh=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Io="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Uh=new RegExp(`^${Io}$`);function Do(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Bh(t){return new RegExp(`^${Do(t)}$`)}function Vh(t){let e=`${Io}T${Do(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Kh(t,e){return!!((e==="v4"||!e)&&Ih.test(t)||(e==="v6"||!e)&&Lh.test(t))}function zh(t,e){if(!Oh.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const s=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Hh(t,e){return!!((e==="v4"||!e)&&Dh.test(t)||(e==="v6"||!e)&&$h.test(t))}class kr extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Y.string){const a=this._getOrReturnCtx(e);return K(a,{code:$.invalid_type,expected:Y.string,received:a.parsedType}),me}const s=new _t;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:$.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:$.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?K(n,{code:$.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&K(n,{code:$.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Nh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"email",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Aa||(Aa=new RegExp(Rh,"u")),Aa.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"emoji",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Ah.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"uuid",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")jh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"nanoid",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Ch.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cuid",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Eh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cuid2",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Th.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"ulid",code:$.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),K(n,{validation:"url",code:$.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"regex",code:$.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Vh(a).test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Uh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Bh(a).test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{code:$.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Ph.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"duration",code:$.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Kh(e.data,a.version)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"ip",code:$.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?zh(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"jwt",code:$.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Hh(e.data,a.version)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"cidr",code:$.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Mh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"base64",code:$.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Fh.test(e.data)||(n=this._getOrReturnCtx(e,n),K(n,{validation:"base64url",code:$.invalid_string,message:a.message}),s.dirty()):Te.assertNever(a);return{status:s.value,value:e.data}}_regex(e,r,s){return this.refinement(n=>e.test(n),{validation:r,code:$.invalid_string,...Q.errToObj(s)})}_addCheck(e){return new kr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Q.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Q.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Q.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Q.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Q.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Q.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Q.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Q.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Q.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Q.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Q.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Q.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Q.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Q.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Q.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Q.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Q.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Q.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Q.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Q.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Q.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Q.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Q.errToObj(r)})}nonempty(e){return this.min(1,Q.errToObj(e))}trim(){return new kr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new kr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new kr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}kr.create=t=>new kr({checks:[],typeName:ge.ZodString,coerce:t?.coerce??!1,...xe(t)});function Wh(t,e){const r=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=r>s?r:s,a=Number.parseInt(t.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/10**n}class ss extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Y.number){const a=this._getOrReturnCtx(e);return K(a,{code:$.invalid_type,expected:Y.number,received:a.parsedType}),me}let s;const n=new _t;for(const a of this._def.checks)a.kind==="int"?Te.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{code:$.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Wh(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{code:$.not_finite,message:a.message}),n.dirty()):Te.assertNever(a);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,s,n){return new ss({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:s,message:Q.toString(n)}]})}_addCheck(e){return new ss({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Q.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Q.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Q.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Q.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Te.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(r===null||s.value>r)&&(r=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(r)&&Number.isFinite(e)}}ss.create=t=>new ss({checks:[],typeName:ge.ZodNumber,coerce:t?.coerce||!1,...xe(t)});class Bs extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Y.bigint)return this._getInvalidInput(e);let s;const n=new _t;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),K(s,{code:$.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):Te.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return K(r,{code:$.invalid_type,expected:Y.bigint,received:r.parsedType}),me}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,s,n){return new Bs({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:s,message:Q.toString(n)}]})}_addCheck(e){return new Bs({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Bs.create=t=>new Bs({checks:[],typeName:ge.ZodBigInt,coerce:t?.coerce??!1,...xe(t)});class ja extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Y.boolean){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.boolean,received:s.parsedType}),me}return Ot(e.data)}}ja.create=t=>new ja({typeName:ge.ZodBoolean,coerce:t?.coerce||!1,...xe(t)});class Cn extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Y.date){const a=this._getOrReturnCtx(e);return K(a,{code:$.invalid_type,expected:Y.date,received:a.parsedType}),me}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return K(a,{code:$.invalid_date}),me}const s=new _t;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:$.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),K(n,{code:$.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):Te.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Cn({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Q.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Q.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Cn.create=t=>new Cn({checks:[],coerce:t?.coerce||!1,typeName:ge.ZodDate,...xe(t)});class Lo extends Ee{_parse(e){if(this._getType(e)!==Y.symbol){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.symbol,received:s.parsedType}),me}return Ot(e.data)}}Lo.create=t=>new Lo({typeName:ge.ZodSymbol,...xe(t)});class $o extends Ee{_parse(e){if(this._getType(e)!==Y.undefined){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.undefined,received:s.parsedType}),me}return Ot(e.data)}}$o.create=t=>new $o({typeName:ge.ZodUndefined,...xe(t)});class Mo extends Ee{_parse(e){if(this._getType(e)!==Y.null){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.null,received:s.parsedType}),me}return Ot(e.data)}}Mo.create=t=>new Mo({typeName:ge.ZodNull,...xe(t)});class Fo extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return Ot(e.data)}}Fo.create=t=>new Fo({typeName:ge.ZodAny,...xe(t)});class Uo extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ot(e.data)}}Uo.create=t=>new Uo({typeName:ge.ZodUnknown,...xe(t)});class Sr extends Ee{_parse(e){const r=this._getOrReturnCtx(e);return K(r,{code:$.invalid_type,expected:Y.never,received:r.parsedType}),me}}Sr.create=t=>new Sr({typeName:ge.ZodNever,...xe(t)});class Bo extends Ee{_parse(e){if(this._getType(e)!==Y.undefined){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.void,received:s.parsedType}),me}return Ot(e.data)}}Bo.create=t=>new Bo({typeName:ge.ZodVoid,...xe(t)});class Xt extends Ee{_parse(e){const{ctx:r,status:s}=this._processInputParams(e),n=this._def;if(r.parsedType!==Y.array)return K(r,{code:$.invalid_type,expected:Y.array,received:r.parsedType}),me;if(n.exactLength!==null){const i=r.data.length>n.exactLength.value,o=r.data.length<n.exactLength.value;(i||o)&&(K(r,{code:i?$.too_big:$.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(K(r,{code:$.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(K(r,{code:$.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>n.type._parseAsync(new _r(r,i,r.path,o)))).then(i=>_t.mergeArray(s,i));const a=[...r.data].map((i,o)=>n.type._parseSync(new _r(r,i,r.path,o)));return _t.mergeArray(s,a)}get element(){return this._def.type}min(e,r){return new Xt({...this._def,minLength:{value:e,message:Q.toString(r)}})}max(e,r){return new Xt({...this._def,maxLength:{value:e,message:Q.toString(r)}})}length(e,r){return new Xt({...this._def,exactLength:{value:e,message:Q.toString(r)}})}nonempty(e){return this.min(1,e)}}Xt.create=(t,e)=>new Xt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ge.ZodArray,...xe(e)});function ns(t){if(t instanceof ze){const e={};for(const r in t.shape){const s=t.shape[r];e[r]=Cr.create(ns(s))}return new ze({...t._def,shape:()=>e})}else return t instanceof Xt?new Xt({...t._def,type:ns(t.element)}):t instanceof Cr?Cr.create(ns(t.unwrap())):t instanceof os?os.create(ns(t.unwrap())):t instanceof Mr?Mr.create(t.items.map(e=>ns(e))):t}class ze extends Ee{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=Te.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==Y.object){const c=this._getOrReturnCtx(e);return K(c,{code:$.invalid_type,expected:Y.object,received:c.parsedType}),me}const{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Sr&&this._def.unknownKeys==="strip"))for(const c in n.data)i.includes(c)||o.push(c);const l=[];for(const c of i){const d=a[c],f=n.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new _r(n,f,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Sr){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of o)l.push({key:{status:"valid",value:d},value:{status:"valid",value:n.data[d]}});else if(c==="strict")o.length>0&&(K(n,{code:$.unrecognized_keys,keys:o}),s.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of o){const f=n.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new _r(n,f,n.path,d)),alwaysSet:d in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const f=await d.key,p=await d.value;c.push({key:f,value:p,alwaysSet:d.alwaysSet})}return c}).then(c=>_t.mergeObjectSync(s,c)):_t.mergeObjectSync(s,l)}get shape(){return this._def.shape()}strict(e){return Q.errToObj,new ze({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,s)=>{const n=this._def.errorMap?.(r,s).message??s.defaultError;return r.code==="unrecognized_keys"?{message:Q.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new ze({...this._def,unknownKeys:"strip"})}passthrough(){return new ze({...this._def,unknownKeys:"passthrough"})}extend(e){return new ze({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ze({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ge.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new ze({...this._def,catchall:e})}pick(e){const r={};for(const s of Te.objectKeys(e))e[s]&&this.shape[s]&&(r[s]=this.shape[s]);return new ze({...this._def,shape:()=>r})}omit(e){const r={};for(const s of Te.objectKeys(this.shape))e[s]||(r[s]=this.shape[s]);return new ze({...this._def,shape:()=>r})}deepPartial(){return ns(this)}partial(e){const r={};for(const s of Te.objectKeys(this.shape)){const n=this.shape[s];e&&!e[s]?r[s]=n:r[s]=n.optional()}return new ze({...this._def,shape:()=>r})}required(e){const r={};for(const s of Te.objectKeys(this.shape))if(e&&!e[s])r[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof Cr;)a=a._def.innerType;r[s]=a}return new ze({...this._def,shape:()=>r})}keyof(){return Ho(Te.objectKeys(this.shape))}}ze.create=(t,e)=>new ze({shape:()=>t,unknownKeys:"strip",catchall:Sr.create(),typeName:ge.ZodObject,...xe(e)}),ze.strictCreate=(t,e)=>new ze({shape:()=>t,unknownKeys:"strict",catchall:Sr.create(),typeName:ge.ZodObject,...xe(e)}),ze.lazycreate=(t,e)=>new ze({shape:t,unknownKeys:"strip",catchall:Sr.create(),typeName:ge.ZodObject,...xe(e)});class En extends Ee{_parse(e){const{ctx:r}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new or(o.ctx.common.issues));return K(r,{code:$.invalid_union,unionErrors:i}),me}if(r.common.async)return Promise.all(s.map(async a=>{const i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const l of s){const c={...r,common:{...r.common,issues:[]},parent:null},d=l._parseSync({data:r.data,path:r.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!a&&(a={result:d,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(l=>new or(l));return K(r,{code:$.invalid_union,unionErrors:o}),me}}get options(){return this._def.options}}En.create=(t,e)=>new En({options:t,typeName:ge.ZodUnion,...xe(e)});function Oa(t,e){const r=xr(t),s=xr(e);if(t===e)return{valid:!0,data:t};if(r===Y.object&&s===Y.object){const n=Te.objectKeys(e),a=Te.objectKeys(t).filter(o=>n.indexOf(o)!==-1),i={...t,...e};for(const o of a){const l=Oa(t[o],e[o]);if(!l.valid)return{valid:!1};i[o]=l.data}return{valid:!0,data:i}}else if(r===Y.array&&s===Y.array){if(t.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<t.length;a++){const i=t[a],o=e[a],l=Oa(i,o);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return r===Y.date&&s===Y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Tn extends Ee{_parse(e){const{status:r,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Po(a)||Po(i))return me;const o=Oa(a.value,i.value);return o.valid?((No(a)||No(i))&&r.dirty(),{status:r.value,value:o.data}):(K(s,{code:$.invalid_intersection_types}),me)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}Tn.create=(t,e,r)=>new Tn({left:t,right:e,typeName:ge.ZodIntersection,...xe(r)});class Mr extends Ee{_parse(e){const{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==Y.array)return K(s,{code:$.invalid_type,expected:Y.array,received:s.parsedType}),me;if(s.data.length<this._def.items.length)return K(s,{code:$.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&s.data.length>this._def.items.length&&(K(s,{code:$.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...s.data].map((i,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new _r(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>_t.mergeArray(r,i)):_t.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Mr({...this._def,rest:e})}}Mr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Mr({items:t,typeName:ge.ZodTuple,rest:null,...xe(e)})};class Vo extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==Y.map)return K(s,{code:$.invalid_type,expected:Y.map,received:s.parsedType}),me;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,l],c)=>({key:n._parse(new _r(s,o,s.path,[c,"key"])),value:a._parse(new _r(s,l,s.path,[c,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of i){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return me;(c.status==="dirty"||d.status==="dirty")&&r.dirty(),o.set(c.value,d.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const l of i){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return me;(c.status==="dirty"||d.status==="dirty")&&r.dirty(),o.set(c.value,d.value)}return{status:r.value,value:o}}}}Vo.create=(t,e,r)=>new Vo({valueType:e,keyType:t,typeName:ge.ZodMap,...xe(r)});class Vs extends Ee{_parse(e){const{status:r,ctx:s}=this._processInputParams(e);if(s.parsedType!==Y.set)return K(s,{code:$.invalid_type,expected:Y.set,received:s.parsedType}),me;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(K(s,{code:$.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(K(s,{code:$.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());const a=this._def.valueType;function i(l){const c=new Set;for(const d of l){if(d.status==="aborted")return me;d.status==="dirty"&&r.dirty(),c.add(d.value)}return{status:r.value,value:c}}const o=[...s.data.values()].map((l,c)=>a._parse(new _r(s,l,s.path,c)));return s.common.async?Promise.all(o).then(l=>i(l)):i(o)}min(e,r){return new Vs({...this._def,minSize:{value:e,message:Q.toString(r)}})}max(e,r){return new Vs({...this._def,maxSize:{value:e,message:Q.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Vs.create=(t,e)=>new Vs({valueType:t,minSize:null,maxSize:null,typeName:ge.ZodSet,...xe(e)});class Ko extends Ee{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Ko.create=(t,e)=>new Ko({getter:t,typeName:ge.ZodLazy,...xe(e)});class zo extends Ee{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return K(r,{received:r.data,code:$.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}zo.create=(t,e)=>new zo({value:t,typeName:ge.ZodLiteral,...xe(e)});function Ho(t,e){return new as({values:t,typeName:ge.ZodEnum,...xe(e)})}class as extends Ee{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),s=this._def.values;return K(r,{expected:Te.joinValues(s),received:r.parsedType,code:$.invalid_type}),me}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),s=this._def.values;return K(r,{received:r.data,code:$.invalid_enum_value,options:s}),me}return Ot(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return as.create(e,{...this._def,...r})}exclude(e,r=this._def){return as.create(this.options.filter(s=>!e.includes(s)),{...this._def,...r})}}as.create=Ho;class Wo extends Ee{_parse(e){const r=Te.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==Y.string&&s.parsedType!==Y.number){const n=Te.objectValues(r);return K(s,{expected:Te.joinValues(n),received:s.parsedType,code:$.invalid_type}),me}if(this._cache||(this._cache=new Set(Te.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=Te.objectValues(r);return K(s,{received:s.data,code:$.invalid_enum_value,options:n}),me}return Ot(e.data)}get enum(){return this._def.values}}Wo.create=(t,e)=>new Wo({values:t,typeName:ge.ZodNativeEnum,...xe(e)});class An extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==Y.promise&&r.common.async===!1)return K(r,{code:$.invalid_type,expected:Y.promise,received:r.parsedType}),me;const s=r.parsedType===Y.promise?r.data:Promise.resolve(r.data);return Ot(s.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}}An.create=(t,e)=>new An({type:t,typeName:ge.ZodPromise,...xe(e)});class is extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ge.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{K(s,i),i.fatal?r.abort():r.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(r.value==="aborted")return me;const l=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return l.status==="aborted"?me:l.status==="dirty"||r.value==="dirty"?Us(l.value):l});{if(r.value==="aborted")return me;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?me:o.status==="dirty"||r.value==="dirty"?Us(o.value):o}}if(n.type==="refinement"){const i=o=>{const l=n.refinement(o,a);if(s.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?me:(o.status==="dirty"&&r.dirty(),i(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?me:(o.status==="dirty"&&r.dirty(),i(o.value).then(()=>({status:r.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!rs(i))return me;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>rs(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:r.value,value:o})):me);Te.assertNever(n)}}is.create=(t,e,r)=>new is({schema:t,typeName:ge.ZodEffects,effect:e,...xe(r)}),is.createWithPreprocess=(t,e,r)=>new is({schema:e,effect:{type:"preprocess",transform:t},typeName:ge.ZodEffects,...xe(r)});class Cr extends Ee{_parse(e){return this._getType(e)===Y.undefined?Ot(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Cr.create=(t,e)=>new Cr({innerType:t,typeName:ge.ZodOptional,...xe(e)});class os extends Ee{_parse(e){return this._getType(e)===Y.null?Ot(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}os.create=(t,e)=>new os({innerType:t,typeName:ge.ZodNullable,...xe(e)});class Pa extends Ee{_parse(e){const{ctx:r}=this._processInputParams(e);let s=r.data;return r.parsedType===Y.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Pa.create=(t,e)=>new Pa({innerType:t,typeName:ge.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...xe(e)});class Na extends Ee{_parse(e){const{ctx:r}=this._processInputParams(e),s={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Sn(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new or(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new or(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Na.create=(t,e)=>new Na({innerType:t,typeName:ge.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...xe(e)});class qo extends Ee{_parse(e){if(this._getType(e)!==Y.nan){const s=this._getOrReturnCtx(e);return K(s,{code:$.invalid_type,expected:Y.nan,received:s.parsedType}),me}return{status:"valid",value:e.data}}}qo.create=t=>new qo({typeName:ge.ZodNaN,...xe(t)});class qh extends Ee{_parse(e){const{ctx:r}=this._processInputParams(e),s=r.data;return this._def.type._parse({data:s,path:r.path,parent:r})}unwrap(){return this._def.type}}class Ra extends Ee{_parse(e){const{status:r,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?me:a.status==="dirty"?(r.dirty(),Us(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?me:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,r){return new Ra({in:e,out:r,typeName:ge.ZodPipeline})}}class Ia extends Ee{_parse(e){const r=this._def.innerType._parse(e),s=n=>(rs(n)&&(n.value=Object.freeze(n.value)),n);return Sn(r)?r.then(n=>s(n)):s(r)}unwrap(){return this._def.innerType}}Ia.create=(t,e)=>new Ia({innerType:t,typeName:ge.ZodReadonly,...xe(e)});var ge;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ge||(ge={}));const Fr=kr.create,Go=ss.create,Gh=ja.create;Sr.create,Xt.create;const Jh=ze.create;En.create,Tn.create,Mr.create;const Jo=as.create;An.create,Cr.create,os.create;var Zh=Object.defineProperty,Da=(t,e)=>Zh(t,"name",{value:e,configurable:!0});function La(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Da(La,"setRef");function Zo(...t){return e=>{let r=!1;const s=t.map(n=>{const a=La(n,e);return!r&&typeof a=="function"&&(r=!0),a});if(r)return()=>{for(let n=0;n<s.length;n++){const a=s[n];typeof a=="function"?a():La(t[n],null)}}}}Da(Zo,"composeRefs");function lr(...t){return O.useCallback(Zo(...t),t)}Da(lr,"useComposedRefs");var Yh=Object.defineProperty,Bt=(t,e)=>Yh(t,"name",{value:e,configurable:!0});function Ur(t){const e=O.forwardRef((r,s)=>{let{children:n,...a}=r,i=null,o=!1;const l=[];$a(n)&&typeof jn=="function"&&(n=jn(n._payload)),O.Children.forEach(n,p=>{if(el(p)){o=!0;const h=p;let g="child"in h.props?h.props.child:h.props.children;$a(g)&&typeof jn=="function"&&(g=jn(g._payload)),i=ef(h,g),l.push(i?.props?.children)}else l.push(p)}),i?i=O.cloneElement(i,void 0,l):!o&&O.Children.count(n)===1&&O.isValidElement(n)&&(i=n);const c=i?Qo(i):void 0,d=lr(s,c);if(!i){if(n||n===0)throw new Error(o?sf(t):rf(t));return n}const f=Xo(a,i.props??{});return i.type!==O.Fragment&&(f.ref=s?d:c),O.cloneElement(i,f)});return e.displayName=`${t}.Slot`,e}Bt(Ur,"createSlot");var Xh=Ur("Slot"),Yo=Symbol.for("radix.slottable");function Qh(t){const e=Bt(r=>"child"in r?r.children(r.child):r.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=Yo,e}Bt(Qh,"createSlottable");var ef=Bt((t,e)=>{if("child"in t.props){const r=t.props.child;return O.isValidElement(r)?O.cloneElement(r,void 0,t.props.children(r.props.children)):null}return O.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function Xo(t,e){const r={...e};for(const s in e){const n=t[s],a=e[s];/^on[A-Z]/.test(s)?n&&a?r[s]=(...o)=>{const l=a(...o);return n(...o),l}:n&&(r[s]=n):s==="style"?r[s]={...n,...a}:s==="className"&&(r[s]=[n,a].filter(Boolean).join(" "))}return{...t,...r}}Bt(Xo,"mergeProps");function Qo(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}Bt(Qo,"getElementRef");function el(t){return O.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Yo}Bt(el,"isSlottable");var tf=Symbol.for("react.lazy");function $a(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===tf&&"_payload"in t&&tl(t._payload)}Bt($a,"isLazyComponent");function tl(t){return typeof t=="object"&&t!==null&&"then"in t}Bt(tl,"isPromiseLike");var rf=Bt(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),sf=Bt(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),jn=O[" use ".trim().toString()];function rl(t){var e,r,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(e=0;e<n;e++)t[e]&&(r=rl(t[e]))&&(s&&(s+=" "),s+=r)}else for(r in t)t[r]&&(s&&(s+=" "),s+=r);return s}function sl(){for(var t,e,r=0,s="",n=arguments.length;r<n;r++)(t=arguments[r])&&(e=rl(t))&&(s&&(s+=" "),s+=e);return s}const nl=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,al=sl,il=(t,e)=>r=>{var s;if(e?.variants==null)return al(t,r?.class,r?.className);const{variants:n,defaultVariants:a}=e,i=Object.keys(n).map(c=>{const d=r?.[c],f=a?.[c];if(d===null)return null;const p=nl(d)||nl(f);return n[c][p]}),o=r&&Object.entries(r).reduce((c,d)=>{let[f,p]=d;return p===void 0||(c[f]=p),c},{}),l=e==null||(s=e.compoundVariants)===null||s===void 0?void 0:s.reduce((c,d)=>{let{class:f,className:p,...h}=d;return Object.entries(h).every(g=>{let[y,v]=g;return Array.isArray(v)?v.includes({...a,...o}[y]):{...a,...o}[y]===v})?[...c,f,p]:c},[]);return al(t,i,l,r?.class,r?.className)},Ma="-",nf=t=>{const e=of(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:s}=t;return{getClassGroupId:i=>{const o=i.split(Ma);return o[0]===""&&o.length!==1&&o.shift(),ol(o,e)||af(i)},getConflictingClassGroupIds:(i,o)=>{const l=r[i]||[];return o&&s[i]?[...l,...s[i]]:l}}},ol=(t,e)=>{if(t.length===0)return e.classGroupId;const r=t[0],s=e.nextPart.get(r),n=s?ol(t.slice(1),s):void 0;if(n)return n;if(e.validators.length===0)return;const a=t.join(Ma);return e.validators.find(({validator:i})=>i(a))?.classGroupId},ll=/^\[(.+)\]$/,af=t=>{if(ll.test(t)){const e=ll.exec(t)[1],r=e?.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},of=t=>{const{theme:e,prefix:r}=t,s={nextPart:new Map,validators:[]};return cf(Object.entries(t.classGroups),r).forEach(([a,i])=>{Fa(i,s,a,e)}),s},Fa=(t,e,r,s)=>{t.forEach(n=>{if(typeof n=="string"){const a=n===""?e:cl(e,n);a.classGroupId=r;return}if(typeof n=="function"){if(lf(n)){Fa(n(s),e,r,s);return}e.validators.push({validator:n,classGroupId:r});return}Object.entries(n).forEach(([a,i])=>{Fa(i,cl(e,a),r,s)})})},cl=(t,e)=>{let r=t;return e.split(Ma).forEach(s=>{r.nextPart.has(s)||r.nextPart.set(s,{nextPart:new Map,validators:[]}),r=r.nextPart.get(s)}),r},lf=t=>t.isThemeGetter,cf=(t,e)=>e?t.map(([r,s])=>{const n=s.map(a=>typeof a=="string"?e+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([i,o])=>[e+i,o])):a);return[r,n]}):t,uf=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,s=new Map;const n=(a,i)=>{r.set(a,i),e++,e>t&&(e=0,s=r,r=new Map)};return{get(a){let i=r.get(a);if(i!==void 0)return i;if((i=s.get(a))!==void 0)return n(a,i),i},set(a,i){r.has(a)?r.set(a,i):n(a,i)}}},ul="!",df=t=>{const{separator:e,experimentalParseClassName:r}=t,s=e.length===1,n=e[0],a=e.length,i=o=>{const l=[];let c=0,d=0,f;for(let v=0;v<o.length;v++){let C=o[v];if(c===0){if(C===n&&(s||o.slice(v,v+a)===e)){l.push(o.slice(d,v)),d=v+a;continue}if(C==="/"){f=v;continue}}C==="["?c++:C==="]"&&c--}const p=l.length===0?o:o.substring(d),h=p.startsWith(ul),g=h?p.substring(1):p,y=f&&f>d?f-d:void 0;return{modifiers:l,hasImportantModifier:h,baseClassName:g,maybePostfixModifierPosition:y}};return r?o=>r({className:o,parseClassName:i}):i},hf=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(s=>{s[0]==="["?(e.push(...r.sort(),s),r=[]):r.push(s)}),e.push(...r.sort()),e},ff=t=>({cache:uf(t.cacheSize),parseClassName:df(t),...nf(t)}),pf=/\s+/,mf=(t,e)=>{const{parseClassName:r,getClassGroupId:s,getConflictingClassGroupIds:n}=e,a=[],i=t.trim().split(pf);let o="";for(let l=i.length-1;l>=0;l-=1){const c=i[l],{modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:h}=r(c);let g=!!h,y=s(g?p.substring(0,h):p);if(!y){if(!g){o=c+(o.length>0?" "+o:o);continue}if(y=s(p),!y){o=c+(o.length>0?" "+o:o);continue}g=!1}const v=hf(d).join(":"),C=f?v+ul:v,_=C+y;if(a.includes(_))continue;a.push(_);const S=n(y,g);for(let E=0;E<S.length;++E){const T=S[E];a.push(C+T)}o=c+(o.length>0?" "+o:o)}return o};function gf(){let t=0,e,r,s="";for(;t<arguments.length;)(e=arguments[t++])&&(r=dl(e))&&(s&&(s+=" "),s+=r);return s}const dl=t=>{if(typeof t=="string")return t;let e,r="";for(let s=0;s<t.length;s++)t[s]&&(e=dl(t[s]))&&(r&&(r+=" "),r+=e);return r};function yf(t,...e){let r,s,n,a=i;function i(l){const c=e.reduce((d,f)=>f(d),t());return r=ff(c),s=r.cache.get,n=r.cache.set,a=o,o(l)}function o(l){const c=s(l);if(c)return c;const d=mf(l,r);return n(l,d),d}return function(){return a(gf.apply(null,arguments))}}const Me=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},hl=/^\[(?:([a-z-]+):)?(.+)\]$/i,vf=/^\d+\/\d+$/,bf=new Set(["px","full","screen"]),wf=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,xf=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,_f=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,kf=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Sf=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,cr=t=>ls(t)||bf.has(t)||vf.test(t),Er=t=>cs(t,"length",Nf),ls=t=>!!t&&!Number.isNaN(Number(t)),Ua=t=>cs(t,"number",ls),Ks=t=>!!t&&Number.isInteger(Number(t)),Cf=t=>t.endsWith("%")&&ls(t.slice(0,-1)),be=t=>hl.test(t),Tr=t=>wf.test(t),Ef=new Set(["length","size","percentage"]),Tf=t=>cs(t,Ef,fl),Af=t=>cs(t,"position",fl),jf=new Set(["image","url"]),Of=t=>cs(t,jf,If),Pf=t=>cs(t,"",Rf),zs=()=>!0,cs=(t,e,r)=>{const s=hl.exec(t);return s?s[1]?typeof e=="string"?s[1]===e:e.has(s[1]):r(s[2]):!1},Nf=t=>xf.test(t)&&!_f.test(t),fl=()=>!1,Rf=t=>kf.test(t),If=t=>Sf.test(t),Df=yf(()=>{const t=Me("colors"),e=Me("spacing"),r=Me("blur"),s=Me("brightness"),n=Me("borderColor"),a=Me("borderRadius"),i=Me("borderSpacing"),o=Me("borderWidth"),l=Me("contrast"),c=Me("grayscale"),d=Me("hueRotate"),f=Me("invert"),p=Me("gap"),h=Me("gradientColorStops"),g=Me("gradientColorStopPositions"),y=Me("inset"),v=Me("margin"),C=Me("opacity"),_=Me("padding"),S=Me("saturate"),E=Me("scale"),T=Me("sepia"),N=Me("skew"),L=Me("space"),ue=Me("translate"),re=()=>["auto","contain","none"],je=()=>["auto","hidden","clip","visible","scroll"],Se=()=>["auto",be,e],F=()=>[be,e],X=()=>["",cr,Er],W=()=>["auto",ls,be],oe=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ye=()=>["solid","dashed","dotted","double","none"],ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],de=()=>["start","end","center","between","around","evenly","stretch"],G=()=>["","0",be],j=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[ls,be];return{cacheSize:500,separator:":",theme:{colors:[zs],spacing:[cr,Er],blur:["none","",Tr,be],brightness:z(),borderColor:[t],borderRadius:["none","","full",Tr,be],borderSpacing:F(),borderWidth:X(),contrast:z(),grayscale:G(),hueRotate:z(),invert:G(),gap:F(),gradientColorStops:[t],gradientColorStopPositions:[Cf,Er],inset:Se(),margin:Se(),opacity:z(),padding:F(),saturate:z(),scale:z(),sepia:G(),skew:z(),space:F(),translate:F()},classGroups:{aspect:[{aspect:["auto","square","video",be]}],container:["container"],columns:[{columns:[Tr]}],"break-after":[{"break-after":j()}],"break-before":[{"break-before":j()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...oe(),be]}],overflow:[{overflow:je()}],"overflow-x":[{"overflow-x":je()}],"overflow-y":[{"overflow-y":je()}],overscroll:[{overscroll:re()}],"overscroll-x":[{"overscroll-x":re()}],"overscroll-y":[{"overscroll-y":re()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Ks,be]}],basis:[{basis:Se()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",be]}],grow:[{grow:G()}],shrink:[{shrink:G()}],order:[{order:["first","last","none",Ks,be]}],"grid-cols":[{"grid-cols":[zs]}],"col-start-end":[{col:["auto",{span:["full",Ks,be]},be]}],"col-start":[{"col-start":W()}],"col-end":[{"col-end":W()}],"grid-rows":[{"grid-rows":[zs]}],"row-start-end":[{row:["auto",{span:[Ks,be]},be]}],"row-start":[{"row-start":W()}],"row-end":[{"row-end":W()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",be]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",be]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...de()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...de(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...de(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[_]}],px:[{px:[_]}],py:[{py:[_]}],ps:[{ps:[_]}],pe:[{pe:[_]}],pt:[{pt:[_]}],pr:[{pr:[_]}],pb:[{pb:[_]}],pl:[{pl:[_]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[L]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[L]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",be,e]}],"min-w":[{"min-w":[be,e,"min","max","fit"]}],"max-w":[{"max-w":[be,e,"none","full","min","max","fit","prose",{screen:[Tr]},Tr]}],h:[{h:[be,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[be,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[be,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[be,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Tr,Er]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Ua]}],"font-family":[{font:[zs]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",be]}],"line-clamp":[{"line-clamp":["none",ls,Ua]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",cr,be]}],"list-image":[{"list-image":["none",be]}],"list-style-type":[{list:["none","disc","decimal",be]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[C]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[C]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ye(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",cr,Er]}],"underline-offset":[{"underline-offset":["auto",cr,be]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",be]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",be]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[C]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...oe(),Af]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Tf]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Of]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[C]}],"border-style":[{border:[...ye(),"hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[C]}],"divide-style":[{divide:ye()}],"border-color":[{border:[n]}],"border-color-x":[{"border-x":[n]}],"border-color-y":[{"border-y":[n]}],"border-color-s":[{"border-s":[n]}],"border-color-e":[{"border-e":[n]}],"border-color-t":[{"border-t":[n]}],"border-color-r":[{"border-r":[n]}],"border-color-b":[{"border-b":[n]}],"border-color-l":[{"border-l":[n]}],"divide-color":[{divide:[n]}],"outline-style":[{outline:["",...ye()]}],"outline-offset":[{"outline-offset":[cr,be]}],"outline-w":[{outline:[cr,Er]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[C]}],"ring-offset-w":[{"ring-offset":[cr,Er]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Tr,Pf]}],"shadow-color":[{shadow:[zs]}],opacity:[{opacity:[C]}],"mix-blend":[{"mix-blend":[...ne(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ne()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[s]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Tr,be]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[f]}],saturate:[{saturate:[S]}],sepia:[{sepia:[T]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[C]}],"backdrop-saturate":[{"backdrop-saturate":[S]}],"backdrop-sepia":[{"backdrop-sepia":[T]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",be]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",be]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",be]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[E]}],"scale-x":[{"scale-x":[E]}],"scale-y":[{"scale-y":[E]}],rotate:[{rotate:[Ks,be]}],"translate-x":[{"translate-x":[ue]}],"translate-y":[{"translate-y":[ue]}],"skew-x":[{"skew-x":[N]}],"skew-y":[{"skew-y":[N]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",be]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",be]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",be]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[cr,Er,Ua]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function On(...t){return Df(sl(t))}const Lf=il("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Br=O.forwardRef(({className:t,variant:e,size:r,asChild:s=!1,...n},a)=>{const i=s?Xh:"button";return u.jsx(i,{className:On(Lf({variant:e,size:r,className:t})),ref:a,...n})});Br.displayName="Button";const us=O.forwardRef(({className:t,type:e,...r},s)=>u.jsx("input",{type:e,className:On("flex h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:s,...r}));us.displayName="Input";var $f=Object.defineProperty,Mf=(t,e)=>$f(t,"name",{value:e,configurable:!0}),Ff=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ds=Ff.reduce((t,e)=>{const r=Ur(`Primitive.${e}`),s=O.forwardRef((n,a)=>{const{asChild:i,...o}=n,l=i?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...o,ref:a})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{});function Uf(t,e){t&&Iu.flushSync(()=>t.dispatchEvent(e))}Mf(Uf,"dispatchDiscreteCustomEvent");var Bf=Object.defineProperty,Vf=(t,e)=>Bf(t,"name",{value:e,configurable:!0}),Kf=O.forwardRef(Vf(function(e,r){return u.jsx(ds.label,{...e,ref:r,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(e.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}})},"Label")),pl=Kf;const zf=il("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Vr=O.forwardRef(({className:t,...e},r)=>u.jsx(pl,{ref:r,className:On(zf(),t),...e}));Vr.displayName=pl.displayName;var Hf=Object.defineProperty,hs=(t,e)=>Hf(t,"name",{value:e,configurable:!0}),ml=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ba(t,e,{checkForDefaultPrevented:r=!0}={}){return hs(function(n){if(t?.(n),r===!1||!n||!n.defaultPrevented)return e?.(n)},"handleEvent")}hs(Ba,"composeEventHandlers");function Wf(t){if(!ml)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}hs(Wf,"getOwnerWindow");function Va(t){if(!ml)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}hs(Va,"getOwnerDocument");function gl(t,e=!1){const{activeElement:r}=Va(t);if(!r?.nodeName)return null;if(yl(r)&&r.contentDocument)return gl(r.contentDocument.body,e);if(e){const s=r.getAttribute("aria-activedescendant");if(s){const n=Va(r).getElementById(s);if(n)return n}}return r}hs(gl,"getActiveElement");function yl(t){return t.tagName==="IFRAME"}hs(yl,"isFrame");var qf=Object.defineProperty,Pt=(t,e)=>qf(t,"name",{value:e,configurable:!0});function Gf(t,e){const r=O.createContext(e);r.displayName=t+"Context";const s=Pt(a=>{const{children:i,...o}=a,l=O.useMemo(()=>o,Object.values(o));return u.jsx(r.Provider,{value:l,children:i})},"Provider");s.displayName=t+"Provider";function n(a,i={}){const{optional:o=!1}=i,l=O.useContext(r);if(l)return l;if(e!==void 0)return e;if(!o)throw new Error(`\`${a}\` must be used within \`${t}\``)}return Pt(n,"useContext"),[s,n]}Pt(Gf,"createContext");function Hs(t,e=[]){let r=[];function s(a,i){const o=O.createContext(i);o.displayName=a+"Context";const l=r.length;r=[...r,i];const c=Pt(f=>{const{scope:p,children:h,...g}=f,y=p?.[t]?.[l]||o,v=O.useMemo(()=>g,Object.values(g));return u.jsx(y.Provider,{value:v,children:h})},"Provider");c.displayName=a+"Provider";function d(f,p,h={}){const{optional:g=!1}=h,y=p?.[t]?.[l]||o,v=O.useContext(y);if(v)return v;if(i!==void 0)return i;if(!g)throw new Error(`\`${f}\` must be used within \`${a}\``)}return Pt(d,"useContext"),[c,d]}Pt(s,"createContext");const n=Pt(()=>{const a=r.map(i=>O.createContext(i));return Pt(function(o){const l=o?.[t]||a;return O.useMemo(()=>({[`__scope${t}`]:{...o,[t]:l}}),[o,l])},"useScope")},"createScope");return n.scopeName=t,[s,vl(n,...e)]}Pt(Hs,"createContextScope");function vl(...t){const e=t[0];if(t.length===1)return e;const r=Pt(()=>{const s=t.map(n=>({useScope:n(),scopeName:n.scopeName}));return Pt(function(a){const i=s.reduce((o,{useScope:l,scopeName:c})=>{const f=l(a)[`__scope${c}`];return{...o,...f}},{});return O.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])},"useComposedScopes")},"createScope");return r.scopeName=e.scopeName,r}Pt(vl,"composeContextScopes");var fs=globalThis?.document?O.useLayoutEffect:()=>{},Jf=Object.defineProperty,Zf=(t,e)=>Jf(t,"name",{value:e,configurable:!0}),bl=O[" useEffectEvent ".trim().toString()],wl=O[" useInsertionEffect ".trim().toString()];function xl(t){if(typeof bl=="function")return bl(t);const e=O.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof wl=="function"?wl(()=>{e.current=t}):fs(()=>{e.current=t}),O.useMemo(()=>((...r)=>e.current?.(...r)),[])}Zf(xl,"useEffectEvent");var Yf=Object.defineProperty,Ws=(t,e)=>Yf(t,"name",{value:e,configurable:!0}),Xf=O[" useInsertionEffect ".trim().toString()]||fs;function Pn({prop:t,defaultProp:e,onChange:r=Ws(()=>{},"onChange"),caller:s}){const[n,a,i]=_l({defaultProp:e,onChange:r}),o=t!==void 0,l=o?t:n,c=O.useCallback(d=>{if(o){const f=kl(d)?d(t):d;f!==t&&i.current?.(f)}else a(d)},[o,t,a,i]);return[l,c]}Ws(Pn,"useControllableState");function _l({defaultProp:t,onChange:e}){const[r,s]=O.useState(t),n=O.useRef(r),a=O.useRef(e);return Xf(()=>{a.current=e},[e]),O.useEffect(()=>{n.current!==r&&(a.current?.(r),n.current=r)},[r,n]),[r,s,a]}Ws(_l,"useUncontrolledState");function kl(t){return typeof t=="function"}Ws(kl,"isFunction");var Sl=Symbol("RADIX:SYNC_STATE");function Qf(t,e,r,s){const{prop:n,defaultProp:a,onChange:i,caller:o}=e,l=n!==void 0,c=xl(i),d=[{...r,state:a}];s&&d.push(s);const[f,p]=O.useReducer((v,C)=>{if(C.type===Sl)return{...v,state:C.state};const _=t(v,C);return l&&!Object.is(_.state,v.state)&&c(_.state),_},...d),h=f.state,g=O.useRef(h);O.useEffect(()=>{g.current!==h&&(g.current=h,l||c(h))},[h,g,l]);const y=O.useMemo(()=>n!==void 0?{...f,state:n}:f,[f,n]);return O.useEffect(()=>{l&&!Object.is(n,f.state)&&p({type:Sl,state:n})},[n,f.state,l]),[y,p]}Ws(Qf,"useControllableStateReducer");var ep=Object.defineProperty,ur=(t,e)=>ep(t,"name",{value:e,configurable:!0});function Cl(t,e){return O.useReducer((r,s)=>e[r][s]??r,t)}ur(Cl,"useStateMachine");var tp=ur(t=>{const{present:e,children:r}=t,s=El(e),n=typeof r=="function"?r({present:s.isPresent}):O.Children.only(r),a=Tl(s.ref,Al(n));return typeof r=="function"||s.isPresent?O.cloneElement(n,{ref:a}):null},"Presence");function El(t){const[e,r]=O.useState(),s=O.useRef(null),n=O.useRef(t),a=O.useRef("none"),i=O.useRef(void 0),o=t?"mounted":"unmounted",[l,c]=Cl(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return O.useEffect(()=>{l==="mounted"?(a.current=i.current??ps(s.current),i.current=void 0):a.current="none"},[l]),fs(()=>{const d=s.current,f=n.current;if(f!==t){const h=a.current,g=ps(d);t?(i.current=g,c("MOUNT")):g==="none"||d?.display==="none"?c("UNMOUNT"):c(f&&h!==g?"ANIMATION_OUT":"UNMOUNT"),n.current=t}},[t,c]),fs(()=>{if(e){let d;const f=e.ownerDocument.defaultView??window,p=ur(g=>{const v=ps(s.current).includes(CSS.escape(g.animationName));if(g.target===e&&v&&(c("ANIMATION_END"),!n.current)){const C=e.style.animationFillMode;e.style.animationFillMode="forwards",d=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=C)})}},"handleAnimationEnd"),h=ur(g=>{g.target===e&&(a.current=ps(s.current))},"handleAnimationStart");return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",p),e.addEventListener("animationend",p),()=>{f.clearTimeout(d),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",p),e.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:O.useCallback(d=>{if(d){const f=getComputedStyle(d);s.current=f,i.current=ps(f)}else s.current=null;r(d)},[])}}ur(El,"usePresence");function Ka(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}ur(Ka,"setRef");function Tl(...t){const e=O.useRef(t);return e.current=t,O.useCallback(r=>{const s=e.current;let n=!1;const a=s.map(i=>{const o=Ka(i,r);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<a.length;i++){const o=a[i];typeof o=="function"?o():Ka(s[i],null)}}},[])}ur(Tl,"useStableComposedRefs");function ps(t){return t?.animationName||"none"}ur(ps,"getAnimationName");function Al(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}ur(Al,"getElementRef");var rp=Object.defineProperty,sp=(t,e)=>rp(t,"name",{value:e,configurable:!0}),np=O[" useId ".trim().toString()]||(()=>{}),ap=0;function za(t){const[e,r]=O.useState(np());return fs(()=>{t||r(s=>s??String(ap++))},[t]),t||(e?`radix-${e}`:"")}sp(za,"useId");var ip=Object.defineProperty,qs=(t,e)=>ip(t,"name",{value:e,configurable:!0}),Ha="Collapsible",[op,jl]=Hs(Ha),[lp,Wa]=op(Ha),cp=O.forwardRef(qs(function(e,r){const{__scopeCollapsible:s,open:n,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[c,d]=Pn({prop:n,defaultProp:a??!1,onChange:o,caller:Ha});return u.jsx(lp,{scope:s,disabled:i,contentId:za(),open:c,onOpenToggle:O.useCallback(()=>d(f=>!f),[d]),children:u.jsx(ds.div,{"data-state":Nn(c),"data-disabled":i?"":void 0,...l,ref:r})})},"Collapsible")),up="CollapsibleTrigger",dp=O.forwardRef(qs(function(e,r){const{__scopeCollapsible:s,...n}=e,a=Wa(up,s);return u.jsx(ds.button,{type:"button","aria-controls":a.open?a.contentId:void 0,"aria-expanded":a.open||!1,"data-state":Nn(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:r,onClick:Ba(e.onClick,a.onOpenToggle)})},"CollapsibleTrigger")),Ol="CollapsibleContent",Pl=O.forwardRef(qs(function(e,r){const{forceMount:s,...n}=e,a=Wa(Ol,e.__scopeCollapsible);return u.jsx(tp,{present:s||a.open,children:({present:i})=>u.jsx(hp,{...n,ref:r,present:i})})},"CollapsibleContent")),hp=O.forwardRef(qs(function(e,r){const{__scopeCollapsible:s,present:n,children:a,...i}=e,o=Wa(Ol,s),[l,c]=O.useState(n),d=O.useRef(null),f=lr(r,d),p=O.useRef(0),h=p.current,g=O.useRef(0),y=g.current,v=o.open||l,C=O.useRef(v),_=O.useRef(void 0);return O.useEffect(()=>{const S=requestAnimationFrame(()=>C.current=!1);return()=>cancelAnimationFrame(S)},[]),fs(()=>{const S=d.current;if(S){_.current=_.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const E=S.getBoundingClientRect();p.current=E.height,g.current=E.width,C.current||(S.style.transitionDuration=_.current.transitionDuration,S.style.animationName=_.current.animationName),c(n)}},[o.open,n]),u.jsx(ds.div,{"data-state":Nn(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!v,...i,ref:f,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...e.style},children:v&&a})},"CollapsibleContentImpl"));function Nn(t){return t?"open":"closed"}qs(Nn,"getState");var Nl=cp,fp=dp,pp=Pl;const mp=Nl,gp=Pl;var yp=t=>{switch(t){case"success":return wp;case"info":return _p;case"warning":return xp;case"error":return kp;default:return null}},vp=Array(12).fill(0),bp=({visible:t,className:e})=>k.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},k.createElement("div",{className:"sonner-spinner"},vp.map((r,s)=>k.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),wp=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),xp=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),_p=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),kp=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},k.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Sp=k.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},k.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),k.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Cp=()=>{let[t,e]=k.useState(document.hidden);return k.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},qa=1,Ep=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:r,...s}=t,n=typeof t?.id=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:qa++,a=this.toasts.find(o=>o.id===n),i=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(n)&&this.dismissedToasts.delete(n),a?this.toasts=this.toasts.map(o=>o.id===n?(this.publish({...o,...t,id:n,title:r}),{...o,...t,id:n,dismissible:i,title:r}):o):this.addToast({title:r,...s,dismissible:i,id:n}),n},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(r=>r({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let r;e.loading!==void 0&&(r=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let s=t instanceof Promise?t:t(),n=r!==void 0,a,i=s.then(async l=>{if(a=["resolve",l],k.isValidElement(l))n=!1,this.create({id:r,type:"default",message:l});else if(Ap(l)&&!l.ok){n=!1;let c=typeof e.error=="function"?await e.error(`HTTP error! status: ${l.status}`):e.error,d=typeof e.description=="function"?await e.description(`HTTP error! status: ${l.status}`):e.description;this.create({id:r,type:"error",message:c,description:d})}else if(e.success!==void 0){n=!1;let c=typeof e.success=="function"?await e.success(l):e.success,d=typeof e.description=="function"?await e.description(l):e.description;this.create({id:r,type:"success",message:c,description:d})}}).catch(async l=>{if(a=["reject",l],e.error!==void 0){n=!1;let c=typeof e.error=="function"?await e.error(l):e.error,d=typeof e.description=="function"?await e.description(l):e.description;this.create({id:r,type:"error",message:c,description:d})}}).finally(()=>{var l;n&&(this.dismiss(r),r=void 0),(l=e.finally)==null||l.call(e)}),o=()=>new Promise((l,c)=>i.then(()=>a[0]==="reject"?c(a[1]):l(a[1])).catch(c));return typeof r!="string"&&typeof r!="number"?{unwrap:o}:Object.assign(r,{unwrap:o})},this.custom=(t,e)=>{let r=e?.id||qa++;return this.create({jsx:t(r),id:r,...e}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},mt=new Ep,Tp=(t,e)=>{let r=e?.id||qa++;return mt.addToast({title:t,...e,id:r}),r},Ap=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",jp=Tp,Op=()=>mt.toasts,Pp=()=>mt.getActiveToasts(),ms=Object.assign(jp,{success:mt.success,info:mt.info,warning:mt.warning,error:mt.error,custom:mt.custom,message:mt.message,promise:mt.promise,dismiss:mt.dismiss,loading:mt.loading},{getHistory:Op,getToasts:Pp});function Np(t,{insertAt:e}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",e==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=t:s.appendChild(document.createTextNode(t))}Np(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
123
+ `);function Rn(t){return t.label!==void 0}var Rp=3,Ip="32px",Dp="16px",Rl=4e3,Lp=356,$p=14,Mp=20,Fp=200;function Vt(...t){return t.filter(Boolean).join(" ")}function Up(t){let[e,r]=t.split("-"),s=[];return e&&s.push(e),r&&s.push(r),s}var Bp=t=>{var e,r,s,n,a,i,o,l,c,d,f;let{invert:p,toast:h,unstyled:g,interacting:y,setHeights:v,visibleToasts:C,heights:_,index:S,toasts:E,expanded:T,removeToast:N,defaultRichColors:L,closeButton:ue,style:re,cancelButtonStyle:je,actionButtonStyle:Se,className:F="",descriptionClassName:X="",duration:W,position:oe,gap:ye,loadingIcon:ne,expandByDefault:de,classNames:G,icons:j,closeButtonAriaLabel:z="Close toast",pauseWhenPageIsHidden:Z}=t,[se,he]=k.useState(null),[le,ae]=k.useState(null),[ce,tt]=k.useState(!1),[Je,Le]=k.useState(!1),[ut,qt]=k.useState(!1),[lt,sr]=k.useState(!1),[rt,Dt]=k.useState(!1),[ht,Gt]=k.useState(0),[Et,Jt]=k.useState(0),Tt=k.useRef(h.duration||W||Rl),Lt=k.useRef(null),ft=k.useRef(null),Pr=S===0,Nr=S+1<=C,qe=h.type,vt=h.dismissible!==!1,Rr=h.className||"",br=h.descriptionClassName||"",nr=k.useMemo(()=>_.findIndex(te=>te.toastId===h.id)||0,[_,h.id]),Ts=k.useMemo(()=>{var te;return(te=h.closeButton)!=null?te:ue},[h.closeButton,ue]),U=k.useMemo(()=>h.duration||W||Rl,[h.duration,W]),m=k.useRef(0),b=k.useRef(0),x=k.useRef(0),A=k.useRef(null),[P,I]=oe.split("-"),M=k.useMemo(()=>_.reduce((te,we,ve)=>ve>=nr?te:te+we.height,0),[_,nr]),R=Cp(),J=h.invert||p,ee=qe==="loading";b.current=k.useMemo(()=>nr*ye+M,[nr,M]),k.useEffect(()=>{Tt.current=U},[U]),k.useEffect(()=>{tt(!0)},[]),k.useEffect(()=>{let te=ft.current;if(te){let we=te.getBoundingClientRect().height;return Jt(we),v(ve=>[{toastId:h.id,height:we,position:h.position},...ve]),()=>v(ve=>ve.filter($e=>$e.toastId!==h.id))}},[v,h.id]),k.useLayoutEffect(()=>{if(!ce)return;let te=ft.current,we=te.style.height;te.style.height="auto";let ve=te.getBoundingClientRect().height;te.style.height=we,Jt(ve),v($e=>$e.find(st=>st.toastId===h.id)?$e.map(st=>st.toastId===h.id?{...st,height:ve}:st):[{toastId:h.id,height:ve,position:h.position},...$e])},[ce,h.title,h.description,v,h.id]);let _e=k.useCallback(()=>{Le(!0),Gt(b.current),v(te=>te.filter(we=>we.toastId!==h.id)),setTimeout(()=>{N(h)},Fp)},[h,N,v,b]);k.useEffect(()=>{if(h.promise&&qe==="loading"||h.duration===1/0||h.type==="loading")return;let te;return T||y||Z&&R?(()=>{if(x.current<m.current){let we=new Date().getTime()-m.current;Tt.current=Tt.current-we}x.current=new Date().getTime()})():Tt.current!==1/0&&(m.current=new Date().getTime(),te=setTimeout(()=>{var we;(we=h.onAutoClose)==null||we.call(h,h),_e()},Tt.current)),()=>clearTimeout(te)},[T,y,h,qe,Z,R,_e]),k.useEffect(()=>{h.delete&&_e()},[_e,h.delete]);function Ze(){var te,we,ve;return j!=null&&j.loading?k.createElement("div",{className:Vt(G?.loader,(te=h?.classNames)==null?void 0:te.loader,"sonner-loader"),"data-visible":qe==="loading"},j.loading):ne?k.createElement("div",{className:Vt(G?.loader,(we=h?.classNames)==null?void 0:we.loader,"sonner-loader"),"data-visible":qe==="loading"},ne):k.createElement(bp,{className:Vt(G?.loader,(ve=h?.classNames)==null?void 0:ve.loader),visible:qe==="loading"})}return k.createElement("li",{tabIndex:0,ref:ft,className:Vt(F,Rr,G?.toast,(e=h?.classNames)==null?void 0:e.toast,G?.default,G?.[qe],(r=h?.classNames)==null?void 0:r[qe]),"data-sonner-toast":"","data-rich-colors":(s=h.richColors)!=null?s:L,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":ce,"data-promise":!!h.promise,"data-swiped":rt,"data-removed":Je,"data-visible":Nr,"data-y-position":P,"data-x-position":I,"data-index":S,"data-front":Pr,"data-swiping":ut,"data-dismissible":vt,"data-type":qe,"data-invert":J,"data-swipe-out":lt,"data-swipe-direction":le,"data-expanded":!!(T||de&&ce),style:{"--index":S,"--toasts-before":S,"--z-index":E.length-S,"--offset":`${Je?ht:b.current}px`,"--initial-height":de?"auto":`${Et}px`,...re,...h.style},onDragEnd:()=>{qt(!1),he(null),A.current=null},onPointerDown:te=>{ee||!vt||(Lt.current=new Date,Gt(b.current),te.target.setPointerCapture(te.pointerId),te.target.tagName!=="BUTTON"&&(qt(!0),A.current={x:te.clientX,y:te.clientY}))},onPointerUp:()=>{var te,we,ve,$e;if(lt||!vt)return;A.current=null;let st=Number(((te=ft.current)==null?void 0:te.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),At=Number(((we=ft.current)==null?void 0:we.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ar=new Date().getTime()-((ve=Lt.current)==null?void 0:ve.getTime()),bt=se==="x"?st:At,ir=Math.abs(bt)/ar;if(Math.abs(bt)>=Mp||ir>.11){Gt(b.current),($e=h.onDismiss)==null||$e.call(h,h),ae(se==="x"?st>0?"right":"left":At>0?"down":"up"),_e(),sr(!0),Dt(!1);return}qt(!1),he(null)},onPointerMove:te=>{var we,ve,$e,st;if(!A.current||!vt||((we=window.getSelection())==null?void 0:we.toString().length)>0)return;let At=te.clientY-A.current.y,ar=te.clientX-A.current.x,bt=(ve=t.swipeDirections)!=null?ve:Up(oe);!se&&(Math.abs(ar)>1||Math.abs(At)>1)&&he(Math.abs(ar)>Math.abs(At)?"x":"y");let ir={x:0,y:0};se==="y"?(bt.includes("top")||bt.includes("bottom"))&&(bt.includes("top")&&At<0||bt.includes("bottom")&&At>0)&&(ir.y=At):se==="x"&&(bt.includes("left")||bt.includes("right"))&&(bt.includes("left")&&ar<0||bt.includes("right")&&ar>0)&&(ir.x=ar),(Math.abs(ir.x)>0||Math.abs(ir.y)>0)&&Dt(!0),($e=ft.current)==null||$e.style.setProperty("--swipe-amount-x",`${ir.x}px`),(st=ft.current)==null||st.style.setProperty("--swipe-amount-y",`${ir.y}px`)}},Ts&&!h.jsx?k.createElement("button",{"aria-label":z,"data-disabled":ee,"data-close-button":!0,onClick:ee||!vt?()=>{}:()=>{var te;_e(),(te=h.onDismiss)==null||te.call(h,h)},className:Vt(G?.closeButton,(n=h?.classNames)==null?void 0:n.closeButton)},(a=j?.close)!=null?a:Sp):null,h.jsx||k.isValidElement(h.title)?h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title:k.createElement(k.Fragment,null,qe||h.icon||h.promise?k.createElement("div",{"data-icon":"",className:Vt(G?.icon,(i=h?.classNames)==null?void 0:i.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||Ze():null,h.type!=="loading"?h.icon||j?.[qe]||yp(qe):null):null,k.createElement("div",{"data-content":"",className:Vt(G?.content,(o=h?.classNames)==null?void 0:o.content)},k.createElement("div",{"data-title":"",className:Vt(G?.title,(l=h?.classNames)==null?void 0:l.title)},typeof h.title=="function"?h.title():h.title),h.description?k.createElement("div",{"data-description":"",className:Vt(X,br,G?.description,(c=h?.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),k.isValidElement(h.cancel)?h.cancel:h.cancel&&Rn(h.cancel)?k.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||je,onClick:te=>{var we,ve;Rn(h.cancel)&&vt&&((ve=(we=h.cancel).onClick)==null||ve.call(we,te),_e())},className:Vt(G?.cancelButton,(d=h?.classNames)==null?void 0:d.cancelButton)},h.cancel.label):null,k.isValidElement(h.action)?h.action:h.action&&Rn(h.action)?k.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||Se,onClick:te=>{var we,ve;Rn(h.action)&&((ve=(we=h.action).onClick)==null||ve.call(we,te),!te.defaultPrevented&&_e())},className:Vt(G?.actionButton,(f=h?.classNames)==null?void 0:f.actionButton)},h.action.label):null))};function Il(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function Vp(t,e){let r={};return[t,e].forEach((s,n)=>{let a=n===1,i=a?"--mobile-offset":"--offset",o=a?Dp:Ip;function l(c){["top","right","bottom","left"].forEach(d=>{r[`${i}-${d}`]=typeof c=="number"?`${c}px`:c})}typeof s=="number"||typeof s=="string"?l(s):typeof s=="object"?["top","right","bottom","left"].forEach(c=>{s[c]===void 0?r[`${i}-${c}`]=o:r[`${i}-${c}`]=typeof s[c]=="number"?`${s[c]}px`:s[c]}):l(o)}),r}k.forwardRef(function(t,e){let{invert:r,position:s="bottom-right",hotkey:n=["altKey","KeyT"],expand:a,closeButton:i,className:o,offset:l,mobileOffset:c,theme:d="light",richColors:f,duration:p,style:h,visibleToasts:g=Rp,toastOptions:y,dir:v=Il(),gap:C=$p,loadingIcon:_,icons:S,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:T}=t,[N,L]=k.useState([]),ue=k.useMemo(()=>Array.from(new Set([s].concat(N.filter(Z=>Z.position).map(Z=>Z.position)))),[N,s]),[re,je]=k.useState([]),[Se,F]=k.useState(!1),[X,W]=k.useState(!1),[oe,ye]=k.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ne=k.useRef(null),de=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),G=k.useRef(null),j=k.useRef(!1),z=k.useCallback(Z=>{L(se=>{var he;return(he=se.find(le=>le.id===Z.id))!=null&&he.delete||mt.dismiss(Z.id),se.filter(({id:le})=>le!==Z.id)})},[]);return k.useEffect(()=>mt.subscribe(Z=>{if(Z.dismiss){L(se=>se.map(he=>he.id===Z.id?{...he,delete:!0}:he));return}setTimeout(()=>{xt.flushSync(()=>{L(se=>{let he=se.findIndex(le=>le.id===Z.id);return he!==-1?[...se.slice(0,he),{...se[he],...Z},...se.slice(he+1)]:[Z,...se]})})})}),[]),k.useEffect(()=>{if(d!=="system"){ye(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ye("dark"):ye("light")),typeof window>"u")return;let Z=window.matchMedia("(prefers-color-scheme: dark)");try{Z.addEventListener("change",({matches:se})=>{ye(se?"dark":"light")})}catch{Z.addListener(({matches:he})=>{try{ye(he?"dark":"light")}catch(le){console.error(le)}})}},[d]),k.useEffect(()=>{N.length<=1&&F(!1)},[N]),k.useEffect(()=>{let Z=se=>{var he,le;n.every(ae=>se[ae]||se.code===ae)&&(F(!0),(he=ne.current)==null||he.focus()),se.code==="Escape"&&(document.activeElement===ne.current||(le=ne.current)!=null&&le.contains(document.activeElement))&&F(!1)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[n]),k.useEffect(()=>{if(ne.current)return()=>{G.current&&(G.current.focus({preventScroll:!0}),G.current=null,j.current=!1)}},[ne.current]),k.createElement("section",{ref:e,"aria-label":`${E} ${de}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},ue.map((Z,se)=>{var he;let[le,ae]=Z.split("-");return N.length?k.createElement("ol",{key:Z,dir:v==="auto"?Il():v,tabIndex:-1,ref:ne,className:o,"data-sonner-toaster":!0,"data-theme":oe,"data-y-position":le,"data-lifted":Se&&N.length>1&&!a,"data-x-position":ae,style:{"--front-toast-height":`${((he=re[0])==null?void 0:he.height)||0}px`,"--width":`${Lp}px`,"--gap":`${C}px`,...h,...Vp(l,c)},onBlur:ce=>{j.current&&!ce.currentTarget.contains(ce.relatedTarget)&&(j.current=!1,G.current&&(G.current.focus({preventScroll:!0}),G.current=null))},onFocus:ce=>{ce.target instanceof HTMLElement&&ce.target.dataset.dismissible==="false"||j.current||(j.current=!0,G.current=ce.relatedTarget)},onMouseEnter:()=>F(!0),onMouseMove:()=>F(!0),onMouseLeave:()=>{X||F(!1)},onDragEnd:()=>F(!1),onPointerDown:ce=>{ce.target instanceof HTMLElement&&ce.target.dataset.dismissible==="false"||W(!0)},onPointerUp:()=>W(!1)},N.filter(ce=>!ce.position&&se===0||ce.position===Z).map((ce,tt)=>{var Je,Le;return k.createElement(Bp,{key:ce.id,icons:S,index:tt,toast:ce,defaultRichColors:f,duration:(Je=y?.duration)!=null?Je:p,className:y?.className,descriptionClassName:y?.descriptionClassName,invert:r,visibleToasts:g,closeButton:(Le=y?.closeButton)!=null?Le:i,interacting:X,position:Z,style:y?.style,unstyled:y?.unstyled,classNames:y?.classNames,cancelButtonStyle:y?.cancelButtonStyle,actionButtonStyle:y?.actionButtonStyle,removeToast:z,toasts:N.filter(ut=>ut.position==ce.position),heights:re.filter(ut=>ut.position==ce.position),setHeights:je,expandByDefault:a,gap:C,loadingIcon:_,expanded:Se,pauseWhenPageIsHidden:T,swipeDirections:t.swipeDirections})})):null}))});const dr=O.forwardRef(({className:t="",...e},r)=>u.jsx("div",{ref:r,className:`rounded-lg border border-border bg-card text-card-foreground shadow-sm ${t}`,...e}));dr.displayName="Card";const Kr=O.forwardRef(({className:t="",...e},r)=>u.jsx("div",{ref:r,className:`flex flex-col space-y-1.5 p-6 ${t}`,...e}));Kr.displayName="CardHeader";const zr=O.forwardRef(({className:t="",...e},r)=>u.jsx("h3",{ref:r,className:`text-2xl font-semibold leading-none tracking-tight ${t}`,...e}));zr.displayName="CardTitle";const In=O.forwardRef(({className:t="",...e},r)=>u.jsx("p",{ref:r,className:`text-sm text-muted-foreground ${t}`,...e}));In.displayName="CardDescription";const Ar=O.forwardRef(({className:t="",...e},r)=>u.jsx("div",{ref:r,className:`p-6 pt-0 ${t}`,...e}));Ar.displayName="CardContent";const Dn=O.forwardRef(({className:t="",variant:e="default",...r},s)=>{const n={default:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border border-input"};return u.jsx("div",{ref:s,className:`inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 ${n[e]} ${t}`,...r})});Dn.displayName="Badge";var Kp=Object.defineProperty,Qe=(t,e)=>Kp(t,"name",{value:e,configurable:!0});function Dl(t){const e=t+"CollectionProvider",[r,s]=Hs(e),[n,a]=r(e,{collectionRef:{current:null},itemMap:new Map}),i=Qe(y=>{const{scope:v,children:C}=y,_=O.useRef(null),S=O.useRef(new Map).current;return u.jsx(n,{scope:v,itemMap:S,collectionRef:_,children:C})},"CollectionProvider");i.displayName=e;const o=t+"CollectionSlot",l=Ur(o),c=O.forwardRef((y,v)=>{const{scope:C,children:_}=y,S=a(o,C),E=lr(v,S.collectionRef);return u.jsx(l,{ref:E,children:_})});c.displayName=o;const d=t+"CollectionItemSlot",f="data-radix-collection-item",p=Ur(d),h=O.forwardRef((y,v)=>{const{scope:C,children:_,...S}=y,E=O.useRef(null),T=lr(v,E),N=a(d,C);return O.useEffect(()=>(N.itemMap.set(E,{ref:E,...S}),()=>{N.itemMap.delete(E)})),u.jsx(p,{[f]:"",ref:T,children:_})});h.displayName=d;function g(y){const v=a(t+"CollectionConsumer",y);return O.useCallback(()=>{const _=v.collectionRef.current;if(!_)return[];const S=Array.from(_.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((N,L)=>S.indexOf(N.ref.current)-S.indexOf(L.ref.current))},[v.collectionRef,v.itemMap])}return Qe(g,"useCollection"),[{Provider:i,Slot:c,ItemSlot:h},g,s]}Qe(Dl,"createCollection");var Ll=new WeakMap,Ga=(Ct=class extends Map{constructor(r){super(r);Nu(this,We);ji(this,We,[...super.keys()]),Ll.set(this,!0)}set(r,s){return Ll.get(this)&&(this.has(r)?dt(this,We)[dt(this,We).indexOf(r)]=r:dt(this,We).push(r)),super.set(r,s),this}insert(r,s,n){const a=this.has(s),i=dt(this,We).length,o=Ja(r);let l=o>=0?o:i+o;const c=l<0||l>=i?-1:l;if(c===this.size||a&&c===this.size-1||c===-1)return this.set(s,n),this;const d=this.size+(a?0:1);o<0&&l++;const f=[...dt(this,We)];let p,h=!1;for(let g=l;g<d;g++)if(l===g){let y=f[g];f[g]===s&&(y=f[g+1]),a&&this.delete(s),p=this.get(y),this.set(s,n)}else{!h&&f[g-1]===s&&(h=!0);const y=f[h?g:g-1],v=p;p=this.get(y),this.delete(y),this.set(y,v)}return this}with(r,s,n){const a=new Ct(this);return a.insert(r,s,n),a}before(r){const s=dt(this,We).indexOf(r)-1;if(!(s<0))return this.entryAt(s)}setBefore(r,s,n){const a=dt(this,We).indexOf(r);return a===-1?this:this.insert(a,s,n)}after(r){let s=dt(this,We).indexOf(r);if(s=s===-1||s===this.size-1?-1:s+1,s!==-1)return this.entryAt(s)}setAfter(r,s,n){const a=dt(this,We).indexOf(r);return a===-1?this:this.insert(a+1,s,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return ji(this,We,[]),super.clear()}delete(r){const s=super.delete(r);return s&&dt(this,We).splice(dt(this,We).indexOf(r),1),s}deleteAt(r){const s=this.keyAt(r);return s!==void 0?this.delete(s):!1}at(r){const s=Ln(dt(this,We),r);if(s!==void 0)return this.get(s)}entryAt(r){const s=Ln(dt(this,We),r);if(s!==void 0)return[s,this.get(s)]}indexOf(r){return dt(this,We).indexOf(r)}keyAt(r){return Ln(dt(this,We),r)}from(r,s){const n=this.indexOf(r);if(n===-1)return;let a=n+s;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.at(a)}keyFrom(r,s){const n=this.indexOf(r);if(n===-1)return;let a=n+s;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.keyAt(a)}find(r,s){let n=0;for(const a of this){if(Reflect.apply(r,s,[a,n,this]))return a;n++}}findIndex(r,s){let n=0;for(const a of this){if(Reflect.apply(r,s,[a,n,this]))return n;n++}return-1}filter(r,s){const n=[];let a=0;for(const i of this)Reflect.apply(r,s,[i,a,this])&&n.push(i),a++;return new Ct(n)}map(r,s){const n=[];let a=0;for(const i of this)n.push([i[0],Reflect.apply(r,s,[i,a,this])]),a++;return new Ct(n)}reduce(...r){const[s,n]=r;let a=0,i=n??this.at(0);for(const o of this)a===0&&r.length===1?i=o:i=Reflect.apply(s,this,[i,o,a,this]),a++;return i}reduceRight(...r){const[s,n]=r;let a=n??this.at(-1);for(let i=this.size-1;i>=0;i--){const o=this.at(i);i===this.size-1&&r.length===1?a=o:a=Reflect.apply(s,this,[a,o,i,this])}return a}toSorted(r){const s=[...this.entries()].sort(r);return new Ct(s)}toReversed(){const r=new Ct;for(let s=this.size-1;s>=0;s--){const n=this.keyAt(s),a=this.get(n);r.set(n,a)}return r}toSpliced(...r){const s=[...this.entries()];return s.splice(...r),new Ct(s)}slice(r,s){const n=new Ct;let a=this.size-1;if(r===void 0)return n;r<0&&(r=r+this.size),s!==void 0&&s>0&&(a=s-1);for(let i=r;i<=a;i++){const o=this.keyAt(i),l=this.get(o);n.set(o,l)}return n}every(r,s){let n=0;for(const a of this){if(!Reflect.apply(r,s,[a,n,this]))return!1;n++}return!0}some(r,s){let n=0;for(const a of this){if(Reflect.apply(r,s,[a,n,this]))return!0;n++}return!1}},We=new WeakMap,Qe(Ct,"OrderedDict"),Ct);function Ln(t,e){if("at"in Array.prototype)return Array.prototype.at.call(t,e);const r=$l(t,e);return r===-1?void 0:t[r]}Qe(Ln,"at");function $l(t,e){const r=t.length,s=Ja(e),n=s>=0?s:r+s;return n<0||n>=r?-1:n}Qe($l,"toSafeIndex");function Ja(t){return t!==t||t===0?0:Math.trunc(t)}Qe(Ja,"toSafeInteger");function zp(t){const e=t+"CollectionProvider",[r,s]=Hs(e),[n,a]=r(e,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Ga,setItemMap:Qe(()=>{},"setItemMap")}),i=Qe(({state:S,...E})=>S?u.jsx(l,{...E,state:S}):u.jsx(o,{...E}),"CollectionProvider");i.displayName=e;const o=Qe(S=>{const E=v();return u.jsx(l,{...S,state:E})},"CollectionInit");o.displayName=e+"Init";const l=Qe(S=>{const{scope:E,children:T,state:N}=S,L=O.useRef(null),[ue,re]=O.useState(null),je=lr(L,re),[Se,F]=N;return O.useEffect(()=>{if(!ue)return;const X=Ul(()=>{});return X.observe(ue,{childList:!0,subtree:!0}),()=>{X.disconnect()}},[ue]),u.jsx(n,{scope:E,itemMap:Se,setItemMap:F,collectionRef:je,collectionRefObject:L,collectionElement:ue,children:T})},"CollectionProviderImpl");l.displayName=e+"Impl";const c=t+"CollectionSlot",d=Ur(c),f=O.forwardRef((S,E)=>{const{scope:T,children:N}=S,L=a(c,T),ue=lr(E,L.collectionRef);return u.jsx(d,{ref:ue,children:N})});f.displayName=c;const p=t+"CollectionItemSlot",h="data-radix-collection-item",g=Ur(p),y=O.forwardRef((S,E)=>{const{scope:T,children:N,...L}=S,ue=O.useRef(null),[re,je]=O.useState(null),Se=lr(E,ue,je),F=a(p,T),{setItemMap:X}=F,W=O.useRef(L);Ml(W.current,L)||(W.current=L);const oe=W.current;return O.useEffect(()=>{const ye=oe;return X(ne=>re?ne.has(re)?ne.set(re,{...ye,element:re}).toSorted(Za):(ne.set(re,{...ye,element:re}),ne.toSorted(Za)):ne),()=>{X(ne=>!re||!ne.has(re)?ne:(ne.delete(re),new Ga(ne)))}},[re,oe,X]),u.jsx(g,{[h]:"",ref:Se,children:N})});y.displayName=p;function v(){return O.useState(new Ga)}Qe(v,"useInitCollection");function C(S){const{itemMap:E}=a(t+"CollectionConsumer",S);return E}return Qe(C,"useCollection"),[{Provider:i,Slot:f,ItemSlot:y},{createCollectionScope:s,useCollection:C,useInitCollection:v}]}Qe(zp,"createCollection");function Ml(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t==null||e==null)return!1;const r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;for(const n of r)if(!Object.prototype.hasOwnProperty.call(e,n)||t[n]!==e[n])return!1;return!0}Qe(Ml,"shallowEqual");function Fl(t,e){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}Qe(Fl,"isElementPreceding");function Za(t,e){return!t[1].element||!e[1].element?0:Fl(t[1].element,e[1].element)?-1:1}Qe(Za,"sortByDocumentPosition");function Ul(t){return new MutationObserver(r=>{for(const s of r)if(s.type==="childList"){t();return}})}Qe(Ul,"getChildListObserver");var Hp=Object.defineProperty,Wp=(t,e)=>Hp(t,"name",{value:e,configurable:!0}),qp=O.createContext(void 0);function Bl(t){const e=O.useContext(qp);return t||e||"ltr"}Wp(Bl,"useDirection");var Gp=Object.defineProperty,kt=(t,e)=>Gp(t,"name",{value:e,configurable:!0}),Qt="Accordion",Jp=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Ya,Zp,Yp]=Dl(Qt),[$n,xb]=Hs(Qt,[Yp,jl]),Xa=jl(),Xp=O.forwardRef(kt(function(e,r){const{type:s,...n}=e,a=n,i=n;return u.jsx(Ya.Provider,{scope:e.__scopeAccordion,children:s==="multiple"?u.jsx(rm,{...i,ref:r}):u.jsx(tm,{...a,ref:r})})},"Accordion")),[Vl,Qp]=$n(Qt),[Kl,em]=$n(Qt,{collapsible:!1}),tm=O.forwardRef(kt(function(e,r){const{value:s,defaultValue:n,onValueChange:a=kt(()=>{},"onValueChange"),collapsible:i=!1,...o}=e,[l,c]=Pn({prop:s,defaultProp:n??"",onChange:a,caller:Qt});return u.jsx(Vl,{scope:e.__scopeAccordion,value:O.useMemo(()=>l?[l]:[],[l]),onItemOpen:c,onItemClose:O.useCallback(()=>i&&c(""),[i,c]),children:u.jsx(Kl,{scope:e.__scopeAccordion,collapsible:i,children:u.jsx(zl,{...o,ref:r})})})},"AccordionImplSingle")),rm=O.forwardRef(kt(function(e,r){const{value:s,defaultValue:n,onValueChange:a=kt(()=>{},"onValueChange"),...i}=e,[o,l]=Pn({prop:s,defaultProp:n??[],onChange:a,caller:Qt}),c=O.useCallback(f=>l((p=[])=>[...p,f]),[l]),d=O.useCallback(f=>l((p=[])=>p.filter(h=>h!==f)),[l]);return u.jsx(Vl,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:d,children:u.jsx(Kl,{scope:e.__scopeAccordion,collapsible:!0,children:u.jsx(zl,{...i,ref:r})})})},"AccordionImplMultiple")),[sm,Mn]=$n(Qt),zl=O.forwardRef(kt(function(e,r){const{__scopeAccordion:s,disabled:n,dir:a,orientation:i="vertical",...o}=e,l=O.useRef(null),c=lr(l,r),d=Zp(s),p=Bl(a)==="ltr",h=Ba(e.onKeyDown,g=>{if(!Jp.includes(g.key))return;const y=g.target,v=d().filter(re=>!re.ref.current?.disabled),C=v.findIndex(re=>re.ref.current===y),_=v.length;if(C===-1)return;g.preventDefault();let S=C;const E=0,T=_-1,N=kt(()=>{S=C+1,S>T&&(S=E)},"moveNext"),L=kt(()=>{S=C-1,S<E&&(S=T)},"movePrev");switch(g.key){case"Home":S=E;break;case"End":S=T;break;case"ArrowRight":i==="horizontal"&&(p?N():L());break;case"ArrowDown":i==="vertical"&&N();break;case"ArrowLeft":i==="horizontal"&&(p?L():N());break;case"ArrowUp":i==="vertical"&&L();break}const ue=S%_;v[ue].ref.current?.focus()});return u.jsx(sm,{scope:s,disabled:n,direction:a,orientation:i,children:u.jsx(Ya.Slot,{scope:s,children:u.jsx(ds.div,{...o,"data-orientation":i,ref:c,onKeyDown:n?void 0:h})})})},"AccordionImpl")),Qa="AccordionItem",[nm,ei]=$n(Qa),am=O.forwardRef(kt(function(e,r){const{__scopeAccordion:s,value:n,...a}=e,i=Mn(Qa,s),o=Qp(Qa,s),l=Xa(s),c=za(),d=n&&o.value.includes(n)||!1,f=i.disabled||e.disabled;return u.jsx(nm,{scope:s,open:d,disabled:f,triggerId:c,children:u.jsx(Nl,{"data-orientation":i.orientation,"data-state":ti(d),...l,...a,ref:r,disabled:f,open:d,onOpenChange:p=>{p?o.onItemOpen(n):o.onItemClose(n)}})})},"AccordionItem")),im="AccordionHeader",om=O.forwardRef(kt(function(e,r){const{__scopeAccordion:s,...n}=e,a=Mn(Qt,s),i=ei(im,s);return u.jsx(ds.h3,{"data-orientation":a.orientation,"data-state":ti(i.open),"data-disabled":i.disabled?"":void 0,...n,ref:r})},"AccordionHeader")),Hl="AccordionTrigger",lm=O.forwardRef(kt(function(e,r){const{__scopeAccordion:s,...n}=e,a=Mn(Qt,s),i=ei(Hl,s),o=em(Hl,s),l=Xa(s);return u.jsx(Ya.ItemSlot,{scope:s,children:u.jsx(fp,{"aria-disabled":i.open&&!o.collapsible||void 0,"data-orientation":a.orientation,id:i.triggerId,...l,...n,ref:r})})},"AccordionTrigger")),cm="AccordionContent",um=O.forwardRef(kt(function(e,r){const{__scopeAccordion:s,...n}=e,a=Mn(Qt,s),i=ei(cm,s),o=Xa(s);return u.jsx(pp,{role:"region","aria-labelledby":i.triggerId,"data-orientation":a.orientation,...o,...n,ref:r,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})},"AccordionContent"));function ti(t){return t?"open":"closed"}kt(ti,"getState");var dm=Xp,hm=am,fm=om,Wl=lm,ql=um;const ri=t=>u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[u.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),u.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),u.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),Gl=t=>u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[u.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),u.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),Fn=t=>u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),u.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),pm=t=>u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:u.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),mm=t=>u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[u.jsx("path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"}),u.jsx("path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"}),u.jsx("path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1"})]}),gm=t=>u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[u.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),u.jsx("circle",{cx:"9",cy:"7",r:"4"}),u.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),u.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),ym=t=>u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:u.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),vm=t=>u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[u.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),u.jsx("polyline",{points:"5 12 12 5 19 12"})]}),Jl=t=>u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:u.jsx("polyline",{points:"6 9 12 15 18 9"})}),Zl=t=>u.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:u.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),bm=t=>u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...t,children:[u.jsx("polyline",{points:"1 4 1 10 7 10"}),u.jsx("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),Yl=dm,si=O.forwardRef(({className:t="",...e},r)=>u.jsx(hm,{ref:r,className:`border-b ${t}`,...e}));si.displayName="AccordionItem";const ni=O.forwardRef(({className:t="",children:e,...r},s)=>u.jsx(fm,{className:"flex",children:u.jsxs(Wl,{ref:s,className:`flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180 ${t}`,...r,children:[e,u.jsx(Jl,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));ni.displayName=Wl.displayName;const ai=O.forwardRef(({className:t="",children:e,...r},s)=>u.jsx(ql,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:u.jsx("div",{className:`pb-4 pt-0 ${t}`,children:e})}));ai.displayName=ql.displayName;function hr({className:t,...e}){return u.jsx("div",{className:On("animate-pulse rounded-md bg-muted",t),...e})}const ii=new Map,Xl=1800*1e3;function wm(t,e,r){return`D1|${e}|svg|${t.day}-${t.month}-${t.year}-${t.hour}-${t.minute}-${t.lat}-${t.lon}-${t.tzone}|${r}`}function xm(t){const e=ii.get(t);if(e&&Date.now()-e.timestamp<Xl)return e.svg;try{const r=sessionStorage.getItem(`kundali_${t}`);if(r){const s=JSON.parse(r);if(Date.now()-s.timestamp<Xl)return ii.set(t,s),s.svg;sessionStorage.removeItem(`kundali_${t}`)}}catch{}return null}function _m(t,e){const r={svg:e,timestamp:Date.now()};ii.set(t,r);try{sessionStorage.setItem(`kundali_${t}`,JSON.stringify(r))}catch{}}function km(t){try{const r=new DOMParser().parseFromString(t,"image/svg+xml"),s=r.querySelector("svg");return s?(s.removeAttribute("width"),s.removeAttribute("height"),s.getAttribute("viewBox")||s.setAttribute("viewBox","0 0 350 350"),s.setAttribute("preserveAspectRatio","xMidYMid meet"),s.setAttribute("style","width:100%;height:auto;display:block;"),new XMLSerializer().serializeToString(r)):t}catch(e){return console.error("[kundaliChart] SVG transform error:",e),t}}async function Sm(t,e){const{birthDetails:r,chartType:s,language:n,signal:a}=e,i=wm(r,s,n),o=xm(i);if(o)return o;const l=await t.functions.invoke("get-kundali-chart",{body:{...r,chartType:s,language:n}});if(a?.aborted)throw new DOMException("Aborted","AbortError");if(l.error)throw new Error(l.error.message||"Failed to fetch kundali chart");const c=l.data?.data?.svg;if(!c)throw new Error("No SVG data in response");const d=km(c);return _m(i,d),d}function Cm({birthDetails:t,supabase:e,language:r,t:s}){const[n,a]=k.useState("North"),[i,o]=k.useState("idle"),[l,c]=k.useState(""),d=k.useRef(null),f=k.useRef(null),h=(r||"").toLowerCase().startsWith("hi")?"hi":"en",g=k.useCallback(async C=>{d.current&&d.current.abort();const _=new AbortController;d.current=_,o("loading");try{const S=await Sm(e,{birthDetails:t,chartType:C,language:h,signal:_.signal});_.signal.aborted||(c(S),o("success"))}catch(S){if(S instanceof Error&&S.name==="AbortError")return;console.error("[KundaliCard] Fetch error:",S),_.signal.aborted||o("error")}},[t,e,h]);k.useEffect(()=>(g(n),()=>{d.current&&d.current.abort()}),[n,g]);const y=C=>{C!==n&&a(C)},v=()=>{g(n)};return u.jsxs(dr,{ref:f,className:"spiritual-glow border border-primary/10",children:[u.jsxs(Kr,{className:"pb-3",children:[u.jsx(zr,{className:"text-xl font-bold",children:s("drYourKundali")}),u.jsxs("div",{className:"flex gap-2 mt-3 pt-2",children:[u.jsx(Br,{type:"button",size:"sm",variant:n==="North"?"default":"outline",className:"rounded-full px-4",onClick:()=>y("North"),children:s("kundaliChartNorth")}),u.jsx(Br,{type:"button",size:"sm",variant:n==="South"?"default":"outline",className:"rounded-full px-4",onClick:()=>y("South"),children:s("kundaliChartSouth")})]})]}),u.jsx(Ar,{children:u.jsxs("div",{className:"w-full max-w-[360px] mx-auto",children:[i==="loading"&&u.jsx(hr,{className:"w-full aspect-square rounded-lg"}),i==="success"&&l&&u.jsx("div",{className:"w-full aspect-square",dangerouslySetInnerHTML:{__html:l}}),i==="error"&&u.jsxs("div",{className:"w-full aspect-square flex flex-col items-center justify-center bg-muted/30 rounded-lg border border-border",children:[u.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:s("kundaliChartLoadError")}),u.jsxs(Br,{type:"button",variant:"outline",size:"sm",onClick:v,className:"gap-2",children:[u.jsx(bm,{className:"w-4 h-4"}),s("kundaliChartRetry")]})]})]})})]})}const Ql=[{type:"kaal-sarp",detailKey:"kaalSarp",nameKey:"drKaalSarpName",descKey:"drKaalSarpDesc",impactKey:"drKaalSarpImpact",remediesKey:"drKaalSarpRemedies",benefitsKey:"drPujaBenefitsKaalSarp",icon:mm,summaryKey:"kaalSarp",severityKey:"kaalSarpSeverity"},{type:"pitra",detailKey:"pitra",nameKey:"drPitraName",descKey:"drPitraDesc",impactKey:"drPitraImpact",remediesKey:"drPitraRemedies",benefitsKey:"drPujaBenefitsPitra",icon:gm,summaryKey:"pitra",severityKey:"pitraSeverity"},{type:"shani",detailKey:"sadeSati",nameKey:"drSadeSatiName",descKey:"drSadeSatiDesc",impactKey:"drSadeSatiImpact",remediesKey:"drSadeSatiRemedies",benefitsKey:"drPujaBenefitsShani",icon:ym,summaryKey:"shaniSadeSati",severityKey:"sadeSatiSeverity"},{type:"mangal",detailKey:"mangal",nameKey:"drMangalName",descKey:"drMangalDesc",impactKey:"drMangalImpact",remediesKey:"drMangalRemedies",benefitsKey:"drPujaBenefitsMangal",icon:pm,summaryKey:"mangal",severityKey:"mangalSeverity"}];function Nt(t){if(!t)return!1;const e=t.toLowerCase();return e==="present"||e==="active"||e==="partial"||e==="suggested"}function Un(t){return t?t.toLowerCase().includes("nullified"):!1}function ec(t,e){if(Array.isArray(t)){const r=t.find(a=>(a.name??a.type)===e);if(!r)return;const s=typeof r.remedies=="string"?r.remedies:Array.isArray(r.remedies)?r.remedies.join(`
124
124
  `):void 0,n=Array.isArray(r.placements)?r.placements:void 0;return{explanation:r.explanation,remedies:s,placements:n}}if(t&&typeof t=="object"&&e in t){const r=t[e];if(!r)return;const s=typeof r.remedies=="string"?r.remedies:Array.isArray(r.remedies)?r.remedies.join(`
125
- `):void 0;return{explanation:r.explanation,remedies:s,placements:r.placements}}}function tc(t,e){if(!t)return"";const r=t.toLowerCase();return r.includes("nullified")?e("drStatusNullified"):r==="present"||r==="active"||r==="partial"||r==="suggested"?e("drStatusPresent"):r==="absent"?e("drStatusAbsent"):r==="inactive"?e("drStatusInactive"):t}function rc(t){if(!t)return 2;const e=t.toLowerCase();return e==="severe"||e==="high"?3:e==="moderate"||e==="medium"?2:e==="mild"||e==="low"?1:2}function sc(t,e){if(!t)return e("drSeverityMedium");const r=t.toLowerCase();return e(r==="severe"||r==="high"?"drSeverityHigh":r==="moderate"||r==="medium"?"drSeverityMedium":r==="mild"||r==="low"?"drSeverityLow":"drSeverityMedium")}function Am({result:t,t:e,onEdit:r,className:s="",kundaliSectionId:n,feedbackEmail:a="pujaseva@appsforbharat.com",renderPujaCard:i,isLoadingPujas:o=!1,renderKundali:l,birthDetails:c,supabase:u,language:p="en",problemArea:f,problemAreaIds:h,customProblemText:y,analytics:g}){const[v,C]=k.useState({}),[_,S]=k.useState(!1),E=!l&&c&&u,T=t.summary??{},N=t.details??{};k.useEffect(()=>{if(!f||!f.trim()||!u){S(!1);return}S(!0),C({}),(async()=>{const z={},se=["mangal","kaal-sarp","pitra","shani"].filter(le=>le==="mangal"?Nt(T.mangal)&&!Bn(T.mangal):le==="kaal-sarp"?Nt(T.kaalSarp):le==="pitra"?Nt(T.pitra):le==="shani"?Nt(T.shaniSadeSati??T.sadeSati):!1);console.log("[DoshaResultsFull] Generating impacts for:",se,"problemArea:",f);const he=se.map(async le=>{try{const ae=h?.find(tt=>tt!=="other")||(h?.includes("other")?"other":void 0);console.log(`[DoshaResultsFull] Calling generate-impact for ${le}`);const ce=await u.functions.invoke("generate-impact",{body:{doshaType:le,problemArea:f,problemAreaId:ae,problemAreaIds:h,customProblemText:y,language:p?.toLowerCase().startsWith("hi")?"hi":"en"}});if(console.log(`[DoshaResultsFull] Impact response for ${le}:`,ce.data),ce.error){console.error(`[DoshaResultsFull] Error generating impact for ${le}:`,ce.error);return}ce.data?.impactText&&(z[le]={title:ce.data.impactTitle||e("drImpactIfPresent"),text:ce.data.impactText})}catch(ae){console.error(`[DoshaResultsFull] Failed to generate impact for ${le}:`,ae)}});await Promise.all(he),console.log("[DoshaResultsFull] Final personalized impacts:",z),C(z),S(!1)})()},[f,h,y,p,u,T]),k.useEffect(()=>{g?.trackDoshaCalculatorResultPageView?.(!0)},[g]);const L=T.shaniSadeSati??T.sadeSati,ue=[{summaryKey:"grahan",detailKey:"grahan",labelKey:"drOtherGrahan",descKey:"drOtherGrahanDesc",impactKey:"drOtherGrahanImpact",remediesKey:"drOtherGrahanRemedies"},{summaryKey:"shrapit",detailKey:"shrapit",labelKey:"drOtherShrapit",descKey:"drOtherShrapitDesc",impactKey:"drOtherShrapitImpact",remediesKey:"drOtherShrapitRemedies"},{summaryKey:"guruChandal",detailKey:"guruChandal",labelKey:"drOtherGuruChandal",descKey:"drOtherGuruChandalDesc",impactKey:"drOtherGuruChandalImpact",remediesKey:"drOtherGuruChandalRemedies"},{summaryKey:"punarphoo",detailKey:"punarphoo",labelKey:"drOtherPunarphoo",descKey:"drOtherPunarphooDesc",impactKey:"drOtherPunarphooImpact",remediesKey:"drOtherPunarphooRemedies"},{summaryKey:"kemadruma",detailKey:"kemadruma",labelKey:"drOtherKemadruma",descKey:"drOtherKemadrumaDesc",impactKey:"drOtherKemadrumaImpact",remediesKey:"drOtherKemadrumaRemedies"},{summaryKey:"gandmool",detailKey:"gandmool",labelKey:"drOtherGandmool",descKey:"drOtherGandmoolDesc",impactKey:"drOtherGandmoolImpact",remediesKey:"drOtherGandmoolRemedies"},{summaryKey:"kalathra",detailKey:"kalathra",labelKey:"drOtherKalathra",descKey:"drOtherKalathraDec",impactKey:"drOtherKalathraImpact",remediesKey:"drOtherKalathraRemedies"},{summaryKey:"vishDaridra",detailKey:"vishDaridra",labelKey:"drOtherVishDaridra",descKey:"drOtherVishDaridraDesc",impactKey:"drOtherVishDaridraImpact",remediesKey:"drOtherVishDaridraRemedies"},{summaryKey:"ketuNaga",detailKey:"ketuNaga",labelKey:"drOtherKetuNaga",descKey:"drOtherKetuNagaDesc",impactKey:"drOtherKetuNagaImpact",remediesKey:"drOtherKetuNagaRemedies"},{summaryKey:"navagrahaUmbrella",detailKey:"navagraha",labelKey:"drOtherNavagraha",descKey:"drOtherNavagrahaDesc",impactKey:"drOtherNavagrahaImpact",remediesKey:"drOtherNavagrahaRemedies"}],je=ue.filter(j=>Nt(T[j.summaryKey])).length>0,Se=Nt(T.mangal)&&!Bn(T.mangal)||Nt(T.kaalSarp)||Nt(T.pitra)||Nt(L)||je,F=[];for(const j of Ql){const z=j.summaryKey==="shaniSadeSati"?L:T[j.summaryKey];if(!Nt(z)||j.type==="mangal"&&Bn(z))continue;const Z=T[j.severityKey],se=j.type==="shani"?T.shaniPhase??T.shaniPhase:void 0,he=ec(N,j.detailKey==="sadeSati"?"sadeSati":j.detailKey),le=he?.explanation??e("drBasedOnPositions"),ce=(he?.remedies??e(j.remediesKey)).split(`
125
+ `):void 0;return{explanation:r.explanation,remedies:s,placements:r.placements}}}function tc(t,e){if(!t)return"";const r=t.toLowerCase();return r.includes("nullified")?e("drStatusNullified"):r==="present"||r==="active"||r==="partial"||r==="suggested"?e("drStatusPresent"):r==="absent"?e("drStatusAbsent"):r==="inactive"?e("drStatusInactive"):t}function rc(t){if(!t)return 2;const e=t.toLowerCase();return e==="severe"||e==="high"?3:e==="moderate"||e==="medium"?2:e==="mild"||e==="low"?1:2}function sc(t,e){if(!t)return e("drSeverityMedium");const r=t.toLowerCase();return e(r==="severe"||r==="high"?"drSeverityHigh":r==="moderate"||r==="medium"?"drSeverityMedium":r==="mild"||r==="low"?"drSeverityLow":"drSeverityMedium")}function Em({result:t,t:e,onEdit:r,className:s="",kundaliSectionId:n,feedbackEmail:a="pujaseva@appsforbharat.com",renderPujaCard:i,isLoadingPujas:o=!1,renderKundali:l,birthDetails:c,supabase:d,language:f="en",problemArea:p,problemAreaIds:h,customProblemText:g,analytics:y}){const[v,C]=k.useState({}),[_,S]=k.useState(!1),E=!l&&c&&d,T=t.summary??{},N=t.details??{};k.useEffect(()=>{if(!p||!p.trim()||!d){S(!1);return}S(!0),C({}),(async()=>{const z={},se=["mangal","kaal-sarp","pitra","shani"].filter(le=>le==="mangal"?Nt(T.mangal)&&!Un(T.mangal):le==="kaal-sarp"?Nt(T.kaalSarp):le==="pitra"?Nt(T.pitra):le==="shani"?Nt(T.shaniSadeSati??T.sadeSati):!1);console.log("[DoshaResultsFull] Generating impacts for:",se,"problemArea:",p);const he=se.map(async le=>{try{const ae=h?.find(tt=>tt!=="other")||(h?.includes("other")?"other":void 0);console.log(`[DoshaResultsFull] Calling generate-impact for ${le}`);const ce=await d.functions.invoke("generate-impact",{body:{doshaType:le,problemArea:p,problemAreaId:ae,problemAreaIds:h,customProblemText:g,language:f?.toLowerCase().startsWith("hi")?"hi":"en"}});if(console.log(`[DoshaResultsFull] Impact response for ${le}:`,ce.data),ce.error){console.error(`[DoshaResultsFull] Error generating impact for ${le}:`,ce.error);return}ce.data?.impactText&&(z[le]={title:ce.data.impactTitle||e("drImpactIfPresent"),text:ce.data.impactText})}catch(ae){console.error(`[DoshaResultsFull] Failed to generate impact for ${le}:`,ae)}});await Promise.all(he),console.log("[DoshaResultsFull] Final personalized impacts:",z),C(z),S(!1)})()},[p,h,g,f,d,T]),k.useEffect(()=>{y?.trackDoshaCalculatorResultPageView?.(!0)},[y]);const L=T.shaniSadeSati??T.sadeSati,ue=[{summaryKey:"grahan",detailKey:"grahan",labelKey:"drOtherGrahan",descKey:"drOtherGrahanDesc",impactKey:"drOtherGrahanImpact",remediesKey:"drOtherGrahanRemedies"},{summaryKey:"shrapit",detailKey:"shrapit",labelKey:"drOtherShrapit",descKey:"drOtherShrapitDesc",impactKey:"drOtherShrapitImpact",remediesKey:"drOtherShrapitRemedies"},{summaryKey:"guruChandal",detailKey:"guruChandal",labelKey:"drOtherGuruChandal",descKey:"drOtherGuruChandalDesc",impactKey:"drOtherGuruChandalImpact",remediesKey:"drOtherGuruChandalRemedies"},{summaryKey:"punarphoo",detailKey:"punarphoo",labelKey:"drOtherPunarphoo",descKey:"drOtherPunarphooDesc",impactKey:"drOtherPunarphooImpact",remediesKey:"drOtherPunarphooRemedies"},{summaryKey:"kemadruma",detailKey:"kemadruma",labelKey:"drOtherKemadruma",descKey:"drOtherKemadrumaDesc",impactKey:"drOtherKemadrumaImpact",remediesKey:"drOtherKemadrumaRemedies"},{summaryKey:"gandmool",detailKey:"gandmool",labelKey:"drOtherGandmool",descKey:"drOtherGandmoolDesc",impactKey:"drOtherGandmoolImpact",remediesKey:"drOtherGandmoolRemedies"},{summaryKey:"kalathra",detailKey:"kalathra",labelKey:"drOtherKalathra",descKey:"drOtherKalathraDec",impactKey:"drOtherKalathraImpact",remediesKey:"drOtherKalathraRemedies"},{summaryKey:"vishDaridra",detailKey:"vishDaridra",labelKey:"drOtherVishDaridra",descKey:"drOtherVishDaridraDesc",impactKey:"drOtherVishDaridraImpact",remediesKey:"drOtherVishDaridraRemedies"},{summaryKey:"ketuNaga",detailKey:"ketuNaga",labelKey:"drOtherKetuNaga",descKey:"drOtherKetuNagaDesc",impactKey:"drOtherKetuNagaImpact",remediesKey:"drOtherKetuNagaRemedies"},{summaryKey:"navagrahaUmbrella",detailKey:"navagraha",labelKey:"drOtherNavagraha",descKey:"drOtherNavagrahaDesc",impactKey:"drOtherNavagrahaImpact",remediesKey:"drOtherNavagrahaRemedies"}],je=ue.filter(j=>Nt(T[j.summaryKey])).length>0,Se=Nt(T.mangal)&&!Un(T.mangal)||Nt(T.kaalSarp)||Nt(T.pitra)||Nt(L)||je,F=[];for(const j of Ql){const z=j.summaryKey==="shaniSadeSati"?L:T[j.summaryKey];if(!Nt(z)||j.type==="mangal"&&Un(z))continue;const Z=T[j.severityKey],se=j.type==="shani"?T.shaniPhase??T.shaniPhase:void 0,he=ec(N,j.detailKey==="sadeSati"?"sadeSati":j.detailKey),le=he?.explanation??e("drBasedOnPositions"),ce=(he?.remedies??e(j.remediesKey)).split(`
126
126
  `).map(Le=>Le.trim()).filter(Boolean),Je=e(j.benefitsKey).split(`
127
- `).map(Le=>Le.trim()).filter(Boolean);F.push({type:j.type,detailKey:j.detailKey,label:e(j.nameKey),icon:j.icon,status:z??"",severity:Z||"moderate",phase:se??void 0,explanation:le,placements:he?.placements,impact:e(j.impactKey),remedies:ce,benefits:Je})}F.sort((j,z)=>rc(z.severity)-rc(j.severity));const[X,W]=k.useState(!1),oe=/\b(house|lagna|ascendant|moon|mars|saturn|rahu|ketu|sun|jupiter|venus|mercury|sign|degree|H\d+|conjunction|aspect)\b|भाव|लग्न|चंद्र|मंगल|शनि|राहु|केतु|सूर्य|बृहस्पति|शुक्र|बुध/i,ye=N&&typeof N=="object"&&!Array.isArray(N)?N:{},ne=[];F.forEach(j=>{const z=ye[j.detailKey==="sadeSati"?"sadeSati":j.detailKey]||{},Z=[...z.placements||[],...z.triggeredBy||[],...z.notes||[]].map(ae=>String(ae||"").trim()).filter(Boolean),se=Array.from(new Set(Z)),he=se.filter(ae=>oe.test(ae)),le=he.length>0?he:se;le.length>0&&ne.push({label:j.label,evidence:le})}),ue.forEach(j=>{if(!Nt(T[j.summaryKey]))return;const z=ye[j.detailKey]||{},Z=[...z.placements||[],...z.triggeredBy||[],...z.notes||[]].map(ae=>String(ae||"").trim()).filter(Boolean),se=Array.from(new Set(Z)),he=se.filter(ae=>oe.test(ae)),le=he.length>0?he:se;if(le.length>0){const ae=e(j.labelKey);ne.some(ce=>ce.label===ae)||ne.push({label:ae,evidence:le})}});const de=j=>j===1?e("drPhaseRising"):j===2?e("drPhasePeak"):j===3?e("drPhaseSetting"):"",G=["bg-orange-50/50 border-l-4 border-l-orange-400","bg-blue-50/50 border-l-4 border-l-blue-400","bg-purple-50/50 border-l-4 border-l-purple-400","bg-amber-50/50 border-l-4 border-l-amber-400"];return d.jsxs("div",{className:`w-full max-w-2xl mx-auto space-y-6 ${s}`,children:[d.jsxs("div",{className:"px-4 pt-4 pb-2 mb-6",children:[d.jsxs("div",{className:"text-center",children:[d.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"#1F2937",fontFamily:'"Plus Jakarta Sans", sans-serif'},children:e("resultPageTitle")}),d.jsx("p",{className:"text-sm leading-relaxed",style:{color:"#6B7280",fontFamily:'"Plus Jakarta Sans", sans-serif'},children:e("resultPageSubtitle")})]}),r?d.jsxs("button",{type:"button",onClick:r,className:"mt-4 inline-flex items-center gap-2 min-h-[44px] px-4 text-sm font-medium border border-gray-300 bg-white rounded-md hover:bg-gray-50 transition-colors text-gray-700",style:{fontFamily:'"Plus Jakarta Sans", sans-serif'},children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[d.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),d.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),e("resultEditForm")]}):null]}),d.jsxs(dr,{className:"spiritual-glow border-2 border-primary/20 mx-4",children:[d.jsx(Kr,{children:d.jsx(zr,{id:"dosha-results-heading",className:`text-2xl sm:text-3xl font-bold break-words ${Se?"text-primary":"text-success"}`,children:Se?e("resultSomeDoshas"):`✓ ${e("resultNoDoshas")}`})}),d.jsx(Ar,{children:Se?d.jsx("div",{className:"flex flex-wrap gap-2",children:F.map(j=>d.jsxs("div",{className:"inline-flex items-center gap-2 bg-accent/20 border border-accent/30 px-4 py-2 rounded-full",children:[d.jsx(si,{className:"w-4 h-4 text-primary"}),d.jsxs("span",{className:"font-medium text-sm text-foreground",children:[j.label,": ",tc(j.status,e)]})]},j.type))}):d.jsxs("div",{className:"text-center py-8",children:[d.jsx(Gl,{className:"w-12 h-12 mx-auto mb-4 text-success"}),d.jsx("p",{className:"text-lg font-medium text-foreground",children:e("resultNoDoshas")}),d.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:e("resultNoDoshasDesc")})]})})]}),F.map((j,z)=>{const Z=j.icon,se=j.type==="shani"&&j.phase?de(j.phase):"",he=G[z%G.length],le=e("drDoshaOf").replace("{{index}}",String(z+1)).replace("{{total}}",String(F.length));return d.jsxs(dr,{className:`spiritual-glow border border-primary/10 ${he}`,children:[d.jsx("div",{className:"px-4 pt-3",children:d.jsx(Ln,{variant:"outline",className:"text-xs font-normal text-muted-foreground",children:le})}),d.jsxs(Kr,{className:"pb-3 pt-2",children:[d.jsxs(zr,{className:"flex items-center gap-3 text-xl",children:[d.jsx(Z,{className:"w-6 h-6 text-primary"}),j.label]}),d.jsxs(Dn,{children:[e("drSeverity"),": ",sc(j.severity,e),j.phase!=null&&` • ${e("drPhase")}: ${j.phase}`]})]}),d.jsxs(Ar,{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsxs("h4",{className:"font-semibold text-base flex items-center gap-2",children:[d.jsx(Un,{className:"w-4 h-4 text-primary"}),e("drWhyMarked"),n&&d.jsxs("button",{type:"button",onClick:()=>{g?.trackDoshaCalculatorResultViewKundliClick?.(!0);const ae=document.getElementById(n);ae&&ae.scrollIntoView({behavior:"smooth",block:"center"})},className:"text-xs text-primary hover:underline ml-auto whitespace-nowrap",children:[e("drViewKundli")," ↓"]})]}),d.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:j.explanation}),se&&d.jsxs("div",{className:"mt-3 p-3 bg-warning/10 rounded-md border border-warning/20",children:[d.jsx("h5",{className:"font-medium text-sm mb-2",children:e("drPhaseMeaning")}),d.jsx("p",{className:"text-sm text-muted-foreground",children:se})]}),j.type!=="pitra"&&j.placements&&j.placements.length>0&&d.jsxs("div",{className:"mt-3 p-3 bg-accent/10 rounded-md border border-accent/20",children:[d.jsx("h5",{className:"font-medium text-sm mb-2",children:e("drPlanetaryPositions")}),d.jsx("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:j.placements.map((ae,ce)=>d.jsx("li",{children:ae},ce))})]})]}),d.jsxs("div",{className:"p-4 bg-destructive/10 border border-destructive/20 rounded-lg",children:[d.jsx("h4",{className:"font-semibold text-sm mb-2 text-destructive",children:v[j.type]?.title||e("drImpactIfPresent")}),_?d.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[d.jsx(Zl,{className:"w-4 h-4 animate-spin"}),d.jsx("span",{children:p==="hi"?"प्रभाव विश्लेषण हो रहा है...":"Analyzing impact..."})]}):d.jsx("p",{className:"text-sm text-muted-foreground",children:v[j.type]?.text||j.impact})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"font-semibold text-base",children:e("drPujaRecommendation")}),i?o?d.jsx("div",{className:"flex items-center justify-center py-6",children:d.jsx(Zl,{className:"w-6 h-6 text-primary animate-spin"})}):i(j.type)||d.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("drNoPujaAvailable")}):d.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("drNoPujaAvailable")})]}),j.benefits.length>0&&d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"font-semibold text-base flex items-center gap-2",children:e("drHowPujaHelps")}),d.jsx("ul",{className:"text-sm text-muted-foreground space-y-3 ml-1",children:j.benefits.map((ae,ce)=>d.jsxs("li",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"text-primary mt-1.5 flex-shrink-0",children:"•"}),d.jsx("span",{children:ae})]},ce))})]})]})]},j.type)}),F.length>0&&d.jsx("p",{className:"text-xs text-muted-foreground text-center italic px-4",children:e("drFomoLine")}),d.jsxs("div",{className:"mt-6 p-4 bg-muted/30 rounded-lg border border-border/50 text-center",children:[d.jsx("p",{className:"text-sm text-foreground/80 font-medium",children:e("drFeedbackContact")}),d.jsx("a",{href:`mailto:${a}`,className:"text-primary hover:underline font-semibold text-base mt-1 inline-block",children:a})]}),d.jsxs(dr,{className:"spiritual-glow",children:[d.jsxs(Kr,{children:[d.jsx(zr,{className:"text-2xl font-bold text-center gradient-spiritual bg-clip-text text-transparent",children:e("drDetailedAnalysis")}),d.jsx(Dn,{className:"text-center",children:e("drBasedOnChart")})]}),d.jsx(Ar,{className:"space-y-4",children:d.jsx(Yl,{type:"single",collapsible:!0,className:"w-full space-y-4",children:Ql.map(j=>{const z=j.detailKey==="sadeSati"?"sadeSati":j.detailKey,Z=j.summaryKey==="shaniSadeSati"?L:T[j.summaryKey],se=ec(N,j.detailKey==="sadeSati"?"sadeSati":j.detailKey),he=T[j.severityKey],le=j.type==="shani"?T.shaniPhase:void 0,ae=j.icon,Je=(se?.remedies?.trim()||e(j.remediesKey)).split(`
128
- `).map(Le=>Le.trim()).filter(Boolean);return d.jsxs(ni,{value:z,className:"border border-border rounded-lg px-4",children:[d.jsx(ai,{value:z,className:"hover:no-underline",children:d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx(ae,{className:"w-5 h-5 text-destructive"}),d.jsxs("div",{className:"text-left",children:[d.jsx("h3",{className:"font-semibold text-lg",children:e(j.nameKey)}),d.jsxs("p",{className:"text-sm text-muted-foreground",children:[e("drStatus"),": ",tc(Z,e),he&&!Bn(Z)&&` • ${e("drSeverity")}: ${sc(he,e)}`,j.type==="shani"&&le!=null&&` • ${e("drPhase")}: ${le}`]})]})]})}),d.jsxs(ii,{className:"pt-4 space-y-4",children:[d.jsx("p",{className:"text-sm text-muted-foreground italic",children:e(j.descKey)}),se?.explanation&&d.jsxs("div",{children:[d.jsx("h4",{className:"font-medium mb-2",children:e("drExplanation")}),d.jsx("p",{className:"text-sm text-muted-foreground",children:se.explanation})]}),se?.placements&&se.placements.length>0&&d.jsxs("div",{className:"p-3 bg-accent/10 rounded-md",children:[d.jsx("h4",{className:"font-medium mb-2",children:e("drPlanetaryPositions")}),d.jsx("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:se.placements.map((Le,ut)=>d.jsx("li",{children:Le},ut))})]}),d.jsxs("div",{children:[d.jsx("h4",{className:"font-medium mb-2",children:e("drTraditionalRemedies")}),d.jsx("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:Je.map((Le,ut)=>d.jsx("li",{children:Le},ut))})]})]})]},z)})})})]}),d.jsxs(dr,{children:[d.jsx(Kr,{className:"cursor-pointer hover:bg-accent/5 transition-colors",onClick:()=>W(j=>!j),children:d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsxs("div",{className:"text-left flex-1 min-w-0",children:[d.jsx(zr,{className:"text-xl font-semibold",children:e("drOtherDoshas")}),d.jsx(Dn,{children:e(je?"drOtherDoshasStatusActive":"drOtherDoshasStatusNone")})]}),d.jsx(Jl,{className:`h-5 w-5 flex-shrink-0 text-muted-foreground transition-transform duration-200 ${X?"rotate-180":""}`})]})}),X&&d.jsx(Ar,{children:d.jsx(Yl,{type:"single",collapsible:!0,className:"w-full space-y-2",children:ue.map(j=>{const z=T[j.summaryKey],Z=Nt(z),se=ye[j.detailKey]??{},he=se.explanation,le=se.placements;return d.jsxs(ni,{value:j.summaryKey,className:"border border-border rounded-lg px-3",children:[d.jsx(ai,{className:"hover:no-underline py-3",children:d.jsxs("div",{className:"flex items-center justify-between gap-2 flex-1 min-w-0 mr-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"font-semibold text-sm text-left leading-tight",children:e(j.labelKey)}),d.jsx(Un,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"})]}),Z?d.jsxs(Ln,{variant:"destructive",className:"flex-shrink-0 text-xs flex items-center gap-1 pointer-events-none",children:[d.jsx(si,{className:"w-3 h-3"}),e("drStatusPresent")]}):d.jsxs(Ln,{variant:"secondary",className:"flex-shrink-0 text-xs flex items-center gap-1 bg-white border pointer-events-none",style:{borderColor:"#e4decd",color:"#000000"},children:[d.jsx(Gl,{className:"w-3 h-3",color:"#000000"}),e("drStatusAbsent")]})]})}),d.jsxs(ii,{className:"space-y-3 pt-0 pb-3",children:[d.jsx("div",{className:"border-l-4 border-orange-500 bg-orange-50 rounded-lg pl-3 py-2",children:d.jsx("p",{className:"text-sm text-muted-foreground italic",children:e(j.descKey)})}),le&&le.length>0&&d.jsxs("div",{className:"p-3 bg-accent/10 rounded-md border border-accent/20",children:[d.jsxs("h5",{className:"font-medium mb-2 flex items-center gap-2 text-sm",children:[d.jsx(Un,{className:"w-4 h-4"}),e("drPlanetaryPositions")]}),d.jsx("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 leading-relaxed",children:le.map((ae,ce)=>d.jsx("li",{children:ae},ce))})]}),he&&d.jsxs("div",{className:"border-l-4 border-orange-500 bg-orange-50 rounded-lg pl-3 py-2",children:[d.jsxs("h5",{className:"font-medium mb-2 text-sm flex items-center gap-2",children:[d.jsx(Un,{className:"w-3.5 h-3.5"}),e(Z?"drWhyPresent":"drWhyAbsent")]}),d.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:he})]}),Z&&d.jsxs("div",{className:"border-l-4 border-red-500 bg-red-50 rounded-lg pl-3 py-2",children:[d.jsxs("h5",{className:"font-medium mb-2 text-sm flex items-center gap-2 text-red-600",children:[d.jsx(si,{className:"w-3.5 h-3.5"}),e("drImpact")]}),d.jsx("p",{className:"text-sm text-muted-foreground",children:e(j.impactKey)})]}),Z&&d.jsxs("div",{children:[d.jsx("h5",{className:"font-medium mb-2 text-sm",children:e("drTraditionalRemedies")}),d.jsx("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:e(j.remediesKey).split(`
129
- `).map((ae,ce)=>d.jsx("li",{children:ae},ce))})]})]})]},j.summaryKey)})})})]}),d.jsx("div",{id:n||"kundali-chart-section",children:(l||E||ne.length>0)&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"flex justify-end mb-2",children:d.jsxs("button",{type:"button",onClick:()=>document.getElementById("dosha-results-heading")?.scrollIntoView({behavior:"smooth",block:"start"}),className:"inline-flex items-center gap-1.5 text-sm text-primary hover:text-primary/80 transition-colors font-medium",children:[d.jsx(wm,{className:"w-4 h-4"}),e("drGoBack")]})}),l?d.jsxs("div",{className:"mt-2",children:[d.jsx("h2",{className:"text-xl font-semibold text-foreground mb-3",children:e("drYourKundali")}),l()]}):E&&c&&u?d.jsx("div",{className:"mt-2",children:d.jsx(Tm,{birthDetails:c,supabase:u,language:p,t:e})}):null,ne.length>0&&d.jsxs(dr,{className:"mt-4 bg-accent/10 border border-accent/30",children:[d.jsx(Kr,{className:"pb-2",children:d.jsx(zr,{className:"text-base font-semibold",children:e("drPlanetaryPositionsCausing")})}),d.jsx(Ar,{className:"pt-0",children:d.jsx("ul",{className:"space-y-3 text-sm text-muted-foreground",children:ne.map((j,z)=>d.jsxs("li",{children:[d.jsxs("div",{className:"font-semibold text-foreground mb-1",children:[j.label,":"]}),d.jsx("ul",{className:"ml-4 space-y-1",children:j.evidence.map((Z,se)=>d.jsxs("li",{className:"flex items-start gap-2",children:[d.jsx("span",{className:"text-primary flex-shrink-0",children:"→"}),d.jsx("span",{children:Z})]},se))})]},z))})})]})]})}),d.jsx("p",{className:"text-xs text-muted-foreground/70 text-center px-4",children:e("drDisclaimer")})]})}const jm=t=>{if(!t)return"";const[e,r,s]=t.split("-");return`${s}/${r}/${e}`},Om=({value:t,onChange:e,error:r,disabled:s=!1,onOpen:n})=>{const a=k.useRef(null),i=(()=>{const l=new Date,c=u=>String(u).padStart(2,"0");return`${l.getFullYear()}-${c(l.getMonth()+1)}-${c(l.getDate())}`})(),o=()=>{n?.();const l=a.current;if(l&&typeof l.showPicker=="function")try{l.showPicker()}catch{l?.focus()}else l?.focus()};return d.jsxs("div",{children:[d.jsxs("div",{className:"relative",style:{height:"48px"},children:[!t&&d.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 text-base pointer-events-none",style:{zIndex:1},children:"Select Date of Birth"}),t&&d.jsx("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-900 text-base pointer-events-none",style:{zIndex:1},children:jm(t)}),d.jsx(ds,{ref:a,type:"date",value:t,max:i,onChange:l=>{const c=l.target.value;c&&c>i||e(c)},onClick:o,onFocus:o,disabled:s,className:r?"border-red-500":""}),d.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400","aria-label":"Open date picker",onMouseDown:l=>l.preventDefault(),onClick:l=>{l.preventDefault(),l.stopPropagation(),o()},children:d.jsx(Pd,{size:20})})]}),r&&d.jsx("p",{className:"text-sm text-red-500 mt-1",children:r})]})},Vn=t=>String(t).padStart(2,"0");function Pm(t){if(!t||!/^\d{2}:\d{2}$/.test(t))return"";const[e,r]=t.split(":").map(Number),s=e===0?12:e>12?e-12:e,n=e>=12?"PM":"AM";return`${s}:${Vn(r)} ${n}`}function Nm(t){if(!/^\d{2}:\d{2}$/.test(t))return{hour12:12,minute:"00",meridiem:"AM"};const[e,r]=t.split(":").map(Number),s=e===0?12:e>12?e-12:e,n=e>=12?"PM":"AM";return{hour12:s,minute:Vn(r),meridiem:n}}function Rm(t){let e=t.hour12;return t.meridiem==="AM"&&e===12&&(e=0),t.meridiem==="PM"&&e!==12&&(e+=12),`${Vn(e)}:${t.minute}`}const Im=({value:t,onChange:e,error:r,disabled:s=!1,onOpen:n})=>{const a=k.useRef(null),[i,o]=k.useState(!1),[l,c]=k.useState({hour12:12,minute:"00",meridiem:"AM"});k.useEffect(()=>{const f=h=>{a.current&&(a.current.contains(h.target)||o(!1))};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const u=()=>{s||(n?.(),c(Nm(t||"12:00")),o(f=>!f))},p=()=>{const f=Rm(l);e(f),o(!1)};return d.jsxs("div",{ref:a,children:[d.jsxs("div",{className:"relative",style:{height:"48px"},children:[d.jsx(ds,{type:"text",value:t?Pm(t):"",readOnly:!0,disabled:s,placeholder:"Exact Time of Birth",onClick:u,className:r?"border-red-500 placeholder:text-[#999ea7]":"placeholder:text-[#999ea7]"}),d.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400","aria-label":"Open time picker",disabled:s,onMouseDown:f=>f.preventDefault(),onClick:f=>{f.preventDefault(),f.stopPropagation(),u()},children:d.jsx(Id,{size:20})})]}),i&&!s&&d.jsxs("div",{className:"absolute z-50 mt-2 p-4 bg-white border rounded-lg shadow-lg",role:"dialog","aria-label":"Select time",children:[d.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[d.jsx("select",{className:"border rounded px-2 py-1",value:l.hour12,onChange:f=>c(h=>({...h,hour12:Number(f.target.value)})),"aria-label":"Hour",children:Array.from({length:12},(f,h)=>h+1).map(f=>d.jsx("option",{value:f,children:f},f))}),d.jsx("span",{children:":"}),d.jsx("select",{className:"border rounded px-2 py-1",value:l.minute,onChange:f=>c(h=>({...h,minute:f.target.value})),"aria-label":"Minute",children:Array.from({length:60},(f,h)=>Vn(h)).map(f=>d.jsx("option",{value:f,children:f},f))}),d.jsxs("div",{className:"flex gap-1 ml-2",children:[d.jsx("button",{type:"button",className:`px-3 py-1 text-sm rounded ${l.meridiem==="AM"?"bg-orange-500 text-white":"bg-gray-200"}`,onClick:()=>c(f=>({...f,meridiem:"AM"})),children:"AM"}),d.jsx("button",{type:"button",className:`px-3 py-1 text-sm rounded ${l.meridiem==="PM"?"bg-orange-500 text-white":"bg-gray-200"}`,onClick:()=>c(f=>({...f,meridiem:"PM"})),children:"PM"})]})]}),d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx("button",{type:"button",className:"px-4 py-2 text-sm bg-gray-200 rounded hover:bg-gray-300",onClick:()=>o(!1),children:"Cancel"}),d.jsx("button",{type:"button",className:"px-4 py-2 text-sm bg-orange-500 text-white rounded hover:bg-orange-600",onClick:p,children:"OK"})]})]}),r&&d.jsx("p",{className:"text-sm text-red-500 mt-1",children:r})]})},Dm=t=>{typeof window<"u"&&console.log("FB Pixel - Field Filled:",t)},Lm=()=>{typeof window<"u"&&console.log("FB Pixel - Calculate Dosha Clicked")},$m=Symbol.for("@supabase/supabase-js.traceContextExtractor");function Mm(){return globalThis[$m]}function Kn(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r}function Fm(t,e,r,s){function n(a){return a instanceof r?a:new r(function(i){i(a)})}return new(r||(r=Promise))(function(a,i){function o(u){try{c(s.next(u))}catch(p){i(p)}}function l(u){try{c(s.throw(u))}catch(p){i(p)}}function c(u){u.done?a(u.value):n(u.value).then(o,l)}c((s=s.apply(t,e||[])).next())})}typeof SuppressedError=="function"&&SuppressedError;const Um=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class li extends Error{constructor(e,r="FunctionsError",s){super(e),this.name=r,this.context=s}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class Bm extends li{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class nc extends li{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class ac extends li{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var ci;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(ci||(ci={}));class Vm{constructor(e,{headers:r={},customFetch:s,region:n=ci.Any}={}){this.url=e,this.headers=r,this.region=n,this.fetch=Um(s)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return Fm(this,arguments,void 0,function*(r,s={}){var n,a;let i,o,l;try{const{headers:c,method:u,body:p,signal:f,timeout:h}=s;let y={},{region:g}=s;g||(g=this.region);const v=new URL(`${this.url}/${r}`);g&&g!=="any"&&(y["x-region"]=g,v.searchParams.set("forceFunctionRegion",g));let C;const _=!!c&&Object.keys(c).some(ue=>ue.toLowerCase()==="content-type");p&&!_?typeof Blob<"u"&&p instanceof Blob||p instanceof ArrayBuffer?(y["Content-Type"]="application/octet-stream",C=p):typeof p=="string"?(y["Content-Type"]="text/plain",C=p):typeof FormData<"u"&&p instanceof FormData?C=p:(y["Content-Type"]="application/json",C=JSON.stringify(p)):p&&typeof p!="string"&&!(typeof Blob<"u"&&p instanceof Blob)&&!(p instanceof ArrayBuffer)&&!(typeof FormData<"u"&&p instanceof FormData)?C=JSON.stringify(p):C=p;let S=f;h&&(o=new AbortController,i=setTimeout(()=>o.abort(),h),f?(S=o.signal,l=()=>o.abort(),f.addEventListener("abort",l)):S=o.signal);const E=yield this.fetch(v.toString(),{method:u||"POST",headers:Object.assign(Object.assign(Object.assign({},y),this.headers),c),body:C,signal:S}).catch(ue=>{throw new Bm(ue)}),T=E.headers.get("x-relay-error");if(T&&T==="true")throw new nc(E);if(!E.ok)throw new ac(E);let N=((n=E.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim().toLowerCase(),L;return N==="application/json"?L=yield E.json():N==="application/octet-stream"||N==="application/pdf"?L=yield E.blob():N==="text/event-stream"?L=E:N==="multipart/form-data"?L=yield E.formData():L=yield E.text(),{data:L,error:null,response:E}}catch(c){return{data:null,error:c,response:c instanceof ac||c instanceof nc?c.context:void 0}}finally{i&&clearTimeout(i),l&&((a=s.signal)===null||a===void 0||a.removeEventListener("abort",l))}})}}var ys=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};const ic=3,oc=t=>Math.min(1e3*2**t,3e4),Km=[520,503],lc=["GET","HEAD","OPTIONS"];function Js(t){"@babel/helpers - typeof";return Js=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Js(t)}function zm(t,e){if(Js(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(Js(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Hm(t){var e=zm(t,"string");return Js(e)=="symbol"?e:e+""}function Wm(t,e,r){return(e=Hm(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function cc(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function Hr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?cc(Object(r),!0).forEach(function(s){Wm(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):cc(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}function uc(t,e){return new Promise(r=>{if(e?.aborted){r();return}const s=setTimeout(()=>{e?.removeEventListener("abort",n),r()},t);function n(){clearTimeout(s),r()}e?.addEventListener("abort",n)})}function qm(t,e,r,s){return!(!s||r>=ic||!lc.includes(t)||!Km.includes(e))}async function dc(t,e,r,s){let n=0;for(;;){const o=Hr({},r.headers);n>0&&(o["X-Retry-Count"]=String(n));let l;try{l=await t(e,{method:r.method,headers:o,body:r.body,signal:r.signal})}catch(c){if(c?.name==="AbortError"||c?.code==="ABORT_ERR"||!lc.includes(r.method))throw c;if(s&&n<ic){const u=oc(n);n++,await uc(u,r.signal);continue}throw c}if(qm(r.method,l.status,n,s)){var a,i;const c=(a=(i=l.headers)===null||i===void 0?void 0:i.get("Retry-After"))!==null&&a!==void 0?a:null,u=c!==null?Math.max(0,parseInt(c,10)||0)*1e3:oc(n);await l.text(),n++,await uc(u,r.signal);continue}return l}}var Gm=class{constructor(t){var e,r,s,n,a;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(r=t.isMaybeSingle)!==null&&r!==void 0?r:!1,this.shouldStripNulls=(s=t.shouldStripNulls)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(n=t.urlLengthLimit)!==null&&n!==void 0?n:8e3,this.retryEnabled=(a=t.retry)!==null&&a!==void 0?a:!0,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if(this.headers.get("Accept")==="text/csv")throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}retry(t){return this.retryEnabled=t,this}then(t,e){var r=this;if(this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){const i=this.headers.get("Accept");i==="application/vnd.pgrst.object+json"?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):(!i||i==="application/json")&&this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const s=this.fetch;let a=(async()=>{const i={};r.headers.forEach((l,c)=>{i[c]=l});const o=await dc(s,r.url.toString(),{method:r.method,headers:i,body:JSON.stringify(r.body,(l,c)=>typeof c=="bigint"?c.toString():c),signal:r.signal},r.retryEnabled);return await r.processResponse(o)})();return this.shouldThrowOnError||(a=a.catch(i=>{var o;let l="",c="",u="";const p=i?.cause;if(p){var f,h,y,g;const _=(f=p?.message)!==null&&f!==void 0?f:"",S=(h=p?.code)!==null&&h!==void 0?h:"";l=`${(y=i?.name)!==null&&y!==void 0?y:"FetchError"}: ${i?.message}`,l+=`
127
+ `).map(Le=>Le.trim()).filter(Boolean);F.push({type:j.type,detailKey:j.detailKey,label:e(j.nameKey),icon:j.icon,status:z??"",severity:Z||"moderate",phase:se??void 0,explanation:le,placements:he?.placements,impact:e(j.impactKey),remedies:ce,benefits:Je})}F.sort((j,z)=>rc(z.severity)-rc(j.severity));const[X,W]=k.useState(!1),oe=/\b(house|lagna|ascendant|moon|mars|saturn|rahu|ketu|sun|jupiter|venus|mercury|sign|degree|H\d+|conjunction|aspect)\b|भाव|लग्न|चंद्र|मंगल|शनि|राहु|केतु|सूर्य|बृहस्पति|शुक्र|बुध/i,ye=N&&typeof N=="object"&&!Array.isArray(N)?N:{},ne=[];F.forEach(j=>{const z=ye[j.detailKey==="sadeSati"?"sadeSati":j.detailKey]||{},Z=[...z.placements||[],...z.triggeredBy||[],...z.notes||[]].map(ae=>String(ae||"").trim()).filter(Boolean),se=Array.from(new Set(Z)),he=se.filter(ae=>oe.test(ae)),le=he.length>0?he:se;le.length>0&&ne.push({label:j.label,evidence:le})}),ue.forEach(j=>{if(!Nt(T[j.summaryKey]))return;const z=ye[j.detailKey]||{},Z=[...z.placements||[],...z.triggeredBy||[],...z.notes||[]].map(ae=>String(ae||"").trim()).filter(Boolean),se=Array.from(new Set(Z)),he=se.filter(ae=>oe.test(ae)),le=he.length>0?he:se;if(le.length>0){const ae=e(j.labelKey);ne.some(ce=>ce.label===ae)||ne.push({label:ae,evidence:le})}});const de=j=>j===1?e("drPhaseRising"):j===2?e("drPhasePeak"):j===3?e("drPhaseSetting"):"",G=["bg-orange-50/50 border-l-4 border-l-orange-400","bg-blue-50/50 border-l-4 border-l-blue-400","bg-purple-50/50 border-l-4 border-l-purple-400","bg-amber-50/50 border-l-4 border-l-amber-400"];return u.jsxs("div",{className:`w-full max-w-2xl mx-auto space-y-6 ${s}`,children:[u.jsxs("div",{className:"px-4 pt-4 pb-2 mb-6",children:[u.jsxs("div",{className:"text-center",children:[u.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"#1F2937",fontFamily:'"Plus Jakarta Sans", sans-serif'},children:e("resultPageTitle")}),u.jsx("p",{className:"text-sm leading-relaxed",style:{color:"#6B7280",fontFamily:'"Plus Jakarta Sans", sans-serif'},children:e("resultPageSubtitle")})]}),r?u.jsxs("button",{type:"button",onClick:r,className:"mt-4 inline-flex items-center gap-2 min-h-[44px] px-4 text-sm font-medium border border-gray-300 bg-white rounded-md hover:bg-gray-50 transition-colors text-gray-700",style:{fontFamily:'"Plus Jakarta Sans", sans-serif'},children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[u.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),u.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),e("resultEditForm")]}):null]}),u.jsxs(dr,{className:"spiritual-glow border-2 border-primary/20 mx-4",children:[u.jsx(Kr,{children:u.jsx(zr,{id:"dosha-results-heading",className:`text-2xl sm:text-3xl font-bold break-words ${Se?"text-primary":"text-success"}`,children:Se?e("resultSomeDoshas"):`✓ ${e("resultNoDoshas")}`})}),u.jsx(Ar,{children:Se?u.jsx("div",{className:"flex flex-wrap gap-2",children:F.map(j=>u.jsxs("div",{className:"inline-flex items-center gap-2 bg-accent/20 border border-accent/30 px-4 py-2 rounded-full",children:[u.jsx(ri,{className:"w-4 h-4 text-primary"}),u.jsxs("span",{className:"font-medium text-sm text-foreground",children:[j.label,": ",tc(j.status,e)]})]},j.type))}):u.jsxs("div",{className:"text-center py-8",children:[u.jsx(Gl,{className:"w-12 h-12 mx-auto mb-4 text-success"}),u.jsx("p",{className:"text-lg font-medium text-foreground",children:e("resultNoDoshas")}),u.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:e("resultNoDoshasDesc")})]})})]}),F.map((j,z)=>{const Z=j.icon,se=j.type==="shani"&&j.phase?de(j.phase):"",he=G[z%G.length],le=e("drDoshaOf").replace("{{index}}",String(z+1)).replace("{{total}}",String(F.length));return u.jsxs(dr,{className:`spiritual-glow border border-primary/10 ${he}`,children:[u.jsx("div",{className:"px-4 pt-3",children:u.jsx(Dn,{variant:"outline",className:"text-xs font-normal text-muted-foreground",children:le})}),u.jsxs(Kr,{className:"pb-3 pt-2",children:[u.jsxs(zr,{className:"flex items-center gap-3 text-xl",children:[u.jsx(Z,{className:"w-6 h-6 text-primary"}),j.label]}),u.jsxs(In,{children:[e("drSeverity"),": ",sc(j.severity,e),j.phase!=null&&` • ${e("drPhase")}: ${j.phase}`]})]}),u.jsxs(Ar,{className:"space-y-4",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsxs("h4",{className:"font-semibold text-base flex items-center gap-2",children:[u.jsx(Fn,{className:"w-4 h-4 text-primary"}),e("drWhyMarked"),n&&u.jsxs("button",{type:"button",onClick:()=>{y?.trackDoshaCalculatorResultViewKundliClick?.(!0);const ae=document.getElementById(n);ae&&ae.scrollIntoView({behavior:"smooth",block:"center"})},className:"text-xs text-primary hover:underline ml-auto whitespace-nowrap",children:[e("drViewKundli")," ↓"]})]}),u.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:j.explanation}),se&&u.jsxs("div",{className:"mt-3 p-3 bg-warning/10 rounded-md border border-warning/20",children:[u.jsx("h5",{className:"font-medium text-sm mb-2",children:e("drPhaseMeaning")}),u.jsx("p",{className:"text-sm text-muted-foreground",children:se})]}),j.type!=="pitra"&&j.placements&&j.placements.length>0&&u.jsxs("div",{className:"mt-3 p-3 bg-accent/10 rounded-md border border-accent/20",children:[u.jsx("h5",{className:"font-medium text-sm mb-2",children:e("drPlanetaryPositions")}),u.jsx("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:j.placements.map((ae,ce)=>u.jsx("li",{children:ae},ce))})]})]}),u.jsxs("div",{className:"p-4 bg-destructive/10 border border-destructive/20 rounded-lg",children:[u.jsx("h4",{className:"font-semibold text-sm mb-2 text-destructive",children:v[j.type]?.title||e("drImpactIfPresent")}),_?u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsx(Zl,{className:"w-4 h-4 animate-spin"}),u.jsx("span",{children:f==="hi"?"प्रभाव विश्लेषण हो रहा है...":"Analyzing impact..."})]}):u.jsx("p",{className:"text-sm text-muted-foreground",children:v[j.type]?.text||j.impact})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"font-semibold text-base",children:e("drPujaRecommendation")}),i?o?u.jsx("div",{className:"flex items-center justify-center py-6",children:u.jsx(Zl,{className:"w-6 h-6 text-primary animate-spin"})}):i(j.type)||u.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("drNoPujaAvailable")}):u.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("drNoPujaAvailable")})]}),j.benefits.length>0&&u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"font-semibold text-base flex items-center gap-2",children:e("drHowPujaHelps")}),u.jsx("ul",{className:"text-sm text-muted-foreground space-y-3 ml-1",children:j.benefits.map((ae,ce)=>u.jsxs("li",{className:"flex items-start gap-3",children:[u.jsx("span",{className:"text-primary mt-1.5 flex-shrink-0",children:"•"}),u.jsx("span",{children:ae})]},ce))})]})]})]},j.type)}),F.length>0&&u.jsx("p",{className:"text-xs text-muted-foreground text-center italic px-4",children:e("drFomoLine")}),u.jsxs("div",{className:"mt-6 p-4 bg-muted/30 rounded-lg border border-border/50 text-center",children:[u.jsx("p",{className:"text-sm text-foreground/80 font-medium",children:e("drFeedbackContact")}),u.jsx("a",{href:`mailto:${a}`,className:"text-primary hover:underline font-semibold text-base mt-1 inline-block",children:a})]}),u.jsxs(dr,{className:"spiritual-glow",children:[u.jsxs(Kr,{children:[u.jsx(zr,{className:"text-2xl font-bold text-center gradient-spiritual bg-clip-text text-transparent",children:e("drDetailedAnalysis")}),u.jsx(In,{className:"text-center",children:e("drBasedOnChart")})]}),u.jsx(Ar,{className:"space-y-4",children:u.jsx(Yl,{type:"single",collapsible:!0,className:"w-full space-y-4",children:Ql.map(j=>{const z=j.detailKey==="sadeSati"?"sadeSati":j.detailKey,Z=j.summaryKey==="shaniSadeSati"?L:T[j.summaryKey],se=ec(N,j.detailKey==="sadeSati"?"sadeSati":j.detailKey),he=T[j.severityKey],le=j.type==="shani"?T.shaniPhase:void 0,ae=j.icon,Je=(se?.remedies?.trim()||e(j.remediesKey)).split(`
128
+ `).map(Le=>Le.trim()).filter(Boolean);return u.jsxs(si,{value:z,className:"border border-border rounded-lg px-4",children:[u.jsx(ni,{value:z,className:"hover:no-underline",children:u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(ae,{className:"w-5 h-5 text-destructive"}),u.jsxs("div",{className:"text-left",children:[u.jsx("h3",{className:"font-semibold text-lg",children:e(j.nameKey)}),u.jsxs("p",{className:"text-sm text-muted-foreground",children:[e("drStatus"),": ",tc(Z,e),he&&!Un(Z)&&` • ${e("drSeverity")}: ${sc(he,e)}`,j.type==="shani"&&le!=null&&` • ${e("drPhase")}: ${le}`]})]})]})}),u.jsxs(ai,{className:"pt-4 space-y-4",children:[u.jsx("p",{className:"text-sm text-muted-foreground italic",children:e(j.descKey)}),se?.explanation&&u.jsxs("div",{children:[u.jsx("h4",{className:"font-medium mb-2",children:e("drExplanation")}),u.jsx("p",{className:"text-sm text-muted-foreground",children:se.explanation})]}),se?.placements&&se.placements.length>0&&u.jsxs("div",{className:"p-3 bg-accent/10 rounded-md",children:[u.jsx("h4",{className:"font-medium mb-2",children:e("drPlanetaryPositions")}),u.jsx("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:se.placements.map((Le,ut)=>u.jsx("li",{children:Le},ut))})]}),u.jsxs("div",{children:[u.jsx("h4",{className:"font-medium mb-2",children:e("drTraditionalRemedies")}),u.jsx("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:Je.map((Le,ut)=>u.jsx("li",{children:Le},ut))})]})]})]},z)})})})]}),u.jsxs(dr,{children:[u.jsx(Kr,{className:"cursor-pointer hover:bg-accent/5 transition-colors",onClick:()=>W(j=>!j),children:u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsxs("div",{className:"text-left flex-1 min-w-0",children:[u.jsx(zr,{className:"text-xl font-semibold",children:e("drOtherDoshas")}),u.jsx(In,{children:e(je?"drOtherDoshasStatusActive":"drOtherDoshasStatusNone")})]}),u.jsx(Jl,{className:`h-5 w-5 flex-shrink-0 text-muted-foreground transition-transform duration-200 ${X?"rotate-180":""}`})]})}),X&&u.jsx(Ar,{children:u.jsx(Yl,{type:"single",collapsible:!0,className:"w-full space-y-2",children:ue.map(j=>{const z=T[j.summaryKey],Z=Nt(z),se=ye[j.detailKey]??{},he=se.explanation,le=se.placements;return u.jsxs(si,{value:j.summaryKey,className:"border border-border rounded-lg px-3",children:[u.jsx(ni,{className:"hover:no-underline py-3",children:u.jsxs("div",{className:"flex items-center justify-between gap-2 flex-1 min-w-0 mr-2",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"font-semibold text-sm text-left leading-tight",children:e(j.labelKey)}),u.jsx(Fn,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"})]}),Z?u.jsxs(Dn,{variant:"destructive",className:"flex-shrink-0 text-xs flex items-center gap-1 pointer-events-none",children:[u.jsx(ri,{className:"w-3 h-3"}),e("drStatusPresent")]}):u.jsxs(Dn,{variant:"secondary",className:"flex-shrink-0 text-xs flex items-center gap-1 bg-white border pointer-events-none",style:{borderColor:"#e4decd",color:"#000000"},children:[u.jsx(Gl,{className:"w-3 h-3",color:"#000000"}),e("drStatusAbsent")]})]})}),u.jsxs(ai,{className:"space-y-3 pt-0 pb-3",children:[u.jsx("div",{className:"border-l-4 border-orange-500 bg-orange-50 rounded-lg pl-3 py-2",children:u.jsx("p",{className:"text-sm text-muted-foreground italic",children:e(j.descKey)})}),le&&le.length>0&&u.jsxs("div",{className:"p-3 bg-accent/10 rounded-md border border-accent/20",children:[u.jsxs("h5",{className:"font-medium mb-2 flex items-center gap-2 text-sm",children:[u.jsx(Fn,{className:"w-4 h-4"}),e("drPlanetaryPositions")]}),u.jsx("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1 leading-relaxed",children:le.map((ae,ce)=>u.jsx("li",{children:ae},ce))})]}),he&&u.jsxs("div",{className:"border-l-4 border-orange-500 bg-orange-50 rounded-lg pl-3 py-2",children:[u.jsxs("h5",{className:"font-medium mb-2 text-sm flex items-center gap-2",children:[u.jsx(Fn,{className:"w-3.5 h-3.5"}),e(Z?"drWhyPresent":"drWhyAbsent")]}),u.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:he})]}),Z&&u.jsxs("div",{className:"border-l-4 border-red-500 bg-red-50 rounded-lg pl-3 py-2",children:[u.jsxs("h5",{className:"font-medium mb-2 text-sm flex items-center gap-2 text-red-600",children:[u.jsx(ri,{className:"w-3.5 h-3.5"}),e("drImpact")]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:e(j.impactKey)})]}),Z&&u.jsxs("div",{children:[u.jsx("h5",{className:"font-medium mb-2 text-sm",children:e("drTraditionalRemedies")}),u.jsx("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:e(j.remediesKey).split(`
129
+ `).map((ae,ce)=>u.jsx("li",{children:ae},ce))})]})]})]},j.summaryKey)})})})]}),u.jsx("div",{id:n||"kundali-chart-section",children:(l||E||ne.length>0)&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"flex justify-end mb-2",children:u.jsxs("button",{type:"button",onClick:()=>document.getElementById("dosha-results-heading")?.scrollIntoView({behavior:"smooth",block:"start"}),className:"inline-flex items-center gap-1.5 text-sm text-primary hover:text-primary/80 transition-colors font-medium",children:[u.jsx(vm,{className:"w-4 h-4"}),e("drGoBack")]})}),l?u.jsxs("div",{className:"mt-2",children:[u.jsx("h2",{className:"text-xl font-semibold text-foreground mb-3",children:e("drYourKundali")}),l()]}):E&&c&&d?u.jsx("div",{className:"mt-2",children:u.jsx(Cm,{birthDetails:c,supabase:d,language:f,t:e})}):null,ne.length>0&&u.jsxs(dr,{className:"mt-4 bg-accent/10 border border-accent/30",children:[u.jsx(Kr,{className:"pb-2",children:u.jsx(zr,{className:"text-base font-semibold",children:e("drPlanetaryPositionsCausing")})}),u.jsx(Ar,{className:"pt-0",children:u.jsx("ul",{className:"space-y-3 text-sm text-muted-foreground",children:ne.map((j,z)=>u.jsxs("li",{children:[u.jsxs("div",{className:"font-semibold text-foreground mb-1",children:[j.label,":"]}),u.jsx("ul",{className:"ml-4 space-y-1",children:j.evidence.map((Z,se)=>u.jsxs("li",{className:"flex items-start gap-2",children:[u.jsx("span",{className:"text-primary flex-shrink-0",children:"→"}),u.jsx("span",{children:Z})]},se))})]},z))})})]})]})}),u.jsx("p",{className:"text-xs text-muted-foreground/70 text-center px-4",children:e("drDisclaimer")})]})}const Tm=t=>{if(!t)return"";const[e,r,s]=t.split("-");return`${s}/${r}/${e}`},Am=({value:t,onChange:e,error:r,disabled:s=!1,onOpen:n})=>{const a=k.useRef(null),i=(()=>{const l=new Date,c=d=>String(d).padStart(2,"0");return`${l.getFullYear()}-${c(l.getMonth()+1)}-${c(l.getDate())}`})(),o=()=>{n?.();const l=a.current;if(l&&typeof l.showPicker=="function")try{l.showPicker()}catch{l?.focus()}else l?.focus()};return u.jsxs("div",{children:[u.jsxs("div",{className:"relative",style:{height:"48px"},children:[!t&&u.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 text-base pointer-events-none",style:{zIndex:1},children:"Select Date of Birth"}),t&&u.jsx("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-900 text-base pointer-events-none",style:{zIndex:1},children:Tm(t)}),u.jsx(us,{ref:a,type:"date",value:t,max:i,onChange:l=>{const c=l.target.value;c&&c>i||e(c)},onClick:o,onFocus:o,disabled:s,className:r?"border-red-500":""}),u.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400","aria-label":"Open date picker",onMouseDown:l=>l.preventDefault(),onClick:l=>{l.preventDefault(),l.stopPropagation(),o()},children:u.jsx(jd,{size:20})})]}),r&&u.jsx("p",{className:"text-sm text-red-500 mt-1",children:r})]})},Bn=t=>String(t).padStart(2,"0");function jm(t){if(!t||!/^\d{2}:\d{2}$/.test(t))return"";const[e,r]=t.split(":").map(Number),s=e===0?12:e>12?e-12:e,n=e>=12?"PM":"AM";return`${s}:${Bn(r)} ${n}`}function Om(t){if(!/^\d{2}:\d{2}$/.test(t))return{hour12:12,minute:"00",meridiem:"AM"};const[e,r]=t.split(":").map(Number),s=e===0?12:e>12?e-12:e,n=e>=12?"PM":"AM";return{hour12:s,minute:Bn(r),meridiem:n}}function Pm(t){let e=t.hour12;return t.meridiem==="AM"&&e===12&&(e=0),t.meridiem==="PM"&&e!==12&&(e+=12),`${Bn(e)}:${t.minute}`}const Nm=({value:t,onChange:e,error:r,disabled:s=!1,onOpen:n})=>{const a=k.useRef(null),[i,o]=k.useState(!1),[l,c]=k.useState({hour12:12,minute:"00",meridiem:"AM"});k.useEffect(()=>{const p=h=>{a.current&&(a.current.contains(h.target)||o(!1))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[]);const d=()=>{s||(n?.(),c(Om(t||"12:00")),o(p=>!p))},f=()=>{const p=Pm(l);e(p),o(!1)};return u.jsxs("div",{ref:a,children:[u.jsxs("div",{className:"relative",style:{height:"48px"},children:[u.jsx(us,{type:"text",value:t?jm(t):"",readOnly:!0,disabled:s,placeholder:"Exact Time of Birth",onClick:d,className:r?"border-red-500 placeholder:text-[#999ea7]":"placeholder:text-[#999ea7]"}),u.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400","aria-label":"Open time picker",disabled:s,onMouseDown:p=>p.preventDefault(),onClick:p=>{p.preventDefault(),p.stopPropagation(),d()},children:u.jsx(Nd,{size:20})})]}),i&&!s&&u.jsxs("div",{className:"absolute z-50 mt-2 p-4 bg-white border rounded-lg shadow-lg",role:"dialog","aria-label":"Select time",children:[u.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[u.jsx("select",{className:"border rounded px-2 py-1",value:l.hour12,onChange:p=>c(h=>({...h,hour12:Number(p.target.value)})),"aria-label":"Hour",children:Array.from({length:12},(p,h)=>h+1).map(p=>u.jsx("option",{value:p,children:p},p))}),u.jsx("span",{children:":"}),u.jsx("select",{className:"border rounded px-2 py-1",value:l.minute,onChange:p=>c(h=>({...h,minute:p.target.value})),"aria-label":"Minute",children:Array.from({length:60},(p,h)=>Bn(h)).map(p=>u.jsx("option",{value:p,children:p},p))}),u.jsxs("div",{className:"flex gap-1 ml-2",children:[u.jsx("button",{type:"button",className:`px-3 py-1 text-sm rounded ${l.meridiem==="AM"?"bg-orange-500 text-white":"bg-gray-200"}`,onClick:()=>c(p=>({...p,meridiem:"AM"})),children:"AM"}),u.jsx("button",{type:"button",className:`px-3 py-1 text-sm rounded ${l.meridiem==="PM"?"bg-orange-500 text-white":"bg-gray-200"}`,onClick:()=>c(p=>({...p,meridiem:"PM"})),children:"PM"})]})]}),u.jsxs("div",{className:"flex justify-end gap-2",children:[u.jsx("button",{type:"button",className:"px-4 py-2 text-sm bg-gray-200 rounded hover:bg-gray-300",onClick:()=>o(!1),children:"Cancel"}),u.jsx("button",{type:"button",className:"px-4 py-2 text-sm bg-orange-500 text-white rounded hover:bg-orange-600",onClick:f,children:"OK"})]})]}),r&&u.jsx("p",{className:"text-sm text-red-500 mt-1",children:r})]})},Rm=t=>{typeof window<"u"&&console.log("FB Pixel - Field Filled:",t)},Im=()=>{typeof window<"u"&&console.log("FB Pixel - Calculate Dosha Clicked")},Dm=Symbol.for("@supabase/supabase-js.traceContextExtractor");function Lm(){return globalThis[Dm]}function Vn(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r}function $m(t,e,r,s){function n(a){return a instanceof r?a:new r(function(i){i(a)})}return new(r||(r=Promise))(function(a,i){function o(d){try{c(s.next(d))}catch(f){i(f)}}function l(d){try{c(s.throw(d))}catch(f){i(f)}}function c(d){d.done?a(d.value):n(d.value).then(o,l)}c((s=s.apply(t,e||[])).next())})}typeof SuppressedError=="function"&&SuppressedError;const Mm=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class oi extends Error{constructor(e,r="FunctionsError",s){super(e),this.name=r,this.context=s}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class Fm extends oi{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class nc extends oi{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class ac extends oi{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var li;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(li||(li={}));class Um{constructor(e,{headers:r={},customFetch:s,region:n=li.Any}={}){this.url=e,this.headers=r,this.region=n,this.fetch=Mm(s)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return $m(this,arguments,void 0,function*(r,s={}){var n,a;let i,o,l;try{const{headers:c,method:d,body:f,signal:p,timeout:h}=s;let g={},{region:y}=s;y||(y=this.region);const v=new URL(`${this.url}/${r}`);y&&y!=="any"&&(g["x-region"]=y,v.searchParams.set("forceFunctionRegion",y));let C;const _=!!c&&Object.keys(c).some(ue=>ue.toLowerCase()==="content-type");f&&!_?typeof Blob<"u"&&f instanceof Blob||f instanceof ArrayBuffer?(g["Content-Type"]="application/octet-stream",C=f):typeof f=="string"?(g["Content-Type"]="text/plain",C=f):typeof FormData<"u"&&f instanceof FormData?C=f:(g["Content-Type"]="application/json",C=JSON.stringify(f)):f&&typeof f!="string"&&!(typeof Blob<"u"&&f instanceof Blob)&&!(f instanceof ArrayBuffer)&&!(typeof FormData<"u"&&f instanceof FormData)?C=JSON.stringify(f):C=f;let S=p;h&&(o=new AbortController,i=setTimeout(()=>o.abort(),h),p?(S=o.signal,l=()=>o.abort(),p.addEventListener("abort",l)):S=o.signal);const E=yield this.fetch(v.toString(),{method:d||"POST",headers:Object.assign(Object.assign(Object.assign({},g),this.headers),c),body:C,signal:S}).catch(ue=>{throw new Fm(ue)}),T=E.headers.get("x-relay-error");if(T&&T==="true")throw new nc(E);if(!E.ok)throw new ac(E);let N=((n=E.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim().toLowerCase(),L;return N==="application/json"?L=yield E.json():N==="application/octet-stream"||N==="application/pdf"?L=yield E.blob():N==="text/event-stream"?L=E:N==="multipart/form-data"?L=yield E.formData():L=yield E.text(),{data:L,error:null,response:E}}catch(c){return{data:null,error:c,response:c instanceof ac||c instanceof nc?c.context:void 0}}finally{i&&clearTimeout(i),l&&((a=s.signal)===null||a===void 0||a.removeEventListener("abort",l))}})}}const ic=3,oc=t=>Math.min(1e3*2**t,3e4),Bm=[520,503],lc=["GET","HEAD","OPTIONS"];var ci=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function Gs(t){"@babel/helpers - typeof";return Gs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gs(t)}function Vm(t,e){if(Gs(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(Gs(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Km(t){var e=Vm(t,"string");return Gs(e)=="symbol"?e:e+""}function zm(t,e,r){return(e=Km(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function cc(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function gs(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?cc(Object(r),!0).forEach(function(s){zm(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):cc(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}function uc(t,e){return new Promise(r=>{if(e?.aborted){r();return}const s=setTimeout(()=>{e?.removeEventListener("abort",n),r()},t);function n(){clearTimeout(s),r()}e?.addEventListener("abort",n)})}function Hm(t,e,r,s){return!(!s||r>=ic||!lc.includes(t)||!Bm.includes(e))}var Wm=class{constructor(t){var e,r,s,n,a;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(r=t.isMaybeSingle)!==null&&r!==void 0?r:!1,this.shouldStripNulls=(s=t.shouldStripNulls)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(n=t.urlLengthLimit)!==null&&n!==void 0?n:8e3,this.retryEnabled=(a=t.retry)!==null&&a!==void 0?a:!0,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if(this.headers.get("Accept")==="text/csv")throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}retry(t){return this.retryEnabled=t,this}then(t,e){var r=this;if(this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){const i=this.headers.get("Accept");i==="application/vnd.pgrst.object+json"?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):(!i||i==="application/json")&&this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const s=this.fetch;let a=(async()=>{let i=0;for(;;){const c={};r.headers.forEach((f,p)=>{c[p]=f}),i>0&&(c["X-Retry-Count"]=String(i));let d;try{d=await s(r.url.toString(),{method:r.method,headers:c,body:JSON.stringify(r.body,(f,p)=>typeof p=="bigint"?p.toString():p),signal:r.signal})}catch(f){if(f?.name==="AbortError"||f?.code==="ABORT_ERR"||!lc.includes(r.method))throw f;if(r.retryEnabled&&i<ic){const p=oc(i);i++,await uc(p,r.signal);continue}throw f}if(Hm(r.method,d.status,i,r.retryEnabled)){var o,l;const f=(o=(l=d.headers)===null||l===void 0?void 0:l.get("Retry-After"))!==null&&o!==void 0?o:null,p=f!==null?Math.max(0,parseInt(f,10)||0)*1e3:oc(i);await d.text(),i++,await uc(p,r.signal);continue}return await r.processResponse(d)}})();return this.shouldThrowOnError||(a=a.catch(i=>{var o;let l="",c="",d="";const f=i?.cause;if(f){var p,h,g,y;const _=(p=f?.message)!==null&&p!==void 0?p:"",S=(h=f?.code)!==null&&h!==void 0?h:"";l=`${(g=i?.name)!==null&&g!==void 0?g:"FetchError"}: ${i?.message}`,l+=`
130
130
 
131
- Caused by: ${(g=p?.name)!==null&&g!==void 0?g:"Error"}: ${_}`,S&&(l+=` (${S})`),p?.stack&&(l+=`
132
- ${p.stack}`)}else{var v;l=(v=i?.stack)!==null&&v!==void 0?v:""}const C=this.url.toString().length;return i?.name==="AbortError"||i?.code==="ABORT_ERR"?(u="",c="Request was aborted (timeout or manual cancellation)",C>this.urlLengthLimit&&(c+=`. Note: Your request URL is ${C} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(p?.name==="HeadersOverflowError"||p?.code==="UND_ERR_HEADERS_OVERFLOW")&&(u="",c="HTTP headers exceeded server limits (typically 16KB)",C>this.urlLengthLimit&&(c+=`. Your request URL is ${C} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:l,hint:c,code:u},data:null,count:null,status:0,statusText:""}})),a.then(t,e)}async processResponse(t){var e=this;let r=null,s=null,n=null,a=t.status,i=t.statusText;if(t.ok){var o,l;if(e.method!=="HEAD"){var c;const h=await t.text();if(h!=="")if(e.headers.get("Accept")==="text/csv")s=h;else if(e.headers.get("Accept")&&(!((c=e.headers.get("Accept"))===null||c===void 0)&&c.includes("application/vnd.pgrst.plan+text")))s=h;else try{s=JSON.parse(h)}catch{if(r={message:h},s=null,e.shouldThrowOnError)throw new ys({message:h,details:"",hint:"",code:""})}}const p=(o=e.headers.get("Prefer"))===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),f=(l=t.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");if(p&&f&&f.length>1&&(n=parseInt(f[1])),e.isMaybeSingle&&Array.isArray(s))if(s.length>1){if(r={code:"PGRST116",details:`Results contain ${s.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},s=null,n=null,a=406,i="Not Acceptable",e.shouldThrowOnError){var u;throw new ys(Hr(Hr({},r),{},{hint:(u=r.hint)!==null&&u!==void 0?u:""}))}}else s.length===1?s=s[0]:s=null}else{const p=await t.text();try{r=JSON.parse(p),Array.isArray(r)&&t.status===404&&(s=[],r=null,a=200,i="OK")}catch{t.status===404&&p===""?(a=204,i="No Content"):r={message:p}}if(r&&e.shouldThrowOnError)throw new ys(r)}return{success:r===null,error:r,data:s,count:n,status:a,statusText:i}}returns(){return this}overrideTypes(){return this}},Jm=class extends Gm{throwOnError(){return super.throwOnError()}select(t){let e=!1;const r=(t??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:s,referencedTable:n=s}={}){const a=n?`${n}.order`:"order",i=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${i?`${i},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){const s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:s=r}={}){const n=typeof s>"u"?"offset":`${s}.offset`,a=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${t}`),this.url.searchParams.set(a,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:t=!1,verbose:e=!1,settings:r=!1,buffers:s=!1,wal:n=!1,format:a="text"}={}){var i;const o=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=(i=this.headers.get("Accept"))!==null&&i!==void 0?i:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${l}"; options=${o};`),a==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const hc=new RegExp("[,()]");var vs=class extends Jm{throwOnError(){return super.throwOnError()}eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const r=Array.from(new Set(e)).map(s=>typeof s=="string"&&hc.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}notIn(t,e){const r=Array.from(new Set(e)).map(s=>typeof s=="string"&&hc.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`not.in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:s}={}){let n="";s==="plain"?n="pl":s==="phrase"?n="ph":s==="websearch"&&(n="w");const a=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${n}fts${a}.${e}`),this}match(t){return Object.entries(t).filter(([e,r])=>r!==void 0).forEach(([e,r])=>{this.url.searchParams.append(e,`eq.${r}`)}),this}not(t,e,r){return this.url.searchParams.append(t,`not.${e}.${r}`),this}or(t,{foreignTable:e,referencedTable:r=e}={}){const s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}},Zm=class{constructor(t,{headers:e={},schema:r,fetch:s,urlLengthLimit:n=8e3,retry:a}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=s,this.urlLengthLimit=n,this.retry=a}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:r=!1,count:s}=e??{},n=r?"HEAD":"GET";let a=!1;const i=(t??"*").split("").map(c=>/\s/.test(c)&&!a?"":(c==='"'&&(a=!a),c)).join(""),{url:o,headers:l}=this.cloneRequestState();return o.searchParams.set("select",i),s&&l.append("Prefer",`count=${s}`),new vs({method:n,url:o,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(t,{count:e,defaultToNull:r=!0}={}){var s;const n="POST",{url:a,headers:i}=this.cloneRequestState();if(e&&i.append("Prefer",`count=${e}`),r||i.append("Prefer","missing=default"),Array.isArray(t)){const o=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(o.length>0){const l=[...new Set(o)].map(c=>`"${c}"`);a.searchParams.set("columns",l.join(","))}}return new vs({method:n,url:a,headers:i,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var a;const i="POST",{url:o,headers:l}=this.cloneRequestState();if(l.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&o.searchParams.set("on_conflict",e),s&&l.append("Prefer",`count=${s}`),n||l.append("Prefer","missing=default"),Array.isArray(t)){const c=t.reduce((u,p)=>u.concat(Object.keys(p)),[]);if(c.length>0){const u=[...new Set(c)].map(p=>`"${p}"`);o.searchParams.set("columns",u.join(","))}}return new vs({method:i,url:o,headers:l,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(t,{count:e}={}){var r;const s="PATCH",{url:n,headers:a}=this.cloneRequestState();return e&&a.append("Prefer",`count=${e}`),new vs({method:s,url:n,headers:a,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:t}={}){var e;const r="DELETE",{url:s,headers:n}=this.cloneRequestState();return t&&n.append("Prefer",`count=${t}`),new vs({method:r,url:s,headers:n,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function Ym(t,e){try{const i=JSON.parse(t);if(i&&typeof i=="object"&&!Array.isArray(i)){var r,s,n,a;return new ys({message:String((r=i.message)!==null&&r!==void 0?r:t),details:(s=i.details)!==null&&s!==void 0?s:"",hint:(n=i.hint)!==null&&n!==void 0?n:"",code:(a=i.code)!==null&&a!==void 0?a:""})}}catch{}return new ys({message:t||e,details:"",hint:"",code:""})}function fc(t,e,r){var s;const n=t;return{success:!1,error:new ys({message:`${(s=n?.name)!==null&&s!==void 0?s:"FetchError"}: ${n?.message}`,details:"",hint:"",code:""}),data:null,count:null,status:e,statusText:r}}var Xm=class Du{constructor(e,{headers:r={},schema:s,fetch:n,timeout:a,urlLengthLimit:i=8e3,retry:o}={}){this.url=e,this.headers=new Headers(r),this.schemaName=s,this.urlLengthLimit=i;const l=n??globalThis.fetch;a!==void 0&&a>0?this.fetch=(c,u)=>{const p=new AbortController,f=setTimeout(()=>p.abort(),a),h=u?.signal;if(h){if(h.aborted)return clearTimeout(f),l(c,u);const y=()=>{clearTimeout(f),p.abort()};return h.addEventListener("abort",y,{once:!0}),l(c,Hr(Hr({},u),{},{signal:p.signal})).finally(()=>{clearTimeout(f),h.removeEventListener("abort",y)})}return l(c,Hr(Hr({},u),{},{signal:p.signal})).finally(()=>clearTimeout(f))}:this.fetch=l,this.retry=o}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new Zm(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(e){return new Du(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}async getOpenApiSpec(){var e=this,r;const s=new Headers(e.headers);s.set("Accept","application/openapi+json"),e.schemaName&&s.set("Accept-Profile",e.schemaName);const n={};s.forEach((c,u)=>{n[u]=c});const a=(r=e.fetch)!==null&&r!==void 0?r:globalThis.fetch;let i;try{var o;i=await dc(a,`${e.url}/`,{method:"GET",headers:n},(o=e.retry)!==null&&o!==void 0?o:!0)}catch(c){return fc(c,0,"")}let l;try{l=await i.text()}catch(c){return fc(c,i.status,i.statusText)}if(i.ok)try{return{success:!0,error:null,data:JSON.parse(l),count:null,status:i.status,statusText:i.statusText}}catch{}return{success:!1,error:Ym(l,i.statusText),data:null,count:null,status:i.status,statusText:i.statusText}}rpc(e,r={},{head:s=!1,get:n=!1,count:a}={}){var i;let o;const l=new URL(`${this.url}/rpc/${e}`);let c;const u=h=>h!==null&&typeof h=="object"&&(!Array.isArray(h)||h.some(u)),p=s&&Object.values(r).some(u);p?(o="POST",c=r):s||n?(o=s?"HEAD":"GET",Object.entries(r).filter(([h,y])=>y!==void 0).map(([h,y])=>[h,Array.isArray(y)?`{${y.join(",")}}`:`${y}`]).forEach(([h,y])=>{l.searchParams.append(h,y)})):(o="POST",c=r);const f=new Headers(this.headers);return p?f.set("Prefer",a?`count=${a},return=minimal`:"return=minimal"):a&&f.set("Prefer",`count=${a}`),new vs({method:o,url:l,headers:f,schema:this.schemaName,body:c,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class Qm{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",wsConstructor:WebSocket};const r=globalThis;if(typeof globalThis<"u"&&typeof r.WebSocket<"u")return{type:"native",wsConstructor:r.WebSocket};const s=typeof global<"u"?global:void 0;if(s&&typeof s.WebSocket<"u")return{type:"native",wsConstructor:s.WebSocket};if(typeof globalThis<"u"&&typeof r.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&r.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const n=globalThis.process;if(n){const a=n.versions;if(a&&a.node)return{type:"unsupported",error:"Node.js detected but native WebSocket not found.",workaround:"Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option."}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.wsConstructor)return e.wsConstructor;let r=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(r+=`
131
+ Caused by: ${(y=f?.name)!==null&&y!==void 0?y:"Error"}: ${_}`,S&&(l+=` (${S})`),f?.stack&&(l+=`
132
+ ${f.stack}`)}else{var v;l=(v=i?.stack)!==null&&v!==void 0?v:""}const C=this.url.toString().length;return i?.name==="AbortError"||i?.code==="ABORT_ERR"?(d="",c="Request was aborted (timeout or manual cancellation)",C>this.urlLengthLimit&&(c+=`. Note: Your request URL is ${C} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(f?.name==="HeadersOverflowError"||f?.code==="UND_ERR_HEADERS_OVERFLOW")&&(d="",c="HTTP headers exceeded server limits (typically 16KB)",C>this.urlLengthLimit&&(c+=`. Your request URL is ${C} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${(o=i?.name)!==null&&o!==void 0?o:"FetchError"}: ${i?.message}`,details:l,hint:c,code:d},data:null,count:null,status:0,statusText:""}})),a.then(t,e)}async processResponse(t){var e=this;let r=null,s=null,n=null,a=t.status,i=t.statusText;if(t.ok){var o,l;if(e.method!=="HEAD"){var c;const h=await t.text();if(h!=="")if(e.headers.get("Accept")==="text/csv")s=h;else if(e.headers.get("Accept")&&(!((c=e.headers.get("Accept"))===null||c===void 0)&&c.includes("application/vnd.pgrst.plan+text")))s=h;else try{s=JSON.parse(h)}catch{if(r={message:h},s=null,e.shouldThrowOnError)throw new ci({message:h,details:"",hint:"",code:""})}}const f=(o=e.headers.get("Prefer"))===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),p=(l=t.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");if(f&&p&&p.length>1&&(n=parseInt(p[1])),e.isMaybeSingle&&Array.isArray(s))if(s.length>1){if(r={code:"PGRST116",details:`Results contain ${s.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},s=null,n=null,a=406,i="Not Acceptable",e.shouldThrowOnError){var d;throw new ci(gs(gs({},r),{},{hint:(d=r.hint)!==null&&d!==void 0?d:""}))}}else s.length===1?s=s[0]:s=null}else{const f=await t.text();try{r=JSON.parse(f),Array.isArray(r)&&t.status===404&&(s=[],r=null,a=200,i="OK")}catch{t.status===404&&f===""?(a=204,i="No Content"):r={message:f}}if(r&&e.shouldThrowOnError)throw new ci(r)}return{success:r===null,error:r,data:s,count:n,status:a,statusText:i}}returns(){return this}overrideTypes(){return this}},qm=class extends Wm{throwOnError(){return super.throwOnError()}select(t){let e=!1;const r=(t??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:s,referencedTable:n=s}={}){const a=n?`${n}.order`:"order",i=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${i?`${i},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){const s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:s=r}={}){const n=typeof s>"u"?"offset":`${s}.offset`,a=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${t}`),this.url.searchParams.set(a,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:t=!1,verbose:e=!1,settings:r=!1,buffers:s=!1,wal:n=!1,format:a="text"}={}){var i;const o=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,n?"wal":null].filter(Boolean).join("|"),l=(i=this.headers.get("Accept"))!==null&&i!==void 0?i:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${a}; for="${l}"; options=${o};`),a==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const dc=new RegExp("[,()]");var ys=class extends qm{throwOnError(){return super.throwOnError()}eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const r=Array.from(new Set(e)).map(s=>typeof s=="string"&&dc.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}notIn(t,e){const r=Array.from(new Set(e)).map(s=>typeof s=="string"&&dc.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`not.in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:s}={}){let n="";s==="plain"?n="pl":s==="phrase"?n="ph":s==="websearch"&&(n="w");const a=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${n}fts${a}.${e}`),this}match(t){return Object.entries(t).filter(([e,r])=>r!==void 0).forEach(([e,r])=>{this.url.searchParams.append(e,`eq.${r}`)}),this}not(t,e,r){return this.url.searchParams.append(t,`not.${e}.${r}`),this}or(t,{foreignTable:e,referencedTable:r=e}={}){const s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}},Gm=class{constructor(t,{headers:e={},schema:r,fetch:s,urlLengthLimit:n=8e3,retry:a}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=s,this.urlLengthLimit=n,this.retry=a}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:r=!1,count:s}=e??{},n=r?"HEAD":"GET";let a=!1;const i=(t??"*").split("").map(c=>/\s/.test(c)&&!a?"":(c==='"'&&(a=!a),c)).join(""),{url:o,headers:l}=this.cloneRequestState();return o.searchParams.set("select",i),s&&l.append("Prefer",`count=${s}`),new ys({method:n,url:o,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(t,{count:e,defaultToNull:r=!0}={}){var s;const n="POST",{url:a,headers:i}=this.cloneRequestState();if(e&&i.append("Prefer",`count=${e}`),r||i.append("Prefer","missing=default"),Array.isArray(t)){const o=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(o.length>0){const l=[...new Set(o)].map(c=>`"${c}"`);a.searchParams.set("columns",l.join(","))}}return new ys({method:n,url:a,headers:i,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var a;const i="POST",{url:o,headers:l}=this.cloneRequestState();if(l.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&o.searchParams.set("on_conflict",e),s&&l.append("Prefer",`count=${s}`),n||l.append("Prefer","missing=default"),Array.isArray(t)){const c=t.reduce((d,f)=>d.concat(Object.keys(f)),[]);if(c.length>0){const d=[...new Set(c)].map(f=>`"${f}"`);o.searchParams.set("columns",d.join(","))}}return new ys({method:i,url:o,headers:l,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(t,{count:e}={}){var r;const s="PATCH",{url:n,headers:a}=this.cloneRequestState();return e&&a.append("Prefer",`count=${e}`),new ys({method:s,url:n,headers:a,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:t}={}){var e;const r="DELETE",{url:s,headers:n}=this.cloneRequestState();return t&&n.append("Prefer",`count=${t}`),new ys({method:r,url:s,headers:n,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}},Jm=class Ru{constructor(e,{headers:r={},schema:s,fetch:n,timeout:a,urlLengthLimit:i=8e3,retry:o}={}){this.url=e,this.headers=new Headers(r),this.schemaName=s,this.urlLengthLimit=i;const l=n??globalThis.fetch;a!==void 0&&a>0?this.fetch=(c,d)=>{const f=new AbortController,p=setTimeout(()=>f.abort(),a),h=d?.signal;if(h){if(h.aborted)return clearTimeout(p),l(c,d);const g=()=>{clearTimeout(p),f.abort()};return h.addEventListener("abort",g,{once:!0}),l(c,gs(gs({},d),{},{signal:f.signal})).finally(()=>{clearTimeout(p),h.removeEventListener("abort",g)})}return l(c,gs(gs({},d),{},{signal:f.signal})).finally(()=>clearTimeout(p))}:this.fetch=l,this.retry=o}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new Gm(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(e){return new Ru(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(e,r={},{head:s=!1,get:n=!1,count:a}={}){var i;let o;const l=new URL(`${this.url}/rpc/${e}`);let c;const d=h=>h!==null&&typeof h=="object"&&(!Array.isArray(h)||h.some(d)),f=s&&Object.values(r).some(d);f?(o="POST",c=r):s||n?(o=s?"HEAD":"GET",Object.entries(r).filter(([h,g])=>g!==void 0).map(([h,g])=>[h,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([h,g])=>{l.searchParams.append(h,g)})):(o="POST",c=r);const p=new Headers(this.headers);return f?p.set("Prefer",a?`count=${a},return=minimal`:"return=minimal"):a&&p.set("Prefer",`count=${a}`),new ys({method:o,url:l,headers:p,schema:this.schemaName,body:c,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class Zm{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",wsConstructor:WebSocket};const r=globalThis;if(typeof globalThis<"u"&&typeof r.WebSocket<"u")return{type:"native",wsConstructor:r.WebSocket};const s=typeof global<"u"?global:void 0;if(s&&typeof s.WebSocket<"u")return{type:"native",wsConstructor:s.WebSocket};if(typeof globalThis<"u"&&typeof r.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&r.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const n=globalThis.process;if(n){const a=n.versions;if(a&&a.node)return{type:"unsupported",error:"Node.js detected but native WebSocket not found.",workaround:"Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option."}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.wsConstructor)return e.wsConstructor;let r=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(r+=`
133
133
 
134
- Suggested solution: ${e.workaround}`),new Error(r)}static isWebSocketSupported(){try{return this.detectEnvironment().type==="native"}catch{return!1}}}const eg="realtime-js/2.115.0",tg="1.0.0",pc="2.0.0",rg=pc,sg=1e4,ng=15e3,ag=1e4,ig=100,jr={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},mc={close:"phx_close",error:"phx_error",join:"phx_join",leave:"phx_leave",access_token:"access_token"},ui={connecting:"connecting",closing:"closing",closed:"closed"};class og{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,r){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return r(this._binaryEncodeUserBroadcastPush(e));let s=[e.join_ref,e.ref,e.topic,e.event,e.payload];return r(JSON.stringify(s))}_binaryEncodeUserBroadcastPush(e){var r;return this._isArrayBuffer((r=e.payload)===null||r===void 0?void 0:r.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var r,s;const n=(s=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&s!==void 0?s:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}_encodeJsonUserBroadcastPush(e){var r,s;const n=(s=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&s!==void 0?s:{},i=new TextEncoder().encode(JSON.stringify(n)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,i)}_encodeUserBroadcastPush(e,r,s){var n,a;const i=new TextEncoder,o=i.encode(e.topic),l=i.encode((n=e.ref)!==null&&n!==void 0?n:""),c=i.encode((a=e.join_ref)!==null&&a!==void 0?a:""),u=i.encode(e.payload.event),p=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},f=i.encode(Object.keys(p).length===0?"":JSON.stringify(p));if(c.length>255)throw new Error(`joinRef length ${c.length} exceeds maximum of 255`);if(l.length>255)throw new Error(`ref length ${l.length} exceeds maximum of 255`);if(o.length>255)throw new Error(`topic length ${o.length} exceeds maximum of 255`);if(u.length>255)throw new Error(`userEvent length ${u.length} exceeds maximum of 255`);if(f.length>255)throw new Error(`metadata length ${f.length} exceeds maximum of 255`);const h=this.USER_BROADCAST_PUSH_META_LENGTH+c.length+l.length+o.length+u.length+f.length,y=new ArrayBuffer(this.HEADER_LENGTH+h),g=new DataView(y),v=new Uint8Array(y);let C=0;g.setUint8(C++,this.KINDS.userBroadcastPush),g.setUint8(C++,c.length),g.setUint8(C++,l.length),g.setUint8(C++,o.length),g.setUint8(C++,u.length),g.setUint8(C++,f.length),g.setUint8(C++,r),v.set(c,C),C+=c.length,v.set(l,C),C+=l.length,v.set(o,C),C+=o.length,v.set(u,C),C+=u.length,v.set(f,C),C+=f.length;var _=new Uint8Array(y.byteLength+s.byteLength);return _.set(new Uint8Array(y),0),_.set(new Uint8Array(s),y.byteLength),_.buffer}decode(e,r){if(this._isArrayBuffer(e)){let s=this._binaryDecode(e);return r(s)}if(typeof e=="string"){const s=JSON.parse(e),[n,a,i,o,l]=s;return r({join_ref:n,ref:a,topic:i,event:o,payload:l})}return r({})}_binaryDecode(e){const r=new DataView(e),s=r.getUint8(0),n=new TextDecoder;if(s===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,r,n)}_decodeUserBroadcast(e,r,s){const n=r.getUint8(1),a=r.getUint8(2),i=r.getUint8(3),o=r.getUint8(4);let l=this.HEADER_LENGTH+4;const c=s.decode(e.slice(l,l+n));l=l+n;const u=s.decode(e.slice(l,l+a));l=l+a;const p=s.decode(e.slice(l,l+i));l=l+i;const f=e.slice(l,e.byteLength),h=o===this.JSON_ENCODING?JSON.parse(s.decode(f)):f,y={type:this.BROADCAST_EVENT,event:u,payload:h};return i>0&&(y.meta=JSON.parse(p)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:y}}_isArrayBuffer(e){var r;return e instanceof ArrayBuffer||((r=e?.constructor)===null||r===void 0?void 0:r.name)==="ArrayBuffer"}_pick(e,r){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([s])=>r.includes(s)))}}var De;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(De||(De={}));const gc=(t,e,r={})=>{var s;const n=(s=r.skipTypes)!==null&&s!==void 0?s:[];return e?Object.keys(e).reduce((a,i)=>(a[i]=lg(i,t,e,n),a),{}):{}},lg=(t,e,r,s)=>{const n=e.find(o=>o.name===t),a=n?.type,i=r[t];return a&&!s.includes(a)?yc(a,i):di(i)},yc=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return hg(e,r)}switch(t){case De.bool:return cg(e);case De.float4:case De.float8:case De.int2:case De.int4:case De.int8:case De.numeric:case De.oid:return ug(e);case De.json:case De.jsonb:return dg(e);case De.timestamp:return fg(e);case De.abstime:case De.date:case De.daterange:case De.int4range:case De.int8range:case De.money:case De.reltime:case De.text:case De.time:case De.timestamptz:case De.timetz:case De.tsrange:case De.tstzrange:return di(e);default:return di(e)}},di=t=>t,cg=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},ug=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},dg=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},hg=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,s=t[r];if(t[0]==="{"&&s==="}"){let a;const i=t.slice(1,r);try{a=JSON.parse("["+i+"]")}catch{a=i?i.split(","):[]}return a.map(o=>yc(e,o))}return t},fg=t=>typeof t=="string"?t.replace(" ","T"):t,vc=t=>{const e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};var bs=t=>typeof t=="function"?t:function(){return t},pg=typeof self<"u"?self:null,ws=typeof window<"u"?window:null,er=pg||ws||globalThis,mg="2.0.0",gg=1e4,yg=1e3,vg=100,tr={connecting:0,open:1,closing:2,closed:3},gt={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},fr={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},hi={longpoll:"longpoll",websocket:"websocket"},bg={complete:4},fi="base64url.bearer.phx.",zn=class{constructor(t,e,r,s){this.channel=t,this.event=e,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(t){this.timeout=t,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:t,response:e,_ref:r}){this.recHooks.filter(s=>s.status===t).forEach(s=>s.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},bc=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},wg=class{constructor(t,e,r){this.state=gt.closed,this.topic=t,this.params=bs(e||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new zn(this,fr.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new bc(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=gt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",s=>{this.state=gt.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=gt.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=gt.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new zn(this,fr.leave,bs({}),this.timeout).send(),this.state=gt.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(fr.reply,(s,n)=>{this.trigger(this.replyEventName(n),s)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=gt.closed,this.bindings=[]}onClose(t){this.on(fr.close,t)}onError(t){return this.on(fr.error,e=>t(e))}on(t,e){let r=this.bindingRef++;return this.bindings.push({event:t,ref:r,callback:e}),r}off(t,e){this.bindings=this.bindings.filter(r=>!(r.event===t&&(typeof e>"u"||e===r.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,r=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new zn(this,t,function(){return e},r);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=gt.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(fr.close,"leave")},r=new zn(this,fr.leave,bs({}),t);return r.receive("ok",()=>e()).receive("timeout",()=>e()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(t,e,r){return e}filterBindings(t,e,r){return!0}isMember(t,e,r,s){return this.topic!==t?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:r,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=gt.joining,this.joinPush.resend(t))}trigger(t,e,r,s){let n=this.onMessage(t,e,r,s);if(e&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let a=this.bindings.filter(i=>i.event===t&&this.filterBindings(i,e,r));for(let i=0;i<a.length;i++)a[i].callback(n,r,s||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===gt.closed}isErrored(){return this.state===gt.errored}isJoined(){return this.state===gt.joined}isJoining(){return this.state===gt.joining}isLeaving(){return this.state===gt.leaving}},Hn=class{static request(t,e,r,s,n,a,i){if(er.XDomainRequest){let o=new er.XDomainRequest;return this.xdomainRequest(o,t,e,s,n,a,i)}else if(er.XMLHttpRequest){let o=new er.XMLHttpRequest;return this.xhrRequest(o,t,e,r,s,n,a,i)}else{if(er.fetch&&er.AbortController)return this.fetchRequest(t,e,r,s,n,a,i);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,e,r,s,n,a,i){let o={method:t,headers:r,body:s},l=null;return n&&(l=new AbortController,setTimeout(()=>l.abort(),n),o.signal=l.signal),er.fetch(e,o).then(c=>c.text()).then(c=>this.parseJSON(c)).then(c=>i&&i(c)).catch(c=>{c.name==="AbortError"&&a?a():i&&i(null)}),l}static xdomainRequest(t,e,r,s,n,a,i){return t.timeout=n,t.open(e,r),t.onload=()=>{let o=this.parseJSON(t.responseText);i&&i(o)},a&&(t.ontimeout=a),t.onprogress=()=>{},t.send(s),t}static xhrRequest(t,e,r,s,n,a,i,o){t.open(e,r,!0),t.timeout=a;for(let[l,c]of Object.entries(s))t.setRequestHeader(l,c);return t.onerror=()=>o&&o(null),t.onreadystatechange=()=>{if(t.readyState===bg.complete&&o){let l=this.parseJSON(t.responseText);o(l)}},i&&(t.ontimeout=i),t.send(n),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let r=[];for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let n=e?`${e}[${s}]`:s,a=t[s];typeof a=="object"?r.push(this.serialize(a,n)):r.push(encodeURIComponent(n)+"="+encodeURIComponent(a))}return r.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let r=t.match(/\?/)?"&":"?";return`${t}${r}${this.serialize(e)}`}},xg=t=>{let e="",r=new Uint8Array(t),s=r.byteLength;for(let n=0;n<s;n++)e+=String.fromCharCode(r[n]);return btoa(e)},xs=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(fi)&&(this.authToken=atob(e[1].slice(fi.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=tr.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+hi.websocket),"$1/"+hi.longpoll)}endpointURL(){return Hn.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,r){this.close(t,e,r),this.readyState=tr.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===tr.open||this.readyState===tr.connecting}poll(){const t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),e=>{if(e){var{status:r,token:s,messages:n}=e;if(r===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=s}else r=0;switch(r){case 200:n.forEach(a=>{setTimeout(()=>this.onmessage({data:a}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=tr.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${r}`)}})}send(t){typeof t!="string"&&(t=xg(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t,e=0){this.awaitingBatchAck=!0;const r=e+vg,s=t.slice(e,r);this.ajax("POST",{"Content-Type":"application/x-ndjson"},s.join(`
135
- `),()=>this.onerror("timeout"),n=>{!n||n.status!==200?(this.awaitingBatchAck=!1,this.onerror(n&&n.status),this.closeAndRetry(1011,"internal server error",!1)):r<t.length?this.batchSend(t,r):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1})}close(t,e,r){for(let n of this.reqs)n.abort();this.readyState=tr.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:r});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(t,e,r,s,n){let a,i=()=>{this.reqs.delete(a),s()};a=Hn.request(t,this.endpointURL(),e,r,this.timeout,i,o=>{this.reqs.delete(a),this.isActive()&&n(o)}),this.reqs.add(a)}},_g=class dn{constructor(e,r={}){let s=r.events||{state:"presence_state",diff:"presence_diff"};this.state=Object.create(null),this.pendingDiffs=[],this.channel=e,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(s.state,n=>{let{onJoin:a,onLeave:i,onSync:o}=this.caller;this.joinRef=this.channel.joinRef(),this.state=dn.syncState(this.state,n,a,i),this.pendingDiffs.forEach(l=>{this.state=dn.syncDiff(this.state,l,a,i)}),this.pendingDiffs=[],o()}),this.channel.on(s.diff,n=>{let{onJoin:a,onLeave:i,onSync:o}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=dn.syncDiff(this.state,n,a,i),o())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(e){return dn.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,r,s,n){let a=this.toNullProtoObj(this.clone(e));r=this.toNullProtoObj(r);let i=Object.create(null),o=Object.create(null);return this.map(a,(l,c)=>{r[l]||(o[l]=c)}),this.map(r,(l,c)=>{let u=a[l];if(u){let p=c.metas.map(g=>g.phx_ref),f=u.metas.map(g=>g.phx_ref),h=c.metas.filter(g=>f.indexOf(g.phx_ref)<0),y=u.metas.filter(g=>p.indexOf(g.phx_ref)<0);h.length>0&&(i[l]=c,i[l].metas=h),y.length>0&&(o[l]=this.clone(u),o[l].metas=y)}else i[l]=c}),this.syncDiff(a,{joins:i,leaves:o},s,n)}static syncDiff(e,r,s,n){e=this.toNullProtoObj(e);let{joins:a,leaves:i}=this.clone(r);return s||(s=function(){}),n||(n=function(){}),this.map(a,(o,l)=>{let c=e[o];if(e[o]=this.clone(l),c){let u=e[o].metas.map(f=>f.phx_ref),p=c.metas.filter(f=>u.indexOf(f.phx_ref)<0);e[o].metas.unshift(...p)}s(o,c,l)}),this.map(i,(o,l)=>{let c=e[o];if(!c)return;let u=l.metas.map(p=>p.phx_ref);c.metas=c.metas.filter(p=>u.indexOf(p.phx_ref)<0),n(o,c,l),c.metas.length===0&&delete e[o]}),e}static list(e,r){return r||(r=function(s,n){return n}),this.map(e,(s,n)=>r(s,n))}static map(e,r){return Object.getOwnPropertyNames(e).map(s=>r(s,e[s]))}static toNullProtoObj(e){if(Object.getPrototypeOf(e)===null)return e;let r=Object.create(null);return Object.getOwnPropertyNames(e).forEach(s=>{r[s]=e[s]}),r}static clone(e){return JSON.parse(JSON.stringify(e))}},Wn={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let r=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(r))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[r,s,n,a,i]=JSON.parse(t);return e({join_ref:r,ref:s,topic:n,event:a,payload:i})}},binaryEncode(t){let{join_ref:e,ref:r,event:s,topic:n,payload:a}=t,i=new TextEncoder,o=i.encode(e),l=i.encode(r),c=i.encode(n),u=i.encode(s);this.assertFieldSize(o.byteLength,"join_ref"),this.assertFieldSize(l.byteLength,"ref"),this.assertFieldSize(c.byteLength,"topic"),this.assertFieldSize(u.byteLength,"event");let p=this.META_LENGTH+o.byteLength+l.byteLength+c.byteLength+u.byteLength,f=new ArrayBuffer(this.HEADER_LENGTH+p),h=new Uint8Array(f),y=new DataView(f),g=0;y.setUint8(g++,this.KINDS.push),y.setUint8(g++,o.byteLength),y.setUint8(g++,l.byteLength),y.setUint8(g++,c.byteLength),y.setUint8(g++,u.byteLength),h.set(o,g),g+=o.byteLength,h.set(l,g),g+=l.byteLength,h.set(c,g),g+=c.byteLength,h.set(u,g),g+=u.byteLength;var v=new Uint8Array(f.byteLength+a.byteLength);return v.set(h,0),v.set(new Uint8Array(a),f.byteLength),v.buffer},assertFieldSize(t,e){if(t>255)throw new Error(`unable to convert ${e} to binary: must be less than or equal to 255 bytes, but is ${t} bytes`)},binaryDecode(t){let e=new DataView(t),r=e.getUint8(0),s=new TextDecoder;switch(r){case this.KINDS.push:return this.decodePush(t,e,s);case this.KINDS.reply:return this.decodeReply(t,e,s);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,s)}},decodePush(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),a=e.getUint8(3),i=this.HEADER_LENGTH+this.META_LENGTH-1,o=r.decode(t.slice(i,i+s));i=i+s;let l=r.decode(t.slice(i,i+n));i=i+n;let c=r.decode(t.slice(i,i+a));i=i+a;let u=t.slice(i,t.byteLength);return{join_ref:o,ref:null,topic:l,event:c,payload:u}},decodeReply(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),a=e.getUint8(3),i=e.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(t.slice(o,o+s));o=o+s;let c=r.decode(t.slice(o,o+n));o=o+n;let u=r.decode(t.slice(o,o+a));o=o+a;let p=r.decode(t.slice(o,o+i));o=o+i;let f=t.slice(o,t.byteLength),h={status:p,response:f};return{join_ref:l,ref:c,topic:u,event:fr.reply,payload:h}},decodeBroadcast(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),a=this.HEADER_LENGTH+2,i=r.decode(t.slice(a,a+s));a=a+s;let o=r.decode(t.slice(a,a+n));a=a+n;let l=t.slice(a,t.byteLength);return{join_ref:null,ref:null,topic:i,event:o,payload:l}}},kg=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||gg,this.transport=e.transport||er.WebSocket||xs,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null;let r=null;try{r=er&&er.sessionStorage}catch{}this.sessionStore=e.sessionStorage||r,this.establishedConnections=0,this.defaultEncoder=Wn.encode.bind(Wn),this.defaultDecoder=Wn.decode.bind(Wn),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==xs?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let s=null;ws&&ws.addEventListener&&(ws.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),s=this.connectClock)}),ws.addEventListener("pageshow",n=>{s===this.connectClock&&(s=null,this.connect())}),ws.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=e.autoSendHeartbeat??!0,this.heartbeatCallback=e.heartbeatCallback??(()=>{}),this.rejoinAfterMs=n=>e.rejoinAfterMs?e.rejoinAfterMs(n):[1e3,2e3,5e3][n-1]||1e4,this.reconnectAfterMs=n=>e.reconnectAfterMs?e.reconnectAfterMs(n):[10,50,100,150,200,250,500,1e3,2e3][n-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(n,a,i)=>{console.log(`${n}: ${a}`,i)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=bs(e.params||{}),this.endPoint=`${t}/${hi.websocket}`,this.vsn=e.vsn||mg,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new bc(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{e.beforeReconnect&&await e.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=e.authToken&&bs(e.authToken)}getLongPollTransport(){return xs}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=Hn.appendParams(Hn.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,e,r){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},e,r)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=bs(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==xs?this.connectWithFallback(xs,this.longPollFallbackMs):this.transportConnect())}log(t,e,r){this.logger&&this.logger(t,e,r)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}onHeartbeat(t){this.heartbeatCallback=t}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),r=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let s=this.onMessage(n=>{n.ref===e&&(this.off([s]),t(Date.now()-r))});return!0}transportName(t){return t===xs?"LongPoll":t.name}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${fi}${btoa(this.authToken()).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),t),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let r=!1,s=!0,n,a,i=this.transportName(t),o=l=>{this.log("transport",`falling back to ${i}...`,l),this.off([n,a]),s=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${i}`))return o("memorized");this.fallbackTimer=setTimeout(o,e),a=this.onError(l=>{this.log("transport","error",l),s&&!r&&(clearTimeout(this.fallbackTimer),o(l))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(r=!0,!s){let l=this.transportName(t);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${l}`,"true"),this.log("transport",`established ${l} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(o,e),this.ping(l=>{this.log("transport","connected to primary after",l),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(t){this.log("error","error in heartbeat callback",t)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),yg,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,r){if(!this.conn)return t&&t();const s=this.conn;this.waitForBufferDone(s,()=>{e?s.close(e,r||""):s.close(),this.waitForSocketClosed(s,()=>{this.conn===s&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,e,r=1){if(r===5||!t.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(t,e,r+1)},150*r)}waitForSocketClosed(t,e,r=1){if(r===5||t.readyState===tr.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(t,e,r+1)},150*r)}onConnClose(t){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(t),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",t)}onConnError(t){this.hasLogger()&&this.log("transport","error",t);let e=this.transport,r=this.establishedConnections;this.triggerStateCallbacks("error",t,e,r),(e===this.transport||r>0)&&this.triggerChanError(t)}triggerChanError(t){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(fr.error,t)})}connectionState(){switch(this.conn&&this.conn.readyState){case tr.connecting:return"connecting";case tr.open:return"open";case tr.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(e=>e!==t)}off(t){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([r])=>t.indexOf(r)===-1)}channel(t,e={}){let r=new wg(t,e,this);return this.channels.push(r),r}push(t){if(this.hasLogger()){let{topic:e,event:r,payload:s,ref:n,join_ref:a}=t;this.log("push",`${e} ${r} (${a}, ${n})`,s)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(t){this.log("error","error in heartbeat callback",t)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(t){this.log("error","error in heartbeat callback",t)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:r,event:s,payload:n,ref:a,join_ref:i}=e;if(a&&a===this.pendingHeartbeatRef){const o=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(n.status==="ok"?"ok":"error",o)}catch(l){this.log("error","error in heartbeat callback",l)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${n.status||""} ${r} ${s} ${a&&"("+a+")"||""}`.trim(),n);for(let o=0;o<this.channels.length;o++){const l=this.channels[o];l.isMember(r,s,n,i)&&l.trigger(s,n,a,i)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(t,...e){try{this.stateChangeCallbacks[t].forEach(([r,s])=>{try{s(...e)}catch(n){this.log("error",`error in ${t} callback`,n)}})}catch(r){this.log("error",`error triggering ${t} callbacks`,r)}}leaveOpenTopic(t){let e=this.channels.find(r=>r.topic===t&&(r.isJoined()||r.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}};class Zs{constructor(e,r){const s=Cg(r);this.presence=new _g(e.getChannel(),s),this.presence.onJoin((n,a,i)=>{const o=Zs.onJoinPayload(n,a,i);e.getChannel().trigger("presence",o)}),this.presence.onLeave((n,a,i)=>{const o=Zs.onLeavePayload(n,a,i);e.getChannel().trigger("presence",o)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return Zs.transformState(this.presence.state)}static transformState(e){return e=Sg(e),Object.getOwnPropertyNames(e).reduce((r,s)=>{const n=e[s];return r[s]=qn(n),r},{})}static onJoinPayload(e,r,s){const n=wc(r),a=qn(s);return{event:"join",key:e,currentPresences:n,newPresences:a}}static onLeavePayload(e,r,s){const n=wc(r),a=qn(s);return{event:"leave",key:e,currentPresences:n,leftPresences:a}}}function qn(t){return t.metas.map(e=>{const r=Object.getOwnPropertyDescriptors(e),s=Object.defineProperties({},r);return s.presence_ref=s.phx_ref,delete s.phx_ref,delete s.phx_ref_prev,s})}function Sg(t){return JSON.parse(JSON.stringify(t))}function Cg(t){return t?.events&&{events:t.events}}function wc(t){return t?.metas?qn(t):[]}var xc;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(xc||(xc={}));class Eg{get state(){return this.presenceAdapter.state}constructor(e,r){this.channel=e,this.presenceAdapter=new Zs(this.channel.channelAdapter,r)}}function Tg(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t&&typeof t=="object"){const e=t;if(typeof e.code=="number"){const r=typeof e.reason=="string"&&e.reason?` (${e.reason})`:"";return new Error(`socket closed: ${e.code}${r}`,{cause:t})}return new Error("channel error: transport failure",{cause:t})}return new Error("channel error: connection lost")}class Ag{constructor(e,r,s){const n=jg(s);this.channel=e.getSocket().channel(r,n),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,r){return this.channel.on(e,r)}off(e,r){this.channel.off(e,r)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,r,s){let n;try{n=this.channel.push(e,r,s)}catch{throw new Error(`tried to push '${e}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>ig){const a=this.channel.pushBuffer.shift();a.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${a.event}`,a.payload())}return n}updateJoinPayload(e){const r=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},r),e)}canPush(){return this.socket.isConnected()&&this.state===jr.joined}isJoined(){return this.state===jr.joined}isJoining(){return this.state===jr.joining}isClosed(){return this.state===jr.closed}isLeaving(){return this.state===jr.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}function jg(t){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config)}}const Og=/[,()"\\]/,Pg=t=>Og.test(t)||t!==t.trim(),Ng=t=>`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,_c=t=>{const e=t===null?"null":String(t);return Pg(e)?Ng(e):e},Rg=t=>t===null?"null":String(t),Ig=(t,e)=>{if(t==="in"){const r=Array.isArray(e)?e:[e];if(r.length===0)throw new Error("Realtime `in` filter requires at least one value.");return`in.(${Array.from(new Set(r)).map(n=>_c(n)).join(",")})`}return t==="is"?`is.${Rg(e)}`:`${t}.${_c(e)}`};class Dg{constructor(){this.filters=[]}add(e,r,s,n=!1){const a=n?"not.":"";return this.filters.push(`${e}=${a}${Ig(r,s)}`),this}eq(e,r){return this.add(e,"eq",r)}neq(e,r){return this.add(e,"neq",r)}gt(e,r){return this.add(e,"gt",r)}gte(e,r){return this.add(e,"gte",r)}lt(e,r){return this.add(e,"lt",r)}lte(e,r){return this.add(e,"lte",r)}in(e,r){return this.add(e,"in",r)}like(e,r){return this.add(e,"like",r)}ilike(e,r){return this.add(e,"ilike",r)}match(e,r){return this.add(e,"match",r)}imatch(e,r){return this.add(e,"imatch",r)}is(e,r){return this.add(e,"is",r)}isDistinct(e,r){return this.add(e,"isdistinct",r)}not(e,r,s){return this.add(e,r,s,!0)}build(){return this.filters.join(",")}toString(){return this.build()}}var kc;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(kc||(kc={}));var Wr;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(Wr||(Wr={}));var pr;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(pr||(pr={}));class mr{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,r={config:{}},s){var n,a;if(this.topic=e,this.params=r,this.socket=s,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.channelAdapter=new Ag(this.socket.socketAdapter,e,this.params),this.presence=new Eg(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=vc(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((a=(n=this.params.config)===null||n===void 0?void 0:n.broadcast)===null||a===void 0)&&a.replay))throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(e,r=this.timeout){var s,n,a,i;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:o,presence:l,private:c,postgres_changes_options:u}}=this.params,p=(n=(s=this.bindings.postgres_changes)===null||s===void 0?void 0:s.map(v=>v.filter))!==null&&n!==void 0?n:[],f=!!this.bindings[Wr.PRESENCE]&&this.bindings[Wr.PRESENCE].length>0||((a=this.params.config.presence)===null||a===void 0?void 0:a.enabled)===!0,h={},y=Object.assign({broadcast:o,presence:Object.assign(Object.assign({},l),{enabled:f}),postgres_changes:p,private:c},u?{postgres_changes_options:u}:{});this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(v=>{e?.(pr.CHANNEL_ERROR,Tg(v))}),this._onClose(()=>e?.(pr.CLOSED)),this.updateJoinPayload(Object.assign({config:y},h)),this._updateFilterMessage();const g=u?.wait&&p.length>0?Math.max(r,((i=u.timeout)!==null&&i!==void 0?i:ng)+ag):r;this.channelAdapter.subscribe(g).receive("ok",async({postgres_changes:v})=>{if(this.socket._isManualToken()||this.socket.setAuth(),v===void 0){e?.(pr.SUBSCRIBED);return}this._updatePostgresBindings(v,e)}).receive("error",v=>{this.state=jr.errored;const C=Object.values(v).join(", ")||"error";e?.(pr.CHANNEL_ERROR,new Error(C,{cause:v}))}).receive("timeout",()=>{e?.(pr.TIMED_OUT)})}return this}_updatePostgresBindings(e,r){var s;const n=this.bindings.postgres_changes,a=(s=n?.length)!==null&&s!==void 0?s:0,i=[];for(let o=0;o<a;o++){const l=n[o],{filter:{event:c,schema:u,table:p,filter:f}}=l,h=e&&e[o];if(h&&h.event===c&&mr.isFilterValueEqual(h.schema,u)&&mr.isFilterValueEqual(h.table,p)&&mr.isFilterValueEqual(h.filter,f))i.push(Object.assign(Object.assign({},l),{id:h.id}));else{this.unsubscribe(),this.state=jr.errored,r?.(pr.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=i,this.state!=jr.errored&&r&&r(pr.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,s){const n=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),a=e===Wr.PRESENCE||e===Wr.POSTGRES_CHANGES;if(n&&a)throw this.socket.log("channel",`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`),new Error(`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(e,r,s)}async httpSend(e,r,s={}){var n;if(r==null)return Promise.reject(new Error("Payload is required for httpSend()"));const a=r instanceof ArrayBuffer||ArrayBuffer.isView(r),i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":a?"application/octet-stream":"application/json"};this.socket.accessTokenValue&&(i.Authorization=`Bearer ${this.socket.accessTokenValue}`);const o=new URL(this.broadcastEndpointURL);o.pathname+=`/${encodeURIComponent(this.subTopic)}/events/${encodeURIComponent(e)}`,this.private&&o.searchParams.set("private","true");const l={method:"POST",headers:i,body:a?r:JSON.stringify(r)},c=await this._fetchWithTimeout(o.toString(),l,(n=s.timeout)!==null&&n!==void 0?n:this.timeout);if(c.status===202)return{success:!0};if(c.status===404)return Promise.reject(new Error("httpSend() requires Realtime server v2.97.0 or newer; the endpoint returned 404. Update your Supabase CLI to a recent version, or upgrade the Realtime server in your self-hosted setup. See https://github.com/supabase/supabase-js/blob/master/packages/core/realtime-js/migrations/httpsend-server-version.md"));let u=c.statusText;try{const p=await c.json();u=p.error||p.message||u}catch{}return Promise.reject(new Error(u))}async send(e,r={}){var s,n;if(!this.channelAdapter.canPush()&&e.type==="broadcast"){const a="Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.";this.socket.hasLogger()?this.socket.log("channel",a):console.warn(a);const{event:i,payload:o}=e,l={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(l.Authorization=`Bearer ${this.socket.accessTokenValue}`);const c={method:"POST",headers:l,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(s=r.timeout)!==null&&s!==void 0?s:this.timeout);return await((n=u.body)===null||n===void 0?void 0:n.cancel()),u.ok?"ok":"error"}catch(u){return u instanceof Error&&u.name==="AbortError"?"timed out":"error"}}else return new Promise(a=>{var i,o,l;const c=this.channelAdapter.push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(o=(i=this.params)===null||i===void 0?void 0:i.config)===null||o===void 0?void 0:o.broadcast)===null||l===void 0)&&l.ack)&&a("ok"),c.receive("ok",()=>a("ok")),c.receive("error",()=>a("error")),c.receive("timeout",()=>a("timed out"))})}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(e=this.timeout){return new Promise(r=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>r("ok")).receive("timeout",()=>r("timed out")).receive("error",()=>r("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,r,s){const n=new AbortController,a=setTimeout(()=>n.abort(),s),i=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:n.signal}));return clearTimeout(a),i}_on(e,r,s){var n;const a=e.toLocaleLowerCase(),i=r?.filter;if((i instanceof Dg||typeof i=="object"&&i!==null&&typeof i.build=="function")&&(r=Object.assign(Object.assign({},r),{filter:i.build()})),a===Wr.POSTGRES_CHANGES&&((n=this.bindings[a])===null||n===void 0?void 0:n.find(u=>mr.isSamePostgresFilter(u.filter,r))))return this.socket.log("error",`duplicate \`postgres_changes\` binding for ${this.topic} ignored`,r),this;const o=this.channelAdapter.on(e,s),l={type:a,filter:r,callback:s,ref:o};return this.bindings[a]?this.bindings[a].push(l):this.bindings[a]=[l],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,r,s)=>{var n,a,i,o,l,c,u;const p=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(p,s))return!1;const f=(n=this.bindings[p])===null||n===void 0?void 0:n.find(h=>h.ref===e.ref);if(!f)return!0;if(["broadcast","presence","postgres_changes"].includes(p))if("id"in f){const h=f.id,y=(a=f.filter)===null||a===void 0?void 0:a.event;return h&&((i=r.ids)===null||i===void 0?void 0:i.includes(h))&&(y==="*"||y?.toLocaleLowerCase()===((o=r.data)===null||o===void 0?void 0:o.type.toLocaleLowerCase()))}else{const h=(c=(l=f?.filter)===null||l===void 0?void 0:l.event)===null||c===void 0?void 0:c.toLocaleLowerCase();return h==="*"||h===((u=r?.event)===null||u===void 0?void 0:u.toLocaleLowerCase())}else return f.type.toLocaleLowerCase()===p})}_notThisChannelEvent(e,r){const{close:s,error:n,leave:a,join:i}=mc;return r&&[s,n,a,i].includes(e)&&r!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,r,s)=>{if(typeof r=="object"&&"ids"in r){const n=r.data,{schema:a,table:i,commit_timestamp:o,type:l,errors:c}=n;return Object.assign(Object.assign({},{schema:a,table:i,commit_timestamp:o,eventType:l,new:{},old:{},errors:c}),this._getPayloadRecords(n))}return r})}copyBindings(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const r in e.bindings)for(const s of e.bindings[r])this._on(s.type,s.filter,s.callback)}static isFilterValueEqual(e,r){return(e??void 0)===(r??void 0)}static isSamePostgresFilter(e,r){var s,n,a,i;const o=(n=(s=e?.select)===null||s===void 0?void 0:s.join())!==null&&n!==void 0?n:void 0,l=(i=(a=r?.select)===null||a===void 0?void 0:a.join())!==null&&i!==void 0?i:void 0;return e?.event===r?.event&&mr.isFilterValueEqual(e?.schema,r?.schema)&&mr.isFilterValueEqual(e?.table,r?.table)&&mr.isFilterValueEqual(e?.filter,r?.filter)&&o===l}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=gc(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=gc(e.columns,e.old_record)),r}}class Lg{constructor(e,r){this.socket=new kg(e,r)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,r,s,n=1e4){return new Promise(a=>{setTimeout(()=>a("timeout"),n),this.socket.disconnect(()=>{e(),a("ok")},r,s)})}push(e){this.socket.push(e)}log(e,r,s){this.socket.log(e,r,s)}hasLogger(){return this.socket.hasLogger()}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==ui.connecting}isDisconnecting(){return this.socket.connectionState()==ui.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const Sc={HEARTBEAT_INTERVAL:25e3},$g=[1e3,2e3,5e3,1e4],Mg=1e4;function Fg(){const t=new Map;return{get length(){return t.size},clear(){t.clear()},getItem(e){return t.has(e)?t.get(e):null},key(e){var r;return(r=Array.from(t.keys())[e])!==null&&r!==void 0?r:null},removeItem(e){t.delete(e)},setItem(e,r){t.set(e,String(r))}}}function Ug(){try{if(typeof globalThis<"u"&&globalThis.sessionStorage)return globalThis.sessionStorage}catch{}return Fg()}const Bg=`
134
+ Suggested solution: ${e.workaround}`),new Error(r)}static isWebSocketSupported(){try{return this.detectEnvironment().type==="native"}catch{return!1}}}const Ym="realtime-js/2.112.4",Xm="1.0.0",hc="2.0.0",Qm=hc,eg=1e4,tg=100,jr={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},fc={close:"phx_close",error:"phx_error",join:"phx_join",leave:"phx_leave",access_token:"access_token"},ui={connecting:"connecting",closing:"closing",closed:"closed"};class rg{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,r){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return r(this._binaryEncodeUserBroadcastPush(e));let s=[e.join_ref,e.ref,e.topic,e.event,e.payload];return r(JSON.stringify(s))}_binaryEncodeUserBroadcastPush(e){var r;return this._isArrayBuffer((r=e.payload)===null||r===void 0?void 0:r.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var r,s;const n=(s=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&s!==void 0?s:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}_encodeJsonUserBroadcastPush(e){var r,s;const n=(s=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&s!==void 0?s:{},i=new TextEncoder().encode(JSON.stringify(n)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,i)}_encodeUserBroadcastPush(e,r,s){var n,a;const i=new TextEncoder,o=i.encode(e.topic),l=i.encode((n=e.ref)!==null&&n!==void 0?n:""),c=i.encode((a=e.join_ref)!==null&&a!==void 0?a:""),d=i.encode(e.payload.event),f=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},p=i.encode(Object.keys(f).length===0?"":JSON.stringify(f));if(c.length>255)throw new Error(`joinRef length ${c.length} exceeds maximum of 255`);if(l.length>255)throw new Error(`ref length ${l.length} exceeds maximum of 255`);if(o.length>255)throw new Error(`topic length ${o.length} exceeds maximum of 255`);if(d.length>255)throw new Error(`userEvent length ${d.length} exceeds maximum of 255`);if(p.length>255)throw new Error(`metadata length ${p.length} exceeds maximum of 255`);const h=this.USER_BROADCAST_PUSH_META_LENGTH+c.length+l.length+o.length+d.length+p.length,g=new ArrayBuffer(this.HEADER_LENGTH+h),y=new DataView(g),v=new Uint8Array(g);let C=0;y.setUint8(C++,this.KINDS.userBroadcastPush),y.setUint8(C++,c.length),y.setUint8(C++,l.length),y.setUint8(C++,o.length),y.setUint8(C++,d.length),y.setUint8(C++,p.length),y.setUint8(C++,r),v.set(c,C),C+=c.length,v.set(l,C),C+=l.length,v.set(o,C),C+=o.length,v.set(d,C),C+=d.length,v.set(p,C),C+=p.length;var _=new Uint8Array(g.byteLength+s.byteLength);return _.set(new Uint8Array(g),0),_.set(new Uint8Array(s),g.byteLength),_.buffer}decode(e,r){if(this._isArrayBuffer(e)){let s=this._binaryDecode(e);return r(s)}if(typeof e=="string"){const s=JSON.parse(e),[n,a,i,o,l]=s;return r({join_ref:n,ref:a,topic:i,event:o,payload:l})}return r({})}_binaryDecode(e){const r=new DataView(e),s=r.getUint8(0),n=new TextDecoder;if(s===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,r,n)}_decodeUserBroadcast(e,r,s){const n=r.getUint8(1),a=r.getUint8(2),i=r.getUint8(3),o=r.getUint8(4);let l=this.HEADER_LENGTH+4;const c=s.decode(e.slice(l,l+n));l=l+n;const d=s.decode(e.slice(l,l+a));l=l+a;const f=s.decode(e.slice(l,l+i));l=l+i;const p=e.slice(l,e.byteLength),h=o===this.JSON_ENCODING?JSON.parse(s.decode(p)):p,g={type:this.BROADCAST_EVENT,event:d,payload:h};return i>0&&(g.meta=JSON.parse(f)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:g}}_isArrayBuffer(e){var r;return e instanceof ArrayBuffer||((r=e?.constructor)===null||r===void 0?void 0:r.name)==="ArrayBuffer"}_pick(e,r){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([s])=>r.includes(s)))}}var De;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(De||(De={}));const pc=(t,e,r={})=>{var s;const n=(s=r.skipTypes)!==null&&s!==void 0?s:[];return e?Object.keys(e).reduce((a,i)=>(a[i]=sg(i,t,e,n),a),{}):{}},sg=(t,e,r,s)=>{const n=e.find(o=>o.name===t),a=n?.type,i=r[t];return a&&!s.includes(a)?mc(a,i):di(i)},mc=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return og(e,r)}switch(t){case De.bool:return ng(e);case De.float4:case De.float8:case De.int2:case De.int4:case De.int8:case De.numeric:case De.oid:return ag(e);case De.json:case De.jsonb:return ig(e);case De.timestamp:return lg(e);case De.abstime:case De.date:case De.daterange:case De.int4range:case De.int8range:case De.money:case De.reltime:case De.text:case De.time:case De.timestamptz:case De.timetz:case De.tsrange:case De.tstzrange:return di(e);default:return di(e)}},di=t=>t,ng=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},ag=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},ig=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},og=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,s=t[r];if(t[0]==="{"&&s==="}"){let a;const i=t.slice(1,r);try{a=JSON.parse("["+i+"]")}catch{a=i?i.split(","):[]}return a.map(o=>mc(e,o))}return t},lg=t=>typeof t=="string"?t.replace(" ","T"):t,gc=t=>{const e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};var vs=t=>typeof t=="function"?t:function(){return t},cg=typeof self<"u"?self:null,bs=typeof window<"u"?window:null,er=cg||bs||globalThis,ug="2.0.0",dg=1e4,hg=1e3,fg=100,tr={connecting:0,open:1,closing:2,closed:3},gt={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},fr={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},hi={longpoll:"longpoll",websocket:"websocket"},pg={complete:4},fi="base64url.bearer.phx.",Kn=class{constructor(t,e,r,s){this.channel=t,this.event=e,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(t){this.timeout=t,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:t,response:e,_ref:r}){this.recHooks.filter(s=>s.status===t).forEach(s=>s.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},yc=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},mg=class{constructor(t,e,r){this.state=gt.closed,this.topic=t,this.params=vs(e||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Kn(this,fr.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new yc(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=gt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",s=>{this.state=gt.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=gt.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=gt.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new Kn(this,fr.leave,vs({}),this.timeout).send(),this.state=gt.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(fr.reply,(s,n)=>{this.trigger(this.replyEventName(n),s)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=gt.closed,this.bindings=[]}onClose(t){this.on(fr.close,t)}onError(t){return this.on(fr.error,e=>t(e))}on(t,e){let r=this.bindingRef++;return this.bindings.push({event:t,ref:r,callback:e}),r}off(t,e){this.bindings=this.bindings.filter(r=>!(r.event===t&&(typeof e>"u"||e===r.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,r=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new Kn(this,t,function(){return e},r);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=gt.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(fr.close,"leave")},r=new Kn(this,fr.leave,vs({}),t);return r.receive("ok",()=>e()).receive("timeout",()=>e()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(t,e,r){return e}filterBindings(t,e,r){return!0}isMember(t,e,r,s){return this.topic!==t?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:r,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=gt.joining,this.joinPush.resend(t))}trigger(t,e,r,s){let n=this.onMessage(t,e,r,s);if(e&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let a=this.bindings.filter(i=>i.event===t&&this.filterBindings(i,e,r));for(let i=0;i<a.length;i++)a[i].callback(n,r,s||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===gt.closed}isErrored(){return this.state===gt.errored}isJoined(){return this.state===gt.joined}isJoining(){return this.state===gt.joining}isLeaving(){return this.state===gt.leaving}},zn=class{static request(t,e,r,s,n,a,i){if(er.XDomainRequest){let o=new er.XDomainRequest;return this.xdomainRequest(o,t,e,s,n,a,i)}else if(er.XMLHttpRequest){let o=new er.XMLHttpRequest;return this.xhrRequest(o,t,e,r,s,n,a,i)}else{if(er.fetch&&er.AbortController)return this.fetchRequest(t,e,r,s,n,a,i);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,e,r,s,n,a,i){let o={method:t,headers:r,body:s},l=null;return n&&(l=new AbortController,setTimeout(()=>l.abort(),n),o.signal=l.signal),er.fetch(e,o).then(c=>c.text()).then(c=>this.parseJSON(c)).then(c=>i&&i(c)).catch(c=>{c.name==="AbortError"&&a?a():i&&i(null)}),l}static xdomainRequest(t,e,r,s,n,a,i){return t.timeout=n,t.open(e,r),t.onload=()=>{let o=this.parseJSON(t.responseText);i&&i(o)},a&&(t.ontimeout=a),t.onprogress=()=>{},t.send(s),t}static xhrRequest(t,e,r,s,n,a,i,o){t.open(e,r,!0),t.timeout=a;for(let[l,c]of Object.entries(s))t.setRequestHeader(l,c);return t.onerror=()=>o&&o(null),t.onreadystatechange=()=>{if(t.readyState===pg.complete&&o){let l=this.parseJSON(t.responseText);o(l)}},i&&(t.ontimeout=i),t.send(n),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let r=[];for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let n=e?`${e}[${s}]`:s,a=t[s];typeof a=="object"?r.push(this.serialize(a,n)):r.push(encodeURIComponent(n)+"="+encodeURIComponent(a))}return r.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let r=t.match(/\?/)?"&":"?";return`${t}${r}${this.serialize(e)}`}},gg=t=>{let e="",r=new Uint8Array(t),s=r.byteLength;for(let n=0;n<s;n++)e+=String.fromCharCode(r[n]);return btoa(e)},ws=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(fi)&&(this.authToken=atob(e[1].slice(fi.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=tr.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+hi.websocket),"$1/"+hi.longpoll)}endpointURL(){return zn.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,r){this.close(t,e,r),this.readyState=tr.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===tr.open||this.readyState===tr.connecting}poll(){const t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),e=>{if(e){var{status:r,token:s,messages:n}=e;if(r===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=s}else r=0;switch(r){case 200:n.forEach(a=>{setTimeout(()=>this.onmessage({data:a}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=tr.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${r}`)}})}send(t){typeof t!="string"&&(t=gg(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t,e=0){this.awaitingBatchAck=!0;const r=e+fg,s=t.slice(e,r);this.ajax("POST",{"Content-Type":"application/x-ndjson"},s.join(`
135
+ `),()=>this.onerror("timeout"),n=>{!n||n.status!==200?(this.awaitingBatchAck=!1,this.onerror(n&&n.status),this.closeAndRetry(1011,"internal server error",!1)):r<t.length?this.batchSend(t,r):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1})}close(t,e,r){for(let n of this.reqs)n.abort();this.readyState=tr.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:r});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(t,e,r,s,n){let a,i=()=>{this.reqs.delete(a),s()};a=zn.request(t,this.endpointURL(),e,r,this.timeout,i,o=>{this.reqs.delete(a),this.isActive()&&n(o)}),this.reqs.add(a)}},yg=class un{constructor(e,r={}){let s=r.events||{state:"presence_state",diff:"presence_diff"};this.state=Object.create(null),this.pendingDiffs=[],this.channel=e,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(s.state,n=>{let{onJoin:a,onLeave:i,onSync:o}=this.caller;this.joinRef=this.channel.joinRef(),this.state=un.syncState(this.state,n,a,i),this.pendingDiffs.forEach(l=>{this.state=un.syncDiff(this.state,l,a,i)}),this.pendingDiffs=[],o()}),this.channel.on(s.diff,n=>{let{onJoin:a,onLeave:i,onSync:o}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=un.syncDiff(this.state,n,a,i),o())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(e){return un.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,r,s,n){let a=this.toNullProtoObj(this.clone(e));r=this.toNullProtoObj(r);let i=Object.create(null),o=Object.create(null);return this.map(a,(l,c)=>{r[l]||(o[l]=c)}),this.map(r,(l,c)=>{let d=a[l];if(d){let f=c.metas.map(y=>y.phx_ref),p=d.metas.map(y=>y.phx_ref),h=c.metas.filter(y=>p.indexOf(y.phx_ref)<0),g=d.metas.filter(y=>f.indexOf(y.phx_ref)<0);h.length>0&&(i[l]=c,i[l].metas=h),g.length>0&&(o[l]=this.clone(d),o[l].metas=g)}else i[l]=c}),this.syncDiff(a,{joins:i,leaves:o},s,n)}static syncDiff(e,r,s,n){e=this.toNullProtoObj(e);let{joins:a,leaves:i}=this.clone(r);return s||(s=function(){}),n||(n=function(){}),this.map(a,(o,l)=>{let c=e[o];if(e[o]=this.clone(l),c){let d=e[o].metas.map(p=>p.phx_ref),f=c.metas.filter(p=>d.indexOf(p.phx_ref)<0);e[o].metas.unshift(...f)}s(o,c,l)}),this.map(i,(o,l)=>{let c=e[o];if(!c)return;let d=l.metas.map(f=>f.phx_ref);c.metas=c.metas.filter(f=>d.indexOf(f.phx_ref)<0),n(o,c,l),c.metas.length===0&&delete e[o]}),e}static list(e,r){return r||(r=function(s,n){return n}),this.map(e,(s,n)=>r(s,n))}static map(e,r){return Object.getOwnPropertyNames(e).map(s=>r(s,e[s]))}static toNullProtoObj(e){if(Object.getPrototypeOf(e)===null)return e;let r=Object.create(null);return Object.getOwnPropertyNames(e).forEach(s=>{r[s]=e[s]}),r}static clone(e){return JSON.parse(JSON.stringify(e))}},Hn={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let r=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(r))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[r,s,n,a,i]=JSON.parse(t);return e({join_ref:r,ref:s,topic:n,event:a,payload:i})}},binaryEncode(t){let{join_ref:e,ref:r,event:s,topic:n,payload:a}=t,i=new TextEncoder,o=i.encode(e),l=i.encode(r),c=i.encode(n),d=i.encode(s);this.assertFieldSize(o.byteLength,"join_ref"),this.assertFieldSize(l.byteLength,"ref"),this.assertFieldSize(c.byteLength,"topic"),this.assertFieldSize(d.byteLength,"event");let f=this.META_LENGTH+o.byteLength+l.byteLength+c.byteLength+d.byteLength,p=new ArrayBuffer(this.HEADER_LENGTH+f),h=new Uint8Array(p),g=new DataView(p),y=0;g.setUint8(y++,this.KINDS.push),g.setUint8(y++,o.byteLength),g.setUint8(y++,l.byteLength),g.setUint8(y++,c.byteLength),g.setUint8(y++,d.byteLength),h.set(o,y),y+=o.byteLength,h.set(l,y),y+=l.byteLength,h.set(c,y),y+=c.byteLength,h.set(d,y),y+=d.byteLength;var v=new Uint8Array(p.byteLength+a.byteLength);return v.set(h,0),v.set(new Uint8Array(a),p.byteLength),v.buffer},assertFieldSize(t,e){if(t>255)throw new Error(`unable to convert ${e} to binary: must be less than or equal to 255 bytes, but is ${t} bytes`)},binaryDecode(t){let e=new DataView(t),r=e.getUint8(0),s=new TextDecoder;switch(r){case this.KINDS.push:return this.decodePush(t,e,s);case this.KINDS.reply:return this.decodeReply(t,e,s);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,s)}},decodePush(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),a=e.getUint8(3),i=this.HEADER_LENGTH+this.META_LENGTH-1,o=r.decode(t.slice(i,i+s));i=i+s;let l=r.decode(t.slice(i,i+n));i=i+n;let c=r.decode(t.slice(i,i+a));i=i+a;let d=t.slice(i,t.byteLength);return{join_ref:o,ref:null,topic:l,event:c,payload:d}},decodeReply(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),a=e.getUint8(3),i=e.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(t.slice(o,o+s));o=o+s;let c=r.decode(t.slice(o,o+n));o=o+n;let d=r.decode(t.slice(o,o+a));o=o+a;let f=r.decode(t.slice(o,o+i));o=o+i;let p=t.slice(o,t.byteLength),h={status:f,response:p};return{join_ref:l,ref:c,topic:d,event:fr.reply,payload:h}},decodeBroadcast(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),a=this.HEADER_LENGTH+2,i=r.decode(t.slice(a,a+s));a=a+s;let o=r.decode(t.slice(a,a+n));a=a+n;let l=t.slice(a,t.byteLength);return{join_ref:null,ref:null,topic:i,event:o,payload:l}}},vg=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||dg,this.transport=e.transport||er.WebSocket||ws,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null;let r=null;try{r=er&&er.sessionStorage}catch{}this.sessionStore=e.sessionStorage||r,this.establishedConnections=0,this.defaultEncoder=Hn.encode.bind(Hn),this.defaultDecoder=Hn.decode.bind(Hn),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==ws?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let s=null;bs&&bs.addEventListener&&(bs.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),s=this.connectClock)}),bs.addEventListener("pageshow",n=>{s===this.connectClock&&(s=null,this.connect())}),bs.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=e.autoSendHeartbeat??!0,this.heartbeatCallback=e.heartbeatCallback??(()=>{}),this.rejoinAfterMs=n=>e.rejoinAfterMs?e.rejoinAfterMs(n):[1e3,2e3,5e3][n-1]||1e4,this.reconnectAfterMs=n=>e.reconnectAfterMs?e.reconnectAfterMs(n):[10,50,100,150,200,250,500,1e3,2e3][n-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(n,a,i)=>{console.log(`${n}: ${a}`,i)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=vs(e.params||{}),this.endPoint=`${t}/${hi.websocket}`,this.vsn=e.vsn||ug,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new yc(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{e.beforeReconnect&&await e.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=e.authToken&&vs(e.authToken)}getLongPollTransport(){return ws}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=zn.appendParams(zn.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,e,r){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},e,r)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=vs(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==ws?this.connectWithFallback(ws,this.longPollFallbackMs):this.transportConnect())}log(t,e,r){this.logger&&this.logger(t,e,r)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}onHeartbeat(t){this.heartbeatCallback=t}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),r=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let s=this.onMessage(n=>{n.ref===e&&(this.off([s]),t(Date.now()-r))});return!0}transportName(t){return t===ws?"LongPoll":t.name}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${fi}${btoa(this.authToken()).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),t),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let r=!1,s=!0,n,a,i=this.transportName(t),o=l=>{this.log("transport",`falling back to ${i}...`,l),this.off([n,a]),s=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${i}`))return o("memorized");this.fallbackTimer=setTimeout(o,e),a=this.onError(l=>{this.log("transport","error",l),s&&!r&&(clearTimeout(this.fallbackTimer),o(l))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(r=!0,!s){let l=this.transportName(t);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${l}`,"true"),this.log("transport",`established ${l} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(o,e),this.ping(l=>{this.log("transport","connected to primary after",l),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(t){this.log("error","error in heartbeat callback",t)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),hg,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,r){if(!this.conn)return t&&t();const s=this.conn;this.waitForBufferDone(s,()=>{e?s.close(e,r||""):s.close(),this.waitForSocketClosed(s,()=>{this.conn===s&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,e,r=1){if(r===5||!t.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(t,e,r+1)},150*r)}waitForSocketClosed(t,e,r=1){if(r===5||t.readyState===tr.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(t,e,r+1)},150*r)}onConnClose(t){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(t),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",t)}onConnError(t){this.hasLogger()&&this.log("transport","error",t);let e=this.transport,r=this.establishedConnections;this.triggerStateCallbacks("error",t,e,r),(e===this.transport||r>0)&&this.triggerChanError(t)}triggerChanError(t){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(fr.error,t)})}connectionState(){switch(this.conn&&this.conn.readyState){case tr.connecting:return"connecting";case tr.open:return"open";case tr.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(e=>e!==t)}off(t){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([r])=>t.indexOf(r)===-1)}channel(t,e={}){let r=new mg(t,e,this);return this.channels.push(r),r}push(t){if(this.hasLogger()){let{topic:e,event:r,payload:s,ref:n,join_ref:a}=t;this.log("push",`${e} ${r} (${a}, ${n})`,s)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(t){this.log("error","error in heartbeat callback",t)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(t){this.log("error","error in heartbeat callback",t)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:r,event:s,payload:n,ref:a,join_ref:i}=e;if(a&&a===this.pendingHeartbeatRef){const o=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(n.status==="ok"?"ok":"error",o)}catch(l){this.log("error","error in heartbeat callback",l)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${n.status||""} ${r} ${s} ${a&&"("+a+")"||""}`.trim(),n);for(let o=0;o<this.channels.length;o++){const l=this.channels[o];l.isMember(r,s,n,i)&&l.trigger(s,n,a,i)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(t,...e){try{this.stateChangeCallbacks[t].forEach(([r,s])=>{try{s(...e)}catch(n){this.log("error",`error in ${t} callback`,n)}})}catch(r){this.log("error",`error triggering ${t} callbacks`,r)}}leaveOpenTopic(t){let e=this.channels.find(r=>r.topic===t&&(r.isJoined()||r.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}};class Js{constructor(e,r){const s=wg(r);this.presence=new yg(e.getChannel(),s),this.presence.onJoin((n,a,i)=>{const o=Js.onJoinPayload(n,a,i);e.getChannel().trigger("presence",o)}),this.presence.onLeave((n,a,i)=>{const o=Js.onLeavePayload(n,a,i);e.getChannel().trigger("presence",o)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return Js.transformState(this.presence.state)}static transformState(e){return e=bg(e),Object.getOwnPropertyNames(e).reduce((r,s)=>{const n=e[s];return r[s]=Wn(n),r},{})}static onJoinPayload(e,r,s){const n=vc(r),a=Wn(s);return{event:"join",key:e,currentPresences:n,newPresences:a}}static onLeavePayload(e,r,s){const n=vc(r),a=Wn(s);return{event:"leave",key:e,currentPresences:n,leftPresences:a}}}function Wn(t){return t.metas.map(e=>{const r=Object.getOwnPropertyDescriptors(e),s=Object.defineProperties({},r);return s.presence_ref=s.phx_ref,delete s.phx_ref,delete s.phx_ref_prev,s})}function bg(t){return JSON.parse(JSON.stringify(t))}function wg(t){return t?.events&&{events:t.events}}function vc(t){return t?.metas?Wn(t):[]}var bc;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(bc||(bc={}));class xg{get state(){return this.presenceAdapter.state}constructor(e,r){this.channel=e,this.presenceAdapter=new Js(this.channel.channelAdapter,r)}}function _g(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t&&typeof t=="object"){const e=t;if(typeof e.code=="number"){const r=typeof e.reason=="string"&&e.reason?` (${e.reason})`:"";return new Error(`socket closed: ${e.code}${r}`,{cause:t})}return new Error("channel error: transport failure",{cause:t})}return new Error("channel error: connection lost")}class kg{constructor(e,r,s){const n=Sg(s);this.channel=e.getSocket().channel(r,n),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,r){return this.channel.on(e,r)}off(e,r){this.channel.off(e,r)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,r,s){let n;try{n=this.channel.push(e,r,s)}catch{throw new Error(`tried to push '${e}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>tg){const a=this.channel.pushBuffer.shift();a.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${a.event}`,a.payload())}return n}updateJoinPayload(e){const r=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},r),e)}canPush(){return this.socket.isConnected()&&this.state===jr.joined}isJoined(){return this.state===jr.joined}isJoining(){return this.state===jr.joining}isClosed(){return this.state===jr.closed}isLeaving(){return this.state===jr.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}function Sg(t){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config)}}const Cg=/[,()"\\]/,Eg=t=>Cg.test(t)||t!==t.trim(),Tg=t=>`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,wc=t=>{const e=t===null?"null":String(t);return Eg(e)?Tg(e):e},Ag=t=>t===null?"null":String(t),jg=(t,e)=>{if(t==="in"){const r=Array.isArray(e)?e:[e];if(r.length===0)throw new Error("Realtime `in` filter requires at least one value.");return`in.(${Array.from(new Set(r)).map(n=>wc(n)).join(",")})`}return t==="is"?`is.${Ag(e)}`:`${t}.${wc(e)}`};class Og{constructor(){this.filters=[]}add(e,r,s,n=!1){const a=n?"not.":"";return this.filters.push(`${e}=${a}${jg(r,s)}`),this}eq(e,r){return this.add(e,"eq",r)}neq(e,r){return this.add(e,"neq",r)}gt(e,r){return this.add(e,"gt",r)}gte(e,r){return this.add(e,"gte",r)}lt(e,r){return this.add(e,"lt",r)}lte(e,r){return this.add(e,"lte",r)}in(e,r){return this.add(e,"in",r)}like(e,r){return this.add(e,"like",r)}ilike(e,r){return this.add(e,"ilike",r)}match(e,r){return this.add(e,"match",r)}imatch(e,r){return this.add(e,"imatch",r)}is(e,r){return this.add(e,"is",r)}isDistinct(e,r){return this.add(e,"isdistinct",r)}not(e,r,s){return this.add(e,r,s,!0)}build(){return this.filters.join(",")}toString(){return this.build()}}var xc;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(xc||(xc={}));var Hr;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(Hr||(Hr={}));var pr;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(pr||(pr={}));class mr{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,r={config:{}},s){var n,a;if(this.topic=e,this.params=r,this.socket=s,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.channelAdapter=new kg(this.socket.socketAdapter,e,this.params),this.presence=new xg(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=gc(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((a=(n=this.params.config)===null||n===void 0?void 0:n.broadcast)===null||a===void 0)&&a.replay))throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(e,r=this.timeout){var s,n,a;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:i,presence:o,private:l}}=this.params,c=(n=(s=this.bindings.postgres_changes)===null||s===void 0?void 0:s.map(h=>h.filter))!==null&&n!==void 0?n:[],d=!!this.bindings[Hr.PRESENCE]&&this.bindings[Hr.PRESENCE].length>0||((a=this.params.config.presence)===null||a===void 0?void 0:a.enabled)===!0,f={},p={broadcast:i,presence:Object.assign(Object.assign({},o),{enabled:d}),postgres_changes:c,private:l};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(h=>{e?.(pr.CHANNEL_ERROR,_g(h))}),this._onClose(()=>e?.(pr.CLOSED)),this.updateJoinPayload(Object.assign({config:p},f)),this._updateFilterMessage(),this.channelAdapter.subscribe(r).receive("ok",async({postgres_changes:h})=>{if(this.socket._isManualToken()||this.socket.setAuth(),h===void 0){e?.(pr.SUBSCRIBED);return}this._updatePostgresBindings(h,e)}).receive("error",h=>{this.state=jr.errored;const g=Object.values(h).join(", ")||"error";e?.(pr.CHANNEL_ERROR,new Error(g,{cause:h}))}).receive("timeout",()=>{e?.(pr.TIMED_OUT)})}return this}_updatePostgresBindings(e,r){var s;const n=this.bindings.postgres_changes,a=(s=n?.length)!==null&&s!==void 0?s:0,i=[];for(let o=0;o<a;o++){const l=n[o],{filter:{event:c,schema:d,table:f,filter:p}}=l,h=e&&e[o];if(h&&h.event===c&&mr.isFilterValueEqual(h.schema,d)&&mr.isFilterValueEqual(h.table,f)&&mr.isFilterValueEqual(h.filter,p))i.push(Object.assign(Object.assign({},l),{id:h.id}));else{this.unsubscribe(),this.state=jr.errored,r?.(pr.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=i,this.state!=jr.errored&&r&&r(pr.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,s){const n=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),a=e===Hr.PRESENCE||e===Hr.POSTGRES_CHANGES;if(n&&a)throw this.socket.log("channel",`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`),new Error(`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(e,r,s)}async httpSend(e,r,s={}){var n;if(r==null)return Promise.reject(new Error("Payload is required for httpSend()"));const a=r instanceof ArrayBuffer||ArrayBuffer.isView(r),i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":a?"application/octet-stream":"application/json"};this.socket.accessTokenValue&&(i.Authorization=`Bearer ${this.socket.accessTokenValue}`);const o=new URL(this.broadcastEndpointURL);o.pathname+=`/${encodeURIComponent(this.subTopic)}/events/${encodeURIComponent(e)}`,this.private&&o.searchParams.set("private","true");const l={method:"POST",headers:i,body:a?r:JSON.stringify(r)},c=await this._fetchWithTimeout(o.toString(),l,(n=s.timeout)!==null&&n!==void 0?n:this.timeout);if(c.status===202)return{success:!0};if(c.status===404)return Promise.reject(new Error("httpSend() requires Realtime server v2.97.0 or newer; the endpoint returned 404. Update your Supabase CLI to a recent version, or upgrade the Realtime server in your self-hosted setup. See https://github.com/supabase/supabase-js/blob/master/packages/core/realtime-js/migrations/httpsend-server-version.md"));let d=c.statusText;try{const f=await c.json();d=f.error||f.message||d}catch{}return Promise.reject(new Error(d))}async send(e,r={}){var s,n;if(!this.channelAdapter.canPush()&&e.type==="broadcast"){const a="Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.";this.socket.hasLogger()?this.socket.log("channel",a):console.warn(a);const{event:i,payload:o}=e,l={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(l.Authorization=`Bearer ${this.socket.accessTokenValue}`);const c={method:"POST",headers:l,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const d=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(s=r.timeout)!==null&&s!==void 0?s:this.timeout);return await((n=d.body)===null||n===void 0?void 0:n.cancel()),d.ok?"ok":"error"}catch(d){return d instanceof Error&&d.name==="AbortError"?"timed out":"error"}}else return new Promise(a=>{var i,o,l;const c=this.channelAdapter.push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(o=(i=this.params)===null||i===void 0?void 0:i.config)===null||o===void 0?void 0:o.broadcast)===null||l===void 0)&&l.ack)&&a("ok"),c.receive("ok",()=>a("ok")),c.receive("error",()=>a("error")),c.receive("timeout",()=>a("timed out"))})}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(e=this.timeout){return new Promise(r=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>r("ok")).receive("timeout",()=>r("timed out")).receive("error",()=>r("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,r,s){const n=new AbortController,a=setTimeout(()=>n.abort(),s),i=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:n.signal}));return clearTimeout(a),i}_on(e,r,s){var n;const a=e.toLocaleLowerCase(),i=r?.filter;if((i instanceof Og||typeof i=="object"&&i!==null&&typeof i.build=="function")&&(r=Object.assign(Object.assign({},r),{filter:i.build()})),a===Hr.POSTGRES_CHANGES&&((n=this.bindings[a])===null||n===void 0?void 0:n.find(d=>mr.isSamePostgresFilter(d.filter,r))))return this.socket.log("error",`duplicate \`postgres_changes\` binding for ${this.topic} ignored`,r),this;const o=this.channelAdapter.on(e,s),l={type:a,filter:r,callback:s,ref:o};return this.bindings[a]?this.bindings[a].push(l):this.bindings[a]=[l],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,r,s)=>{var n,a,i,o,l,c,d;const f=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(f,s))return!1;const p=(n=this.bindings[f])===null||n===void 0?void 0:n.find(h=>h.ref===e.ref);if(!p)return!0;if(["broadcast","presence","postgres_changes"].includes(f))if("id"in p){const h=p.id,g=(a=p.filter)===null||a===void 0?void 0:a.event;return h&&((i=r.ids)===null||i===void 0?void 0:i.includes(h))&&(g==="*"||g?.toLocaleLowerCase()===((o=r.data)===null||o===void 0?void 0:o.type.toLocaleLowerCase()))}else{const h=(c=(l=p?.filter)===null||l===void 0?void 0:l.event)===null||c===void 0?void 0:c.toLocaleLowerCase();return h==="*"||h===((d=r?.event)===null||d===void 0?void 0:d.toLocaleLowerCase())}else return p.type.toLocaleLowerCase()===f})}_notThisChannelEvent(e,r){const{close:s,error:n,leave:a,join:i}=fc;return r&&[s,n,a,i].includes(e)&&r!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,r,s)=>{if(typeof r=="object"&&"ids"in r){const n=r.data,{schema:a,table:i,commit_timestamp:o,type:l,errors:c}=n;return Object.assign(Object.assign({},{schema:a,table:i,commit_timestamp:o,eventType:l,new:{},old:{},errors:c}),this._getPayloadRecords(n))}return r})}copyBindings(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const r in e.bindings)for(const s of e.bindings[r])this._on(s.type,s.filter,s.callback)}static isFilterValueEqual(e,r){return(e??void 0)===(r??void 0)}static isSamePostgresFilter(e,r){var s,n,a,i;const o=(n=(s=e?.select)===null||s===void 0?void 0:s.join())!==null&&n!==void 0?n:void 0,l=(i=(a=r?.select)===null||a===void 0?void 0:a.join())!==null&&i!==void 0?i:void 0;return e?.event===r?.event&&mr.isFilterValueEqual(e?.schema,r?.schema)&&mr.isFilterValueEqual(e?.table,r?.table)&&mr.isFilterValueEqual(e?.filter,r?.filter)&&o===l}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=pc(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=pc(e.columns,e.old_record)),r}}class Pg{constructor(e,r){this.socket=new vg(e,r)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,r,s,n=1e4){return new Promise(a=>{setTimeout(()=>a("timeout"),n),this.socket.disconnect(()=>{e(),a("ok")},r,s)})}push(e){this.socket.push(e)}log(e,r,s){this.socket.log(e,r,s)}hasLogger(){return this.socket.hasLogger()}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==ui.connecting}isDisconnecting(){return this.socket.connectionState()==ui.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const _c={HEARTBEAT_INTERVAL:25e3},Ng=[1e3,2e3,5e3,1e4],Rg=1e4;function Ig(){const t=new Map;return{get length(){return t.size},clear(){t.clear()},getItem(e){return t.has(e)?t.get(e):null},key(e){var r;return(r=Array.from(t.keys())[e])!==null&&r!==void 0?r:null},removeItem(e){t.delete(e)},setItem(e,r){t.set(e,String(r))}}}function Dg(){try{if(typeof globalThis<"u"&&globalThis.sessionStorage)return globalThis.sessionStorage}catch{}return Ig()}const Lg=`
136
136
  addEventListener("message", (e) => {
137
137
  if (e.data.event === "start") {
138
138
  setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
139
139
  }
140
- });`;class Vg{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,r){var s;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new og,this._manuallySetToken=!1,this._authPromise=null,this._authGeneration=0,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=a=>a?(...i)=>a(...i):(...i)=>fetch(...i),!(!((s=r?.params)===null||s===void 0)&&s.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey;const n=this._initializeOptions(r);this.socketAdapter=new Lg(e,n),this.httpEndpoint=vc(e),this.fetch=this._resolveFetch(r?.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(e){const r=e.message;throw new Error(`WebSocket not available: ${r}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,r){return this._cancelPendingDisconnect(),this.isDisconnecting()?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,r)}getChannels(){return this.channels}async removeChannel(e){const r=await e.unsubscribe();return r==="ok"&&e.teardown(),r}async removeAllChannels(){const e=this.channels.map(async s=>{const n=await s.unsubscribe();return s.teardown(),n}),r=await Promise.all(e);return await this.disconnect(),r}log(e,r,s){this.socketAdapter.log(e,r,s)}hasLogger(){return this.socketAdapter.hasLogger()}connectionState(){return this.socketAdapter.connectionState()||ui.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,r={config:{}}){const s=`realtime:${e}`,n=this.getChannels().find(a=>a.topic===s);if(n)return n;{const a=new mr(`realtime:${e}`,r,this);return this._cancelPendingDisconnect(),this.channels.push(a),a}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){const r=++this._authGeneration,s=this._performAuth(e,r);r===this._authGeneration&&(this._authPromise=s);try{await s}finally{this._authPromise===s&&(this._authPromise=null)}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(r=>r.topic!==e.topic),this.channels.length===0&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),this._disconnectOnEmptyChannelsAfterMs===0){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,this.channels.length===0&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){this._pendingDisconnectTimer!==null&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(e,r){let s,n=!1;if(e)s=e,n=!0;else if(this.accessToken)try{s=await this.accessToken()}catch(a){this.log("error","Error fetching access token from callback",a),s=this.accessTokenValue}else s=this.accessTokenValue;r===this._authGeneration&&(this.accessToken?this._manuallySetToken=!1:n&&(this._manuallySetToken=!0),this.accessTokenValue!=s&&(this.accessTokenValue=s,this.channels.forEach(a=>{const i={access_token:s,version:eg};a.updateJoinPayload(i),a.joinedOnce&&a.channelAdapter.isJoined()&&a.channelAdapter.push(mc.access_token,{access_token:s})})))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(r=>{this.log("error",`Error setting auth in ${e}`,r)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(r=>{this.log("error","error waiting for auth on connect",r)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(r,s)=>{r!=="disconnected"&&(r=="sent"&&this._setAuthSafely(),e&&e(r,s))}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let r;if(e)r=e;else{const s=new Blob([Bg],{type:"application/javascript"});r=URL.createObjectURL(s)}return r}_initializeOptions(e){var r,s,n,a,i,o,l,c,u,p,f,h;this.worker=(r=e?.worker)!==null&&r!==void 0?r:!1,this.accessToken=(s=e?.accessToken)!==null&&s!==void 0?s:null;const y={};y.timeout=(n=e?.timeout)!==null&&n!==void 0?n:sg,y.heartbeatIntervalMs=(a=e?.heartbeatIntervalMs)!==null&&a!==void 0?a:Sc.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=(i=e?.disconnectOnEmptyChannelsAfterMs)!==null&&i!==void 0?i:2*((o=e?.heartbeatIntervalMs)!==null&&o!==void 0?o:Sc.HEARTBEAT_INTERVAL),y.transport=(l=e?.transport)!==null&&l!==void 0?l:Qm.getWebSocketConstructor(),y.params=e?.params,y.logger=e?.logger,y.heartbeatCallback=this._wrapHeartbeatCallback(e?.heartbeatCallback),y.sessionStorage=(c=e?.sessionStorage)!==null&&c!==void 0?c:Ug(),y.reconnectAfterMs=(u=e?.reconnectAfterMs)!==null&&u!==void 0?u:(_=>$g[_-1]||Mg);let g,v;const C=(p=e?.vsn)!==null&&p!==void 0?p:rg;switch(C){case tg:g=(_,S)=>S(JSON.stringify(_)),v=(_,S)=>S(JSON.parse(_));break;case pc:g=this.serializer.encode.bind(this.serializer),v=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${y.vsn}`)}if(y.vsn=C,y.encode=(f=e?.encode)!==null&&f!==void 0?f:g,y.decode=(h=e?.decode)!==null&&h!==void 0?h:v,y.beforeReconnect=this._reconnectAuth.bind(this),(e?.logLevel||e?.log_level)&&(this.logLevel=e.logLevel||e.log_level,y.params=Object.assign(Object.assign({},y.params),{log_level:this.logLevel})),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e?.workerUrl,y.autoSendHeartbeat=!this.worker}return y}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var Ys=class extends Error{constructor(t,e){super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&e.icebergType?.includes("CommitState")===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function Kg(t,e,r){const s=new URL(e,t);if(r)for(const[n,a]of Object.entries(r))a!==void 0&&s.searchParams.set(n,a);return s.toString()}async function zg(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function Hg(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:r,path:s,query:n,body:a,headers:i}){const o=Kg(t.baseUrl,s,n),l=await zg(t.auth),c=await e(o,{method:r,headers:{...a?{"Content-Type":"application/json"}:{},...l,...i},body:a?JSON.stringify(a):void 0}),u=await c.text(),p=(c.headers.get("content-type")||"").includes("application/json"),f=p&&u?JSON.parse(u):u;if(!c.ok){const h=p?f:void 0,y=h?.error;throw new Ys(y?.message??`Request failed with status ${c.status}`,{status:c.status,icebergType:y?.type,icebergCode:y?.code,details:h})}return{status:c.status,headers:c.headers,data:f}}}}function Gn(t){return t.join("")}var Wg=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Gn(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(s=>({namespace:s}))}async createNamespace(t,e){const r={namespace:t.namespace,properties:e?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Gn(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Gn(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Gn(t.namespace)}`}),!0}catch(e){if(e instanceof Ys&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(r){if(r instanceof Ys&&r.status===409)return;throw r}}};function _s(t){return t.join("")}var qg=class{constructor(t,e="",r){this.client=t,this.prefix=e,this.accessDelegation=r}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${_s(t.namespace)}/tables`})).data.identifiers}async createTable(t,e){const r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${_s(t.namespace)}/tables`,body:e,headers:r})).data.metadata}async updateTable(t,e){const r=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${_s(t.namespace)}/tables/${t.name}`,body:e});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(t,e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${_s(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String(e?.purge??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${_s(t.namespace)}/tables/${t.name}`,headers:e})).data.metadata}async tableExists(t){const e={};this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${_s(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(r){if(r instanceof Ys&&r.status===404)return!1;throw r}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(r){if(r instanceof Ys&&r.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw r}}},Gg=class{constructor(t){let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const r=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=Hg({baseUrl:r,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=t.accessDelegation?.join(","),this.namespaceOps=new Wg(this.client,e),this.tableOps=new qg(this.client,e,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,e){return this.namespaceOps.createNamespace(t,e)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,e){return this.tableOps.createTable(t,e)}async updateTable(t,e){return this.tableOps.updateTable(t,e)}async dropTable(t,e){await this.tableOps.dropTable(t,e)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,e){return this.namespaceOps.createNamespaceIfNotExists(t,e)}async createTableIfNotExists(t,e){return this.tableOps.createTableIfNotExists(t,e)}};function Xs(t){"@babel/helpers - typeof";return Xs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xs(t)}function Jg(t,e){if(Xs(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(Xs(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Zg(t){var e=Jg(t,"string");return Xs(e)=="symbol"?e:e+""}function Yg(t,e,r){return(e=Zg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Cc(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function ie(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Cc(Object(r),!0).forEach(function(s){Yg(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Cc(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}var Jn=class extends Error{constructor(t,e="storage",r,s){super(t),this.__isStorageError=!0,this.namespace=e,this.name=e==="vectors"?"StorageVectorsError":"StorageError",this.status=r,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function Zn(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var pi=class extends Jn{constructor(t,e,r,s="storage",n){super(t,s,e,r),this.name=s==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=e,this.statusCode=r,this.code=n}toJSON(){return ie(ie({},super.toJSON()),{},{code:this.code})}},Ec=class extends Jn{constructor(t,e,r="storage"){super(t,r),this.name=r==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=e}};function Yn(t,e,r){const s=ie({},t),n=e.toLowerCase();for(const a of Object.keys(s))a.toLowerCase()===n&&delete s[a];return s[n]=r,s}function Xg(t){const e={};for(const[r,s]of Object.entries(t))e[r.toLowerCase()]=s;return e}const Qg=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),ey=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},mi=t=>{if(Array.isArray(t))return t.map(r=>mi(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,s])=>{const n=r.replace(/([-_][a-z])/gi,a=>a.toUpperCase().replace(/[-_]/g,""));e[n]=mi(s)}),e},ty=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t),Tc=t=>t.split("/").map(encodeURIComponent).join("/"),Ac=t=>{if(typeof t=="object"&&t!==null){const e=t;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error;if(typeof e.error=="object"&&e.error!==null){const r=e.error;if(typeof r.message=="string")return r.message}}return JSON.stringify(t)},ry=async(t,e,r,s)=>{if(t!==null&&typeof t=="object"&&"json"in t&&typeof t.json=="function"){const n=t;let a=parseInt(String(n.status),10);Number.isFinite(a)||(a=500),n.json().then(i=>{const o=i?.statusCode||i?.code||a+"";e(new pi(Ac(i),a,o,s,i?.code))}).catch(()=>{const i=a+"";e(new pi(n.statusText||`HTTP ${a} error`,a,i,s))})}else e(new Ec(Ac(t),t,s))},sy=(t,e,r,s)=>{const n={method:t,headers:e?.headers||{}};if(t==="GET"||t==="HEAD"||!s)return ie(ie({},n),r);if(ey(s)){var a;const i=e?.headers||{};let o;for(const[l,c]of Object.entries(i))l.toLowerCase()==="content-type"&&(o=c);n.headers=Yn(i,"Content-Type",(a=o)!==null&&a!==void 0?a:"application/json"),n.body=JSON.stringify(s)}else n.body=s;return e?.duplex&&(n.duplex=e.duplex),ie(ie({},n),r)};async function Qs(t,e,r,s,n,a,i){return new Promise((o,l)=>{t(r,sy(e,s,n,a)).then(c=>{if(!c.ok)throw c;if(s?.noResolveJson)return c;if(i==="vectors"){const u=c.headers.get("content-type");if(c.headers.get("content-length")==="0"||c.status===204)return{};if(!u||!u.includes("application/json"))return{}}return c.json()}).then(c=>o(c)).catch(c=>ry(c,l,s,i))})}function jc(t="storage"){return{get:async(e,r,s,n)=>Qs(e,"GET",r,s,n,void 0,t),post:async(e,r,s,n,a)=>Qs(e,"POST",r,n,a,s,t),put:async(e,r,s,n,a)=>Qs(e,"PUT",r,n,a,s,t),head:async(e,r,s,n)=>Qs(e,"HEAD",r,ie(ie({},s),{},{noResolveJson:!0}),n,void 0,t),remove:async(e,r,s,n,a)=>Qs(e,"DELETE",r,n,a,s,t)}}const ny=jc("storage"),{get:en,post:Kt,put:gi,head:ay,remove:tn}=ny,St=jc("vectors");var ks=class{constructor(t,e={},r,s="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=Xg(e),this.fetch=Qg(r),this.namespace=s}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=Yn(this.headers,t,e),this}async handleOperation(t){var e=this;try{return{data:await t(),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(Zn(r))return{data:null,error:r};throw r}}};let Oc;Oc=Symbol.toStringTag;var iy=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[Oc]="StreamDownloadBuilder",this.promise=null}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(Zn(e))return{data:null,error:e};throw e}}};let Pc;Pc=Symbol.toStringTag;var oy=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[Pc]="BlobDownloadBuilder",this.promise=null}asStream(){return new iy(this.downloadFn,this.shouldThrowOnError)}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:await(await t.downloadFn()).blob(),error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(Zn(e))return{data:null,error:e};throw e}}};const yi={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Nc={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var ly=class extends ks{constructor(t,e={},r,s){super(t,e,s,"storage"),this.bucketId=r}async uploadOrUpdate(t,e,r,s){var n=this;return n.handleOperation(async()=>{let a;const i=ie(ie({},Nc),s);let o=ie(ie({},n.headers),t==="POST"&&{"x-upsert":String(i.upsert)});const l=i.metadata;if(typeof Blob<"u"&&r instanceof Blob?(a=new FormData,a.append("cacheControl",i.cacheControl),l&&a.append("metadata",n.encodeMetadata(l)),a.append("",r)):typeof FormData<"u"&&r instanceof FormData?(a=r,a.has("cacheControl")||a.append("cacheControl",i.cacheControl),l&&!a.has("metadata")&&a.append("metadata",n.encodeMetadata(l))):(a=r,o["cache-control"]=`max-age=${i.cacheControl}`,o["content-type"]=i.contentType,l&&(o["x-metadata"]=n.toBase64(n.encodeMetadata(l))),(typeof ReadableStream<"u"&&a instanceof ReadableStream||a&&typeof a=="object"&&"pipe"in a&&typeof a.pipe=="function")&&!i.duplex&&(i.duplex="half")),s?.headers)for(const[f,h]of Object.entries(s.headers))o=Yn(o,f,h);const c=n._removeEmptyFolders(e),u=n._getFinalPath(c),p=await(t=="PUT"?gi:Kt)(n.fetch,`${n.url}/object/${u}`,a,ie({headers:o},i?.duplex?{duplex:i.duplex}:{}));return{path:c,id:p.Id,fullPath:p.Key}})}async upload(t,e,r){return this.uploadOrUpdate("POST",t,e,r)}async uploadToSignedUrl(t,e,r,s){var n=this;const a=n._removeEmptyFolders(t),i=n._getFinalPath(a),o=new URL(n.url+`/object/upload/sign/${i}`);return o.searchParams.set("token",e),n.handleOperation(async()=>{let l;const c=ie(ie({},Nc),s);let u=ie(ie({},n.headers),{"x-upsert":String(c.upsert)});const p=c.metadata;if(typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),p&&l.append("metadata",n.encodeMetadata(p)),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.has("cacheControl")||l.append("cacheControl",c.cacheControl),p&&!l.has("metadata")&&l.append("metadata",n.encodeMetadata(p))):(l=r,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType,p&&(u["x-metadata"]=n.toBase64(n.encodeMetadata(p))),(typeof ReadableStream<"u"&&l instanceof ReadableStream||l&&typeof l=="object"&&"pipe"in l&&typeof l.pipe=="function")&&!c.duplex&&(c.duplex="half")),s?.headers)for(const[f,h]of Object.entries(s.headers))u=Yn(u,f,h);return{path:a,fullPath:(await gi(n.fetch,o.toString(),l,ie({headers:u},c?.duplex?{duplex:c.duplex}:{}))).Key}})}async createSignedUploadUrl(t,e){var r=this;return r.handleOperation(async()=>{let s=r._getFinalPath(t);const n=ie({},r.headers);e?.upsert&&(n["x-upsert"]="true");const a=await Kt(r.fetch,`${r.url}/object/upload/sign/${s}`,{},{headers:n}),i=new URL(r.url+a.url),o=i.searchParams.get("token");if(!o)throw new Jn("No token returned by API");return{signedUrl:i.toString(),path:t,token:o}})}async update(t,e,r){return this.uploadOrUpdate("PUT",t,e,r)}async move(t,e,r){var s=this;return s.handleOperation(async()=>await Kt(s.fetch,`${s.url}/object/move`,{bucketId:s.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r?.destinationBucket,sourceVersionId:r?.sourceVersionId},{headers:s.headers}))}async copy(t,e,r){var s=this;return s.handleOperation(async()=>({path:(await Kt(s.fetch,`${s.url}/object/copy`,{bucketId:s.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r?.destinationBucket,sourceVersionId:r?.sourceVersionId},{headers:s.headers})).Key}))}async createSignedUrl(t,e,r){var s=this;return s.handleOperation(async()=>{let n=s._getFinalPath(t);const a=typeof r?.transform=="object"&&r.transform!==null&&Object.keys(r.transform).length>0;let i=await Kt(s.fetch,`${s.url}/object/sign/${n}`,ie({expiresIn:e},a?{transform:r.transform}:{}),{headers:s.headers});const o=new URLSearchParams;r?.download&&o.set("download",r.download===!0?"":r.download),r?.cacheNonce!=null&&o.set("cacheNonce",String(r.cacheNonce));const l=o.toString();return{signedUrl:encodeURI(`${s.url}${i.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(t,e,r){var s=this;return s.handleOperation(async()=>{const n=await Kt(s.fetch,`${s.url}/object/sign/${s.bucketId}`,{expiresIn:e,paths:t},{headers:s.headers}),a=new URLSearchParams;r?.download&&a.set("download",r.download===!0?"":r.download),r?.cacheNonce!=null&&a.set("cacheNonce",String(r.cacheNonce));const i=a.toString();return n.map(o=>ie(ie({},o),{},{signedUrl:o.signedURL?encodeURI(`${s.url}${o.signedURL}${i?`&${i}`:""}`):null}))})}download(t,e,r){const s=typeof e?.transform=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image/authenticated":"object",n=new URLSearchParams;e?.transform&&this.applyTransformOptsToQuery(n,e.transform),e?.cacheNonce!=null&&n.set("cacheNonce",String(e.cacheNonce)),e?.versionId!=null&&n.set("versionId",String(e.versionId));const a=n.toString(),i=this._getFinalPath(t),o=()=>en(this.fetch,`${this.url}/${s}/${i}${a?`?${a}`:""}`,{headers:this.headers,noResolveJson:!0},r);return new oy(o,this.shouldThrowOnError)}async info(t,e){var r=this;const s=r._getFinalPath(t),n=new URLSearchParams;e?.versionId!=null&&n.set("versionId",String(e.versionId));const a=n.toString();return r.handleOperation(async()=>mi(await en(r.fetch,`${r.url}/object/info/${s}${a?`?${a}`:""}`,{headers:r.headers})))}async exists(t){var e=this;const r=e._getFinalPath(t);try{return await ay(e.fetch,`${e.url}/object/${r}`,{headers:e.headers}),{data:!0,error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(Zn(n)){var s;const a=n instanceof pi?n.status:n instanceof Ec?(s=n.originalError)===null||s===void 0?void 0:s.status:void 0;if(a!==void 0&&[400,404].includes(a))return{data:!1,error:n}}throw n}}getPublicUrl(t,e){const r=this._getFinalPath(t),s=new URLSearchParams;e?.download&&s.set("download",e.download===!0?"":e.download),e?.transform&&this.applyTransformOptsToQuery(s,e.transform),e?.cacheNonce!=null&&s.set("cacheNonce",String(e.cacheNonce));const n=s.toString(),a=typeof e?.transform=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${r}`)+(n?`?${n}`:"")}}}async remove(t){var e=this;return e.handleOperation(async()=>await tn(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}))}async purgeCache(t,e,r){var s=this;return s.handleOperation(async()=>{const n=Tc(s._getFinalPath(t)),a=new URLSearchParams;e?.transformations&&a.set("transformations","true");const i=a.toString();return await tn(s.fetch,`${s.url}/cdn/${n}${i?`?${i}`:""}`,{},{headers:s.headers},r)})}async list(t,e,r){var s=this;return s.handleOperation(async()=>{const n=e?.sortBy?ie(ie({},yi.sortBy),e.sortBy):yi.sortBy,a=ie(ie(ie({},yi),e),{},{sortBy:n,prefix:t||""});return await Kt(s.fetch,`${s.url}/object/list/${s.bucketId}`,a,{headers:s.headers},r)})}async listV2(t,e){var r=this;return r.handleOperation(async()=>{const s=ie({},t);return await Kt(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,s,{headers:r.headers},e)})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(t,e){return e.width&&t.set("width",e.width.toString()),e.height&&t.set("height",e.height.toString()),e.resize&&t.set("resize",e.resize),e.format&&t.set("format",e.format),e.quality&&t.set("quality",e.quality.toString()),t}};const rn={"X-Client-Info":"storage-js/2.115.0"};var cy=class extends ks{constructor(t,e={},r,s){const n=new URL(t);s?.useNewHostname&&/supabase\.(co|in|red)$/.test(n.hostname)&&!n.hostname.includes("storage.supabase.")&&(n.hostname=n.hostname.replace("supabase.","storage.supabase."));const a=n.href.replace(/\/$/,""),i=ie(ie({},rn),e);super(a,i,r,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=e.listBucketOptionsToQueryString(t);return await en(e.fetch,`${e.url}/bucket${r}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await en(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var r=this;return r.handleOperation(async()=>await Kt(r.fetch,`${r.url}/bucket`,{id:t,name:t,type:e.type,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes,versioning_status:e.versioningStatus},{headers:r.headers}))}async updateBucket(t,e){var r=this;return r.handleOperation(async()=>await gi(r.fetch,`${r.url}/bucket/${t}`,{id:t,name:t,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes,versioning_status:e.versioningStatus},{headers:r.headers}))}async emptyBucket(t){var e=this;return e.handleOperation(async()=>await Kt(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await tn(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}async purgeBucketCache(t,e,r){var s=this;return s.handleOperation(async()=>{const n=new URLSearchParams;e?.transformations&&n.set("transformations","true");const a=n.toString();return await tn(s.fetch,`${s.url}/cdn/${Tc(t)}${a?`?${a}`:""}`,{},{headers:s.headers},r)})}listBucketOptionsToQueryString(t){const e={};return t&&("limit"in t&&(e.limit=String(t.limit)),"offset"in t&&(e.offset=String(t.offset)),t.search&&(e.search=t.search),t.sortColumn&&(e.sortColumn=t.sortColumn),t.sortOrder&&(e.sortOrder=t.sortOrder)),Object.keys(e).length>0?"?"+new URLSearchParams(e).toString():""}},uy=class extends ks{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=ie(ie({},rn),e);super(s,n,r,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await Kt(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}))}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=new URLSearchParams;t?.limit!==void 0&&r.set("limit",t.limit.toString()),t?.offset!==void 0&&r.set("offset",t.offset.toString()),t?.sortColumn&&r.set("sortColumn",t.sortColumn),t?.sortOrder&&r.set("sortOrder",t.sortOrder),t?.search&&r.set("search",t.search);const s=r.toString(),n=s?`${e.url}/bucket?${s}`:`${e.url}/bucket`;return await en(e.fetch,n,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await tn(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!ty(t))throw new Jn("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const r=new Gg({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),s=this.shouldThrowOnError;return new Proxy(r,{get(n,a){const i=n[a];return typeof i!="function"?i:async(...o)=>{try{return{data:await i.apply(n,o),error:null}}catch(l){if(s)throw l;return{data:null,error:l}}}}})}},dy=class extends ks{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=ie(ie({},rn),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var r=this;return r.handleOperation(async()=>await St.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var r=this;return r.handleOperation(async()=>await St.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers})||{})}},hy=class extends ks{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=ie(ie({},rn),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async putVectors(t){var e=this;if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}))}async listVectors(t){var e=this;if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}))}async deleteVectors(t){var e=this;if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},fy=class extends ks{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=ie(ie({},rn),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},py=class extends fy{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new my(this.url,this.headers,t,this.fetch)}async createBucket(t){var e=()=>super.createBucket,r=this;return e().call(r,t)}async getBucket(t){var e=()=>super.getBucket,r=this;return e().call(r,t)}async listBuckets(t={}){var e=()=>super.listBuckets,r=this;return e().call(r,t)}async deleteBucket(t){var e=()=>super.deleteBucket,r=this;return e().call(r,t)}},my=class extends dy{constructor(t,e,r,s){super(t,e,s),this.vectorBucketName=r}async createIndex(t){var e=()=>super.createIndex,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName}))}async getIndex(t){var e=()=>super.getIndex,r=this;return e().call(r,r.vectorBucketName,t)}async deleteIndex(t){var e=()=>super.deleteIndex,r=this;return e().call(r,r.vectorBucketName,t)}index(t){return new gy(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},gy=class extends hy{constructor(t,e,r,s,n){super(t,e,n),this.vectorBucketName=r,this.indexName=s}async putVectors(t){var e=()=>super.putVectors,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async getVectors(t){var e=()=>super.getVectors,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}},yy=class extends cy{constructor(t,e={},r,s){super(t,e,r,s)}from(t){return new ly(this.url,this.headers,t,this.fetch)}get vectors(){return new py(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new uy(this.url+"/iceberg",this.headers,this.fetch)}};const Rc="2.115.0",gr=30*1e3,sn=3,vi=sn*gr,vy=2*gr,by="http://localhost:9999",wy="supabase.auth.token",xy={"X-Client-Info":`gotrue-js/${Rc}`},bi="X-Supabase-Api-Version",Ic={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},_y=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,qr="sb_flow_id",ky=5,Sy=600*1e3;class nn extends Error{constructor(e,r,s){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=s}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function B(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Cy extends nn{constructor(e,r,s){super(e,r,s),this.name="AuthApiError",this.status=r,this.code=s}}function Dc(t){return B(t)&&t.name==="AuthApiError"}class zt extends nn{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class rr extends nn{constructor(e,r,s,n){super(e,s,n),this.name=r,this.status=s}}class et extends rr{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Xn(t){return B(t)&&t.name==="AuthSessionMissingError"}class Ss extends rr{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Qn extends rr{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class ea extends rr{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}function Ey(t){return B(t)&&t.name==="AuthImplicitGrantRedirectError"}class Lc extends rr{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class Ty extends rr{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class ta extends rr{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function ra(t){return B(t)&&t.name==="AuthRetryableFetchError"}class $c extends rr{constructor(e="Refresh result discarded: session state changed mid-flight (e.g., concurrent signOut)"){super(e,"AuthRefreshDiscardedError",409,void 0)}}function Ay(t){return B(t)&&t.name==="AuthRefreshDiscardedError"}class Mc extends rr{constructor(e,r,s){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=s}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class sa extends rr{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const na="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),Fc=`
141
- \r=`.split(""),jy=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<Fc.length;e+=1)t[Fc[e].charCodeAt(0)]=-2;for(let e=0;e<na.length;e+=1)t[na[e].charCodeAt(0)]=e;return t})();function Uc(t,e,r){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const s=e.queue>>e.queuedBits-6&63;r(na[s]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const s=e.queue>>e.queuedBits-6&63;r(na[s]),e.queuedBits-=6}}function Bc(t,e,r){const s=jy[t];if(s>-1)for(e.queue=e.queue<<6|s,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(s===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Vc(t){const e=[],r=i=>{e.push(String.fromCodePoint(i))},s={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},a=i=>{Ny(i,s,r)};for(let i=0;i<t.length;i+=1)Bc(t.charCodeAt(i),n,a);return e.join("")}function Oy(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function Py(t,e){for(let r=0;r<t.length;r+=1){let s=t.charCodeAt(r);if(s>55295&&s<=56319){const n=(s-55296)*1024&65535;s=(t.charCodeAt(r+1)-56320&65535|n)+65536,r+=1}Oy(s,e)}}function Ny(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let s=1;s<6;s+=1)if((t>>7-s&1)===0){e.utf8seq=s;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function Cs(t){const e=[],r={queue:0,queuedBits:0},s=n=>{e.push(n)};for(let n=0;n<t.length;n+=1)Bc(t.charCodeAt(n),r,s);return new Uint8Array(e)}function Ry(t){const e=[];return Py(t,r=>e.push(r)),new Uint8Array(e)}function Gr(t){const e=[],r={queue:0,queuedBits:0},s=n=>{e.push(n)};return t.forEach(n=>Uc(n,r,s)),Uc(null,r,s),e.join("")}function Iy(t){return Math.round(Date.now()/1e3)+t}function Dy(){return Symbol("auth-callback")}const ot=()=>typeof window<"u"&&typeof document<"u",Jr={tested:!1,writable:!1},Kc=()=>{if(!ot())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Jr.tested)return Jr.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Jr.tested=!0,Jr.writable=!0}catch{Jr.tested=!0,Jr.writable=!1}return Jr.writable};function zc(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((n,a)=>{e[a]=n})}catch{}return r.searchParams.forEach((s,n)=>{e[n]=s}),e}const Hc=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Ly=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",yr=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},ct=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return null}},yt=async(t,e)=>{await t.removeItem(e)};class aa{constructor(){this.promise=new aa.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}aa.promiseConstructor=Promise;function ia(t){const e=t.split(".");if(e.length!==3)throw new sa("Invalid JWT structure");for(let s=0;s<e.length;s++)if(!_y.test(e[s]))throw new sa("JWT not in base64url format");return{header:JSON.parse(Vc(e[0])),payload:JSON.parse(Vc(e[1])),signature:Cs(e[2]),raw:{header:e[0],payload:e[1]}}}async function $y(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function My(t,e){return new Promise((s,n)=>{(async()=>{for(let a=0;a<1/0;a++)try{const i=await t(a);if(!e(a,null,i)){s(i);return}}catch(i){if(!e(a,i)){n(i);return}}})()})}function Wc(t){return("0"+t.toString(16)).substr(-2)}function Fy(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",s=r.length;let n="";for(let a=0;a<56;a++)n+=r.charAt(Math.floor(Math.random()*s));return n}return crypto.getRandomValues(e),Array.from(e,Wc).join("")}async function Uy(t){const r=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",r),n=new Uint8Array(s);return Array.from(n).map(a=>String.fromCharCode(a)).join("")}async function By(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await Uy(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}const Vy=/^[a-zA-Z0-9_-]{8,64}$/;function oa(t){return typeof t=="string"&&Vy.test(t)?t:null}function Ky(){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,Wc).join("")}let t="";for(let e=0;e<32;e++)t+=Math.floor(Math.random()*16).toString(16);return t}const Es=(t,e)=>`${t}-flow-${e}-code-verifier`,an=t=>`${t}-flows-code-verifier`;async function wi(t,e){const r=await ct(t,an(e));return Array.isArray(r)?r.filter(s=>oa(s)!==null):[]}async function zy(t,e,r,s,n){await yr(t,Es(e,r),s);const a=(await wi(t,e)).filter(i=>i!==r);for(a.push(r);a.length>ky;){const i=a.shift();await yt(t,Es(e,i)),n?.(i)}await yr(t,an(e),a),await yr(t,`${e}-code-verifier`,s)}async function Hy(t,e,r){if(r){const n=await ct(t,Es(e,r));return{verifier:typeof n=="string"?n:null,flowId:r}}const s=await ct(t,`${e}-code-verifier`);return{verifier:typeof s=="string"?s:null,flowId:null}}async function Ht(t,e,r){const s=`${e}-code-verifier`;if(!r){await yt(t,s);return}const n=Es(e,r),a=await ct(t,n);await yt(t,n);const i=await wi(t,e),o=i.filter(l=>l!==r);o.length!==i.length&&(o.length>0?await yr(t,an(e),o):await yt(t,an(e))),a!=null&&a===await ct(t,s)&&await yt(t,s)}async function Wy(t,e){const r=await wi(t,e);for(const s of r)await yt(t,Es(e,s));await yt(t,an(e)),await yt(t,`${e}-code-verifier`)}function qy(t,e){const r=t.indexOf("#");let s=r===-1?t:t.slice(0,r);const n=r===-1?"":t.slice(r),a=s.indexOf("?");if(a!==-1){const o=s.slice(0,a),l=s.slice(a+1).split("&").filter(c=>c!==""&&c!==qr&&!c.startsWith(`${qr}=`));s=l.length>0?`${o}?${l.join("&")}`:o}const i=s.includes("?")?"&":"?";return`${s}${i}${qr}=${encodeURIComponent(e)}${n}`}async function Gy(t,e,r=!1,s){const n=Fy();let a=n;r&&(a+="/recovery");const i=Ky();await zy(t,e,i,a,s);const o=await By(n);return[o,n===o?"plain":"s256",i]}const Jy=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Zy(t){const e=t.headers.get(bi);if(!e||!e.match(Jy))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function Yy(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function Xy(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const Qy=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function vr(t){if(!Qy.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Wt(t){if(!t.passkey)throw new Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function xi(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const s=r.toString();if(s==="Symbol(Symbol.toPrimitive)"||s==="Symbol(Symbol.toStringTag)"||s==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function ev(t,e){return new Proxy(t,{get:(r,s,n)=>{if(s==="__isInsecureUserWarningProxy")return!0;if(typeof s=="symbol"){const a=s.toString();if(a==="Symbol(Symbol.toPrimitive)"||a==="Symbol(Symbol.toStringTag)"||a==="Symbol(util.inspect.custom)"||a==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,s,n)}return!e.value&&typeof s=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),e.value=!0),Reflect.get(r,s,n)}})}function qc(t){return JSON.parse(JSON.stringify(t))}const Zr=t=>{if(typeof t=="object"&&t!==null){const e=t;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error}return JSON.stringify(t)},Gc=[500,501,502,503,504,520,521,522,523,524,525,526,527,528,529,530];async function Jc(t){var e;if(!Ly(t))throw new ta(Zr(t),0);let r;try{r=await t.json()}catch(a){throw Gc.includes(t.status)?new ta(t.statusText||`HTTP ${t.status}`,t.status):new zt(Zr(a),a)}if(Gc.includes(t.status))throw new ta(Zr(r),t.status);let s;const n=Zy(t);if(n&&n.getTime()>=Ic["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?s=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(s=r.error_code),s){if(s==="weak_password")throw new Mc(Zr(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(s==="session_not_found")throw new et}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((a,i)=>a&&typeof i=="string",!0))throw new Mc(Zr(r),t.status,r.weak_password.reasons);throw new Cy(Zr(r),t.status||500,s)}const tv=(t,e,r,s)=>{const n={method:t,headers:e?.headers||{}};return t==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),n.body=JSON.stringify(s),Object.assign(Object.assign({},n),r))};async function q(t,e,r,s){var n;const a=Object.assign({},s?.headers);a[bi]||(a[bi]=Ic["2024-01-01"].name),s?.jwt&&(a.Authorization=`Bearer ${s.jwt}`);const i=(n=s?.query)!==null&&n!==void 0?n:{};s?.redirectTo&&(i.redirect_to=s.redirectTo);const o=Object.keys(i).length?"?"+new URLSearchParams(i).toString():"",l=await rv(t,e,r+o,{headers:a,noResolveJson:s?.noResolveJson},{},s?.body);return s?.xform?s?.xform(l):{data:Object.assign({},l),error:null}}async function rv(t,e,r,s,n,a){const i=tv(e,s,n,a);let o;try{o=await t(r,Object.assign({},i))}catch(l){throw new ta(Zr(l),0)}if(o.ok||await Jc(o),s?.noResolveJson)return o;try{return await o.json()}catch(l){await Jc(l)}}function Rt(t){var e;let r=null;av(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=Iy(t.expires_in)));const s=(e=t.user)!==null&&e!==void 0?e:typeof t?.id=="string"?t:null;return{data:{session:r,user:s},error:null}}function Zc(t){const e=Rt(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,s)=>r&&typeof s=="string",!0)&&(e.data.weak_password=t.weak_password),e}function Or(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function sv(t){return{data:t,error:null}}function nv(t){const{action_link:e,email_otp:r,hashed_token:s,redirect_to:n,verification_type:a}=t,i=Kn(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),o={action_link:e,email_otp:r,hashed_token:s,redirect_to:n,verification_type:a},l=Object.assign({},i);return{data:{properties:o,user:l},error:null}}function Yc(t){return t}function av(t){return!!t.access_token&&!!t.refresh_token&&!!t.expires_in}const _i=["global","local","others"];class iv{constructor({url:e="",headers:r={},fetch:s,experimental:n}){this.url=e,this.headers=r,this.fetch=Hc(s),this.experimental=n??{},this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(e,r=_i[0]){if(_i.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${_i.join(", ")}`);try{return await q(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(s){if(B(s))return{data:null,error:s};throw s}}async inviteUserByEmail(e,r={}){try{return await q(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:Or})}catch(s){if(B(s))return{data:{user:null},error:s};throw s}}async generateLink(e){try{const{options:r}=e,s=Kn(e,["options"]),n=Object.assign(Object.assign({},s),r);return"newEmail"in s&&(n.new_email=s?.newEmail,delete n.newEmail),await q(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:n,headers:this.headers,xform:nv,redirectTo:r?.redirectTo})}catch(r){if(B(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await q(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Or})}catch(r){if(B(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,s,n,a,i,o,l;try{const c={nextPage:null,lastPage:0,total:0},u=await q(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=e?.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(a=(n=e?.perPage)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:""},xform:Yc});if(u.error)throw u.error;const p=await u.json(),f=(i=u.headers.get("x-total-count"))!==null&&i!==void 0?i:0,h=(l=(o=u.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return h.length>0&&(h.forEach(y=>{const g=parseInt(y.split(";")[0].split("=")[1].substring(0,1)),v=JSON.parse(y.split(";")[1].split("=")[1]);c[`${v}Page`]=g}),c.total=parseInt(f)),{data:Object.assign(Object.assign({},p),c),error:null}}catch(c){if(B(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){vr(e);try{return await q(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Or})}catch(r){if(B(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){vr(e);try{return await q(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:Or})}catch(s){if(B(s))return{data:{user:null},error:s};throw s}}async deleteUser(e,r=!1){vr(e);try{return await q(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:Or})}catch(s){if(B(s))return{data:{user:null},error:s};throw s}}async _listFactors(e){vr(e.userId);try{const{data:r,error:s}=await q(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:n=>({data:{factors:n},error:null})});return{data:r,error:s}}catch(r){if(B(r))return{data:null,error:r};throw r}}async _deleteFactor(e){vr(e.userId),vr(e.id);try{return{data:await q(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}async _listOAuthClients(e){var r,s,n,a,i,o,l;try{const c={nextPage:null,lastPage:0,total:0},u=await q(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=e?.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(a=(n=e?.perPage)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:""},xform:Yc});if(u.error)throw u.error;const p=await u.json(),f=(i=u.headers.get("x-total-count"))!==null&&i!==void 0?i:0,h=(l=(o=u.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return h.length>0&&(h.forEach(y=>{const g=parseInt(y.split(";")[0].split("=")[1].substring(0,1)),v=JSON.parse(y.split(";")[1].split("=")[1]);c[`${v}Page`]=g}),c.total=parseInt(f)),{data:Object.assign(Object.assign({},p),c),error:null}}catch(c){if(B(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await q(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _getOAuthClient(e){try{return await q(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _updateOAuthClient(e,r){try{return await q(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:r,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(B(s))return{data:null,error:s};throw s}}async _deleteOAuthClient(e){try{return await q(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(e){try{return await q(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _listCustomProviders(e){try{const r={};return e?.type&&(r.type=e.type),await q(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:r,xform:s=>{var n;return{data:{providers:(n=s?.providers)!==null&&n!==void 0?n:[]},error:null}}})}catch(r){if(B(r))return{data:{providers:[]},error:r};throw r}}async _createCustomProvider(e){try{return await q(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _getCustomProvider(e){try{return await q(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _updateCustomProvider(e,r){try{return await q(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:r,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(B(s))return{data:null,error:s};throw s}}async _deleteCustomProvider(e){try{return await q(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}async _adminListPasskeys(e){Wt(this.experimental),vr(e.userId);try{return await q(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _adminDeletePasskey(e){Wt(this.experimental),vr(e.userId),vr(e.passkeyId);try{return await q(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}}function Xc(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}globalThis&&Kc()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug");class ov extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}function lv(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function Qc(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function cv(t){return parseInt(t,16)}function uv(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,s=>s.toString(16).padStart(2,"0")).join("")}function dv(t){var e;const{chainId:r,domain:s,expirationTime:n,issuedAt:a=new Date,nonce:i,notBefore:o,requestId:l,resources:c,scheme:u,uri:p,version:f}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!s)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(i&&i.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${i}`);if(!p)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(f!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${f}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
142
- `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const h=Qc(t.address),y=u?`${u}://${s}`:s,g=t.statement?`${t.statement}
143
- `:"",v=`${y} wants you to sign in with your Ethereum account:
140
+ });`;class $g{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,r){var s;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={},this.ref=0,this.serializer=new rg,this._manuallySetToken=!1,this._authPromise=null,this._authGeneration=0,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=a=>a?(...i)=>a(...i):(...i)=>fetch(...i),!(!((s=r?.params)===null||s===void 0)&&s.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey;const n=this._initializeOptions(r);this.socketAdapter=new Pg(e,n),this.httpEndpoint=gc(e),this.fetch=this._resolveFetch(r?.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(e){const r=e.message;throw new Error(`WebSocket not available: ${r}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,r){return this._cancelPendingDisconnect(),this.isDisconnecting()?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,r)}getChannels(){return this.channels}async removeChannel(e){const r=await e.unsubscribe();return r==="ok"&&e.teardown(),r}async removeAllChannels(){const e=this.channels.map(async s=>{const n=await s.unsubscribe();return s.teardown(),n}),r=await Promise.all(e);return await this.disconnect(),r}log(e,r,s){this.socketAdapter.log(e,r,s)}hasLogger(){return this.socketAdapter.hasLogger()}connectionState(){return this.socketAdapter.connectionState()||ui.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,r={config:{}}){const s=`realtime:${e}`,n=this.getChannels().find(a=>a.topic===s);if(n)return n;{const a=new mr(`realtime:${e}`,r,this);return this._cancelPendingDisconnect(),this.channels.push(a),a}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){const r=++this._authGeneration,s=this._performAuth(e,r);r===this._authGeneration&&(this._authPromise=s);try{await s}finally{this._authPromise===s&&(this._authPromise=null)}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(r=>r.topic!==e.topic),this.channels.length===0&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),this._disconnectOnEmptyChannelsAfterMs===0){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,this.channels.length===0&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){this._pendingDisconnectTimer!==null&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(e,r){let s,n=!1;if(e)s=e,n=!0;else if(this.accessToken)try{s=await this.accessToken()}catch(a){this.log("error","Error fetching access token from callback",a),s=this.accessTokenValue}else s=this.accessTokenValue;r===this._authGeneration&&(this.accessToken?this._manuallySetToken=!1:n&&(this._manuallySetToken=!0),this.accessTokenValue!=s&&(this.accessTokenValue=s,this.channels.forEach(a=>{const i={access_token:s,version:Ym};a.updateJoinPayload(i),a.joinedOnce&&a.channelAdapter.isJoined()&&a.channelAdapter.push(fc.access_token,{access_token:s})})))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(r=>{this.log("error",`Error setting auth in ${e}`,r)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(r=>{this.log("error","error waiting for auth on connect",r)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(r,s)=>{r!=="disconnected"&&(r=="sent"&&this._setAuthSafely(),e&&e(r,s))}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let r;if(e)r=e;else{const s=new Blob([Lg],{type:"application/javascript"});r=URL.createObjectURL(s)}return r}_initializeOptions(e){var r,s,n,a,i,o,l,c,d,f,p,h;this.worker=(r=e?.worker)!==null&&r!==void 0?r:!1,this.accessToken=(s=e?.accessToken)!==null&&s!==void 0?s:null;const g={};g.timeout=(n=e?.timeout)!==null&&n!==void 0?n:eg,g.heartbeatIntervalMs=(a=e?.heartbeatIntervalMs)!==null&&a!==void 0?a:_c.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=(i=e?.disconnectOnEmptyChannelsAfterMs)!==null&&i!==void 0?i:2*((o=e?.heartbeatIntervalMs)!==null&&o!==void 0?o:_c.HEARTBEAT_INTERVAL),g.transport=(l=e?.transport)!==null&&l!==void 0?l:Zm.getWebSocketConstructor(),g.params=e?.params,g.logger=e?.logger,g.heartbeatCallback=this._wrapHeartbeatCallback(e?.heartbeatCallback),g.sessionStorage=(c=e?.sessionStorage)!==null&&c!==void 0?c:Dg(),g.reconnectAfterMs=(d=e?.reconnectAfterMs)!==null&&d!==void 0?d:(_=>Ng[_-1]||Rg);let y,v;const C=(f=e?.vsn)!==null&&f!==void 0?f:Qm;switch(C){case Xm:y=(_,S)=>S(JSON.stringify(_)),v=(_,S)=>S(JSON.parse(_));break;case hc:y=this.serializer.encode.bind(this.serializer),v=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${g.vsn}`)}if(g.vsn=C,g.encode=(p=e?.encode)!==null&&p!==void 0?p:y,g.decode=(h=e?.decode)!==null&&h!==void 0?h:v,g.beforeReconnect=this._reconnectAuth.bind(this),(e?.logLevel||e?.log_level)&&(this.logLevel=e.logLevel||e.log_level,g.params=Object.assign(Object.assign({},g.params),{log_level:this.logLevel})),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e?.workerUrl,g.autoSendHeartbeat=!this.worker}return g}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var Zs=class extends Error{constructor(t,e){super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&e.icebergType?.includes("CommitState")===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function Mg(t,e,r){const s=new URL(e,t);if(r)for(const[n,a]of Object.entries(r))a!==void 0&&s.searchParams.set(n,a);return s.toString()}async function Fg(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function Ug(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:r,path:s,query:n,body:a,headers:i}){const o=Mg(t.baseUrl,s,n),l=await Fg(t.auth),c=await e(o,{method:r,headers:{...a?{"Content-Type":"application/json"}:{},...l,...i},body:a?JSON.stringify(a):void 0}),d=await c.text(),f=(c.headers.get("content-type")||"").includes("application/json"),p=f&&d?JSON.parse(d):d;if(!c.ok){const h=f?p:void 0,g=h?.error;throw new Zs(g?.message??`Request failed with status ${c.status}`,{status:c.status,icebergType:g?.type,icebergCode:g?.code,details:h})}return{status:c.status,headers:c.headers,data:p}}}}function qn(t){return t.join("")}var Bg=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:qn(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(s=>({namespace:s}))}async createNamespace(t,e){const r={namespace:t.namespace,properties:e?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${qn(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${qn(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${qn(t.namespace)}`}),!0}catch(e){if(e instanceof Zs&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(r){if(r instanceof Zs&&r.status===409)return;throw r}}};function xs(t){return t.join("")}var Vg=class{constructor(t,e="",r){this.client=t,this.prefix=e,this.accessDelegation=r}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${xs(t.namespace)}/tables`})).data.identifiers}async createTable(t,e){const r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${xs(t.namespace)}/tables`,body:e,headers:r})).data.metadata}async updateTable(t,e){const r=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${xs(t.namespace)}/tables/${t.name}`,body:e});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(t,e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${xs(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String(e?.purge??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${xs(t.namespace)}/tables/${t.name}`,headers:e})).data.metadata}async tableExists(t){const e={};this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${xs(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(r){if(r instanceof Zs&&r.status===404)return!1;throw r}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(r){if(r instanceof Zs&&r.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw r}}},Kg=class{constructor(t){let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const r=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=Ug({baseUrl:r,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=t.accessDelegation?.join(","),this.namespaceOps=new Bg(this.client,e),this.tableOps=new Vg(this.client,e,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,e){return this.namespaceOps.createNamespace(t,e)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,e){return this.tableOps.createTable(t,e)}async updateTable(t,e){return this.tableOps.updateTable(t,e)}async dropTable(t,e){await this.tableOps.dropTable(t,e)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,e){return this.namespaceOps.createNamespaceIfNotExists(t,e)}async createTableIfNotExists(t,e){return this.tableOps.createTableIfNotExists(t,e)}};function Ys(t){"@babel/helpers - typeof";return Ys=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ys(t)}function zg(t,e){if(Ys(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(Ys(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Hg(t){var e=zg(t,"string");return Ys(e)=="symbol"?e:e+""}function Wg(t,e,r){return(e=Hg(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function kc(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function ie(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?kc(Object(r),!0).forEach(function(s){Wg(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):kc(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}var Gn=class extends Error{constructor(t,e="storage",r,s){super(t),this.__isStorageError=!0,this.namespace=e,this.name=e==="vectors"?"StorageVectorsError":"StorageError",this.status=r,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function Jn(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var pi=class extends Gn{constructor(t,e,r,s="storage",n){super(t,s,e,r),this.name=s==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=e,this.statusCode=r,this.code=n}toJSON(){return ie(ie({},super.toJSON()),{},{code:this.code})}},Sc=class extends Gn{constructor(t,e,r="storage"){super(t,r),this.name=r==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=e}};function Zn(t,e,r){const s=ie({},t),n=e.toLowerCase();for(const a of Object.keys(s))a.toLowerCase()===n&&delete s[a];return s[n]=r,s}function qg(t){const e={};for(const[r,s]of Object.entries(t))e[r.toLowerCase()]=s;return e}const Gg=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Jg=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},mi=t=>{if(Array.isArray(t))return t.map(r=>mi(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,s])=>{const n=r.replace(/([-_][a-z])/gi,a=>a.toUpperCase().replace(/[-_]/g,""));e[n]=mi(s)}),e},Zg=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t),Cc=t=>t.split("/").map(encodeURIComponent).join("/"),Ec=t=>{if(typeof t=="object"&&t!==null){const e=t;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error;if(typeof e.error=="object"&&e.error!==null){const r=e.error;if(typeof r.message=="string")return r.message}}return JSON.stringify(t)},Yg=async(t,e,r,s)=>{if(t!==null&&typeof t=="object"&&"json"in t&&typeof t.json=="function"){const n=t;let a=parseInt(String(n.status),10);Number.isFinite(a)||(a=500),n.json().then(i=>{const o=i?.statusCode||i?.code||a+"";e(new pi(Ec(i),a,o,s,i?.code))}).catch(()=>{const i=a+"";e(new pi(n.statusText||`HTTP ${a} error`,a,i,s))})}else e(new Sc(Ec(t),t,s))},Xg=(t,e,r,s)=>{const n={method:t,headers:e?.headers||{}};if(t==="GET"||t==="HEAD"||!s)return ie(ie({},n),r);if(Jg(s)){var a;const i=e?.headers||{};let o;for(const[l,c]of Object.entries(i))l.toLowerCase()==="content-type"&&(o=c);n.headers=Zn(i,"Content-Type",(a=o)!==null&&a!==void 0?a:"application/json"),n.body=JSON.stringify(s)}else n.body=s;return e?.duplex&&(n.duplex=e.duplex),ie(ie({},n),r)};async function Xs(t,e,r,s,n,a,i){return new Promise((o,l)=>{t(r,Xg(e,s,n,a)).then(c=>{if(!c.ok)throw c;if(s?.noResolveJson)return c;if(i==="vectors"){const d=c.headers.get("content-type");if(c.headers.get("content-length")==="0"||c.status===204)return{};if(!d||!d.includes("application/json"))return{}}return c.json()}).then(c=>o(c)).catch(c=>Yg(c,l,s,i))})}function Tc(t="storage"){return{get:async(e,r,s,n)=>Xs(e,"GET",r,s,n,void 0,t),post:async(e,r,s,n,a)=>Xs(e,"POST",r,n,a,s,t),put:async(e,r,s,n,a)=>Xs(e,"PUT",r,n,a,s,t),head:async(e,r,s,n)=>Xs(e,"HEAD",r,ie(ie({},s),{},{noResolveJson:!0}),n,void 0,t),remove:async(e,r,s,n,a)=>Xs(e,"DELETE",r,n,a,s,t)}}const Qg=Tc("storage"),{get:Qs,post:Kt,put:gi,head:ey,remove:en}=Qg,St=Tc("vectors");var _s=class{constructor(t,e={},r,s="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=qg(e),this.fetch=Gg(r),this.namespace=s}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=Zn(this.headers,t,e),this}async handleOperation(t){var e=this;try{return{data:await t(),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(Jn(r))return{data:null,error:r};throw r}}};let Ac;Ac=Symbol.toStringTag;var ty=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[Ac]="StreamDownloadBuilder",this.promise=null}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(Jn(e))return{data:null,error:e};throw e}}};let jc;jc=Symbol.toStringTag;var ry=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[jc]="BlobDownloadBuilder",this.promise=null}asStream(){return new ty(this.downloadFn,this.shouldThrowOnError)}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:await(await t.downloadFn()).blob(),error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(Jn(e))return{data:null,error:e};throw e}}};const yi={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Oc={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var sy=class extends _s{constructor(t,e={},r,s){super(t,e,s,"storage"),this.bucketId=r}async uploadOrUpdate(t,e,r,s){var n=this;return n.handleOperation(async()=>{let a;const i=ie(ie({},Oc),s);let o=ie(ie({},n.headers),t==="POST"&&{"x-upsert":String(i.upsert)});const l=i.metadata;if(typeof Blob<"u"&&r instanceof Blob?(a=new FormData,a.append("cacheControl",i.cacheControl),l&&a.append("metadata",n.encodeMetadata(l)),a.append("",r)):typeof FormData<"u"&&r instanceof FormData?(a=r,a.has("cacheControl")||a.append("cacheControl",i.cacheControl),l&&!a.has("metadata")&&a.append("metadata",n.encodeMetadata(l))):(a=r,o["cache-control"]=`max-age=${i.cacheControl}`,o["content-type"]=i.contentType,l&&(o["x-metadata"]=n.toBase64(n.encodeMetadata(l))),(typeof ReadableStream<"u"&&a instanceof ReadableStream||a&&typeof a=="object"&&"pipe"in a&&typeof a.pipe=="function")&&!i.duplex&&(i.duplex="half")),s?.headers)for(const[p,h]of Object.entries(s.headers))o=Zn(o,p,h);const c=n._removeEmptyFolders(e),d=n._getFinalPath(c),f=await(t=="PUT"?gi:Kt)(n.fetch,`${n.url}/object/${d}`,a,ie({headers:o},i?.duplex?{duplex:i.duplex}:{}));return{path:c,id:f.Id,fullPath:f.Key}})}async upload(t,e,r){return this.uploadOrUpdate("POST",t,e,r)}async uploadToSignedUrl(t,e,r,s){var n=this;const a=n._removeEmptyFolders(t),i=n._getFinalPath(a),o=new URL(n.url+`/object/upload/sign/${i}`);return o.searchParams.set("token",e),n.handleOperation(async()=>{let l;const c=ie(ie({},Oc),s);let d=ie(ie({},n.headers),{"x-upsert":String(c.upsert)});const f=c.metadata;if(typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),f&&l.append("metadata",n.encodeMetadata(f)),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.has("cacheControl")||l.append("cacheControl",c.cacheControl),f&&!l.has("metadata")&&l.append("metadata",n.encodeMetadata(f))):(l=r,d["cache-control"]=`max-age=${c.cacheControl}`,d["content-type"]=c.contentType,f&&(d["x-metadata"]=n.toBase64(n.encodeMetadata(f))),(typeof ReadableStream<"u"&&l instanceof ReadableStream||l&&typeof l=="object"&&"pipe"in l&&typeof l.pipe=="function")&&!c.duplex&&(c.duplex="half")),s?.headers)for(const[p,h]of Object.entries(s.headers))d=Zn(d,p,h);return{path:a,fullPath:(await gi(n.fetch,o.toString(),l,ie({headers:d},c?.duplex?{duplex:c.duplex}:{}))).Key}})}async createSignedUploadUrl(t,e){var r=this;return r.handleOperation(async()=>{let s=r._getFinalPath(t);const n=ie({},r.headers);e?.upsert&&(n["x-upsert"]="true");const a=await Kt(r.fetch,`${r.url}/object/upload/sign/${s}`,{},{headers:n}),i=new URL(r.url+a.url),o=i.searchParams.get("token");if(!o)throw new Gn("No token returned by API");return{signedUrl:i.toString(),path:t,token:o}})}async update(t,e,r){return this.uploadOrUpdate("PUT",t,e,r)}async move(t,e,r){var s=this;return s.handleOperation(async()=>await Kt(s.fetch,`${s.url}/object/move`,{bucketId:s.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r?.destinationBucket},{headers:s.headers}))}async copy(t,e,r){var s=this;return s.handleOperation(async()=>({path:(await Kt(s.fetch,`${s.url}/object/copy`,{bucketId:s.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r?.destinationBucket},{headers:s.headers})).Key}))}async createSignedUrl(t,e,r){var s=this;return s.handleOperation(async()=>{let n=s._getFinalPath(t);const a=typeof r?.transform=="object"&&r.transform!==null&&Object.keys(r.transform).length>0;let i=await Kt(s.fetch,`${s.url}/object/sign/${n}`,ie({expiresIn:e},a?{transform:r.transform}:{}),{headers:s.headers});const o=new URLSearchParams;r?.download&&o.set("download",r.download===!0?"":r.download),r?.cacheNonce!=null&&o.set("cacheNonce",String(r.cacheNonce));const l=o.toString();return{signedUrl:encodeURI(`${s.url}${i.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(t,e,r){var s=this;return s.handleOperation(async()=>{const n=await Kt(s.fetch,`${s.url}/object/sign/${s.bucketId}`,{expiresIn:e,paths:t},{headers:s.headers}),a=new URLSearchParams;r?.download&&a.set("download",r.download===!0?"":r.download),r?.cacheNonce!=null&&a.set("cacheNonce",String(r.cacheNonce));const i=a.toString();return n.map(o=>ie(ie({},o),{},{signedUrl:o.signedURL?encodeURI(`${s.url}${o.signedURL}${i?`&${i}`:""}`):null}))})}download(t,e,r){const s=typeof e?.transform=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image/authenticated":"object",n=new URLSearchParams;e?.transform&&this.applyTransformOptsToQuery(n,e.transform),e?.cacheNonce!=null&&n.set("cacheNonce",String(e.cacheNonce));const a=n.toString(),i=this._getFinalPath(t),o=()=>Qs(this.fetch,`${this.url}/${s}/${i}${a?`?${a}`:""}`,{headers:this.headers,noResolveJson:!0},r);return new ry(o,this.shouldThrowOnError)}async info(t){var e=this;const r=e._getFinalPath(t);return e.handleOperation(async()=>mi(await Qs(e.fetch,`${e.url}/object/info/${r}`,{headers:e.headers})))}async exists(t){var e=this;const r=e._getFinalPath(t);try{return await ey(e.fetch,`${e.url}/object/${r}`,{headers:e.headers}),{data:!0,error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(Jn(n)){var s;const a=n instanceof pi?n.status:n instanceof Sc?(s=n.originalError)===null||s===void 0?void 0:s.status:void 0;if(a!==void 0&&[400,404].includes(a))return{data:!1,error:n}}throw n}}getPublicUrl(t,e){const r=this._getFinalPath(t),s=new URLSearchParams;e?.download&&s.set("download",e.download===!0?"":e.download),e?.transform&&this.applyTransformOptsToQuery(s,e.transform),e?.cacheNonce!=null&&s.set("cacheNonce",String(e.cacheNonce));const n=s.toString(),a=typeof e?.transform=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${r}`)+(n?`?${n}`:"")}}}async remove(t){var e=this;return e.handleOperation(async()=>await en(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}))}async purgeCache(t,e,r){var s=this;return s.handleOperation(async()=>{const n=Cc(s._getFinalPath(t)),a=new URLSearchParams;e?.transformations&&a.set("transformations","true");const i=a.toString();return await en(s.fetch,`${s.url}/cdn/${n}${i?`?${i}`:""}`,{},{headers:s.headers},r)})}async list(t,e,r){var s=this;return s.handleOperation(async()=>{const n=e?.sortBy?ie(ie({},yi.sortBy),e.sortBy):yi.sortBy,a=ie(ie(ie({},yi),e),{},{sortBy:n,prefix:t||""});return await Kt(s.fetch,`${s.url}/object/list/${s.bucketId}`,a,{headers:s.headers},r)})}async listV2(t,e){var r=this;return r.handleOperation(async()=>{const s=ie({},t);return await Kt(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,s,{headers:r.headers},e)})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(t,e){return e.width&&t.set("width",e.width.toString()),e.height&&t.set("height",e.height.toString()),e.resize&&t.set("resize",e.resize),e.format&&t.set("format",e.format),e.quality&&t.set("quality",e.quality.toString()),t}};const tn={"X-Client-Info":"storage-js/2.112.4"};var ny=class extends _s{constructor(t,e={},r,s){const n=new URL(t);s?.useNewHostname&&/supabase\.(co|in|red)$/.test(n.hostname)&&!n.hostname.includes("storage.supabase.")&&(n.hostname=n.hostname.replace("supabase.","storage.supabase."));const a=n.href.replace(/\/$/,""),i=ie(ie({},tn),e);super(a,i,r,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=e.listBucketOptionsToQueryString(t);return await Qs(e.fetch,`${e.url}/bucket${r}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await Qs(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var r=this;return r.handleOperation(async()=>await Kt(r.fetch,`${r.url}/bucket`,{id:t,name:t,type:e.type,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:r.headers}))}async updateBucket(t,e){var r=this;return r.handleOperation(async()=>await gi(r.fetch,`${r.url}/bucket/${t}`,{id:t,name:t,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:r.headers}))}async emptyBucket(t){var e=this;return e.handleOperation(async()=>await Kt(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await en(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}async purgeBucketCache(t,e,r){var s=this;return s.handleOperation(async()=>{const n=new URLSearchParams;e?.transformations&&n.set("transformations","true");const a=n.toString();return await en(s.fetch,`${s.url}/cdn/${Cc(t)}${a?`?${a}`:""}`,{},{headers:s.headers},r)})}listBucketOptionsToQueryString(t){const e={};return t&&("limit"in t&&(e.limit=String(t.limit)),"offset"in t&&(e.offset=String(t.offset)),t.search&&(e.search=t.search),t.sortColumn&&(e.sortColumn=t.sortColumn),t.sortOrder&&(e.sortOrder=t.sortOrder)),Object.keys(e).length>0?"?"+new URLSearchParams(e).toString():""}},ay=class extends _s{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=ie(ie({},tn),e);super(s,n,r,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await Kt(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}))}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=new URLSearchParams;t?.limit!==void 0&&r.set("limit",t.limit.toString()),t?.offset!==void 0&&r.set("offset",t.offset.toString()),t?.sortColumn&&r.set("sortColumn",t.sortColumn),t?.sortOrder&&r.set("sortOrder",t.sortOrder),t?.search&&r.set("search",t.search);const s=r.toString(),n=s?`${e.url}/bucket?${s}`:`${e.url}/bucket`;return await Qs(e.fetch,n,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await en(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!Zg(t))throw new Gn("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const r=new Kg({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),s=this.shouldThrowOnError;return new Proxy(r,{get(n,a){const i=n[a];return typeof i!="function"?i:async(...o)=>{try{return{data:await i.apply(n,o),error:null}}catch(l){if(s)throw l;return{data:null,error:l}}}}})}},iy=class extends _s{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=ie(ie({},tn),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var r=this;return r.handleOperation(async()=>await St.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var r=this;return r.handleOperation(async()=>await St.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers})||{})}},oy=class extends _s{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=ie(ie({},tn),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async putVectors(t){var e=this;if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}))}async listVectors(t){var e=this;if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}))}async deleteVectors(t){var e=this;if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},ly=class extends _s{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=ie(ie({},tn),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await St.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},cy=class extends ly{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new uy(this.url,this.headers,t,this.fetch)}async createBucket(t){var e=()=>super.createBucket,r=this;return e().call(r,t)}async getBucket(t){var e=()=>super.getBucket,r=this;return e().call(r,t)}async listBuckets(t={}){var e=()=>super.listBuckets,r=this;return e().call(r,t)}async deleteBucket(t){var e=()=>super.deleteBucket,r=this;return e().call(r,t)}},uy=class extends iy{constructor(t,e,r,s){super(t,e,s),this.vectorBucketName=r}async createIndex(t){var e=()=>super.createIndex,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName}))}async getIndex(t){var e=()=>super.getIndex,r=this;return e().call(r,r.vectorBucketName,t)}async deleteIndex(t){var e=()=>super.deleteIndex,r=this;return e().call(r,r.vectorBucketName,t)}index(t){return new dy(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},dy=class extends oy{constructor(t,e,r,s,n){super(t,e,n),this.vectorBucketName=r,this.indexName=s}async putVectors(t){var e=()=>super.putVectors,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async getVectors(t){var e=()=>super.getVectors,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,r=this;return e().call(r,ie(ie({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}},hy=class extends ny{constructor(t,e={},r,s){super(t,e,r,s)}from(t){return new sy(this.url,this.headers,t,this.fetch)}get vectors(){return new cy(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new ay(this.url+"/iceberg",this.headers,this.fetch)}};const Pc="2.112.4",gr=30*1e3,rn=3,vi=rn*gr,fy=2*gr,py="http://localhost:9999",my="supabase.auth.token",gy={"X-Client-Info":`gotrue-js/${Pc}`},bi="X-Supabase-Api-Version",Nc={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},yy=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Wr="sb_flow_id",vy=5,by=600*1e3;class sn extends Error{constructor(e,r,s){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=s}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function B(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class wy extends sn{constructor(e,r,s){super(e,r,s),this.name="AuthApiError",this.status=r,this.code=s}}function Rc(t){return B(t)&&t.name==="AuthApiError"}class zt extends sn{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class rr extends sn{constructor(e,r,s,n){super(e,s,n),this.name=r,this.status=s}}class et extends rr{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Yn(t){return B(t)&&t.name==="AuthSessionMissingError"}class ks extends rr{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Xn extends rr{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Qn extends rr{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}function xy(t){return B(t)&&t.name==="AuthImplicitGrantRedirectError"}class Ic extends rr{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class _y extends rr{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class ea extends rr{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function ta(t){return B(t)&&t.name==="AuthRetryableFetchError"}class Dc extends rr{constructor(e="Refresh result discarded: session state changed mid-flight (e.g., concurrent signOut)"){super(e,"AuthRefreshDiscardedError",409,void 0)}}function ky(t){return B(t)&&t.name==="AuthRefreshDiscardedError"}class Lc extends rr{constructor(e,r,s){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=s}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class ra extends rr{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const sa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),$c=`
141
+ \r=`.split(""),Sy=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<$c.length;e+=1)t[$c[e].charCodeAt(0)]=-2;for(let e=0;e<sa.length;e+=1)t[sa[e].charCodeAt(0)]=e;return t})();function Mc(t,e,r){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const s=e.queue>>e.queuedBits-6&63;r(sa[s]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const s=e.queue>>e.queuedBits-6&63;r(sa[s]),e.queuedBits-=6}}function Fc(t,e,r){const s=Sy[t];if(s>-1)for(e.queue=e.queue<<6|s,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(s===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Uc(t){const e=[],r=i=>{e.push(String.fromCodePoint(i))},s={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},a=i=>{Ty(i,s,r)};for(let i=0;i<t.length;i+=1)Fc(t.charCodeAt(i),n,a);return e.join("")}function Cy(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function Ey(t,e){for(let r=0;r<t.length;r+=1){let s=t.charCodeAt(r);if(s>55295&&s<=56319){const n=(s-55296)*1024&65535;s=(t.charCodeAt(r+1)-56320&65535|n)+65536,r+=1}Cy(s,e)}}function Ty(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let s=1;s<6;s+=1)if((t>>7-s&1)===0){e.utf8seq=s;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function Ss(t){const e=[],r={queue:0,queuedBits:0},s=n=>{e.push(n)};for(let n=0;n<t.length;n+=1)Fc(t.charCodeAt(n),r,s);return new Uint8Array(e)}function Ay(t){const e=[];return Ey(t,r=>e.push(r)),new Uint8Array(e)}function qr(t){const e=[],r={queue:0,queuedBits:0},s=n=>{e.push(n)};return t.forEach(n=>Mc(n,r,s)),Mc(null,r,s),e.join("")}function jy(t){return Math.round(Date.now()/1e3)+t}function Oy(){return Symbol("auth-callback")}const ot=()=>typeof window<"u"&&typeof document<"u",Gr={tested:!1,writable:!1},Bc=()=>{if(!ot())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Gr.tested)return Gr.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Gr.tested=!0,Gr.writable=!0}catch{Gr.tested=!0,Gr.writable=!1}return Gr.writable};function Vc(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((n,a)=>{e[a]=n})}catch{}return r.searchParams.forEach((s,n)=>{e[n]=s}),e}const Kc=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Py=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",yr=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},ct=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return null}},yt=async(t,e)=>{await t.removeItem(e)};class na{constructor(){this.promise=new na.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}na.promiseConstructor=Promise;function aa(t){const e=t.split(".");if(e.length!==3)throw new ra("Invalid JWT structure");for(let s=0;s<e.length;s++)if(!yy.test(e[s]))throw new ra("JWT not in base64url format");return{header:JSON.parse(Uc(e[0])),payload:JSON.parse(Uc(e[1])),signature:Ss(e[2]),raw:{header:e[0],payload:e[1]}}}async function Ny(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function Ry(t,e){return new Promise((s,n)=>{(async()=>{for(let a=0;a<1/0;a++)try{const i=await t(a);if(!e(a,null,i)){s(i);return}}catch(i){if(!e(a,i)){n(i);return}}})()})}function zc(t){return("0"+t.toString(16)).substr(-2)}function Iy(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",s=r.length;let n="";for(let a=0;a<56;a++)n+=r.charAt(Math.floor(Math.random()*s));return n}return crypto.getRandomValues(e),Array.from(e,zc).join("")}async function Dy(t){const r=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",r),n=new Uint8Array(s);return Array.from(n).map(a=>String.fromCharCode(a)).join("")}async function Ly(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await Dy(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}const $y=/^[a-zA-Z0-9_-]{8,64}$/;function ia(t){return typeof t=="string"&&$y.test(t)?t:null}function My(){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,zc).join("")}let t="";for(let e=0;e<32;e++)t+=Math.floor(Math.random()*16).toString(16);return t}const Cs=(t,e)=>`${t}-flow-${e}-code-verifier`,nn=t=>`${t}-flows-code-verifier`;async function wi(t,e){const r=await ct(t,nn(e));return Array.isArray(r)?r.filter(s=>ia(s)!==null):[]}async function Fy(t,e,r,s,n){await yr(t,Cs(e,r),s);const a=(await wi(t,e)).filter(i=>i!==r);for(a.push(r);a.length>vy;){const i=a.shift();await yt(t,Cs(e,i)),n?.(i)}await yr(t,nn(e),a),await yr(t,`${e}-code-verifier`,s)}async function Uy(t,e,r){if(r){const n=await ct(t,Cs(e,r));return{verifier:typeof n=="string"?n:null,flowId:r}}const s=await ct(t,`${e}-code-verifier`);return{verifier:typeof s=="string"?s:null,flowId:null}}async function Ht(t,e,r){const s=`${e}-code-verifier`;if(!r){await yt(t,s);return}const n=Cs(e,r),a=await ct(t,n);await yt(t,n);const i=await wi(t,e),o=i.filter(l=>l!==r);o.length!==i.length&&(o.length>0?await yr(t,nn(e),o):await yt(t,nn(e))),a!=null&&a===await ct(t,s)&&await yt(t,s)}async function By(t,e){const r=await wi(t,e);for(const s of r)await yt(t,Cs(e,s));await yt(t,nn(e)),await yt(t,`${e}-code-verifier`)}function Vy(t,e){const r=t.indexOf("#");let s=r===-1?t:t.slice(0,r);const n=r===-1?"":t.slice(r),a=s.indexOf("?");if(a!==-1){const o=s.slice(0,a),l=s.slice(a+1).split("&").filter(c=>c!==""&&c!==Wr&&!c.startsWith(`${Wr}=`));s=l.length>0?`${o}?${l.join("&")}`:o}const i=s.includes("?")?"&":"?";return`${s}${i}${Wr}=${encodeURIComponent(e)}${n}`}async function Ky(t,e,r=!1,s){const n=Iy();let a=n;r&&(a+="/recovery");const i=My();await Fy(t,e,i,a,s);const o=await Ly(n);return[o,n===o?"plain":"s256",i]}const zy=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Hy(t){const e=t.headers.get(bi);if(!e||!e.match(zy))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function Wy(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function qy(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const Gy=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function vr(t){if(!Gy.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Wt(t){if(!t.passkey)throw new Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function xi(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const s=r.toString();if(s==="Symbol(Symbol.toPrimitive)"||s==="Symbol(Symbol.toStringTag)"||s==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function Jy(t,e){return new Proxy(t,{get:(r,s,n)=>{if(s==="__isInsecureUserWarningProxy")return!0;if(typeof s=="symbol"){const a=s.toString();if(a==="Symbol(Symbol.toPrimitive)"||a==="Symbol(Symbol.toStringTag)"||a==="Symbol(util.inspect.custom)"||a==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,s,n)}return!e.value&&typeof s=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),e.value=!0),Reflect.get(r,s,n)}})}function Hc(t){return JSON.parse(JSON.stringify(t))}const Jr=t=>{if(typeof t=="object"&&t!==null){const e=t;if(typeof e.msg=="string")return e.msg;if(typeof e.message=="string")return e.message;if(typeof e.error_description=="string")return e.error_description;if(typeof e.error=="string")return e.error}return JSON.stringify(t)},Wc=[500,501,502,503,504,520,521,522,523,524,525,526,527,528,529,530];async function qc(t){var e;if(!Py(t))throw new ea(Jr(t),0);let r;try{r=await t.json()}catch(a){throw Wc.includes(t.status)?new ea(t.statusText||`HTTP ${t.status}`,t.status):new zt(Jr(a),a)}if(Wc.includes(t.status))throw new ea(Jr(r),t.status);let s;const n=Hy(t);if(n&&n.getTime()>=Nc["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?s=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(s=r.error_code),s){if(s==="weak_password")throw new Lc(Jr(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(s==="session_not_found")throw new et}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((a,i)=>a&&typeof i=="string",!0))throw new Lc(Jr(r),t.status,r.weak_password.reasons);throw new wy(Jr(r),t.status||500,s)}const Zy=(t,e,r,s)=>{const n={method:t,headers:e?.headers||{}};return t==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),n.body=JSON.stringify(s),Object.assign(Object.assign({},n),r))};async function q(t,e,r,s){var n;const a=Object.assign({},s?.headers);a[bi]||(a[bi]=Nc["2024-01-01"].name),s?.jwt&&(a.Authorization=`Bearer ${s.jwt}`);const i=(n=s?.query)!==null&&n!==void 0?n:{};s?.redirectTo&&(i.redirect_to=s.redirectTo);const o=Object.keys(i).length?"?"+new URLSearchParams(i).toString():"",l=await Yy(t,e,r+o,{headers:a,noResolveJson:s?.noResolveJson},{},s?.body);return s?.xform?s?.xform(l):{data:Object.assign({},l),error:null}}async function Yy(t,e,r,s,n,a){const i=Zy(e,s,n,a);let o;try{o=await t(r,Object.assign({},i))}catch(l){throw new ea(Jr(l),0)}if(o.ok||await qc(o),s?.noResolveJson)return o;try{return await o.json()}catch(l){await qc(l)}}function Rt(t){var e;let r=null;ev(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=jy(t.expires_in)));const s=(e=t.user)!==null&&e!==void 0?e:typeof t?.id=="string"?t:null;return{data:{session:r,user:s},error:null}}function Gc(t){const e=Rt(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,s)=>r&&typeof s=="string",!0)&&(e.data.weak_password=t.weak_password),e}function Or(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function Xy(t){return{data:t,error:null}}function Qy(t){const{action_link:e,email_otp:r,hashed_token:s,redirect_to:n,verification_type:a}=t,i=Vn(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),o={action_link:e,email_otp:r,hashed_token:s,redirect_to:n,verification_type:a},l=Object.assign({},i);return{data:{properties:o,user:l},error:null}}function Jc(t){return t}function ev(t){return!!t.access_token&&!!t.refresh_token&&!!t.expires_in}const _i=["global","local","others"];class tv{constructor({url:e="",headers:r={},fetch:s,experimental:n}){this.url=e,this.headers=r,this.fetch=Kc(s),this.experimental=n??{},this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(e,r=_i[0]){if(_i.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${_i.join(", ")}`);try{return await q(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(s){if(B(s))return{data:null,error:s};throw s}}async inviteUserByEmail(e,r={}){try{return await q(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:Or})}catch(s){if(B(s))return{data:{user:null},error:s};throw s}}async generateLink(e){try{const{options:r}=e,s=Vn(e,["options"]),n=Object.assign(Object.assign({},s),r);return"newEmail"in s&&(n.new_email=s?.newEmail,delete n.newEmail),await q(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:n,headers:this.headers,xform:Qy,redirectTo:r?.redirectTo})}catch(r){if(B(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await q(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Or})}catch(r){if(B(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,s,n,a,i,o,l;try{const c={nextPage:null,lastPage:0,total:0},d=await q(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=e?.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(a=(n=e?.perPage)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:""},xform:Jc});if(d.error)throw d.error;const f=await d.json(),p=(i=d.headers.get("x-total-count"))!==null&&i!==void 0?i:0,h=(l=(o=d.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return h.length>0&&(h.forEach(g=>{const y=parseInt(g.split(";")[0].split("=")[1].substring(0,1)),v=JSON.parse(g.split(";")[1].split("=")[1]);c[`${v}Page`]=y}),c.total=parseInt(p)),{data:Object.assign(Object.assign({},f),c),error:null}}catch(c){if(B(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){vr(e);try{return await q(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Or})}catch(r){if(B(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){vr(e);try{return await q(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:Or})}catch(s){if(B(s))return{data:{user:null},error:s};throw s}}async deleteUser(e,r=!1){vr(e);try{return await q(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:Or})}catch(s){if(B(s))return{data:{user:null},error:s};throw s}}async _listFactors(e){vr(e.userId);try{const{data:r,error:s}=await q(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:n=>({data:{factors:n},error:null})});return{data:r,error:s}}catch(r){if(B(r))return{data:null,error:r};throw r}}async _deleteFactor(e){vr(e.userId),vr(e.id);try{return{data:await q(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}async _listOAuthClients(e){var r,s,n,a,i,o,l;try{const c={nextPage:null,lastPage:0,total:0},d=await q(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=e?.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(a=(n=e?.perPage)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:""},xform:Jc});if(d.error)throw d.error;const f=await d.json(),p=(i=d.headers.get("x-total-count"))!==null&&i!==void 0?i:0,h=(l=(o=d.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&l!==void 0?l:[];return h.length>0&&(h.forEach(g=>{const y=parseInt(g.split(";")[0].split("=")[1].substring(0,1)),v=JSON.parse(g.split(";")[1].split("=")[1]);c[`${v}Page`]=y}),c.total=parseInt(p)),{data:Object.assign(Object.assign({},f),c),error:null}}catch(c){if(B(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await q(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _getOAuthClient(e){try{return await q(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _updateOAuthClient(e,r){try{return await q(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:r,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(B(s))return{data:null,error:s};throw s}}async _deleteOAuthClient(e){try{return await q(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(e){try{return await q(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _listCustomProviders(e){try{const r={};return e?.type&&(r.type=e.type),await q(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:r,xform:s=>{var n;return{data:{providers:(n=s?.providers)!==null&&n!==void 0?n:[]},error:null}}})}catch(r){if(B(r))return{data:{providers:[]},error:r};throw r}}async _createCustomProvider(e){try{return await q(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _getCustomProvider(e){try{return await q(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _updateCustomProvider(e,r){try{return await q(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:r,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(B(s))return{data:null,error:s};throw s}}async _deleteCustomProvider(e){try{return await q(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}async _adminListPasskeys(e){Wt(this.experimental),vr(e.userId);try{return await q(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(B(r))return{data:null,error:r};throw r}}async _adminDeletePasskey(e){Wt(this.experimental),vr(e.userId),vr(e.passkeyId);try{return await q(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(B(r))return{data:null,error:r};throw r}}}function Zc(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}globalThis&&Bc()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug");class rv extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}function sv(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function Yc(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function nv(t){return parseInt(t,16)}function av(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,s=>s.toString(16).padStart(2,"0")).join("")}function iv(t){var e;const{chainId:r,domain:s,expirationTime:n,issuedAt:a=new Date,nonce:i,notBefore:o,requestId:l,resources:c,scheme:d,uri:f,version:p}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!s)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(i&&i.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${i}`);if(!f)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(p!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${p}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(`
142
+ `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const h=Yc(t.address),g=d?`${d}://${s}`:s,y=t.statement?`${t.statement}
143
+ `:"",v=`${g} wants you to sign in with your Ethereum account:
144
144
  ${h}
145
145
 
146
- ${g}`;let C=`URI: ${p}
147
- Version: ${f}
146
+ ${y}`;let C=`URI: ${f}
147
+ Version: ${p}
148
148
  Chain ID: ${r}${i?`
149
149
  Nonce: ${i}`:""}
150
150
  Issued At: ${a.toISOString()}`;if(n&&(C+=`
@@ -153,8 +153,8 @@ Not Before: ${o.toISOString()}`),l&&(C+=`
153
153
  Request ID: ${l}`),c){let _=`
154
154
  Resources:`;for(const S of c){if(!S||typeof S!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${S}`);_+=`
155
155
  - ${S}`}C+=_}return`${v}
156
- ${C}`}class He extends Error{constructor({message:e,code:r,cause:s,name:n}){var a;super(e,{cause:s}),this.__isWebAuthnError=!0,this.name=(a=n??(s instanceof Error?s.name:void 0))!==null&&a!==void 0?a:"Unknown Error",this.code=r}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class la extends He{constructor(e,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:e}),this.name="WebAuthnUnknownError",this.originalError=r}}function hv({error:t,options:e}){var r,s,n;const{publicKey:a}=e;if(!a)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new He({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=a.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new He({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((s=a.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new He({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((n=a.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new He({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new He({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new He({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return a.pubKeyCredParams.filter(o=>o.type==="public-key").length===0?new He({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new He({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const i=window.location.hostname;if(nu(i)){if(a.rp.id!==i)return new He({message:`The RP ID "${a.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new He({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(a.user.id.byteLength<1||a.user.id.byteLength>64)return new He({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new He({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new He({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function fv({error:t,options:e}){const{publicKey:r}=e;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new He({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new He({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const s=window.location.hostname;if(nu(s)){if(r.rpId!==s)return new He({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new He({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new He({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new He({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class pv{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const ki=new pv;function eu(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:r,excludeCredentials:s}=t,n=Kn(t,["challenge","user","excludeCredentials"]),a=Cs(e).buffer,i=Object.assign(Object.assign({},r),{id:Cs(r.id).buffer}),o=Object.assign(Object.assign({},n),{challenge:a,user:i});if(s&&s.length>0){o.excludeCredentials=new Array(s.length);for(let l=0;l<s.length;l++){const c=s[l];o.excludeCredentials[l]=Object.assign(Object.assign({},c),{id:Cs(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return o}function tu(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:r}=t,s=Kn(t,["challenge","allowCredentials"]),n=Cs(e).buffer,a=Object.assign(Object.assign({},s),{challenge:n});if(r&&r.length>0){a.allowCredentials=new Array(r.length);for(let i=0;i<r.length;i++){const o=r[i];a.allowCredentials[i]=Object.assign(Object.assign({},o),{id:Cs(o.id).buffer,type:o.type||"public-key",transports:o.transports})}}return a}function ru(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t;return{id:t.id,rawId:t.id,response:{attestationObject:Gr(new Uint8Array(t.response.attestationObject)),clientDataJSON:Gr(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function su(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t,s=t.getClientExtensionResults(),n=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:Gr(new Uint8Array(n.authenticatorData)),clientDataJSON:Gr(new Uint8Array(n.clientDataJSON)),signature:Gr(new Uint8Array(n.signature)),userHandle:n.userHandle?Gr(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:s,authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function nu(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function ca(){var t,e;return!!(ot()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator?.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator?.credentials)===null||e===void 0?void 0:e.get)=="function")}async function au(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new la("Browser returned unexpected credential type",e)}:{data:null,error:new la("Empty credential response",e)}}catch(e){return{data:null,error:hv({error:e,options:t})}}}async function iu(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new la("Browser returned unexpected credential type",e)}:{data:null,error:new la("Empty credential response",e)}}catch(e){return{data:null,error:fv({error:e,options:t})}}}const mv={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},gv={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function ua(...t){const e=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),r=n=>n instanceof ArrayBuffer||ArrayBuffer.isView(n),s={};for(const n of t)if(n)for(const a in n){const i=n[a];if(i!==void 0)if(Array.isArray(i))s[a]=i;else if(r(i))s[a]=i;else if(e(i)){const o=s[a];e(o)?s[a]=ua(o,i):s[a]=ua(i)}else s[a]=i}return s}function yv(t,e){return ua(mv,t,e||{})}function vv(t,e){return ua(gv,t,e||{})}class bv{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:r,friendlyName:s,signal:n},a){var i;try{const{data:o,error:l}=await this.client.mfa.challenge({factorId:e,webauthn:r});if(!o)return{data:null,error:l};const c=n??ki.createNewAbortSignal();if(o.webauthn.type==="create"){const{user:u}=o.webauthn.credential_options.publicKey;if(!u.name){const p=s;if(p)u.name=`${u.id}:${p}`;else{const h=(await this.client.getUser()).data.user,y=((i=h?.user_metadata)===null||i===void 0?void 0:i.name)||h?.email||h?.id||"User";u.name=`${u.id}:${y}`}}u.displayName||(u.displayName=u.name)}switch(o.webauthn.type){case"create":{const u=yv(o.webauthn.credential_options.publicKey,a?.create),{data:p,error:f}=await au({publicKey:u,signal:c});return p?{data:{factorId:e,challengeId:o.id,webauthn:{type:o.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}case"request":{const u=vv(o.webauthn.credential_options.publicKey,a?.request),{data:p,error:f}=await iu(Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:u,signal:c}));return p?{data:{factorId:e,challengeId:o.id,webauthn:{type:o.webauthn.type,credential_response:p}},error:null}:{data:null,error:f}}}}catch(o){return B(o)?{data:null,error:o}:{data:null,error:new zt("Unexpected error in challenge",o)}}}async _verify({challengeId:e,factorId:r,webauthn:s}){return this.client.mfa.verify({factorId:r,challengeId:e,webauthn:s})}async _authenticate({factorId:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},a){if(!r)return{data:null,error:new nn("rpId is required for WebAuthn authentication")};try{if(!ca())return{data:null,error:new zt("Browser does not support WebAuthn",null)};const{data:i,error:o}=await this.challenge({factorId:e,webauthn:{rpId:r,rpOrigins:s},signal:n},{request:a});if(!i)return{data:null,error:o};const{webauthn:l}=i;return this._verify({factorId:e,challengeId:i.challengeId,webauthn:{type:l.type,rpId:r,rpOrigins:s,credential_response:l.credential_response}})}catch(i){return B(i)?{data:null,error:i}:{data:null,error:new zt("Unexpected error in authenticate",i)}}}async _register({friendlyName:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},a){if(!r)return{data:null,error:new nn("rpId is required for WebAuthn registration")};try{if(!ca())return{data:null,error:new zt("Browser does not support WebAuthn",null)};const{data:i,error:o}=await this._enroll({friendlyName:e});if(!i)return await this.client.mfa.listFactors().then(u=>{var p;return(p=u.data)===null||p===void 0?void 0:p.all.find(f=>f.factor_type==="webauthn"&&f.friendly_name===e&&f.status==="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId:u?.id}):void 0),{data:null,error:o};const{data:l,error:c}=await this._challenge({factorId:i.id,friendlyName:i.friendly_name,webauthn:{rpId:r,rpOrigins:s},signal:n},{create:a});return l?this._verify({factorId:i.id,challengeId:l.challengeId,webauthn:{rpId:r,rpOrigins:s,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(i){return B(i)?{data:null,error:i}:{data:null,error:new zt("Unexpected error in register",i)}}}}lv();const wv={url:by,storageKey:wy,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:xy,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}},Ts={};let ou=!1;class on{get jwks(){var e,r;return(r=(e=Ts[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){Ts[this.storageKey]=Object.assign(Object.assign({},Ts[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=Ts[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Ts[this.storageKey]=Object.assign(Object.assign({},Ts[this.storageKey]),{cachedAt:e})}constructor(e){var r,s,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.lastRefreshFailure=null,this._sessionRemovalEpoch=0,this.initializePromise=null,this._pendingInitNotifications=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lock=null,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const a=Object.assign(Object.assign({},wv),e);if(this.storageKey=a.storageKey,this.instanceID=(r=on.nextInstanceID[this.storageKey])!==null&&r!==void 0?r:0,on.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.instanceID>0&&ot()){const i=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(i),this.logDebugMessages&&console.trace(i)}if(this.persistSession=a.persistSession,this.autoRefreshToken=a.autoRefreshToken,this.experimental=(s=a.experimental)!==null&&s!==void 0?s:{},this.admin=new iv({url:a.url,headers:a.headers,fetch:a.fetch,experimental:this.experimental}),this.url=a.url,this.headers=a.headers,this.fetch=Hc(a.fetch),this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,this.throwOnError=a.throwOnError,this.lockAcquireTimeout=a.lockAcquireTimeout,a.lock!=null&&(this.lock=a.lock,ou||(ou=!0,console.warn(`${this._logPrefix()} The "lock" option is deprecated and will be removed in v3. The client now coordinates session refreshes without a lock, so most apps can drop the option. See https://github.com/supabase/supabase-js/blob/master/packages/core/auth-js/migrations/lockless-coordination.md`))),this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),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),webauthn:new bv(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(a.storage?this.storage=a.storage:Kc()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Xc(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=Xc(this.memoryStorage)),ot()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),(i.data.event==="TOKEN_REFRESHED"||i.data.event==="SIGNED_IN")&&(this.lastRefreshFailure=null);try{await this._notifyAllSubscribers(i.data.event,i.data.session,!1)}catch(o){this._debug("#broadcastChannel","error",o)}})}a.skipAutoInitialize||this.initialize().catch(i=>{this._debug("#initialize()","error",i)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${Rc}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){var e;if(this.initializePromise)return await this.initializePromise;this._pendingInitNotifications=[],this.initializePromise=(async()=>this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()):await this._initialize())();const r=await this.initializePromise,s=(e=this._pendingInitNotifications)!==null&&e!==void 0?e:[];this._pendingInitNotifications=null;for(const n of s)await this._notifyAllSubscribers(n.event,n.session,n.broadcast);return r}async _initialize(){var e;try{let r={},s="none";if(ot()&&(r=zc(window.location.href),this._isImplicitGrantCallback(r)?s="implicit":await this._isPKCECallback(r)&&(s="pkce")),ot()&&this.detectSessionInUrl&&s!=="none"){const{data:n,error:a}=await this._getSessionFromURL(r,s);if(a){if(this._debug("#_initialize()","error detecting session from URL",a),Ey(a)){const l=(e=a.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:a}}return{error:a}}const{session:i,redirectType:o}=n;return this._debug("#_initialize()","detected session in URL",i,"redirect type",o),await this._saveSession(i),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",i):await this._notifyAllSubscribers("SIGNED_IN",i)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return B(r)?this._returnResult({error:r}):this._returnResult({error:new zt("Unexpected error during initialization",r)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,s,n;try{const a=await q(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(s=(r=e?.options)===null||r===void 0?void 0:r.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:(n=e?.options)===null||n===void 0?void 0:n.captchaToken}},xform:Rt}),{data:i,error:o}=a;if(o||!i)return this._returnResult({data:{user:null,session:null},error:o});const l=i.session,c=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(a){if(B(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async signUp(e){var r,s,n;let a=null;try{let i;if("email"in e){const{email:p,password:f,options:h}=e;let y=null,g=null;this.flowType==="pkce"&&([y,g,a]=await this._getCodeChallengeAndMethod()),i=await q(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(h?.emailRedirectTo,a),body:{email:p,password:f,data:(r=h?.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:h?.captchaToken},code_challenge:y,code_challenge_method:g},xform:Rt})}else if("phone"in e){const{phone:p,password:f,options:h}=e;i=await q(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:f,data:(s=h?.data)!==null&&s!==void 0?s:{},channel:(n=h?.channel)!==null&&n!==void 0?n:"sms",gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:Rt})}else throw new Qn("You must provide either an email or phone number and a password");const{data:o,error:l}=i;if(l||!o)return await Ht(this.storage,this.storageKey,a),this._returnResult({data:{user:null,session:null},error:l});const c=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),this._returnResult({data:{user:u,session:c},error:null})}catch(i){if(await Ht(this.storage,this.storageKey,a),B(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithPassword(e){try{let r;if("email"in e){const{email:a,password:i,options:o}=e;r=await q(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:a,password:i,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:Zc})}else if("phone"in e){const{phone:a,password:i,options:o}=e;r=await q(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:a,password:i,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:Zc})}else throw new Qn("You must provide either an email or phone number and a password");const{data:s,error:n}=r;if(n)return this._returnResult({data:{user:null,session:null},error:n});if(!s||!s.session||!s.user){const a=new Ss;return this._returnResult({data:{user:null,session:null},error:a})}return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),this._returnResult({data:Object.assign({user:s.user,session:s.session},s.weak_password?{weakPassword:s.weak_password}:null),error:n})}catch(r){if(B(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOAuth(e){var r,s,n,a;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(s=e.options)===null||s===void 0?void 0:s.scopes,queryParams:(n=e.options)===null||n===void 0?void 0:n.queryParams,skipBrowserRedirect:(a=e.options)===null||a===void 0?void 0:a.skipBrowserRedirect})}async exchangeCodeForSession(e,r){return await this.initializePromise,this.lock!=null?this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e,r)):this._exchangeCodeForSession(e,r)}async signInWithWeb3(e){const{chain:r}=e;switch(r){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(e){var r,s,n,a,i,o,l,c,u,p,f;let h,y;if("message"in e)h=e.message,y=e.signature;else{const{chain:g,wallet:v,statement:C,options:_}=e;let S;if(ot())if(typeof v=="object")S=v;else{const re=window;if("ethereum"in re&&typeof re.ethereum=="object"&&"request"in re.ethereum&&typeof re.ethereum.request=="function")S=re.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof v!="object"||!_?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");S=v}const E=new URL((r=_?.url)!==null&&r!==void 0?r:window.location.href),T=await S.request({method:"eth_requestAccounts"}).then(re=>re).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!T||T.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const N=Qc(T[0]);let L=(s=_?.signInWithEthereum)===null||s===void 0?void 0:s.chainId;if(!L){const re=await S.request({method:"eth_chainId"});L=cv(re)}const ue={domain:E.host,address:N,statement:C,uri:E.href,version:"1",chainId:L,nonce:(n=_?.signInWithEthereum)===null||n===void 0?void 0:n.nonce,issuedAt:(i=(a=_?.signInWithEthereum)===null||a===void 0?void 0:a.issuedAt)!==null&&i!==void 0?i:new Date,expirationTime:(o=_?.signInWithEthereum)===null||o===void 0?void 0:o.expirationTime,notBefore:(l=_?.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=_?.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=_?.signInWithEthereum)===null||u===void 0?void 0:u.resources};h=dv(ue),y=await S.request({method:"personal_sign",params:[uv(h),N]})}try{const{data:g,error:v}=await q(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:h,signature:y},!((p=e.options)===null||p===void 0)&&p.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:Rt});if(v)throw v;if(!g||!g.session||!g.user){const C=new Ss;return this._returnResult({data:{user:null,session:null},error:C})}return g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("SIGNED_IN",g.session)),this._returnResult({data:Object.assign({},g),error:v})}catch(g){if(B(g))return this._returnResult({data:{user:null,session:null},error:g});throw g}}async signInWithSolana(e){var r,s,n,a,i,o,l,c,u,p,f,h;let y,g;if("message"in e)y=e.message,g=e.signature;else{const{chain:v,wallet:C,statement:_,options:S}=e;let E;if(ot())if(typeof C=="object")E=C;else{const N=window;if("solana"in N&&typeof N.solana=="object"&&("signIn"in N.solana&&typeof N.solana.signIn=="function"||"signMessage"in N.solana&&typeof N.solana.signMessage=="function"))E=N.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof C!="object"||!S?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");E=C}const T=new URL((r=S?.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in E&&E.signIn){const N=await E.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},S?.signInWithSolana),{version:"1",domain:T.host,uri:T.href}),_?{statement:_}:null));let L;if(Array.isArray(N)&&N[0]&&typeof N[0]=="object")L=N[0];else if(N&&typeof N=="object"&&"signedMessage"in N&&"signature"in N)L=N;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in L&&"signature"in L&&(typeof L.signedMessage=="string"||L.signedMessage instanceof Uint8Array)&&L.signature instanceof Uint8Array)y=typeof L.signedMessage=="string"?L.signedMessage:new TextDecoder().decode(L.signedMessage),g=L.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in E)||typeof E.signMessage!="function"||!("publicKey"in E)||typeof E!="object"||!E.publicKey||!("toBase58"in E.publicKey)||typeof E.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");y=[`${T.host} wants you to sign in with your Solana account:`,E.publicKey.toBase58(),..._?["",_,""]:[""],"Version: 1",`URI: ${T.href}`,`Issued At: ${(n=(s=S?.signInWithSolana)===null||s===void 0?void 0:s.issuedAt)!==null&&n!==void 0?n:new Date().toISOString()}`,...!((a=S?.signInWithSolana)===null||a===void 0)&&a.notBefore?[`Not Before: ${S.signInWithSolana.notBefore}`]:[],...!((i=S?.signInWithSolana)===null||i===void 0)&&i.expirationTime?[`Expiration Time: ${S.signInWithSolana.expirationTime}`]:[],...!((o=S?.signInWithSolana)===null||o===void 0)&&o.chainId?[`Chain ID: ${S.signInWithSolana.chainId}`]:[],...!((l=S?.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${S.signInWithSolana.nonce}`]:[],...!((c=S?.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${S.signInWithSolana.requestId}`]:[],...!((p=(u=S?.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||p===void 0)&&p.length?["Resources",...S.signInWithSolana.resources.map(L=>`- ${L}`)]:[]].join(`
157
- `);const N=await E.signMessage(new TextEncoder().encode(y),"utf8");if(!N||!(N instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");g=N}}try{const{data:v,error:C}=await q(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:y,signature:Gr(g)},!((f=e.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(h=e.options)===null||h===void 0?void 0:h.captchaToken}}:null),xform:Rt});if(C)throw C;if(!v||!v.session||!v.user){const _=new Ss;return this._returnResult({data:{user:null,session:null},error:_})}return v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),this._returnResult({data:Object.assign({},v),error:C})}catch(v){if(B(v))return this._returnResult({data:{user:null,session:null},error:v});throw v}}async _exchangeCodeForSession(e,r){const s=r?.flowId!=null,n=s?oa(r?.flowId):ot()?oa(zc(window.location.href)[qr]):null;s&&!n&&this._debug("#_exchangeCodeForSession()","provided flowId is not a valid flow id",r?.flowId);const{verifier:a,flowId:i}=s&&!n?{verifier:null,flowId:null}:await Hy(this.storage,this.storageKey,n),[o,l]=(a??"").split("/");try{if(!o&&this.flowType==="pkce")throw new Ty;const{data:c,error:u}=await q(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:o},xform:Rt});if(await Ht(this.storage,this.storageKey,i),u)throw u;if(!c||!c.session||!c.user){const p=new Ss;return this._returnResult({data:{user:null,session:null,redirectType:null},error:p})}return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers(l==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c.session)),this._returnResult({data:Object.assign(Object.assign({},c),{redirectType:l??null}),error:u})}catch(c){if(await Ht(this.storage,this.storageKey,i),B(c))return this._returnResult({data:{user:null,session:null,redirectType:null},error:c});throw c}}async signInWithIdToken(e){try{const{options:r,provider:s,token:n,access_token:a,nonce:i}=e,o=await q(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:s,id_token:n,access_token:a,nonce:i,gotrue_meta_security:{captcha_token:r?.captchaToken}},xform:Rt}),{data:l,error:c}=o;if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l||!l.session||!l.user){const u=new Ss;return this._returnResult({data:{user:null,session:null},error:u})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),this._returnResult({data:l,error:c})}catch(r){if(B(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOtp(e){var r,s,n,a,i;let o=null;try{if("email"in e){const{email:l,options:c}=e;let u=null,p=null;this.flowType==="pkce"&&([u,p,o]=await this._getCodeChallengeAndMethod());const{error:f}=await q(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:l,data:(r=c?.data)!==null&&r!==void 0?r:{},create_user:(s=c?.shouldCreateUser)!==null&&s!==void 0?s:!0,gotrue_meta_security:{captcha_token:c?.captchaToken},code_challenge:u,code_challenge_method:p},redirectTo:this._maybeAppendFlowIdToRedirect(c?.emailRedirectTo,o)});return this._returnResult({data:{user:null,session:null},error:f})}if("phone"in e){const{phone:l,options:c}=e,{data:u,error:p}=await q(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:l,data:(n=c?.data)!==null&&n!==void 0?n:{},create_user:(a=c?.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:c?.captchaToken},channel:(i=c?.channel)!==null&&i!==void 0?i:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:u?.message_id},error:p})}throw new Qn("You must provide either an email or phone number.")}catch(l){if(await Ht(this.storage,this.storageKey,o),B(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async verifyOtp(e){var r,s;try{let n,a;"options"in e&&(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo,a=(s=e.options)===null||s===void 0?void 0:s.captchaToken);const{data:i,error:o}=await q(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:n,xform:Rt});if(o)throw o;if(!i)throw new Error("An error occurred on token verification.");const l=i.session,c=i.user;return l?.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(n){if(B(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithSSO(e){var r,s,n,a;let i=null;try{let o=null,l=null;this.flowType==="pkce"&&([o,l,i]=await this._getCodeChallengeAndMethod());const c=await q(this.fetch,"POST",`${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:this._maybeAppendFlowIdToRedirect((r=e.options)===null||r===void 0?void 0:r.redirectTo,i)}),!((s=e?.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:l}),headers:this.headers,xform:sv});return!((n=c.data)===null||n===void 0)&&n.url&&ot()&&!(!((a=e.options)===null||a===void 0)&&a.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(o){if(await Ht(this.storage,this.storageKey,i),B(o))return this._returnResult({data:null,error:o});throw o}}async reauthenticate(){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate()):await this._reauthenticate()}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)throw s;if(!r)throw new et;const{error:n}=await q(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return this._returnResult({data:{user:null,session:null},error:n})})}catch(e){if(B(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){let r=null;try{const s=`${this.url}/resend`;if("email"in e){const{email:n,type:a,options:i}=e;let o=null,l=null;this.flowType==="pkce"&&([o,l,r]=await this._getCodeChallengeAndMethod());const{error:c}=await q(this.fetch,"POST",s,{headers:this.headers,body:{email:n,type:a,gotrue_meta_security:{captcha_token:i?.captchaToken},code_challenge:o,code_challenge_method:l},redirectTo:this._maybeAppendFlowIdToRedirect(i?.emailRedirectTo,r)});return c&&await Ht(this.storage,this.storageKey,r),this._returnResult({data:{user:null,session:null},error:c})}else if("phone"in e){const{phone:n,type:a,options:i}=e,{data:o,error:l}=await q(this.fetch,"POST",s,{headers:this.headers,body:{phone:n,type:a,gotrue_meta_security:{captcha_token:i?.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o?.message_id},error:l})}throw new Qn("You must provide either an email or phone number and a type")}catch(s){if(await Ht(this.storage,this.storageKey,r),B(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async getSession(){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async e=>e)):await this._useSession(async e=>e)}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const s=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await s,await r()))();return this.pendingInLock.push((async()=>{try{await n}catch{}})()),n}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const s=r();for(this.pendingInLock.push((async()=>{try{await s}catch{}})()),await s;this.pendingInLock.length;){const n=[...this.pendingInLock];await Promise.all(n),this.pendingInLock.splice(0,n.length)}return await s}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lock!=null&&!this.lockAcquired&&this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await ct(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const s=e.expires_at?e.expires_at*1e3-Date.now()<vi:!1;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",e.expires_at),!s){if(this.userStorage){const i=await ct(this.userStorage,this.storageKey+"-user");i?.user?e.user=i.user:e.user=xi()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const i={value:this.suppressGetSessionWarning};e.user=ev(e.user,i),i.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:n,error:a}=await this._callRefreshToken(e.refresh_token);if(a){if(!!(e.expires_at&&e.expires_at*1e3>Date.now())){const o=await ct(this.storage,this.storageKey);if(o&&o.refresh_token===e.refresh_token)return this._returnResult({data:{session:e},error:null})}return this._returnResult({data:{session:null},error:a})}return this._returnResult({data:{session:n},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;let r;return this.lock!=null?r=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser()):r=await this._getUser(),r.data.user&&(this.suppressGetSessionWarning=!0),r}async _getUser(e){try{return e?await q(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Or}):await this._useSession(async r=>{var s,n,a;const{data:i,error:o}=r;if(o)throw o;return!(!((s=i.session)===null||s===void 0)&&s.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new et}:await q(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(a=(n=i.session)===null||n===void 0?void 0:n.access_token)!==null&&a!==void 0?a:void 0,xform:Or})})}catch(r){if(B(r))return Xn(r)&&await this._removeSession(),this._returnResult({data:{user:null},error:r});throw r}}async updateUser(e,r={}){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,r)):await this._updateUser(e,r)}async _updateUser(e,r={}){let s=null;try{return await this._useSession(async n=>{const{data:a,error:i}=n;if(i)throw i;if(!a.session)throw new et;const o=a.session;let l=null,c=null;this.flowType==="pkce"&&e.email!=null&&([l,c,s]=await this._getCodeChallengeAndMethod());const{data:u,error:p}=await q(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(r?.emailRedirectTo,s),body:Object.assign(Object.assign({},e),{code_challenge:l,code_challenge_method:c}),jwt:o.access_token,xform:Or});if(p)throw p;return o.user=u.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(n){if(await Ht(this.storage,this.storageKey,s),B(n))return this._returnResult({data:{user:null},error:n});throw n}}async setSession(e){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e)):await this._setSession(e)}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new et;const r=Date.now()/1e3;let s=r,n=!0,a=null;const{payload:i}=ia(e.access_token);if(i.exp&&(s=i.exp,n=s<=r),n){const{data:o,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!o)return{data:{user:null,session:null},error:null};a=o}else{const{data:o,error:l}=await this._getUser(e.access_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});a={access_token:e.access_token,refresh_token:e.refresh_token,user:o.user,token_type:"bearer",expires_in:s-r,expires_at:s},await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)}return this._returnResult({data:{user:a.user,session:a},error:null})}catch(r){if(B(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}}async refreshSession(e){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e)):await this._refreshSession(e)}async _refreshSession(e){try{return await this._useSession(async r=>{var s;if(!e){const{data:i,error:o}=r;if(o)throw o;e=(s=i.session)!==null&&s!==void 0?s:void 0}if(!e?.refresh_token)throw new et;const{data:n,error:a}=await this._callRefreshToken(e.refresh_token);return a?this._returnResult({data:{user:null,session:null},error:a}):n?this._returnResult({data:{user:n.user,session:n},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(r){if(B(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async _getSessionFromURL(e,r){var s;try{if(!ot())throw new ea("No browser detected.");if(e.error||e.error_description||e.error_code)throw new ea(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new Lc("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new ea("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Lc("No code detected.");const{data:S,error:E}=await this._exchangeCodeForSession(e.code,{flowId:e[qr]});if(E)throw E;const T=new URL(window.location.href);return T.searchParams.delete("code"),T.searchParams.delete(qr),window.history.replaceState(window.history.state,"",T.toString()),{data:{session:S.session,redirectType:(s=S.redirectType)!==null&&s!==void 0?s:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:i,refresh_token:o,expires_in:l,expires_at:c,token_type:u}=e;if(!i||!l||!o||!u)throw new ea("No session defined in URL");const p=Math.round(Date.now()/1e3),f=parseInt(l);let h=p+f;c&&(h=parseInt(c));const y=h-p;y*1e3<=gr&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${y}s, should have been closer to ${f}s`);const g=h-f;p-g>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",g,h,p):p-g<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",g,h,p);const{data:v,error:C}=await this._getUser(i);if(C)throw C;const _={provider_token:n,provider_refresh_token:a,access_token:i,expires_in:f,expires_at:h,refresh_token:o,token_type:u,user:v.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:_,redirectType:e.type},error:null})}catch(n){if(B(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error||e.error_description||e.error_code)}async _isPKCECallback(e){if(!e.code)return!1;const r=oa(e[qr]);return r&&await ct(this.storage,Es(this.storageKey,r))?!0:!!await ct(this.storage,`${this.storageKey}-code-verifier`)}async signOut(e={scope:"global"}){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e)):await this._signOut(e)}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var s;const n=async()=>{await this._removeSession()},{data:a,error:i}=r;if(i&&!Xn(i))return this._returnResult({error:i});const o=(s=a.session)===null||s===void 0?void 0:s.access_token;if(o){const{error:l}=await this.admin.signOut(o,e);if(l&&!(Dc(l)&&(l.status===404||l.status===401||l.status===403)||Xn(l)))return e!=="others"&&await n(),this._returnResult({error:l})}return e!=="others"&&await n(),this._returnResult({error:null})})}onAuthStateChange(e){const r=Dy(),s={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,s),(async()=>(await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(r)}):await this._emitInitialSession(r)))(),{data:{subscription:s}}}async _emitInitialSession(e){return await this._useSession(async r=>{var s,n;try{const{data:{session:a},error:i}=r;if(i)throw i;await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",a)),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(a){await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",a),Xn(a)||ra(a)||Dc(a)&&(a.code==="refresh_token_not_found"||a.code==="refresh_token_already_used"||a.code==="session_expired")?console.warn(a):console.error(a)}})}async resetPasswordForEmail(e,r={}){let s=null,n=null,a=null;this.flowType==="pkce"&&([s,n,a]=await this._getCodeChallengeAndMethod(!0));try{return await q(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:s,code_challenge_method:n,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(r.redirectTo,a)})}catch(i){if(await Ht(this.storage,this.storageKey,a),B(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:r,error:s}=await this.getUser();if(s)throw s;return this._returnResult({data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var r;let s=null;try{const{data:n,error:a}=await this._useSession(async i=>{var o,l,c,u,p;const{data:f,error:h}=i;if(h)throw h;const{url:y,flowId:g}=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(l=e.options)===null||l===void 0?void 0:l.scopes,queryParams:(c=e.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return s=g,await q(this.fetch,"GET",y,{headers:this.headers,jwt:(p=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return ot()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n?.url),this._returnResult({data:{provider:e.provider,url:n?.url,flowId:s},error:null})}catch(n){if(B(n))return this._returnResult({data:{provider:e.provider,url:null,flowId:s},error:n});throw n}}async linkIdentityIdToken(e){return await this._useSession(async r=>{var s;try{const{error:n,data:{session:a}}=r;if(n)throw n;const{options:i,provider:o,token:l,access_token:c,nonce:u}=e,p=await q(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(s=a?.access_token)!==null&&s!==void 0?s:void 0,body:{provider:o,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:i?.captchaToken}},xform:Rt}),{data:f,error:h}=p;return h?this._returnResult({data:{user:null,session:null},error:h}):!f||!f.session||!f.user?this._returnResult({data:{user:null,session:null},error:new Ss}):(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("USER_UPDATED",f.session)),this._returnResult({data:f,error:h}))}catch(n){if(await Ht(this.storage,this.storageKey,null),B(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}})}async unlinkIdentity(e){try{return await this._useSession(async r=>{var s,n;const{data:a,error:i}=r;if(i)throw i;return await q(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(s=a.session)===null||s===void 0?void 0:s.access_token)!==null&&n!==void 0?n:void 0})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _refreshAccessToken(e){const r="#_refreshAccessToken()";this._debug(r,"begin");try{const s=Date.now();return await My(async n=>(n>0&&await $y(200*Math.pow(2,n-1)),this._debug(r,"refreshing attempt",n),await q(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Rt})),(n,a)=>{const i=200*Math.pow(2,n);return a&&ra(a)&&Date.now()+i-s<gr})}catch(s){if(this._debug(r,"error",s),B(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){const{url:s,flowId:n}=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",s),ot()&&!r.skipBrowserRedirect&&window.location.assign(s),{data:{provider:e,url:s,flowId:n},error:null}}async _recoverAndRefresh(){var e,r;const s="#_recoverAndRefresh()";this._debug(s,"begin");try{const n=await ct(this.storage,this.storageKey);if(n&&this.userStorage){let i=await ct(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!i&&(i={user:n.user},await yr(this.userStorage,this.storageKey+"-user",i)),n.user=(e=i?.user)!==null&&e!==void 0?e:xi()}else if(n&&!n.user&&!n.user){const i=await ct(this.storage,this.storageKey+"-user");i&&i?.user?(n.user=i.user,await yt(this.storage,this.storageKey+"-user"),await yr(this.storage,this.storageKey,n)):n.user=xi()}if(this._debug(s,"session from storage",n),!this._isValidSession(n)){this._debug(s,"session is not valid"),n!==null&&await this._removeSession();return}const a=((r=n.expires_at)!==null&&r!==void 0?r:1/0)*1e3-Date.now()<vi;if(this._debug(s,`session has${a?"":" not"} expired with margin of ${vi}s`),a){if(this.autoRefreshToken&&n.refresh_token){const{error:i}=await this._callRefreshToken(n.refresh_token);i&&(Ay(i)?this._debug(s,"refresh discarded by commit guard",i):this._debug(s,"refresh failed",i))}}else if(n.user&&n.user.__isUserNotAvailableProxy===!0)try{const{data:i,error:o}=await this._getUser(n.access_token);!o&&i?.user?(n.user=i.user,await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)):this._debug(s,"could not get user data, skipping SIGNED_IN notification")}catch(i){console.error("Error getting user data:",i),this._debug(s,"error getting user data, skipping SIGNED_IN notification",i)}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(s,"error",n),ra(n)?console.warn(n):console.error(n);return}finally{this._debug(s,"end")}}async _callRefreshToken(e){var r,s;if(!e)throw new et;if(this.refreshingDeferred)return this.refreshingDeferred.promise;if(this.lastRefreshFailure&&this.lastRefreshFailure.refreshToken===e&&Date.now()<this.lastRefreshFailure.expiresAt)return this._debug("#_callRefreshToken()","returning cached failure (cooldown active)"),this.lastRefreshFailure.result;const n="#_callRefreshToken()";this._debug(n,"begin");try{this.refreshingDeferred=new aa,this.refreshingDeferred.promise.then(void 0,()=>{});const a=await ct(this.storage,this.storageKey),{data:i,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!i.session)throw new et;const l=await ct(this.storage,this.storageKey);if(a!==null&&(l===null||l.refresh_token!==a.refresh_token)){this._debug(n,"commit guard: storage changed since refresh started, discarding rotated tokens",{startedWith:"present",nowHolds:l?"replaced":"cleared"});const f={data:null,error:new $c};return this.refreshingDeferred.resolve(f),f}const u=this._sessionRemovalEpoch;if(await this._saveSession(i.session),this._sessionRemovalEpoch!==u){this._debug(n,"commit guard (post-save): _removeSession ran during _saveSession, undoing write"),await yt(this.storage,this.storageKey),this.userStorage&&await yt(this.userStorage,this.storageKey+"-user");const f={data:null,error:new $c};return this.refreshingDeferred.resolve(f),f}await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const p={data:i.session,error:null};return this.lastRefreshFailure=null,this.refreshingDeferred.resolve(p),p}catch(a){if(this._debug(n,"error",a),B(a)){const i={data:null,error:a};if(!ra(a)){const o=await ct(this.storage,this.storageKey);!!(o?.expires_at&&o.expires_at*1e3>Date.now())?this._debug(n,"proactive refresh failed, access token still valid — preserving session"):await this._removeSession()}return this.lastRefreshFailure={refreshToken:e,result:i,expiresAt:Date.now()+vy},(r=this.refreshingDeferred)===null||r===void 0||r.resolve(i),i}throw(s=this.refreshingDeferred)===null||s===void 0||s.reject(a),a}finally{this.refreshingDeferred=null,this._debug(n,"end")}}async _notifyAllSubscribers(e,r,s=!0){if(this._pendingInitNotifications!==null&&s){this._pendingInitNotifications.push({event:e,session:r,broadcast:s});return}const n=`#_notifyAllSubscribers(${e})`;this._debug(n,"begin",r,`broadcast = ${s}`);try{this.broadcastChannel&&s&&this.broadcastChannel.postMessage({event:e,session:r});const a=[],i=Array.from(this.stateChangeEmitters.values()).map(async o=>{try{await o.callback(e,r)}catch(l){a.push(l)}});if(await Promise.all(i),a.length>0){for(let o=0;o<a.length;o+=1)console.error(a[o]);throw a[0]}}finally{this._debug(n,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;const r=Object.assign({},e),s=r.user&&r.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!s&&r.user&&await yr(this.userStorage,this.storageKey+"-user",{user:r.user});const n=Object.assign({},r);delete n.user;const a=qc(n);await yr(this.storage,this.storageKey,a)}else{const n=qc(r);await yr(this.storage,this.storageKey,n)}}async _removeSession(){this._sessionRemovalEpoch+=1,this._debug("#_removeSession()"),this.lastRefreshFailure=null,this.suppressGetSessionWarning=!1,await yt(this.storage,this.storageKey),await Wy(this.storage,this.storageKey),await yt(this.storage,this.storageKey+"-user"),this.userStorage&&await yt(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&ot()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),gr);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const r=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=r,r&&typeof r=="object"&&typeof r.unref=="function"?r.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(r)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const r=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,r&&clearTimeout(r)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async dispose(){var e;this._removeVisibilityChangedCallback(),await this._stopAutoRefresh(),(e=this.broadcastChannel)===null||e===void 0||e.close(),this.broadcastChannel=null,this.stateChangeEmitters.clear()}async _autoRefreshTokenTick(){if(this._debug("#_autoRefreshTokenTick()","begin"),this.lock!=null){try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:s}}=r;if(!s||!s.refresh_token||!s.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((s.expires_at*1e3-e)/gr);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${gr}ms, refresh threshold is ${sn} ticks`),n<=sn&&await this._callRefreshToken(s.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof ov)this._debug("auto refresh token tick lock not available");else throw e}return}if(this.refreshingDeferred!==null){this._debug("#_autoRefreshTokenTick()","refresh already in flight, skipping");return}try{const e=Date.now();try{await this._useSession(async r=>{const{data:{session:s}}=r;if(!s||!s.refresh_token||!s.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((s.expires_at*1e3-e)/gr);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${gr}ms, refresh threshold is ${sn} ticks`),n<=sn&&await this._callRefreshToken(s.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ot()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;if(this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"){if(this.autoRefreshToken&&this._startAutoRefresh(),!e)if(await this.initializePromise,this.lock!=null)await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()});else{if(document.visibilityState!=="visible"){this._debug(r,"visibilityState is no longer visible, skipping recovery");return}await this._recoverAndRefresh()}}else document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,s){let n=s?.redirectTo,a=null,i=null,o=null;this.flowType==="pkce"&&([a,i,o]=await this._getCodeChallengeAndMethod(),n=this._maybeAppendFlowIdToRedirect(n,o));const l=[`provider=${encodeURIComponent(r)}`];if(n&&l.push(`redirect_to=${encodeURIComponent(n)}`),s?.scopes&&l.push(`scopes=${encodeURIComponent(s.scopes)}`),a!=null&&i!=null){const c=new URLSearchParams({code_challenge:`${encodeURIComponent(a)}`,code_challenge_method:`${encodeURIComponent(i)}`});l.push(c.toString())}if(s?.queryParams){const c=new URLSearchParams(s.queryParams);l.push(c.toString())}return s?.skipBrowserRedirect&&l.push(`skip_http_redirect=${s.skipBrowserRedirect}`),{url:`${e}?${l.join("&")}`,flowId:o}}_maybeAppendFlowIdToRedirect(e,r){return!e||!r||!this.experimental.appendPkceFlowIdToRedirects?e??void 0:qy(e,r)}async _getCodeChallengeAndMethod(e=!1){return Gy(this.storage,this.storageKey,e,r=>this._debug("#_getCodeChallengeAndMethod()","evicted oldest pending PKCE verifier slot",r))}async _unenroll(e){try{return await this._useSession(async r=>{var s;const{data:n,error:a}=r;return a?this._returnResult({data:null,error:a}):await q(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(s=n?.session)===null||s===void 0?void 0:s.access_token})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _enroll(e){try{return await this._useSession(async r=>{var s,n;const{data:a,error:i}=r;if(i)return this._returnResult({data:null,error:i});const o=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:c}=await q(this.fetch,"POST",`${this.url}/factors`,{body:o,headers:this.headers,jwt:(s=a?.session)===null||s===void 0?void 0:s.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&l.type==="totp"&&(!((n=l?.totp)===null||n===void 0)&&n.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),this._returnResult({data:l,error:null}))})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _verify(e){const r=async()=>{try{return await this._useSession(async s=>{var n;const{data:a,error:i}=s;if(i)return this._returnResult({data:null,error:i});const o=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?ru(e.webauthn.credential_response):su(e.webauthn.credential_response)})}:{code:e.code}),{data:l,error:c}=await q(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:(n=a?.session)===null||n===void 0?void 0:n.access_token});return c?this._returnResult({data:null,error:c}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+l.expires_in},l)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",l),this._returnResult({data:l,error:c}))})}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}};return this.lock!=null?this._acquireLock(this.lockAcquireTimeout,r):r()}async _challenge(e){const r=async()=>{try{return await this._useSession(async s=>{var n;const{data:a,error:i}=s;if(i)return this._returnResult({data:null,error:i});const o=await q(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(n=a?.session)===null||n===void 0?void 0:n.access_token});if(o.error)return o;const{data:l}=o;if(l.type!=="webauthn")return{data:l,error:null};switch(l.webauthn.type){case"create":return{data:Object.assign(Object.assign({},l),{webauthn:Object.assign(Object.assign({},l.webauthn),{credential_options:Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:eu(l.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},l),{webauthn:Object.assign(Object.assign({},l.webauthn),{credential_options:Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:tu(l.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}};return this.lock!=null?this._acquireLock(this.lockAcquireTimeout,r):r()}async _challengeAndVerify(e){const{data:r,error:s}=await this._challenge({factorId:e.factorId});return s?this._returnResult({data:null,error:s}):await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){var e;const{data:{user:r},error:s}=await this.getUser();if(s)return{data:null,error:s};const n={all:[],phone:[],totp:[],webauthn:[]};for(const a of(e=r?.factors)!==null&&e!==void 0?e:[])n.all.push(a),a.status==="verified"&&n[a.factor_type].push(a);return{data:n,error:null}}async _getAuthenticatorAssuranceLevel(e){var r,s,n,a;if(e)try{const{payload:h}=ia(e);let y=null;h.aal&&(y=h.aal);let g=y;const{data:{user:v},error:C}=await this.getUser(e);if(C)return this._returnResult({data:null,error:C});((s=(r=v?.factors)===null||r===void 0?void 0:r.filter(E=>E.status==="verified"))!==null&&s!==void 0?s:[]).length>0&&(g="aal2");const S=h.amr||[];return{data:{currentLevel:y,nextLevel:g,currentAuthenticationMethods:S},error:null}}catch(h){if(B(h))return this._returnResult({data:null,error:h});throw h}const{data:{session:i},error:o}=await this.getSession();if(o)return this._returnResult({data:null,error:o});if(!i)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=ia(i.access_token);let c=null;l.aal&&(c=l.aal);let u=c;((a=(n=i.user.factors)===null||n===void 0?void 0:n.filter(h=>h.status==="verified"))!==null&&a!==void 0?a:[]).length>0&&(u="aal2");const f=l.amr||[];return{data:{currentLevel:c,nextLevel:u,currentAuthenticationMethods:f},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;return n?this._returnResult({data:null,error:n}):s?await q(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:s.access_token,xform:a=>({data:a,error:null})}):this._returnResult({data:null,error:new et})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _approveAuthorization(e,r){try{return await this._useSession(async s=>{const{data:{session:n},error:a}=s;if(a)return this._returnResult({data:null,error:a});if(!n)return this._returnResult({data:null,error:new et});const i=await q(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"approve"},xform:o=>({data:o,error:null})});return i.data&&i.data.redirect_url&&ot()&&!r?.skipBrowserRedirect&&window.location.assign(i.data.redirect_url),i})}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}}async _denyAuthorization(e,r){try{return await this._useSession(async s=>{const{data:{session:n},error:a}=s;if(a)return this._returnResult({data:null,error:a});if(!n)return this._returnResult({data:null,error:new et});const i=await q(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"deny"},xform:o=>({data:o,error:null})});return i.data&&i.data.redirect_url&&ot()&&!r?.skipBrowserRedirect&&window.location.assign(i.data.redirect_url),i})}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;return s?this._returnResult({data:null,error:s}):r?await q(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,xform:n=>({data:n,error:null})}):this._returnResult({data:null,error:new et})})}catch(e){if(B(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;return n?this._returnResult({data:null,error:n}):s?(await q(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new et})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(e,r={keys:[]}){let s=r.keys.find(o=>o.kid===e);if(s)return s;const n=Date.now();if(s=this.jwks.keys.find(o=>o.kid===e),s&&this.jwks_cached_at+Sy>n)return s;const{data:a,error:i}=await q(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(i)throw i;return!a.keys||a.keys.length===0||(this.jwks=a,this.jwks_cached_at=n,s=a.keys.find(o=>o.kid===e),!s)?null:s}async getClaims(e,r={}){try{let s=e;if(!s){const{data:h,error:y}=await this.getSession();if(y||!h.session)return this._returnResult({data:null,error:y});s=h.session.access_token}const{header:n,payload:a,signature:i,raw:{header:o,payload:l}}=ia(s);if(!r?.allowExpired)try{Yy(a.exp)}catch(h){throw new sa(h instanceof Error?h.message:"JWT validation failed")}const c=!n.alg||n.alg.startsWith("HS")||!n.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(n.kid,r?.keys?{keys:r.keys}:r?.jwks);if(!c){const{error:h}=await this.getUser(s);if(h)throw h;return{data:{claims:a,header:n,signature:i},error:null}}const u=Xy(n.alg),p=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,p,i,Ry(`${o}.${l}`)))throw new sa("Invalid JWT signature");return{data:{claims:a,header:n,signature:i},error:null}}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}}async signInWithPasskey(e){var r,s,n;Wt(this.experimental);try{if(!ca())return this._returnResult({data:null,error:new zt("Browser does not support WebAuthn",null)});const{data:a,error:i}=await this._startPasskeyAuthentication({options:{captchaToken:(r=e?.options)===null||r===void 0?void 0:r.captchaToken}});if(i||!a)return this._returnResult({data:null,error:i});const o=tu(a.options),l=(n=(s=e?.options)===null||s===void 0?void 0:s.signal)!==null&&n!==void 0?n:ki.createNewAbortSignal(),{data:c,error:u}=await iu({publicKey:o,signal:l});if(u||!c)return this._returnResult({data:null,error:u??new zt("WebAuthn ceremony failed",null)});const p=su(c);return this._verifyPasskeyAuthentication({challengeId:a.challenge_id,credential:p})}catch(a){if(B(a))return this._returnResult({data:null,error:a});throw a}}async registerPasskey(e){var r,s;Wt(this.experimental);try{if(!ca())return this._returnResult({data:null,error:new zt("Browser does not support WebAuthn",null)});const{data:n,error:a}=await this._startPasskeyRegistration();if(a||!n)return this._returnResult({data:null,error:a});const i=eu(n.options),o=(s=(r=e?.options)===null||r===void 0?void 0:r.signal)!==null&&s!==void 0?s:ki.createNewAbortSignal(),{data:l,error:c}=await au({publicKey:i,signal:o});if(c||!l)return this._returnResult({data:null,error:c??new zt("WebAuthn ceremony failed",null)});const u=ru(l);return this._verifyPasskeyRegistration({challengeId:n.challenge_id,credential:u})}catch(n){if(B(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyRegistration(){Wt(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new et});const{data:n,error:a}=await q(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:r.access_token,body:{}});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(B(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){Wt(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new et});const{data:a,error:i}=await q(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:s.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:a,error:null})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _startPasskeyAuthentication(e){var r;Wt(this.experimental);try{const{data:s,error:n}=await q(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(r=e?.options)===null||r===void 0?void 0:r.captchaToken}}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:s,error:null})}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}}async _verifyPasskeyAuthentication(e){Wt(this.experimental);try{const{data:r,error:s}=await q(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:Rt});return s?this._returnResult({data:null,error:s}):(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:r,error:null}))}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _listPasskeys(){Wt(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new et});const{data:n,error:a}=await q(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:r.access_token,xform:i=>({data:i,error:null})});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(B(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){Wt(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new et});const{data:a,error:i}=await q(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:s.access_token,body:{friendly_name:e.friendlyName}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:a,error:null})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _deletePasskey(e){Wt(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new et});const{error:a}=await q(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:s.access_token,noResolveJson:!0});return a?this._returnResult({data:null,error:a}):this._returnResult({data:null,error:null})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}}on.nextInstanceID={};const xv=on,_v="2.115.0";let ln="",da;if(typeof Deno<"u"){var Si;ln="deno",da=(Si=Deno.version)===null||Si===void 0?void 0:Si.deno}else if(typeof document<"u")ln="web";else if(typeof navigator<"u"&&navigator.product==="ReactNative")ln="react-native";else{var Ci;ln="node";const t=globalThis.process;da=t==null||(Ci=t.version)===null||Ci===void 0?void 0:Ci.replace(/^v/,"")}const lu=[`runtime=${ln}`];da&&lu.push(`runtime-version=${da}`);const kv={headers:{"X-Client-Info":`supabase-js/${_v}; ${lu.join("; ")}`}},Sv={schema:"public"},Cv={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Ev={},Tv={enabled:!1,respectSamplingDecision:!0};function Av(t){if(!t||typeof t!="string")return null;const e=t.split("-");if(e.length!==4)return null;const[r,s,n,a]=e;if(r.length!==2||s.length!==32||n.length!==16||a.length!==2)return null;const i=/^[0-9a-f]+$/i;return!i.test(r)||!i.test(s)||!i.test(n)||!i.test(a)||s==="00000000000000000000000000000000"||n==="0000000000000000"?null:{version:r,traceId:s,parentId:n,traceFlags:a,isSampled:(parseInt(a,16)&1)===1}}function jv(t,e){if(!t||!e||e.length===0)return!1;let r;if(t instanceof URL)r=t;else try{r=new URL(t)}catch{return!1}for(const s of e)try{if(typeof s=="string"){if(Ov(r.hostname,s))return!0}else if(s instanceof RegExp){if(s.test(r.hostname))return!0}else if(typeof s=="function"&&s(r))return!0}catch{continue}return!1}function Ov(t,e){if(e===t)return!0;if(e.startsWith("*.")){const r=e.slice(2);if(t.endsWith(r)&&(t===r||t.endsWith("."+r)))return!0}return!1}function Pv(t){const e=[];try{const r=new URL(t);e.push(r.hostname)}catch{}return e.push("*.supabase.co","*.supabase.in"),e.push("localhost","127.0.0.1","[::1]"),e}function cn(t){"@babel/helpers - typeof";return cn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},cn(t)}function Nv(t,e){if(cn(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(cn(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Rv(t){var e=Nv(t,"string");return cn(e)=="symbol"?e:e+""}function Iv(t,e,r){return(e=Rv(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function cu(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function Be(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?cu(Object(r),!0).forEach(function(s){Iv(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):cu(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}const Dv=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Lv=()=>Headers,uu=t=>t.startsWith("sb_publishable_")||t.startsWith("sb_secret_"),$v="sb_temp_",du=new Set,Mv=t=>{var e,r;if(!t.startsWith("sb_")||uu(t)||t.startsWith($v))return;const s=(e=(r=t.match(/^sb_[a-zA-Z0-9]+_/))===null||r===void 0?void 0:r[0])!==null&&e!==void 0?e:"unknown";du.has(s)||(du.add(s),console.warn("@supabase/supabase-js: Unrecognized Supabase API key format. The client will proceed and send this key as-is; if you see authentication errors you may need to upgrade @supabase/supabase-js to a version that recognizes this key type."))},hu=(t,e,r,s,n,a)=>{const i=Dv(s),o=Lv(),l=n?.enabled===!0,c=n?.respectSamplingDecision!==!1,u=l?Pv(e):null,p=!(a?.omitApiKeyAsBearer&&uu(t));return async(f,h)=>{const y=await r();let g=new o(h?.headers);if(g.has("apikey")||g.set("apikey",t),!g.has("Authorization")){const v=y??(p?t:null);v&&g.set("Authorization",`Bearer ${v}`)}if(u){const v=Fv(f,u,c);v&&(v.traceparent&&!g.has("traceparent")&&g.set("traceparent",v.traceparent),v.tracestate&&!g.has("tracestate")&&g.set("tracestate",v.tracestate),v.baggage&&!g.has("baggage")&&g.set("baggage",v.baggage))}return i(f,Be(Be({},h),{},{headers:g}))}};let fu=!1,pu=!1;function Fv(t,e,r){const s=Mm();if(!s)return fu||(fu=!0,console.warn("@supabase/supabase-js: tracePropagation is enabled but the tracing runtime is not loaded, so trace headers will not be attached. Add `import '@supabase/supabase-js/tracing'` at your application entry point (requires the OpenTelemetry API package to be installed). The CDN/UMD build does not support trace propagation.")),null;if(!jv(typeof t=="string"||t instanceof URL?t:t.url,e))return null;const n=s();if(!n||!n.traceparent){var a;if(!(n==null||(a=n.carrierKeys)===null||a===void 0)&&a.length&&!pu){pu=!0;const i=n.carrierKeys.includes("sentry-trace")?" Sentry detected: set `propagateTraceparent: true` in Sentry.init() to emit it.":" Configure your tracing SDK to emit W3C trace context on outgoing requests.";console.warn(`@supabase/supabase-js: tracePropagation is enabled and a tracing SDK is active, but its propagator wrote [${n.carrierKeys.join(", ")}] and no W3C traceparent header, so trace headers will not be attached.`+i)}return null}if(r){const i=Av(n.traceparent);if(i&&!i.isSampled)return{traceparent:n.traceparent}}return n}function mu(t){return typeof t=="boolean"?{enabled:t}:t}function Uv(t){return t.endsWith("/")?t:t+"/"}function Bv(t,e){var r,s,n,a,i,o;const{db:l,auth:c,realtime:u,global:p}=t,{db:f,auth:h,realtime:y,global:g}=e,v=mu(t.tracePropagation),C=mu(e.tracePropagation),_={db:Be(Be({},f),l),auth:Be(Be({},h),c),realtime:Be(Be({},y),u),storage:{},global:Be(Be(Be({},g),p),{},{headers:Be(Be({},(r=g?.headers)!==null&&r!==void 0?r:{}),(s=p?.headers)!==null&&s!==void 0?s:{})}),tracePropagation:{enabled:(n=(a=v?.enabled)!==null&&a!==void 0?a:C?.enabled)!==null&&n!==void 0?n:!1,respectSamplingDecision:(i=(o=v?.respectSamplingDecision)!==null&&o!==void 0?o:C?.respectSamplingDecision)!==null&&i!==void 0?i:!0},accessToken:async()=>""};return t.accessToken?_.accessToken=t.accessToken:delete _.accessToken,_}function Vv(t){const e=t?.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(Uv(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var Kv=class extends xv{constructor(t){super(t)}},zv=class{constructor(t,e,r){var s,n;this.supabaseUrl=t,this.supabaseKey=e;const a=Vv(t);if(!e)throw new Error("supabaseKey is required.");Mv(e),this.realtimeUrl=new URL("realtime/v1",a),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",a),this.storageUrl=new URL("storage/v1",a),this.functionsUrl=new URL("functions/v1",a);const i=`sb-${a.hostname.split(".")[0]}-auth-token`,o={db:Sv,realtime:Ev,auth:Be(Be({},Cv),{},{storageKey:i}),global:kv,tracePropagation:Tv},l=Bv(r??{},o);if(this.settings=l,this.storageKey=(s=l.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(n=l.global.headers)!==null&&n!==void 0?n:{},l.accessToken)this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(u,p)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(p)} is not possible`)}});else{var c;this.auth=this._initSupabaseAuthClient((c=l.auth)!==null&&c!==void 0?c:{},this.headers,l.global.fetch)}this.fetch=hu(e,t,this._getSessionToken.bind(this),l.global.fetch,l.tracePropagation),this.functionsFetch=hu(e,t,this._getSessionToken.bind(this),l.global.fetch,l.tracePropagation,{omitApiKeyAsBearer:!0}),this.realtime=this._initRealtimeClient(Be({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(u=>this.realtime.setAuth(u)).catch(u=>console.warn("Failed to set initial Realtime auth token:",u)),this.rest=new Xm(new URL("rest/v1",a).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit,retry:l.db.retry}),this.storage=new yy(this.storageUrl.href,this.headers,this.fetch,r?.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new Vm(this.functionsUrl.href,{headers:this.headers,customFetch:this.functionsFetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}getOpenApiSpec(){return this.rest.getOpenApiSpec()}rpc(t,e={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,r)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getSessionToken(){var t=this,e,r;if(t.accessToken)return await t.accessToken();const{data:s}=await t.auth.getSession();return(e=(r=s.session)===null||r===void 0?void 0:r.access_token)!==null&&e!==void 0?e:null}async _getAccessToken(){var t=this,e;return(e=await t._getSessionToken())!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:s,userStorage:n,storageKey:a,flowType:i,lock:o,debug:l,throwOnError:c,experimental:u,lockAcquireTimeout:p,skipAutoInitialize:f},h,y){const g={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Kv({url:this.authUrl.href,headers:Be(Be({},g),h),storageKey:a,autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:s,userStorage:n,flowType:i,lock:o,debug:l,throwOnError:c,experimental:u,fetch:y,lockAcquireTimeout:p,skipAutoInitialize:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(v=>v.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new Vg(this.realtimeUrl.href,Be(Be({},t),{},{params:Be(Be({},{apikey:this.supabaseKey}),t?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e?.access_token)})}_handleTokenChanged(t,e,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN"||t==="INITIAL_SESSION")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const Hv=(t,e,r)=>new zv(t,e,r);function Wv(){if(typeof window<"u"||globalThis.Deno!==void 0)return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const r=e.match(/^v(\d+)\./);return r?parseInt(r[1],10)<=20:!1}Wv()&&console.warn("⚠️ Node.js 20 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 22 or later. For more information, visit: https://github.com/orgs/supabase/discussions/45715");const Ei=Hv("https://xcpktmmwqjkbkkmjxmpa.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhjcGt0bW13cWprYmtrbWp4bXBhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njc3NjE4MTYsImV4cCI6MjA4MzMzNzgxNn0.a0HC_Ji1rgvlrkWDnY10eKzFFtfMKEDP4-O_cUbjXmg",{auth:{persistSession:!1,autoRefreshToken:!1},global:{headers:{"Content-Type":"application/json"}}});let ha=null;const qv=(t,e)=>typeof window>"u"||window.google?.maps?.places?Promise.resolve():ha||(ha=new Promise((r,s)=>{const n=document.querySelector('script[data-google-maps-places="true"]');if(n){const o=Date.now(),l=()=>{if(window.google?.maps?.places){r();return}if(Date.now()-o>5e3){s(new Error("Google Maps script present but Places library did not become available."));return}window.setTimeout(l,50)};n.getAttribute("src")?l():(n.addEventListener("load",()=>l()),n.addEventListener("error",()=>s(new Error("Failed to load Google Maps API"))));return}const a=document.createElement("script"),i=new URL("https://maps.googleapis.com/maps/api/js");i.searchParams.set("key",t),i.searchParams.set("libraries","places"),i.searchParams.set("loading","async"),e&&i.searchParams.set("language",e),a.src=i.toString(),a.async=!0,a.defer=!0,a.setAttribute("data-google-maps-places","true"),a.onload=()=>{const o=Date.now(),l=()=>{if(window.google?.maps?.places){r();return}if(Date.now()-o>2e3){s(new Error("Google Maps loaded but Places library is unavailable. Check API key restrictions / enabled APIs."));return}window.setTimeout(l,50)};l()},a.onerror=()=>s(new Error("Failed to load Google Maps API")),document.head.appendChild(a)}),ha),Gv=(t={})=>{const{apiKey:e,language:r="en",restrictCountry:s}=t,[n,a]=k.useState(!1),[i,o]=k.useState([]),[l,c]=k.useState(!1),[u,p]=k.useState(null),f=k.useRef(null),h=k.useRef(null),y=k.useRef(null);k.useEffect(()=>{if(!e){a(!1),p(null);return}qv(e,r).then(()=>{try{f.current=new google.maps.places.AutocompleteService;const _=document.createElement("div");h.current=new google.maps.places.PlacesService(_),y.current=new google.maps.places.AutocompleteSessionToken,a(!0),p(null)}catch(_){a(!1),p(_ instanceof Error?_.message:"Failed to create Places services")}}).catch(_=>{a(!1),p(_ instanceof Error?_.message:"Failed to load location service")})},[e,r]);const g=k.useCallback(async _=>{if(!_||_.length<2||!f.current){o([]);return}c(!0);try{const S={input:_,types:["(cities)"],sessionToken:y.current??void 0};s&&(S.componentRestrictions={country:s});const E=await new Promise((T,N)=>{f.current.getPlacePredictions(S,(L,ue)=>{ue===google.maps.places.PlacesServiceStatus.OK&&L?T(L):ue===google.maps.places.PlacesServiceStatus.ZERO_RESULTS?T([]):N(new Error(`Places API error: ${ue}`))})});o(E.map(T=>({place_id:T.place_id,description:T.description,structured_formatting:{main_text:T.structured_formatting?.main_text||T.description,secondary_text:T.structured_formatting?.secondary_text||""}})))}catch{o([])}finally{c(!1)}},[s]),v=k.useCallback(async _=>{if(!h.current)return null;try{const S=await new Promise((re,je)=>{h.current.getDetails({placeId:_,fields:["geometry","address_components","formatted_address"],sessionToken:y.current??void 0},(Se,F)=>{F===google.maps.places.PlacesServiceStatus.OK&&Se?re(Se):je(new Error(`Place details error: ${F}`))})});y.current=new google.maps.places.AutocompleteSessionToken;const E=S.geometry?.location?.lat()||0,T=S.geometry?.location?.lng()||0;let N="",L="",ue="";return S.address_components?.forEach(re=>{re.types.includes("locality")&&(N=re.long_name),re.types.includes("administrative_area_level_1")&&(L=re.long_name),re.types.includes("country")&&(ue=re.long_name)}),{display_name:S.formatted_address||"",lat:E,lng:T,city:N,state:L,country:ue}}catch{return null}},[]),C=k.useCallback(()=>o([]),[]);return{isLoaded:n,predictions:i,isSearching:l,loadError:u,searchPlaces:g,getPlaceDetails:v,clearPredictions:C}},gu={"पितृ दोष निवारण महायज्ञ एवं काशी गंगा महाआरती":"Pitru Dosha Nivaran Mahayagya & Kashi Ganga Maha Aarti","पितृ दोष शांति महापूजा एवं काशी गंगा आरती":"Pitra Dosha Shanti Mahapuja & Kashi Ganga Aarti","पितृ दोष निवारण पूजा एवं काशी गंगा आरती":"Pitra Dosha Nivaran Puja & Kashi Ganga Aarti","त्र्यंबकेश्वर ज्योतिर्लिंग रुद्राभिषेक और काल सर्प दोष निवारण पूजा":"Trimbakeshwar Jyotirlinga Rudrabhishek & Kaal Sarp Dosha Nivaran Puja","काल सर्प दोष निवारण पूजा एवं त्र्यंबकेश्वर ज्योतिर्लिंग रुद्राभिषेक":"Kaal Sarp Dosha Nivaran Puja & Trimbakeshwar Jyotirlinga Rudrabhishek","राहु-सूर्य दोष निवारण पूजा":"Rahu-Surya Dosha Nivaran Puja","मंगल दोष निवारण पूजा":"Mangal Dosha Nivaran Puja","शनि शांति पूजा":"Shani Shanti Puja","शनि साढ़े साती शांति पूजा":"Shani Sade Sati Shanti Puja","नवग्रह शांति पूजा":"Navagraha Shanti Puja","गुरु चांडाल दोष निवारण पूजा":"Guru Chandal Dosha Nivaran Puja","श्रापित दोष निवारण पूजा":"Shrapit Dosha Nivaran Puja","काल सर्प दोष पूजा":"Kaal Sarp Dosha Puja","मंगल पूजा":"Mangal Puja","शनि पूजा":"Shani Puja","राहु पूजा":"Rahu Puja","केतु पूजा":"Ketu Puja","नवग्रह शांति पूजा, शनि तिल तेल अभिषेक और पाप ग्रह शांति यज्ञ":"Navagraha Shanti Puja, Shani Til Tel Abhishek and Paap Graha Shanti Yagya","30 दिन मंगल दोष निवारण पूजा":"30-Day Mangal Dosha Nivaran Puja","30 दिनों में मंगल दोष निवारण पूजा":"30-Day Mangal Dosha Nivaran Puja","30 दिन मंगल पूजा":"30-Day Mangal Puja","30 लाख मंगल जाप":"30 Lakh Mangal Jaap","शनि साढ़ेसाती शांति पूजा":"Shani Sade Sati Shanti Puja","शनि महादशा शांति पूजा":"Shani Mahadasha Shanti Puja","शनि दोष निवारण पूजा":"Shani Dosha Nivaran Puja","काल सर्प दोष निवारण महापूजा":"Kaal Sarp Dosha Nivaran Mahapuja","पिशाच मोचन कुंड पूजा":"Pishach Mochan Kund Puja","पितृ तर्पण पूजा":"Pitru Tarpan Puja"},Jv={पूजा:"Puja",महापूजा:"Mahapuja",दोष:"Dosha",निवारण:"Nivaran",शांति:"Shanti",महायज्ञ:"Mahayagya",यज्ञ:"Yagya",अभिषेक:"Abhishek",रुद्राभिषेक:"Rudrabhishek",आरती:"Aarti",महाआरती:"Maha Aarti",महादशा:"Mahadasha",मंदिर:"Temple",ज्योतिर्लिंग:"Jyotirlinga",देव:"Dev",एवं:"&",और:"and",तिल:"Til",तेल:"Tel",गंगा:"Ganga",पाप:"Paap",ग्रह:"Graha",नवग्रह:"Navagraha",मंगल:"Mangal",शनि:"Shani","साढ़े साती":"Sade Sati",साढ़ेसाती:"Sade Sati",राहु:"Rahu",केतु:"Ketu",गुरु:"Guru",सूर्य:"Surya",चंद्र:"Chandra",चन्द्र:"Chandra",बुध:"Budh",शुक्र:"Shukra","काल सर्प":"Kaal Sarp",कालसर्प:"Kaal Sarp",पितृ:"Pitru",पितर:"Pitra",श्रापित:"Shrapit",चांडाल:"Chandal",काशी:"Kashi",त्र्यंबकेश्वर:"Trimbakeshwar",हथला:"Hathla"},yu={"काशी विश्वनाथ मंदिर":"Kashi Vishwanath Temple","त्र्यंबकेश्वर मंदिर":"Trimbakeshwar Temple","त्र्यंबकेश्वर ज्योतिर्लिंग":"Trimbakeshwar Jyotirlinga","महाकालेश्वर मंदिर":"Mahakaleshwar Temple","सोमनाथ मंदिर":"Somnath Temple","केदारनाथ मंदिर":"Kedarnath Temple","बद्रीनाथ मंदिर":"Badrinath Temple","रामेश्वरम मंदिर":"Rameshwaram Temple","द्वारकाधीश मंदिर":"Dwarkadhish Temple","जगन्नाथ पुरी मंदिर":"Jagannath Puri Temple","हथला शनि देव मंदिर":"Hathla Shani Dev Temple"};function vu(t){const e=t.split("/");if(e.length!==3)return null;const r=parseInt(e[0],10),s=parseInt(e[1],10)-1,n=parseInt(e[2],10);return new Date(n,s,r)}function bu(t){let e=t;return Object.entries(Jv).sort((s,n)=>n[0].length-s[0].length).forEach(([s,n])=>{const a=new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi");e=e.replace(a,n)}),e.replace(/\s+/g," ").trim()}function wu(t,e){const r=e?.toLowerCase().startsWith("hi"),s=typeof t=="string"?t:t.pooja_title,n=typeof t=="string"?void 0:t.pooja_title_english;if(r)return s;if(n?.trim())return n;if(gu[s])return gu[s];const a=bu(s);return a!==s?a:s}function xu(t,e){const r=e?.toLowerCase().startsWith("hi"),s=typeof t=="string"?t:t.temple_name,n=typeof t=="string"?void 0:t.temple_name_english;if(r)return s;if(n?.trim())return n;if(yu[s])return yu[s];const a=bu(s);return a!==s?a:s}function _u(t,e="en"){const r=vu(t);if(!r)return t;const n=e?.toLowerCase().startsWith("hi")?"hi-IN":"en-GB";return new Intl.DateTimeFormat(n,{day:"numeric",month:"short",year:"numeric"}).format(r)}function Zv(t){if(!t||typeof window>"u")return t;try{const e=new URLSearchParams(window.location.search),r=e.get("utm_source"),s=e.get("utm_medium"),n=e.get("utm_content");if(!r&&!s&&!n)return t;const a=new URL(t);return r&&a.searchParams.set("utm_source",r),s&&a.searchParams.set("utm_medium",s),n&&a.searchParams.set("utm_content",n),a.toString()}catch{return t}}function ku(t,e){const s=e?.toLowerCase().startsWith("hi")?t.puja_link_hindi||t.puja_link:t.puja_link||t.puja_link_hindi;return Zv(s||"")}function Su(t,e){return e?.toLowerCase().startsWith("hi")?t.cover_media_url||t.cover_media_url_english||"":t.cover_media_url_english||t.cover_media_url||""}function Yv(t,e){const s={mangal:["mangal","manglik","मंगल","मांगलिक"],"kaal-sarp":["kaal sarp","kaal-sarp","kaalsarp","काल सर्प","कालसर्प"],pitra:["pitra","pitru","पितृ","पितर"],shani:["shani","sade sati","शनि","साढ़े साती","साढ़ेसाती"]}[e];if(!s||s.length===0)return t[0]||null;const n=t.filter(o=>{const l=(o.pooja_title||"").toLowerCase(),c=(o.pooja_title_english||"").toLowerCase();return l.includes("rashi")||c.includes("rashi")?!1:s.some(u=>l.includes(u.toLowerCase())||c.includes(u.toLowerCase()))});if(n.length===0)return null;const a=new Date;return a.setHours(0,0,0,0),(n.filter(o=>{const l=vu(o.schedule_date_ist);return l?l.getTime()>=a.getTime():!0})[0]??n[0])||null}const Xv=({pujas:t,language:e="en",analytics:r})=>{const[s,n]=k.useState(0);if(k.useEffect(()=>{if(!t||t.length<=1)return;const g=setInterval(()=>{n(v=>v===t.length-1?0:v+1)},4e3);return()=>clearInterval(g)},[t]),!t||t.length===0)return null;const a=t[s],i=e?.toLowerCase().startsWith("hi"),o=wu(a,e),l=xu(a,e),c=_u(a.schedule_date_ist,e),u=ku(a,e),p=Su(a,e),f=()=>{n(g=>g===0?t.length-1:g-1)},h=()=>{n(g=>g===t.length-1?0:g+1)},y=()=>{r?.trackDoshaCalculatorResultBookCtaClicked?.({position:"puja_card",url:u,isOldDosha:!0}),window.open(u,"_blank","noopener,noreferrer")};return d.jsxs(dr,{className:"overflow-hidden hover:shadow-lg transition-shadow max-w-2xl mx-auto",children:[d.jsxs("div",{className:"relative",children:[d.jsx("button",{onClick:f,className:"absolute left-4 top-1/2 -translate-y-1/2 z-20 h-8 w-8 rounded-full bg-white/90 hover:bg-white flex items-center justify-center shadow-lg transition-all","aria-label":"Previous",children:d.jsx(Nd,{className:"h-4 w-4 text-gray-800"})}),d.jsx("button",{onClick:h,className:"absolute right-4 top-1/2 -translate-y-1/2 z-20 h-8 w-8 rounded-full bg-white/90 hover:bg-white flex items-center justify-center shadow-lg transition-all","aria-label":"Next",children:d.jsx(Rd,{className:"h-4 w-4 text-gray-800"})}),p&&d.jsx("div",{className:"relative aspect-[16/9] w-full overflow-hidden bg-gradient-to-br from-orange-50 to-orange-100",children:d.jsx(Dr,{src:p,alt:o,className:"w-full h-full object-contain",loading:"lazy"})}),d.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2 z-10",children:t.map((g,v)=>d.jsx("button",{className:`h-2.5 rounded-full transition-all ${v===s?"w-8 bg-primary":"w-2.5 bg-white/60 hover:bg-white/80"}`,onClick:()=>n(v),"aria-label":`Go to slide ${v+1}`},v))})]}),d.jsxs("div",{className:"p-6 space-y-3 bg-white",children:[d.jsx("h3",{className:"font-bold text-xl text-gray-900",children:o}),a.temple_name&&d.jsx("p",{className:"text-base text-gray-600",children:l}),a.schedule_date_ist&&d.jsx("p",{className:"text-base font-medium text-gray-900",children:c}),a.individual_pack_price_inr>0&&d.jsx("p",{className:"text-lg font-bold text-primary",children:i?`₹${a.individual_pack_price_inr} से शुरू`:`Starting from ₹${a.individual_pack_price_inr}`}),d.jsxs(Br,{size:"lg",className:"book-puja-cta w-full h-14 text-lg font-bold",onClick:y,children:[i?"पूजा बुक करें":"Book Puja",d.jsx(Xi,{className:"ml-2 h-4 w-4"})]}),d.jsx("p",{className:"text-xs text-center text-gray-500",children:i?"श्री मंदिर द्वारा संचालित":"Powered by Sri Mandir"})]})]})};function Cu(t){const e=[];let r="",s=!1;for(let n=0;n<t.length;n++){const a=t[n];a==='"'?s&&t[n+1]==='"'?(r+='"',n++):s=!s:a===","&&!s?(e.push(r),r=""):r+=a}return e.push(r),e.map(n=>n.trim().replace(/^"|"$/g,""))}function It(t,...e){const r=n=>n.trim().toLowerCase().replace(/[_\s]+/g," ").trim(),s=new Map;Object.entries(t).forEach(([n,a])=>s.set(r(n),a));for(const n of e){const a=s.get(r(n));if(a!==void 0&&a.trim())return a.trim()}return""}function Qv(t){const r=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
156
+ ${C}`}class He extends Error{constructor({message:e,code:r,cause:s,name:n}){var a;super(e,{cause:s}),this.__isWebAuthnError=!0,this.name=(a=n??(s instanceof Error?s.name:void 0))!==null&&a!==void 0?a:"Unknown Error",this.code=r}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class oa extends He{constructor(e,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:e}),this.name="WebAuthnUnknownError",this.originalError=r}}function ov({error:t,options:e}){var r,s,n;const{publicKey:a}=e;if(!a)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new He({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=a.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new He({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((s=a.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new He({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((n=a.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new He({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new He({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new He({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return a.pubKeyCredParams.filter(o=>o.type==="public-key").length===0?new He({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new He({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const i=window.location.hostname;if(ru(i)){if(a.rp.id!==i)return new He({message:`The RP ID "${a.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new He({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(a.user.id.byteLength<1||a.user.id.byteLength>64)return new He({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new He({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new He({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function lv({error:t,options:e}){const{publicKey:r}=e;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new He({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new He({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const s=window.location.hostname;if(ru(s)){if(r.rpId!==s)return new He({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new He({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new He({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new He({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class cv{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const ki=new cv;function Xc(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:r,excludeCredentials:s}=t,n=Vn(t,["challenge","user","excludeCredentials"]),a=Ss(e).buffer,i=Object.assign(Object.assign({},r),{id:Ss(r.id).buffer}),o=Object.assign(Object.assign({},n),{challenge:a,user:i});if(s&&s.length>0){o.excludeCredentials=new Array(s.length);for(let l=0;l<s.length;l++){const c=s[l];o.excludeCredentials[l]=Object.assign(Object.assign({},c),{id:Ss(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return o}function Qc(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:r}=t,s=Vn(t,["challenge","allowCredentials"]),n=Ss(e).buffer,a=Object.assign(Object.assign({},s),{challenge:n});if(r&&r.length>0){a.allowCredentials=new Array(r.length);for(let i=0;i<r.length;i++){const o=r[i];a.allowCredentials[i]=Object.assign(Object.assign({},o),{id:Ss(o.id).buffer,type:o.type||"public-key",transports:o.transports})}}return a}function eu(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t;return{id:t.id,rawId:t.id,response:{attestationObject:qr(new Uint8Array(t.response.attestationObject)),clientDataJSON:qr(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function tu(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t,s=t.getClientExtensionResults(),n=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:qr(new Uint8Array(n.authenticatorData)),clientDataJSON:qr(new Uint8Array(n.clientDataJSON)),signature:qr(new Uint8Array(n.signature)),userHandle:n.userHandle?qr(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:s,authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function ru(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function la(){var t,e;return!!(ot()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator?.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator?.credentials)===null||e===void 0?void 0:e.get)=="function")}async function su(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new oa("Browser returned unexpected credential type",e)}:{data:null,error:new oa("Empty credential response",e)}}catch(e){return{data:null,error:ov({error:e,options:t})}}}async function nu(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new oa("Browser returned unexpected credential type",e)}:{data:null,error:new oa("Empty credential response",e)}}catch(e){return{data:null,error:lv({error:e,options:t})}}}const uv={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},dv={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function ca(...t){const e=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),r=n=>n instanceof ArrayBuffer||ArrayBuffer.isView(n),s={};for(const n of t)if(n)for(const a in n){const i=n[a];if(i!==void 0)if(Array.isArray(i))s[a]=i;else if(r(i))s[a]=i;else if(e(i)){const o=s[a];e(o)?s[a]=ca(o,i):s[a]=ca(i)}else s[a]=i}return s}function hv(t,e){return ca(uv,t,e||{})}function fv(t,e){return ca(dv,t,e||{})}class pv{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:r,friendlyName:s,signal:n},a){var i;try{const{data:o,error:l}=await this.client.mfa.challenge({factorId:e,webauthn:r});if(!o)return{data:null,error:l};const c=n??ki.createNewAbortSignal();if(o.webauthn.type==="create"){const{user:d}=o.webauthn.credential_options.publicKey;if(!d.name){const f=s;if(f)d.name=`${d.id}:${f}`;else{const h=(await this.client.getUser()).data.user,g=((i=h?.user_metadata)===null||i===void 0?void 0:i.name)||h?.email||h?.id||"User";d.name=`${d.id}:${g}`}}d.displayName||(d.displayName=d.name)}switch(o.webauthn.type){case"create":{const d=hv(o.webauthn.credential_options.publicKey,a?.create),{data:f,error:p}=await su({publicKey:d,signal:c});return f?{data:{factorId:e,challengeId:o.id,webauthn:{type:o.webauthn.type,credential_response:f}},error:null}:{data:null,error:p}}case"request":{const d=fv(o.webauthn.credential_options.publicKey,a?.request),{data:f,error:p}=await nu(Object.assign(Object.assign({},o.webauthn.credential_options),{publicKey:d,signal:c}));return f?{data:{factorId:e,challengeId:o.id,webauthn:{type:o.webauthn.type,credential_response:f}},error:null}:{data:null,error:p}}}}catch(o){return B(o)?{data:null,error:o}:{data:null,error:new zt("Unexpected error in challenge",o)}}}async _verify({challengeId:e,factorId:r,webauthn:s}){return this.client.mfa.verify({factorId:r,challengeId:e,webauthn:s})}async _authenticate({factorId:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},a){if(!r)return{data:null,error:new sn("rpId is required for WebAuthn authentication")};try{if(!la())return{data:null,error:new zt("Browser does not support WebAuthn",null)};const{data:i,error:o}=await this.challenge({factorId:e,webauthn:{rpId:r,rpOrigins:s},signal:n},{request:a});if(!i)return{data:null,error:o};const{webauthn:l}=i;return this._verify({factorId:e,challengeId:i.challengeId,webauthn:{type:l.type,rpId:r,rpOrigins:s,credential_response:l.credential_response}})}catch(i){return B(i)?{data:null,error:i}:{data:null,error:new zt("Unexpected error in authenticate",i)}}}async _register({friendlyName:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},a){if(!r)return{data:null,error:new sn("rpId is required for WebAuthn registration")};try{if(!la())return{data:null,error:new zt("Browser does not support WebAuthn",null)};const{data:i,error:o}=await this._enroll({friendlyName:e});if(!i)return await this.client.mfa.listFactors().then(d=>{var f;return(f=d.data)===null||f===void 0?void 0:f.all.find(p=>p.factor_type==="webauthn"&&p.friendly_name===e&&p.status!=="unverified")}).then(d=>d?this.client.mfa.unenroll({factorId:d?.id}):void 0),{data:null,error:o};const{data:l,error:c}=await this._challenge({factorId:i.id,friendlyName:i.friendly_name,webauthn:{rpId:r,rpOrigins:s},signal:n},{create:a});return l?this._verify({factorId:i.id,challengeId:l.challengeId,webauthn:{rpId:r,rpOrigins:s,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(i){return B(i)?{data:null,error:i}:{data:null,error:new zt("Unexpected error in register",i)}}}}sv();const mv={url:py,storageKey:my,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:gy,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}},Es={};let au=!1;class an{get jwks(){var e,r;return(r=(e=Es[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){Es[this.storageKey]=Object.assign(Object.assign({},Es[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=Es[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Es[this.storageKey]=Object.assign(Object.assign({},Es[this.storageKey]),{cachedAt:e})}constructor(e){var r,s,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.lastRefreshFailure=null,this._sessionRemovalEpoch=0,this.initializePromise=null,this._pendingInitNotifications=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lock=null,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const a=Object.assign(Object.assign({},mv),e);if(this.storageKey=a.storageKey,this.instanceID=(r=an.nextInstanceID[this.storageKey])!==null&&r!==void 0?r:0,an.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.instanceID>0&&ot()){const i=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(i),this.logDebugMessages&&console.trace(i)}if(this.persistSession=a.persistSession,this.autoRefreshToken=a.autoRefreshToken,this.experimental=(s=a.experimental)!==null&&s!==void 0?s:{},this.admin=new tv({url:a.url,headers:a.headers,fetch:a.fetch,experimental:this.experimental}),this.url=a.url,this.headers=a.headers,this.fetch=Kc(a.fetch),this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,this.throwOnError=a.throwOnError,this.lockAcquireTimeout=a.lockAcquireTimeout,a.lock!=null&&(this.lock=a.lock,au||(au=!0,console.warn(`${this._logPrefix()} The "lock" option is deprecated and will be removed in v3. The client now coordinates session refreshes without a lock, so most apps can drop the option. See https://github.com/supabase/supabase-js/blob/master/packages/core/auth-js/migrations/lockless-coordination.md`))),this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),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),webauthn:new pv(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(a.storage?this.storage=a.storage:Bc()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Zc(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=Zc(this.memoryStorage)),ot()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),(i.data.event==="TOKEN_REFRESHED"||i.data.event==="SIGNED_IN")&&(this.lastRefreshFailure=null);try{await this._notifyAllSubscribers(i.data.event,i.data.session,!1)}catch(o){this._debug("#broadcastChannel","error",o)}})}a.skipAutoInitialize||this.initialize().catch(i=>{this._debug("#initialize()","error",i)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${Pc}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){var e;if(this.initializePromise)return await this.initializePromise;this._pendingInitNotifications=[],this.initializePromise=(async()=>this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()):await this._initialize())();const r=await this.initializePromise,s=(e=this._pendingInitNotifications)!==null&&e!==void 0?e:[];this._pendingInitNotifications=null;for(const n of s)await this._notifyAllSubscribers(n.event,n.session,n.broadcast);return r}async _initialize(){var e;try{let r={},s="none";if(ot()&&(r=Vc(window.location.href),this._isImplicitGrantCallback(r)?s="implicit":await this._isPKCECallback(r)&&(s="pkce")),ot()&&this.detectSessionInUrl&&s!=="none"){const{data:n,error:a}=await this._getSessionFromURL(r,s);if(a){if(this._debug("#_initialize()","error detecting session from URL",a),xy(a)){const l=(e=a.details)===null||e===void 0?void 0:e.code;if(l==="identity_already_exists"||l==="identity_not_found"||l==="single_identity_not_deletable")return{error:a}}return{error:a}}const{session:i,redirectType:o}=n;return this._debug("#_initialize()","detected session in URL",i,"redirect type",o),await this._saveSession(i),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",i):await this._notifyAllSubscribers("SIGNED_IN",i)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return B(r)?this._returnResult({error:r}):this._returnResult({error:new zt("Unexpected error during initialization",r)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,s,n;try{const a=await q(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(s=(r=e?.options)===null||r===void 0?void 0:r.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:(n=e?.options)===null||n===void 0?void 0:n.captchaToken}},xform:Rt}),{data:i,error:o}=a;if(o||!i)return this._returnResult({data:{user:null,session:null},error:o});const l=i.session,c=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(a){if(B(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async signUp(e){var r,s,n;let a=null;try{let i;if("email"in e){const{email:f,password:p,options:h}=e;let g=null,y=null;this.flowType==="pkce"&&([g,y,a]=await this._getCodeChallengeAndMethod()),i=await q(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(h?.emailRedirectTo,a),body:{email:f,password:p,data:(r=h?.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:h?.captchaToken},code_challenge:g,code_challenge_method:y},xform:Rt})}else if("phone"in e){const{phone:f,password:p,options:h}=e;i=await q(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:f,password:p,data:(s=h?.data)!==null&&s!==void 0?s:{},channel:(n=h?.channel)!==null&&n!==void 0?n:"sms",gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:Rt})}else throw new Xn("You must provide either an email or phone number and a password");const{data:o,error:l}=i;if(l||!o)return await Ht(this.storage,this.storageKey,a),this._returnResult({data:{user:null,session:null},error:l});const c=o.session,d=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),this._returnResult({data:{user:d,session:c},error:null})}catch(i){if(await Ht(this.storage,this.storageKey,a),B(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithPassword(e){try{let r;if("email"in e){const{email:a,password:i,options:o}=e;r=await q(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:a,password:i,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:Gc})}else if("phone"in e){const{phone:a,password:i,options:o}=e;r=await q(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:a,password:i,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:Gc})}else throw new Xn("You must provide either an email or phone number and a password");const{data:s,error:n}=r;if(n)return this._returnResult({data:{user:null,session:null},error:n});if(!s||!s.session||!s.user){const a=new ks;return this._returnResult({data:{user:null,session:null},error:a})}return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),this._returnResult({data:Object.assign({user:s.user,session:s.session},s.weak_password?{weakPassword:s.weak_password}:null),error:n})}catch(r){if(B(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOAuth(e){var r,s,n,a;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(s=e.options)===null||s===void 0?void 0:s.scopes,queryParams:(n=e.options)===null||n===void 0?void 0:n.queryParams,skipBrowserRedirect:(a=e.options)===null||a===void 0?void 0:a.skipBrowserRedirect})}async exchangeCodeForSession(e,r){return await this.initializePromise,this.lock!=null?this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e,r)):this._exchangeCodeForSession(e,r)}async signInWithWeb3(e){const{chain:r}=e;switch(r){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(e){var r,s,n,a,i,o,l,c,d,f,p;let h,g;if("message"in e)h=e.message,g=e.signature;else{const{chain:y,wallet:v,statement:C,options:_}=e;let S;if(ot())if(typeof v=="object")S=v;else{const re=window;if("ethereum"in re&&typeof re.ethereum=="object"&&"request"in re.ethereum&&typeof re.ethereum.request=="function")S=re.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof v!="object"||!_?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");S=v}const E=new URL((r=_?.url)!==null&&r!==void 0?r:window.location.href),T=await S.request({method:"eth_requestAccounts"}).then(re=>re).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!T||T.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const N=Yc(T[0]);let L=(s=_?.signInWithEthereum)===null||s===void 0?void 0:s.chainId;if(!L){const re=await S.request({method:"eth_chainId"});L=nv(re)}const ue={domain:E.host,address:N,statement:C,uri:E.href,version:"1",chainId:L,nonce:(n=_?.signInWithEthereum)===null||n===void 0?void 0:n.nonce,issuedAt:(i=(a=_?.signInWithEthereum)===null||a===void 0?void 0:a.issuedAt)!==null&&i!==void 0?i:new Date,expirationTime:(o=_?.signInWithEthereum)===null||o===void 0?void 0:o.expirationTime,notBefore:(l=_?.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=_?.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(d=_?.signInWithEthereum)===null||d===void 0?void 0:d.resources};h=iv(ue),g=await S.request({method:"personal_sign",params:[av(h),N]})}try{const{data:y,error:v}=await q(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:h,signature:g},!((f=e.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(p=e.options)===null||p===void 0?void 0:p.captchaToken}}:null),xform:Rt});if(v)throw v;if(!y||!y.session||!y.user){const C=new ks;return this._returnResult({data:{user:null,session:null},error:C})}return y.session&&(await this._saveSession(y.session),await this._notifyAllSubscribers("SIGNED_IN",y.session)),this._returnResult({data:Object.assign({},y),error:v})}catch(y){if(B(y))return this._returnResult({data:{user:null,session:null},error:y});throw y}}async signInWithSolana(e){var r,s,n,a,i,o,l,c,d,f,p,h;let g,y;if("message"in e)g=e.message,y=e.signature;else{const{chain:v,wallet:C,statement:_,options:S}=e;let E;if(ot())if(typeof C=="object")E=C;else{const N=window;if("solana"in N&&typeof N.solana=="object"&&("signIn"in N.solana&&typeof N.solana.signIn=="function"||"signMessage"in N.solana&&typeof N.solana.signMessage=="function"))E=N.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof C!="object"||!S?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");E=C}const T=new URL((r=S?.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in E&&E.signIn){const N=await E.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},S?.signInWithSolana),{version:"1",domain:T.host,uri:T.href}),_?{statement:_}:null));let L;if(Array.isArray(N)&&N[0]&&typeof N[0]=="object")L=N[0];else if(N&&typeof N=="object"&&"signedMessage"in N&&"signature"in N)L=N;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in L&&"signature"in L&&(typeof L.signedMessage=="string"||L.signedMessage instanceof Uint8Array)&&L.signature instanceof Uint8Array)g=typeof L.signedMessage=="string"?L.signedMessage:new TextDecoder().decode(L.signedMessage),y=L.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in E)||typeof E.signMessage!="function"||!("publicKey"in E)||typeof E!="object"||!E.publicKey||!("toBase58"in E.publicKey)||typeof E.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");g=[`${T.host} wants you to sign in with your Solana account:`,E.publicKey.toBase58(),..._?["",_,""]:[""],"Version: 1",`URI: ${T.href}`,`Issued At: ${(n=(s=S?.signInWithSolana)===null||s===void 0?void 0:s.issuedAt)!==null&&n!==void 0?n:new Date().toISOString()}`,...!((a=S?.signInWithSolana)===null||a===void 0)&&a.notBefore?[`Not Before: ${S.signInWithSolana.notBefore}`]:[],...!((i=S?.signInWithSolana)===null||i===void 0)&&i.expirationTime?[`Expiration Time: ${S.signInWithSolana.expirationTime}`]:[],...!((o=S?.signInWithSolana)===null||o===void 0)&&o.chainId?[`Chain ID: ${S.signInWithSolana.chainId}`]:[],...!((l=S?.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${S.signInWithSolana.nonce}`]:[],...!((c=S?.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${S.signInWithSolana.requestId}`]:[],...!((f=(d=S?.signInWithSolana)===null||d===void 0?void 0:d.resources)===null||f===void 0)&&f.length?["Resources",...S.signInWithSolana.resources.map(L=>`- ${L}`)]:[]].join(`
157
+ `);const N=await E.signMessage(new TextEncoder().encode(g),"utf8");if(!N||!(N instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");y=N}}try{const{data:v,error:C}=await q(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:g,signature:qr(y)},!((p=e.options)===null||p===void 0)&&p.captchaToken?{gotrue_meta_security:{captcha_token:(h=e.options)===null||h===void 0?void 0:h.captchaToken}}:null),xform:Rt});if(C)throw C;if(!v||!v.session||!v.user){const _=new ks;return this._returnResult({data:{user:null,session:null},error:_})}return v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),this._returnResult({data:Object.assign({},v),error:C})}catch(v){if(B(v))return this._returnResult({data:{user:null,session:null},error:v});throw v}}async _exchangeCodeForSession(e,r){const s=r?.flowId!=null,n=s?ia(r?.flowId):ot()?ia(Vc(window.location.href)[Wr]):null;s&&!n&&this._debug("#_exchangeCodeForSession()","provided flowId is not a valid flow id",r?.flowId);const{verifier:a,flowId:i}=s&&!n?{verifier:null,flowId:null}:await Uy(this.storage,this.storageKey,n),[o,l]=(a??"").split("/");try{if(!o&&this.flowType==="pkce")throw new _y;const{data:c,error:d}=await q(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:o},xform:Rt});if(await Ht(this.storage,this.storageKey,i),d)throw d;if(!c||!c.session||!c.user){const f=new ks;return this._returnResult({data:{user:null,session:null,redirectType:null},error:f})}return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers(l==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c.session)),this._returnResult({data:Object.assign(Object.assign({},c),{redirectType:l??null}),error:d})}catch(c){if(await Ht(this.storage,this.storageKey,i),B(c))return this._returnResult({data:{user:null,session:null,redirectType:null},error:c});throw c}}async signInWithIdToken(e){try{const{options:r,provider:s,token:n,access_token:a,nonce:i}=e,o=await q(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:s,id_token:n,access_token:a,nonce:i,gotrue_meta_security:{captcha_token:r?.captchaToken}},xform:Rt}),{data:l,error:c}=o;if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l||!l.session||!l.user){const d=new ks;return this._returnResult({data:{user:null,session:null},error:d})}return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",l.session)),this._returnResult({data:l,error:c})}catch(r){if(B(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOtp(e){var r,s,n,a,i;let o=null;try{if("email"in e){const{email:l,options:c}=e;let d=null,f=null;this.flowType==="pkce"&&([d,f,o]=await this._getCodeChallengeAndMethod());const{error:p}=await q(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:l,data:(r=c?.data)!==null&&r!==void 0?r:{},create_user:(s=c?.shouldCreateUser)!==null&&s!==void 0?s:!0,gotrue_meta_security:{captcha_token:c?.captchaToken},code_challenge:d,code_challenge_method:f},redirectTo:this._maybeAppendFlowIdToRedirect(c?.emailRedirectTo,o)});return this._returnResult({data:{user:null,session:null},error:p})}if("phone"in e){const{phone:l,options:c}=e,{data:d,error:f}=await q(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:l,data:(n=c?.data)!==null&&n!==void 0?n:{},create_user:(a=c?.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:c?.captchaToken},channel:(i=c?.channel)!==null&&i!==void 0?i:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:d?.message_id},error:f})}throw new Xn("You must provide either an email or phone number.")}catch(l){if(await Ht(this.storage,this.storageKey,o),B(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async verifyOtp(e){var r,s;try{let n,a;"options"in e&&(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo,a=(s=e.options)===null||s===void 0?void 0:s.captchaToken);const{data:i,error:o}=await q(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:n,xform:Rt});if(o)throw o;if(!i)throw new Error("An error occurred on token verification.");const l=i.session,c=i.user;return l?.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(n){if(B(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithSSO(e){var r,s,n,a;let i=null;try{let o=null,l=null;this.flowType==="pkce"&&([o,l,i]=await this._getCodeChallengeAndMethod());const c=await q(this.fetch,"POST",`${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:this._maybeAppendFlowIdToRedirect((r=e.options)===null||r===void 0?void 0:r.redirectTo,i)}),!((s=e?.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:l}),headers:this.headers,xform:Xy});return!((n=c.data)===null||n===void 0)&&n.url&&ot()&&!(!((a=e.options)===null||a===void 0)&&a.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(o){if(await Ht(this.storage,this.storageKey,i),B(o))return this._returnResult({data:null,error:o});throw o}}async reauthenticate(){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate()):await this._reauthenticate()}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)throw s;if(!r)throw new et;const{error:n}=await q(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return this._returnResult({data:{user:null,session:null},error:n})})}catch(e){if(B(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){let r=null;try{const s=`${this.url}/resend`;if("email"in e){const{email:n,type:a,options:i}=e;let o=null,l=null;this.flowType==="pkce"&&([o,l,r]=await this._getCodeChallengeAndMethod());const{error:c}=await q(this.fetch,"POST",s,{headers:this.headers,body:{email:n,type:a,gotrue_meta_security:{captcha_token:i?.captchaToken},code_challenge:o,code_challenge_method:l},redirectTo:this._maybeAppendFlowIdToRedirect(i?.emailRedirectTo,r)});return c&&await Ht(this.storage,this.storageKey,r),this._returnResult({data:{user:null,session:null},error:c})}else if("phone"in e){const{phone:n,type:a,options:i}=e,{data:o,error:l}=await q(this.fetch,"POST",s,{headers:this.headers,body:{phone:n,type:a,gotrue_meta_security:{captcha_token:i?.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o?.message_id},error:l})}throw new Xn("You must provide either an email or phone number and a type")}catch(s){if(await Ht(this.storage,this.storageKey,r),B(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async getSession(){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async e=>e)):await this._useSession(async e=>e)}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const s=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await s,await r()))();return this.pendingInLock.push((async()=>{try{await n}catch{}})()),n}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const s=r();for(this.pendingInLock.push((async()=>{try{await s}catch{}})()),await s;this.pendingInLock.length;){const n=[...this.pendingInLock];await Promise.all(n),this.pendingInLock.splice(0,n.length)}return await s}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lock!=null&&!this.lockAcquired&&this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await ct(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const s=e.expires_at?e.expires_at*1e3-Date.now()<vi:!1;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",e.expires_at),!s){if(this.userStorage){const i=await ct(this.userStorage,this.storageKey+"-user");i?.user?e.user=i.user:e.user=xi()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const i={value:this.suppressGetSessionWarning};e.user=Jy(e.user,i),i.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:n,error:a}=await this._callRefreshToken(e.refresh_token);if(a){if(!!(e.expires_at&&e.expires_at*1e3>Date.now())){const o=await ct(this.storage,this.storageKey);if(o&&o.refresh_token===e.refresh_token)return this._returnResult({data:{session:e},error:null})}return this._returnResult({data:{session:null},error:a})}return this._returnResult({data:{session:n},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;let r;return this.lock!=null?r=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser()):r=await this._getUser(),r.data.user&&(this.suppressGetSessionWarning=!0),r}async _getUser(e){try{return e?await q(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Or}):await this._useSession(async r=>{var s,n,a;const{data:i,error:o}=r;if(o)throw o;return!(!((s=i.session)===null||s===void 0)&&s.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new et}:await q(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(a=(n=i.session)===null||n===void 0?void 0:n.access_token)!==null&&a!==void 0?a:void 0,xform:Or})})}catch(r){if(B(r))return Yn(r)&&await this._removeSession(),this._returnResult({data:{user:null},error:r});throw r}}async updateUser(e,r={}){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,r)):await this._updateUser(e,r)}async _updateUser(e,r={}){let s=null;try{return await this._useSession(async n=>{const{data:a,error:i}=n;if(i)throw i;if(!a.session)throw new et;const o=a.session;let l=null,c=null;this.flowType==="pkce"&&e.email!=null&&([l,c,s]=await this._getCodeChallengeAndMethod());const{data:d,error:f}=await q(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(r?.emailRedirectTo,s),body:Object.assign(Object.assign({},e),{code_challenge:l,code_challenge_method:c}),jwt:o.access_token,xform:Or});if(f)throw f;return o.user=d.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(n){if(await Ht(this.storage,this.storageKey,s),B(n))return this._returnResult({data:{user:null},error:n});throw n}}async setSession(e){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e)):await this._setSession(e)}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new et;const r=Date.now()/1e3;let s=r,n=!0,a=null;const{payload:i}=aa(e.access_token);if(i.exp&&(s=i.exp,n=s<=r),n){const{data:o,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!o)return{data:{user:null,session:null},error:null};a=o}else{const{data:o,error:l}=await this._getUser(e.access_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});a={access_token:e.access_token,refresh_token:e.refresh_token,user:o.user,token_type:"bearer",expires_in:s-r,expires_at:s},await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)}return this._returnResult({data:{user:a.user,session:a},error:null})}catch(r){if(B(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}}async refreshSession(e){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e)):await this._refreshSession(e)}async _refreshSession(e){try{return await this._useSession(async r=>{var s;if(!e){const{data:i,error:o}=r;if(o)throw o;e=(s=i.session)!==null&&s!==void 0?s:void 0}if(!e?.refresh_token)throw new et;const{data:n,error:a}=await this._callRefreshToken(e.refresh_token);return a?this._returnResult({data:{user:null,session:null},error:a}):n?this._returnResult({data:{user:n.user,session:n},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(r){if(B(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async _getSessionFromURL(e,r){var s;try{if(!ot())throw new Qn("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Qn(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new Ic("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Qn("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Ic("No code detected.");const{data:S,error:E}=await this._exchangeCodeForSession(e.code,{flowId:e[Wr]});if(E)throw E;const T=new URL(window.location.href);return T.searchParams.delete("code"),T.searchParams.delete(Wr),window.history.replaceState(window.history.state,"",T.toString()),{data:{session:S.session,redirectType:(s=S.redirectType)!==null&&s!==void 0?s:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:i,refresh_token:o,expires_in:l,expires_at:c,token_type:d}=e;if(!i||!l||!o||!d)throw new Qn("No session defined in URL");const f=Math.round(Date.now()/1e3),p=parseInt(l);let h=f+p;c&&(h=parseInt(c));const g=h-f;g*1e3<=gr&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${g}s, should have been closer to ${p}s`);const y=h-p;f-y>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",y,h,f):f-y<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",y,h,f);const{data:v,error:C}=await this._getUser(i);if(C)throw C;const _={provider_token:n,provider_refresh_token:a,access_token:i,expires_in:p,expires_at:h,refresh_token:o,token_type:d,user:v.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:_,redirectType:e.type},error:null})}catch(n){if(B(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error||e.error_description||e.error_code)}async _isPKCECallback(e){if(!e.code)return!1;const r=ia(e[Wr]);return r&&await ct(this.storage,Cs(this.storageKey,r))?!0:!!await ct(this.storage,`${this.storageKey}-code-verifier`)}async signOut(e={scope:"global"}){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e)):await this._signOut(e)}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var s;const n=async()=>{await this._removeSession()},{data:a,error:i}=r;if(i&&!Yn(i))return this._returnResult({error:i});const o=(s=a.session)===null||s===void 0?void 0:s.access_token;if(o){const{error:l}=await this.admin.signOut(o,e);if(l&&!(Rc(l)&&(l.status===404||l.status===401||l.status===403)||Yn(l)))return e!=="others"&&await n(),this._returnResult({error:l})}return e!=="others"&&await n(),this._returnResult({error:null})})}onAuthStateChange(e){const r=Oy(),s={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,s),(async()=>(await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(r)}):await this._emitInitialSession(r)))(),{data:{subscription:s}}}async _emitInitialSession(e){return await this._useSession(async r=>{var s,n;try{const{data:{session:a},error:i}=r;if(i)throw i;await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",a)),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(a){await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",a),Yn(a)||ta(a)||Rc(a)&&(a.code==="refresh_token_not_found"||a.code==="refresh_token_already_used"||a.code==="session_expired")?console.warn(a):console.error(a)}})}async resetPasswordForEmail(e,r={}){let s=null,n=null,a=null;this.flowType==="pkce"&&([s,n,a]=await this._getCodeChallengeAndMethod(!0));try{return await q(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:s,code_challenge_method:n,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(r.redirectTo,a)})}catch(i){if(await Ht(this.storage,this.storageKey,a),B(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:r,error:s}=await this.getUser();if(s)throw s;return this._returnResult({data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var r;let s=null;try{const{data:n,error:a}=await this._useSession(async i=>{var o,l,c,d,f;const{data:p,error:h}=i;if(h)throw h;const{url:g,flowId:y}=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(l=e.options)===null||l===void 0?void 0:l.scopes,queryParams:(c=e.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return s=y,await q(this.fetch,"GET",g,{headers:this.headers,jwt:(f=(d=p.session)===null||d===void 0?void 0:d.access_token)!==null&&f!==void 0?f:void 0})});if(a)throw a;return ot()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n?.url),this._returnResult({data:{provider:e.provider,url:n?.url,flowId:s},error:null})}catch(n){if(B(n))return this._returnResult({data:{provider:e.provider,url:null,flowId:s},error:n});throw n}}async linkIdentityIdToken(e){return await this._useSession(async r=>{var s;try{const{error:n,data:{session:a}}=r;if(n)throw n;const{options:i,provider:o,token:l,access_token:c,nonce:d}=e,f=await q(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(s=a?.access_token)!==null&&s!==void 0?s:void 0,body:{provider:o,id_token:l,access_token:c,nonce:d,link_identity:!0,gotrue_meta_security:{captcha_token:i?.captchaToken}},xform:Rt}),{data:p,error:h}=f;return h?this._returnResult({data:{user:null,session:null},error:h}):!p||!p.session||!p.user?this._returnResult({data:{user:null,session:null},error:new ks}):(p.session&&(await this._saveSession(p.session),await this._notifyAllSubscribers("USER_UPDATED",p.session)),this._returnResult({data:p,error:h}))}catch(n){if(await Ht(this.storage,this.storageKey,null),B(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}})}async unlinkIdentity(e){try{return await this._useSession(async r=>{var s,n;const{data:a,error:i}=r;if(i)throw i;return await q(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(s=a.session)===null||s===void 0?void 0:s.access_token)!==null&&n!==void 0?n:void 0})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _refreshAccessToken(e){const r="#_refreshAccessToken()";this._debug(r,"begin");try{const s=Date.now();return await Ry(async n=>(n>0&&await Ny(200*Math.pow(2,n-1)),this._debug(r,"refreshing attempt",n),await q(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Rt})),(n,a)=>{const i=200*Math.pow(2,n);return a&&ta(a)&&Date.now()+i-s<gr})}catch(s){if(this._debug(r,"error",s),B(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){const{url:s,flowId:n}=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",s),ot()&&!r.skipBrowserRedirect&&window.location.assign(s),{data:{provider:e,url:s,flowId:n},error:null}}async _recoverAndRefresh(){var e,r;const s="#_recoverAndRefresh()";this._debug(s,"begin");try{const n=await ct(this.storage,this.storageKey);if(n&&this.userStorage){let i=await ct(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!i&&(i={user:n.user},await yr(this.userStorage,this.storageKey+"-user",i)),n.user=(e=i?.user)!==null&&e!==void 0?e:xi()}else if(n&&!n.user&&!n.user){const i=await ct(this.storage,this.storageKey+"-user");i&&i?.user?(n.user=i.user,await yt(this.storage,this.storageKey+"-user"),await yr(this.storage,this.storageKey,n)):n.user=xi()}if(this._debug(s,"session from storage",n),!this._isValidSession(n)){this._debug(s,"session is not valid"),n!==null&&await this._removeSession();return}const a=((r=n.expires_at)!==null&&r!==void 0?r:1/0)*1e3-Date.now()<vi;if(this._debug(s,`session has${a?"":" not"} expired with margin of ${vi}s`),a){if(this.autoRefreshToken&&n.refresh_token){const{error:i}=await this._callRefreshToken(n.refresh_token);i&&(ky(i)?this._debug(s,"refresh discarded by commit guard",i):this._debug(s,"refresh failed",i))}}else if(n.user&&n.user.__isUserNotAvailableProxy===!0)try{const{data:i,error:o}=await this._getUser(n.access_token);!o&&i?.user?(n.user=i.user,await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)):this._debug(s,"could not get user data, skipping SIGNED_IN notification")}catch(i){console.error("Error getting user data:",i),this._debug(s,"error getting user data, skipping SIGNED_IN notification",i)}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(s,"error",n),ta(n)?console.warn(n):console.error(n);return}finally{this._debug(s,"end")}}async _callRefreshToken(e){var r,s;if(!e)throw new et;if(this.refreshingDeferred)return this.refreshingDeferred.promise;if(this.lastRefreshFailure&&this.lastRefreshFailure.refreshToken===e&&Date.now()<this.lastRefreshFailure.expiresAt)return this._debug("#_callRefreshToken()","returning cached failure (cooldown active)"),this.lastRefreshFailure.result;const n="#_callRefreshToken()";this._debug(n,"begin");try{this.refreshingDeferred=new na,this.refreshingDeferred.promise.then(void 0,()=>{});const a=await ct(this.storage,this.storageKey),{data:i,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!i.session)throw new et;const l=await ct(this.storage,this.storageKey);if(a!==null&&(l===null||l.refresh_token!==a.refresh_token)){this._debug(n,"commit guard: storage changed since refresh started, discarding rotated tokens",{startedWith:"present",nowHolds:l?"replaced":"cleared"});const p={data:null,error:new Dc};return this.refreshingDeferred.resolve(p),p}const d=this._sessionRemovalEpoch;if(await this._saveSession(i.session),this._sessionRemovalEpoch!==d){this._debug(n,"commit guard (post-save): _removeSession ran during _saveSession, undoing write"),await yt(this.storage,this.storageKey),this.userStorage&&await yt(this.userStorage,this.storageKey+"-user");const p={data:null,error:new Dc};return this.refreshingDeferred.resolve(p),p}await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const f={data:i.session,error:null};return this.lastRefreshFailure=null,this.refreshingDeferred.resolve(f),f}catch(a){if(this._debug(n,"error",a),B(a)){const i={data:null,error:a};if(!ta(a)){const o=await ct(this.storage,this.storageKey);!!(o?.expires_at&&o.expires_at*1e3>Date.now())?this._debug(n,"proactive refresh failed, access token still valid — preserving session"):await this._removeSession()}return this.lastRefreshFailure={refreshToken:e,result:i,expiresAt:Date.now()+fy},(r=this.refreshingDeferred)===null||r===void 0||r.resolve(i),i}throw(s=this.refreshingDeferred)===null||s===void 0||s.reject(a),a}finally{this.refreshingDeferred=null,this._debug(n,"end")}}async _notifyAllSubscribers(e,r,s=!0){if(this._pendingInitNotifications!==null&&s){this._pendingInitNotifications.push({event:e,session:r,broadcast:s});return}const n=`#_notifyAllSubscribers(${e})`;this._debug(n,"begin",r,`broadcast = ${s}`);try{this.broadcastChannel&&s&&this.broadcastChannel.postMessage({event:e,session:r});const a=[],i=Array.from(this.stateChangeEmitters.values()).map(async o=>{try{await o.callback(e,r)}catch(l){a.push(l)}});if(await Promise.all(i),a.length>0){for(let o=0;o<a.length;o+=1)console.error(a[o]);throw a[0]}}finally{this._debug(n,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;const r=Object.assign({},e),s=r.user&&r.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!s&&r.user&&await yr(this.userStorage,this.storageKey+"-user",{user:r.user});const n=Object.assign({},r);delete n.user;const a=Hc(n);await yr(this.storage,this.storageKey,a)}else{const n=Hc(r);await yr(this.storage,this.storageKey,n)}}async _removeSession(){this._sessionRemovalEpoch+=1,this._debug("#_removeSession()"),this.lastRefreshFailure=null,this.suppressGetSessionWarning=!1,await yt(this.storage,this.storageKey),await By(this.storage,this.storageKey),await yt(this.storage,this.storageKey+"-user"),this.userStorage&&await yt(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&ot()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),gr);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const r=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=r,r&&typeof r=="object"&&typeof r.unref=="function"?r.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(r)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const r=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,r&&clearTimeout(r)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async dispose(){var e;this._removeVisibilityChangedCallback(),await this._stopAutoRefresh(),(e=this.broadcastChannel)===null||e===void 0||e.close(),this.broadcastChannel=null,this.stateChangeEmitters.clear()}async _autoRefreshTokenTick(){if(this._debug("#_autoRefreshTokenTick()","begin"),this.lock!=null){try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:s}}=r;if(!s||!s.refresh_token||!s.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((s.expires_at*1e3-e)/gr);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${gr}ms, refresh threshold is ${rn} ticks`),n<=rn&&await this._callRefreshToken(s.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e instanceof rv)this._debug("auto refresh token tick lock not available");else throw e}return}if(this.refreshingDeferred!==null){this._debug("#_autoRefreshTokenTick()","refresh already in flight, skipping");return}try{const e=Date.now();try{await this._useSession(async r=>{const{data:{session:s}}=r;if(!s||!s.refresh_token||!s.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((s.expires_at*1e3-e)/gr);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${gr}ms, refresh threshold is ${rn} ticks`),n<=rn&&await this._callRefreshToken(s.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ot()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;if(this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"){if(this.autoRefreshToken&&this._startAutoRefresh(),!e)if(await this.initializePromise,this.lock!=null)await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()});else{if(document.visibilityState!=="visible"){this._debug(r,"visibilityState is no longer visible, skipping recovery");return}await this._recoverAndRefresh()}}else document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,s){let n=s?.redirectTo,a=null,i=null,o=null;this.flowType==="pkce"&&([a,i,o]=await this._getCodeChallengeAndMethod(),n=this._maybeAppendFlowIdToRedirect(n,o));const l=[`provider=${encodeURIComponent(r)}`];if(n&&l.push(`redirect_to=${encodeURIComponent(n)}`),s?.scopes&&l.push(`scopes=${encodeURIComponent(s.scopes)}`),a!=null&&i!=null){const c=new URLSearchParams({code_challenge:`${encodeURIComponent(a)}`,code_challenge_method:`${encodeURIComponent(i)}`});l.push(c.toString())}if(s?.queryParams){const c=new URLSearchParams(s.queryParams);l.push(c.toString())}return s?.skipBrowserRedirect&&l.push(`skip_http_redirect=${s.skipBrowserRedirect}`),{url:`${e}?${l.join("&")}`,flowId:o}}_maybeAppendFlowIdToRedirect(e,r){return!e||!r||!this.experimental.appendPkceFlowIdToRedirects?e??void 0:Vy(e,r)}async _getCodeChallengeAndMethod(e=!1){return Ky(this.storage,this.storageKey,e,r=>this._debug("#_getCodeChallengeAndMethod()","evicted oldest pending PKCE verifier slot",r))}async _unenroll(e){try{return await this._useSession(async r=>{var s;const{data:n,error:a}=r;return a?this._returnResult({data:null,error:a}):await q(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(s=n?.session)===null||s===void 0?void 0:s.access_token})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _enroll(e){try{return await this._useSession(async r=>{var s,n;const{data:a,error:i}=r;if(i)return this._returnResult({data:null,error:i});const o=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:l,error:c}=await q(this.fetch,"POST",`${this.url}/factors`,{body:o,headers:this.headers,jwt:(s=a?.session)===null||s===void 0?void 0:s.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&l.type==="totp"&&(!((n=l?.totp)===null||n===void 0)&&n.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),this._returnResult({data:l,error:null}))})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _verify(e){const r=async()=>{try{return await this._useSession(async s=>{var n;const{data:a,error:i}=s;if(i)return this._returnResult({data:null,error:i});const o=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?eu(e.webauthn.credential_response):tu(e.webauthn.credential_response)})}:{code:e.code}),{data:l,error:c}=await q(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:(n=a?.session)===null||n===void 0?void 0:n.access_token});return c?this._returnResult({data:null,error:c}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+l.expires_in},l)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",l),this._returnResult({data:l,error:c}))})}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}};return this.lock!=null?this._acquireLock(this.lockAcquireTimeout,r):r()}async _challenge(e){const r=async()=>{try{return await this._useSession(async s=>{var n;const{data:a,error:i}=s;if(i)return this._returnResult({data:null,error:i});const o=await q(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(n=a?.session)===null||n===void 0?void 0:n.access_token});if(o.error)return o;const{data:l}=o;if(l.type!=="webauthn")return{data:l,error:null};switch(l.webauthn.type){case"create":return{data:Object.assign(Object.assign({},l),{webauthn:Object.assign(Object.assign({},l.webauthn),{credential_options:Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:Xc(l.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},l),{webauthn:Object.assign(Object.assign({},l.webauthn),{credential_options:Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:Qc(l.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}};return this.lock!=null?this._acquireLock(this.lockAcquireTimeout,r):r()}async _challengeAndVerify(e){const{data:r,error:s}=await this._challenge({factorId:e.factorId});return s?this._returnResult({data:null,error:s}):await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){var e;const{data:{user:r},error:s}=await this.getUser();if(s)return{data:null,error:s};const n={all:[],phone:[],totp:[],webauthn:[]};for(const a of(e=r?.factors)!==null&&e!==void 0?e:[])n.all.push(a),a.status==="verified"&&n[a.factor_type].push(a);return{data:n,error:null}}async _getAuthenticatorAssuranceLevel(e){var r,s,n,a;if(e)try{const{payload:h}=aa(e);let g=null;h.aal&&(g=h.aal);let y=g;const{data:{user:v},error:C}=await this.getUser(e);if(C)return this._returnResult({data:null,error:C});((s=(r=v?.factors)===null||r===void 0?void 0:r.filter(E=>E.status==="verified"))!==null&&s!==void 0?s:[]).length>0&&(y="aal2");const S=h.amr||[];return{data:{currentLevel:g,nextLevel:y,currentAuthenticationMethods:S},error:null}}catch(h){if(B(h))return this._returnResult({data:null,error:h});throw h}const{data:{session:i},error:o}=await this.getSession();if(o)return this._returnResult({data:null,error:o});if(!i)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=aa(i.access_token);let c=null;l.aal&&(c=l.aal);let d=c;((a=(n=i.user.factors)===null||n===void 0?void 0:n.filter(h=>h.status==="verified"))!==null&&a!==void 0?a:[]).length>0&&(d="aal2");const p=l.amr||[];return{data:{currentLevel:c,nextLevel:d,currentAuthenticationMethods:p},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;return n?this._returnResult({data:null,error:n}):s?await q(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:s.access_token,xform:a=>({data:a,error:null})}):this._returnResult({data:null,error:new et})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _approveAuthorization(e,r){try{return await this._useSession(async s=>{const{data:{session:n},error:a}=s;if(a)return this._returnResult({data:null,error:a});if(!n)return this._returnResult({data:null,error:new et});const i=await q(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"approve"},xform:o=>({data:o,error:null})});return i.data&&i.data.redirect_url&&ot()&&!r?.skipBrowserRedirect&&window.location.assign(i.data.redirect_url),i})}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}}async _denyAuthorization(e,r){try{return await this._useSession(async s=>{const{data:{session:n},error:a}=s;if(a)return this._returnResult({data:null,error:a});if(!n)return this._returnResult({data:null,error:new et});const i=await q(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"deny"},xform:o=>({data:o,error:null})});return i.data&&i.data.redirect_url&&ot()&&!r?.skipBrowserRedirect&&window.location.assign(i.data.redirect_url),i})}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;return s?this._returnResult({data:null,error:s}):r?await q(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,xform:n=>({data:n,error:null})}):this._returnResult({data:null,error:new et})})}catch(e){if(B(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;return n?this._returnResult({data:null,error:n}):s?(await q(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new et})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(e,r={keys:[]}){let s=r.keys.find(o=>o.kid===e);if(s)return s;const n=Date.now();if(s=this.jwks.keys.find(o=>o.kid===e),s&&this.jwks_cached_at+by>n)return s;const{data:a,error:i}=await q(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(i)throw i;return!a.keys||a.keys.length===0||(this.jwks=a,this.jwks_cached_at=n,s=a.keys.find(o=>o.kid===e),!s)?null:s}async getClaims(e,r={}){try{let s=e;if(!s){const{data:h,error:g}=await this.getSession();if(g||!h.session)return this._returnResult({data:null,error:g});s=h.session.access_token}const{header:n,payload:a,signature:i,raw:{header:o,payload:l}}=aa(s);if(!r?.allowExpired)try{Wy(a.exp)}catch(h){throw new ra(h instanceof Error?h.message:"JWT validation failed")}const c=!n.alg||n.alg.startsWith("HS")||!n.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(n.kid,r?.keys?{keys:r.keys}:r?.jwks);if(!c){const{error:h}=await this.getUser(s);if(h)throw h;return{data:{claims:a,header:n,signature:i},error:null}}const d=qy(n.alg),f=await crypto.subtle.importKey("jwk",c,d,!0,["verify"]);if(!await crypto.subtle.verify(d,f,i,Ay(`${o}.${l}`)))throw new ra("Invalid JWT signature");return{data:{claims:a,header:n,signature:i},error:null}}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}}async signInWithPasskey(e){var r,s,n;Wt(this.experimental);try{if(!la())return this._returnResult({data:null,error:new zt("Browser does not support WebAuthn",null)});const{data:a,error:i}=await this._startPasskeyAuthentication({options:{captchaToken:(r=e?.options)===null||r===void 0?void 0:r.captchaToken}});if(i||!a)return this._returnResult({data:null,error:i});const o=Qc(a.options),l=(n=(s=e?.options)===null||s===void 0?void 0:s.signal)!==null&&n!==void 0?n:ki.createNewAbortSignal(),{data:c,error:d}=await nu({publicKey:o,signal:l});if(d||!c)return this._returnResult({data:null,error:d??new zt("WebAuthn ceremony failed",null)});const f=tu(c);return this._verifyPasskeyAuthentication({challengeId:a.challenge_id,credential:f})}catch(a){if(B(a))return this._returnResult({data:null,error:a});throw a}}async registerPasskey(e){var r,s;Wt(this.experimental);try{if(!la())return this._returnResult({data:null,error:new zt("Browser does not support WebAuthn",null)});const{data:n,error:a}=await this._startPasskeyRegistration();if(a||!n)return this._returnResult({data:null,error:a});const i=Xc(n.options),o=(s=(r=e?.options)===null||r===void 0?void 0:r.signal)!==null&&s!==void 0?s:ki.createNewAbortSignal(),{data:l,error:c}=await su({publicKey:i,signal:o});if(c||!l)return this._returnResult({data:null,error:c??new zt("WebAuthn ceremony failed",null)});const d=eu(l);return this._verifyPasskeyRegistration({challengeId:n.challenge_id,credential:d})}catch(n){if(B(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyRegistration(){Wt(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new et});const{data:n,error:a}=await q(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:r.access_token,body:{}});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(B(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){Wt(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new et});const{data:a,error:i}=await q(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:s.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:a,error:null})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _startPasskeyAuthentication(e){var r;Wt(this.experimental);try{const{data:s,error:n}=await q(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(r=e?.options)===null||r===void 0?void 0:r.captchaToken}}});return n?this._returnResult({data:null,error:n}):this._returnResult({data:s,error:null})}catch(s){if(B(s))return this._returnResult({data:null,error:s});throw s}}async _verifyPasskeyAuthentication(e){Wt(this.experimental);try{const{data:r,error:s}=await q(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:Rt});return s?this._returnResult({data:null,error:s}):(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:r,error:null}))}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _listPasskeys(){Wt(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;if(s)return this._returnResult({data:null,error:s});if(!r)return this._returnResult({data:null,error:new et});const{data:n,error:a}=await q(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:r.access_token,xform:i=>({data:i,error:null})});return a?this._returnResult({data:null,error:a}):this._returnResult({data:n,error:null})})}catch(e){if(B(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){Wt(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new et});const{data:a,error:i}=await q(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:s.access_token,body:{friendly_name:e.friendlyName}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:a,error:null})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}async _deletePasskey(e){Wt(this.experimental);try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;if(n)return this._returnResult({data:null,error:n});if(!s)return this._returnResult({data:null,error:new et});const{error:a}=await q(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:s.access_token,noResolveJson:!0});return a?this._returnResult({data:null,error:a}):this._returnResult({data:null,error:null})})}catch(r){if(B(r))return this._returnResult({data:null,error:r});throw r}}}an.nextInstanceID={};const gv=an,yv="2.112.4";let on="",ua;if(typeof Deno<"u"){var Si;on="deno",ua=(Si=Deno.version)===null||Si===void 0?void 0:Si.deno}else if(typeof document<"u")on="web";else if(typeof navigator<"u"&&navigator.product==="ReactNative")on="react-native";else{var Ci;on="node";const t=globalThis.process;ua=t==null||(Ci=t.version)===null||Ci===void 0?void 0:Ci.replace(/^v/,"")}const iu=[`runtime=${on}`];ua&&iu.push(`runtime-version=${ua}`);const vv={headers:{"X-Client-Info":`supabase-js/${yv}; ${iu.join("; ")}`}},bv={schema:"public"},wv={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},xv={},_v={enabled:!1,respectSamplingDecision:!0};function kv(t){if(!t||typeof t!="string")return null;const e=t.split("-");if(e.length!==4)return null;const[r,s,n,a]=e;if(r.length!==2||s.length!==32||n.length!==16||a.length!==2)return null;const i=/^[0-9a-f]+$/i;return!i.test(r)||!i.test(s)||!i.test(n)||!i.test(a)||s==="00000000000000000000000000000000"||n==="0000000000000000"?null:{version:r,traceId:s,parentId:n,traceFlags:a,isSampled:(parseInt(a,16)&1)===1}}function Sv(t,e){if(!t||!e||e.length===0)return!1;let r;if(t instanceof URL)r=t;else try{r=new URL(t)}catch{return!1}for(const s of e)try{if(typeof s=="string"){if(Cv(r.hostname,s))return!0}else if(s instanceof RegExp){if(s.test(r.hostname))return!0}else if(typeof s=="function"&&s(r))return!0}catch{continue}return!1}function Cv(t,e){if(e===t)return!0;if(e.startsWith("*.")){const r=e.slice(2);if(t.endsWith(r)&&(t===r||t.endsWith("."+r)))return!0}return!1}function Ev(t){const e=[];try{const r=new URL(t);e.push(r.hostname)}catch{}return e.push("*.supabase.co","*.supabase.in"),e.push("localhost","127.0.0.1","[::1]"),e}function ln(t){"@babel/helpers - typeof";return ln=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ln(t)}function Tv(t,e){if(ln(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(ln(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Av(t){var e=Tv(t,"string");return ln(e)=="symbol"?e:e+""}function jv(t,e,r){return(e=Av(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ou(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function Be(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ou(Object(r),!0).forEach(function(s){jv(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ou(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}const Ov=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Pv=()=>Headers,lu=t=>t.startsWith("sb_publishable_")||t.startsWith("sb_secret_"),Nv="sb_temp_",cu=new Set,Rv=t=>{var e,r;if(!t.startsWith("sb_")||lu(t)||t.startsWith(Nv))return;const s=(e=(r=t.match(/^sb_[a-zA-Z0-9]+_/))===null||r===void 0?void 0:r[0])!==null&&e!==void 0?e:"unknown";cu.has(s)||(cu.add(s),console.warn("@supabase/supabase-js: Unrecognized Supabase API key format. The client will proceed and send this key as-is; if you see authentication errors you may need to upgrade @supabase/supabase-js to a version that recognizes this key type."))},uu=(t,e,r,s,n,a)=>{const i=Ov(s),o=Pv(),l=n?.enabled===!0,c=n?.respectSamplingDecision!==!1,d=l?Ev(e):null,f=!(a?.omitApiKeyAsBearer&&lu(t));return async(p,h)=>{const g=await r();let y=new o(h?.headers);if(y.has("apikey")||y.set("apikey",t),!y.has("Authorization")){const v=g??(f?t:null);v&&y.set("Authorization",`Bearer ${v}`)}if(d){const v=Iv(p,d,c);v&&(v.traceparent&&!y.has("traceparent")&&y.set("traceparent",v.traceparent),v.tracestate&&!y.has("tracestate")&&y.set("tracestate",v.tracestate),v.baggage&&!y.has("baggage")&&y.set("baggage",v.baggage))}return i(p,Be(Be({},h),{},{headers:y}))}};let du=!1,hu=!1;function Iv(t,e,r){const s=Lm();if(!s)return du||(du=!0,console.warn("@supabase/supabase-js: tracePropagation is enabled but the tracing runtime is not loaded, so trace headers will not be attached. Add `import '@supabase/supabase-js/tracing'` at your application entry point (requires the OpenTelemetry API package to be installed). The CDN/UMD build does not support trace propagation.")),null;if(!Sv(typeof t=="string"||t instanceof URL?t:t.url,e))return null;const n=s();if(!n||!n.traceparent){var a;if(!(n==null||(a=n.carrierKeys)===null||a===void 0)&&a.length&&!hu){hu=!0;const i=n.carrierKeys.includes("sentry-trace")?" Sentry detected: set `propagateTraceparent: true` in Sentry.init() to emit it.":" Configure your tracing SDK to emit W3C trace context on outgoing requests.";console.warn(`@supabase/supabase-js: tracePropagation is enabled and a tracing SDK is active, but its propagator wrote [${n.carrierKeys.join(", ")}] and no W3C traceparent header, so trace headers will not be attached.`+i)}return null}if(r){const i=kv(n.traceparent);if(i&&!i.isSampled)return{traceparent:n.traceparent}}return n}function fu(t){return typeof t=="boolean"?{enabled:t}:t}function Dv(t){return t.endsWith("/")?t:t+"/"}function Lv(t,e){var r,s,n,a,i,o;const{db:l,auth:c,realtime:d,global:f}=t,{db:p,auth:h,realtime:g,global:y}=e,v=fu(t.tracePropagation),C=fu(e.tracePropagation),_={db:Be(Be({},p),l),auth:Be(Be({},h),c),realtime:Be(Be({},g),d),storage:{},global:Be(Be(Be({},y),f),{},{headers:Be(Be({},(r=y?.headers)!==null&&r!==void 0?r:{}),(s=f?.headers)!==null&&s!==void 0?s:{})}),tracePropagation:{enabled:(n=(a=v?.enabled)!==null&&a!==void 0?a:C?.enabled)!==null&&n!==void 0?n:!1,respectSamplingDecision:(i=(o=v?.respectSamplingDecision)!==null&&o!==void 0?o:C?.respectSamplingDecision)!==null&&i!==void 0?i:!0},accessToken:async()=>""};return t.accessToken?_.accessToken=t.accessToken:delete _.accessToken,_}function $v(t){const e=t?.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(Dv(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var Mv=class extends gv{constructor(t){super(t)}},Fv=class{constructor(t,e,r){var s,n;this.supabaseUrl=t,this.supabaseKey=e;const a=$v(t);if(!e)throw new Error("supabaseKey is required.");Rv(e),this.realtimeUrl=new URL("realtime/v1",a),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",a),this.storageUrl=new URL("storage/v1",a),this.functionsUrl=new URL("functions/v1",a);const i=`sb-${a.hostname.split(".")[0]}-auth-token`,o={db:bv,realtime:xv,auth:Be(Be({},wv),{},{storageKey:i}),global:vv,tracePropagation:_v},l=Lv(r??{},o);if(this.settings=l,this.storageKey=(s=l.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(n=l.global.headers)!==null&&n!==void 0?n:{},l.accessToken)this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(d,f)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(f)} is not possible`)}});else{var c;this.auth=this._initSupabaseAuthClient((c=l.auth)!==null&&c!==void 0?c:{},this.headers,l.global.fetch)}this.fetch=uu(e,t,this._getSessionToken.bind(this),l.global.fetch,l.tracePropagation),this.functionsFetch=uu(e,t,this._getSessionToken.bind(this),l.global.fetch,l.tracePropagation,{omitApiKeyAsBearer:!0}),this.realtime=this._initRealtimeClient(Be({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(d=>this.realtime.setAuth(d)).catch(d=>console.warn("Failed to set initial Realtime auth token:",d)),this.rest=new Jm(new URL("rest/v1",a).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit,retry:l.db.retry}),this.storage=new hy(this.storageUrl.href,this.headers,this.fetch,r?.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new Um(this.functionsUrl.href,{headers:this.headers,customFetch:this.functionsFetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,r)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getSessionToken(){var t=this,e,r;if(t.accessToken)return await t.accessToken();const{data:s}=await t.auth.getSession();return(e=(r=s.session)===null||r===void 0?void 0:r.access_token)!==null&&e!==void 0?e:null}async _getAccessToken(){var t=this,e;return(e=await t._getSessionToken())!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:s,userStorage:n,storageKey:a,flowType:i,lock:o,debug:l,throwOnError:c,experimental:d,lockAcquireTimeout:f,skipAutoInitialize:p},h,g){const y={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new Mv({url:this.authUrl.href,headers:Be(Be({},y),h),storageKey:a,autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:s,userStorage:n,flowType:i,lock:o,debug:l,throwOnError:c,experimental:d,fetch:g,lockAcquireTimeout:f,skipAutoInitialize:p,hasCustomAuthorizationHeader:Object.keys(this.headers).some(v=>v.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new $g(this.realtimeUrl.href,Be(Be({},t),{},{params:Be(Be({},{apikey:this.supabaseKey}),t?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e?.access_token)})}_handleTokenChanged(t,e,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN"||t==="INITIAL_SESSION")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const Uv=(t,e,r)=>new Fv(t,e,r);function Bv(){if(typeof window<"u"||globalThis.Deno!==void 0)return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const r=e.match(/^v(\d+)\./);return r?parseInt(r[1],10)<=20:!1}Bv()&&console.warn("⚠️ Node.js 20 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 22 or later. For more information, visit: https://github.com/orgs/supabase/discussions/45715");const Ei=Uv("https://xcpktmmwqjkbkkmjxmpa.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhjcGt0bW13cWprYmtrbWp4bXBhIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Njc3NjE4MTYsImV4cCI6MjA4MzMzNzgxNn0.a0HC_Ji1rgvlrkWDnY10eKzFFtfMKEDP4-O_cUbjXmg",{auth:{persistSession:!1,autoRefreshToken:!1},global:{headers:{"Content-Type":"application/json"}}});let da=null;const Vv=(t,e)=>typeof window>"u"||window.google?.maps?.places?Promise.resolve():da||(da=new Promise((r,s)=>{const n=document.querySelector('script[data-google-maps-places="true"]');if(n){const o=Date.now(),l=()=>{if(window.google?.maps?.places){r();return}if(Date.now()-o>5e3){s(new Error("Google Maps script present but Places library did not become available."));return}window.setTimeout(l,50)};n.getAttribute("src")?l():(n.addEventListener("load",()=>l()),n.addEventListener("error",()=>s(new Error("Failed to load Google Maps API"))));return}const a=document.createElement("script"),i=new URL("https://maps.googleapis.com/maps/api/js");i.searchParams.set("key",t),i.searchParams.set("libraries","places"),i.searchParams.set("loading","async"),e&&i.searchParams.set("language",e),a.src=i.toString(),a.async=!0,a.defer=!0,a.setAttribute("data-google-maps-places","true"),a.onload=()=>{const o=Date.now(),l=()=>{if(window.google?.maps?.places){r();return}if(Date.now()-o>2e3){s(new Error("Google Maps loaded but Places library is unavailable. Check API key restrictions / enabled APIs."));return}window.setTimeout(l,50)};l()},a.onerror=()=>s(new Error("Failed to load Google Maps API")),document.head.appendChild(a)}),da),Kv=(t={})=>{const{apiKey:e,language:r="en",restrictCountry:s}=t,[n,a]=k.useState(!1),[i,o]=k.useState([]),[l,c]=k.useState(!1),[d,f]=k.useState(null),p=k.useRef(null),h=k.useRef(null),g=k.useRef(null);k.useEffect(()=>{if(!e){a(!1),f(null);return}Vv(e,r).then(()=>{try{p.current=new google.maps.places.AutocompleteService;const _=document.createElement("div");h.current=new google.maps.places.PlacesService(_),g.current=new google.maps.places.AutocompleteSessionToken,a(!0),f(null)}catch(_){a(!1),f(_ instanceof Error?_.message:"Failed to create Places services")}}).catch(_=>{a(!1),f(_ instanceof Error?_.message:"Failed to load location service")})},[e,r]);const y=k.useCallback(async _=>{if(!_||_.length<2||!p.current){o([]);return}c(!0);try{const S={input:_,types:["(cities)"],sessionToken:g.current??void 0};s&&(S.componentRestrictions={country:s});const E=await new Promise((T,N)=>{p.current.getPlacePredictions(S,(L,ue)=>{ue===google.maps.places.PlacesServiceStatus.OK&&L?T(L):ue===google.maps.places.PlacesServiceStatus.ZERO_RESULTS?T([]):N(new Error(`Places API error: ${ue}`))})});o(E.map(T=>({place_id:T.place_id,description:T.description,structured_formatting:{main_text:T.structured_formatting?.main_text||T.description,secondary_text:T.structured_formatting?.secondary_text||""}})))}catch{o([])}finally{c(!1)}},[s]),v=k.useCallback(async _=>{if(!h.current)return null;try{const S=await new Promise((re,je)=>{h.current.getDetails({placeId:_,fields:["geometry","address_components","formatted_address"],sessionToken:g.current??void 0},(Se,F)=>{F===google.maps.places.PlacesServiceStatus.OK&&Se?re(Se):je(new Error(`Place details error: ${F}`))})});g.current=new google.maps.places.AutocompleteSessionToken;const E=S.geometry?.location?.lat()||0,T=S.geometry?.location?.lng()||0;let N="",L="",ue="";return S.address_components?.forEach(re=>{re.types.includes("locality")&&(N=re.long_name),re.types.includes("administrative_area_level_1")&&(L=re.long_name),re.types.includes("country")&&(ue=re.long_name)}),{display_name:S.formatted_address||"",lat:E,lng:T,city:N,state:L,country:ue}}catch{return null}},[]),C=k.useCallback(()=>o([]),[]);return{isLoaded:n,predictions:i,isSearching:l,loadError:d,searchPlaces:y,getPlaceDetails:v,clearPredictions:C}},pu={"पितृ दोष निवारण महायज्ञ एवं काशी गंगा महाआरती":"Pitru Dosha Nivaran Mahayagya & Kashi Ganga Maha Aarti","पितृ दोष शांति महापूजा एवं काशी गंगा आरती":"Pitra Dosha Shanti Mahapuja & Kashi Ganga Aarti","पितृ दोष निवारण पूजा एवं काशी गंगा आरती":"Pitra Dosha Nivaran Puja & Kashi Ganga Aarti","त्र्यंबकेश्वर ज्योतिर्लिंग रुद्राभिषेक और काल सर्प दोष निवारण पूजा":"Trimbakeshwar Jyotirlinga Rudrabhishek & Kaal Sarp Dosha Nivaran Puja","काल सर्प दोष निवारण पूजा एवं त्र्यंबकेश्वर ज्योतिर्लिंग रुद्राभिषेक":"Kaal Sarp Dosha Nivaran Puja & Trimbakeshwar Jyotirlinga Rudrabhishek","राहु-सूर्य दोष निवारण पूजा":"Rahu-Surya Dosha Nivaran Puja","मंगल दोष निवारण पूजा":"Mangal Dosha Nivaran Puja","शनि शांति पूजा":"Shani Shanti Puja","शनि साढ़े साती शांति पूजा":"Shani Sade Sati Shanti Puja","नवग्रह शांति पूजा":"Navagraha Shanti Puja","गुरु चांडाल दोष निवारण पूजा":"Guru Chandal Dosha Nivaran Puja","श्रापित दोष निवारण पूजा":"Shrapit Dosha Nivaran Puja","काल सर्प दोष पूजा":"Kaal Sarp Dosha Puja","मंगल पूजा":"Mangal Puja","शनि पूजा":"Shani Puja","राहु पूजा":"Rahu Puja","केतु पूजा":"Ketu Puja","नवग्रह शांति पूजा, शनि तिल तेल अभिषेक और पाप ग्रह शांति यज्ञ":"Navagraha Shanti Puja, Shani Til Tel Abhishek and Paap Graha Shanti Yagya","30 दिन मंगल दोष निवारण पूजा":"30-Day Mangal Dosha Nivaran Puja","30 दिनों में मंगल दोष निवारण पूजा":"30-Day Mangal Dosha Nivaran Puja","30 दिन मंगल पूजा":"30-Day Mangal Puja","30 लाख मंगल जाप":"30 Lakh Mangal Jaap","शनि साढ़ेसाती शांति पूजा":"Shani Sade Sati Shanti Puja","शनि महादशा शांति पूजा":"Shani Mahadasha Shanti Puja","शनि दोष निवारण पूजा":"Shani Dosha Nivaran Puja","काल सर्प दोष निवारण महापूजा":"Kaal Sarp Dosha Nivaran Mahapuja","पिशाच मोचन कुंड पूजा":"Pishach Mochan Kund Puja","पितृ तर्पण पूजा":"Pitru Tarpan Puja"},zv={पूजा:"Puja",महापूजा:"Mahapuja",दोष:"Dosha",निवारण:"Nivaran",शांति:"Shanti",महायज्ञ:"Mahayagya",यज्ञ:"Yagya",अभिषेक:"Abhishek",रुद्राभिषेक:"Rudrabhishek",आरती:"Aarti",महाआरती:"Maha Aarti",महादशा:"Mahadasha",मंदिर:"Temple",ज्योतिर्लिंग:"Jyotirlinga",देव:"Dev",एवं:"&",और:"and",तिल:"Til",तेल:"Tel",गंगा:"Ganga",पाप:"Paap",ग्रह:"Graha",नवग्रह:"Navagraha",मंगल:"Mangal",शनि:"Shani","साढ़े साती":"Sade Sati",साढ़ेसाती:"Sade Sati",राहु:"Rahu",केतु:"Ketu",गुरु:"Guru",सूर्य:"Surya",चंद्र:"Chandra",चन्द्र:"Chandra",बुध:"Budh",शुक्र:"Shukra","काल सर्प":"Kaal Sarp",कालसर्प:"Kaal Sarp",पितृ:"Pitru",पितर:"Pitra",श्रापित:"Shrapit",चांडाल:"Chandal",काशी:"Kashi",त्र्यंबकेश्वर:"Trimbakeshwar",हथला:"Hathla"},mu={"काशी विश्वनाथ मंदिर":"Kashi Vishwanath Temple","त्र्यंबकेश्वर मंदिर":"Trimbakeshwar Temple","त्र्यंबकेश्वर ज्योतिर्लिंग":"Trimbakeshwar Jyotirlinga","महाकालेश्वर मंदिर":"Mahakaleshwar Temple","सोमनाथ मंदिर":"Somnath Temple","केदारनाथ मंदिर":"Kedarnath Temple","बद्रीनाथ मंदिर":"Badrinath Temple","रामेश्वरम मंदिर":"Rameshwaram Temple","द्वारकाधीश मंदिर":"Dwarkadhish Temple","जगन्नाथ पुरी मंदिर":"Jagannath Puri Temple","हथला शनि देव मंदिर":"Hathla Shani Dev Temple"};function gu(t){const e=t.split("/");if(e.length!==3)return null;const r=parseInt(e[0],10),s=parseInt(e[1],10)-1,n=parseInt(e[2],10);return new Date(n,s,r)}function yu(t){let e=t;return Object.entries(zv).sort((s,n)=>n[0].length-s[0].length).forEach(([s,n])=>{const a=new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi");e=e.replace(a,n)}),e.replace(/\s+/g," ").trim()}function vu(t,e){const r=e?.toLowerCase().startsWith("hi"),s=typeof t=="string"?t:t.pooja_title,n=typeof t=="string"?void 0:t.pooja_title_english;if(r)return s;if(n?.trim())return n;if(pu[s])return pu[s];const a=yu(s);return a!==s?a:s}function bu(t,e){const r=e?.toLowerCase().startsWith("hi"),s=typeof t=="string"?t:t.temple_name,n=typeof t=="string"?void 0:t.temple_name_english;if(r)return s;if(n?.trim())return n;if(mu[s])return mu[s];const a=yu(s);return a!==s?a:s}function wu(t,e="en"){const r=gu(t);if(!r)return t;const n=e?.toLowerCase().startsWith("hi")?"hi-IN":"en-GB";return new Intl.DateTimeFormat(n,{day:"numeric",month:"short",year:"numeric"}).format(r)}function Hv(t){if(!t||typeof window>"u")return t;try{const e=new URLSearchParams(window.location.search),r=e.get("utm_source"),s=e.get("utm_medium"),n=e.get("utm_content");if(!r&&!s&&!n)return t;const a=new URL(t);return r&&a.searchParams.set("utm_source",r),s&&a.searchParams.set("utm_medium",s),n&&a.searchParams.set("utm_content",n),a.toString()}catch{return t}}function xu(t,e){const s=e?.toLowerCase().startsWith("hi")?t.puja_link_hindi||t.puja_link:t.puja_link||t.puja_link_hindi;return Hv(s||"")}function _u(t,e){return e?.toLowerCase().startsWith("hi")?t.cover_media_url||t.cover_media_url_english||"":t.cover_media_url_english||t.cover_media_url||""}function Wv(t,e){const s={mangal:["mangal","manglik","मंगल","मांगलिक"],"kaal-sarp":["kaal sarp","kaal-sarp","kaalsarp","काल सर्प","कालसर्प"],pitra:["pitra","pitru","पितृ","पितर"],shani:["shani","sade sati","शनि","साढ़े साती","साढ़ेसाती"]}[e];if(!s||s.length===0)return t[0]||null;const n=t.filter(o=>{const l=(o.pooja_title||"").toLowerCase(),c=(o.pooja_title_english||"").toLowerCase();return l.includes("rashi")||c.includes("rashi")?!1:s.some(d=>l.includes(d.toLowerCase())||c.includes(d.toLowerCase()))});if(n.length===0)return null;const a=new Date;return a.setHours(0,0,0,0),(n.filter(o=>{const l=gu(o.schedule_date_ist);return l?l.getTime()>=a.getTime():!0})[0]??n[0])||null}const qv=({pujas:t,language:e="en",analytics:r})=>{const[s,n]=k.useState(0);if(k.useEffect(()=>{if(!t||t.length<=1)return;const y=setInterval(()=>{n(v=>v===t.length-1?0:v+1)},4e3);return()=>clearInterval(y)},[t]),!t||t.length===0)return null;const a=t[s],i=e?.toLowerCase().startsWith("hi"),o=vu(a,e),l=bu(a,e),c=wu(a.schedule_date_ist,e),d=xu(a,e),f=_u(a,e),p=()=>{n(y=>y===0?t.length-1:y-1)},h=()=>{n(y=>y===t.length-1?0:y+1)},g=()=>{r?.trackDoshaCalculatorResultBookCtaClicked?.({position:"puja_card",url:d,isOldDosha:!0}),window.open(d,"_blank","noopener,noreferrer")};return u.jsxs(dr,{className:"overflow-hidden hover:shadow-lg transition-shadow max-w-2xl mx-auto",children:[u.jsxs("div",{className:"relative",children:[u.jsx("button",{onClick:p,className:"absolute left-4 top-1/2 -translate-y-1/2 z-20 h-8 w-8 rounded-full bg-white/90 hover:bg-white flex items-center justify-center shadow-lg transition-all","aria-label":"Previous",children:u.jsx(Od,{className:"h-4 w-4 text-gray-800"})}),u.jsx("button",{onClick:h,className:"absolute right-4 top-1/2 -translate-y-1/2 z-20 h-8 w-8 rounded-full bg-white/90 hover:bg-white flex items-center justify-center shadow-lg transition-all","aria-label":"Next",children:u.jsx(Pd,{className:"h-4 w-4 text-gray-800"})}),f&&u.jsx("div",{className:"relative aspect-[16/9] w-full overflow-hidden bg-gradient-to-br from-orange-50 to-orange-100",children:u.jsx(Dr,{src:f,alt:o,className:"w-full h-full object-contain",loading:"lazy"})}),u.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2 z-10",children:t.map((y,v)=>u.jsx("button",{className:`h-2.5 rounded-full transition-all ${v===s?"w-8 bg-primary":"w-2.5 bg-white/60 hover:bg-white/80"}`,onClick:()=>n(v),"aria-label":`Go to slide ${v+1}`},v))})]}),u.jsxs("div",{className:"p-6 space-y-3 bg-white",children:[u.jsx("h3",{className:"font-bold text-xl text-gray-900",children:o}),a.temple_name&&u.jsx("p",{className:"text-base text-gray-600",children:l}),a.schedule_date_ist&&u.jsx("p",{className:"text-base font-medium text-gray-900",children:c}),a.individual_pack_price_inr>0&&u.jsx("p",{className:"text-lg font-bold text-primary",children:i?`₹${a.individual_pack_price_inr} से शुरू`:`Starting from ₹${a.individual_pack_price_inr}`}),u.jsxs(Br,{size:"lg",className:"book-puja-cta w-full h-14 text-lg font-bold",onClick:g,children:[i?"पूजा बुक करें":"Book Puja",u.jsx(Xi,{className:"ml-2 h-4 w-4"})]}),u.jsx("p",{className:"text-xs text-center text-gray-500",children:i?"श्री मंदिर द्वारा संचालित":"Powered by Sri Mandir"})]})]})};function ku(t){const e=[];let r="",s=!1;for(let n=0;n<t.length;n++){const a=t[n];a==='"'?s&&t[n+1]==='"'?(r+='"',n++):s=!s:a===","&&!s?(e.push(r),r=""):r+=a}return e.push(r),e.map(n=>n.trim().replace(/^"|"$/g,""))}function It(t,...e){const r=n=>n.trim().toLowerCase().replace(/[_\s]+/g," ").trim(),s=new Map;Object.entries(t).forEach(([n,a])=>s.set(r(n),a));for(const n of e){const a=s.get(r(n));if(a!==void 0&&a.trim())return a.trim()}return""}function Gv(t){const r=t.replace(/^\uFEFF/,"").replace(/\r\n?/g,`
158
158
  `).trim().split(`
159
- `);if(r.length<2)return[];const s=Cu(r[0]),n=[];for(let a=1;a<r.length;a++){const i=Cu(r[a]);if(i.length<s.length)continue;const o={};s.forEach((g,v)=>{o[g]=i[v]??""});const l=It(o,"store_id","store id"),c=It(o,"pooja_title","pooja title","puja title");if(!l||!c)continue;const u=It(o,"puja_link","puja link","pooja link")||It(o,"puja link","pooja link"),p=It(o,"schedule_date_ist","schedule date ist","schedule date"),f=parseFloat(It(o,"individual_pack_price_inr","individual pack price inr","price"))||0,h=It(o,"cover_media_url","cover media url","cover image"),y=It(o,"cover_media_url_english","cover media url english","cover image english");n.push({store_id:l,pooja_title:c,temple_name:It(o,"temple_name","temple name")||"",pooja_title_english:It(o,"pooja_title_english","pooja title english","puja title english"),temple_name_english:It(o,"temple_name_english","temple name english"),puja_link:u,puja_link_hindi:It(o,"puja_link_hindi","puja link hindi","pooja link hindi"),individual_pack_price_inr:f,schedule_date_ist:p,cover_media_url:h,cover_media_url_english:y})}return n}let un=[],Eu=0;const eb=3600*1e3,tb=async()=>{const t=Date.now();if(un.length>0&&t-Eu<eb)return un;try{const{data:e,error:r}=await Ei.functions.invoke("fetch-pujas");if(r)return console.warn("[fetchSriMandirPujas] Error:",r),un;const n=Qv(typeof e=="string"?e:"");return n.length>0&&(un=n,Eu=t),n}catch(e){return console.error("[fetchSriMandirPujas] Exception:",e),un}},rb=(t,e=10)=>t.slice(0,e);async function sb(t,e){const{visitorId:r,sessionId:s,problemStatements:n,language:a}=e;if(n.length!==0)try{await t.from("session_problem_statements").insert({visitor_id:r,session_id:s,problem_statements:n,language:a??"en"})}catch{}}async function nb(t,e,r){console.log("[invokeCalculateDosha] Calling Edge Function with payload:",{...e,name:e.name?"***":void 0});try{const{data:s,error:n}=await t.functions.invoke("calculate-dosha",{body:e,headers:r??{}});return console.log("[invokeCalculateDosha] Response:",{data:s,error:n}),n?(console.error("[invokeCalculateDosha] Error:",n),{success:!1,error:n.message||"Calculation failed"}):s&&typeof s=="object"&&"success"in s?s.success===!0?s:{success:!1,error:s.error??"Unknown error",details:s.details}:{success:!1,error:"Invalid response from server"}}catch(s){return console.error("[invokeCalculateDosha] Exception:",s),{success:!1,error:s instanceof Error?s.message:"Network error occurred"}}}async function ab(t,e,r={}){const{visitorId:s="unknown",sessionId:n="unknown",trackProblemStatements:a=!0,problemStatements:i=[],language:o="en"}=r;return a&&i.length>0&&await sb(t,{visitorId:s,sessionId:n,problemStatements:i,language:o}),nb(t,e,{"x-visitor-id":s,"x-session-id":n})}function ib({puja:t,doshaType:e,language:r,onBookClick:s,analytics:n}){const a=r?.toLowerCase().startsWith("hi"),i=wu(t,r),o=xu(t,r),l=_u(t.schedule_date_ist,r),c=ku(t,r),u=Su(t,r),p=async()=>{if(n?.trackDoshaCalculatorResultBookCtaClicked?.({position:"puja_card",url:c,isOldDosha:!0}),s)try{await s()}catch(f){console.error("Error in onBookClick:",f)}window.open(c,"_blank","noopener,noreferrer")};return d.jsx(dr,{className:"overflow-hidden hover:shadow-lg transition-shadow relative",children:d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"absolute -top-1 -left-1 z-10",children:d.jsx("span",{className:"inline-flex items-center px-2 py-1 text-[10px] font-medium bg-destructive/90 text-destructive-foreground rounded-br-md shadow-sm",children:a?"सीमित सीटें":"Limited Seats"})}),u&&d.jsx("div",{className:"relative aspect-[16/10] w-full overflow-hidden bg-muted",children:d.jsx(Dr,{src:u,alt:i,className:"w-full h-full object-contain",loading:"lazy"})}),d.jsxs(Ar,{className:"p-3 space-y-2",children:[d.jsx("h4",{className:"font-semibold text-sm line-clamp-2 text-card-foreground",children:i}),t.temple_name&&d.jsx("p",{className:"text-sm text-muted-foreground",children:o}),t.schedule_date_ist&&d.jsx("p",{className:"text-sm font-medium text-card-foreground",children:l}),t.individual_pack_price_inr>0&&d.jsx("p",{className:"text-base font-bold text-primary",children:a?`₹${t.individual_pack_price_inr} से शुरू`:`Starting from ₹${t.individual_pack_price_inr}`}),d.jsxs(Br,{size:"lg",className:"book-puja-cta w-full h-14 text-lg font-bold",onClick:async f=>{f.preventDefault(),await p()},children:[a?"पूजा बुक करें":"Book Puja",d.jsx(Xi,{className:"ml-1.5 h-3.5 w-3.5",size:14})]}),d.jsx("p",{className:"text-[10px] text-center text-muted-foreground",children:a?"श्री मंदिर द्वारा संचालित":"Powered by Sri Mandir"})]})]})})}const ob=Yh({problemArea:Fr().max(500,"Maximum 500 characters allowed").optional(),otherProblem:Fr().max(100,"Maximum 100 characters allowed").optional(),name:Fr().trim().min(1,"Name is required").max(100,"Name must be less than 100 characters"),gender:Jo(["M","F"],{required_error:"Gender is required",invalid_type_error:"Gender is required"}),date:Fr().min(1,"Date of birth is required"),time:Fr().optional().nullable(),unknownTime:Zh().default(!1),place:Fr().trim().min(1,"Birth place is required"),lat:Go().optional(),lon:Go().optional(),tz:Fr().optional(),chartStyle:Jo(["north","south"]).default("north").optional()}).superRefine((t,e)=>{t.time&&!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.time)&&e.addIssue({code:$.custom,path:["time"],message:"Invalid time format (HH:MM)"}),!t.unknownTime&&(!t.time||t.time.trim()==="")&&e.addIssue({code:$.custom,path:["time"],message:"Time of birth is required"})}),Tu=({analytics:t,googleMapsApiKey:e}={})=>{const r=U=>U.replace(/[^a-zA-Z\u0900-\u097F\s]/g,"").replace(/\s{2,}/g," "),{t:s}=Ls(),{predictions:n,isSearching:a,searchPlaces:i,getPlaceDetails:o,clearPredictions:l}=Gv({apiKey:e,language:Re.language||"en"}),[c,u]=k.useState(!1),[p,f]=k.useState(!1),[h,y]=k.useState(null),[g,v]=k.useState(null),[,C]=k.useState(null),[_,S]=k.useState(!1),[E,T]=k.useState(-1),[N,L]=k.useState(null),[ue,re]=k.useState([]),[je,Se]=k.useState(!0),F=(Re.language?Re.language.toLowerCase():"").startsWith("hi"),[X,W]=k.useState(new Set),[oe,ye]=k.useState(!1);k.useEffect(()=>{t?.trackDoshaCalculatorWebView?.(!0)},[t]),k.useEffect(()=>{(async()=>{Se(!0);const m=await tb();re(m),Se(!1)})()},[]);const ne=()=>{oe||(ye(!0),t?.trackFormFillInitiated?.(!0))},de=U=>{X.has(U)||(console.log(`[Analytics] Tracking form_field_filled: ${U}`),nt("form_field_filled",{page:"home",metadata:{field:U,variant:"v2",is_old_dosha:!0}}),Dm(U),W(m=>new Set(m).add(U)))},{register:G,handleSubmit:j,watch:z,setValue:Z,reset:se,clearErrors:he,trigger:le,formState:{errors:ae}}=bh({resolver:kh(ob),mode:"onSubmit",reValidateMode:"onChange",defaultValues:{unknownTime:!1,chartStyle:"north",place:""}}),ce=z("unknownTime"),tt=z("time"),Je=z("place"),Le=z("name"),ut=z("date"),qt=z("gender"),[lt,sr]=k.useState([]),[rt,Dt]=k.useState(!1),[ht,Gt]=k.useState(""),[Et,Jt]=k.useState(null);Le?.trim()||ut||tt||Je?.trim()||qt||lt.length>0;const Tt=!!(Le?.trim()&&qt&&ut&&Je?.trim()&&(ce||tt)),Lt=U=>{if(!U)return 0;const m=new Date(U),b=new Date;let x=b.getFullYear()-m.getFullYear();const A=b.getMonth()-m.getMonth();return(A<0||A===0&&b.getDate()<m.getDate())&&x--,x},ft=[{id:"marriage",en:"Marriage",hi:"शादी"},{id:"financial",en:"Money",hi:"पैसा"},{id:"health",en:"Health",hi:"स्वास्थ्य"},{id:"education",en:"Education",hi:"शिक्षा"},{id:"career",en:"Career",hi:"करियर"},{id:"other",en:"Others",hi:"अन्य"}],Pr=U=>{if(Lt(U)<18){const b=["marriage","financial","career","business"];if(lt.some(A=>b.includes(A)))return Jt(F?"कृपया उचित समस्या क्षेत्र चुनें। विवाह, वित्तीय, करियर और व्यापार संबंधी समस्याएं 18 वर्ष से अधिक आयु के उपयोगकर्ताओं के लिए हैं।":"Please select appropriate problem areas. Marriage, financial, career, and business-related issues are applicable for users above 18 years."),!1}return Jt(null),!0};k.useEffect(()=>{const U=Re.language?.startsWith("hi"),m=lt.filter(b=>b!=="other").map(b=>{const x=ft.find(A=>A.id===b);return x?U?x.hi:x.en:""}).filter(Boolean);rt&&ht.trim()&&m.push(ht.trim()),Z("problemArea",m.join("; ")),m.length>0&&de("problemArea")},[lt,ht,rt]);const Nr=U=>{Jt(null),U==="other"?(Dt(!rt),rt?(sr(m=>m.filter(b=>b!=="other")),Gt("")):sr(m=>[...m.filter(b=>b!=="other"),"other"])):sr(m=>m.includes(U)?m.filter(b=>b!==U):[...m,U])},qe=U=>{const m=r(U);if(N&&clearTimeout(N),m.length<2){l(),u(!1);return}const b=setTimeout(async()=>{await i(m),u(!0),T(-1)},300);L(b)},vt=async(U,m)=>{if(!e)return"Asia/Kolkata";try{const b=Math.floor(Date.now()/1e3),x=`https://maps.googleapis.com/maps/api/timezone/json?location=${U},${m}&timestamp=${b}&key=${e}`,P=await(await fetch(x)).json();return P.status==="OK"&&P.timeZoneId?P.timeZoneId:"Asia/Kolkata"}catch{return"Asia/Kolkata"}},Rr=async(U,m)=>{const b=r(m).trim(),x=await o(U);if(x){const A=await vt(x.lat,x.lng);Z("place",b),Z("lat",x.lat),Z("lon",x.lng),Z("tz",A),gs.success(s("dosha.locationSelected")),de("place"),t?.trackPlaceOfBirthChosen?.(b,!0)}else Z("place",b),gs.error(s("dosha.locationError","Could not get location coordinates. Please try again."));u(!1),l(),T(-1)},br=()=>{setTimeout(()=>{u(!1),T(-1)},200)},nr=U=>{if(!(!c||n.length===0))switch(U.key){case"ArrowDown":U.preventDefault(),T(m=>m<n.length-1?m+1:m);break;case"ArrowUp":U.preventDefault(),T(m=>m>0?m-1:-1);break;case"Enter":if(E>=0&&E<n.length){U.preventDefault();const m=n[E];Rr(m.place_id,m.description)}else u(!1),T(-1);break;case"Escape":u(!1),T(-1);break}},As=async U=>{if(!Pr(U.date))return;Tt?t?.trackFloatingCtaClicked?.(fa.all_fields_filled,!0):t?.trackFloatingCtaClicked?.(fa.fields_not_filled,!0);const m=lt.includes("marriage")?"marriage":lt[0]||"",b={...U,name:U.name.trim(),gender:U.gender,problemArea:m};nt("calculate_dosha_clicked",{metadata:{hasTime:!b.unknownTime,place:b.place,date:b.date,variant:"v2",is_old_dosha:!0}}),Lm(),f(!0);try{const x=localStorage.getItem("analytics_visitor_id")||"unknown",A=localStorage.getItem("analytics_session_id")||"unknown",P=lt.filter(ve=>ve!=="other").map(ve=>{const $e=ft.find(st=>st.id===ve);return $e?Re.language?.startsWith("hi")?$e.hi:$e.en:ve});rt&&ht.trim()&&P.push(ht.trim());const I={name:b.name,gender:b.gender,date:b.date,time:b.unknownTime?"":b.time||"12:00",unknownTime:b.unknownTime,place:b.place,lat:b.lat??28.6139,lon:b.lon??77.209,tz:b.tz||"Asia/Kolkata",problemArea:m},M=await ab(Ei,I,{visitorId:x,sessionId:A,trackProblemStatements:P.length>0,problemStatements:P,language:Re.language?.startsWith("hi")?"hi":"en"});if(!M.success)throw new Error(M.error||"Calculation failed");const R={...M,summary:{...M.summary||{}}};if(!R.summary.shaniSadeSati&&(R.summary.sadeSati&&(R.summary.shaniSadeSati=R.summary.sadeSati==="active"?"active":"inactive"),R.summary.sadeSatiPhase&&R.summary.shaniPhase==null)){const ve=String(R.summary.sadeSatiPhase);R.summary.shaniPhase=ve.includes("RISING")?1:ve.includes("PEAK")?2:ve.includes("SETTING")?3:null}y(R);const[J,ee,_e]=I.date.split("-").map(Number),[Ze,te]=(I.time||"12:00").split(":").map(Number);let we=5.5;if(I.tz)try{const ve=new Date,$e=new Date(ve.toLocaleString("en-US",{timeZone:"UTC"}));we=(new Date(ve.toLocaleString("en-US",{timeZone:I.tz})).getTime()-$e.getTime())/(1e3*60*60)}catch(ve){console.warn("[DoshaCalculatorV2] Failed to calculate timezone offset:",ve)}v({day:_e,month:ee,year:J,hour:Ze,minute:te,lat:I.lat,lon:I.lon,tzone:we}),S(!0),sessionStorage.setItem("dosha_calculated","true"),gs.success(s("dosha.calculationSuccess")),nt("dosha_calculate",{metadata:{calculation_id:R.calculationId,name:I.name,gender:I.gender,date_of_birth:I.date,time_of_birth:I.time||null,place_of_birth:I.place,problem_area:I.problemArea||null,hasTime:!I.unknownTime,variant:"v2",is_old_dosha:!0,doshas_found:{mangal:R.summary?.mangal,kaalSarp:R.summary?.kaalSarp,pitra:R.summary?.pitra,shaniSadeSati:R.summary?.shaniSadeSati}}}),R.calculationId&&C(R.calculationId)}catch(x){console.error("Calculation error:",x),console.error("Error details:",{message:x instanceof Error?x.message:"Unknown error",stack:x instanceof Error?x.stack:void 0,type:x?.constructor?.name});const A=x instanceof Error?x.message:String(x),P=A.toLowerCase().includes("cors")||A.toLowerCase().includes("network")||A.toLowerCase().includes("fetch");nt("dosha_calculate_unsuccessful",{metadata:{error:A,isCorsError:P,place:b.place,date:b.date,hasTime:!b.unknownTime,variant:"v2",is_old_dosha:!0}}),P?gs.error(F?"कनेक्शन त्रुटि। कृपया अपना इंटरनेट कनेक्शन जांचें और पुनः प्रयास करें।":"Connection error. Please check your internet connection and try again."):gs.error(s("dosha.calculationError"))}finally{f(!1)}};return d.jsxs("div",{className:"container mx-auto px-4 max-w-2xl mb-12",children:[!h&&d.jsxs("div",{className:"text-center mb-6 pt-4",children:[d.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"#1F2937",fontFamily:'"Plus Jakarta Sans", sans-serif'},children:F?"मुफ़्त में पूजा उपाय खोजें":"Find Puja Remedy for Free"}),d.jsx("p",{className:"text-sm leading-relaxed",style:{color:"#6B7280",fontFamily:'"Plus Jakarta Sans", sans-serif'},children:F?"अपनी कुंडली का विश्लेषण करें और पता लगाएं कि आपके वैदिक चार्ट में कौन से दोष (यदि कोई हो) दिखाई देते हैं—और भक्तिपूर्ण उपचार देखें।":"Analyse your kundli to find out which doshas (if any) appear in your Vedic chart—and see devotional remedies."})]}),d.jsx(yp,{open:!_,onOpenChange:U=>S(!U),children:d.jsx(vp,{children:d.jsxs("form",{id:"dosha-form",onSubmit:j(As,U=>{console.log("[Form] Validation errors:",U);const m=U.place?.message||U.time?.message||U.date?.message||Object.values(U)[0]?.message||s("dosha.formError","Please correct the highlighted fields");gs.error(m)}),style:{display:"flex",width:"100%",margin:"0 auto",padding:"16px",flexDirection:"column",alignItems:"center",gap:"20px",borderRadius:"16px",border:"1px solid #F3F4F6",background:"#FFF"},children:[d.jsxs("div",{className:"space-y-2 w-full",onFocusCapture:()=>{ne(),t?.trackNameSectionClicked?.()},children:[d.jsxs(Vr,{htmlFor:"name",className:"text-base font-medium text-foreground",children:[F?"नाम":"Name",d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(ds,{id:"name",type:"text",...G("name",{onChange:U=>{U.target.value&&(de("name"),t?.trackNameSectionFilled?.())}}),placeholder:F?"अपना नाम दर्ज करें":"Enter your name",className:"min-h-[48px] text-base dosha-input placeholder:text-[#6B7280] focus-visible:ring-0 focus-visible:ring-offset-0",style:{backgroundColor:"#FFF",color:"#000",border:"1px solid #E1561F"},required:!0,maxLength:100}),ae.name&&d.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[d.jsx($s,{className:"w-4 h-4"}),ae.name.message]})]}),d.jsxs("div",{className:"space-y-2 w-full",children:[d.jsxs(Vr,{className:"text-base font-medium text-foreground flex items-center gap-2",children:[d.jsx(Kd,{className:"w-4 h-4"}),F?"लिंग":"Gender",d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsxs("div",{className:"flex items-center gap-6",children:[d.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[d.jsx("input",{type:"radio",...G("gender",{onChange:()=>{ne(),de("gender")}}),value:"M",className:"w-4 h-4 border border-gray-300",style:{accentColor:"#F75E22"}}),d.jsx("span",{className:"text-sm text-foreground",children:F?"पुरुष":"Male"})]}),d.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[d.jsx("input",{type:"radio",...G("gender",{onChange:()=>{ne(),de("gender")}}),value:"F",className:"w-4 h-4 border border-gray-300",style:{accentColor:"#F75E22"}}),d.jsx("span",{className:"text-sm text-foreground",children:F?"महिला":"Female"})]})]}),ae.gender&&d.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[d.jsx($s,{className:"w-4 h-4"}),ae.gender.message]})]}),d.jsxs("div",{className:"space-y-2 w-full",children:[d.jsxs(Vr,{className:"text-base font-medium text-foreground",children:[F?"आपके जीवन की सबसे बड़ी समस्याएं कौन सी हैं?":"Which are the biggest problem areas in your life?",d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx("p",{className:"text-xs",style:{color:"#735743"},children:F?"आप 1 से अधिक चुन सकते हैं":"You can choose more than 1"}),d.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px"},children:ft.map(U=>{const m=lt.includes(U.id);return d.jsx("button",{type:"button",onClick:()=>Nr(U.id),style:{display:"flex",height:"40px",padding:"8px 14px",justifyContent:"center",alignItems:"center",gap:"10px",borderRadius:"8px",border:"1px solid #F75E22",backgroundColor:m?"#F75E22":"transparent",color:m?"#FFFFFF":"#502D14",fontFamily:'"Plus Jakarta Sans", sans-serif',fontSize:"14px",fontWeight:500,transition:"all 0.2s ease"},children:F?U.hi:U.en},U.id)})}),rt&&d.jsxs("div",{className:"space-y-1",children:[d.jsx(ds,{type:"text",value:ht,onChange:U=>{U.target.value.length<=100&&Gt(U.target.value)},placeholder:F?"कृपया अपनी समस्या बताएं":"Please describe your problem",className:"min-h-[48px] text-base dosha-input placeholder:text-[#6B7280] focus-visible:ring-0 focus-visible:ring-offset-0",style:{backgroundColor:"#F9FAFB",color:"#000",border:"1px solid #E1561F"},maxLength:100}),d.jsx("p",{className:"text-xs text-muted-foreground",children:F?"अधिकतम 100 अक्षर":"Max 100 characters"})]}),ae.problemArea&&d.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[d.jsx($s,{className:"w-4 h-4"}),ae.problemArea.message]})]}),d.jsxs("div",{className:"w-full",style:{display:"flex",flexDirection:"column",gap:"20px"},children:[d.jsxs("div",{children:[d.jsxs(Vr,{className:"text-base font-medium text-foreground",children:[F?"अपनी जन्म विवरण दर्ज करें":"Enter Your Birth Details",d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx("p",{className:"text-xs mt-1",style:{color:"#735743"},children:F?"यह आपकी जन्म कुंडली में ग्रहों की सटीक स्थिति की गणना करने में मदद करता है।":"This helps calculate the exact planetary position in your birth chart."})]}),d.jsx(Om,{value:z("date"),onChange:U=>{ne(),Z("date",U),le("date"),de("date"),t?.trackDobFilled?.(!0)},onOpen:()=>{ne(),t?.trackDobClicked?.(!0)},error:ae.date?.message}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Im,{value:z("time")||"",onChange:U=>{ne(),Z("time",U),le("time"),de("time"),t?.trackTimeFilled?.(!0)},onOpen:()=>{ne(),t?.trackTimeClicked?.(!0)},disabled:ce,error:ae.time?.message}),d.jsxs("div",{className:"gap-2 flex items-end justify-start",children:[d.jsx("input",{type:"checkbox",id:"unknownTime",checked:ce,onChange:U=>{ne(),t?.trackTimeCheckboxClicked?.(!0),Z("unknownTime",U.target.checked),U.target.checked?(Z("time",""),he("time")):le("time")},className:"w-5 h-5 mt-0.5 rounded cursor-pointer appearance-none border-2 border-gray-400 checked:bg-orange-500 checked:border-orange-500 relative checked:after:content-['✓'] checked:after:text-white checked:after:absolute checked:after:inset-0 checked:after:flex checked:after:items-center checked:after:justify-center checked:after:text-sm checked:after:font-bold"}),d.jsx(Vr,{htmlFor:"unknownTime",className:"text-base cursor-pointer text-[#374151]",children:F?"मुझे अपने जन्म का समय नहीं पता":"I don't know my birth time"})]}),d.jsx("p",{className:"text-xs",style:{color:"#735743"},children:F?"नोट - जन्म का सटीक समय न होने पर सटीकता कम हो जाएगी। हम केवल चंद्रमा आधारित जाँच ही करेंगे।":"Note - Without exact birth time, accuracy will be reduced. We'll run Moon-based checks only."})]})]}),d.jsxs("div",{className:"space-y-2 relative w-full",onFocusCapture:()=>{ne(),t?.trackPlaceOfBirthClicked?.(!0)},children:[d.jsxs(Vr,{className:"text-base font-medium text-foreground",children:[F?"जन्म स्थान (शहर)":"Place of Birth (City)",d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsxs("div",{className:"relative",children:[d.jsx(ds,{id:"place",...G("place",{onChange:U=>{const m=r(U.target.value);m!==U.target.value&&(U.target.value=m),Z("place",m,{shouldValidate:!0}),qe(m)}}),placeholder:F?"उदाहरण: जयपुर, मुंबई, वाराणसी":"e.g. Jaipur, Mumbai, Varanasi",className:"min-h-[48px] text-base pr-10 dosha-input placeholder:text-[#6B7280] focus-visible:ring-0 focus-visible:ring-offset-0",style:{backgroundColor:"#FFF",color:"#000",border:"1px solid #E1561F"},onKeyDown:nr,onBlur:br,autoComplete:"off"}),d.jsx(Fd,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-5 h-5 pointer-events-none",style:{color:"#F75E22"}})]}),c&&n.length>0&&d.jsx("div",{className:"absolute z-10 w-full mt-1 bg-card border border-border rounded-md shadow-lg max-h-60 overflow-auto",children:n.map((U,m)=>d.jsxs("button",{type:"button",className:`w-full text-left px-4 py-3 hover:bg-accent transition-colors ${m===E?"bg-accent":""}`,onClick:()=>Rr(U.place_id,U.description),children:[d.jsx("div",{className:"text-sm font-medium",children:U.structured_formatting?.main_text}),d.jsx("div",{className:"text-xs text-muted-foreground",children:U.structured_formatting?.secondary_text})]},U.place_id))}),a&&d.jsx("div",{className:"absolute right-3 top-9",children:d.jsx(Qi,{className:"w-4 h-4 animate-spin text-muted-foreground"})}),ae.place&&d.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[d.jsx($s,{className:"w-4 h-4"}),ae.place.message]})]}),Et&&d.jsx("div",{className:"p-3 bg-destructive/10 border border-destructive/30 rounded-lg",children:d.jsxs("p",{className:"text-sm text-destructive flex items-start gap-2",children:[d.jsx($s,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),Et]})}),d.jsx(Br,{type:"submit",disabled:p,className:"w-full h-[48px] text-base font-semibold text-white",style:{borderRadius:"8px",background:"radial-gradient(142.71% 142.71% at 50% -42.71%, #F99724 0%, #E1561F 100%)",boxShadow:"0 4px 12px rgba(225, 86, 31, 0.3)"},children:p?d.jsxs(d.Fragment,{children:[d.jsx(Qi,{className:"mr-2 h-5 w-5 animate-spin"}),F?"गणना हो रही है...":"Calculating..."]}):F?"मेरे दोषों की गणना करें":"Calculate My Doshas"})]})})}),h&&d.jsx(Am,{result:h,t:s,onEdit:()=>{S(!1),window.scrollTo({top:0,behavior:"smooth"})},className:"mt-8",birthDetails:g,supabase:Ei,language:Re.language||"en",isLoadingPujas:je,problemArea:z("problemArea")||"",problemAreaIds:lt,customProblemText:ht,kundaliSectionId:"kundali-chart-section",analytics:t,renderPujaCard:U=>{const m=Yv(ue,U);return m?d.jsx(ib,{puja:m,doshaType:U,language:Re.language||"en",analytics:t}):null}}),ue.length>0&&d.jsxs("div",{className:"mt-8 space-y-4 w-full max-w-4xl mx-auto",children:[d.jsxs("div",{className:"text-center",children:[d.jsx("h2",{className:"text-2xl sm:text-3xl font-bold gradient-spiritual bg-clip-text text-transparent",children:F?"श्री मंदिर द्वारा पूजा उपाय":"Sri Mandir Puja Remedies"}),d.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:F?"अपने दोषों के लिए प्रभावी पूजा उपाय देखें":"Explore effective puja remedies for your doshas"})]}),d.jsx(Xv,{pujas:rb(ue,10),doshaType:"all",language:Re.language||"en",formData:{name:z("name")||"",gender:z("gender")||"",dateOfBirth:z("date")||"",timeOfBirth:z("time")||null,placeOfBirth:z("place")||"",problemArea:z("problemArea")||""},variant:"v1",analytics:t})]})]})},lb="https://srm-cdn.a4b.io/yoda/1771903456293.png",cb="https://srm-cdn.a4b.io/yoda/1771903492301.png",ub="https://srm-cdn.a4b.io/yoda/1770639330970.png",db="https://srm-cdn.a4b.io/yoda/1770639293055.png",hb="https://srm-cdn.a4b.io/yoda/1770639358174.png",fb="https://srm-cdn.a4b.io/yoda/1770639427379.png",pb="https://srm-cdn.a4b.io/yoda/1770639381899.png",Ti=[{id:1,name:"Karthik Nair",location:"Kochi",stars:4,review:{en:"The Dosha Calculator accurately detected Mangal Dosha in my kundli which my family pandit had also confirmed years ago. I booked the recommended puja and within months my delayed marriage finally happened. Truly life-changing tool.",hi:"दोष कैलकुलेटर ने मेरी कुंडली में मंगल दोष का सही पता लगाया जिसे मेरे परिवार के पंडित ने भी वर्षों पहले पुष्टि की थी। मैंने अनुशंसित पूजा बुक की और कुछ महीनों में मेरी देर से हो रही शादी आखिरकार हो गई। सच में जीवन बदलने वाला टूल।"}},{id:2,name:"Priya Verma",location:"Delhi",stars:5,review:{en:"I was skeptical at first but the Dosha Calculator found Shani Sade Sati which explained all my career struggles. The Shani puja they recommended brought such positive changes within weeks. The accuracy of this tool is remarkable and the remedies actually work.",hi:"मुझे पहले संदेह था लेकिन दोष कैलकुलेटर ने शनि साढ़े साती का पता लगाया जिसने मेरी सभी करियर समस्याओं को समझाया। उनकी अनुशंसित शनि पूजा ने कुछ हफ्तों में ऐसे सकारात्मक बदलाव लाए। इस टूल की सटीकता उल्लेखनीय है और उपाय वास्तव में काम करते हैं।"}},{id:3,name:"Venkatesh Iyer",location:"Chennai",stars:4,review:{en:"Finally found out why I was facing so many obstacles in life - the calculator detected Kaal Sarp Dosha. After doing the recommended puja at Trimbakeshwar, my business started improving. This tool saved me from visiting multiple astrologers.",hi:"आखिरकार पता चला कि मैं जीवन में इतनी बाधाओं का सामना क्यों कर रहा था - कैलकुलेटर ने काल सर्प दोष का पता लगाया। त्र्यंबकेश्वर में अनुशंसित पूजा करने के बाद, मेरा व्यवसाय सुधरने लगा। इस टूल ने मुझे कई ज्योतिषियों के पास जाने से बचाया।"}},{id:4,name:"Neha Agarwal",location:"Varanasi",stars:5,review:{en:"The Dosha Calculator detected Pitra Dosha in my chart which no one had told me before. The detailed explanation helped me understand why our family was facing health issues. After the Pishach Mochan puja, things have improved significantly. Highly recommend this tool.",hi:"दोष कैलकुलेटर ने मेरी कुंडली में पितृ दोष का पता लगाया जो मुझे पहले किसी ने नहीं बताया था। विस्तृत व्याख्या ने मुझे समझने में मदद की कि हमारा परिवार स्वास्थ्य समस्याओं का सामना क्यों कर रहा था। पिशाच मोचन पूजा के बाद, चीजें काफी सुधर गई हैं। इस टूल की अत्यधिक सिफारिश करता हूं।"}},{id:5,name:"Lakshmi Menon",location:"Bangalore",stars:4,review:{en:"Such an easy and accurate tool to check doshas in your kundli. It found multiple doshas and suggested specific pujas for each one. The remedies have brought peace and prosperity to my family. Best kundli analysis I have ever used online.",hi:"अपनी कुंडली में दोष जांचने के लिए इतना आसान और सटीक टूल। इसने कई दोष खोजे और प्रत्येक के लिए विशिष्ट पूजा सुझाई। उपायों ने मेरे परिवार में शांति और समृद्धि लाई है। सबसे अच्छा कुंडली विश्लेषण जो मैंने कभी ऑनलाइन उपयोग किया है।"}}],mb={1:ub,2:db,3:hb,4:fb,5:pb};function Au(){const{i18n:t}=Ls(),e=(t.language||"").toLowerCase().startsWith("hi"),r=[...Ti,...Ti,...Ti];return d.jsxs("div",{className:"w-full py-8 sm:py-12 overflow-hidden",style:{backgroundColor:"#FFF8E1"},children:[d.jsx("div",{className:"container mx-auto px-4 sm:px-6 max-w-4xl",children:d.jsxs("div",{className:"text-center mb-6",children:[d.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[d.jsx(Dr,{src:lb,alt:"",className:"w-20 h-3",width:80,height:12,loading:"lazy"}),d.jsx("h2",{className:"text-[18px] font-semibold text-foreground whitespace-nowrap",children:e?"हमारे भक्त क्या कहते हैं":"What Our Devotees Say"}),d.jsx(Dr,{src:cb,alt:"",className:"w-20 h-3",width:80,height:12,loading:"lazy"})]}),d.jsx("p",{className:"text-[16px] font-medium text-[#502D14]",children:e?"भारत भर के हज़ारों परिवारों का भरोसा":"Trusted by thousands of families across India"})]})}),d.jsx("div",{className:"relative w-full overflow-hidden",children:d.jsx("div",{className:"flex w-max animate-marquee-fast gap-4 px-4",children:r.map((s,n)=>d.jsxs("div",{style:{display:"flex",minWidth:"280px",maxWidth:"280px",padding:"16px",flexDirection:"column",justifyContent:"space-between",alignItems:"flex-start",gap:"12px",flexShrink:0,borderRadius:"8px",background:"#FFF2CF"},children:[d.jsxs("p",{className:"text-[12px] font-medium text-[#1D2125] leading-relaxed",children:['"',e?s.review.hi:s.review.en,'"']}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("div",{className:"w-8 h-8 rounded-full bg-white/60 flex items-center justify-center flex-shrink-0 overflow-hidden",children:d.jsx(Dr,{src:mb[s.id],alt:`${s.name} review avatar`,width:32,height:32,className:"w-full h-full object-cover rounded-full",loading:"lazy"})}),d.jsxs("div",{children:[d.jsxs("span",{className:"text-sm font-medium text-foreground block",children:[s.name,", ",s.location]}),d.jsx("div",{className:"flex gap-0.5 mt-0.5",children:[...Array(5)].map((a,i)=>d.jsx(Bd,{className:"w-3 h-3",fill:i<s.stars?"#FACC15":"#D1D5DB",color:i<s.stars?"#FACC15":"#D1D5DB"},i))})]})]})]},`${s.id}-${n}`))})})]})}function ju(){const{i18n:t}=Ls(),r=(t.language||"").toLowerCase().startsWith("hi")?["3 करोड़+ ऐप डाउनलोड","30 लाख+ परिवारों द्वारा विश्वसनीय","1000+ पंडितों का नेटवर्क","प्रमाणित वैदिक पूजाएं"]:["3 Crore+ App Downloads","Trusted by 30 Lakh+ Families","1000+ Pandits Network","Certified Vedic Pujas"],s=[...r,...r,...r];return d.jsx("div",{className:"w-full overflow-hidden py-3",style:{background:"#F75E22"},children:d.jsx("div",{className:"flex w-max animate-marquee",children:s.map((n,a)=>d.jsxs("span",{className:"mx-6 text-sm font-medium text-white inline-flex items-center gap-2 whitespace-nowrap",children:[d.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white/80"}),n]},a))})})}function Ou(){const{t}=Ls();return d.jsx("footer",{className:"bg-orange-500 text-white pt-8 sm:pt-12 pb-6 sm:pb-8",children:d.jsxs("div",{className:"container mx-auto px-4 sm:px-6",children:[d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6 sm:gap-8 mb-6 sm:mb-8",children:[d.jsxs("div",{className:"md:col-span-2",children:[d.jsx(Dr,{src:"https://srm-cdn.a4b.io/yoda/1771903635316.png",alt:"Sri Mandir",className:"h-12 sm:h-16 w-auto mb-3 sm:mb-4",width:228,height:84,loading:"lazy"}),d.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:t("footer.description")})]}),d.jsxs("div",{className:"md:ml-8",children:[d.jsx("h3",{className:"font-semibold text-base sm:text-lg mb-3 sm:mb-4",children:t("footer.company")}),d.jsxs("ul",{className:"space-y-2 sm:space-y-3",children:[d.jsx("li",{children:d.jsx("a",{href:"https://www.srimandir.com/aboutus",target:"_blank",rel:"noopener noreferrer",className:"text-sm sm:text-base hover:underline min-h-[44px] flex items-center",onClick:()=>nt("footer_link_clicked",{metadata:{link:"about_us",url:"https://www.srimandir.com/aboutus"}}),children:t("footer.aboutUs")})}),d.jsx("li",{children:d.jsx("a",{href:"https://www.srimandir.com/contact-us",target:"_blank",rel:"noopener noreferrer",className:"text-sm sm:text-base hover:underline min-h-[44px] flex items-center",onClick:()=>nt("footer_link_clicked",{metadata:{link:"contact_us",url:"https://www.srimandir.com/contact-us"}}),children:t("footer.contactUs")})})]})]}),d.jsxs("div",{className:"md:ml-4",children:[d.jsx("h3",{className:"font-semibold text-base sm:text-lg mb-3 sm:mb-4",children:t("footer.ourServices")}),d.jsxs("ul",{className:"space-y-1.5 sm:space-y-2",children:[d.jsx("li",{children:d.jsx("span",{className:"text-sm sm:text-base",children:t("footer.services.puja")})}),d.jsx("li",{children:d.jsx("span",{className:"text-sm sm:text-base",children:t("footer.services.chadhava")})}),d.jsx("li",{children:d.jsx("span",{className:"text-sm sm:text-base",children:t("footer.services.panchang")})}),d.jsx("li",{children:d.jsx("span",{className:"text-sm sm:text-base",children:t("footer.services.temples")})})]}),d.jsx("h3",{className:"font-semibold text-base sm:text-lg mb-3 sm:mb-4 mt-6 sm:mt-8",children:t("footer.ourAddress")}),d.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:t("footer.address")})]})]}),d.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center border-t border-orange-400 pt-6 sm:pt-8 gap-6",children:[d.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4 w-full sm:w-auto",children:[d.jsxs("a",{href:"https://play.google.com/store/apps/details?id=com.mandir&pli=1",target:"_blank",rel:"noopener noreferrer",className:"bg-black text-white px-4 py-3 sm:py-2 rounded-lg flex items-center gap-2 hover:bg-gray-800 transition-colors w-full sm:w-auto justify-center min-h-[48px]",onClick:()=>nt("app_download_clicked",{metadata:{platform:"google_play"}}),children:[d.jsx("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M3,20.5V3.5C3,2.91 3.34,2.39 3.84,2.15L13.69,12L3.84,21.85C3.34,21.61 3,21.09 3,20.5M16.81,15.12L6.05,21.34L14.54,12.85L16.81,15.12M20.16,10.81C20.5,11.08 20.75,11.5 20.75,12C20.75,12.5 20.53,12.9 20.18,13.18L17.89,14.5L15.39,12L17.89,9.5L20.16,10.81M6.05,2.66L16.81,8.88L14.54,11.15L6.05,2.66Z"})}),d.jsxs("div",{className:"text-xs",children:[d.jsx("div",{children:"GET IT ON"}),d.jsx("div",{className:"font-semibold",children:"Google Play"})]})]}),d.jsxs("a",{href:"https://apps.apple.com/in/app/sri-mandir-puja-chadhava/id1637621461",target:"_blank",rel:"noopener noreferrer",className:"bg-black text-white px-4 py-3 sm:py-2 rounded-lg flex items-center gap-2 hover:bg-gray-800 transition-colors w-full sm:w-auto justify-center min-h-[48px]",onClick:()=>nt("app_download_clicked",{metadata:{platform:"app_store"}}),children:[d.jsx("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M18.71,19.5C17.88,20.74 17,21.95 15.66,21.97C14.32,22 13.89,21.18 12.37,21.18C10.84,21.18 10.37,21.95 9.1,22C7.79,22.05 6.8,20.68 5.96,19.47C4.25,17 2.94,12.45 4.7,9.39C5.57,7.87 7.13,6.91 8.82,6.88C10.1,6.86 11.32,7.75 12.11,7.75C12.89,7.75 14.37,6.68 15.92,6.84C16.57,6.87 18.39,7.1 19.56,8.82C19.47,8.88 17.39,10.17 17.41,12.63C17.44,15.65 20.06,16.66 20.09,16.67C20.06,16.74 19.67,18.11 18.71,19.5M13,3.5C13.73,2.67 14.94,2.04 15.94,2C16.07,3.17 15.6,4.35 14.9,5.19C14.21,6.04 13.07,6.7 11.95,6.61C11.8,5.46 12.36,4.26 13,3.5Z"})}),d.jsxs("div",{className:"text-xs",children:[d.jsx("div",{children:"Download on the"}),d.jsx("div",{className:"font-semibold",children:"App Store"})]})]})]}),d.jsxs("div",{className:"flex flex-wrap justify-center gap-3 sm:gap-4 w-full sm:w-auto",children:[d.jsx("a",{href:"https://www.youtube.com/@srimandirofficial",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"youtube"}}),children:d.jsx(zd,{size:20})}),d.jsx("a",{href:"https://www.instagram.com/sri.mandir",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"instagram"}}),children:d.jsx($d,{size:20})}),d.jsx("a",{href:"https://www.linkedin.com/company/appsforbharat/posts/?feedView=all",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"linkedin"}}),children:d.jsx(Md,{size:20})}),d.jsx("a",{href:"https://api.whatsapp.com/send?phone=7829661119",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"whatsapp"}}),children:d.jsx(Ud,{size:20})}),d.jsx("a",{href:"https://x.com/SriMandir_App",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"twitter"}}),children:d.jsx(Vd,{size:20})}),d.jsx("a",{href:"https://www.facebook.com/srimandirapp",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"facebook"}}),children:d.jsx(Dd,{size:20})})]})]}),d.jsxs("div",{className:"border-t border-orange-400 pt-4 sm:pt-6 mt-6 text-center",children:[d.jsxs("div",{className:"flex flex-col sm:flex-row justify-center items-center gap-3 sm:gap-4 text-sm sm:text-base",children:[d.jsx("a",{href:"https://www.srimandir.com/privacy-policy",target:"_blank",rel:"noopener noreferrer",className:"hover:underline min-h-[44px] flex items-center",onClick:()=>nt("footer_link_clicked",{metadata:{link:"privacy_policy",url:"https://www.srimandir.com/privacy-policy"}}),children:t("footer.privacyPolicy")}),d.jsx("span",{className:"hidden sm:inline",children:"•"}),d.jsx("a",{href:"https://www.srimandir.com/terms-of-use",target:"_blank",rel:"noopener noreferrer",className:"hover:underline min-h-[44px] flex items-center",onClick:()=>nt("footer_link_clicked",{metadata:{link:"terms_of_use",url:"https://www.srimandir.com/terms-of-use"}}),children:t("footer.terms")})]}),d.jsx("p",{className:"text-sm sm:text-base mt-3 sm:mt-4 opacity-80",children:t("footer.copyright")})]})]})})}const Pu=({analytics:t,googleMapsApiKey:e,isGlobal:r}={})=>(k.useEffect(()=>{const s=Uu();nt("page_view",{page:"home",metadata:{variant:"v2",is_old_dosha:!0,...s,referrer:document.referrer||void 0,landing_page:window.location.pathname+window.location.search}});const n={root:null,rootMargin:"0px",threshold:.5},a=l=>{l.forEach(c=>{if(c.isIntersecting){const u=c.target.getAttribute("data-section");u&&t?.trackDoshaSectionImpression?.({section:u,timestamp:new Date().toISOString(),is_old_dosha:!0})}})},i=new IntersectionObserver(a,n),o=setTimeout(()=>{document.querySelectorAll("[data-section]").forEach(c=>i.observe(c))},100);return()=>{clearTimeout(o),i.disconnect()}},[t]),d.jsx("div",{className:"min-h-screen relative",style:{backgroundColor:"#FFFCEF"},children:d.jsxs("div",{className:"relative z-10",children:[d.jsx(eo,{analytics:t,isGlobal:r}),d.jsx("div",{"data-section":"form",children:d.jsx(Tu,{analytics:t,googleMapsApiKey:e})}),d.jsx("div",{"data-section":"testimonials",children:d.jsx(Au,{})}),d.jsx("div",{"data-section":"trust-bar",children:d.jsx(ju,{})}),d.jsx("div",{"data-section":"footer",children:d.jsx(Ou,{})})]})})),gb=t=>{const[e,r]=k.useState("control"),[s,n]=k.useState(!0);return k.useEffect(()=>{r("v2"),n(!1)},[t]),{variant:e,isLoading:s}},yb={},vb=()=>{const{isLoading:t}=gb(yb.HOME_UI);return t?d.jsx("div",{className:"min-h-screen bg-background",children:d.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-2xl",children:[d.jsx("div",{className:"flex justify-center mb-6",children:d.jsx(hr,{className:"h-16 w-48"})}),d.jsx(hr,{className:"h-10 w-full mb-4"}),d.jsx(hr,{className:"h-6 w-3/4 mx-auto mb-8"}),d.jsxs("div",{className:"space-y-4",children:[d.jsx(hr,{className:"h-12 w-full"}),d.jsx(hr,{className:"h-12 w-full"}),d.jsx(hr,{className:"h-12 w-full"}),d.jsx(hr,{className:"h-12 w-full"}),d.jsx(hr,{className:"h-14 w-full rounded-full"})]})]})}):d.jsx(Pu,{})};Ae.DoshaCalculatorV2=Tu,Ae.FLOATING_CTA_STATUS=fa,Ae.Footer=Ou,Ae.HeaderV2=eo,Ae.HomePageExperiment=vb,Ae.IndexV2=Pu,Ae.TestimonialsV2=Au,Ae.TrustBarV2=ju,Object.defineProperty(Ae,Symbol.toStringTag,{value:"Module"})}));
159
+ `);if(r.length<2)return[];const s=ku(r[0]),n=[];for(let a=1;a<r.length;a++){const i=ku(r[a]);if(i.length<s.length)continue;const o={};s.forEach((y,v)=>{o[y]=i[v]??""});const l=It(o,"store_id","store id"),c=It(o,"pooja_title","pooja title","puja title");if(!l||!c)continue;const d=It(o,"puja_link","puja link","pooja link")||It(o,"puja link","pooja link"),f=It(o,"schedule_date_ist","schedule date ist","schedule date"),p=parseFloat(It(o,"individual_pack_price_inr","individual pack price inr","price"))||0,h=It(o,"cover_media_url","cover media url","cover image"),g=It(o,"cover_media_url_english","cover media url english","cover image english");n.push({store_id:l,pooja_title:c,temple_name:It(o,"temple_name","temple name")||"",pooja_title_english:It(o,"pooja_title_english","pooja title english","puja title english"),temple_name_english:It(o,"temple_name_english","temple name english"),puja_link:d,puja_link_hindi:It(o,"puja_link_hindi","puja link hindi","pooja link hindi"),individual_pack_price_inr:p,schedule_date_ist:f,cover_media_url:h,cover_media_url_english:g})}return n}let cn=[],Su=0;const Jv=3600*1e3,Zv=async()=>{const t=Date.now();if(cn.length>0&&t-Su<Jv)return cn;try{const{data:e,error:r}=await Ei.functions.invoke("fetch-pujas");if(r)return console.warn("[fetchSriMandirPujas] Error:",r),cn;const n=Gv(typeof e=="string"?e:"");return n.length>0&&(cn=n,Su=t),n}catch(e){return console.error("[fetchSriMandirPujas] Exception:",e),cn}},Yv=(t,e=10)=>t.slice(0,e);async function Xv(t,e){const{visitorId:r,sessionId:s,problemStatements:n,language:a}=e;if(n.length!==0)try{await t.from("session_problem_statements").insert({visitor_id:r,session_id:s,problem_statements:n,language:a??"en"})}catch{}}async function Qv(t,e,r){console.log("[invokeCalculateDosha] Calling Edge Function with payload:",{...e,name:e.name?"***":void 0});try{const{data:s,error:n}=await t.functions.invoke("calculate-dosha",{body:e,headers:r??{}});return console.log("[invokeCalculateDosha] Response:",{data:s,error:n}),n?(console.error("[invokeCalculateDosha] Error:",n),{success:!1,error:n.message||"Calculation failed"}):s&&typeof s=="object"&&"success"in s?s.success===!0?s:{success:!1,error:s.error??"Unknown error",details:s.details}:{success:!1,error:"Invalid response from server"}}catch(s){return console.error("[invokeCalculateDosha] Exception:",s),{success:!1,error:s instanceof Error?s.message:"Network error occurred"}}}async function eb(t,e,r={}){const{visitorId:s="unknown",sessionId:n="unknown",trackProblemStatements:a=!0,problemStatements:i=[],language:o="en"}=r;return a&&i.length>0&&await Xv(t,{visitorId:s,sessionId:n,problemStatements:i,language:o}),Qv(t,e,{"x-visitor-id":s,"x-session-id":n})}function tb({puja:t,doshaType:e,language:r,onBookClick:s,analytics:n}){const a=r?.toLowerCase().startsWith("hi"),i=vu(t,r),o=bu(t,r),l=wu(t.schedule_date_ist,r),c=xu(t,r),d=_u(t,r),f=async()=>{if(n?.trackDoshaCalculatorResultBookCtaClicked?.({position:"puja_card",url:c,isOldDosha:!0}),s)try{await s()}catch(p){console.error("Error in onBookClick:",p)}window.open(c,"_blank","noopener,noreferrer")};return u.jsx(dr,{className:"overflow-hidden hover:shadow-lg transition-shadow relative",children:u.jsxs("div",{className:"relative",children:[u.jsx("div",{className:"absolute -top-1 -left-1 z-10",children:u.jsx("span",{className:"inline-flex items-center px-2 py-1 text-[10px] font-medium bg-destructive/90 text-destructive-foreground rounded-br-md shadow-sm",children:a?"सीमित सीटें":"Limited Seats"})}),d&&u.jsx("div",{className:"relative aspect-[16/10] w-full overflow-hidden bg-muted",children:u.jsx(Dr,{src:d,alt:i,className:"w-full h-full object-contain",loading:"lazy"})}),u.jsxs(Ar,{className:"p-3 space-y-2",children:[u.jsx("h4",{className:"font-semibold text-sm line-clamp-2 text-card-foreground",children:i}),t.temple_name&&u.jsx("p",{className:"text-sm text-muted-foreground",children:o}),t.schedule_date_ist&&u.jsx("p",{className:"text-sm font-medium text-card-foreground",children:l}),t.individual_pack_price_inr>0&&u.jsx("p",{className:"text-base font-bold text-primary",children:a?`₹${t.individual_pack_price_inr} से शुरू`:`Starting from ₹${t.individual_pack_price_inr}`}),u.jsxs(Br,{size:"lg",className:"book-puja-cta w-full h-14 text-lg font-bold",onClick:async p=>{p.preventDefault(),await f()},children:[a?"पूजा बुक करें":"Book Puja",u.jsx(Xi,{className:"ml-1.5 h-3.5 w-3.5",size:14})]}),u.jsx("p",{className:"text-[10px] text-center text-muted-foreground",children:a?"श्री मंदिर द्वारा संचालित":"Powered by Sri Mandir"})]})]})})}const rb=Jh({problemArea:Fr().max(500,"Maximum 500 characters allowed").optional(),otherProblem:Fr().max(100,"Maximum 100 characters allowed").optional(),name:Fr().trim().min(1,"Name is required").max(100,"Name must be less than 100 characters"),gender:Jo(["M","F"],{required_error:"Gender is required",invalid_type_error:"Gender is required"}),date:Fr().min(1,"Date of birth is required"),time:Fr().optional().nullable(),unknownTime:Gh().default(!1),place:Fr().trim().min(1,"Birth place is required"),lat:Go().optional(),lon:Go().optional(),tz:Fr().optional(),chartStyle:Jo(["north","south"]).default("north").optional()}).superRefine((t,e)=>{t.time&&!/^([01]\d|2[0-3]):([0-5]\d)$/.test(t.time)&&e.addIssue({code:$.custom,path:["time"],message:"Invalid time format (HH:MM)"}),!t.unknownTime&&(!t.time||t.time.trim()==="")&&e.addIssue({code:$.custom,path:["time"],message:"Time of birth is required"})}),Cu=({analytics:t,googleMapsApiKey:e}={})=>{const r=U=>U.replace(/[^a-zA-Z\u0900-\u097F\s]/g,"").replace(/\s{2,}/g," "),{t:s}=Ds(),{predictions:n,isSearching:a,searchPlaces:i,getPlaceDetails:o,clearPredictions:l}=Kv({apiKey:e,language:Re.language||"en"}),[c,d]=k.useState(!1),[f,p]=k.useState(!1),[h,g]=k.useState(null),[y,v]=k.useState(null),[,C]=k.useState(null),[_,S]=k.useState(!1),[E,T]=k.useState(-1),[N,L]=k.useState(null),[ue,re]=k.useState([]),[je,Se]=k.useState(!0),F=(Re.language?Re.language.toLowerCase():"").startsWith("hi"),[X,W]=k.useState(new Set),[oe,ye]=k.useState(!1);k.useEffect(()=>{t?.trackDoshaCalculatorWebView?.(!0)},[t]),k.useEffect(()=>{(async()=>{Se(!0);const m=await Zv();re(m),Se(!1)})()},[]);const ne=()=>{oe||(ye(!0),t?.trackFormFillInitiated?.(!0))},de=U=>{X.has(U)||(console.log(`[Analytics] Tracking form_field_filled: ${U}`),nt("form_field_filled",{page:"home",metadata:{field:U,variant:"v2",is_old_dosha:!0}}),Rm(U),W(m=>new Set(m).add(U)))},{register:G,handleSubmit:j,watch:z,setValue:Z,reset:se,clearErrors:he,trigger:le,formState:{errors:ae}}=yh({resolver:xh(rb),mode:"onSubmit",reValidateMode:"onChange",defaultValues:{unknownTime:!1,chartStyle:"north",place:""}}),ce=z("unknownTime"),tt=z("time"),Je=z("place"),Le=z("name"),ut=z("date"),qt=z("gender"),[lt,sr]=k.useState([]),[rt,Dt]=k.useState(!1),[ht,Gt]=k.useState(""),[Et,Jt]=k.useState(null);Le?.trim()||ut||tt||Je?.trim()||qt||lt.length>0;const Tt=!!(Le?.trim()&&qt&&ut&&Je?.trim()&&(ce||tt)),Lt=U=>{if(!U)return 0;const m=new Date(U),b=new Date;let x=b.getFullYear()-m.getFullYear();const A=b.getMonth()-m.getMonth();return(A<0||A===0&&b.getDate()<m.getDate())&&x--,x},ft=[{id:"marriage",en:"Marriage",hi:"शादी"},{id:"financial",en:"Money",hi:"पैसा"},{id:"health",en:"Health",hi:"स्वास्थ्य"},{id:"education",en:"Education",hi:"शिक्षा"},{id:"career",en:"Career",hi:"करियर"},{id:"other",en:"Others",hi:"अन्य"}],Pr=U=>{if(Lt(U)<18){const b=["marriage","financial","career","business"];if(lt.some(A=>b.includes(A)))return Jt(F?"कृपया उचित समस्या क्षेत्र चुनें। विवाह, वित्तीय, करियर और व्यापार संबंधी समस्याएं 18 वर्ष से अधिक आयु के उपयोगकर्ताओं के लिए हैं।":"Please select appropriate problem areas. Marriage, financial, career, and business-related issues are applicable for users above 18 years."),!1}return Jt(null),!0};k.useEffect(()=>{const U=Re.language?.startsWith("hi"),m=lt.filter(b=>b!=="other").map(b=>{const x=ft.find(A=>A.id===b);return x?U?x.hi:x.en:""}).filter(Boolean);rt&&ht.trim()&&m.push(ht.trim()),Z("problemArea",m.join("; ")),m.length>0&&de("problemArea")},[lt,ht,rt]);const Nr=U=>{Jt(null),U==="other"?(Dt(!rt),rt?(sr(m=>m.filter(b=>b!=="other")),Gt("")):sr(m=>[...m.filter(b=>b!=="other"),"other"])):sr(m=>m.includes(U)?m.filter(b=>b!==U):[...m,U])},qe=U=>{const m=r(U);if(N&&clearTimeout(N),m.length<2){l(),d(!1);return}const b=setTimeout(async()=>{await i(m),d(!0),T(-1)},300);L(b)},vt=async(U,m)=>{if(!e)return"Asia/Kolkata";try{const b=Math.floor(Date.now()/1e3),x=`https://maps.googleapis.com/maps/api/timezone/json?location=${U},${m}&timestamp=${b}&key=${e}`,P=await(await fetch(x)).json();return P.status==="OK"&&P.timeZoneId?P.timeZoneId:"Asia/Kolkata"}catch{return"Asia/Kolkata"}},Rr=async(U,m)=>{const b=r(m).trim(),x=await o(U);if(x){const A=await vt(x.lat,x.lng);Z("place",b),Z("lat",x.lat),Z("lon",x.lng),Z("tz",A),ms.success(s("dosha.locationSelected")),de("place"),t?.trackPlaceOfBirthChosen?.(b,!0)}else Z("place",b),ms.error(s("dosha.locationError","Could not get location coordinates. Please try again."));d(!1),l(),T(-1)},br=()=>{setTimeout(()=>{d(!1),T(-1)},200)},nr=U=>{if(!(!c||n.length===0))switch(U.key){case"ArrowDown":U.preventDefault(),T(m=>m<n.length-1?m+1:m);break;case"ArrowUp":U.preventDefault(),T(m=>m>0?m-1:-1);break;case"Enter":if(E>=0&&E<n.length){U.preventDefault();const m=n[E];Rr(m.place_id,m.description)}else d(!1),T(-1);break;case"Escape":d(!1),T(-1);break}},Ts=async U=>{if(!Pr(U.date))return;Tt?t?.trackFloatingCtaClicked?.(ha.all_fields_filled,!0):t?.trackFloatingCtaClicked?.(ha.fields_not_filled,!0);const m=lt.includes("marriage")?"marriage":lt[0]||"",b={...U,name:U.name.trim(),gender:U.gender,problemArea:m};nt("calculate_dosha_clicked",{metadata:{hasTime:!b.unknownTime,place:b.place,date:b.date,variant:"v2",is_old_dosha:!0}}),Im(),p(!0);try{const x=localStorage.getItem("analytics_visitor_id")||"unknown",A=localStorage.getItem("analytics_session_id")||"unknown",P=lt.filter(ve=>ve!=="other").map(ve=>{const $e=ft.find(st=>st.id===ve);return $e?Re.language?.startsWith("hi")?$e.hi:$e.en:ve});rt&&ht.trim()&&P.push(ht.trim());const I={name:b.name,gender:b.gender,date:b.date,time:b.unknownTime?"":b.time||"12:00",unknownTime:b.unknownTime,place:b.place,lat:b.lat??28.6139,lon:b.lon??77.209,tz:b.tz||"Asia/Kolkata",problemArea:m},M=await eb(Ei,I,{visitorId:x,sessionId:A,trackProblemStatements:P.length>0,problemStatements:P,language:Re.language?.startsWith("hi")?"hi":"en"});if(!M.success)throw new Error(M.error||"Calculation failed");const R={...M,summary:{...M.summary||{}}};if(!R.summary.shaniSadeSati&&(R.summary.sadeSati&&(R.summary.shaniSadeSati=R.summary.sadeSati==="active"?"active":"inactive"),R.summary.sadeSatiPhase&&R.summary.shaniPhase==null)){const ve=String(R.summary.sadeSatiPhase);R.summary.shaniPhase=ve.includes("RISING")?1:ve.includes("PEAK")?2:ve.includes("SETTING")?3:null}g(R);const[J,ee,_e]=I.date.split("-").map(Number),[Ze,te]=(I.time||"12:00").split(":").map(Number);let we=5.5;if(I.tz)try{const ve=new Date,$e=new Date(ve.toLocaleString("en-US",{timeZone:"UTC"}));we=(new Date(ve.toLocaleString("en-US",{timeZone:I.tz})).getTime()-$e.getTime())/(1e3*60*60)}catch(ve){console.warn("[DoshaCalculatorV2] Failed to calculate timezone offset:",ve)}v({day:_e,month:ee,year:J,hour:Ze,minute:te,lat:I.lat,lon:I.lon,tzone:we}),S(!0),sessionStorage.setItem("dosha_calculated","true"),ms.success(s("dosha.calculationSuccess")),nt("dosha_calculate",{metadata:{calculation_id:R.calculationId,name:I.name,gender:I.gender,date_of_birth:I.date,time_of_birth:I.time||null,place_of_birth:I.place,problem_area:I.problemArea||null,hasTime:!I.unknownTime,variant:"v2",is_old_dosha:!0,doshas_found:{mangal:R.summary?.mangal,kaalSarp:R.summary?.kaalSarp,pitra:R.summary?.pitra,shaniSadeSati:R.summary?.shaniSadeSati}}}),R.calculationId&&C(R.calculationId)}catch(x){console.error("Calculation error:",x),console.error("Error details:",{message:x instanceof Error?x.message:"Unknown error",stack:x instanceof Error?x.stack:void 0,type:x?.constructor?.name});const A=x instanceof Error?x.message:String(x),P=A.toLowerCase().includes("cors")||A.toLowerCase().includes("network")||A.toLowerCase().includes("fetch");nt("dosha_calculate_unsuccessful",{metadata:{error:A,isCorsError:P,place:b.place,date:b.date,hasTime:!b.unknownTime,variant:"v2",is_old_dosha:!0}}),P?ms.error(F?"कनेक्शन त्रुटि। कृपया अपना इंटरनेट कनेक्शन जांचें और पुनः प्रयास करें।":"Connection error. Please check your internet connection and try again."):ms.error(s("dosha.calculationError"))}finally{p(!1)}};return u.jsxs("div",{className:"container mx-auto px-4 max-w-2xl mb-12",children:[!h&&u.jsxs("div",{className:"text-center mb-6 pt-4",children:[u.jsx("h1",{className:"text-2xl font-bold mb-2",style:{color:"#1F2937",fontFamily:'"Plus Jakarta Sans", sans-serif'},children:F?"मुफ़्त में पूजा उपाय खोजें":"Find Puja Remedy for Free"}),u.jsx("p",{className:"text-sm leading-relaxed",style:{color:"#6B7280",fontFamily:'"Plus Jakarta Sans", sans-serif'},children:F?"अपनी कुंडली का विश्लेषण करें और पता लगाएं कि आपके वैदिक चार्ट में कौन से दोष (यदि कोई हो) दिखाई देते हैं—और भक्तिपूर्ण उपचार देखें।":"Analyse your kundli to find out which doshas (if any) appear in your Vedic chart—and see devotional remedies."})]}),u.jsx(mp,{open:!_,onOpenChange:U=>S(!U),children:u.jsx(gp,{children:u.jsxs("form",{id:"dosha-form",onSubmit:j(Ts,U=>{console.log("[Form] Validation errors:",U);const m=U.place?.message||U.time?.message||U.date?.message||Object.values(U)[0]?.message||s("dosha.formError","Please correct the highlighted fields");ms.error(m)}),style:{display:"flex",width:"100%",margin:"0 auto",padding:"16px",flexDirection:"column",alignItems:"center",gap:"20px",borderRadius:"16px",border:"1px solid #F3F4F6",background:"#FFF"},children:[u.jsxs("div",{className:"space-y-2 w-full",onFocusCapture:()=>{ne(),t?.trackNameSectionClicked?.()},children:[u.jsxs(Vr,{htmlFor:"name",className:"text-base font-medium text-foreground",children:[F?"नाम":"Name",u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(us,{id:"name",type:"text",...G("name",{onChange:U=>{U.target.value&&(de("name"),t?.trackNameSectionFilled?.())}}),placeholder:F?"अपना नाम दर्ज करें":"Enter your name",className:"min-h-[48px] text-base dosha-input placeholder:text-[#6B7280] focus-visible:ring-0 focus-visible:ring-offset-0",style:{backgroundColor:"#FFF",color:"#000",border:"1px solid #E1561F"},required:!0,maxLength:100}),ae.name&&u.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[u.jsx(Ls,{className:"w-4 h-4"}),ae.name.message]})]}),u.jsxs("div",{className:"space-y-2 w-full",children:[u.jsxs(Vr,{className:"text-base font-medium text-foreground flex items-center gap-2",children:[u.jsx(Bd,{className:"w-4 h-4"}),F?"लिंग":"Gender",u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsxs("div",{className:"flex items-center gap-6",children:[u.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[u.jsx("input",{type:"radio",...G("gender",{onChange:()=>{ne(),de("gender")}}),value:"M",className:"w-4 h-4 border border-gray-300",style:{accentColor:"#F75E22"}}),u.jsx("span",{className:"text-sm text-foreground",children:F?"पुरुष":"Male"})]}),u.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[u.jsx("input",{type:"radio",...G("gender",{onChange:()=>{ne(),de("gender")}}),value:"F",className:"w-4 h-4 border border-gray-300",style:{accentColor:"#F75E22"}}),u.jsx("span",{className:"text-sm text-foreground",children:F?"महिला":"Female"})]})]}),ae.gender&&u.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[u.jsx(Ls,{className:"w-4 h-4"}),ae.gender.message]})]}),u.jsxs("div",{className:"space-y-2 w-full",children:[u.jsxs(Vr,{className:"text-base font-medium text-foreground",children:[F?"आपके जीवन की सबसे बड़ी समस्याएं कौन सी हैं?":"Which are the biggest problem areas in your life?",u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx("p",{className:"text-xs",style:{color:"#735743"},children:F?"आप 1 से अधिक चुन सकते हैं":"You can choose more than 1"}),u.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px"},children:ft.map(U=>{const m=lt.includes(U.id);return u.jsx("button",{type:"button",onClick:()=>Nr(U.id),style:{display:"flex",height:"40px",padding:"8px 14px",justifyContent:"center",alignItems:"center",gap:"10px",borderRadius:"8px",border:"1px solid #F75E22",backgroundColor:m?"#F75E22":"transparent",color:m?"#FFFFFF":"#502D14",fontFamily:'"Plus Jakarta Sans", sans-serif',fontSize:"14px",fontWeight:500,transition:"all 0.2s ease"},children:F?U.hi:U.en},U.id)})}),rt&&u.jsxs("div",{className:"space-y-1",children:[u.jsx(us,{type:"text",value:ht,onChange:U=>{U.target.value.length<=100&&Gt(U.target.value)},placeholder:F?"कृपया अपनी समस्या बताएं":"Please describe your problem",className:"min-h-[48px] text-base dosha-input placeholder:text-[#6B7280] focus-visible:ring-0 focus-visible:ring-offset-0",style:{backgroundColor:"#F9FAFB",color:"#000",border:"1px solid #E1561F"},maxLength:100}),u.jsx("p",{className:"text-xs text-muted-foreground",children:F?"अधिकतम 100 अक्षर":"Max 100 characters"})]}),ae.problemArea&&u.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[u.jsx(Ls,{className:"w-4 h-4"}),ae.problemArea.message]})]}),u.jsxs("div",{className:"w-full",style:{display:"flex",flexDirection:"column",gap:"20px"},children:[u.jsxs("div",{children:[u.jsxs(Vr,{className:"text-base font-medium text-foreground",children:[F?"अपनी जन्म विवरण दर्ज करें":"Enter Your Birth Details",u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx("p",{className:"text-xs mt-1",style:{color:"#735743"},children:F?"यह आपकी जन्म कुंडली में ग्रहों की सटीक स्थिति की गणना करने में मदद करता है।":"This helps calculate the exact planetary position in your birth chart."})]}),u.jsx(Am,{value:z("date"),onChange:U=>{ne(),Z("date",U),le("date"),de("date"),t?.trackDobFilled?.(!0)},onOpen:()=>{ne(),t?.trackDobClicked?.(!0)},error:ae.date?.message}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(Nm,{value:z("time")||"",onChange:U=>{ne(),Z("time",U),le("time"),de("time"),t?.trackTimeFilled?.(!0)},onOpen:()=>{ne(),t?.trackTimeClicked?.(!0)},disabled:ce,error:ae.time?.message}),u.jsxs("div",{className:"gap-2 flex items-end justify-start",children:[u.jsx("input",{type:"checkbox",id:"unknownTime",checked:ce,onChange:U=>{ne(),t?.trackTimeCheckboxClicked?.(!0),Z("unknownTime",U.target.checked),U.target.checked?(Z("time",""),he("time")):le("time")},className:"w-5 h-5 mt-0.5 rounded cursor-pointer appearance-none border-2 border-gray-400 checked:bg-orange-500 checked:border-orange-500 relative checked:after:content-['✓'] checked:after:text-white checked:after:absolute checked:after:inset-0 checked:after:flex checked:after:items-center checked:after:justify-center checked:after:text-sm checked:after:font-bold"}),u.jsx(Vr,{htmlFor:"unknownTime",className:"text-base cursor-pointer text-[#374151]",children:F?"मुझे अपने जन्म का समय नहीं पता":"I don't know my birth time"})]}),u.jsx("p",{className:"text-xs",style:{color:"#735743"},children:F?"नोट - जन्म का सटीक समय न होने पर सटीकता कम हो जाएगी। हम केवल चंद्रमा आधारित जाँच ही करेंगे।":"Note - Without exact birth time, accuracy will be reduced. We'll run Moon-based checks only."})]})]}),u.jsxs("div",{className:"space-y-2 relative w-full",onFocusCapture:()=>{ne(),t?.trackPlaceOfBirthClicked?.(!0)},children:[u.jsxs(Vr,{className:"text-base font-medium text-foreground",children:[F?"जन्म स्थान (शहर)":"Place of Birth (City)",u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsxs("div",{className:"relative",children:[u.jsx(us,{id:"place",...G("place",{onChange:U=>{const m=r(U.target.value);m!==U.target.value&&(U.target.value=m),Z("place",m,{shouldValidate:!0}),qe(m)}}),placeholder:F?"उदाहरण: जयपुर, मुंबई, वाराणसी":"e.g. Jaipur, Mumbai, Varanasi",className:"min-h-[48px] text-base pr-10 dosha-input placeholder:text-[#6B7280] focus-visible:ring-0 focus-visible:ring-offset-0",style:{backgroundColor:"#FFF",color:"#000",border:"1px solid #E1561F"},onKeyDown:nr,onBlur:br,autoComplete:"off"}),u.jsx($d,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-5 h-5 pointer-events-none",style:{color:"#F75E22"}})]}),c&&n.length>0&&u.jsx("div",{className:"absolute z-10 w-full mt-1 bg-card border border-border rounded-md shadow-lg max-h-60 overflow-auto",children:n.map((U,m)=>u.jsxs("button",{type:"button",className:`w-full text-left px-4 py-3 hover:bg-accent transition-colors ${m===E?"bg-accent":""}`,onClick:()=>Rr(U.place_id,U.description),children:[u.jsx("div",{className:"text-sm font-medium",children:U.structured_formatting?.main_text}),u.jsx("div",{className:"text-xs text-muted-foreground",children:U.structured_formatting?.secondary_text})]},U.place_id))}),a&&u.jsx("div",{className:"absolute right-3 top-9",children:u.jsx(Qi,{className:"w-4 h-4 animate-spin text-muted-foreground"})}),ae.place&&u.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[u.jsx(Ls,{className:"w-4 h-4"}),ae.place.message]})]}),Et&&u.jsx("div",{className:"p-3 bg-destructive/10 border border-destructive/30 rounded-lg",children:u.jsxs("p",{className:"text-sm text-destructive flex items-start gap-2",children:[u.jsx(Ls,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),Et]})}),u.jsx(Br,{type:"submit",disabled:f,className:"w-full h-[48px] text-base font-semibold text-white",style:{borderRadius:"8px",background:"radial-gradient(142.71% 142.71% at 50% -42.71%, #F99724 0%, #E1561F 100%)",boxShadow:"0 4px 12px rgba(225, 86, 31, 0.3)"},children:f?u.jsxs(u.Fragment,{children:[u.jsx(Qi,{className:"mr-2 h-5 w-5 animate-spin"}),F?"गणना हो रही है...":"Calculating..."]}):F?"मेरे दोषों की गणना करें":"Calculate My Doshas"})]})})}),h&&u.jsx(Em,{result:h,t:s,onEdit:()=>{S(!1),window.scrollTo({top:0,behavior:"smooth"})},className:"mt-8",birthDetails:y,supabase:Ei,language:Re.language||"en",isLoadingPujas:je,problemArea:z("problemArea")||"",problemAreaIds:lt,customProblemText:ht,kundaliSectionId:"kundali-chart-section",analytics:t,renderPujaCard:U=>{const m=Wv(ue,U);return m?u.jsx(tb,{puja:m,doshaType:U,language:Re.language||"en",analytics:t}):null}}),ue.length>0&&u.jsxs("div",{className:"mt-8 space-y-4 w-full max-w-4xl mx-auto",children:[u.jsxs("div",{className:"text-center",children:[u.jsx("h2",{className:"text-2xl sm:text-3xl font-bold gradient-spiritual bg-clip-text text-transparent",children:F?"श्री मंदिर द्वारा पूजा उपाय":"Sri Mandir Puja Remedies"}),u.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:F?"अपने दोषों के लिए प्रभावी पूजा उपाय देखें":"Explore effective puja remedies for your doshas"})]}),u.jsx(qv,{pujas:Yv(ue,10),doshaType:"all",language:Re.language||"en",formData:{name:z("name")||"",gender:z("gender")||"",dateOfBirth:z("date")||"",timeOfBirth:z("time")||null,placeOfBirth:z("place")||"",problemArea:z("problemArea")||""},variant:"v1",analytics:t})]})]})},sb="https://srm-cdn.a4b.io/yoda/1771903456293.png",nb="https://srm-cdn.a4b.io/yoda/1771903492301.png",ab="https://srm-cdn.a4b.io/yoda/1770639330970.png",ib="https://srm-cdn.a4b.io/yoda/1770639293055.png",ob="https://srm-cdn.a4b.io/yoda/1770639358174.png",lb="https://srm-cdn.a4b.io/yoda/1770639427379.png",cb="https://srm-cdn.a4b.io/yoda/1770639381899.png",Ti=[{id:1,name:"Karthik Nair",location:"Kochi",stars:4,review:{en:"The Dosha Calculator accurately detected Mangal Dosha in my kundli which my family pandit had also confirmed years ago. I booked the recommended puja and within months my delayed marriage finally happened. Truly life-changing tool.",hi:"दोष कैलकुलेटर ने मेरी कुंडली में मंगल दोष का सही पता लगाया जिसे मेरे परिवार के पंडित ने भी वर्षों पहले पुष्टि की थी। मैंने अनुशंसित पूजा बुक की और कुछ महीनों में मेरी देर से हो रही शादी आखिरकार हो गई। सच में जीवन बदलने वाला टूल।"}},{id:2,name:"Priya Verma",location:"Delhi",stars:5,review:{en:"I was skeptical at first but the Dosha Calculator found Shani Sade Sati which explained all my career struggles. The Shani puja they recommended brought such positive changes within weeks. The accuracy of this tool is remarkable and the remedies actually work.",hi:"मुझे पहले संदेह था लेकिन दोष कैलकुलेटर ने शनि साढ़े साती का पता लगाया जिसने मेरी सभी करियर समस्याओं को समझाया। उनकी अनुशंसित शनि पूजा ने कुछ हफ्तों में ऐसे सकारात्मक बदलाव लाए। इस टूल की सटीकता उल्लेखनीय है और उपाय वास्तव में काम करते हैं।"}},{id:3,name:"Venkatesh Iyer",location:"Chennai",stars:4,review:{en:"Finally found out why I was facing so many obstacles in life - the calculator detected Kaal Sarp Dosha. After doing the recommended puja at Trimbakeshwar, my business started improving. This tool saved me from visiting multiple astrologers.",hi:"आखिरकार पता चला कि मैं जीवन में इतनी बाधाओं का सामना क्यों कर रहा था - कैलकुलेटर ने काल सर्प दोष का पता लगाया। त्र्यंबकेश्वर में अनुशंसित पूजा करने के बाद, मेरा व्यवसाय सुधरने लगा। इस टूल ने मुझे कई ज्योतिषियों के पास जाने से बचाया।"}},{id:4,name:"Neha Agarwal",location:"Varanasi",stars:5,review:{en:"The Dosha Calculator detected Pitra Dosha in my chart which no one had told me before. The detailed explanation helped me understand why our family was facing health issues. After the Pishach Mochan puja, things have improved significantly. Highly recommend this tool.",hi:"दोष कैलकुलेटर ने मेरी कुंडली में पितृ दोष का पता लगाया जो मुझे पहले किसी ने नहीं बताया था। विस्तृत व्याख्या ने मुझे समझने में मदद की कि हमारा परिवार स्वास्थ्य समस्याओं का सामना क्यों कर रहा था। पिशाच मोचन पूजा के बाद, चीजें काफी सुधर गई हैं। इस टूल की अत्यधिक सिफारिश करता हूं।"}},{id:5,name:"Lakshmi Menon",location:"Bangalore",stars:4,review:{en:"Such an easy and accurate tool to check doshas in your kundli. It found multiple doshas and suggested specific pujas for each one. The remedies have brought peace and prosperity to my family. Best kundli analysis I have ever used online.",hi:"अपनी कुंडली में दोष जांचने के लिए इतना आसान और सटीक टूल। इसने कई दोष खोजे और प्रत्येक के लिए विशिष्ट पूजा सुझाई। उपायों ने मेरे परिवार में शांति और समृद्धि लाई है। सबसे अच्छा कुंडली विश्लेषण जो मैंने कभी ऑनलाइन उपयोग किया है।"}}],ub={1:ab,2:ib,3:ob,4:lb,5:cb};function Eu(){const{i18n:t}=Ds(),e=(t.language||"").toLowerCase().startsWith("hi"),r=[...Ti,...Ti,...Ti];return u.jsxs("div",{className:"w-full py-8 sm:py-12 overflow-hidden",style:{backgroundColor:"#FFF8E1"},children:[u.jsx("div",{className:"container mx-auto px-4 sm:px-6 max-w-4xl",children:u.jsxs("div",{className:"text-center mb-6",children:[u.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[u.jsx(Dr,{src:sb,alt:"",className:"w-20 h-3",width:80,height:12,loading:"lazy"}),u.jsx("h2",{className:"text-[18px] font-semibold text-foreground whitespace-nowrap",children:e?"हमारे भक्त क्या कहते हैं":"What Our Devotees Say"}),u.jsx(Dr,{src:nb,alt:"",className:"w-20 h-3",width:80,height:12,loading:"lazy"})]}),u.jsx("p",{className:"text-[16px] font-medium text-[#502D14]",children:e?"भारत भर के हज़ारों परिवारों का भरोसा":"Trusted by thousands of families across India"})]})}),u.jsx("div",{className:"relative w-full overflow-hidden",children:u.jsx("div",{className:"flex w-max animate-marquee-fast gap-4 px-4",children:r.map((s,n)=>u.jsxs("div",{style:{display:"flex",minWidth:"280px",maxWidth:"280px",padding:"16px",flexDirection:"column",justifyContent:"space-between",alignItems:"flex-start",gap:"12px",flexShrink:0,borderRadius:"8px",background:"#FFF2CF"},children:[u.jsxs("p",{className:"text-[12px] font-medium text-[#1D2125] leading-relaxed",children:['"',e?s.review.hi:s.review.en,'"']}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"w-8 h-8 rounded-full bg-white/60 flex items-center justify-center flex-shrink-0 overflow-hidden",children:u.jsx(Dr,{src:ub[s.id],alt:`${s.name} review avatar`,width:32,height:32,className:"w-full h-full object-cover rounded-full",loading:"lazy"})}),u.jsxs("div",{children:[u.jsxs("span",{className:"text-sm font-medium text-foreground block",children:[s.name,", ",s.location]}),u.jsx("div",{className:"flex gap-0.5 mt-0.5",children:[...Array(5)].map((a,i)=>u.jsx(Fd,{className:"w-3 h-3",fill:i<s.stars?"#FACC15":"#D1D5DB",color:i<s.stars?"#FACC15":"#D1D5DB"},i))})]})]})]},`${s.id}-${n}`))})})]})}function Tu(){const{i18n:t}=Ds(),r=(t.language||"").toLowerCase().startsWith("hi")?["3 करोड़+ ऐप डाउनलोड","30 लाख+ परिवारों द्वारा विश्वसनीय","1000+ पंडितों का नेटवर्क","प्रमाणित वैदिक पूजाएं"]:["3 Crore+ App Downloads","Trusted by 30 Lakh+ Families","1000+ Pandits Network","Certified Vedic Pujas"],s=[...r,...r,...r];return u.jsx("div",{className:"w-full overflow-hidden py-3",style:{background:"#F75E22"},children:u.jsx("div",{className:"flex w-max animate-marquee",children:s.map((n,a)=>u.jsxs("span",{className:"mx-6 text-sm font-medium text-white inline-flex items-center gap-2 whitespace-nowrap",children:[u.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white/80"}),n]},a))})})}function Au(){const{t}=Ds();return u.jsx("footer",{className:"bg-orange-500 text-white pt-8 sm:pt-12 pb-6 sm:pb-8",children:u.jsxs("div",{className:"container mx-auto px-4 sm:px-6",children:[u.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6 sm:gap-8 mb-6 sm:mb-8",children:[u.jsxs("div",{className:"md:col-span-2",children:[u.jsx(Dr,{src:"https://srm-cdn.a4b.io/yoda/1771903635316.png",alt:"Sri Mandir",className:"h-12 sm:h-16 w-auto mb-3 sm:mb-4",width:228,height:84,loading:"lazy"}),u.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:t("footer.description")})]}),u.jsxs("div",{className:"md:ml-8",children:[u.jsx("h3",{className:"font-semibold text-base sm:text-lg mb-3 sm:mb-4",children:t("footer.company")}),u.jsxs("ul",{className:"space-y-2 sm:space-y-3",children:[u.jsx("li",{children:u.jsx("a",{href:"https://www.srimandir.com/aboutus",target:"_blank",rel:"noopener noreferrer",className:"text-sm sm:text-base hover:underline min-h-[44px] flex items-center",onClick:()=>nt("footer_link_clicked",{metadata:{link:"about_us",url:"https://www.srimandir.com/aboutus"}}),children:t("footer.aboutUs")})}),u.jsx("li",{children:u.jsx("a",{href:"https://www.srimandir.com/contact-us",target:"_blank",rel:"noopener noreferrer",className:"text-sm sm:text-base hover:underline min-h-[44px] flex items-center",onClick:()=>nt("footer_link_clicked",{metadata:{link:"contact_us",url:"https://www.srimandir.com/contact-us"}}),children:t("footer.contactUs")})})]})]}),u.jsxs("div",{className:"md:ml-4",children:[u.jsx("h3",{className:"font-semibold text-base sm:text-lg mb-3 sm:mb-4",children:t("footer.ourServices")}),u.jsxs("ul",{className:"space-y-1.5 sm:space-y-2",children:[u.jsx("li",{children:u.jsx("span",{className:"text-sm sm:text-base",children:t("footer.services.puja")})}),u.jsx("li",{children:u.jsx("span",{className:"text-sm sm:text-base",children:t("footer.services.chadhava")})}),u.jsx("li",{children:u.jsx("span",{className:"text-sm sm:text-base",children:t("footer.services.panchang")})}),u.jsx("li",{children:u.jsx("span",{className:"text-sm sm:text-base",children:t("footer.services.temples")})})]}),u.jsx("h3",{className:"font-semibold text-base sm:text-lg mb-3 sm:mb-4 mt-6 sm:mt-8",children:t("footer.ourAddress")}),u.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:t("footer.address")})]})]}),u.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center border-t border-orange-400 pt-6 sm:pt-8 gap-6",children:[u.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4 w-full sm:w-auto",children:[u.jsxs("a",{href:"https://play.google.com/store/apps/details?id=com.mandir&pli=1",target:"_blank",rel:"noopener noreferrer",className:"bg-black text-white px-4 py-3 sm:py-2 rounded-lg flex items-center gap-2 hover:bg-gray-800 transition-colors w-full sm:w-auto justify-center min-h-[48px]",onClick:()=>nt("app_download_clicked",{metadata:{platform:"google_play"}}),children:[u.jsx("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"currentColor",children:u.jsx("path",{d:"M3,20.5V3.5C3,2.91 3.34,2.39 3.84,2.15L13.69,12L3.84,21.85C3.34,21.61 3,21.09 3,20.5M16.81,15.12L6.05,21.34L14.54,12.85L16.81,15.12M20.16,10.81C20.5,11.08 20.75,11.5 20.75,12C20.75,12.5 20.53,12.9 20.18,13.18L17.89,14.5L15.39,12L17.89,9.5L20.16,10.81M6.05,2.66L16.81,8.88L14.54,11.15L6.05,2.66Z"})}),u.jsxs("div",{className:"text-xs",children:[u.jsx("div",{children:"GET IT ON"}),u.jsx("div",{className:"font-semibold",children:"Google Play"})]})]}),u.jsxs("a",{href:"https://apps.apple.com/in/app/sri-mandir-puja-chadhava/id1637621461",target:"_blank",rel:"noopener noreferrer",className:"bg-black text-white px-4 py-3 sm:py-2 rounded-lg flex items-center gap-2 hover:bg-gray-800 transition-colors w-full sm:w-auto justify-center min-h-[48px]",onClick:()=>nt("app_download_clicked",{metadata:{platform:"app_store"}}),children:[u.jsx("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"currentColor",children:u.jsx("path",{d:"M18.71,19.5C17.88,20.74 17,21.95 15.66,21.97C14.32,22 13.89,21.18 12.37,21.18C10.84,21.18 10.37,21.95 9.1,22C7.79,22.05 6.8,20.68 5.96,19.47C4.25,17 2.94,12.45 4.7,9.39C5.57,7.87 7.13,6.91 8.82,6.88C10.1,6.86 11.32,7.75 12.11,7.75C12.89,7.75 14.37,6.68 15.92,6.84C16.57,6.87 18.39,7.1 19.56,8.82C19.47,8.88 17.39,10.17 17.41,12.63C17.44,15.65 20.06,16.66 20.09,16.67C20.06,16.74 19.67,18.11 18.71,19.5M13,3.5C13.73,2.67 14.94,2.04 15.94,2C16.07,3.17 15.6,4.35 14.9,5.19C14.21,6.04 13.07,6.7 11.95,6.61C11.8,5.46 12.36,4.26 13,3.5Z"})}),u.jsxs("div",{className:"text-xs",children:[u.jsx("div",{children:"Download on the"}),u.jsx("div",{className:"font-semibold",children:"App Store"})]})]})]}),u.jsxs("div",{className:"flex flex-wrap justify-center gap-3 sm:gap-4 w-full sm:w-auto",children:[u.jsx("a",{href:"https://www.youtube.com/@srimandirofficial",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"youtube"}}),children:u.jsx(Vd,{size:20})}),u.jsx("a",{href:"https://www.instagram.com/sri.mandir",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"instagram"}}),children:u.jsx(Dd,{size:20})}),u.jsx("a",{href:"https://www.linkedin.com/company/appsforbharat/posts/?feedView=all",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"linkedin"}}),children:u.jsx(Ld,{size:20})}),u.jsx("a",{href:"https://api.whatsapp.com/send?phone=7829661119",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"whatsapp"}}),children:u.jsx(Md,{size:20})}),u.jsx("a",{href:"https://x.com/SriMandir_App",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"twitter"}}),children:u.jsx(Ud,{size:20})}),u.jsx("a",{href:"https://www.facebook.com/srimandirapp",target:"_blank",rel:"noopener noreferrer",className:"bg-white text-orange-500 p-3 rounded-full hover:bg-gray-100 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",onClick:()=>nt("social_media_clicked",{metadata:{platform:"facebook"}}),children:u.jsx(Rd,{size:20})})]})]}),u.jsxs("div",{className:"border-t border-orange-400 pt-4 sm:pt-6 mt-6 text-center",children:[u.jsxs("div",{className:"flex flex-col sm:flex-row justify-center items-center gap-3 sm:gap-4 text-sm sm:text-base",children:[u.jsx("a",{href:"https://www.srimandir.com/privacy-policy",target:"_blank",rel:"noopener noreferrer",className:"hover:underline min-h-[44px] flex items-center",onClick:()=>nt("footer_link_clicked",{metadata:{link:"privacy_policy",url:"https://www.srimandir.com/privacy-policy"}}),children:t("footer.privacyPolicy")}),u.jsx("span",{className:"hidden sm:inline",children:"•"}),u.jsx("a",{href:"https://www.srimandir.com/terms-of-use",target:"_blank",rel:"noopener noreferrer",className:"hover:underline min-h-[44px] flex items-center",onClick:()=>nt("footer_link_clicked",{metadata:{link:"terms_of_use",url:"https://www.srimandir.com/terms-of-use"}}),children:t("footer.terms")})]}),u.jsx("p",{className:"text-sm sm:text-base mt-3 sm:mt-4 opacity-80",children:t("footer.copyright")})]})]})})}const ju=({analytics:t,googleMapsApiKey:e,isGlobal:r}={})=>(k.useEffect(()=>{const s=Mu();nt("page_view",{page:"home",metadata:{variant:"v2",is_old_dosha:!0,...s,referrer:document.referrer||void 0,landing_page:window.location.pathname+window.location.search}});const n={root:null,rootMargin:"0px",threshold:.5},a=l=>{l.forEach(c=>{if(c.isIntersecting){const d=c.target.getAttribute("data-section");d&&t?.trackDoshaSectionImpression?.({section:d,timestamp:new Date().toISOString(),is_old_dosha:!0})}})},i=new IntersectionObserver(a,n),o=setTimeout(()=>{document.querySelectorAll("[data-section]").forEach(c=>i.observe(c))},100);return()=>{clearTimeout(o),i.disconnect()}},[t]),u.jsx("div",{className:"min-h-screen relative",style:{backgroundColor:"#FFFCEF"},children:u.jsxs("div",{className:"relative z-10",children:[u.jsx(eo,{analytics:t,isGlobal:r}),u.jsx("div",{"data-section":"form",children:u.jsx(Cu,{analytics:t,googleMapsApiKey:e})}),u.jsx("div",{"data-section":"testimonials",children:u.jsx(Eu,{})}),u.jsx("div",{"data-section":"trust-bar",children:u.jsx(Tu,{})}),u.jsx("div",{"data-section":"footer",children:u.jsx(Au,{})})]})})),db=t=>{const[e,r]=k.useState("control"),[s,n]=k.useState(!0);return k.useEffect(()=>{r("v2"),n(!1)},[t]),{variant:e,isLoading:s}},hb={},fb=()=>{const{isLoading:t}=db(hb.HOME_UI);return t?u.jsx("div",{className:"min-h-screen bg-background",children:u.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-2xl",children:[u.jsx("div",{className:"flex justify-center mb-6",children:u.jsx(hr,{className:"h-16 w-48"})}),u.jsx(hr,{className:"h-10 w-full mb-4"}),u.jsx(hr,{className:"h-6 w-3/4 mx-auto mb-8"}),u.jsxs("div",{className:"space-y-4",children:[u.jsx(hr,{className:"h-12 w-full"}),u.jsx(hr,{className:"h-12 w-full"}),u.jsx(hr,{className:"h-12 w-full"}),u.jsx(hr,{className:"h-12 w-full"}),u.jsx(hr,{className:"h-14 w-full rounded-full"})]})]})}):u.jsx(ju,{})};Ae.DoshaCalculatorV2=Cu,Ae.FLOATING_CTA_STATUS=ha,Ae.Footer=Au,Ae.HeaderV2=eo,Ae.HomePageExperiment=fb,Ae.IndexV2=ju,Ae.TestimonialsV2=Eu,Ae.TrustBarV2=Tu,Object.defineProperty(Ae,Symbol.toStringTag,{value:"Module"})}));
160
160
  //# sourceMappingURL=old-dosha-calculator.umd.cjs.map