var Sf=t=>{throw TypeError(t)};var Oc=(t,e,r)=>e.has(t)||Sf("Cannot "+r);var C=(t,e,r)=>(Oc(t,e,"read from private field"),r?r.call(t):e.get(t)),ce=(t,e,r)=>e.has(t)?Sf("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Z=(t,e,r,n)=>(Oc(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),qe=(t,e,r)=>(Oc(t,e,"access private method"),r);var aa=(t,e,r,n)=>({set _(s){Z(t,e,s,r)},get _(){return C(t,e,n)}});function ex(t,e){for(var r=0;rn[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function r(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=r(s);fetch(s.href,i)}})();function vg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var yg={exports:{}},Jl={},wg={exports:{}},se={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Jo=Symbol.for("react.element"),tx=Symbol.for("react.portal"),rx=Symbol.for("react.fragment"),nx=Symbol.for("react.strict_mode"),sx=Symbol.for("react.profiler"),ix=Symbol.for("react.provider"),ox=Symbol.for("react.context"),ax=Symbol.for("react.forward_ref"),lx=Symbol.for("react.suspense"),cx=Symbol.for("react.memo"),ux=Symbol.for("react.lazy"),Ef=Symbol.iterator;function dx(t){return t===null||typeof t!="object"?null:(t=Ef&&t[Ef]||t["@@iterator"],typeof t=="function"?t:null)}var xg={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},bg=Object.assign,_g={};function _i(t,e,r){this.props=t,this.context=e,this.refs=_g,this.updater=r||xg}_i.prototype.isReactComponent={};_i.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};_i.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function kg(){}kg.prototype=_i.prototype;function Gd(t,e,r){this.props=t,this.context=e,this.refs=_g,this.updater=r||xg}var Jd=Gd.prototype=new kg;Jd.constructor=Gd;bg(Jd,_i.prototype);Jd.isPureReactComponent=!0;var Cf=Array.isArray,Sg=Object.prototype.hasOwnProperty,Qd={current:null},Eg={key:!0,ref:!0,__self:!0,__source:!0};function Cg(t,e,r){var n,s={},i=null,o=null;if(e!=null)for(n in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(i=""+e.key),e)Sg.call(e,n)&&!Eg.hasOwnProperty(n)&&(s[n]=e[n]);var a=arguments.length-2;if(a===1)s.children=r;else if(1>>1,V=T[X];if(0>>1;Xs(Ae,M))Hes(de,Ae)?(T[X]=de,T[He]=M,X=He):(T[X]=Ae,T[oe]=M,X=oe);else if(Hes(de,M))T[X]=de,T[He]=M,X=He;else break e}}return N}function s(T,N){var M=T.sortIndex-N.sortIndex;return M!==0?M:T.id-N.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var l=[],c=[],u=1,d=null,f=3,h=!1,y=!1,w=!1,x=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(T){for(var N=r(c);N!==null;){if(N.callback===null)n(c);else if(N.startTime<=T)n(c),N.sortIndex=N.expirationTime,e(l,N);else break;N=r(c)}}function _(T){if(w=!1,v(T),!y)if(r(l)!==null)y=!0,K(k);else{var N=r(c);N!==null&&Y(_,N.startTime-T)}}function k(T,N){y=!1,w&&(w=!1,m(R),R=-1),h=!0;var M=f;try{for(v(N),d=r(l);d!==null&&(!(d.expirationTime>N)||T&&!q());){var X=d.callback;if(typeof X=="function"){d.callback=null,f=d.priorityLevel;var V=X(d.expirationTime<=N);N=t.unstable_now(),typeof V=="function"?d.callback=V:d===r(l)&&n(l),v(N)}else n(l);d=r(l)}if(d!==null)var ne=!0;else{var oe=r(c);oe!==null&&Y(_,oe.startTime-N),ne=!1}return ne}finally{d=null,f=M,h=!1}}var S=!1,E=null,R=-1,P=5,I=-1;function q(){return!(t.unstable_now()-IT||125X?(T.sortIndex=M,e(c,T),r(l)===null&&T===r(c)&&(w?(m(R),R=-1):w=!0,Y(_,M-X))):(T.sortIndex=V,e(l,T),y||h||(y=!0,K(k))),T},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(T){var N=f;return function(){var M=f;f=N;try{return T.apply(this,arguments)}finally{f=M}}}})(Pg);Ag.exports=Pg;var _x=Ag.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var kx=b,yt=_x;function j(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wu=Object.prototype.hasOwnProperty,Sx=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Nf={},Rf={};function Ex(t){return wu.call(Rf,t)?!0:wu.call(Nf,t)?!1:Sx.test(t)?Rf[t]=!0:(Nf[t]=!0,!1)}function Cx(t,e,r,n){if(r!==null&&r.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function Tx(t,e,r,n){if(e===null||typeof e>"u"||Cx(t,e,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function nt(t,e,r,n,s,i,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=s,this.mustUseProperty=r,this.propertyName=t,this.type=e,this.sanitizeURL=i,this.removeEmptyString=o}var Ve={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Ve[t]=new nt(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Ve[e]=new nt(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Ve[t]=new nt(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Ve[t]=new nt(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Ve[t]=new nt(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Ve[t]=new nt(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Ve[t]=new nt(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Ve[t]=new nt(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Ve[t]=new nt(t,5,!1,t.toLowerCase(),null,!1,!1)});var Yd=/[\-:]([a-z])/g;function Xd(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Yd,Xd);Ve[e]=new nt(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Yd,Xd);Ve[e]=new nt(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Yd,Xd);Ve[e]=new nt(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Ve[t]=new nt(t,1,!1,t.toLowerCase(),null,!1,!1)});Ve.xlinkHref=new nt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Ve[t]=new nt(t,1,!1,t.toLowerCase(),null,!0,!0)});function eh(t,e,r,n){var s=Ve.hasOwnProperty(e)?Ve[e]:null;(s!==null?s.type!==0:n||!(2a||s[o]!==i[a]){var l=` `+s[o].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{$c=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?qi(t):""}function Nx(t){switch(t.tag){case 5:return qi(t.type);case 16:return qi("Lazy");case 13:return qi("Suspense");case 19:return qi("SuspenseList");case 0:case 2:case 15:return t=Dc(t.type,!1),t;case 11:return t=Dc(t.type.render,!1),t;case 1:return t=Dc(t.type,!0),t;default:return""}}function ku(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Ps:return"Fragment";case As:return"Portal";case xu:return"Profiler";case th:return"StrictMode";case bu:return"Suspense";case _u:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Lg:return(t.displayName||"Context")+".Consumer";case Ig:return(t._context.displayName||"Context")+".Provider";case rh:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case nh:return e=t.displayName||null,e!==null?e:ku(t.type)||"Memo";case Zr:e=t._payload,t=t._init;try{return ku(t(e))}catch{}}return null}function Rx(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ku(e);case 8:return e===th?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Sn(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Dg(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function jx(t){var e=Dg(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),n=""+t[e];if(!t.hasOwnProperty(e)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var s=r.get,i=r.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(o){n=""+o,i.call(this,o)}}),Object.defineProperty(t,e,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(o){n=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function ua(t){t._valueTracker||(t._valueTracker=jx(t))}function Mg(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=Dg(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function rl(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Su(t,e){var r=e.checked;return Se({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function Af(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=Sn(e.value!=null?e.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Ug(t,e){e=e.checked,e!=null&&eh(t,"checked",e,!1)}function Eu(t,e){Ug(t,e);var r=Sn(e.value),n=e.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Cu(t,e.type,r):e.hasOwnProperty("defaultValue")&&Cu(t,e.type,Sn(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Pf(t,e,r){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,r||e===t.value||(t.value=e),t.defaultValue=e}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function Cu(t,e,r){(e!=="number"||rl(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var Ki=Array.isArray;function Vs(t,e,r,n){if(t=t.options,e){e={};for(var s=0;s"+e.valueOf().toString()+"",e=da.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function po(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var Xi={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ax=["Webkit","ms","Moz","O"];Object.keys(Xi).forEach(function(t){Ax.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Xi[e]=Xi[t]})});function Wg(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||Xi.hasOwnProperty(t)&&Xi[t]?(""+e).trim():e+"px"}function Vg(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,s=Wg(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,s):t[r]=s}}var Px=Se({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ru(t,e){if(e){if(Px[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(j(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(j(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(j(61))}if(e.style!=null&&typeof e.style!="object")throw Error(j(62))}}function ju(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Au=null;function sh(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Pu=null,Hs=null,qs=null;function Lf(t){if(t=Yo(t)){if(typeof Pu!="function")throw Error(j(280));var e=t.stateNode;e&&(e=ec(e),Pu(t.stateNode,t.type,e))}}function Hg(t){Hs?qs?qs.push(t):qs=[t]:Hs=t}function qg(){if(Hs){var t=Hs,e=qs;if(qs=Hs=null,Lf(t),e)for(t=0;t>>=0,t===0?32:31-(Wx(t)/Vx|0)|0}var ha=64,fa=4194304;function Gi(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function ol(t,e){var r=t.pendingLanes;if(r===0)return 0;var n=0,s=t.suspendedLanes,i=t.pingedLanes,o=r&268435455;if(o!==0){var a=o&~s;a!==0?n=Gi(a):(i&=o,i!==0&&(n=Gi(i)))}else o=r&~s,o!==0?n=Gi(o):i!==0&&(n=Gi(i));if(n===0)return 0;if(e!==0&&e!==n&&!(e&s)&&(s=n&-n,i=e&-e,s>=i||s===16&&(i&4194240)!==0))return e;if(n&4&&(n|=r&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=n;0r;r++)e.push(t);return e}function Qo(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-qt(e),t[e]=r}function Gx(t,e){var r=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0=to),Vf=" ",Hf=!1;function hv(t,e){switch(t){case"keyup":return _b.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fv(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Os=!1;function Sb(t,e){switch(t){case"compositionend":return fv(e);case"keypress":return e.which!==32?null:(Hf=!0,Vf);case"textInput":return t=e.data,t===Vf&&Hf?null:t;default:return null}}function Eb(t,e){if(Os)return t==="compositionend"||!hh&&hv(t,e)?(t=uv(),Ba=ch=un=null,Os=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:r,offset:e-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Jf(r)}}function vv(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?vv(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function yv(){for(var t=window,e=rl();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=rl(t.document)}return e}function fh(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function Ib(t){var e=yv(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&vv(r.ownerDocument.documentElement,r)){if(n!==null&&fh(r)){if(e=n.start,t=n.end,t===void 0&&(t=e),"selectionStart"in r)r.selectionStart=e,r.selectionEnd=Math.min(t,r.value.length);else if(t=(e=r.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=r.textContent.length,i=Math.min(n.start,s);n=n.end===void 0?i:Math.min(n.end,s),!t.extend&&i>n&&(s=n,n=i,i=s),s=Qf(r,i);var o=Qf(r,n);s&&o&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),i>n?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=r;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,Is=null,Mu=null,no=null,Uu=!1;function Zf(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Uu||Is==null||Is!==rl(n)||(n=Is,"selectionStart"in n&&fh(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),no&&xo(no,n)||(no=n,n=cl(Mu,"onSelect"),0Ds||(t.current=Hu[Ds],Hu[Ds]=null,Ds--)}function me(t,e){Ds++,Hu[Ds]=t.current,t.current=e}var En={},Ze=On(En),lt=On(!1),ts=En;function li(t,e){var r=t.type.contextTypes;if(!r)return En;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in r)s[i]=e[i];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function ct(t){return t=t.childContextTypes,t!=null}function dl(){ye(lt),ye(Ze)}function sp(t,e,r){if(Ze.current!==En)throw Error(j(168));me(Ze,e),me(lt,r)}function Tv(t,e,r){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var s in n)if(!(s in e))throw Error(j(108,Rx(t)||"Unknown",s));return Se({},r,n)}function hl(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||En,ts=Ze.current,me(Ze,t),me(lt,lt.current),!0}function ip(t,e,r){var n=t.stateNode;if(!n)throw Error(j(169));r?(t=Tv(t,e,ts),n.__reactInternalMemoizedMergedChildContext=t,ye(lt),ye(Ze),me(Ze,t)):ye(lt),me(lt,r)}var Er=null,tc=!1,Zc=!1;function Nv(t){Er===null?Er=[t]:Er.push(t)}function qb(t){tc=!0,Nv(t)}function In(){if(!Zc&&Er!==null){Zc=!0;var t=0,e=he;try{var r=Er;for(he=1;t>=o,s-=o,Tr=1<<32-qt(e)+s|r<R?(P=E,E=null):P=E.sibling;var I=f(m,E,v[R],_);if(I===null){E===null&&(E=P);break}t&&E&&I.alternate===null&&e(m,E),g=i(I,g,R),S===null?k=I:S.sibling=I,S=I,E=P}if(R===v.length)return r(m,E),xe&&Fn(m,R),k;if(E===null){for(;RR?(P=E,E=null):P=E.sibling;var q=f(m,E,I.value,_);if(q===null){E===null&&(E=P);break}t&&E&&q.alternate===null&&e(m,E),g=i(q,g,R),S===null?k=q:S.sibling=q,S=q,E=P}if(I.done)return r(m,E),xe&&Fn(m,R),k;if(E===null){for(;!I.done;R++,I=v.next())I=d(m,I.value,_),I!==null&&(g=i(I,g,R),S===null?k=I:S.sibling=I,S=I);return xe&&Fn(m,R),k}for(E=n(m,E);!I.done;R++,I=v.next())I=h(E,m,R,I.value,_),I!==null&&(t&&I.alternate!==null&&E.delete(I.key===null?R:I.key),g=i(I,g,R),S===null?k=I:S.sibling=I,S=I);return t&&E.forEach(function(F){return e(m,F)}),xe&&Fn(m,R),k}function x(m,g,v,_){if(typeof v=="object"&&v!==null&&v.type===Ps&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case ca:e:{for(var k=v.key,S=g;S!==null;){if(S.key===k){if(k=v.type,k===Ps){if(S.tag===7){r(m,S.sibling),g=s(S,v.props.children),g.return=m,m=g;break e}}else if(S.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===Zr&&lp(k)===S.type){r(m,S.sibling),g=s(S,v.props),g.ref=Mi(m,S,v),g.return=m,m=g;break e}r(m,S);break}else e(m,S);S=S.sibling}v.type===Ps?(g=es(v.props.children,m.mode,_,v.key),g.return=m,m=g):(_=Qa(v.type,v.key,v.props,null,m.mode,_),_.ref=Mi(m,g,v),_.return=m,m=_)}return o(m);case As:e:{for(S=v.key;g!==null;){if(g.key===S)if(g.tag===4&&g.stateNode.containerInfo===v.containerInfo&&g.stateNode.implementation===v.implementation){r(m,g.sibling),g=s(g,v.children||[]),g.return=m,m=g;break e}else{r(m,g);break}else e(m,g);g=g.sibling}g=iu(v,m.mode,_),g.return=m,m=g}return o(m);case Zr:return S=v._init,x(m,g,S(v._payload),_)}if(Ki(v))return y(m,g,v,_);if(Oi(v))return w(m,g,v,_);xa(m,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,g!==null&&g.tag===6?(r(m,g.sibling),g=s(g,v),g.return=m,m=g):(r(m,g),g=su(v,m.mode,_),g.return=m,m=g),o(m)):r(m,g)}return x}var ui=Pv(!0),Ov=Pv(!1),ml=On(null),gl=null,Fs=null,vh=null;function yh(){vh=Fs=gl=null}function wh(t){var e=ml.current;ye(ml),t._currentValue=e}function Gu(t,e,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),t===r)break;t=t.return}}function Gs(t,e){gl=t,vh=Fs=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(at=!0),t.firstContext=null)}function Rt(t){var e=t._currentValue;if(vh!==t)if(t={context:t,memoizedValue:e,next:null},Fs===null){if(gl===null)throw Error(j(308));Fs=t,gl.dependencies={lanes:0,firstContext:t}}else Fs=Fs.next=t;return e}var Vn=null;function xh(t){Vn===null?Vn=[t]:Vn.push(t)}function Iv(t,e,r,n){var s=e.interleaved;return s===null?(r.next=r,xh(e)):(r.next=s.next,s.next=r),e.interleaved=r,Pr(t,n)}function Pr(t,e){t.lanes|=e;var r=t.alternate;for(r!==null&&(r.lanes|=e),r=t,t=t.return;t!==null;)t.childLanes|=e,r=t.alternate,r!==null&&(r.childLanes|=e),r=t,t=t.return;return r.tag===3?r.stateNode:null}var Yr=!1;function bh(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Lv(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Rr(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function yn(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,ae&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,Pr(t,r)}return s=n.interleaved,s===null?(e.next=e,xh(n)):(e.next=s.next,s.next=e),n.interleaved=e,Pr(t,r)}function Va(t,e,r){if(e=e.updateQueue,e!==null&&(e=e.shared,(r&4194240)!==0)){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,oh(t,r)}}function cp(t,e){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var s=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var o={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?s=i=o:i=i.next=o,r=r.next}while(r!==null);i===null?s=i=e:i=i.next=e}else s=i=e;r={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=e:t.next=e,r.lastBaseUpdate=e}function vl(t,e,r,n){var s=t.updateQueue;Yr=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var l=a,c=l.next;l.next=null,o===null?i=c:o.next=c,o=l;var u=t.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==o&&(a===null?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(i!==null){var d=s.baseState;o=0,u=c=l=null,a=i;do{var f=a.lane,h=a.eventTime;if((n&f)===f){u!==null&&(u=u.next={eventTime:h,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var y=t,w=a;switch(f=e,h=r,w.tag){case 1:if(y=w.payload,typeof y=="function"){d=y.call(h,d,f);break e}d=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=w.payload,f=typeof y=="function"?y.call(h,d,f):y,f==null)break e;d=Se({},d,f);break e;case 2:Yr=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,f=s.effects,f===null?s.effects=[a]:f.push(a))}else h={eventTime:h,lane:f,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(c=u=h,l=d):u=u.next=h,o|=f;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;f=a,a=f.next,f.next=null,s.lastBaseUpdate=f,s.shared.pending=null}}while(!0);if(u===null&&(l=d),s.baseState=l,s.firstBaseUpdate=c,s.lastBaseUpdate=u,e=s.shared.interleaved,e!==null){s=e;do o|=s.lane,s=s.next;while(s!==e)}else i===null&&(s.shared.lanes=0);ss|=o,t.lanes=o,t.memoizedState=d}}function up(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;er?r:4,t(!0);var n=Xc.transition;Xc.transition={};try{t(!1),e()}finally{he=r,Xc.transition=n}}function Yv(){return jt().memoizedState}function Qb(t,e,r){var n=xn(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},Xv(t))ey(e,r);else if(r=Iv(t,e,r,n),r!==null){var s=tt();Kt(r,t,n,s),ty(r,e,n)}}function Zb(t,e,r){var n=xn(t),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(Xv(t))ey(e,s);else{var i=t.alternate;if(t.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var o=e.lastRenderedState,a=i(o,r);if(s.hasEagerState=!0,s.eagerState=a,Gt(a,o)){var l=e.interleaved;l===null?(s.next=s,xh(e)):(s.next=l.next,l.next=s),e.interleaved=s;return}}catch{}finally{}r=Iv(t,e,s,n),r!==null&&(s=tt(),Kt(r,t,n,s),ty(r,e,n))}}function Xv(t){var e=t.alternate;return t===_e||e!==null&&e===_e}function ey(t,e){so=wl=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function ty(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,oh(t,r)}}var xl={readContext:Rt,useCallback:Ke,useContext:Ke,useEffect:Ke,useImperativeHandle:Ke,useInsertionEffect:Ke,useLayoutEffect:Ke,useMemo:Ke,useReducer:Ke,useRef:Ke,useState:Ke,useDebugValue:Ke,useDeferredValue:Ke,useTransition:Ke,useMutableSource:Ke,useSyncExternalStore:Ke,useId:Ke,unstable_isNewReconciler:!1},Yb={readContext:Rt,useCallback:function(t,e){return rr().memoizedState=[t,e===void 0?null:e],t},useContext:Rt,useEffect:hp,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,qa(4194308,4,Kv.bind(null,e,t),r)},useLayoutEffect:function(t,e){return qa(4194308,4,t,e)},useInsertionEffect:function(t,e){return qa(4,2,t,e)},useMemo:function(t,e){var r=rr();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=rr();return e=r!==void 0?r(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=Qb.bind(null,_e,t),[n.memoizedState,t]},useRef:function(t){var e=rr();return t={current:t},e.memoizedState=t},useState:dp,useDebugValue:Rh,useDeferredValue:function(t){return rr().memoizedState=t},useTransition:function(){var t=dp(!1),e=t[0];return t=Jb.bind(null,t[1]),rr().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=_e,s=rr();if(xe){if(r===void 0)throw Error(j(407));r=r()}else{if(r=e(),Ue===null)throw Error(j(349));ns&30||Uv(n,e,r)}s.memoizedState=r;var i={value:r,getSnapshot:e};return s.queue=i,hp(zv.bind(null,n,i,t),[t]),n.flags|=2048,No(9,Fv.bind(null,n,i,r,e),void 0,null),r},useId:function(){var t=rr(),e=Ue.identifierPrefix;if(xe){var r=Nr,n=Tr;r=(n&~(1<<32-qt(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=Co++,0<\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=o.createElement(r,{is:n.is}):(t=o.createElement(r),r==="select"&&(o=t,n.multiple?o.multiple=!0:n.size&&(o.size=n.size))):t=o.createElementNS(t,r),t[lr]=e,t[ko]=n,dy(t,e,!1,!1),e.stateNode=t;e:{switch(o=ju(r,n),r){case"dialog":ve("cancel",t),ve("close",t),s=n;break;case"iframe":case"object":case"embed":ve("load",t),s=n;break;case"video":case"audio":for(s=0;sfi&&(e.flags|=128,n=!0,Ui(i,!1),e.lanes=4194304)}else{if(!n)if(t=yl(o),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),Ui(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!xe)return Ge(e),null}else 2*Re()-i.renderingStartTime>fi&&r!==1073741824&&(e.flags|=128,n=!0,Ui(i,!1),e.lanes=4194304);i.isBackwards?(o.sibling=e.child,e.child=o):(r=i.last,r!==null?r.sibling=o:e.child=o,i.last=o)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Re(),e.sibling=null,r=be.current,me(be,n?r&1|2:r&1),e):(Ge(e),null);case 22:case 23:return Lh(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?ht&1073741824&&(Ge(e),e.subtreeFlags&6&&(e.flags|=8192)):Ge(e),null;case 24:return null;case 25:return null}throw Error(j(156,e.tag))}function o_(t,e){switch(mh(e),e.tag){case 1:return ct(e.type)&&dl(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return di(),ye(lt),ye(Ze),Sh(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return kh(e),null;case 13:if(ye(be),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(j(340));ci()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return ye(be),null;case 4:return di(),null;case 10:return wh(e.type._context),null;case 22:case 23:return Lh(),null;case 24:return null;default:return null}}var _a=!1,Qe=!1,a_=typeof WeakSet=="function"?WeakSet:Set,U=null;function zs(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){Ne(t,e,n)}else r.current=null}function nd(t,e,r){try{r()}catch(n){Ne(t,e,n)}}var kp=!1;function l_(t,e){if(Fu=al,t=yv(),fh(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var s=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{r.nodeType,i.nodeType}catch{r=null;break e}var o=0,a=-1,l=-1,c=0,u=0,d=t,f=null;t:for(;;){for(var h;d!==r||s!==0&&d.nodeType!==3||(a=o+s),d!==i||n!==0&&d.nodeType!==3||(l=o+n),d.nodeType===3&&(o+=d.nodeValue.length),(h=d.firstChild)!==null;)f=d,d=h;for(;;){if(d===t)break t;if(f===r&&++c===s&&(a=o),f===i&&++u===n&&(l=o),(h=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=h}r=a===-1||l===-1?null:{start:a,end:l}}else r=null}r=r||{start:0,end:0}}else r=null;for(zu={focusedElem:t,selectionRange:r},al=!1,U=e;U!==null;)if(e=U,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,U=t;else for(;U!==null;){e=U;try{var y=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var w=y.memoizedProps,x=y.memoizedState,m=e.stateNode,g=m.getSnapshotBeforeUpdate(e.elementType===e.type?w:Mt(e.type,w),x);m.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var v=e.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(j(163))}}catch(_){Ne(e,e.return,_)}if(t=e.sibling,t!==null){t.return=e.return,U=t;break}U=e.return}return y=kp,kp=!1,y}function io(t,e,r){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&t)===t){var i=s.destroy;s.destroy=void 0,i!==void 0&&nd(e,r,i)}s=s.next}while(s!==n)}}function sc(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var r=e=e.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==e)}}function sd(t){var e=t.ref;if(e!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof e=="function"?e(t):e.current=t}}function py(t){var e=t.alternate;e!==null&&(t.alternate=null,py(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[lr],delete e[ko],delete e[Vu],delete e[Vb],delete e[Hb])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function my(t){return t.tag===5||t.tag===3||t.tag===4}function Sp(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||my(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function id(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.nodeType===8?r.parentNode.insertBefore(t,e):r.insertBefore(t,e):(r.nodeType===8?(e=r.parentNode,e.insertBefore(t,r)):(e=r,e.appendChild(t)),r=r._reactRootContainer,r!=null||e.onclick!==null||(e.onclick=ul));else if(n!==4&&(t=t.child,t!==null))for(id(t,e,r),t=t.sibling;t!==null;)id(t,e,r),t=t.sibling}function od(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.insertBefore(t,e):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(od(t,e,r),t=t.sibling;t!==null;)od(t,e,r),t=t.sibling}var Be=null,Wt=!1;function Kr(t,e,r){for(r=r.child;r!==null;)gy(t,e,r),r=r.sibling}function gy(t,e,r){if(dr&&typeof dr.onCommitFiberUnmount=="function")try{dr.onCommitFiberUnmount(Ql,r)}catch{}switch(r.tag){case 5:Qe||zs(r,e);case 6:var n=Be,s=Wt;Be=null,Kr(t,e,r),Be=n,Wt=s,Be!==null&&(Wt?(t=Be,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Be.removeChild(r.stateNode));break;case 18:Be!==null&&(Wt?(t=Be,r=r.stateNode,t.nodeType===8?Qc(t.parentNode,r):t.nodeType===1&&Qc(t,r),yo(t)):Qc(Be,r.stateNode));break;case 4:n=Be,s=Wt,Be=r.stateNode.containerInfo,Wt=!0,Kr(t,e,r),Be=n,Wt=s;break;case 0:case 11:case 14:case 15:if(!Qe&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){s=n=n.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&nd(r,e,o),s=s.next}while(s!==n)}Kr(t,e,r);break;case 1:if(!Qe&&(zs(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(a){Ne(r,e,a)}Kr(t,e,r);break;case 21:Kr(t,e,r);break;case 22:r.mode&1?(Qe=(n=Qe)||r.memoizedState!==null,Kr(t,e,r),Qe=n):Kr(t,e,r);break;default:Kr(t,e,r)}}function Ep(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new a_),e.forEach(function(n){var s=v_.bind(null,t,n);r.has(n)||(r.add(n),n.then(s,s))})}}function Lt(t,e){var r=e.deletions;if(r!==null)for(var n=0;ns&&(s=o),n&=~i}if(n=s,n=Re()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*u_(n/1960))-n,10t?16:t,dn===null)var n=!1;else{if(t=dn,dn=null,kl=0,ae&6)throw Error(j(331));var s=ae;for(ae|=4,U=t.current;U!==null;){var i=U,o=i.child;if(U.flags&16){var a=i.deletions;if(a!==null){for(var l=0;lRe()-Oh?Xn(t,0):Ph|=r),ut(t,e)}function Sy(t,e){e===0&&(t.mode&1?(e=fa,fa<<=1,!(fa&130023424)&&(fa=4194304)):e=1);var r=tt();t=Pr(t,e),t!==null&&(Qo(t,e,r),ut(t,r))}function g_(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),Sy(t,r)}function v_(t,e){var r=0;switch(t.tag){case 13:var n=t.stateNode,s=t.memoizedState;s!==null&&(r=s.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(j(314))}n!==null&&n.delete(e),Sy(t,r)}var Ey;Ey=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||lt.current)at=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return at=!1,s_(t,e,r);at=!!(t.flags&131072)}else at=!1,xe&&e.flags&1048576&&Rv(e,pl,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;Ka(t,e),t=e.pendingProps;var s=li(e,Ze.current);Gs(e,r),s=Ch(null,e,n,t,s,r);var i=Th();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,ct(n)?(i=!0,hl(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,bh(e),s.updater=nc,e.stateNode=s,s._reactInternals=e,Qu(e,n,t,r),e=Xu(null,e,n,!0,i,r)):(e.tag=0,xe&&i&&ph(e),Xe(null,e,s,r),e=e.child),e;case 16:n=e.elementType;e:{switch(Ka(t,e),t=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=w_(n),t=Mt(n,t),s){case 0:e=Yu(null,e,n,t,r);break e;case 1:e=xp(null,e,n,t,r);break e;case 11:e=yp(null,e,n,t,r);break e;case 14:e=wp(null,e,n,Mt(n.type,t),r);break e}throw Error(j(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Mt(n,s),Yu(t,e,n,s,r);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Mt(n,s),xp(t,e,n,s,r);case 3:e:{if(ly(e),t===null)throw Error(j(387));n=e.pendingProps,i=e.memoizedState,s=i.element,Lv(t,e),vl(e,n,null,r);var o=e.memoizedState;if(n=o.element,i.isDehydrated)if(i={element:n,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=hi(Error(j(423)),e),e=bp(t,e,n,r,s);break e}else if(n!==s){s=hi(Error(j(424)),e),e=bp(t,e,n,r,s);break e}else for(mt=vn(e.stateNode.containerInfo.firstChild),gt=e,xe=!0,Vt=null,r=Ov(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(ci(),n===s){e=Or(t,e,r);break e}Xe(t,e,n,r)}e=e.child}return e;case 5:return $v(e),t===null&&Ku(e),n=e.type,s=e.pendingProps,i=t!==null?t.memoizedProps:null,o=s.children,Bu(n,s)?o=null:i!==null&&Bu(n,i)&&(e.flags|=32),ay(t,e),Xe(t,e,o,r),e.child;case 6:return t===null&&Ku(e),null;case 13:return cy(t,e,r);case 4:return _h(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=ui(e,null,n,r):Xe(t,e,n,r),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Mt(n,s),yp(t,e,n,s,r);case 7:return Xe(t,e,e.pendingProps,r),e.child;case 8:return Xe(t,e,e.pendingProps.children,r),e.child;case 12:return Xe(t,e,e.pendingProps.children,r),e.child;case 10:e:{if(n=e.type._context,s=e.pendingProps,i=e.memoizedProps,o=s.value,me(ml,n._currentValue),n._currentValue=o,i!==null)if(Gt(i.value,o)){if(i.children===s.children&&!lt.current){e=Or(t,e,r);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var l=a.firstContext;l!==null;){if(l.context===n){if(i.tag===1){l=Rr(-1,r&-r),l.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}i.lanes|=r,l=i.alternate,l!==null&&(l.lanes|=r),Gu(i.return,r,e),a.lanes|=r;break}l=l.next}}else if(i.tag===10)o=i.type===e.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(j(341));o.lanes|=r,a=o.alternate,a!==null&&(a.lanes|=r),Gu(o,r,e),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===e){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Xe(t,e,s.children,r),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,Gs(e,r),s=Rt(s),n=n(s),e.flags|=1,Xe(t,e,n,r),e.child;case 14:return n=e.type,s=Mt(n,e.pendingProps),s=Mt(n.type,s),wp(t,e,n,s,r);case 15:return iy(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Mt(n,s),Ka(t,e),e.tag=1,ct(n)?(t=!0,hl(e)):t=!1,Gs(e,r),ry(e,n,s),Qu(e,n,s,r),Xu(null,e,n,!0,t,r);case 19:return uy(t,e,r);case 22:return oy(t,e,r)}throw Error(j(156,e.tag))};function Cy(t,e){return Xg(t,e)}function y_(t,e,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Tt(t,e,r,n){return new y_(t,e,r,n)}function Dh(t){return t=t.prototype,!(!t||!t.isReactComponent)}function w_(t){if(typeof t=="function")return Dh(t)?1:0;if(t!=null){if(t=t.$$typeof,t===rh)return 11;if(t===nh)return 14}return 2}function bn(t,e){var r=t.alternate;return r===null?(r=Tt(t.tag,e,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=e,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,e=t.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function Qa(t,e,r,n,s,i){var o=2;if(n=t,typeof t=="function")Dh(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Ps:return es(r.children,s,i,e);case th:o=8,s|=8;break;case xu:return t=Tt(12,r,e,s|2),t.elementType=xu,t.lanes=i,t;case bu:return t=Tt(13,r,e,s),t.elementType=bu,t.lanes=i,t;case _u:return t=Tt(19,r,e,s),t.elementType=_u,t.lanes=i,t;case $g:return oc(r,s,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Ig:o=10;break e;case Lg:o=9;break e;case rh:o=11;break e;case nh:o=14;break e;case Zr:o=16,n=null;break e}throw Error(j(130,t==null?t:typeof t,""))}return e=Tt(o,r,e,s),e.elementType=t,e.type=n,e.lanes=i,e}function es(t,e,r,n){return t=Tt(7,t,n,e),t.lanes=r,t}function oc(t,e,r,n){return t=Tt(22,t,n,e),t.elementType=$g,t.lanes=r,t.stateNode={isHidden:!1},t}function su(t,e,r){return t=Tt(6,t,null,e),t.lanes=r,t}function iu(t,e,r){return e=Tt(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function x_(t,e,r,n,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Uc(0),this.expirationTimes=Uc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Uc(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Mh(t,e,r,n,s,i,o,a,l){return t=new x_(t,e,r,a,l),e===1?(e=1,i===!0&&(e|=8)):e=0,i=Tt(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},bh(i),t}function b_(t,e,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(jy)}catch(t){console.error(t)}}jy(),jg.exports=xt;var ea=jg.exports;const Ay=vg(ea);var Py,Op=ea;Py=Op.createRoot,Op.hydrateRoot;var dc=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},hc=typeof window>"u"||"Deno"in globalThis;function Ut(){}function C_(t,e){return typeof t=="function"?t(e):t}function T_(t){return typeof t=="number"&&t>=0&&t!==1/0}function N_(t,e){return Math.max(t+(e||0)-Date.now(),0)}function dd(t,e){return typeof t=="function"?t(e):t}function R_(t,e){return typeof t=="function"?t(e):t}function Ip(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:i,queryKey:o,stale:a}=t;if(o){if(n){if(e.queryHash!==Bh(o,e.options))return!1}else if(!Ao(e.queryKey,o))return!1}if(r!=="all"){const l=e.isActive();if(r==="active"&&!l||r==="inactive"&&l)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||s&&s!==e.state.fetchStatus||i&&!i(e))}function Lp(t,e){const{exact:r,status:n,predicate:s,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(jo(e.options.mutationKey)!==jo(i))return!1}else if(!Ao(e.options.mutationKey,i))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function Bh(t,e){return((e==null?void 0:e.queryKeyHashFn)||jo)(t)}function jo(t){return JSON.stringify(t,(e,r)=>hd(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function Ao(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>Ao(t[r],e[r])):!1}function Oy(t,e){if(t===e)return t;const r=$p(t)&&$p(e);if(r||hd(t)&&hd(e)){const n=r?t:Object.keys(t),s=n.length,i=r?e:Object.keys(e),o=i.length,a=r?[]:{},l=new Set(n);let c=0;for(let u=0;u{setTimeout(e,t)})}function A_(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Oy(t,e):e}function P_(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function O_(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var Wh=Symbol();function Iy(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===Wh?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}var Kn,sn,Xs,cg,I_=(cg=class extends dc{constructor(){super();ce(this,Kn);ce(this,sn);ce(this,Xs);Z(this,Xs,e=>{if(!hc&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){C(this,sn)||this.setEventListener(C(this,Xs))}onUnsubscribe(){var e;this.hasListeners()||((e=C(this,sn))==null||e.call(this),Z(this,sn,void 0))}setEventListener(e){var r;Z(this,Xs,e),(r=C(this,sn))==null||r.call(this),Z(this,sn,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){C(this,Kn)!==e&&(Z(this,Kn,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof C(this,Kn)=="boolean"?C(this,Kn):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},Kn=new WeakMap,sn=new WeakMap,Xs=new WeakMap,cg),Ly=new I_,ei,on,ti,ug,L_=(ug=class extends dc{constructor(){super();ce(this,ei,!0);ce(this,on);ce(this,ti);Z(this,ti,e=>{if(!hc&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){C(this,on)||this.setEventListener(C(this,ti))}onUnsubscribe(){var e;this.hasListeners()||((e=C(this,on))==null||e.call(this),Z(this,on,void 0))}setEventListener(e){var r;Z(this,ti,e),(r=C(this,on))==null||r.call(this),Z(this,on,e(this.setOnline.bind(this)))}setOnline(e){C(this,ei)!==e&&(Z(this,ei,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return C(this,ei)}},ei=new WeakMap,on=new WeakMap,ti=new WeakMap,ug),Cl=new L_;function $_(){let t,e;const r=new Promise((s,i)=>{t=s,e=i});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),t(s)},r.reject=s=>{n({status:"rejected",reason:s}),e(s)},r}function D_(t){return Math.min(1e3*2**t,3e4)}function $y(t){return(t??"online")==="online"?Cl.isOnline():!0}var Dy=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function ou(t){return t instanceof Dy}function My(t){let e=!1,r=0,n=!1,s;const i=$_(),o=w=>{var x;n||(f(new Dy(w)),(x=t.abort)==null||x.call(t))},a=()=>{e=!0},l=()=>{e=!1},c=()=>Ly.isFocused()&&(t.networkMode==="always"||Cl.isOnline())&&t.canRun(),u=()=>$y(t.networkMode)&&t.canRun(),d=w=>{var x;n||(n=!0,(x=t.onSuccess)==null||x.call(t,w),s==null||s(),i.resolve(w))},f=w=>{var x;n||(n=!0,(x=t.onError)==null||x.call(t,w),s==null||s(),i.reject(w))},h=()=>new Promise(w=>{var x;s=m=>{(n||c())&&w(m)},(x=t.onPause)==null||x.call(t)}).then(()=>{var w;s=void 0,n||(w=t.onContinue)==null||w.call(t)}),y=()=>{if(n)return;let w;const x=r===0?t.initialPromise:void 0;try{w=x??t.fn()}catch(m){w=Promise.reject(m)}Promise.resolve(w).then(d).catch(m=>{var S;if(n)return;const g=t.retry??(hc?0:3),v=t.retryDelay??D_,_=typeof v=="function"?v(r,m):v,k=g===!0||typeof g=="number"&&rc()?void 0:h()).then(()=>{e?f(m):y()})})};return{promise:i,cancel:o,continue:()=>(s==null||s(),i),cancelRetry:a,continueRetry:l,canStart:u,start:()=>(u()?y():h().then(y),i)}}var M_=t=>setTimeout(t,0);function U_(){let t=[],e=0,r=a=>{a()},n=a=>{a()},s=M_;const i=a=>{e?t.push(a):s(()=>{r(a)})},o=()=>{const a=t;t=[],a.length&&s(()=>{n(()=>{a.forEach(l=>{r(l)})})})};return{batch:a=>{let l;e++;try{l=a()}finally{e--,e||o()}return l},batchCalls:a=>(...l)=>{i(()=>{a(...l)})},schedule:i,setNotifyFunction:a=>{r=a},setBatchNotifyFunction:a=>{n=a},setScheduler:a=>{s=a}}}var et=U_(),Gn,dg,Uy=(dg=class{constructor(){ce(this,Gn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),T_(this.gcTime)&&Z(this,Gn,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(hc?1/0:5*60*1e3))}clearGcTimeout(){C(this,Gn)&&(clearTimeout(C(this,Gn)),Z(this,Gn,void 0))}},Gn=new WeakMap,dg),ri,Jn,St,Qn,Je,Ko,Zn,zt,xr,hg,F_=(hg=class extends Uy{constructor(e){super();ce(this,zt);ce(this,ri);ce(this,Jn);ce(this,St);ce(this,Qn);ce(this,Je);ce(this,Ko);ce(this,Zn);Z(this,Zn,!1),Z(this,Ko,e.defaultOptions),this.setOptions(e.options),this.observers=[],Z(this,Qn,e.client),Z(this,St,C(this,Qn).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,Z(this,ri,B_(this.options)),this.state=e.state??C(this,ri),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=C(this,Je))==null?void 0:e.promise}setOptions(e){this.options={...C(this,Ko),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&C(this,St).remove(this)}setData(e,r){const n=A_(this.state.data,e,this.options);return qe(this,zt,xr).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){qe(this,zt,xr).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=C(this,Je))==null?void 0:n.promise;return(s=C(this,Je))==null||s.cancel(e),r?r.then(Ut).catch(Ut):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(C(this,ri))}isActive(){return this.observers.some(e=>R_(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Wh||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>dd(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!N_(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=C(this,Je))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=C(this,Je))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),C(this,St).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(C(this,Je)&&(C(this,Zn)?C(this,Je).cancel({revert:!0}):C(this,Je).cancelRetry()),this.scheduleGc()),C(this,St).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||qe(this,zt,xr).call(this,{type:"invalidate"})}fetch(e,r){var c,u,d;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(C(this,Je))return C(this,Je).continueRetry(),C(this,Je).promise}if(e&&this.setOptions(e),!this.options.queryFn){const f=this.observers.find(h=>h.options.queryFn);f&&this.setOptions(f.options)}const n=new AbortController,s=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(Z(this,Zn,!0),n.signal)})},i=()=>{const f=Iy(this.options,r),y=(()=>{const w={client:C(this,Qn),queryKey:this.queryKey,meta:this.meta};return s(w),w})();return Z(this,Zn,!1),this.options.persister?this.options.persister(f,y,this):f(y)},a=(()=>{const f={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:C(this,Qn),state:this.state,fetchFn:i};return s(f),f})();(c=this.options.behavior)==null||c.onFetch(a,this),Z(this,Jn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=a.fetchOptions)==null?void 0:u.meta))&&qe(this,zt,xr).call(this,{type:"fetch",meta:(d=a.fetchOptions)==null?void 0:d.meta});const l=f=>{var h,y,w,x;ou(f)&&f.silent||qe(this,zt,xr).call(this,{type:"error",error:f}),ou(f)||((y=(h=C(this,St).config).onError)==null||y.call(h,f,this),(x=(w=C(this,St).config).onSettled)==null||x.call(w,this.state.data,f,this)),this.scheduleGc()};return Z(this,Je,My({initialPromise:r==null?void 0:r.initialPromise,fn:a.fetchFn,abort:n.abort.bind(n),onSuccess:f=>{var h,y,w,x;if(f===void 0){l(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(m){l(m);return}(y=(h=C(this,St).config).onSuccess)==null||y.call(h,f,this),(x=(w=C(this,St).config).onSettled)==null||x.call(w,f,this.state.error,this),this.scheduleGc()},onError:l,onFail:(f,h)=>{qe(this,zt,xr).call(this,{type:"failed",failureCount:f,error:h})},onPause:()=>{qe(this,zt,xr).call(this,{type:"pause"})},onContinue:()=>{qe(this,zt,xr).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0})),C(this,Je).start()}},ri=new WeakMap,Jn=new WeakMap,St=new WeakMap,Qn=new WeakMap,Je=new WeakMap,Ko=new WeakMap,Zn=new WeakMap,zt=new WeakSet,xr=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...z_(n.data,this.options),fetchMeta:e.meta??null};case"success":return Z(this,Jn,void 0),{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const s=e.error;return ou(s)&&s.revert&&C(this,Jn)?{...C(this,Jn),fetchStatus:"idle"}:{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),et.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),C(this,St).notify({query:this,type:"updated",action:e})})},hg);function z_(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:$y(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function B_(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var sr,fg,W_=(fg=class extends dc{constructor(e={}){super();ce(this,sr);this.config=e,Z(this,sr,new Map)}build(e,r,n){const s=r.queryKey,i=r.queryHash??Bh(s,r);let o=this.get(i);return o||(o=new F_({client:e,queryKey:s,queryHash:i,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(o)),o}add(e){C(this,sr).has(e.queryHash)||(C(this,sr).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=C(this,sr).get(e.queryHash);r&&(e.destroy(),r===e&&C(this,sr).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){et.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return C(this,sr).get(e)}getAll(){return[...C(this,sr).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>Ip(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>Ip(e,n)):r}notify(e){et.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){et.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){et.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},sr=new WeakMap,fg),ir,Ye,Yn,or,Qr,pg,V_=(pg=class extends Uy{constructor(e){super();ce(this,or);ce(this,ir);ce(this,Ye);ce(this,Yn);this.mutationId=e.mutationId,Z(this,Ye,e.mutationCache),Z(this,ir,[]),this.state=e.state||H_(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){C(this,ir).includes(e)||(C(this,ir).push(e),this.clearGcTimeout(),C(this,Ye).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){Z(this,ir,C(this,ir).filter(r=>r!==e)),this.scheduleGc(),C(this,Ye).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){C(this,ir).length||(this.state.status==="pending"?this.scheduleGc():C(this,Ye).remove(this))}continue(){var e;return((e=C(this,Yn))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var i,o,a,l,c,u,d,f,h,y,w,x,m,g,v,_,k,S,E,R;const r=()=>{qe(this,or,Qr).call(this,{type:"continue"})};Z(this,Yn,My({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(P,I)=>{qe(this,or,Qr).call(this,{type:"failed",failureCount:P,error:I})},onPause:()=>{qe(this,or,Qr).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>C(this,Ye).canRun(this)}));const n=this.state.status==="pending",s=!C(this,Yn).canStart();try{if(n)r();else{qe(this,or,Qr).call(this,{type:"pending",variables:e,isPaused:s}),await((o=(i=C(this,Ye).config).onMutate)==null?void 0:o.call(i,e,this));const I=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,e));I!==this.state.context&&qe(this,or,Qr).call(this,{type:"pending",context:I,variables:e,isPaused:s})}const P=await C(this,Yn).start();return await((u=(c=C(this,Ye).config).onSuccess)==null?void 0:u.call(c,P,e,this.state.context,this)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,P,e,this.state.context)),await((y=(h=C(this,Ye).config).onSettled)==null?void 0:y.call(h,P,null,this.state.variables,this.state.context,this)),await((x=(w=this.options).onSettled)==null?void 0:x.call(w,P,null,e,this.state.context)),qe(this,or,Qr).call(this,{type:"success",data:P}),P}catch(P){try{throw await((g=(m=C(this,Ye).config).onError)==null?void 0:g.call(m,P,e,this.state.context,this)),await((_=(v=this.options).onError)==null?void 0:_.call(v,P,e,this.state.context)),await((S=(k=C(this,Ye).config).onSettled)==null?void 0:S.call(k,void 0,P,this.state.variables,this.state.context,this)),await((R=(E=this.options).onSettled)==null?void 0:R.call(E,void 0,P,e,this.state.context)),P}finally{qe(this,or,Qr).call(this,{type:"error",error:P})}}finally{C(this,Ye).runNext(this)}}},ir=new WeakMap,Ye=new WeakMap,Yn=new WeakMap,or=new WeakSet,Qr=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),et.batch(()=>{C(this,ir).forEach(n=>{n.onMutationUpdate(e)}),C(this,Ye).notify({mutation:this,type:"updated",action:e})})},pg);function H_(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Cr,Bt,Go,mg,q_=(mg=class extends dc{constructor(e={}){super();ce(this,Cr);ce(this,Bt);ce(this,Go);this.config=e,Z(this,Cr,new Set),Z(this,Bt,new Map),Z(this,Go,0)}build(e,r,n){const s=new V_({mutationCache:this,mutationId:++aa(this,Go)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){C(this,Cr).add(e);const r=Ea(e);if(typeof r=="string"){const n=C(this,Bt).get(r);n?n.push(e):C(this,Bt).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(C(this,Cr).delete(e)){const r=Ea(e);if(typeof r=="string"){const n=C(this,Bt).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&C(this,Bt).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=Ea(e);if(typeof r=="string"){const n=C(this,Bt).get(r),s=n==null?void 0:n.find(i=>i.state.status==="pending");return!s||s===e}else return!0}runNext(e){var n;const r=Ea(e);if(typeof r=="string"){const s=(n=C(this,Bt).get(r))==null?void 0:n.find(i=>i!==e&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){et.batch(()=>{C(this,Cr).forEach(e=>{this.notify({type:"removed",mutation:e})}),C(this,Cr).clear(),C(this,Bt).clear()})}getAll(){return Array.from(C(this,Cr))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>Lp(r,n))}findAll(e={}){return this.getAll().filter(r=>Lp(e,r))}notify(e){et.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return et.batch(()=>Promise.all(e.map(r=>r.continue().catch(Ut))))}},Cr=new WeakMap,Bt=new WeakMap,Go=new WeakMap,mg);function Ea(t){var e;return(e=t.options.scope)==null?void 0:e.id}function Mp(t){return{onFetch:(e,r)=>{var u,d,f,h,y;const n=e.options,s=(f=(d=(u=e.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,i=((h=e.state.data)==null?void 0:h.pages)||[],o=((y=e.state.data)==null?void 0:y.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const c=async()=>{let w=!1;const x=v=>{Object.defineProperty(v,"signal",{enumerable:!0,get:()=>(e.signal.aborted?w=!0:e.signal.addEventListener("abort",()=>{w=!0}),e.signal)})},m=Iy(e.options,e.fetchOptions),g=async(v,_,k)=>{if(w)return Promise.reject();if(_==null&&v.pages.length)return Promise.resolve(v);const E=(()=>{const q={client:e.client,queryKey:e.queryKey,pageParam:_,direction:k?"backward":"forward",meta:e.options.meta};return x(q),q})(),R=await m(E),{maxPages:P}=e.options,I=k?O_:P_;return{pages:I(v.pages,R,P),pageParams:I(v.pageParams,_,P)}};if(s&&i.length){const v=s==="backward",_=v?K_:Up,k={pages:i,pageParams:o},S=_(n,k);a=await g(k,S,v)}else{const v=t??i.length;do{const _=l===0?o[0]??n.initialPageParam:Up(n,a);if(l>0&&_==null)break;a=await g(a,_),l++}while(l{var w,x;return(x=(w=e.options).persister)==null?void 0:x.call(w,c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=c}}}function Up(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function K_(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var Ee,an,ln,ni,si,cn,ii,oi,gg,G_=(gg=class{constructor(t={}){ce(this,Ee);ce(this,an);ce(this,ln);ce(this,ni);ce(this,si);ce(this,cn);ce(this,ii);ce(this,oi);Z(this,Ee,t.queryCache||new W_),Z(this,an,t.mutationCache||new q_),Z(this,ln,t.defaultOptions||{}),Z(this,ni,new Map),Z(this,si,new Map),Z(this,cn,0)}mount(){aa(this,cn)._++,C(this,cn)===1&&(Z(this,ii,Ly.subscribe(async t=>{t&&(await this.resumePausedMutations(),C(this,Ee).onFocus())})),Z(this,oi,Cl.subscribe(async t=>{t&&(await this.resumePausedMutations(),C(this,Ee).onOnline())})))}unmount(){var t,e;aa(this,cn)._--,C(this,cn)===0&&((t=C(this,ii))==null||t.call(this),Z(this,ii,void 0),(e=C(this,oi))==null||e.call(this),Z(this,oi,void 0))}isFetching(t){return C(this,Ee).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return C(this,an).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=C(this,Ee).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=C(this,Ee).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(dd(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return C(this,Ee).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),s=C(this,Ee).get(n.queryHash),i=s==null?void 0:s.state.data,o=C_(e,i);if(o!==void 0)return C(this,Ee).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(t,e,r){return et.batch(()=>C(this,Ee).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=C(this,Ee).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=C(this,Ee);et.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=C(this,Ee);return et.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=et.batch(()=>C(this,Ee).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(Ut).catch(Ut)}invalidateQueries(t,e={}){return et.batch(()=>(C(this,Ee).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=et.batch(()=>C(this,Ee).findAll(t).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,r);return r.throwOnError||(i=i.catch(Ut)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(Ut)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=C(this,Ee).build(this,e);return r.isStaleByTime(dd(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ut).catch(Ut)}fetchInfiniteQuery(t){return t.behavior=Mp(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ut).catch(Ut)}ensureInfiniteQueryData(t){return t.behavior=Mp(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return Cl.isOnline()?C(this,an).resumePausedMutations():Promise.resolve()}getQueryCache(){return C(this,Ee)}getMutationCache(){return C(this,an)}getDefaultOptions(){return C(this,ln)}setDefaultOptions(t){Z(this,ln,t)}setQueryDefaults(t,e){C(this,ni).set(jo(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...C(this,ni).values()],r={};return e.forEach(n=>{Ao(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){C(this,si).set(jo(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...C(this,si).values()],r={};return e.forEach(n=>{Ao(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...C(this,ln).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=Bh(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Wh&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...C(this,ln).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){C(this,Ee).clear(),C(this,an).clear()}},Ee=new WeakMap,an=new WeakMap,ln=new WeakMap,ni=new WeakMap,si=new WeakMap,cn=new WeakMap,ii=new WeakMap,oi=new WeakMap,gg),J_=b.createContext(void 0),Q_=({client:t,children:e})=>(b.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),p.jsx(J_.Provider,{value:t,children:e}));/** * @remix-run/router v1.23.0 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Po(){return Po=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function Fy(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Y_(){return Math.random().toString(36).substr(2,8)}function zp(t,e){return{usr:t.state,key:t.key,idx:e}}function fd(t,e,r,n){return r===void 0&&(r=null),Po({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Ei(e):e,{state:r,key:e&&e.key||n||Y_()})}function Tl(t){let{pathname:e="/",search:r="",hash:n=""}=t;return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Ei(t){let e={};if(t){let r=t.indexOf("#");r>=0&&(e.hash=t.substr(r),t=t.substr(0,r));let n=t.indexOf("?");n>=0&&(e.search=t.substr(n),t=t.substr(0,n)),t&&(e.pathname=t)}return e}function X_(t,e,r,n){n===void 0&&(n={});let{window:s=document.defaultView,v5Compat:i=!1}=n,o=s.history,a=hn.Pop,l=null,c=u();c==null&&(c=0,o.replaceState(Po({},o.state,{idx:c}),""));function u(){return(o.state||{idx:null}).idx}function d(){a=hn.Pop;let x=u(),m=x==null?null:x-c;c=x,l&&l({action:a,location:w.location,delta:m})}function f(x,m){a=hn.Push;let g=fd(w.location,x,m);c=u()+1;let v=zp(g,c),_=w.createHref(g);try{o.pushState(v,"",_)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;s.location.assign(_)}i&&l&&l({action:a,location:w.location,delta:1})}function h(x,m){a=hn.Replace;let g=fd(w.location,x,m);c=u();let v=zp(g,c),_=w.createHref(g);o.replaceState(v,"",_),i&&l&&l({action:a,location:w.location,delta:0})}function y(x){let m=s.location.origin!=="null"?s.location.origin:s.location.href,g=typeof x=="string"?x:Tl(x);return g=g.replace(/ $/,"%20"),ke(m,"No window.location.(origin|href) available to create URL for href: "+g),new URL(g,m)}let w={get action(){return a},get location(){return t(s,o)},listen(x){if(l)throw new Error("A history only accepts one active listener");return s.addEventListener(Fp,d),l=x,()=>{s.removeEventListener(Fp,d),l=null}},createHref(x){return e(s,x)},createURL:y,encodeLocation(x){let m=y(x);return{pathname:m.pathname,search:m.search,hash:m.hash}},push:f,replace:h,go(x){return o.go(x)}};return w}var Bp;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(Bp||(Bp={}));function ek(t,e,r){return r===void 0&&(r="/"),tk(t,e,r,!1)}function tk(t,e,r,n){let s=typeof e=="string"?Ei(e):e,i=pi(s.pathname||"/",r);if(i==null)return null;let o=zy(t);rk(o);let a=null;for(let l=0;a==null&&l{let l={relativePath:a===void 0?i.path||"":a,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};l.relativePath.startsWith("/")&&(ke(l.relativePath.startsWith(n),'Absolute route path "'+l.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),l.relativePath=l.relativePath.slice(n.length));let c=_n([n,l.relativePath]),u=r.concat(l);i.children&&i.children.length>0&&(ke(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+c+'".')),zy(i.children,e,u,c)),!(i.path==null&&!i.index)&&e.push({path:c,score:ck(c,i.index),routesMeta:u})};return t.forEach((i,o)=>{var a;if(i.path===""||!((a=i.path)!=null&&a.includes("?")))s(i,o);else for(let l of By(i.path))s(i,o,l)}),e}function By(t){let e=t.split("/");if(e.length===0)return[];let[r,...n]=e,s=r.endsWith("?"),i=r.replace(/\?$/,"");if(n.length===0)return s?[i,""]:[i];let o=By(n.join("/")),a=[];return a.push(...o.map(l=>l===""?i:[i,l].join("/"))),s&&a.push(...o),a.map(l=>t.startsWith("/")&&l===""?"/":l)}function rk(t){t.sort((e,r)=>e.score!==r.score?r.score-e.score:uk(e.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const nk=/^:[\w-]+$/,sk=3,ik=2,ok=1,ak=10,lk=-2,Wp=t=>t==="*";function ck(t,e){let r=t.split("/"),n=r.length;return r.some(Wp)&&(n+=lk),e&&(n+=ik),r.filter(s=>!Wp(s)).reduce((s,i)=>s+(nk.test(i)?sk:i===""?ok:ak),n)}function uk(t,e){return t.length===e.length&&t.slice(0,-1).every((n,s)=>n===e[s])?t[t.length-1]-e[e.length-1]:0}function dk(t,e,r){let{routesMeta:n}=t,s={},i="/",o=[];for(let a=0;a{let{paramName:f,isOptional:h}=u;if(f==="*"){let w=a[d]||"";o=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const y=a[d];return h&&!y?c[f]=void 0:c[f]=(y||"").replace(/%2F/g,"/"),c},{}),pathname:i,pathnameBase:o,pattern:t}}function hk(t,e,r){e===void 0&&(e=!1),r===void 0&&(r=!0),Fy(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let n=[],s="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,a,l)=>(n.push({paramName:a,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),s+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?s+="\\/*$":t!==""&&t!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,e?void 0:"i"),n]}function fk(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Fy(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function pi(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let r=e.endsWith("/")?e.length-1:e.length,n=t.charAt(r);return n&&n!=="/"?null:t.slice(r)||"/"}function pk(t,e){e===void 0&&(e="/");let{pathname:r,search:n="",hash:s=""}=typeof t=="string"?Ei(t):t;return{pathname:r?r.startsWith("/")?r:mk(r,e):e,search:yk(n),hash:wk(s)}}function mk(t,e){let r=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(s=>{s===".."?r.length>1&&r.pop():s!=="."&&r.push(s)}),r.length>1?r.join("/"):"/"}function au(t,e,r,n){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function gk(t){return t.filter((e,r)=>r===0||e.route.path&&e.route.path.length>0)}function Vh(t,e){let r=gk(t);return e?r.map((n,s)=>s===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function Hh(t,e,r,n){n===void 0&&(n=!1);let s;typeof t=="string"?s=Ei(t):(s=Po({},t),ke(!s.pathname||!s.pathname.includes("?"),au("?","pathname","search",s)),ke(!s.pathname||!s.pathname.includes("#"),au("#","pathname","hash",s)),ke(!s.search||!s.search.includes("#"),au("#","search","hash",s)));let i=t===""||s.pathname==="",o=i?"/":s.pathname,a;if(o==null)a=r;else{let d=e.length-1;if(!n&&o.startsWith("..")){let f=o.split("/");for(;f[0]==="..";)f.shift(),d-=1;s.pathname=f.join("/")}a=d>=0?e[d]:"/"}let l=pk(s,a),c=o&&o!=="/"&&o.endsWith("/"),u=(i||o===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(c||u)&&(l.pathname+="/"),l}const _n=t=>t.join("/").replace(/\/\/+/g,"/"),vk=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),yk=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,wk=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function xk(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Wy=["post","put","patch","delete"];new Set(Wy);const bk=["get",...Wy];new Set(bk);/** * React Router v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Oo(){return Oo=Object.assign?Object.assign.bind():function(t){for(var e=1;e{a.current=!0}),b.useCallback(function(c,u){if(u===void 0&&(u={}),!a.current)return;if(typeof c=="number"){n.go(c);return}let d=Hh(c,JSON.parse(o),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:_n([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,o,i,t])}function Sk(){let{matches:t}=b.useContext(Ur),e=t[t.length-1];return e?e.params:{}}function mc(t,e){let{relative:r}=e===void 0?{}:e,{future:n}=b.useContext(Mr),{matches:s}=b.useContext(Ur),{pathname:i}=ds(),o=JSON.stringify(Vh(s,n.v7_relativeSplatPath));return b.useMemo(()=>Hh(t,JSON.parse(o),i,r==="path"),[t,o,i,r])}function Ek(t,e){return Ck(t,e)}function Ck(t,e,r,n){Ci()||ke(!1);let{navigator:s}=b.useContext(Mr),{matches:i}=b.useContext(Ur),o=i[i.length-1],a=o?o.params:{};o&&o.pathname;let l=o?o.pathnameBase:"/";o&&o.route;let c=ds(),u;if(e){var d;let x=typeof e=="string"?Ei(e):e;l==="/"||(d=x.pathname)!=null&&d.startsWith(l)||ke(!1),u=x}else u=c;let f=u.pathname||"/",h=f;if(l!=="/"){let x=l.replace(/^\//,"").split("/");h="/"+f.replace(/^\//,"").split("/").slice(x.length).join("/")}let y=ek(t,{pathname:h}),w=Ak(y&&y.map(x=>Object.assign({},x,{params:Object.assign({},a,x.params),pathname:_n([l,s.encodeLocation?s.encodeLocation(x.pathname).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?l:_n([l,s.encodeLocation?s.encodeLocation(x.pathnameBase).pathname:x.pathnameBase])})),i,r,n);return e&&w?b.createElement(pc.Provider,{value:{location:Oo({pathname:"/",search:"",hash:"",state:null,key:"default"},u),navigationType:hn.Pop}},w):w}function Tk(){let t=Lk(),e=xk(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},e),r?b.createElement("pre",{style:s},r):null,null)}const Nk=b.createElement(Tk,null);class Rk extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){console.error("React Router caught the following error during render",e,r)}render(){return this.state.error!==void 0?b.createElement(Ur.Provider,{value:this.props.routeContext},b.createElement(Hy.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function jk(t){let{routeContext:e,match:r,children:n}=t,s=b.useContext(fc);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),b.createElement(Ur.Provider,{value:e},n)}function Ak(t,e,r,n){var s;if(e===void 0&&(e=[]),r===void 0&&(r=null),n===void 0&&(n=null),t==null){var i;if(!r)return null;if(r.errors)t=r.matches;else if((i=n)!=null&&i.v7_partialHydration&&e.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let o=t,a=(s=r)==null?void 0:s.errors;if(a!=null){let u=o.findIndex(d=>d.route.id&&(a==null?void 0:a[d.route.id])!==void 0);u>=0||ke(!1),o=o.slice(0,Math.min(o.length,u+1))}let l=!1,c=-1;if(r&&n&&n.v7_partialHydration)for(let u=0;u=0?o=o.slice(0,c+1):o=[o[0]];break}}}return o.reduceRight((u,d,f)=>{let h,y=!1,w=null,x=null;r&&(h=a&&d.route.id?a[d.route.id]:void 0,w=d.route.errorElement||Nk,l&&(c<0&&f===0?(y=!0,x=null):c===f&&(y=!0,x=d.route.hydrateFallbackElement||null)));let m=e.concat(o.slice(0,f+1)),g=()=>{let v;return h?v=w:y?v=x:d.route.Component?v=b.createElement(d.route.Component,null):d.route.element?v=d.route.element:v=u,b.createElement(jk,{match:d,routeContext:{outlet:u,matches:m,isDataRoute:r!=null},children:v})};return r&&(d.route.ErrorBoundary||d.route.errorElement||f===0)?b.createElement(Rk,{location:r.location,revalidation:r.revalidation,component:w,error:h,children:g(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):g()},null)}var Ky=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(Ky||{}),Rl=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}(Rl||{});function Pk(t){let e=b.useContext(fc);return e||ke(!1),e}function Ok(t){let e=b.useContext(Vy);return e||ke(!1),e}function Ik(t){let e=b.useContext(Ur);return e||ke(!1),e}function Gy(t){let e=Ik(),r=e.matches[e.matches.length-1];return r.route.id||ke(!1),r.route.id}function Lk(){var t;let e=b.useContext(Hy),r=Ok(Rl.UseRouteError),n=Gy(Rl.UseRouteError);return e!==void 0?e:(t=r.errors)==null?void 0:t[n]}function $k(){let{router:t}=Pk(Ky.UseNavigateStable),e=Gy(Rl.UseNavigateStable),r=b.useRef(!1);return qy(()=>{r.current=!0}),b.useCallback(function(s,i){i===void 0&&(i={}),r.current&&(typeof s=="number"?t.navigate(s):t.navigate(s,Oo({fromRouteId:e},i)))},[t,e])}function Dk(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Mk(t){let{to:e,replace:r,state:n,relative:s}=t;Ci()||ke(!1);let{future:i,static:o}=b.useContext(Mr),{matches:a}=b.useContext(Ur),{pathname:l}=ds(),c=qh(),u=Hh(e,Vh(a,i.v7_relativeSplatPath),l,s==="path"),d=JSON.stringify(u);return b.useEffect(()=>c(JSON.parse(d),{replace:r,state:n,relative:s}),[c,d,s,r,n]),null}function br(t){ke(!1)}function Uk(t){let{basename:e="/",children:r=null,location:n,navigationType:s=hn.Pop,navigator:i,static:o=!1,future:a}=t;Ci()&&ke(!1);let l=e.replace(/^\/*/,"/"),c=b.useMemo(()=>({basename:l,navigator:i,static:o,future:Oo({v7_relativeSplatPath:!1},a)}),[l,a,i,o]);typeof n=="string"&&(n=Ei(n));let{pathname:u="/",search:d="",hash:f="",state:h=null,key:y="default"}=n,w=b.useMemo(()=>{let x=pi(u,l);return x==null?null:{location:{pathname:x,search:d,hash:f,state:h,key:y},navigationType:s}},[l,u,d,f,h,y,s]);return w==null?null:b.createElement(Mr.Provider,{value:c},b.createElement(pc.Provider,{children:r,value:w}))}function Fk(t){let{children:e,location:r}=t;return Ek(pd(e),r)}new Promise(()=>{});function pd(t,e){e===void 0&&(e=[]);let r=[];return b.Children.forEach(t,(n,s)=>{if(!b.isValidElement(n))return;let i=[...e,s];if(n.type===b.Fragment){r.push.apply(r,pd(n.props.children,i));return}n.type!==br&&ke(!1),!n.props.index||!n.props.children||ke(!1);let o={id:n.props.id||i.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(o.children=pd(n.props.children,i)),r.push(o)}),r}/** * React Router DOM v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function jl(){return jl=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(r[s]=t[s]);return r}function zk(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Bk(t,e){return t.button===0&&(!e||e==="_self")&&!zk(t)}const Wk=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Vk=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],Hk="6";try{window.__reactRouterVersion=Hk}catch{}const qk=b.createContext({isTransitioning:!1}),Kk="startTransition",Vp=Ng[Kk];function Gk(t){let{basename:e,children:r,future:n,window:s}=t,i=b.useRef();i.current==null&&(i.current=Z_({window:s,v5Compat:!0}));let o=i.current,[a,l]=b.useState({action:o.action,location:o.location}),{v7_startTransition:c}=n||{},u=b.useCallback(d=>{c&&Vp?Vp(()=>l(d)):l(d)},[l,c]);return b.useLayoutEffect(()=>o.listen(u),[o,u]),b.useEffect(()=>Dk(n),[n]),b.createElement(Uk,{basename:e,children:r,location:a.location,navigationType:a.action,navigator:o,future:n})}const Jk=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Qk=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,mi=b.forwardRef(function(e,r){let{onClick:n,relative:s,reloadDocument:i,replace:o,state:a,target:l,to:c,preventScrollReset:u,viewTransition:d}=e,f=Jy(e,Wk),{basename:h}=b.useContext(Mr),y,w=!1;if(typeof c=="string"&&Qk.test(c)&&(y=c,Jk))try{let v=new URL(window.location.href),_=c.startsWith("//")?new URL(v.protocol+c):new URL(c),k=pi(_.pathname,h);_.origin===v.origin&&k!=null?c=k+_.search+_.hash:w=!0}catch{}let x=_k(c,{relative:s}),m=Xk(c,{replace:o,state:a,target:l,preventScrollReset:u,relative:s,viewTransition:d});function g(v){n&&n(v),v.defaultPrevented||m(v)}return b.createElement("a",jl({},f,{href:y||x,onClick:w||i?n:g,ref:r,target:l}))}),Zk=b.forwardRef(function(e,r){let{"aria-current":n="page",caseSensitive:s=!1,className:i="",end:o=!1,style:a,to:l,viewTransition:c,children:u}=e,d=Jy(e,Vk),f=mc(l,{relative:d.relative}),h=ds(),y=b.useContext(Vy),{navigator:w,basename:x}=b.useContext(Mr),m=y!=null&&e1(f)&&c===!0,g=w.encodeLocation?w.encodeLocation(f).pathname:f.pathname,v=h.pathname,_=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;s||(v=v.toLowerCase(),_=_?_.toLowerCase():null,g=g.toLowerCase()),_&&x&&(_=pi(_,x)||_);const k=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let S=v===g||!o&&v.startsWith(g)&&v.charAt(k)==="/",E=_!=null&&(_===g||!o&&_.startsWith(g)&&_.charAt(g.length)==="/"),R={isActive:S,isPending:E,isTransitioning:m},P=S?n:void 0,I;typeof i=="function"?I=i(R):I=[i,S?"active":null,E?"pending":null,m?"transitioning":null].filter(Boolean).join(" ");let q=typeof a=="function"?a(R):a;return b.createElement(mi,jl({},d,{"aria-current":P,className:I,ref:r,style:q,to:l,viewTransition:c}),typeof u=="function"?u(R):u)});var md;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(md||(md={}));var Hp;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(Hp||(Hp={}));function Yk(t){let e=b.useContext(fc);return e||ke(!1),e}function Xk(t,e){let{target:r,replace:n,state:s,preventScrollReset:i,relative:o,viewTransition:a}=e===void 0?{}:e,l=qh(),c=ds(),u=mc(t,{relative:o});return b.useCallback(d=>{if(Bk(d,r)){d.preventDefault();let f=n!==void 0?n:Tl(c)===Tl(u);l(t,{replace:f,state:s,preventScrollReset:i,relative:o,viewTransition:a})}},[c,l,u,n,s,r,t,i,o,a])}function e1(t,e){e===void 0&&(e={});let r=b.useContext(qk);r==null&&ke(!1);let{basename:n}=Yk(md.useViewTransitionState),s=mc(t,{relative:e.relative});if(!r.isTransitioning)return!1;let i=pi(r.currentLocation.pathname,n)||r.currentLocation.pathname,o=pi(r.nextLocation.pathname,n)||r.nextLocation.pathname;return Nl(s.pathname,o)!=null||Nl(s.pathname,i)!=null}var qp=["light","dark"],t1="(prefers-color-scheme: dark)",r1=b.createContext(void 0),n1={setTheme:t=>{},themes:[]},s1=()=>{var t;return(t=b.useContext(r1))!=null?t:n1};b.memo(({forcedTheme:t,storageKey:e,attribute:r,enableSystem:n,enableColorScheme:s,defaultTheme:i,value:o,attrs:a,nonce:l})=>{let c=i==="system",u=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${a.map(y=>`'${y}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,d=s?qp.includes(i)&&i?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${i}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",f=(y,w=!1,x=!0)=>{let m=o?o[y]:y,g=w?y+"|| ''":`'${m}'`,v="";return s&&x&&!w&&qp.includes(y)&&(v+=`d.style.colorScheme = '${y}';`),r==="class"?w||m?v+=`c.add(${g})`:v+="null":m&&(v+=`d[s](n,${g})`),v},h=t?`!function(){${u}${f(t)}}()`:n?`!function(){try{${u}var e=localStorage.getItem('${e}');if('system'===e||(!e&&${c})){var t='${t1}',m=window.matchMedia(t);if(m.media!==t||m.matches){${f("dark")}}else{${f("light")}}}else if(e){${o?`var x=${JSON.stringify(o)};`:""}${f(o?"x[e]":"e",!0)}}${c?"":"else{"+f(i,!1,!1)+"}"}${d}}catch(e){}}()`:`!function(){try{${u}var e=localStorage.getItem('${e}');if(e){${o?`var x=${JSON.stringify(o)};`:""}${f(o?"x[e]":"e",!0)}}else{${f(i,!1,!1)};}${d}}catch(t){}}();`;return b.createElement("script",{nonce:l,dangerouslySetInnerHTML:{__html:h}})});var i1=t=>{switch(t){case"success":return l1;case"info":return u1;case"warning":return c1;case"error":return d1;default:return null}},o1=Array(12).fill(0),a1=({visible:t,className:e})=>O.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},O.createElement("div",{className:"sonner-spinner"},o1.map((r,n)=>O.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),l1=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},O.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"})),c1=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},O.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"})),u1=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},O.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"})),d1=O.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},O.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"})),h1=O.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"},O.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),O.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),f1=()=>{let[t,e]=O.useState(document.hidden);return O.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},gd=1,p1=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,...n}=t,s=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:gd++,i=this.toasts.find(a=>a.id===s),o=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),i?this.toasts=this.toasts.map(a=>a.id===s?(this.publish({...a,...t,id:s,title:r}),{...a,...t,id:s,dismissible:o,title:r}):a):this.addToast({title:r,...n,dismissible:o,id:s}),s},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 n=t instanceof Promise?t:t(),s=r!==void 0,i,o=n.then(async l=>{if(i=["resolve",l],O.isValidElement(l))s=!1,this.create({id:r,type:"default",message:l});else if(g1(l)&&!l.ok){s=!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){s=!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(i=["reject",l],e.error!==void 0){s=!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;s&&(this.dismiss(r),r=void 0),(l=e.finally)==null||l.call(e)}),a=()=>new Promise((l,c)=>o.then(()=>i[0]==="reject"?c(i[1]):l(i[1])).catch(c));return typeof r!="string"&&typeof r!="number"?{unwrap:a}:Object.assign(r,{unwrap:a})},this.custom=(t,e)=>{let r=(e==null?void 0:e.id)||gd++;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}},it=new p1,m1=(t,e)=>{let r=(e==null?void 0:e.id)||gd++;return it.addToast({title:t,...e,id:r}),r},g1=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",v1=m1,y1=()=>it.toasts,w1=()=>it.getActiveToasts(),cr=Object.assign(v1,{success:it.success,info:it.info,warning:it.warning,error:it.error,custom:it.custom,message:it.message,promise:it.promise,dismiss:it.dismiss,loading:it.loading},{getHistory:y1,getToasts:w1});function x1(t,{insertAt:e}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}x1(`: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%)} `);function Ca(t){return t.label!==void 0}var b1=3,_1="32px",k1="16px",Kp=4e3,S1=356,E1=14,C1=20,T1=200;function $t(...t){return t.filter(Boolean).join(" ")}function N1(t){let[e,r]=t.split("-"),n=[];return e&&n.push(e),r&&n.push(r),n}var R1=t=>{var e,r,n,s,i,o,a,l,c,u,d;let{invert:f,toast:h,unstyled:y,interacting:w,setHeights:x,visibleToasts:m,heights:g,index:v,toasts:_,expanded:k,removeToast:S,defaultRichColors:E,closeButton:R,style:P,cancelButtonStyle:I,actionButtonStyle:q,className:F="",descriptionClassName:te="",duration:$,position:ie,gap:K,loadingIcon:Y,expandByDefault:T,classNames:N,icons:M,closeButtonAriaLabel:X="Close toast",pauseWhenPageIsHidden:V}=t,[ne,oe]=O.useState(null),[Ae,He]=O.useState(null),[de,fs]=O.useState(!1),[zr,Ln]=O.useState(!1),[Br,ps]=O.useState(!1),[Wr,sa]=O.useState(!1),[Rc,ia]=O.useState(!1),[jc,Ai]=O.useState(0),[ms,yf]=O.useState(0),Pi=O.useRef(h.duration||$||Kp),wf=O.useRef(null),$n=O.useRef(null),Hw=v===0,qw=v+1<=m,_t=h.type,gs=h.dismissible!==!1,Kw=h.className||"",Gw=h.descriptionClassName||"",oa=O.useMemo(()=>g.findIndex(Q=>Q.toastId===h.id)||0,[g,h.id]),Jw=O.useMemo(()=>{var Q;return(Q=h.closeButton)!=null?Q:R},[h.closeButton,R]),xf=O.useMemo(()=>h.duration||$||Kp,[h.duration,$]),Ac=O.useRef(0),vs=O.useRef(0),bf=O.useRef(0),ys=O.useRef(null),[Qw,Zw]=ie.split("-"),_f=O.useMemo(()=>g.reduce((Q,fe,we)=>we>=oa?Q:Q+fe.height,0),[g,oa]),kf=f1(),Yw=h.invert||f,Pc=_t==="loading";vs.current=O.useMemo(()=>oa*K+_f,[oa,_f]),O.useEffect(()=>{Pi.current=xf},[xf]),O.useEffect(()=>{fs(!0)},[]),O.useEffect(()=>{let Q=$n.current;if(Q){let fe=Q.getBoundingClientRect().height;return yf(fe),x(we=>[{toastId:h.id,height:fe,position:h.position},...we]),()=>x(we=>we.filter(Pt=>Pt.toastId!==h.id))}},[x,h.id]),O.useLayoutEffect(()=>{if(!de)return;let Q=$n.current,fe=Q.style.height;Q.style.height="auto";let we=Q.getBoundingClientRect().height;Q.style.height=fe,yf(we),x(Pt=>Pt.find(Ot=>Ot.toastId===h.id)?Pt.map(Ot=>Ot.toastId===h.id?{...Ot,height:we}:Ot):[{toastId:h.id,height:we,position:h.position},...Pt])},[de,h.title,h.description,x,h.id]);let Vr=O.useCallback(()=>{Ln(!0),Ai(vs.current),x(Q=>Q.filter(fe=>fe.toastId!==h.id)),setTimeout(()=>{S(h)},T1)},[h,S,x,vs]);O.useEffect(()=>{if(h.promise&&_t==="loading"||h.duration===1/0||h.type==="loading")return;let Q;return k||w||V&&kf?(()=>{if(bf.current{var fe;(fe=h.onAutoClose)==null||fe.call(h,h),Vr()},Pi.current)),()=>clearTimeout(Q)},[k,w,h,_t,V,kf,Vr]),O.useEffect(()=>{h.delete&&Vr()},[Vr,h.delete]);function Xw(){var Q,fe,we;return M!=null&&M.loading?O.createElement("div",{className:$t(N==null?void 0:N.loader,(Q=h==null?void 0:h.classNames)==null?void 0:Q.loader,"sonner-loader"),"data-visible":_t==="loading"},M.loading):Y?O.createElement("div",{className:$t(N==null?void 0:N.loader,(fe=h==null?void 0:h.classNames)==null?void 0:fe.loader,"sonner-loader"),"data-visible":_t==="loading"},Y):O.createElement(a1,{className:$t(N==null?void 0:N.loader,(we=h==null?void 0:h.classNames)==null?void 0:we.loader),visible:_t==="loading"})}return O.createElement("li",{tabIndex:0,ref:$n,className:$t(F,Kw,N==null?void 0:N.toast,(e=h==null?void 0:h.classNames)==null?void 0:e.toast,N==null?void 0:N.default,N==null?void 0:N[_t],(r=h==null?void 0:h.classNames)==null?void 0:r[_t]),"data-sonner-toast":"","data-rich-colors":(n=h.richColors)!=null?n:E,"data-styled":!(h.jsx||h.unstyled||y),"data-mounted":de,"data-promise":!!h.promise,"data-swiped":Rc,"data-removed":zr,"data-visible":qw,"data-y-position":Qw,"data-x-position":Zw,"data-index":v,"data-front":Hw,"data-swiping":Br,"data-dismissible":gs,"data-type":_t,"data-invert":Yw,"data-swipe-out":Wr,"data-swipe-direction":Ae,"data-expanded":!!(k||T&&de),style:{"--index":v,"--toasts-before":v,"--z-index":_.length-v,"--offset":`${zr?jc:vs.current}px`,"--initial-height":T?"auto":`${ms}px`,...P,...h.style},onDragEnd:()=>{ps(!1),oe(null),ys.current=null},onPointerDown:Q=>{Pc||!gs||(wf.current=new Date,Ai(vs.current),Q.target.setPointerCapture(Q.pointerId),Q.target.tagName!=="BUTTON"&&(ps(!0),ys.current={x:Q.clientX,y:Q.clientY}))},onPointerUp:()=>{var Q,fe,we,Pt;if(Wr||!gs)return;ys.current=null;let Ot=Number(((Q=$n.current)==null?void 0:Q.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Hr=Number(((fe=$n.current)==null?void 0:fe.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Dn=new Date().getTime()-((we=wf.current)==null?void 0:we.getTime()),It=ne==="x"?Ot:Hr,qr=Math.abs(It)/Dn;if(Math.abs(It)>=C1||qr>.11){Ai(vs.current),(Pt=h.onDismiss)==null||Pt.call(h,h),He(ne==="x"?Ot>0?"right":"left":Hr>0?"down":"up"),Vr(),sa(!0),ia(!1);return}ps(!1),oe(null)},onPointerMove:Q=>{var fe,we,Pt,Ot;if(!ys.current||!gs||((fe=window.getSelection())==null?void 0:fe.toString().length)>0)return;let Hr=Q.clientY-ys.current.y,Dn=Q.clientX-ys.current.x,It=(we=t.swipeDirections)!=null?we:N1(ie);!ne&&(Math.abs(Dn)>1||Math.abs(Hr)>1)&&oe(Math.abs(Dn)>Math.abs(Hr)?"x":"y");let qr={x:0,y:0};ne==="y"?(It.includes("top")||It.includes("bottom"))&&(It.includes("top")&&Hr<0||It.includes("bottom")&&Hr>0)&&(qr.y=Hr):ne==="x"&&(It.includes("left")||It.includes("right"))&&(It.includes("left")&&Dn<0||It.includes("right")&&Dn>0)&&(qr.x=Dn),(Math.abs(qr.x)>0||Math.abs(qr.y)>0)&&ia(!0),(Pt=$n.current)==null||Pt.style.setProperty("--swipe-amount-x",`${qr.x}px`),(Ot=$n.current)==null||Ot.style.setProperty("--swipe-amount-y",`${qr.y}px`)}},Jw&&!h.jsx?O.createElement("button",{"aria-label":X,"data-disabled":Pc,"data-close-button":!0,onClick:Pc||!gs?()=>{}:()=>{var Q;Vr(),(Q=h.onDismiss)==null||Q.call(h,h)},className:$t(N==null?void 0:N.closeButton,(s=h==null?void 0:h.classNames)==null?void 0:s.closeButton)},(i=M==null?void 0:M.close)!=null?i:h1):null,h.jsx||b.isValidElement(h.title)?h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title:O.createElement(O.Fragment,null,_t||h.icon||h.promise?O.createElement("div",{"data-icon":"",className:$t(N==null?void 0:N.icon,(o=h==null?void 0:h.classNames)==null?void 0:o.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||Xw():null,h.type!=="loading"?h.icon||(M==null?void 0:M[_t])||i1(_t):null):null,O.createElement("div",{"data-content":"",className:$t(N==null?void 0:N.content,(a=h==null?void 0:h.classNames)==null?void 0:a.content)},O.createElement("div",{"data-title":"",className:$t(N==null?void 0:N.title,(l=h==null?void 0:h.classNames)==null?void 0:l.title)},typeof h.title=="function"?h.title():h.title),h.description?O.createElement("div",{"data-description":"",className:$t(te,Gw,N==null?void 0:N.description,(c=h==null?void 0:h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),b.isValidElement(h.cancel)?h.cancel:h.cancel&&Ca(h.cancel)?O.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||I,onClick:Q=>{var fe,we;Ca(h.cancel)&&gs&&((we=(fe=h.cancel).onClick)==null||we.call(fe,Q),Vr())},className:$t(N==null?void 0:N.cancelButton,(u=h==null?void 0:h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,b.isValidElement(h.action)?h.action:h.action&&Ca(h.action)?O.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||q,onClick:Q=>{var fe,we;Ca(h.action)&&((we=(fe=h.action).onClick)==null||we.call(fe,Q),!Q.defaultPrevented&&Vr())},className:$t(N==null?void 0:N.actionButton,(d=h==null?void 0:h.classNames)==null?void 0:d.actionButton)},h.action.label):null))};function Gp(){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 j1(t,e){let r={};return[t,e].forEach((n,s)=>{let i=s===1,o=i?"--mobile-offset":"--offset",a=i?k1:_1;function l(c){["top","right","bottom","left"].forEach(u=>{r[`${o}-${u}`]=typeof c=="number"?`${c}px`:c})}typeof n=="number"||typeof n=="string"?l(n):typeof n=="object"?["top","right","bottom","left"].forEach(c=>{n[c]===void 0?r[`${o}-${c}`]=a:r[`${o}-${c}`]=typeof n[c]=="number"?`${n[c]}px`:n[c]}):l(a)}),r}var A1=b.forwardRef(function(t,e){let{invert:r,position:n="bottom-right",hotkey:s=["altKey","KeyT"],expand:i,closeButton:o,className:a,offset:l,mobileOffset:c,theme:u="light",richColors:d,duration:f,style:h,visibleToasts:y=b1,toastOptions:w,dir:x=Gp(),gap:m=E1,loadingIcon:g,icons:v,containerAriaLabel:_="Notifications",pauseWhenPageIsHidden:k}=t,[S,E]=O.useState([]),R=O.useMemo(()=>Array.from(new Set([n].concat(S.filter(V=>V.position).map(V=>V.position)))),[S,n]),[P,I]=O.useState([]),[q,F]=O.useState(!1),[te,$]=O.useState(!1),[ie,K]=O.useState(u!=="system"?u:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Y=O.useRef(null),T=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),N=O.useRef(null),M=O.useRef(!1),X=O.useCallback(V=>{E(ne=>{var oe;return(oe=ne.find(Ae=>Ae.id===V.id))!=null&&oe.delete||it.dismiss(V.id),ne.filter(({id:Ae})=>Ae!==V.id)})},[]);return O.useEffect(()=>it.subscribe(V=>{if(V.dismiss){E(ne=>ne.map(oe=>oe.id===V.id?{...oe,delete:!0}:oe));return}setTimeout(()=>{Ay.flushSync(()=>{E(ne=>{let oe=ne.findIndex(Ae=>Ae.id===V.id);return oe!==-1?[...ne.slice(0,oe),{...ne[oe],...V},...ne.slice(oe+1)]:[V,...ne]})})})}),[]),O.useEffect(()=>{if(u!=="system"){K(u);return}if(u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;let V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:ne})=>{K(ne?"dark":"light")})}catch{V.addListener(({matches:oe})=>{try{K(oe?"dark":"light")}catch(Ae){console.error(Ae)}})}},[u]),O.useEffect(()=>{S.length<=1&&F(!1)},[S]),O.useEffect(()=>{let V=ne=>{var oe,Ae;s.every(He=>ne[He]||ne.code===He)&&(F(!0),(oe=Y.current)==null||oe.focus()),ne.code==="Escape"&&(document.activeElement===Y.current||(Ae=Y.current)!=null&&Ae.contains(document.activeElement))&&F(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[s]),O.useEffect(()=>{if(Y.current)return()=>{N.current&&(N.current.focus({preventScroll:!0}),N.current=null,M.current=!1)}},[Y.current]),O.createElement("section",{ref:e,"aria-label":`${_} ${T}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},R.map((V,ne)=>{var oe;let[Ae,He]=V.split("-");return S.length?O.createElement("ol",{key:V,dir:x==="auto"?Gp():x,tabIndex:-1,ref:Y,className:a,"data-sonner-toaster":!0,"data-theme":ie,"data-y-position":Ae,"data-lifted":q&&S.length>1&&!i,"data-x-position":He,style:{"--front-toast-height":`${((oe=P[0])==null?void 0:oe.height)||0}px`,"--width":`${S1}px`,"--gap":`${m}px`,...h,...j1(l,c)},onBlur:de=>{M.current&&!de.currentTarget.contains(de.relatedTarget)&&(M.current=!1,N.current&&(N.current.focus({preventScroll:!0}),N.current=null))},onFocus:de=>{de.target instanceof HTMLElement&&de.target.dataset.dismissible==="false"||M.current||(M.current=!0,N.current=de.relatedTarget)},onMouseEnter:()=>F(!0),onMouseMove:()=>F(!0),onMouseLeave:()=>{te||F(!1)},onDragEnd:()=>F(!1),onPointerDown:de=>{de.target instanceof HTMLElement&&de.target.dataset.dismissible==="false"||$(!0)},onPointerUp:()=>$(!1)},S.filter(de=>!de.position&&ne===0||de.position===V).map((de,fs)=>{var zr,Ln;return O.createElement(R1,{key:de.id,icons:v,index:fs,toast:de,defaultRichColors:d,duration:(zr=w==null?void 0:w.duration)!=null?zr:f,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:r,visibleToasts:y,closeButton:(Ln=w==null?void 0:w.closeButton)!=null?Ln:o,interacting:te,position:V,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,removeToast:X,toasts:S.filter(Br=>Br.position==de.position),heights:P.filter(Br=>Br.position==de.position),setHeights:I,expandByDefault:i,gap:m,loadingIcon:g,expanded:q,pauseWhenPageIsHidden:k,swipeDirections:t.swipeDirections})})):null}))});const P1=({...t})=>{const{theme:e="system"}=s1();return p.jsx(A1,{theme:e,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})},O1=1,I1=1e6;let lu=0;function L1(){return lu=(lu+1)%Number.MAX_SAFE_INTEGER,lu.toString()}const cu=new Map,Jp=t=>{if(cu.has(t))return;const e=setTimeout(()=>{cu.delete(t),lo({type:"REMOVE_TOAST",toastId:t})},I1);cu.set(t,e)},$1=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,O1)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(r=>r.id===e.toast.id?{...r,...e.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=e;return r?Jp(r):t.toasts.forEach(n=>{Jp(n.id)}),{...t,toasts:t.toasts.map(n=>n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(r=>r.id!==e.toastId)}}},Za=[];let Ya={toasts:[]};function lo(t){Ya=$1(Ya,t),Za.forEach(e=>{e(Ya)})}function D1({...t}){const e=L1(),r=s=>lo({type:"UPDATE_TOAST",toast:{...s,id:e}}),n=()=>lo({type:"DISMISS_TOAST",toastId:e});return lo({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:s=>{s||n()}}}),{id:e,dismiss:n,update:r}}function M1(){const[t,e]=b.useState(Ya);return b.useEffect(()=>(Za.push(e),()=>{const r=Za.indexOf(e);r>-1&&Za.splice(r,1)}),[t]),{...t,toast:D1,dismiss:r=>lo({type:"DISMISS_TOAST",toastId:r})}}function Le(t,e,{checkForDefaultPrevented:r=!0}={}){return function(s){if(t==null||t(s),r===!1||!s.defaultPrevented)return e==null?void 0:e(s)}}function Qp(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Qy(...t){return e=>{let r=!1;const n=t.map(s=>{const i=Qp(s,e);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let s=0;s{var m;const{scope:f,children:h,...y}=d,w=((m=f==null?void 0:f[t])==null?void 0:m[l])||a,x=b.useMemo(()=>y,Object.values(y));return p.jsx(w.Provider,{value:x,children:h})};c.displayName=i+"Provider";function u(d,f){var w;const h=((w=f==null?void 0:f[t])==null?void 0:w[l])||a,y=b.useContext(h);if(y)return y;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[c,u]}const s=()=>{const i=r.map(o=>b.createContext(o));return function(a){const l=(a==null?void 0:a[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return s.scopeName=t,[n,U1(s,...e)]}function U1(...t){const e=t[0];if(t.length===1)return e;const r=()=>{const n=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(i){const o=n.reduce((a,{useScope:l,scopeName:c})=>{const d=l(i)[`__scope${c}`];return{...a,...d}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return r.scopeName=e.scopeName,r}function vd(t){const e=F1(t),r=b.forwardRef((n,s)=>{const{children:i,...o}=n,a=b.Children.toArray(i),l=a.find(B1);if(l){const c=l.props.children,u=a.map(d=>d===l?b.Children.count(c)>1?b.Children.only(null):b.isValidElement(c)?c.props.children:null:d);return p.jsx(e,{...o,ref:s,children:b.isValidElement(c)?b.cloneElement(c,void 0,u):null})}return p.jsx(e,{...o,ref:s,children:i})});return r.displayName=`${t}.Slot`,r}function F1(t){const e=b.forwardRef((r,n)=>{const{children:s,...i}=r;if(b.isValidElement(s)){const o=V1(s),a=W1(i,s.props);return s.type!==b.Fragment&&(a.ref=n?Qy(n,o):o),b.cloneElement(s,a)}return b.Children.count(s)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var Zy=Symbol("radix.slottable");function z1(t){const e=({children:r})=>p.jsx(p.Fragment,{children:r});return e.displayName=`${t}.Slottable`,e.__radixId=Zy,e}function B1(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Zy}function W1(t,e){const r={...e};for(const n in e){const s=t[n],i=e[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...a)=>{const l=i(...a);return s(...a),l}:s&&(r[n]=s):n==="style"?r[n]={...s,...i}:n==="className"&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...t,...r}}function V1(t){var n,s;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function H1(t){const e=t+"CollectionProvider",[r,n]=gc(e),[s,i]=r(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:x,children:m}=w,g=O.useRef(null),v=O.useRef(new Map).current;return p.jsx(s,{scope:x,itemMap:v,collectionRef:g,children:m})};o.displayName=e;const a=t+"CollectionSlot",l=vd(a),c=O.forwardRef((w,x)=>{const{scope:m,children:g}=w,v=i(a,m),_=Jt(x,v.collectionRef);return p.jsx(l,{ref:_,children:g})});c.displayName=a;const u=t+"CollectionItemSlot",d="data-radix-collection-item",f=vd(u),h=O.forwardRef((w,x)=>{const{scope:m,children:g,...v}=w,_=O.useRef(null),k=Jt(x,_),S=i(u,m);return O.useEffect(()=>(S.itemMap.set(_,{ref:_,...v}),()=>void S.itemMap.delete(_))),p.jsx(f,{[d]:"",ref:k,children:g})});h.displayName=u;function y(w){const x=i(t+"CollectionConsumer",w);return O.useCallback(()=>{const g=x.collectionRef.current;if(!g)return[];const v=Array.from(g.querySelectorAll(`[${d}]`));return Array.from(x.itemMap.values()).sort((S,E)=>v.indexOf(S.ref.current)-v.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:o,Slot:c,ItemSlot:h},y,n]}var q1=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],dt=q1.reduce((t,e)=>{const r=vd(`Primitive.${e}`),n=b.forwardRef((s,i)=>{const{asChild:o,...a}=s,l=o?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(l,{...a,ref:i})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function Yy(t,e){t&&ea.flushSync(()=>t.dispatchEvent(e))}function Cn(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...r)=>{var n;return(n=e.current)==null?void 0:n.call(e,...r)},[])}function K1(t,e=globalThis==null?void 0:globalThis.document){const r=Cn(t);b.useEffect(()=>{const n=s=>{s.key==="Escape"&&r(s)};return e.addEventListener("keydown",n,{capture:!0}),()=>e.removeEventListener("keydown",n,{capture:!0})},[r,e])}var G1="DismissableLayer",yd="dismissableLayer.update",J1="dismissableLayer.pointerDownOutside",Q1="dismissableLayer.focusOutside",Zp,Xy=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Kh=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:o,onDismiss:a,...l}=t,c=b.useContext(Xy),[u,d]=b.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,h]=b.useState({}),y=Jt(e,E=>d(E)),w=Array.from(c.layers),[x]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),m=w.indexOf(x),g=u?w.indexOf(u):-1,v=c.layersWithOutsidePointerEventsDisabled.size>0,_=g>=m,k=Y1(E=>{const R=E.target,P=[...c.branches].some(I=>I.contains(R));!_||P||(s==null||s(E),o==null||o(E),E.defaultPrevented||a==null||a())},f),S=X1(E=>{const R=E.target;[...c.branches].some(I=>I.contains(R))||(i==null||i(E),o==null||o(E),E.defaultPrevented||a==null||a())},f);return K1(E=>{g===c.layers.size-1&&(n==null||n(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},f),b.useEffect(()=>{if(u)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Zp=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),Yp(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Zp)}},[u,f,r,c]),b.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),Yp())},[u,c]),b.useEffect(()=>{const E=()=>h({});return document.addEventListener(yd,E),()=>document.removeEventListener(yd,E)},[]),p.jsx(dt.div,{...l,ref:y,style:{pointerEvents:v?_?"auto":"none":void 0,...t.style},onFocusCapture:Le(t.onFocusCapture,S.onFocusCapture),onBlurCapture:Le(t.onBlurCapture,S.onBlurCapture),onPointerDownCapture:Le(t.onPointerDownCapture,k.onPointerDownCapture)})});Kh.displayName=G1;var Z1="DismissableLayerBranch",e0=b.forwardRef((t,e)=>{const r=b.useContext(Xy),n=b.useRef(null),s=Jt(e,n);return b.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),p.jsx(dt.div,{...t,ref:s})});e0.displayName=Z1;function Y1(t,e=globalThis==null?void 0:globalThis.document){const r=Cn(t),n=b.useRef(!1),s=b.useRef(()=>{});return b.useEffect(()=>{const i=a=>{if(a.target&&!n.current){let l=function(){t0(J1,r,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",s.current),s.current=l,e.addEventListener("click",s.current,{once:!0})):l()}else e.removeEventListener("click",s.current);n.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",s.current)}},[e,r]),{onPointerDownCapture:()=>n.current=!0}}function X1(t,e=globalThis==null?void 0:globalThis.document){const r=Cn(t),n=b.useRef(!1);return b.useEffect(()=>{const s=i=>{i.target&&!n.current&&t0(Q1,r,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function Yp(){const t=new CustomEvent(yd);document.dispatchEvent(t)}function t0(t,e,r,{discrete:n}){const s=r.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:r});e&&s.addEventListener(t,e,{once:!0}),n?Yy(s,i):s.dispatchEvent(i)}var eS=Kh,tS=e0,Tn=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},rS="Portal",r0=b.forwardRef((t,e)=>{var a;const{container:r,...n}=t,[s,i]=b.useState(!1);Tn(()=>i(!0),[]);const o=r||s&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?Ay.createPortal(p.jsx(dt.div,{...n,ref:e}),o):null});r0.displayName=rS;function nS(t,e){return b.useReducer((r,n)=>e[r][n]??r,t)}var Gh=t=>{const{present:e,children:r}=t,n=sS(e),s=typeof r=="function"?r({present:n.isPresent}):b.Children.only(r),i=Jt(n.ref,iS(s));return typeof r=="function"||n.isPresent?b.cloneElement(s,{ref:i}):null};Gh.displayName="Presence";function sS(t){const[e,r]=b.useState(),n=b.useRef(null),s=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[a,l]=nS(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const c=Ta(n.current);i.current=a==="mounted"?c:"none"},[a]),Tn(()=>{const c=n.current,u=s.current;if(u!==t){const f=i.current,h=Ta(c);t?l("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&f!==h?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,l]),Tn(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,d=h=>{const w=Ta(n.current).includes(h.animationName);if(h.target===e&&w&&(l("ANIMATION_END"),!s.current)){const x=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=x)})}},f=h=>{h.target===e&&(i.current=Ta(n.current))};return e.addEventListener("animationstart",f),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",f),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:b.useCallback(c=>{n.current=c?getComputedStyle(c):null,r(c)},[])}}function Ta(t){return(t==null?void 0:t.animationName)||"none"}function iS(t){var n,s;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var oS=Ng[" useInsertionEffect ".trim().toString()]||Tn;function aS({prop:t,defaultProp:e,onChange:r=()=>{},caller:n}){const[s,i,o]=lS({defaultProp:e,onChange:r}),a=t!==void 0,l=a?t:s;{const u=b.useRef(t!==void 0);b.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${n} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,n])}const c=b.useCallback(u=>{var d;if(a){const f=cS(u)?u(t):u;f!==t&&((d=o.current)==null||d.call(o,f))}else i(u)},[a,t,i,o]);return[l,c]}function lS({defaultProp:t,onChange:e}){const[r,n]=b.useState(t),s=b.useRef(r),i=b.useRef(e);return oS(()=>{i.current=e},[e]),b.useEffect(()=>{var o;s.current!==r&&((o=i.current)==null||o.call(i,r),s.current=r)},[r,s]),[r,n,i]}function cS(t){return typeof t=="function"}var uS=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),dS="VisuallyHidden",vc=b.forwardRef((t,e)=>p.jsx(dt.span,{...t,ref:e,style:{...uS,...t.style}}));vc.displayName=dS;var hS=vc,Jh="ToastProvider",[Qh,fS,pS]=H1("Toast"),[n0,aA]=gc("Toast",[pS]),[mS,yc]=n0(Jh),s0=t=>{const{__scopeToast:e,label:r="Notification",duration:n=5e3,swipeDirection:s="right",swipeThreshold:i=50,children:o}=t,[a,l]=b.useState(null),[c,u]=b.useState(0),d=b.useRef(!1),f=b.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${Jh}\`. Expected non-empty \`string\`.`),p.jsx(Qh.Provider,{scope:e,children:p.jsx(mS,{scope:e,label:r,duration:n,swipeDirection:s,swipeThreshold:i,toastCount:c,viewport:a,onViewportChange:l,onToastAdd:b.useCallback(()=>u(h=>h+1),[]),onToastRemove:b.useCallback(()=>u(h=>h-1),[]),isFocusedToastEscapeKeyDownRef:d,isClosePausedRef:f,children:o})})};s0.displayName=Jh;var i0="ToastViewport",gS=["F8"],wd="toast.viewportPause",xd="toast.viewportResume",o0=b.forwardRef((t,e)=>{const{__scopeToast:r,hotkey:n=gS,label:s="Notifications ({hotkey})",...i}=t,o=yc(i0,r),a=fS(r),l=b.useRef(null),c=b.useRef(null),u=b.useRef(null),d=b.useRef(null),f=Jt(e,d,o.onViewportChange),h=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),y=o.toastCount>0;b.useEffect(()=>{const x=m=>{var v;n.length!==0&&n.every(_=>m[_]||m.code===_)&&((v=d.current)==null||v.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[n]),b.useEffect(()=>{const x=l.current,m=d.current;if(y&&x&&m){const g=()=>{if(!o.isClosePausedRef.current){const S=new CustomEvent(wd);m.dispatchEvent(S),o.isClosePausedRef.current=!0}},v=()=>{if(o.isClosePausedRef.current){const S=new CustomEvent(xd);m.dispatchEvent(S),o.isClosePausedRef.current=!1}},_=S=>{!x.contains(S.relatedTarget)&&v()},k=()=>{x.contains(document.activeElement)||v()};return x.addEventListener("focusin",g),x.addEventListener("focusout",_),x.addEventListener("pointermove",g),x.addEventListener("pointerleave",k),window.addEventListener("blur",g),window.addEventListener("focus",v),()=>{x.removeEventListener("focusin",g),x.removeEventListener("focusout",_),x.removeEventListener("pointermove",g),x.removeEventListener("pointerleave",k),window.removeEventListener("blur",g),window.removeEventListener("focus",v)}}},[y,o.isClosePausedRef]);const w=b.useCallback(({tabbingDirection:x})=>{const g=a().map(v=>{const _=v.ref.current,k=[_,...RS(_)];return x==="forwards"?k:k.reverse()});return(x==="forwards"?g.reverse():g).flat()},[a]);return b.useEffect(()=>{const x=d.current;if(x){const m=g=>{var k,S,E;const v=g.altKey||g.ctrlKey||g.metaKey;if(g.key==="Tab"&&!v){const R=document.activeElement,P=g.shiftKey;if(g.target===x&&P){(k=c.current)==null||k.focus();return}const F=w({tabbingDirection:P?"backwards":"forwards"}),te=F.findIndex($=>$===R);uu(F.slice(te+1))?g.preventDefault():P?(S=c.current)==null||S.focus():(E=u.current)==null||E.focus()}};return x.addEventListener("keydown",m),()=>x.removeEventListener("keydown",m)}},[a,w]),p.jsxs(tS,{ref:l,role:"region","aria-label":s.replace("{hotkey}",h),tabIndex:-1,style:{pointerEvents:y?void 0:"none"},children:[y&&p.jsx(bd,{ref:c,onFocusFromOutsideViewport:()=>{const x=w({tabbingDirection:"forwards"});uu(x)}}),p.jsx(Qh.Slot,{scope:r,children:p.jsx(dt.ol,{tabIndex:-1,...i,ref:f})}),y&&p.jsx(bd,{ref:u,onFocusFromOutsideViewport:()=>{const x=w({tabbingDirection:"backwards"});uu(x)}})]})});o0.displayName=i0;var a0="ToastFocusProxy",bd=b.forwardRef((t,e)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...s}=t,i=yc(a0,r);return p.jsx(vc,{"aria-hidden":!0,tabIndex:0,...s,ref:e,style:{position:"fixed"},onFocus:o=>{var c;const a=o.relatedTarget;!((c=i.viewport)!=null&&c.contains(a))&&n()}})});bd.displayName=a0;var ta="Toast",vS="toast.swipeStart",yS="toast.swipeMove",wS="toast.swipeCancel",xS="toast.swipeEnd",l0=b.forwardRef((t,e)=>{const{forceMount:r,open:n,defaultOpen:s,onOpenChange:i,...o}=t,[a,l]=aS({prop:n,defaultProp:s??!0,onChange:i,caller:ta});return p.jsx(Gh,{present:r||a,children:p.jsx(kS,{open:a,...o,ref:e,onClose:()=>l(!1),onPause:Cn(t.onPause),onResume:Cn(t.onResume),onSwipeStart:Le(t.onSwipeStart,c=>{c.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Le(t.onSwipeMove,c=>{const{x:u,y:d}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","move"),c.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${d}px`)}),onSwipeCancel:Le(t.onSwipeCancel,c=>{c.currentTarget.setAttribute("data-swipe","cancel"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Le(t.onSwipeEnd,c=>{const{x:u,y:d}=c.detail.delta;c.currentTarget.setAttribute("data-swipe","end"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),c.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),c.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),c.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${d}px`),l(!1)})})})});l0.displayName=ta;var[bS,_S]=n0(ta,{onClose(){}}),kS=b.forwardRef((t,e)=>{const{__scopeToast:r,type:n="foreground",duration:s,open:i,onClose:o,onEscapeKeyDown:a,onPause:l,onResume:c,onSwipeStart:u,onSwipeMove:d,onSwipeCancel:f,onSwipeEnd:h,...y}=t,w=yc(ta,r),[x,m]=b.useState(null),g=Jt(e,$=>m($)),v=b.useRef(null),_=b.useRef(null),k=s||w.duration,S=b.useRef(0),E=b.useRef(k),R=b.useRef(0),{onToastAdd:P,onToastRemove:I}=w,q=Cn(()=>{var ie;(x==null?void 0:x.contains(document.activeElement))&&((ie=w.viewport)==null||ie.focus()),o()}),F=b.useCallback($=>{!$||$===1/0||(window.clearTimeout(R.current),S.current=new Date().getTime(),R.current=window.setTimeout(q,$))},[q]);b.useEffect(()=>{const $=w.viewport;if($){const ie=()=>{F(E.current),c==null||c()},K=()=>{const Y=new Date().getTime()-S.current;E.current=E.current-Y,window.clearTimeout(R.current),l==null||l()};return $.addEventListener(wd,K),$.addEventListener(xd,ie),()=>{$.removeEventListener(wd,K),$.removeEventListener(xd,ie)}}},[w.viewport,k,l,c,F]),b.useEffect(()=>{i&&!w.isClosePausedRef.current&&F(k)},[i,k,w.isClosePausedRef,F]),b.useEffect(()=>(P(),()=>I()),[P,I]);const te=b.useMemo(()=>x?m0(x):null,[x]);return w.viewport?p.jsxs(p.Fragment,{children:[te&&p.jsx(SS,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:te}),p.jsx(bS,{scope:r,onClose:q,children:ea.createPortal(p.jsx(Qh.ItemSlot,{scope:r,children:p.jsx(eS,{asChild:!0,onEscapeKeyDown:Le(a,()=>{w.isFocusedToastEscapeKeyDownRef.current||q(),w.isFocusedToastEscapeKeyDownRef.current=!1}),children:p.jsx(dt.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":w.swipeDirection,...y,ref:g,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Le(t.onKeyDown,$=>{$.key==="Escape"&&(a==null||a($.nativeEvent),$.nativeEvent.defaultPrevented||(w.isFocusedToastEscapeKeyDownRef.current=!0,q()))}),onPointerDown:Le(t.onPointerDown,$=>{$.button===0&&(v.current={x:$.clientX,y:$.clientY})}),onPointerMove:Le(t.onPointerMove,$=>{if(!v.current)return;const ie=$.clientX-v.current.x,K=$.clientY-v.current.y,Y=!!_.current,T=["left","right"].includes(w.swipeDirection),N=["left","up"].includes(w.swipeDirection)?Math.min:Math.max,M=T?N(0,ie):0,X=T?0:N(0,K),V=$.pointerType==="touch"?10:2,ne={x:M,y:X},oe={originalEvent:$,delta:ne};Y?(_.current=ne,Na(yS,d,oe,{discrete:!1})):Xp(ne,w.swipeDirection,V)?(_.current=ne,Na(vS,u,oe,{discrete:!1}),$.target.setPointerCapture($.pointerId)):(Math.abs(ie)>V||Math.abs(K)>V)&&(v.current=null)}),onPointerUp:Le(t.onPointerUp,$=>{const ie=_.current,K=$.target;if(K.hasPointerCapture($.pointerId)&&K.releasePointerCapture($.pointerId),_.current=null,v.current=null,ie){const Y=$.currentTarget,T={originalEvent:$,delta:ie};Xp(ie,w.swipeDirection,w.swipeThreshold)?Na(xS,h,T,{discrete:!0}):Na(wS,f,T,{discrete:!0}),Y.addEventListener("click",N=>N.preventDefault(),{once:!0})}})})})}),w.viewport)})]}):null}),SS=t=>{const{__scopeToast:e,children:r,...n}=t,s=yc(ta,e),[i,o]=b.useState(!1),[a,l]=b.useState(!1);return TS(()=>o(!0)),b.useEffect(()=>{const c=window.setTimeout(()=>l(!0),1e3);return()=>window.clearTimeout(c)},[]),a?null:p.jsx(r0,{asChild:!0,children:p.jsx(vc,{...n,children:i&&p.jsxs(p.Fragment,{children:[s.label," ",r]})})})},ES="ToastTitle",c0=b.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return p.jsx(dt.div,{...n,ref:e})});c0.displayName=ES;var CS="ToastDescription",u0=b.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return p.jsx(dt.div,{...n,ref:e})});u0.displayName=CS;var d0="ToastAction",h0=b.forwardRef((t,e)=>{const{altText:r,...n}=t;return r.trim()?p.jsx(p0,{altText:r,asChild:!0,children:p.jsx(Zh,{...n,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${d0}\`. Expected non-empty \`string\`.`),null)});h0.displayName=d0;var f0="ToastClose",Zh=b.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t,s=_S(f0,r);return p.jsx(p0,{asChild:!0,children:p.jsx(dt.button,{type:"button",...n,ref:e,onClick:Le(t.onClick,s.onClose)})})});Zh.displayName=f0;var p0=b.forwardRef((t,e)=>{const{__scopeToast:r,altText:n,...s}=t;return p.jsx(dt.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...s,ref:e})});function m0(t){const e=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&e.push(n.textContent),NS(n)){const s=n.ariaHidden||n.hidden||n.style.display==="none",i=n.dataset.radixToastAnnounceExclude==="";if(!s)if(i){const o=n.dataset.radixToastAnnounceAlt;o&&e.push(o)}else e.push(...m0(n))}}),e}function Na(t,e,r,{discrete:n}){const s=r.originalEvent.currentTarget,i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r});e&&s.addEventListener(t,e,{once:!0}),n?Yy(s,i):s.dispatchEvent(i)}var Xp=(t,e,r=0)=>{const n=Math.abs(t.x),s=Math.abs(t.y),i=n>s;return e==="left"||e==="right"?i&&n>r:!i&&s>r};function TS(t=()=>{}){const e=Cn(t);Tn(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[e])}function NS(t){return t.nodeType===t.ELEMENT_NODE}function RS(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||s?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function uu(t){const e=document.activeElement;return t.some(r=>r===e?!0:(r.focus(),document.activeElement!==e))}var jS=s0,g0=o0,v0=l0,y0=c0,w0=u0,x0=h0,b0=Zh;function _0(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,tm=k0,AS=(t,e)=>r=>{var n;if((e==null?void 0:e.variants)==null)return tm(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:s,defaultVariants:i}=e,o=Object.keys(s).map(c=>{const u=r==null?void 0:r[c],d=i==null?void 0:i[c];if(u===null)return null;const f=em(u)||em(d);return s[c][f]}),a=r&&Object.entries(r).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),l=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((c,u)=>{let{class:d,className:f,...h}=u;return Object.entries(h).every(y=>{let[w,x]=y;return Array.isArray(x)?x.includes({...i,...a}[w]):{...i,...a}[w]===x})?[...c,d,f]:c},[]);return tm(t,o,l,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PS=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),S0=(...t)=>t.filter((e,r,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===r).join(" ").trim();/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var OS={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"};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IS=b.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:i,iconNode:o,...a},l)=>b.createElement("svg",{ref:l,...OS,width:e,height:e,stroke:t,strokeWidth:n?Number(r)*24/Number(e):r,className:S0("lucide",s),...a},[...o.map(([c,u])=>b.createElement(c,u)),...Array.isArray(i)?i:[i]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const je=(t,e)=>{const r=b.forwardRef(({className:n,...s},i)=>b.createElement(IS,{ref:i,iconNode:e,className:S0(`lucide-${PS(t)}`,n),...s}));return r.displayName=`${t}`,r};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yh=je("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E0=je("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xh=je("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LS=je("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ef=je("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $S=je("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DS=je("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MS=je("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const US=je("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tf=je("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FS=je("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C0=je("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zS=je("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BS=je("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T0=je("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WS=je("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VS=je("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HS=je("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qS=je("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KS=je("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N0=je("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),rf="-",GS=t=>{const e=QS(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:o=>{const a=o.split(rf);return a[0]===""&&a.length!==1&&a.shift(),R0(a,e)||JS(o)},getConflictingClassGroupIds:(o,a)=>{const l=r[o]||[];return a&&n[o]?[...l,...n[o]]:l}}},R0=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const r=t[0],n=e.nextPart.get(r),s=n?R0(t.slice(1),n):void 0;if(s)return s;if(e.validators.length===0)return;const i=t.join(rf);return(o=e.validators.find(({validator:a})=>a(i)))==null?void 0:o.classGroupId},rm=/^\[(.+)\]$/,JS=t=>{if(rm.test(t)){const e=rm.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},QS=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return YS(Object.entries(t.classGroups),r).forEach(([i,o])=>{_d(o,n,i,e)}),n},_d=(t,e,r,n)=>{t.forEach(s=>{if(typeof s=="string"){const i=s===""?e:nm(e,s);i.classGroupId=r;return}if(typeof s=="function"){if(ZS(s)){_d(s(n),e,r,n);return}e.validators.push({validator:s,classGroupId:r});return}Object.entries(s).forEach(([i,o])=>{_d(o,nm(e,i),r,n)})})},nm=(t,e)=>{let r=t;return e.split(rf).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},ZS=t=>t.isThemeGetter,YS=(t,e)=>e?t.map(([r,n])=>{const s=n.map(i=>typeof i=="string"?e+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,a])=>[e+o,a])):i);return[r,s]}):t,XS=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const s=(i,o)=>{r.set(i,o),e++,e>t&&(e=0,n=r,r=new Map)};return{get(i){let o=r.get(i);if(o!==void 0)return o;if((o=n.get(i))!==void 0)return s(i,o),o},set(i,o){r.has(i)?r.set(i,o):s(i,o)}}},j0="!",eE=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,s=e[0],i=e.length,o=a=>{const l=[];let c=0,u=0,d;for(let x=0;xu?d-u:void 0;return{modifiers:l,hasImportantModifier:h,baseClassName:y,maybePostfixModifierPosition:w}};return r?a=>r({className:a,parseClassName:o}):o},tE=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},rE=t=>({cache:XS(t.cacheSize),parseClassName:eE(t),...GS(t)}),nE=/\s+/,sE=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:s}=e,i=[],o=t.trim().split(nE);let a="";for(let l=o.length-1;l>=0;l-=1){const c=o[l],{modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:h}=r(c);let y=!!h,w=n(y?f.substring(0,h):f);if(!w){if(!y){a=c+(a.length>0?" "+a:a);continue}if(w=n(f),!w){a=c+(a.length>0?" "+a:a);continue}y=!1}const x=tE(u).join(":"),m=d?x+j0:x,g=m+w;if(i.includes(g))continue;i.push(g);const v=s(w,y);for(let _=0;_0?" "+a:a)}return a};function iE(){let t=0,e,r,n="";for(;t{if(typeof t=="string")return t;let e,r="";for(let n=0;nd(u),t());return r=rE(c),n=r.cache.get,s=r.cache.set,i=a,a(l)}function a(l){const c=n(l);if(c)return c;const u=sE(l,r);return s(l,u),u}return function(){return i(iE.apply(null,arguments))}}const ge=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},P0=/^\[(?:([a-z-]+):)?(.+)\]$/i,aE=/^\d+\/\d+$/,lE=new Set(["px","full","screen"]),cE=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uE=/\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$/,dE=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,hE=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,fE=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yr=t=>Qs(t)||lE.has(t)||aE.test(t),Gr=t=>Ti(t,"length",bE),Qs=t=>!!t&&!Number.isNaN(Number(t)),du=t=>Ti(t,"number",Qs),zi=t=>!!t&&Number.isInteger(Number(t)),pE=t=>t.endsWith("%")&&Qs(t.slice(0,-1)),ee=t=>P0.test(t),Jr=t=>cE.test(t),mE=new Set(["length","size","percentage"]),gE=t=>Ti(t,mE,O0),vE=t=>Ti(t,"position",O0),yE=new Set(["image","url"]),wE=t=>Ti(t,yE,kE),xE=t=>Ti(t,"",_E),Bi=()=>!0,Ti=(t,e,r)=>{const n=P0.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},bE=t=>uE.test(t)&&!dE.test(t),O0=()=>!1,_E=t=>hE.test(t),kE=t=>fE.test(t),SE=()=>{const t=ge("colors"),e=ge("spacing"),r=ge("blur"),n=ge("brightness"),s=ge("borderColor"),i=ge("borderRadius"),o=ge("borderSpacing"),a=ge("borderWidth"),l=ge("contrast"),c=ge("grayscale"),u=ge("hueRotate"),d=ge("invert"),f=ge("gap"),h=ge("gradientColorStops"),y=ge("gradientColorStopPositions"),w=ge("inset"),x=ge("margin"),m=ge("opacity"),g=ge("padding"),v=ge("saturate"),_=ge("scale"),k=ge("sepia"),S=ge("skew"),E=ge("space"),R=ge("translate"),P=()=>["auto","contain","none"],I=()=>["auto","hidden","clip","visible","scroll"],q=()=>["auto",ee,e],F=()=>[ee,e],te=()=>["",yr,Gr],$=()=>["auto",Qs,ee],ie=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],K=()=>["solid","dashed","dotted","double","none"],Y=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],T=()=>["start","end","center","between","around","evenly","stretch"],N=()=>["","0",ee],M=()=>["auto","avoid","all","avoid-page","page","left","right","column"],X=()=>[Qs,ee];return{cacheSize:500,separator:":",theme:{colors:[Bi],spacing:[yr,Gr],blur:["none","",Jr,ee],brightness:X(),borderColor:[t],borderRadius:["none","","full",Jr,ee],borderSpacing:F(),borderWidth:te(),contrast:X(),grayscale:N(),hueRotate:X(),invert:N(),gap:F(),gradientColorStops:[t],gradientColorStopPositions:[pE,Gr],inset:q(),margin:q(),opacity:X(),padding:F(),saturate:X(),scale:X(),sepia:N(),skew:X(),space:F(),translate:F()},classGroups:{aspect:[{aspect:["auto","square","video",ee]}],container:["container"],columns:[{columns:[Jr]}],"break-after":[{"break-after":M()}],"break-before":[{"break-before":M()}],"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:[...ie(),ee]}],overflow:[{overflow:I()}],"overflow-x":[{"overflow-x":I()}],"overflow-y":[{"overflow-y":I()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",zi,ee]}],basis:[{basis:q()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ee]}],grow:[{grow:N()}],shrink:[{shrink:N()}],order:[{order:["first","last","none",zi,ee]}],"grid-cols":[{"grid-cols":[Bi]}],"col-start-end":[{col:["auto",{span:["full",zi,ee]},ee]}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":[Bi]}],"row-start-end":[{row:["auto",{span:[zi,ee]},ee]}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ee]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ee]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...T()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...T(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...T(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[g]}],px:[{px:[g]}],py:[{py:[g]}],ps:[{ps:[g]}],pe:[{pe:[g]}],pt:[{pt:[g]}],pr:[{pr:[g]}],pb:[{pb:[g]}],pl:[{pl:[g]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[E]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[E]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ee,e]}],"min-w":[{"min-w":[ee,e,"min","max","fit"]}],"max-w":[{"max-w":[ee,e,"none","full","min","max","fit","prose",{screen:[Jr]},Jr]}],h:[{h:[ee,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ee,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ee,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ee,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Jr,Gr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",du]}],"font-family":[{font:[Bi]}],"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",ee]}],"line-clamp":[{"line-clamp":["none",Qs,du]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",yr,ee]}],"list-image":[{"list-image":["none",ee]}],"list-style-type":[{list:["none","disc","decimal",ee]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[m]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...K(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",yr,Gr]}],"underline-offset":[{"underline-offset":["auto",yr,ee]}],"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",ee]}],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",ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[m]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ie(),vE]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",gE]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},wE]}],"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:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[m]}],"border-style":[{border:[...K(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[m]}],"divide-style":[{divide:K()}],"border-color":[{border:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-s":[{"border-s":[s]}],"border-color-e":[{"border-e":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:["",...K()]}],"outline-offset":[{"outline-offset":[yr,ee]}],"outline-w":[{outline:[yr,Gr]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[m]}],"ring-offset-w":[{"ring-offset":[yr,Gr]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Jr,xE]}],"shadow-color":[{shadow:[Bi]}],opacity:[{opacity:[m]}],"mix-blend":[{"mix-blend":[...Y(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Y()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Jr,ee]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[v]}],sepia:[{sepia:[k]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[m]}],"backdrop-saturate":[{"backdrop-saturate":[v]}],"backdrop-sepia":[{"backdrop-sepia":[k]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ee]}],duration:[{duration:X()}],ease:[{ease:["linear","in","out","in-out",ee]}],delay:[{delay:X()}],animate:[{animate:["none","spin","ping","pulse","bounce",ee]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[zi,ee]}],"translate-x":[{"translate-x":[R]}],"translate-y":[{"translate-y":[R]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ee]}],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",ee]}],"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",ee]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[yr,Gr,du]}],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"]}}},EE=oE(SE);function hs(...t){return EE(k0(t))}const CE=jS,I0=b.forwardRef(({className:t,...e},r)=>p.jsx(g0,{ref:r,className:hs("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...e}));I0.displayName=g0.displayName;const TE=AS("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),L0=b.forwardRef(({className:t,variant:e,...r},n)=>p.jsx(v0,{ref:n,className:hs(TE({variant:e}),t),...r}));L0.displayName=v0.displayName;const NE=b.forwardRef(({className:t,...e},r)=>p.jsx(x0,{ref:r,className:hs("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...e}));NE.displayName=x0.displayName;const $0=b.forwardRef(({className:t,...e},r)=>p.jsx(b0,{ref:r,className:hs("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...e,children:p.jsx(N0,{className:"h-4 w-4"})}));$0.displayName=b0.displayName;const D0=b.forwardRef(({className:t,...e},r)=>p.jsx(y0,{ref:r,className:hs("text-sm font-semibold",t),...e}));D0.displayName=y0.displayName;const M0=b.forwardRef(({className:t,...e},r)=>p.jsx(w0,{ref:r,className:hs("text-sm opacity-90",t),...e}));M0.displayName=w0.displayName;function RE(){const{toasts:t}=M1();return p.jsxs(CE,{children:[t.map(function({id:e,title:r,description:n,action:s,...i}){return p.jsxs(L0,{...i,children:[p.jsxs("div",{className:"grid gap-1",children:[r&&p.jsx(D0,{children:r}),n&&p.jsx(M0,{children:n})]}),s,p.jsx($0,{})]},e)}),p.jsx(I0,{})]})}const jE=["top","right","bottom","left"],Nn=Math.min,ft=Math.max,Al=Math.round,Ra=Math.floor,fr=t=>({x:t,y:t}),AE={left:"right",right:"left",bottom:"top",top:"bottom"},PE={start:"end",end:"start"};function kd(t,e,r){return ft(t,Nn(e,r))}function Ir(t,e){return typeof t=="function"?t(e):t}function Lr(t){return t.split("-")[0]}function Ni(t){return t.split("-")[1]}function nf(t){return t==="x"?"y":"x"}function sf(t){return t==="y"?"height":"width"}const OE=new Set(["top","bottom"]);function ur(t){return OE.has(Lr(t))?"y":"x"}function of(t){return nf(ur(t))}function IE(t,e,r){r===void 0&&(r=!1);const n=Ni(t),s=of(t),i=sf(s);let o=s==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Pl(o)),[o,Pl(o)]}function LE(t){const e=Pl(t);return[Sd(t),e,Sd(e)]}function Sd(t){return t.replace(/start|end/g,e=>PE[e])}const sm=["left","right"],im=["right","left"],$E=["top","bottom"],DE=["bottom","top"];function ME(t,e,r){switch(t){case"top":case"bottom":return r?e?im:sm:e?sm:im;case"left":case"right":return e?$E:DE;default:return[]}}function UE(t,e,r,n){const s=Ni(t);let i=ME(Lr(t),r==="start",n);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(Sd)))),i}function Pl(t){return t.replace(/left|right|bottom|top/g,e=>AE[e])}function FE(t){return{top:0,right:0,bottom:0,left:0,...t}}function U0(t){return typeof t!="number"?FE(t):{top:t,right:t,bottom:t,left:t}}function Ol(t){const{x:e,y:r,width:n,height:s}=t;return{width:n,height:s,top:r,left:e,right:e+n,bottom:r+s,x:e,y:r}}function om(t,e,r){let{reference:n,floating:s}=t;const i=ur(e),o=of(e),a=sf(o),l=Lr(e),c=i==="y",u=n.x+n.width/2-s.width/2,d=n.y+n.height/2-s.height/2,f=n[a]/2-s[a]/2;let h;switch(l){case"top":h={x:u,y:n.y-s.height};break;case"bottom":h={x:u,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:d};break;case"left":h={x:n.x-s.width,y:d};break;default:h={x:n.x,y:n.y}}switch(Ni(e)){case"start":h[o]-=f*(r&&c?-1:1);break;case"end":h[o]+=f*(r&&c?-1:1);break}return h}const zE=async(t,e,r)=>{const{placement:n="bottom",strategy:s="absolute",middleware:i=[],platform:o}=r,a=i.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:d}=om(c,n,l),f=n,h={},y=0;for(let w=0;w({name:"arrow",options:t,async fn(e){const{x:r,y:n,placement:s,rects:i,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=Ir(t,e)||{};if(c==null)return{};const d=U0(u),f={x:r,y:n},h=of(s),y=sf(h),w=await o.getDimensions(c),x=h==="y",m=x?"top":"left",g=x?"bottom":"right",v=x?"clientHeight":"clientWidth",_=i.reference[y]+i.reference[h]-f[h]-i.floating[y],k=f[h]-i.reference[h],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let E=S?S[v]:0;(!E||!await(o.isElement==null?void 0:o.isElement(S)))&&(E=a.floating[v]||i.floating[y]);const R=_/2-k/2,P=E/2-w[y]/2-1,I=Nn(d[m],P),q=Nn(d[g],P),F=I,te=E-w[y]-q,$=E/2-w[y]/2+R,ie=kd(F,$,te),K=!l.arrow&&Ni(s)!=null&&$!==ie&&i.reference[y]/2-($$<=0)){var q,F;const $=(((q=i.flip)==null?void 0:q.index)||0)+1,ie=E[$];if(ie&&(!(d==="alignment"?g!==ur(ie):!1)||I.every(T=>T.overflows[0]>0&&ur(T.placement)===g)))return{data:{index:$,overflows:I},reset:{placement:ie}};let K=(F=I.filter(Y=>Y.overflows[0]<=0).sort((Y,T)=>Y.overflows[1]-T.overflows[1])[0])==null?void 0:F.placement;if(!K)switch(h){case"bestFit":{var te;const Y=(te=I.filter(T=>{if(S){const N=ur(T.placement);return N===g||N==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(N=>N>0).reduce((N,M)=>N+M,0)]).sort((T,N)=>T[1]-N[1])[0])==null?void 0:te[0];Y&&(K=Y);break}case"initialPlacement":K=a;break}if(s!==K)return{reset:{placement:K}}}return{}}}};function am(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function lm(t){return jE.some(e=>t[e]>=0)}const VE=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:r}=e,{strategy:n="referenceHidden",...s}=Ir(t,e);switch(n){case"referenceHidden":{const i=await Io(e,{...s,elementContext:"reference"}),o=am(i,r.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:lm(o)}}}case"escaped":{const i=await Io(e,{...s,altBoundary:!0}),o=am(i,r.floating);return{data:{escapedOffsets:o,escaped:lm(o)}}}default:return{}}}}},F0=new Set(["left","top"]);async function HE(t,e){const{placement:r,platform:n,elements:s}=t,i=await(n.isRTL==null?void 0:n.isRTL(s.floating)),o=Lr(r),a=Ni(r),l=ur(r)==="y",c=F0.has(o)?-1:1,u=i&&l?-1:1,d=Ir(e,t);let{mainAxis:f,crossAxis:h,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof y=="number"&&(h=a==="end"?y*-1:y),l?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const qE=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var r,n;const{x:s,y:i,placement:o,middlewareData:a}=e,l=await HE(e,t);return o===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:o}}}}},KE=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:r,y:n,placement:s}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:a={fn:x=>{let{x:m,y:g}=x;return{x:m,y:g}}},...l}=Ir(t,e),c={x:r,y:n},u=await Io(e,l),d=ur(Lr(s)),f=nf(d);let h=c[f],y=c[d];if(i){const x=f==="y"?"top":"left",m=f==="y"?"bottom":"right",g=h+u[x],v=h-u[m];h=kd(g,h,v)}if(o){const x=d==="y"?"top":"left",m=d==="y"?"bottom":"right",g=y+u[x],v=y-u[m];y=kd(g,y,v)}const w=a.fn({...e,[f]:h,[d]:y});return{...w,data:{x:w.x-r,y:w.y-n,enabled:{[f]:i,[d]:o}}}}}},GE=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:r,y:n,placement:s,rects:i,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Ir(t,e),u={x:r,y:n},d=ur(s),f=nf(d);let h=u[f],y=u[d];const w=Ir(a,e),x=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(l){const v=f==="y"?"height":"width",_=i.reference[f]-i.floating[v]+x.mainAxis,k=i.reference[f]+i.reference[v]-x.mainAxis;h<_?h=_:h>k&&(h=k)}if(c){var m,g;const v=f==="y"?"width":"height",_=F0.has(Lr(s)),k=i.reference[d]-i.floating[v]+(_&&((m=o.offset)==null?void 0:m[d])||0)+(_?0:x.crossAxis),S=i.reference[d]+i.reference[v]+(_?0:((g=o.offset)==null?void 0:g[d])||0)-(_?x.crossAxis:0);yS&&(y=S)}return{[f]:h,[d]:y}}}},JE=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var r,n;const{placement:s,rects:i,platform:o,elements:a}=e,{apply:l=()=>{},...c}=Ir(t,e),u=await Io(e,c),d=Lr(s),f=Ni(s),h=ur(s)==="y",{width:y,height:w}=i.floating;let x,m;d==="top"||d==="bottom"?(x=d,m=f===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(m=d,x=f==="end"?"top":"bottom");const g=w-u.top-u.bottom,v=y-u.left-u.right,_=Nn(w-u[x],g),k=Nn(y-u[m],v),S=!e.middlewareData.shift;let E=_,R=k;if((r=e.middlewareData.shift)!=null&&r.enabled.x&&(R=v),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(E=g),S&&!f){const I=ft(u.left,0),q=ft(u.right,0),F=ft(u.top,0),te=ft(u.bottom,0);h?R=y-2*(I!==0||q!==0?I+q:ft(u.left,u.right)):E=w-2*(F!==0||te!==0?F+te:ft(u.top,u.bottom))}await l({...e,availableWidth:R,availableHeight:E});const P=await o.getDimensions(a.floating);return y!==P.width||w!==P.height?{reset:{rects:!0}}:{}}}};function wc(){return typeof window<"u"}function Ri(t){return z0(t)?(t.nodeName||"").toLowerCase():"#document"}function vt(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function vr(t){var e;return(e=(z0(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function z0(t){return wc()?t instanceof Node||t instanceof vt(t).Node:!1}function Qt(t){return wc()?t instanceof Element||t instanceof vt(t).Element:!1}function gr(t){return wc()?t instanceof HTMLElement||t instanceof vt(t).HTMLElement:!1}function cm(t){return!wc()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof vt(t).ShadowRoot}const QE=new Set(["inline","contents"]);function ra(t){const{overflow:e,overflowX:r,overflowY:n,display:s}=Zt(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+r)&&!QE.has(s)}const ZE=new Set(["table","td","th"]);function YE(t){return ZE.has(Ri(t))}const XE=[":popover-open",":modal"];function xc(t){return XE.some(e=>{try{return t.matches(e)}catch{return!1}})}const eC=["transform","translate","scale","rotate","perspective"],tC=["transform","translate","scale","rotate","perspective","filter"],rC=["paint","layout","strict","content"];function af(t){const e=lf(),r=Qt(t)?Zt(t):t;return eC.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!e&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!e&&(r.filter?r.filter!=="none":!1)||tC.some(n=>(r.willChange||"").includes(n))||rC.some(n=>(r.contain||"").includes(n))}function nC(t){let e=Rn(t);for(;gr(e)&&!gi(e);){if(af(e))return e;if(xc(e))return null;e=Rn(e)}return null}function lf(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const sC=new Set(["html","body","#document"]);function gi(t){return sC.has(Ri(t))}function Zt(t){return vt(t).getComputedStyle(t)}function bc(t){return Qt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Rn(t){if(Ri(t)==="html")return t;const e=t.assignedSlot||t.parentNode||cm(t)&&t.host||vr(t);return cm(e)?e.host:e}function B0(t){const e=Rn(t);return gi(e)?t.ownerDocument?t.ownerDocument.body:t.body:gr(e)&&ra(e)?e:B0(e)}function Lo(t,e,r){var n;e===void 0&&(e=[]),r===void 0&&(r=!0);const s=B0(t),i=s===((n=t.ownerDocument)==null?void 0:n.body),o=vt(s);if(i){const a=Ed(o);return e.concat(o,o.visualViewport||[],ra(s)?s:[],a&&r?Lo(a):[])}return e.concat(s,Lo(s,[],r))}function Ed(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function W0(t){const e=Zt(t);let r=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=gr(t),i=s?t.offsetWidth:r,o=s?t.offsetHeight:n,a=Al(r)!==i||Al(n)!==o;return a&&(r=i,n=o),{width:r,height:n,$:a}}function cf(t){return Qt(t)?t:t.contextElement}function Zs(t){const e=cf(t);if(!gr(e))return fr(1);const r=e.getBoundingClientRect(),{width:n,height:s,$:i}=W0(e);let o=(i?Al(r.width):r.width)/n,a=(i?Al(r.height):r.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const iC=fr(0);function V0(t){const e=vt(t);return!lf()||!e.visualViewport?iC:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function oC(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==vt(t)?!1:e}function os(t,e,r,n){e===void 0&&(e=!1),r===void 0&&(r=!1);const s=t.getBoundingClientRect(),i=cf(t);let o=fr(1);e&&(n?Qt(n)&&(o=Zs(n)):o=Zs(t));const a=oC(i,r,n)?V0(i):fr(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,u=s.width/o.x,d=s.height/o.y;if(i){const f=vt(i),h=n&&Qt(n)?vt(n):n;let y=f,w=Ed(y);for(;w&&n&&h!==y;){const x=Zs(w),m=w.getBoundingClientRect(),g=Zt(w),v=m.left+(w.clientLeft+parseFloat(g.paddingLeft))*x.x,_=m.top+(w.clientTop+parseFloat(g.paddingTop))*x.y;l*=x.x,c*=x.y,u*=x.x,d*=x.y,l+=v,c+=_,y=vt(w),w=Ed(y)}}return Ol({width:u,height:d,x:l,y:c})}function uf(t,e){const r=bc(t).scrollLeft;return e?e.left+r:os(vr(t)).left+r}function H0(t,e,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-(r?0:uf(t,n)),i=n.top+e.scrollTop;return{x:s,y:i}}function aC(t){let{elements:e,rect:r,offsetParent:n,strategy:s}=t;const i=s==="fixed",o=vr(n),a=e?xc(e.floating):!1;if(n===o||a&&i)return r;let l={scrollLeft:0,scrollTop:0},c=fr(1);const u=fr(0),d=gr(n);if((d||!d&&!i)&&((Ri(n)!=="body"||ra(o))&&(l=bc(n)),gr(n))){const h=os(n);c=Zs(n),u.x=h.x+n.clientLeft,u.y=h.y+n.clientTop}const f=o&&!d&&!i?H0(o,l,!0):fr(0);return{width:r.width*c.x,height:r.height*c.y,x:r.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:r.y*c.y-l.scrollTop*c.y+u.y+f.y}}function lC(t){return Array.from(t.getClientRects())}function cC(t){const e=vr(t),r=bc(t),n=t.ownerDocument.body,s=ft(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=ft(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-r.scrollLeft+uf(t);const a=-r.scrollTop;return Zt(n).direction==="rtl"&&(o+=ft(e.clientWidth,n.clientWidth)-s),{width:s,height:i,x:o,y:a}}function uC(t,e){const r=vt(t),n=vr(t),s=r.visualViewport;let i=n.clientWidth,o=n.clientHeight,a=0,l=0;if(s){i=s.width,o=s.height;const c=lf();(!c||c&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:i,height:o,x:a,y:l}}const dC=new Set(["absolute","fixed"]);function hC(t,e){const r=os(t,!0,e==="fixed"),n=r.top+t.clientTop,s=r.left+t.clientLeft,i=gr(t)?Zs(t):fr(1),o=t.clientWidth*i.x,a=t.clientHeight*i.y,l=s*i.x,c=n*i.y;return{width:o,height:a,x:l,y:c}}function um(t,e,r){let n;if(e==="viewport")n=uC(t,r);else if(e==="document")n=cC(vr(t));else if(Qt(e))n=hC(e,r);else{const s=V0(t);n={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Ol(n)}function q0(t,e){const r=Rn(t);return r===e||!Qt(r)||gi(r)?!1:Zt(r).position==="fixed"||q0(r,e)}function fC(t,e){const r=e.get(t);if(r)return r;let n=Lo(t,[],!1).filter(a=>Qt(a)&&Ri(a)!=="body"),s=null;const i=Zt(t).position==="fixed";let o=i?Rn(t):t;for(;Qt(o)&&!gi(o);){const a=Zt(o),l=af(o);!l&&a.position==="fixed"&&(s=null),(i?!l&&!s:!l&&a.position==="static"&&!!s&&dC.has(s.position)||ra(o)&&!l&&q0(t,o))?n=n.filter(u=>u!==o):s=a,o=Rn(o)}return e.set(t,n),n}function pC(t){let{element:e,boundary:r,rootBoundary:n,strategy:s}=t;const o=[...r==="clippingAncestors"?xc(e)?[]:fC(e,this._c):[].concat(r),n],a=o[0],l=o.reduce((c,u)=>{const d=um(e,u,s);return c.top=ft(d.top,c.top),c.right=Nn(d.right,c.right),c.bottom=Nn(d.bottom,c.bottom),c.left=ft(d.left,c.left),c},um(e,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function mC(t){const{width:e,height:r}=W0(t);return{width:e,height:r}}function gC(t,e,r){const n=gr(e),s=vr(e),i=r==="fixed",o=os(t,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=fr(0);function c(){l.x=uf(s)}if(n||!n&&!i)if((Ri(e)!=="body"||ra(s))&&(a=bc(e)),n){const h=os(e,!0,i,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else s&&c();i&&!n&&s&&c();const u=s&&!n&&!i?H0(s,a):fr(0),d=o.left+a.scrollLeft-l.x-u.x,f=o.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function hu(t){return Zt(t).position==="static"}function dm(t,e){if(!gr(t)||Zt(t).position==="fixed")return null;if(e)return e(t);let r=t.offsetParent;return vr(t)===r&&(r=r.ownerDocument.body),r}function K0(t,e){const r=vt(t);if(xc(t))return r;if(!gr(t)){let s=Rn(t);for(;s&&!gi(s);){if(Qt(s)&&!hu(s))return s;s=Rn(s)}return r}let n=dm(t,e);for(;n&&YE(n)&&hu(n);)n=dm(n,e);return n&&gi(n)&&hu(n)&&!af(n)?r:n||nC(t)||r}const vC=async function(t){const e=this.getOffsetParent||K0,r=this.getDimensions,n=await r(t.floating);return{reference:gC(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function yC(t){return Zt(t).direction==="rtl"}const wC={convertOffsetParentRelativeRectToViewportRelativeRect:aC,getDocumentElement:vr,getClippingRect:pC,getOffsetParent:K0,getElementRects:vC,getClientRects:lC,getDimensions:mC,getScale:Zs,isElement:Qt,isRTL:yC};function G0(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function xC(t,e){let r=null,n;const s=vr(t);function i(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const c=t.getBoundingClientRect(),{left:u,top:d,width:f,height:h}=c;if(a||e(),!f||!h)return;const y=Ra(d),w=Ra(s.clientWidth-(u+f)),x=Ra(s.clientHeight-(d+h)),m=Ra(u),v={rootMargin:-y+"px "+-w+"px "+-x+"px "+-m+"px",threshold:ft(0,Nn(1,l))||1};let _=!0;function k(S){const E=S[0].intersectionRatio;if(E!==l){if(!_)return o();E?o(!1,E):n=setTimeout(()=>{o(!1,1e-7)},1e3)}E===1&&!G0(c,t.getBoundingClientRect())&&o(),_=!1}try{r=new IntersectionObserver(k,{...v,root:s.ownerDocument})}catch{r=new IntersectionObserver(k,v)}r.observe(t)}return o(!0),i}function bC(t,e,r,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=n,c=cf(t),u=s||i?[...c?Lo(c):[],...Lo(e)]:[];u.forEach(m=>{s&&m.addEventListener("scroll",r,{passive:!0}),i&&m.addEventListener("resize",r)});const d=c&&a?xC(c,r):null;let f=-1,h=null;o&&(h=new ResizeObserver(m=>{let[g]=m;g&&g.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var v;(v=h)==null||v.observe(e)})),r()}),c&&!l&&h.observe(c),h.observe(e));let y,w=l?os(t):null;l&&x();function x(){const m=os(t);w&&!G0(w,m)&&r(),w=m,y=requestAnimationFrame(x)}return r(),()=>{var m;u.forEach(g=>{s&&g.removeEventListener("scroll",r),i&&g.removeEventListener("resize",r)}),d==null||d(),(m=h)==null||m.disconnect(),h=null,l&&cancelAnimationFrame(y)}}const _C=qE,kC=KE,SC=WE,EC=JE,CC=VE,hm=BE,TC=GE,NC=(t,e,r)=>{const n=new Map,s={platform:wC,...r},i={...s.platform,_c:n};return zE(t,e,{...s,platform:i})};var RC=typeof document<"u",jC=function(){},Xa=RC?b.useLayoutEffect:jC;function Il(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let r,n,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(r=t.length,r!==e.length)return!1;for(n=r;n--!==0;)if(!Il(t[n],e[n]))return!1;return!0}if(s=Object.keys(t),r=s.length,r!==Object.keys(e).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(e,s[n]))return!1;for(n=r;n--!==0;){const i=s[n];if(!(i==="_owner"&&t.$$typeof)&&!Il(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function J0(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function fm(t,e){const r=J0(t);return Math.round(e*r)/r}function fu(t){const e=b.useRef(t);return Xa(()=>{e.current=t}),e}function AC(t){t===void 0&&(t={});const{placement:e="bottom",strategy:r="absolute",middleware:n=[],platform:s,elements:{reference:i,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=t,[u,d]=b.useState({x:0,y:0,strategy:r,placement:e,middlewareData:{},isPositioned:!1}),[f,h]=b.useState(n);Il(f,n)||h(n);const[y,w]=b.useState(null),[x,m]=b.useState(null),g=b.useCallback(T=>{T!==S.current&&(S.current=T,w(T))},[]),v=b.useCallback(T=>{T!==E.current&&(E.current=T,m(T))},[]),_=i||y,k=o||x,S=b.useRef(null),E=b.useRef(null),R=b.useRef(u),P=l!=null,I=fu(l),q=fu(s),F=fu(c),te=b.useCallback(()=>{if(!S.current||!E.current)return;const T={placement:e,strategy:r,middleware:f};q.current&&(T.platform=q.current),NC(S.current,E.current,T).then(N=>{const M={...N,isPositioned:F.current!==!1};$.current&&!Il(R.current,M)&&(R.current=M,ea.flushSync(()=>{d(M)}))})},[f,e,r,q,F]);Xa(()=>{c===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,d(T=>({...T,isPositioned:!1})))},[c]);const $=b.useRef(!1);Xa(()=>($.current=!0,()=>{$.current=!1}),[]),Xa(()=>{if(_&&(S.current=_),k&&(E.current=k),_&&k){if(I.current)return I.current(_,k,te);te()}},[_,k,te,I,P]);const ie=b.useMemo(()=>({reference:S,floating:E,setReference:g,setFloating:v}),[g,v]),K=b.useMemo(()=>({reference:_,floating:k}),[_,k]),Y=b.useMemo(()=>{const T={position:r,left:0,top:0};if(!K.floating)return T;const N=fm(K.floating,u.x),M=fm(K.floating,u.y);return a?{...T,transform:"translate("+N+"px, "+M+"px)",...J0(K.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:N,top:M}},[r,a,K.floating,u.x,u.y]);return b.useMemo(()=>({...u,update:te,refs:ie,elements:K,floatingStyles:Y}),[u,te,ie,K,Y])}const PC=t=>{function e(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:t,fn(r){const{element:n,padding:s}=typeof t=="function"?t(r):t;return n&&e(n)?n.current!=null?hm({element:n.current,padding:s}).fn(r):{}:n?hm({element:n,padding:s}).fn(r):{}}}},OC=(t,e)=>({..._C(t),options:[t,e]}),IC=(t,e)=>({...kC(t),options:[t,e]}),LC=(t,e)=>({...TC(t),options:[t,e]}),$C=(t,e)=>({...SC(t),options:[t,e]}),DC=(t,e)=>({...EC(t),options:[t,e]}),MC=(t,e)=>({...CC(t),options:[t,e]}),UC=(t,e)=>({...PC(t),options:[t,e]});var FC="Arrow",Q0=b.forwardRef((t,e)=>{const{children:r,width:n=10,height:s=5,...i}=t;return p.jsx(dt.svg,{...i,ref:e,width:n,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:p.jsx("polygon",{points:"0,0 30,0 15,10"})})});Q0.displayName=FC;var zC=Q0;function BC(t){const[e,r]=b.useState(void 0);return Tn(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let o,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=t.offsetWidth,a=t.offsetHeight;r({width:o,height:a})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),e}var Z0="Popper",[Y0,X0]=gc(Z0),[lA,ew]=Y0(Z0),tw="PopperAnchor",rw=b.forwardRef((t,e)=>{const{__scopePopper:r,virtualRef:n,...s}=t,i=ew(tw,r),o=b.useRef(null),a=Jt(e,o);return b.useEffect(()=>{i.onAnchorChange((n==null?void 0:n.current)||o.current)}),n?null:p.jsx(dt.div,{...s,ref:a})});rw.displayName=tw;var df="PopperContent",[WC,VC]=Y0(df),nw=b.forwardRef((t,e)=>{var de,fs,zr,Ln,Br,ps;const{__scopePopper:r,side:n="bottom",sideOffset:s=0,align:i="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:h="optimized",onPlaced:y,...w}=t,x=ew(df,r),[m,g]=b.useState(null),v=Jt(e,Wr=>g(Wr)),[_,k]=b.useState(null),S=BC(_),E=(S==null?void 0:S.width)??0,R=(S==null?void 0:S.height)??0,P=n+(i!=="center"?"-"+i:""),I=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},q=Array.isArray(c)?c:[c],F=q.length>0,te={padding:I,boundary:q.filter(qC),altBoundary:F},{refs:$,floatingStyles:ie,placement:K,isPositioned:Y,middlewareData:T}=AC({strategy:"fixed",placement:P,whileElementsMounted:(...Wr)=>bC(...Wr,{animationFrame:h==="always"}),elements:{reference:x.anchor},middleware:[OC({mainAxis:s+R,alignmentAxis:o}),l&&IC({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?LC():void 0,...te}),l&&$C({...te}),DC({...te,apply:({elements:Wr,rects:sa,availableWidth:Rc,availableHeight:ia})=>{const{width:jc,height:Ai}=sa.reference,ms=Wr.floating.style;ms.setProperty("--radix-popper-available-width",`${Rc}px`),ms.setProperty("--radix-popper-available-height",`${ia}px`),ms.setProperty("--radix-popper-anchor-width",`${jc}px`),ms.setProperty("--radix-popper-anchor-height",`${Ai}px`)}}),_&&UC({element:_,padding:a}),KC({arrowWidth:E,arrowHeight:R}),f&&MC({strategy:"referenceHidden",...te})]}),[N,M]=ow(K),X=Cn(y);Tn(()=>{Y&&(X==null||X())},[Y,X]);const V=(de=T.arrow)==null?void 0:de.x,ne=(fs=T.arrow)==null?void 0:fs.y,oe=((zr=T.arrow)==null?void 0:zr.centerOffset)!==0,[Ae,He]=b.useState();return Tn(()=>{m&&He(window.getComputedStyle(m).zIndex)},[m]),p.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...ie,transform:Y?ie.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ae,"--radix-popper-transform-origin":[(Ln=T.transformOrigin)==null?void 0:Ln.x,(Br=T.transformOrigin)==null?void 0:Br.y].join(" "),...((ps=T.hide)==null?void 0:ps.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:p.jsx(WC,{scope:r,placedSide:N,onArrowChange:k,arrowX:V,arrowY:ne,shouldHideArrow:oe,children:p.jsx(dt.div,{"data-side":N,"data-align":M,...w,ref:v,style:{...w.style,animation:Y?void 0:"none"}})})})});nw.displayName=df;var sw="PopperArrow",HC={top:"bottom",right:"left",bottom:"top",left:"right"},iw=b.forwardRef(function(e,r){const{__scopePopper:n,...s}=e,i=VC(sw,n),o=HC[i.placedSide];return p.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:p.jsx(zC,{...s,ref:r,style:{...s.style,display:"block"}})})});iw.displayName=sw;function qC(t){return t!==null}var KC=t=>({name:"transformOrigin",options:t,fn(e){var x,m,g;const{placement:r,rects:n,middlewareData:s}=e,o=((x=s.arrow)==null?void 0:x.centerOffset)!==0,a=o?0:t.arrowWidth,l=o?0:t.arrowHeight,[c,u]=ow(r),d={start:"0%",center:"50%",end:"100%"}[u],f=(((m=s.arrow)==null?void 0:m.x)??0)+a/2,h=(((g=s.arrow)==null?void 0:g.y)??0)+l/2;let y="",w="";return c==="bottom"?(y=o?d:`${f}px`,w=`${-l}px`):c==="top"?(y=o?d:`${f}px`,w=`${n.floating.height+l}px`):c==="right"?(y=`${-l}px`,w=o?d:`${h}px`):c==="left"&&(y=`${n.floating.width+l}px`,w=o?d:`${h}px`),{data:{x:y,y:w}}}});function ow(t){const[e,r="center"]=t.split("-");return[e,r]}var GC=rw,JC=nw,QC=iw,[_c,cA]=gc("Tooltip",[X0]),hf=X0(),aw="TooltipProvider",ZC=700,pm="tooltip.open",[YC,lw]=_c(aw),cw=t=>{const{__scopeTooltip:e,delayDuration:r=ZC,skipDelayDuration:n=300,disableHoverableContent:s=!1,children:i}=t,o=b.useRef(!0),a=b.useRef(!1),l=b.useRef(0);return b.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),p.jsx(YC,{scope:e,isOpenDelayedRef:o,delayDuration:r,onOpen:b.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,n)},[n]),isPointerInTransitRef:a,onPointerInTransitChange:b.useCallback(c=>{a.current=c},[]),disableHoverableContent:s,children:i})};cw.displayName=aw;var uw="Tooltip",[uA,kc]=_c(uw),Cd="TooltipTrigger",XC=b.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=kc(Cd,r),i=lw(Cd,r),o=hf(r),a=b.useRef(null),l=Jt(e,a,s.onTriggerChange),c=b.useRef(!1),u=b.useRef(!1),d=b.useCallback(()=>c.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),p.jsx(GC,{asChild:!0,...o,children:p.jsx(dt.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...n,ref:l,onPointerMove:Le(t.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!i.isPointerInTransitRef.current&&(s.onTriggerEnter(),u.current=!0)}),onPointerLeave:Le(t.onPointerLeave,()=>{s.onTriggerLeave(),u.current=!1}),onPointerDown:Le(t.onPointerDown,()=>{s.open&&s.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Le(t.onFocus,()=>{c.current||s.onOpen()}),onBlur:Le(t.onBlur,s.onClose),onClick:Le(t.onClick,s.onClose)})})});XC.displayName=Cd;var eT="TooltipPortal",[dA,tT]=_c(eT,{forceMount:void 0}),vi="TooltipContent",dw=b.forwardRef((t,e)=>{const r=tT(vi,t.__scopeTooltip),{forceMount:n=r.forceMount,side:s="top",...i}=t,o=kc(vi,t.__scopeTooltip);return p.jsx(Gh,{present:n||o.open,children:o.disableHoverableContent?p.jsx(hw,{side:s,...i,ref:e}):p.jsx(rT,{side:s,...i,ref:e})})}),rT=b.forwardRef((t,e)=>{const r=kc(vi,t.__scopeTooltip),n=lw(vi,t.__scopeTooltip),s=b.useRef(null),i=Jt(e,s),[o,a]=b.useState(null),{trigger:l,onClose:c}=r,u=s.current,{onPointerInTransitChange:d}=n,f=b.useCallback(()=>{a(null),d(!1)},[d]),h=b.useCallback((y,w)=>{const x=y.currentTarget,m={x:y.clientX,y:y.clientY},g=aT(m,x.getBoundingClientRect()),v=lT(m,g),_=cT(w.getBoundingClientRect()),k=dT([...v,..._]);a(k),d(!0)},[d]);return b.useEffect(()=>()=>f(),[f]),b.useEffect(()=>{if(l&&u){const y=x=>h(x,u),w=x=>h(x,l);return l.addEventListener("pointerleave",y),u.addEventListener("pointerleave",w),()=>{l.removeEventListener("pointerleave",y),u.removeEventListener("pointerleave",w)}}},[l,u,h,f]),b.useEffect(()=>{if(o){const y=w=>{const x=w.target,m={x:w.clientX,y:w.clientY},g=(l==null?void 0:l.contains(x))||(u==null?void 0:u.contains(x)),v=!uT(m,o);g?f():v&&(f(),c())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[l,u,o,c,f]),p.jsx(hw,{...t,ref:i})}),[nT,sT]=_c(uw,{isInside:!1}),iT=z1("TooltipContent"),hw=b.forwardRef((t,e)=>{const{__scopeTooltip:r,children:n,"aria-label":s,onEscapeKeyDown:i,onPointerDownOutside:o,...a}=t,l=kc(vi,r),c=hf(r),{onClose:u}=l;return b.useEffect(()=>(document.addEventListener(pm,u),()=>document.removeEventListener(pm,u)),[u]),b.useEffect(()=>{if(l.trigger){const d=f=>{const h=f.target;h!=null&&h.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),p.jsx(Kh,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:p.jsxs(JC,{"data-state":l.stateAttribute,...c,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[p.jsx(iT,{children:n}),p.jsx(nT,{scope:r,isInside:!0,children:p.jsx(hS,{id:l.contentId,role:"tooltip",children:s||n})})]})})});dw.displayName=vi;var fw="TooltipArrow",oT=b.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=hf(r);return sT(fw,r).isInside?null:p.jsx(QC,{...s,...n,ref:e})});oT.displayName=fw;function aT(t,e){const r=Math.abs(e.top-t.y),n=Math.abs(e.bottom-t.y),s=Math.abs(e.right-t.x),i=Math.abs(e.left-t.x);switch(Math.min(r,n,s,i)){case i:return"left";case s:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function lT(t,e,r=5){const n=[];switch(e){case"top":n.push({x:t.x-r,y:t.y+r},{x:t.x+r,y:t.y+r});break;case"bottom":n.push({x:t.x-r,y:t.y-r},{x:t.x+r,y:t.y-r});break;case"left":n.push({x:t.x+r,y:t.y-r},{x:t.x+r,y:t.y+r});break;case"right":n.push({x:t.x-r,y:t.y-r},{x:t.x-r,y:t.y+r});break}return n}function cT(t){const{top:e,right:r,bottom:n,left:s}=t;return[{x:s,y:e},{x:r,y:e},{x:r,y:n},{x:s,y:n}]}function uT(t,e){const{x:r,y:n}=t;let s=!1;for(let i=0,o=e.length-1;in!=f>n&&r<(d-c)*(n-u)/(f-u)+c&&(s=!s)}return s}function dT(t){const e=t.slice();return e.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),hT(e)}function hT(t){if(t.length<=1)return t.slice();const e=[];for(let n=0;n=2;){const i=e[e.length-1],o=e[e.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))e.pop();else break}e.push(s)}e.pop();const r=[];for(let n=t.length-1;n>=0;n--){const s=t[n];for(;r.length>=2;){const i=r[r.length-1],o=r[r.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))r.pop();else break}r.push(s)}return r.pop(),e.length===1&&r.length===1&&e[0].x===r[0].x&&e[0].y===r[0].y?e:e.concat(r)}var fT=cw,pw=dw;const pT=fT,mT=b.forwardRef(({className:t,sideOffset:e=4,...r},n)=>p.jsx(pw,{ref:n,sideOffset:e,className:hs("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));mT.displayName=pw.displayName;function Sc(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);st?(...e)=>t(...e):(...e)=>fetch(...e);class ff extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class yT extends ff{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class mm extends ff{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class gm extends ff{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var Td;(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"})(Td||(Td={}));class wT{constructor(e,{headers:r={},customFetch:n,region:s=Td.Any}={}){this.url=e,this.headers=r,this.region=s,this.fetch=vT(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return gT(this,arguments,void 0,function*(r,n={}){var s;let i,o;try{const{headers:a,method:l,body:c,signal:u,timeout:d}=n;let f={},{region:h}=n;h||(h=this.region);const y=new URL(`${this.url}/${r}`);h&&h!=="any"&&(f["x-region"]=h,y.searchParams.set("forceFunctionRegion",h));let w;c&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)?typeof Blob<"u"&&c instanceof Blob||c instanceof ArrayBuffer?(f["Content-Type"]="application/octet-stream",w=c):typeof c=="string"?(f["Content-Type"]="text/plain",w=c):typeof FormData<"u"&&c instanceof FormData?w=c:(f["Content-Type"]="application/json",w=JSON.stringify(c)):c&&typeof c!="string"&&!(typeof Blob<"u"&&c instanceof Blob)&&!(c instanceof ArrayBuffer)&&!(typeof FormData<"u"&&c instanceof FormData)?w=JSON.stringify(c):w=c;let x=u;d&&(o=new AbortController,i=setTimeout(()=>o.abort(),d),u?(x=o.signal,u.addEventListener("abort",()=>o.abort())):x=o.signal);const m=yield this.fetch(y.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},f),this.headers),a),body:w,signal:x}).catch(k=>{throw new yT(k)}),g=m.headers.get("x-relay-error");if(g&&g==="true")throw new mm(m);if(!m.ok)throw new gm(m);let v=((s=m.headers.get("Content-Type"))!==null&&s!==void 0?s:"text/plain").split(";")[0].trim(),_;return v==="application/json"?_=yield m.json():v==="application/octet-stream"||v==="application/pdf"?_=yield m.blob():v==="text/event-stream"?_=m:v==="multipart/form-data"?_=yield m.formData():_=yield m.text(),{data:_,error:null,response:m}}catch(a){return{data:null,error:a,response:a instanceof gm||a instanceof mm?a.context:void 0}}finally{i&&clearTimeout(i)}})}}const mw=3,vm=t=>Math.min(1e3*2**t,3e4),xT=[520,503],gw=["GET","HEAD","OPTIONS"];var bT=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 ym(t,e){return new Promise(r=>{if(e!=null&&e.aborted){r();return}const n=setTimeout(()=>{e==null||e.removeEventListener("abort",s),r()},t);function s(){clearTimeout(n),r()}e==null||e.addEventListener("abort",s)})}function _T(t,e,r,n){return!(!n||r>=mw||!gw.includes(t)||!xT.includes(e))}var kT=class{constructor(t){var e,r,n,s,i;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=(n=t.shouldStripNulls)!==null&&n!==void 0?n:!1,this.urlLengthLimit=(s=t.urlLengthLimit)!==null&&s!==void 0?s:8e3,this.retryEnabled=(i=t.retry)!==null&&i!==void 0?i:!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 o=this.headers.get("Accept");o==="application/vnd.pgrst.object+json"?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):(!o||o==="application/json")&&this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const n=this.fetch;let i=(async()=>{let o=0;for(;;){const c=new Headers(r.headers);o>0&&c.set("X-Retry-Count",String(o));let u;try{u=await n(r.url.toString(),{method:r.method,headers:c,body:JSON.stringify(r.body,(d,f)=>typeof f=="bigint"?f.toString():f),signal:r.signal})}catch(d){if((d==null?void 0:d.name)==="AbortError"||(d==null?void 0:d.code)==="ABORT_ERR"||!gw.includes(r.method))throw d;if(r.retryEnabled&&o{var a;let l="",c="",u="";const d=o==null?void 0:o.cause;if(d){var f,h,y,w;const g=(f=d==null?void 0:d.message)!==null&&f!==void 0?f:"",v=(h=d==null?void 0:d.code)!==null&&h!==void 0?h:"";l=`${(y=o==null?void 0:o.name)!==null&&y!==void 0?y:"FetchError"}: ${o==null?void 0:o.message}`,l+=` Caused by: ${(w=d==null?void 0:d.name)!==null&&w!==void 0?w:"Error"}: ${g}`,v&&(l+=` (${v})`),d!=null&&d.stack&&(l+=` ${d.stack}`)}else{var x;l=(x=o==null?void 0:o.stack)!==null&&x!==void 0?x:""}const m=this.url.toString().length;return(o==null?void 0:o.name)==="AbortError"||(o==null?void 0:o.code)==="ABORT_ERR"?(u="",c="Request was aborted (timeout or manual cancellation)",m>this.urlLengthLimit&&(c+=`. Note: Your request URL is ${m} 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.`)):((d==null?void 0:d.name)==="HeadersOverflowError"||(d==null?void 0:d.code)==="UND_ERR_HEADERS_OVERFLOW")&&(u="",c="HTTP headers exceeded server limits (typically 16KB)",m>this.urlLengthLimit&&(c+=`. Your request URL is ${m} 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:`${(a=o==null?void 0:o.name)!==null&&a!==void 0?a:"FetchError"}: ${o==null?void 0:o.message}`,details:l,hint:c,code:u},data:null,count:null,status:0,statusText:""}})),i.then(t,e)}async processResponse(t){var e=this;let r=null,n=null,s=null,i=t.status,o=t.statusText;if(t.ok){var a,l;if(e.method!=="HEAD"){var c;const f=await t.text();f===""||(e.headers.get("Accept")==="text/csv"||e.headers.get("Accept")&&(!((c=e.headers.get("Accept"))===null||c===void 0)&&c.includes("application/vnd.pgrst.plan+text"))?n=f:n=JSON.parse(f))}const u=(a=e.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),d=(l=t.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");u&&d&&d.length>1&&(s=parseInt(d[1])),e.isMaybeSingle&&Array.isArray(n)&&(n.length>1?(r={code:"PGRST116",details:`Results contain ${n.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},n=null,s=null,i=406,o="Not Acceptable"):n.length===1?n=n[0]:n=null)}else{const u=await t.text();try{r=JSON.parse(u),Array.isArray(r)&&t.status===404&&(n=[],r=null,i=200,o="OK")}catch{t.status===404&&u===""?(i=204,o="No Content"):r={message:u}}if(r&&e.shouldThrowOnError)throw new bT(r)}return{success:r===null,error:r,data:n,count:s,status:i,statusText:o}}returns(){return this}overrideTypes(){return this}},ST=class extends kT{select(t){let e=!1;const r=(t??"*").split("").map(n=>/\s/.test(n)&&!e?"":(n==='"'&&(e=!e),n)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:n,referencedTable:s=n}={}){const i=s?`${s}.order`:"order",o=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${o?`${o},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){const n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:n=r}={}){const s=typeof n>"u"?"offset":`${n}.offset`,i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${t}`),this.url.searchParams.set(i,`${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:n=!1,wal:s=!1,format:i="text"}={}){var o;const a=[t?"analyze":null,e?"verbose":null,r?"settings":null,n?"buffers":null,s?"wal":null].filter(Boolean).join("|"),l=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${l}"; options=${a};`),i==="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 wm=new RegExp("[,()]");var Cs=class extends ST{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(n=>typeof n=="string"&&wm.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}notIn(t,e){const r=Array.from(new Set(e)).map(n=>typeof n=="string"&&wm.test(n)?`"${n}"`:`${n}`).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:n}={}){let s="";n==="plain"?s="pl":n==="phrase"?s="ph":n==="websearch"&&(s="w");const i=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${s}fts${i}.${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 n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}},ET=class{constructor(t,{headers:e={},schema:r,fetch:n,urlLengthLimit:s=8e3,retry:i}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=n,this.urlLengthLimit=s,this.retry=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:r=!1,count:n}=e??{},s=r?"HEAD":"GET";let i=!1;const o=(t??"*").split("").map(c=>/\s/.test(c)&&!i?"":(c==='"'&&(i=!i),c)).join(""),{url:a,headers:l}=this.cloneRequestState();return a.searchParams.set("select",o),n&&l.append("Prefer",`count=${n}`),new Cs({method:s,url:a,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(t,{count:e,defaultToNull:r=!0}={}){var n;const s="POST",{url:i,headers:o}=this.cloneRequestState();if(e&&o.append("Prefer",`count=${e}`),r||o.append("Prefer","missing=default"),Array.isArray(t)){const a=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(a.length>0){const l=[...new Set(a)].map(c=>`"${c}"`);i.searchParams.set("columns",l.join(","))}}return new Cs({method:s,url:i,headers:o,schema:this.schema,body:t,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:n,defaultToNull:s=!0}={}){var i;const o="POST",{url:a,headers:l}=this.cloneRequestState();if(l.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&a.searchParams.set("on_conflict",e),n&&l.append("Prefer",`count=${n}`),s||l.append("Prefer","missing=default"),Array.isArray(t)){const c=t.reduce((u,d)=>u.concat(Object.keys(d)),[]);if(c.length>0){const u=[...new Set(c)].map(d=>`"${d}"`);a.searchParams.set("columns",u.join(","))}}return new Cs({method:o,url:a,headers:l,schema:this.schema,body:t,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(t,{count:e}={}){var r;const n="PATCH",{url:s,headers:i}=this.cloneRequestState();return e&&i.append("Prefer",`count=${e}`),new Cs({method:n,url:s,headers:i,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:n,headers:s}=this.cloneRequestState();return t&&s.append("Prefer",`count=${t}`),new Cs({method:r,url:n,headers:s,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function $o(t){"@babel/helpers - typeof";return $o=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},$o(t)}function CT(t,e){if($o(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if($o(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function TT(t){var e=CT(t,"string");return $o(e)=="symbol"?e:e+""}function NT(t,e,r){return(e=TT(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function xm(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function ja(t){for(var e=1;e0?this.fetch=(c,u)=>{const d=new AbortController,f=setTimeout(()=>d.abort(),i),h=u==null?void 0:u.signal;if(h){if(h.aborted)return clearTimeout(f),l(c,u);const y=()=>{clearTimeout(f),d.abort()};return h.addEventListener("abort",y,{once:!0}),l(c,ja(ja({},u),{},{signal:d.signal})).finally(()=>{clearTimeout(f),h.removeEventListener("abort",y)})}return l(c,ja(ja({},u),{},{signal:d.signal})).finally(()=>clearTimeout(f))}:this.fetch=l,this.retry=a}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new ET(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 vw(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(e,r={},{head:n=!1,get:s=!1,count:i}={}){var o;let a;const l=new URL(`${this.url}/rpc/${e}`);let c;const u=h=>h!==null&&typeof h=="object"&&(!Array.isArray(h)||h.some(u)),d=n&&Object.values(r).some(u);d?(a="POST",c=r):n||s?(a=n?"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)})):(a="POST",c=r);const f=new Headers(this.headers);return d?f.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&f.set("Prefer",`count=${i}`),new Cs({method:a,url:l,headers:f,schema:this.schemaName,body:c,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class jT{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.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"&&globalThis.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 r=globalThis.process;if(r){const n=r.versions;if(n&&n.node){const s=n.node,i=parseInt(s.replace(/^v/,"").split(".")[0]);return i>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${i} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${i} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: import ws from "ws" new RealtimeClient(url, { transport: ws })`}}}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.constructor)return e.constructor;let r=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(r+=` Suggested solution: ${e.workaround}`),new Error(r)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const AT="2.105.1",PT=`realtime-js/${AT}`,OT="1.0.0",yw="2.0.0",IT=yw,LT=1e4,$T=100,rn={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},ww={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave",access_token:"access_token"},Nd={connecting:"connecting",open:"open",closing:"closing",closed:"closed"};class DT{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 n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return r(JSON.stringify(n))}_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,n;const s=(n=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&n!==void 0?n:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,s)}_encodeJsonUserBroadcastPush(e){var r,n;const s=(n=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&n!==void 0?n:{},o=new TextEncoder().encode(JSON.stringify(s)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,o)}_encodeUserBroadcastPush(e,r,n){var s,i;const o=e.topic,a=(s=e.ref)!==null&&s!==void 0?s:"",l=(i=e.join_ref)!==null&&i!==void 0?i:"",c=e.payload.event,u=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},d=Object.keys(u).length===0?"":JSON.stringify(u);if(l.length>255)throw new Error(`joinRef length ${l.length} exceeds maximum of 255`);if(a.length>255)throw new Error(`ref length ${a.length} exceeds maximum of 255`);if(o.length>255)throw new Error(`topic length ${o.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`userEvent length ${c.length} exceeds maximum of 255`);if(d.length>255)throw new Error(`metadata length ${d.length} exceeds maximum of 255`);const f=this.USER_BROADCAST_PUSH_META_LENGTH+l.length+a.length+o.length+c.length+d.length,h=new ArrayBuffer(this.HEADER_LENGTH+f);let y=new DataView(h),w=0;y.setUint8(w++,this.KINDS.userBroadcastPush),y.setUint8(w++,l.length),y.setUint8(w++,a.length),y.setUint8(w++,o.length),y.setUint8(w++,c.length),y.setUint8(w++,d.length),y.setUint8(w++,r),Array.from(l,m=>y.setUint8(w++,m.charCodeAt(0))),Array.from(a,m=>y.setUint8(w++,m.charCodeAt(0))),Array.from(o,m=>y.setUint8(w++,m.charCodeAt(0))),Array.from(c,m=>y.setUint8(w++,m.charCodeAt(0))),Array.from(d,m=>y.setUint8(w++,m.charCodeAt(0)));var x=new Uint8Array(h.byteLength+n.byteLength);return x.set(new Uint8Array(h),0),x.set(new Uint8Array(n),h.byteLength),x.buffer}decode(e,r){if(this._isArrayBuffer(e)){let n=this._binaryDecode(e);return r(n)}if(typeof e=="string"){const n=JSON.parse(e),[s,i,o,a,l]=n;return r({join_ref:s,ref:i,topic:o,event:a,payload:l})}return r({})}_binaryDecode(e){const r=new DataView(e),n=r.getUint8(0),s=new TextDecoder;switch(n){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,r,s)}}_decodeUserBroadcast(e,r,n){const s=r.getUint8(1),i=r.getUint8(2),o=r.getUint8(3),a=r.getUint8(4);let l=this.HEADER_LENGTH+4;const c=n.decode(e.slice(l,l+s));l=l+s;const u=n.decode(e.slice(l,l+i));l=l+i;const d=n.decode(e.slice(l,l+o));l=l+o;const f=e.slice(l,e.byteLength),h=a===this.JSON_ENCODING?JSON.parse(n.decode(f)):f,y={type:this.BROADCAST_EVENT,event:u,payload:h};return o>0&&(y.meta=JSON.parse(d)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:y}}_isArrayBuffer(e){var r;return e instanceof ArrayBuffer||((r=e==null?void 0: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(([n])=>r.includes(n)))}}var pe;(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"})(pe||(pe={}));const bm=(t,e,r={})=>{var n;const s=(n=r.skipTypes)!==null&&n!==void 0?n:[];return e?Object.keys(e).reduce((i,o)=>(i[o]=MT(o,t,e,s),i),{}):{}},MT=(t,e,r,n)=>{const s=e.find(a=>a.name===t),i=s==null?void 0:s.type,o=r[t];return i&&!n.includes(i)?xw(i,o):Rd(o)},xw=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return BT(e,r)}switch(t){case pe.bool:return UT(e);case pe.float4:case pe.float8:case pe.int2:case pe.int4:case pe.int8:case pe.numeric:case pe.oid:return FT(e);case pe.json:case pe.jsonb:return zT(e);case pe.timestamp:return WT(e);case pe.abstime:case pe.date:case pe.daterange:case pe.int4range:case pe.int8range:case pe.money:case pe.reltime:case pe.text:case pe.time:case pe.timestamptz:case pe.timetz:case pe.tsrange:case pe.tstzrange:return Rd(e);default:return Rd(e)}},Rd=t=>t,UT=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},FT=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},zT=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},BT=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,n=t[r];if(t[0]==="{"&&n==="}"){let i;const o=t.slice(1,r);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(a=>xw(e,a))}return t},WT=t=>typeof t=="string"?t.replace(" ","T"):t,bw=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 co=t=>typeof t=="function"?t:function(){return t},VT=typeof self<"u"?self:null,Ts=typeof window<"u"?window:null,nr=VT||Ts||globalThis,HT="2.0.0",qT=1e4,KT=1e3,ar={connecting:0,open:1,closing:2,closed:3},st={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},kr={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},jd={longpoll:"longpoll",websocket:"websocket"},GT={complete:4},Ad="base64url.bearer.phx.",Aa=class{constructor(t,e,r,n){this.channel=t,this.event=e,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=n,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(n=>n.status===t).forEach(n=>n.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})}},_w=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))}},JT=class{constructor(t,e,r){this.state=st.closed,this.topic=t,this.params=co(e||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Aa(this,kr.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new _w(()=>{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=st.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(n=>n.send()),this.pushBuffer=[]}),this.joinPush.receive("error",n=>{this.state=st.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,n),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=st.closed,this.socket.remove(this)}),this.onError(n=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,n),this.isJoining()&&this.joinPush.reset(),this.state=st.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 Aa(this,kr.leave,co({}),this.timeout).send(),this.state=st.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(kr.reply,(n,s)=>{this.trigger(this.replyEventName(s),n)})}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=st.closed,this.bindings=[]}onClose(t){this.on(kr.close,t)}onError(t){return this.on(kr.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 n=new Aa(this,t,function(){return e},r);return this.canPush()?n.send():(n.startTimeout(),this.pushBuffer.push(n)),n}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=st.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(kr.close,"leave")},r=new Aa(this,kr.leave,co({}),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,n){return this.topic!==t?!1:n&&n!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:r,joinRef:n}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=st.joining,this.joinPush.resend(t))}trigger(t,e,r,n){let s=this.onMessage(t,e,r,n);if(e&&!s)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(o=>o.event===t&&this.filterBindings(o,e,r));for(let o=0;ol.abort(),s),a.signal=l.signal),nr.fetch(e,a).then(c=>c.text()).then(c=>this.parseJSON(c)).then(c=>o&&o(c)).catch(c=>{c.name==="AbortError"&&i?i():o&&o(null)}),l}static xdomainRequest(t,e,r,n,s,i,o){return t.timeout=s,t.open(e,r),t.onload=()=>{let a=this.parseJSON(t.responseText);o&&o(a)},i&&(t.ontimeout=i),t.onprogress=()=>{},t.send(n),t}static xhrRequest(t,e,r,n,s,i,o,a){t.open(e,r,!0),t.timeout=i;for(let[l,c]of Object.entries(n))t.setRequestHeader(l,c);return t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===GT.complete&&a){let l=this.parseJSON(t.responseText);a(l)}},o&&(t.ontimeout=o),t.send(s),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 n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let s=e?`${e}[${n}]`:n,i=t[n];typeof i=="object"?r.push(this.serialize(i,s)):r.push(encodeURIComponent(s)+"="+encodeURIComponent(i))}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)}`}},QT=t=>{let e="",r=new Uint8Array(t),n=r.byteLength;for(let s=0;sthis.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+jd.websocket),"$1/"+jd.longpoll)}endpointURL(){return Ll.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,r){this.close(t,e,r),this.readyState=ar.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===ar.open||this.readyState===ar.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:n,messages:s}=e;if(r===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=n}else r=0;switch(r){case 200:s.forEach(i=>{setTimeout(()=>this.onmessage({data:i}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=ar.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=QT(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){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},t.join(` `),()=>this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,!e||e.status!==200?(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(t,e,r){for(let s of this.reqs)s.abort();this.readyState=ar.closed;let n=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",n)):this.onclose(n)}ajax(t,e,r,n,s){let i,o=()=>{this.reqs.delete(i),n()};i=Ll.request(t,this.endpointURL(),e,r,this.timeout,o,a=>{this.reqs.delete(i),this.isActive()&&s(a)}),this.reqs.add(i)}},ZT=class Qi{constructor(e,r={}){let n=r.events||{state:"presence_state",diff:"presence_diff"};this.state={},this.pendingDiffs=[],this.channel=e,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(n.state,s=>{let{onJoin:i,onLeave:o,onSync:a}=this.caller;this.joinRef=this.channel.joinRef(),this.state=Qi.syncState(this.state,s,i,o),this.pendingDiffs.forEach(l=>{this.state=Qi.syncDiff(this.state,l,i,o)}),this.pendingDiffs=[],a()}),this.channel.on(n.diff,s=>{let{onJoin:i,onLeave:o,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=Qi.syncDiff(this.state,s,i,o),a())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(e){return Qi.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,r,n,s){let i=this.clone(e),o={},a={};return this.map(i,(l,c)=>{r[l]||(a[l]=c)}),this.map(r,(l,c)=>{let u=i[l];if(u){let d=c.metas.map(w=>w.phx_ref),f=u.metas.map(w=>w.phx_ref),h=c.metas.filter(w=>f.indexOf(w.phx_ref)<0),y=u.metas.filter(w=>d.indexOf(w.phx_ref)<0);h.length>0&&(o[l]=c,o[l].metas=h),y.length>0&&(a[l]=this.clone(u),a[l].metas=y)}else o[l]=c}),this.syncDiff(i,{joins:o,leaves:a},n,s)}static syncDiff(e,r,n,s){let{joins:i,leaves:o}=this.clone(r);return n||(n=function(){}),s||(s=function(){}),this.map(i,(a,l)=>{let c=e[a];if(e[a]=this.clone(l),c){let u=e[a].metas.map(f=>f.phx_ref),d=c.metas.filter(f=>u.indexOf(f.phx_ref)<0);e[a].metas.unshift(...d)}n(a,c,l)}),this.map(o,(a,l)=>{let c=e[a];if(!c)return;let u=l.metas.map(d=>d.phx_ref);c.metas=c.metas.filter(d=>u.indexOf(d.phx_ref)<0),s(a,c,l),c.metas.length===0&&delete e[a]}),e}static list(e,r){return r||(r=function(n,s){return s}),this.map(e,(n,s)=>r(n,s))}static map(e,r){return Object.getOwnPropertyNames(e).map(n=>r(n,e[n]))}static clone(e){return JSON.parse(JSON.stringify(e))}},Pa={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,n,s,i,o]=JSON.parse(t);return e({join_ref:r,ref:n,topic:s,event:i,payload:o})}},binaryEncode(t){let{join_ref:e,ref:r,event:n,topic:s,payload:i}=t,o=this.META_LENGTH+e.length+r.length+s.length+n.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),c=0;l.setUint8(c++,this.KINDS.push),l.setUint8(c++,e.length),l.setUint8(c++,r.length),l.setUint8(c++,s.length),l.setUint8(c++,n.length),Array.from(e,d=>l.setUint8(c++,d.charCodeAt(0))),Array.from(r,d=>l.setUint8(c++,d.charCodeAt(0))),Array.from(s,d=>l.setUint8(c++,d.charCodeAt(0))),Array.from(n,d=>l.setUint8(c++,d.charCodeAt(0)));var u=new Uint8Array(a.byteLength+i.byteLength);return u.set(new Uint8Array(a),0),u.set(new Uint8Array(i),a.byteLength),u.buffer},binaryDecode(t){let e=new DataView(t),r=e.getUint8(0),n=new TextDecoder;switch(r){case this.KINDS.push:return this.decodePush(t,e,n);case this.KINDS.reply:return this.decodeReply(t,e,n);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,n)}},decodePush(t,e,r){let n=e.getUint8(1),s=e.getUint8(2),i=e.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=r.decode(t.slice(o,o+n));o=o+n;let l=r.decode(t.slice(o,o+s));o=o+s;let c=r.decode(t.slice(o,o+i));o=o+i;let u=t.slice(o,t.byteLength);return{join_ref:a,ref:null,topic:l,event:c,payload:u}},decodeReply(t,e,r){let n=e.getUint8(1),s=e.getUint8(2),i=e.getUint8(3),o=e.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(t.slice(a,a+n));a=a+n;let c=r.decode(t.slice(a,a+s));a=a+s;let u=r.decode(t.slice(a,a+i));a=a+i;let d=r.decode(t.slice(a,a+o));a=a+o;let f=t.slice(a,t.byteLength),h={status:d,response:f};return{join_ref:l,ref:c,topic:u,event:kr.reply,payload:h}},decodeBroadcast(t,e,r){let n=e.getUint8(1),s=e.getUint8(2),i=this.HEADER_LENGTH+2,o=r.decode(t.slice(i,i+n));i=i+n;let a=r.decode(t.slice(i,i+s));i=i+s;let l=t.slice(i,t.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},YT=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||qT,this.transport=e.transport||nr.WebSocket||xs,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=e.sessionStorage||nr&&nr.sessionStorage,this.establishedConnections=0,this.defaultEncoder=Pa.encode.bind(Pa),this.defaultDecoder=Pa.decode.bind(Pa),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 r=null;Ts&&Ts.addEventListener&&(Ts.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),r=this.connectClock)}),Ts.addEventListener("pageshow",n=>{r===this.connectClock&&(r=null,this.connect())}),Ts.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,s,i)=>{console.log(`${n}: ${s}`,i)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=co(e.params||{}),this.endPoint=`${t}/${jd.websocket}`,this.vsn=e.vsn||HT,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new _w(()=>{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}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=Ll.appendParams(Ll.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=co(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 n=this.onMessage(s=>{s.ref===e&&(this.off([n]),t(Date.now()-r))});return!0}transportName(t){switch(t){case xs:return"LongPoll";default:return t.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${Ad}${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,n=!0,s,i,o=this.transportName(t),a=l=>{this.log("transport",`falling back to ${o}...`,l),this.off([s,i]),n=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${o}`))return a("memorized");this.fallbackTimer=setTimeout(a,e),i=this.onError(l=>{this.log("transport","error",l),n&&!r&&(clearTimeout(this.fallbackTimer),a(l))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(r=!0,!n){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(a,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(),KT,"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 n=this.conn;this.waitForBufferDone(n,()=>{e?n.close(e,r||""):n.close(),this.waitForSocketClosed(n,()=>{this.conn===n&&(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===ar.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(kr.error,t)})}connectionState(){switch(this.conn&&this.conn.readyState){case ar.connecting:return"connecting";case ar.open:return"open";case ar.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 JT(t,e,this);return this.channels.push(r),r}push(t){if(this.hasLogger()){let{topic:e,event:r,payload:n,ref:s,join_ref:i}=t;this.log("push",`${e} ${r} (${i}, ${s})`,n)}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:n,payload:s,ref:i,join_ref:o}=e;if(i&&i===this.pendingHeartbeatRef){const a=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(s.status==="ok"?"ok":"error",a)}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",`${s.status||""} ${r} ${n} ${i&&"("+i+")"||""}`.trim(),s);for(let a=0;a{try{n(...e)}catch(s){this.log("error",`error in ${t} callback`,s)}})}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 uo{constructor(e,r){const n=eN(r);this.presence=new ZT(e.getChannel(),n),this.presence.onJoin((s,i,o)=>{const a=uo.onJoinPayload(s,i,o);e.getChannel().trigger("presence",a)}),this.presence.onLeave((s,i,o)=>{const a=uo.onLeavePayload(s,i,o);e.getChannel().trigger("presence",a)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return uo.transformState(this.presence.state)}static transformState(e){return e=XT(e),Object.getOwnPropertyNames(e).reduce((r,n)=>{const s=e[n];return r[n]=el(s),r},{})}static onJoinPayload(e,r,n){const s=_m(r),i=el(n);return{event:"join",key:e,currentPresences:s,newPresences:i}}static onLeavePayload(e,r,n){const s=_m(r),i=el(n);return{event:"leave",key:e,currentPresences:s,leftPresences:i}}}function el(t){return t.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))}function XT(t){return JSON.parse(JSON.stringify(t))}function eN(t){return(t==null?void 0:t.events)&&{events:t.events}}function _m(t){return t!=null&&t.metas?el(t):[]}var km;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(km||(km={}));class tN{get state(){return this.presenceAdapter.state}constructor(e,r){this.channel=e,this.presenceAdapter=new uo(this.channel.channelAdapter,r)}}function rN(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 nN{constructor(e,r,n){const s=sN(n);this.channel=e.getSocket().channel(r,s),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,n){let s;try{s=this.channel.push(e,r,n)}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>$T){const i=this.channel.pushBuffer.shift();i.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${i.event}`,i.payload())}return s}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===rn.joined}isJoined(){return this.state===rn.joined}isJoining(){return this.state===rn.joining}isClosed(){return this.state===rn.closed}isLeaving(){return this.state===rn.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}function sN(t){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config)}}var Sm;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(Sm||(Sm={}));var Ws;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(Ws||(Ws={}));var Sr;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Sr||(Sr={}));class ho{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:{}},n){var s,i;if(this.topic=e,this.params=r,this.socket=n,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 nN(this.socket.socketAdapter,e,this.params),this.presence=new tN(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=bw(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((i=(s=this.params.config)===null||s===void 0?void 0:s.broadcast)===null||i===void 0)&&i.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 n,s,i;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:o,presence:a,private:l}}=this.params,c=(s=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(h=>h.filter))!==null&&s!==void 0?s:[],u=!!this.bindings[Ws.PRESENCE]&&this.bindings[Ws.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,d={},f={broadcast:o,presence:Object.assign(Object.assign({},a),{enabled:u}),postgres_changes:c,private:l};this.socket.accessTokenValue&&(d.access_token=this.socket.accessTokenValue),this._onError(h=>{e==null||e(Sr.CHANNEL_ERROR,rN(h))}),this._onClose(()=>e==null?void 0:e(Sr.CLOSED)),this.updateJoinPayload(Object.assign({config:f},d)),this._updateFilterMessage(),this.channelAdapter.subscribe(r).receive("ok",async({postgres_changes:h})=>{if(this.socket._isManualToken()||this.socket.setAuth(),h===void 0){e==null||e(Sr.SUBSCRIBED);return}this._updatePostgresBindings(h,e)}).receive("error",h=>{this.state=rn.errored;const y=Object.values(h).join(", ")||"error";e==null||e(Sr.CHANNEL_ERROR,new Error(y,{cause:h}))}).receive("timeout",()=>{e==null||e(Sr.TIMED_OUT)})}return this}_updatePostgresBindings(e,r){var n;const s=this.bindings.postgres_changes,i=(n=s==null?void 0:s.length)!==null&&n!==void 0?n:0,o=[];for(let a=0;a{var o,a,l;const c=this.channelAdapter.push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((l=(a=(o=this.params)===null||o===void 0?void 0:o.config)===null||a===void 0?void 0:a.broadcast)===null||l===void 0)&&l.ack)&&i("ok"),c.receive("ok",()=>i("ok")),c.receive("error",()=>i("error")),c.receive("timeout",()=>i("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,n){const s=new AbortController,i=setTimeout(()=>s.abort(),n),o=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:s.signal}));return clearTimeout(i),o}_on(e,r,n){const s=e.toLocaleLowerCase(),i=this.channelAdapter.on(e,n),o={type:s,filter:r,callback:n,ref:i};return this.bindings[s]?this.bindings[s].push(o):this.bindings[s]=[o],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,r,n)=>{var s,i,o,a,l,c,u;const d=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(d,n))return!1;const f=(s=this.bindings[d])===null||s===void 0?void 0:s.find(h=>h.ref===e.ref);if(!f)return!0;if(["broadcast","presence","postgres_changes"].includes(d))if("id"in f){const h=f.id,y=(i=f.filter)===null||i===void 0?void 0:i.event;return h&&((o=r.ids)===null||o===void 0?void 0:o.includes(h))&&(y==="*"||(y==null?void 0:y.toLocaleLowerCase())===((a=r.data)===null||a===void 0?void 0:a.type.toLocaleLowerCase()))}else{const h=(c=(l=f==null?void 0:f.filter)===null||l===void 0?void 0:l.event)===null||c===void 0?void 0:c.toLocaleLowerCase();return h==="*"||h===((u=r==null?void 0:r.event)===null||u===void 0?void 0:u.toLocaleLowerCase())}else return f.type.toLocaleLowerCase()===d})}_notThisChannelEvent(e,r){const{close:n,error:s,leave:i,join:o}=ww;return r&&[n,s,i,o].includes(e)&&r!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,r,n)=>{if(typeof r=="object"&&"ids"in r){const s=r.data,{schema:i,table:o,commit_timestamp:a,type:l,errors:c}=s;return Object.assign(Object.assign({},{schema:i,table:o,commit_timestamp:a,eventType:l,new:{},old:{},errors:c}),this._getPayloadRecords(s))}return r})}copyBindings(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const r in e.bindings)for(const n of e.bindings[r])this._on(n.type,n.filter,n.callback)}static isFilterValueEqual(e,r){return(e??void 0)===(r??void 0)}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=bm(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=bm(e.columns,e.old_record)),r}}class iN{constructor(e,r){this.socket=new YT(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,n,s=1e4){return new Promise(i=>{setTimeout(()=>i("timeout"),s),this.socket.disconnect(()=>{e(),i("ok")},r,n)})}push(e){this.socket.push(e)}log(e,r,n){this.socket.log(e,r,n)}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()==Nd.connecting}isDisconnecting(){return this.socket.connectionState()==Nd.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const Em={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},oN=[1e3,2e3,5e3,1e4],aN=1e4,lN=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class cN{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 n;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 DT,this._manuallySetToken=!1,this._authPromise=null,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=i=>i?(...o)=>i(...o):(...o)=>fetch(...o),!(!((n=r==null?void 0:r.params)===null||n===void 0)&&n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey;const s=this._initializeOptions(r);this.socketAdapter=new iN(e,s),this.httpEndpoint=bw(e),this.fetch=this._resolveFetch(r==null?void 0: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 r.includes("Node.js")?new Error(`${r} To use Realtime in Node.js, you need to provide a WebSocket implementation: Option 1: Use Node.js 22+ which has native WebSocket support Option 2: Install and provide the "ws" package: npm install ws import ws from "ws" const client = new RealtimeClient(url, { ...options, transport: ws })`):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 n=>{const s=await n.unsubscribe();return n.teardown(),s}),r=await Promise.all(e);return await this.disconnect(),r}log(e,r,n){this.socketAdapter.log(e,r,n)}connectionState(){return this.socketAdapter.connectionState()||Nd.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,r={config:{}}){const n=`realtime:${e}`,s=this.getChannels().find(i=>i.topic===n);if(s)return s;{const i=new ho(`realtime:${e}`,r,this);return this._cancelPendingDisconnect(),this.channels.push(i),i}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{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=null){let r,n=!1;if(e)r=e,n=!0;else if(this.accessToken)try{r=await this.accessToken()}catch(s){this.log("error","Error fetching access token from callback",s),r=this.accessTokenValue}else r=this.accessTokenValue;n?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(s=>{const i={access_token:r,version:PT};r&&s.updateJoinPayload(i),s.joinedOnce&&s.channelAdapter.isJoined()&&s.channelAdapter.push(ww.access_token,{access_token:r})}))}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,n)=>{r=="sent"&&this._setAuthSafely(),e&&e(r,n)}}_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 n=new Blob([lN],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}_initializeOptions(e){var r,n,s,i,o,a,l,c,u,d,f;this.worker=(r=e==null?void 0:e.worker)!==null&&r!==void 0?r:!1,this.accessToken=(n=e==null?void 0:e.accessToken)!==null&&n!==void 0?n:null;const h={};h.timeout=(s=e==null?void 0:e.timeout)!==null&&s!==void 0?s:LT,h.heartbeatIntervalMs=(i=e==null?void 0:e.heartbeatIntervalMs)!==null&&i!==void 0?i:Em.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=(o=e==null?void 0:e.disconnectOnEmptyChannelsAfterMs)!==null&&o!==void 0?o:2*((a=e==null?void 0:e.heartbeatIntervalMs)!==null&&a!==void 0?a:Em.HEARTBEAT_INTERVAL),h.transport=(l=e==null?void 0:e.transport)!==null&&l!==void 0?l:jT.getWebSocketConstructor(),h.params=e==null?void 0:e.params,h.logger=e==null?void 0:e.logger,h.heartbeatCallback=this._wrapHeartbeatCallback(e==null?void 0:e.heartbeatCallback),h.reconnectAfterMs=(c=e==null?void 0:e.reconnectAfterMs)!==null&&c!==void 0?c:m=>oN[m-1]||aN;let y,w;const x=(u=e==null?void 0:e.vsn)!==null&&u!==void 0?u:IT;switch(x){case OT:y=(m,g)=>g(JSON.stringify(m)),w=(m,g)=>g(JSON.parse(m));break;case yw:y=this.serializer.encode.bind(this.serializer),w=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${h.vsn}`)}if(h.vsn=x,h.encode=(d=e==null?void 0:e.encode)!==null&&d!==void 0?d:y,h.decode=(f=e==null?void 0:e.decode)!==null&&f!==void 0?f:w,h.beforeReconnect=this._reconnectAuth.bind(this),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,h.params=Object.assign(Object.assign({},h.params),{log_level:this.logLevel})),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl,h.autoSendHeartbeat=!this.worker}return h}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var Do=class extends Error{constructor(t,e){var r;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)&&((r=e.icebergType)==null?void 0:r.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function uN(t,e,r){const n=new URL(e,t);if(r)for(const[s,i]of Object.entries(r))i!==void 0&&n.searchParams.set(s,i);return n.toString()}async function dN(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 hN(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:r,path:n,query:s,body:i,headers:o}){const a=uN(t.baseUrl,n,s),l=await dN(t.auth),c=await e(a,{method:r,headers:{...i?{"Content-Type":"application/json"}:{},...l,...o},body:i?JSON.stringify(i):void 0}),u=await c.text(),d=(c.headers.get("content-type")||"").includes("application/json"),f=d&&u?JSON.parse(u):u;if(!c.ok){const h=d?f:void 0,y=h==null?void 0:h.error;throw new Do((y==null?void 0:y.message)??`Request failed with status ${c.status}`,{status:c.status,icebergType:y==null?void 0:y.type,icebergCode:y==null?void 0:y.code,details:h})}return{status:c.status,headers:c.headers,data:f}}}}function Oa(t){return t.join("")}var fN=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Oa(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(n=>({namespace:n}))}async createNamespace(t,e){const r={namespace:t.namespace,properties:e==null?void 0: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/${Oa(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Oa(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Oa(t.namespace)}`}),!0}catch(e){if(e instanceof Do&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(r){if(r instanceof Do&&r.status===409)return;throw r}}};function bs(t){return t.join("")}var pN=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/${bs(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/${bs(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/${bs(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/${bs(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String((e==null?void 0: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/${bs(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/${bs(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(r){if(r instanceof Do&&r.status===404)return!1;throw r}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(r){if(r instanceof Do&&r.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw r}}},mN=class{constructor(t){var n;let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const r=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=hN({baseUrl:r,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=(n=t.accessDelegation)==null?void 0:n.join(","),this.namespaceOps=new fN(this.client,e),this.tableOps=new pN(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 Mo(t){"@babel/helpers - typeof";return Mo=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},Mo(t)}function gN(t,e){if(Mo(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Mo(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function vN(t){var e=gN(t,"string");return Mo(e)=="symbol"?e:e+""}function yN(t,e,r){return(e=vN(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Cm(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function H(t){for(var e=1;et?(...e)=>t(...e):(...e)=>fetch(...e),bN=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)},Od=t=>{if(Array.isArray(t))return t.map(r=>Od(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,n])=>{const s=r.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[s]=Od(n)}),e},_N=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t),Tm=t=>{var e;return t.msg||t.message||t.error_description||(typeof t.error=="string"?t.error:(e=t.error)===null||e===void 0?void 0:e.message)||JSON.stringify(t)},kN=async(t,e,r,n)=>{if(t!==null&&typeof t=="object"&&typeof t.json=="function"){const s=t;let i=parseInt(s.status,10);Number.isFinite(i)||(i=500),s.json().then(o=>{const a=(o==null?void 0:o.statusCode)||(o==null?void 0:o.code)||i+"";e(new Pd(Tm(o),i,a,n))}).catch(()=>{const o=i+"";e(new Pd(s.statusText||`HTTP ${i} error`,i,o,n))})}else e(new kw(Tm(t),t,n))},SN=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};if(t==="GET"||t==="HEAD"||!n)return H(H({},s),r);if(bN(n)){var i;const o=(e==null?void 0:e.headers)||{};let a;for(const[l,c]of Object.entries(o))l.toLowerCase()==="content-type"&&(a=c);s.headers=$l(o,"Content-Type",(i=a)!==null&&i!==void 0?i:"application/json"),s.body=JSON.stringify(n)}else s.body=n;return e!=null&&e.duplex&&(s.duplex=e.duplex),H(H({},s),r)};async function Wi(t,e,r,n,s,i,o){return new Promise((a,l)=>{t(r,SN(e,n,s,i)).then(c=>{if(!c.ok)throw c;if(n!=null&&n.noResolveJson)return c;if(o==="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=>a(c)).catch(c=>kN(c,l,n,o))})}function Sw(t="storage"){return{get:async(e,r,n,s)=>Wi(e,"GET",r,n,s,void 0,t),post:async(e,r,n,s,i)=>Wi(e,"POST",r,s,i,n,t),put:async(e,r,n,s,i)=>Wi(e,"PUT",r,s,i,n,t),head:async(e,r,n,s)=>Wi(e,"HEAD",r,H(H({},n),{},{noResolveJson:!0}),s,void 0,t),remove:async(e,r,n,s,i)=>Wi(e,"DELETE",r,s,i,n,t)}}const EN=Sw("storage"),{get:Uo,post:Ft,put:Id,head:CN,remove:pf}=EN,pt=Sw("vectors");var ji=class{constructor(t,e={},r,n="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=wN(e),this.fetch=xN(r),this.namespace=n}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=$l(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(Cc(r))return{data:null,error:r};throw r}}},TN=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e}then(t,e){return this.execute().then(t,e)}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(Cc(e))return{data:null,error:e};throw e}}};let Ew;Ew=Symbol.toStringTag;var NN=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[Ew]="BlobDownloadBuilder",this.promise=null}asStream(){return new TN(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(Cc(e))return{data:null,error:e};throw e}}};const RN={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},Nm={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var jN=class extends ji{constructor(t,e={},r,n){super(t,e,n,"storage"),this.bucketId=r}async uploadOrUpdate(t,e,r,n){var s=this;return s.handleOperation(async()=>{let i;const o=H(H({},Nm),n);let a=H(H({},s.headers),t==="POST"&&{"x-upsert":String(o.upsert)});const l=o.metadata;if(typeof Blob<"u"&&r instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),l&&i.append("metadata",s.encodeMetadata(l)),i.append("",r)):typeof FormData<"u"&&r instanceof FormData?(i=r,i.has("cacheControl")||i.append("cacheControl",o.cacheControl),l&&!i.has("metadata")&&i.append("metadata",s.encodeMetadata(l))):(i=r,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType,l&&(a["x-metadata"]=s.toBase64(s.encodeMetadata(l))),(typeof ReadableStream<"u"&&i instanceof ReadableStream||i&&typeof i=="object"&&"pipe"in i&&typeof i.pipe=="function")&&!o.duplex&&(o.duplex="half")),n!=null&&n.headers)for(const[f,h]of Object.entries(n.headers))a=$l(a,f,h);const c=s._removeEmptyFolders(e),u=s._getFinalPath(c),d=await(t=="PUT"?Id:Ft)(s.fetch,`${s.url}/object/${u}`,i,H({headers:a},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{path:c,id:d.Id,fullPath:d.Key}})}async upload(t,e,r){return this.uploadOrUpdate("POST",t,e,r)}async uploadToSignedUrl(t,e,r,n){var s=this;const i=s._removeEmptyFolders(t),o=s._getFinalPath(i),a=new URL(s.url+`/object/upload/sign/${o}`);return a.searchParams.set("token",e),s.handleOperation(async()=>{let l;const c=H(H({},Nm),n);let u=H(H({},s.headers),{"x-upsert":String(c.upsert)});const d=c.metadata;if(typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),d&&l.append("metadata",s.encodeMetadata(d)),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.has("cacheControl")||l.append("cacheControl",c.cacheControl),d&&!l.has("metadata")&&l.append("metadata",s.encodeMetadata(d))):(l=r,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType,d&&(u["x-metadata"]=s.toBase64(s.encodeMetadata(d))),(typeof ReadableStream<"u"&&l instanceof ReadableStream||l&&typeof l=="object"&&"pipe"in l&&typeof l.pipe=="function")&&!c.duplex&&(c.duplex="half")),n!=null&&n.headers)for(const[f,h]of Object.entries(n.headers))u=$l(u,f,h);return{path:i,fullPath:(await Id(s.fetch,a.toString(),l,H({headers:u},c!=null&&c.duplex?{duplex:c.duplex}:{}))).Key}})}async createSignedUploadUrl(t,e){var r=this;return r.handleOperation(async()=>{let n=r._getFinalPath(t);const s=H({},r.headers);e!=null&&e.upsert&&(s["x-upsert"]="true");const i=await Ft(r.fetch,`${r.url}/object/upload/sign/${n}`,{},{headers:s}),o=new URL(r.url+i.url),a=o.searchParams.get("token");if(!a)throw new Ec("No token returned by API");return{signedUrl:o.toString(),path:t,token:a}})}async update(t,e,r){return this.uploadOrUpdate("PUT",t,e,r)}async move(t,e,r){var n=this;return n.handleOperation(async()=>await Ft(n.fetch,`${n.url}/object/move`,{bucketId:n.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r==null?void 0:r.destinationBucket},{headers:n.headers}))}async copy(t,e,r){var n=this;return n.handleOperation(async()=>({path:(await Ft(n.fetch,`${n.url}/object/copy`,{bucketId:n.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r==null?void 0:r.destinationBucket},{headers:n.headers})).Key}))}async createSignedUrl(t,e,r){var n=this;return n.handleOperation(async()=>{let s=n._getFinalPath(t);const i=typeof(r==null?void 0:r.transform)=="object"&&r.transform!==null&&Object.keys(r.transform).length>0;let o=await Ft(n.fetch,`${n.url}/object/sign/${s}`,H({expiresIn:e},i?{transform:r.transform}:{}),{headers:n.headers});const a=new URLSearchParams;r!=null&&r.download&&a.set("download",r.download===!0?"":r.download),(r==null?void 0:r.cacheNonce)!=null&&a.set("cacheNonce",String(r.cacheNonce));const l=a.toString();return{signedUrl:encodeURI(`${n.url}${o.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(t,e,r){var n=this;return n.handleOperation(async()=>{const s=await Ft(n.fetch,`${n.url}/object/sign/${n.bucketId}`,{expiresIn:e,paths:t},{headers:n.headers}),i=new URLSearchParams;r!=null&&r.download&&i.set("download",r.download===!0?"":r.download),(r==null?void 0:r.cacheNonce)!=null&&i.set("cacheNonce",String(r.cacheNonce));const o=i.toString();return s.map(a=>H(H({},a),{},{signedUrl:a.signedURL?encodeURI(`${n.url}${a.signedURL}${o?`&${o}`:""}`):null}))})}download(t,e,r){const n=typeof(e==null?void 0:e.transform)=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image/authenticated":"object",s=new URLSearchParams;e!=null&&e.transform&&this.applyTransformOptsToQuery(s,e.transform),(e==null?void 0:e.cacheNonce)!=null&&s.set("cacheNonce",String(e.cacheNonce));const i=s.toString(),o=this._getFinalPath(t),a=()=>Uo(this.fetch,`${this.url}/${n}/${o}${i?`?${i}`:""}`,{headers:this.headers,noResolveJson:!0},r);return new NN(a,this.shouldThrowOnError)}async info(t){var e=this;const r=e._getFinalPath(t);return e.handleOperation(async()=>Od(await Uo(e.fetch,`${e.url}/object/info/${r}`,{headers:e.headers})))}async exists(t){var e=this;const r=e._getFinalPath(t);try{return await CN(e.fetch,`${e.url}/object/${r}`,{headers:e.headers}),{data:!0,error:null}}catch(s){if(e.shouldThrowOnError)throw s;if(Cc(s)){var n;const i=s instanceof Pd?s.status:s instanceof kw?(n=s.originalError)===null||n===void 0?void 0:n.status:void 0;if(i!==void 0&&[400,404].includes(i))return{data:!1,error:s}}throw s}}getPublicUrl(t,e){const r=this._getFinalPath(t),n=new URLSearchParams;e!=null&&e.download&&n.set("download",e.download===!0?"":e.download),e!=null&&e.transform&&this.applyTransformOptsToQuery(n,e.transform),(e==null?void 0:e.cacheNonce)!=null&&n.set("cacheNonce",String(e.cacheNonce));const s=n.toString(),i=typeof(e==null?void 0:e.transform)=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${r}`)+(s?`?${s}`:"")}}}async remove(t){var e=this;return e.handleOperation(async()=>await pf(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}))}async list(t,e,r){var n=this;return n.handleOperation(async()=>{const s=H(H(H({},RN),e),{},{prefix:t||""});return await Ft(n.fetch,`${n.url}/object/list/${n.bucketId}`,s,{headers:n.headers},r)})}async listV2(t,e){var r=this;return r.handleOperation(async()=>{const n=H({},t);return await Ft(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,n,{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 AN="2.105.1",na={"X-Client-Info":`storage-js/${AN}`};var PN=class extends ji{constructor(t,e={},r,n){const s=new URL(t);n!=null&&n.useNewHostname&&/supabase\.(co|in|red)$/.test(s.hostname)&&!s.hostname.includes("storage.supabase.")&&(s.hostname=s.hostname.replace("supabase.","storage.supabase."));const i=s.href.replace(/\/$/,""),o=H(H({},na),e);super(i,o,r,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=e.listBucketOptionsToQueryString(t);return await Uo(e.fetch,`${e.url}/bucket${r}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await Uo(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var r=this;return r.handleOperation(async()=>await Ft(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 Id(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 Ft(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await pf(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}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():""}},ON=class extends ji{constructor(t,e={},r){const n=t.replace(/\/$/,""),s=H(H({},na),e);super(n,s,r,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await Ft(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==null?void 0:t.limit)!==void 0&&r.set("limit",t.limit.toString()),(t==null?void 0:t.offset)!==void 0&&r.set("offset",t.offset.toString()),t!=null&&t.sortColumn&&r.set("sortColumn",t.sortColumn),t!=null&&t.sortOrder&&r.set("sortOrder",t.sortOrder),t!=null&&t.search&&r.set("search",t.search);const n=r.toString(),s=n?`${e.url}/bucket?${n}`:`${e.url}/bucket`;return await Uo(e.fetch,s,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await pf(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!_N(t))throw new Ec("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 mN({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),n=this.shouldThrowOnError;return new Proxy(r,{get(s,i){const o=s[i];return typeof o!="function"?o:async(...a)=>{try{return{data:await o.apply(s,a),error:null}}catch(l){if(n)throw l;return{data:null,error:l}}}}})}},IN=class extends ji{constructor(t,e={},r){const n=t.replace(/\/$/,""),s=H(H({},na),{},{"Content-Type":"application/json"},e);super(n,s,r,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await pt.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var r=this;return r.handleOperation(async()=>await pt.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await pt.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var r=this;return r.handleOperation(async()=>await pt.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers})||{})}},LN=class extends ji{constructor(t,e={},r){const n=t.replace(/\/$/,""),s=H(H({},na),{},{"Content-Type":"application/json"},e);super(n,s,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 pt.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await pt.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 pt.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await pt.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 pt.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},$N=class extends ji{constructor(t,e={},r){const n=t.replace(/\/$/,""),s=H(H({},na),{},{"Content-Type":"application/json"},e);super(n,s,r,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await pt.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await pt.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await pt.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await pt.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},DN=class extends $N{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new MN(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)}},MN=class extends IN{constructor(t,e,r,n){super(t,e,n),this.vectorBucketName=r}async createIndex(t){var e=()=>super.createIndex,r=this;return e().call(r,H(H({},t),{},{vectorBucketName:r.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,r=this;return e().call(r,H(H({},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 UN(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},UN=class extends LN{constructor(t,e,r,n,s){super(t,e,s),this.vectorBucketName=r,this.indexName=n}async putVectors(t){var e=()=>super.putVectors,r=this;return e().call(r,H(H({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async getVectors(t){var e=()=>super.getVectors,r=this;return e().call(r,H(H({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,r=this;return e().call(r,H(H({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,r=this;return e().call(r,H(H({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,r=this;return e().call(r,H(H({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}},FN=class extends PN{constructor(t,e={},r,n){super(t,e,r,n)}from(t){return new jN(this.url,this.headers,t,this.fetch)}get vectors(){return new DN(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new ON(this.url+"/iceberg",this.headers,this.fetch)}};const Cw="2.105.1",Ns=30*1e3,Ld=3,pu=Ld*Ns,zN="http://localhost:9999",BN="supabase.auth.token",WN={"X-Client-Info":`gotrue-js/${Cw}`},$d="X-Supabase-Api-Version",Tw={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},VN=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,HN=10*60*1e3;class Fo extends Error{constructor(e,r,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function L(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class qN extends Fo{constructor(e,r,n){super(e,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function KN(t){return L(t)&&t.name==="AuthApiError"}class Ht extends Fo{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class Fr extends Fo{constructor(e,r,n,s){super(e,n,s),this.name=r,this.status=n}}class De extends Fr{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function Ia(t){return L(t)&&t.name==="AuthSessionMissingError"}class _s extends Fr{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class La extends Fr{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class $a extends Fr{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 GN(t){return L(t)&&t.name==="AuthImplicitGrantRedirectError"}class Rm extends Fr{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 JN extends Fr{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 Dd extends Fr{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function mu(t){return L(t)&&t.name==="AuthRetryableFetchError"}class jm extends Fr{constructor(e,r,n){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class Md extends Fr{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const Dl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),Am=` \r=`.split(""),QN=(()=>{const t=new Array(128);for(let e=0;e=6;){const n=e.queue>>e.queuedBits-6&63;r(Dl[n]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const n=e.queue>>e.queuedBits-6&63;r(Dl[n]),e.queuedBits-=6}}function Nw(t,e,r){const n=QN[t];if(n>-1)for(e.queue=e.queue<<6|n,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Om(t){const e=[],r=o=>{e.push(String.fromCodePoint(o))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=o=>{XN(o,n,r)};for(let o=0;o>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 YN(t,e){for(let r=0;r55295&&n<=56319){const s=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|s)+65536,r+=1}ZN(n,e)}}function XN(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){e.utf8seq=n;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 Ys(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};for(let s=0;se.push(r)),new Uint8Array(e)}function qn(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};return t.forEach(s=>Pm(s,r,n)),Pm(null,r,n),e.join("")}function tR(t){return Math.round(Date.now()/1e3)+t}function rR(){return Symbol("auth-callback")}const ze=()=>typeof window<"u"&&typeof document<"u",Mn={tested:!1,writable:!1},Rw=()=>{if(!ze())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Mn.tested)return Mn.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Mn.tested=!0,Mn.writable=!0}catch{Mn.tested=!0,Mn.writable=!1}return Mn.writable};function nR(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((s,i)=>{e[i]=s})}catch{}return r.searchParams.forEach((n,s)=>{e[s]=n}),e}const jw=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),sR=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Rs=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},Un=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Fe=async(t,e)=>{await t.removeItem(e)};class Tc{constructor(){this.promise=new Tc.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}Tc.promiseConstructor=Promise;function Da(t){const e=t.split(".");if(e.length!==3)throw new Md("Invalid JWT structure");for(let n=0;n{setTimeout(()=>e(null),t)})}function oR(t,e){return new Promise((n,s)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await t(i);if(!e(i,null,o)){n(o);return}}catch(o){if(!e(i,o)){s(o);return}}})()})}function aR(t){return("0"+t.toString(16)).substr(-2)}function lR(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let s="";for(let i=0;i<56;i++)s+=r.charAt(Math.floor(Math.random()*n));return s}return crypto.getRandomValues(e),Array.from(e,aR).join("")}async function cR(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),s=new Uint8Array(n);return Array.from(s).map(i=>String.fromCharCode(i)).join("")}async function uR(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 cR(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function ks(t,e,r=!1){const n=lR();let s=n;r&&(s+="/recovery"),await Rs(t,`${e}-code-verifier`,s);const i=await uR(n);return[i,n===i?"plain":"s256"]}const dR=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function hR(t){const e=t.headers.get($d);if(!e||!e.match(dR))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function fR(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 pR(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 mR=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function wr(t){if(!mR.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Dt(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 gu(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const n=r.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="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 gR(t,e){return new Proxy(t,{get:(r,n,s)=>{if(n==="__isInsecureUserWarningProxy")return!0;if(typeof n=="symbol"){const i=n.toString();if(i==="Symbol(Symbol.toPrimitive)"||i==="Symbol(Symbol.toStringTag)"||i==="Symbol(util.inspect.custom)"||i==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,n,s)}return!e.value&&typeof n=="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,n,s)}})}function Im(t){return JSON.parse(JSON.stringify(t))}const Bn=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),vR=[502,503,504,520,521,522,523,524,530];async function Lm(t){var e;if(!sR(t))throw new Dd(Bn(t),0);if(vR.includes(t.status))throw new Dd(Bn(t),t.status);let r;try{r=await t.json()}catch(i){throw new Ht(Bn(i),i)}let n;const s=hR(t);if(s&&s.getTime()>=Tw["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new jm(Bn(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new De}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((i,o)=>i&&typeof o=="string",!0))throw new jm(Bn(r),t.status,r.weak_password.reasons);throw new qN(Bn(r),t.status||500,n)}const yR=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),r))};async function z(t,e,r,n){var s;const i=Object.assign({},n==null?void 0:n.headers);i[$d]||(i[$d]=Tw["2024-01-01"].name),n!=null&&n.jwt&&(i.Authorization=`Bearer ${n.jwt}`);const o=(s=n==null?void 0:n.query)!==null&&s!==void 0?s:{};n!=null&&n.redirectTo&&(o.redirect_to=n.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await wR(t,e,r+a,{headers:i,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(l):{data:Object.assign({},l),error:null}}async function wR(t,e,r,n,s,i){const o=yR(e,n,s,i);let a;try{a=await t(r,Object.assign({},o))}catch(l){throw console.error(l),new Dd(Bn(l),0)}if(a.ok||await Lm(a),n!=null&&n.noResolveJson)return a;try{return await a.json()}catch(l){await Lm(l)}}function kt(t){var e;let r=null;_R(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=tR(t.expires_in)));const n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}function $m(t){const e=kt(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,n)=>r&&typeof n=="string",!0)&&(e.data.weak_password=t.weak_password),e}function nn(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function xR(t){return{data:t,error:null}}function bR(t){const{action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i}=t,o=Sc(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i},l=Object.assign({},o);return{data:{properties:a,user:l},error:null}}function Dm(t){return t}function _R(t){return t.access_token&&t.refresh_token&&t.expires_in}const vu=["global","local","others"];class kR{constructor({url:e="",headers:r={},fetch:n,experimental:s}){this.url=e,this.headers=r,this.fetch=jw(n),this.experimental=s??{},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=vu[0]){if(vu.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${vu.join(", ")}`);try{return await z(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(L(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,r={}){try{return await z(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:nn})}catch(n){if(L(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{const{options:r}=e,n=Sc(e,["options"]),s=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(s.new_email=n==null?void 0:n.newEmail,delete s.newEmail),await z(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:bR,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(L(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await z(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:nn})}catch(r){if(L(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,n,s,i,o,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await z(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(i=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:Dm});if(u.error)throw u.error;const d=await u.json(),f=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,h=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return h.length>0&&(h.forEach(y=>{const w=parseInt(y.split(";")[0].split("=")[1].substring(0,1)),x=JSON.parse(y.split(";")[1].split("=")[1]);c[`${x}Page`]=w}),c.total=parseInt(f)),{data:Object.assign(Object.assign({},d),c),error:null}}catch(c){if(L(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){wr(e);try{return await z(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:nn})}catch(r){if(L(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){wr(e);try{return await z(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:nn})}catch(n){if(L(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){wr(e);try{return await z(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:nn})}catch(n){if(L(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){wr(e.userId);try{const{data:r,error:n}=await z(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:r,error:n}}catch(r){if(L(r))return{data:null,error:r};throw r}}async _deleteFactor(e){wr(e.userId),wr(e.id);try{return{data:await z(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(L(r))return{data:null,error:r};throw r}}async _listOAuthClients(e){var r,n,s,i,o,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await z(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(i=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:Dm});if(u.error)throw u.error;const d=await u.json(),f=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,h=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return h.length>0&&(h.forEach(y=>{const w=parseInt(y.split(";")[0].split("=")[1].substring(0,1)),x=JSON.parse(y.split(";")[1].split("=")[1]);c[`${x}Page`]=w}),c.total=parseInt(f)),{data:Object.assign(Object.assign({},d),c),error:null}}catch(c){if(L(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await z(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(L(r))return{data:null,error:r};throw r}}async _getOAuthClient(e){try{return await z(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(L(r))return{data:null,error:r};throw r}}async _updateOAuthClient(e,r){try{return await z(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(L(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(e){try{return await z(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(L(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(e){try{return await z(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(L(r))return{data:null,error:r};throw r}}async _listCustomProviders(e){try{const r={};return e!=null&&e.type&&(r.type=e.type),await z(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:r,xform:n=>{var s;return{data:{providers:(s=n==null?void 0:n.providers)!==null&&s!==void 0?s:[]},error:null}}})}catch(r){if(L(r))return{data:{providers:[]},error:r};throw r}}async _createCustomProvider(e){try{return await z(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(L(r))return{data:null,error:r};throw r}}async _getCustomProvider(e){try{return await z(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(L(r))return{data:null,error:r};throw r}}async _updateCustomProvider(e,r){try{return await z(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(L(n))return{data:null,error:n};throw n}}async _deleteCustomProvider(e){try{return await z(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(L(r))return{data:null,error:r};throw r}}async _adminListPasskeys(e){Dt(this.experimental),wr(e.userId);try{return await z(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(L(r))return{data:null,error:r};throw r}}async _adminDeletePasskey(e){Dt(this.experimental),wr(e.userId),wr(e.passkeyId);try{return await z(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(L(r))return{data:null,error:r};throw r}}}function Mm(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}const Xt={debug:!!(globalThis&&Rw()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class Aw extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class Um extends Aw{}async function SR(t,e,r){Xt.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const n=new globalThis.AbortController;let s;e>0&&(s=setTimeout(()=>{n.abort(),Xt.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e)),await Promise.resolve();try{return await globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async i=>{if(i){clearTimeout(s),Xt.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,i.name);try{return await r()}finally{Xt.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,i.name)}}else{if(e===0)throw Xt.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new Um(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Xt.debug)try{const o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),clearTimeout(s),await r()}})}catch(i){if(e>0&&clearTimeout(s),(i==null?void 0:i.name)==="AbortError"&&e>0){if(n.signal.aborted)return Xt.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",t),console.warn(`@supabase/gotrue-js: Lock "${t}" was not released within ${e}ms. This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover.`),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,{mode:"exclusive",steal:!0},async o=>{if(o){Xt.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",t,o.name);try{return await r()}finally{Xt.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",t,o.name)}}else return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await r()}));throw Xt.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",t),new Um(`Lock "${t}" was released because another request stole it`)}throw i}}function ER(){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 Pw(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function CR(t){return parseInt(t,16)}function TR(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}function NR(t){var e;const{chainId:r,domain:n,expirationTime:s,issuedAt:i=new Date,nonce:o,notBefore:a,requestId:l,resources:c,scheme:u,uri:d,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(!n)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${o}`);if(!d)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(` `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const h=Pw(t.address),y=u?`${u}://${n}`:n,w=t.statement?`${t.statement} `:"",x=`${y} wants you to sign in with your Ethereum account: ${h} ${w}`;let m=`URI: ${d} Version: ${f} Chain ID: ${r}${o?` Nonce: ${o}`:""} Issued At: ${i.toISOString()}`;if(s&&(m+=` Expiration Time: ${s.toISOString()}`),a&&(m+=` Not Before: ${a.toISOString()}`),l&&(m+=` Request ID: ${l}`),c){let g=` Resources:`;for(const v of c){if(!v||typeof v!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${v}`);g+=` - ${v}`}m+=g}return`${x} ${m}`}class Pe extends Error{constructor({message:e,code:r,cause:n,name:s}){var i;super(e,{cause:n}),this.__isWebAuthnError=!0,this.name=(i=s??(n instanceof Error?n.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=r}}class Ml extends Pe{constructor(e,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:e}),this.name="WebAuthnUnknownError",this.originalError=r}}function RR({error:t,options:e}){var r,n,s;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Pe({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=i.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new Pe({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new Pe({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((s=i.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new Pe({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 Pe({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Pe({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(a=>a.type==="public-key").length===0?new Pe({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Pe({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 o=window.location.hostname;if(Ow(o)){if(i.rp.id!==o)return new Pe({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Pe({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new Pe({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 Pe({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 Pe({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function jR({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 Pe({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Pe({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(Ow(n)){if(r.rpId!==n)return new Pe({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Pe({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Pe({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 Pe({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class AR{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 Ud=new AR;function Fm(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:n}=t,s=Sc(t,["challenge","user","excludeCredentials"]),i=Ys(e).buffer,o=Object.assign(Object.assign({},r),{id:Ys(r.id).buffer}),a=Object.assign(Object.assign({},s),{challenge:i,user:o});if(n&&n.length>0){a.excludeCredentials=new Array(n.length);for(let l=0;l0){i.allowCredentials=new Array(r.length);for(let o=0;os!==null&&typeof s=="object"&&!Array.isArray(s),r=s=>s instanceof ArrayBuffer||ArrayBuffer.isView(s),n={};for(const s of t)if(s)for(const i in s){const o=s[i];if(o!==void 0)if(Array.isArray(o))n[i]=o;else if(r(o))n[i]=o;else if(e(o)){const a=n[i];e(a)?n[i]=Fl(a,o):n[i]=Fl(o)}else n[i]=o}return n}function IR(t,e){return Fl(PR,t,e||{})}function LR(t,e){return Fl(OR,t,e||{})}class $R{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:n,signal:s},i){var o;try{const{data:a,error:l}=await this.client.mfa.challenge({factorId:e,webauthn:r});if(!a)return{data:null,error:l};const c=s??Ud.createNewAbortSignal();if(a.webauthn.type==="create"){const{user:u}=a.webauthn.credential_options.publicKey;if(!u.name){const d=n;if(d)u.name=`${u.id}:${d}`;else{const h=(await this.client.getUser()).data.user,y=((o=h==null?void 0:h.user_metadata)===null||o===void 0?void 0:o.name)||(h==null?void 0:h.email)||(h==null?void 0:h.id)||"User";u.name=`${u.id}:${y}`}}u.displayName||(u.displayName=u.name)}switch(a.webauthn.type){case"create":{const u=IR(a.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:d,error:f}=await Iw({publicKey:u,signal:c});return d?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:d}},error:null}:{data:null,error:f}}case"request":{const u=LR(a.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:d,error:f}=await Lw(Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:u,signal:c}));return d?{data:{factorId:e,challengeId:a.id,webauthn:{type:a.webauthn.type,credential_response:d}},error:null}:{data:null,error:f}}}}catch(a){return L(a)?{data:null,error:a}:{data:null,error:new Ht("Unexpected error in challenge",a)}}}async _verify({challengeId:e,factorId:r,webauthn:n}){return this.client.mfa.verify({factorId:r,challengeId:e,webauthn:n})}async _authenticate({factorId:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:s}={}},i){if(!r)return{data:null,error:new Fo("rpId is required for WebAuthn authentication")};try{if(!Ul())return{data:null,error:new Ht("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this.challenge({factorId:e,webauthn:{rpId:r,rpOrigins:n},signal:s},{request:i});if(!o)return{data:null,error:a};const{webauthn:l}=o;return this._verify({factorId:e,challengeId:o.challengeId,webauthn:{type:l.type,rpId:r,rpOrigins:n,credential_response:l.credential_response}})}catch(o){return L(o)?{data:null,error:o}:{data:null,error:new Ht("Unexpected error in authenticate",o)}}}async _register({friendlyName:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:s}={}},i){if(!r)return{data:null,error:new Fo("rpId is required for WebAuthn registration")};try{if(!Ul())return{data:null,error:new Ht("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this._enroll({friendlyName:e});if(!o)return await this.client.mfa.listFactors().then(u=>{var d;return(d=u.data)===null||d===void 0?void 0:d.all.find(f=>f.factor_type==="webauthn"&&f.friendly_name===e&&f.status!=="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId:u==null?void 0:u.id}):void 0),{data:null,error:a};const{data:l,error:c}=await this._challenge({factorId:o.id,friendlyName:o.friendly_name,webauthn:{rpId:r,rpOrigins:n},signal:s},{create:i});return l?this._verify({factorId:o.id,challengeId:l.challengeId,webauthn:{rpId:r,rpOrigins:n,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(o){return L(o)?{data:null,error:o}:{data:null,error:new Ht("Unexpected error in register",o)}}}}ER();const DR={url:zN,storageKey:BN,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:WN,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}};async function Vm(t,e,r){return await r()}const Ss={};class zo{get jwks(){var e,r;return(r=(e=Ss[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){Ss[this.storageKey]=Object.assign(Object.assign({},Ss[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=Ss[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Ss[this.storageKey]=Object.assign(Object.assign({},Ss[this.storageKey]),{cachedAt:e})}constructor(e){var r,n,s,i;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const o=Object.assign(Object.assign({},DR),e);if(this.storageKey=o.storageKey,this.instanceID=(r=zo.nextInstanceID[this.storageKey])!==null&&r!==void 0?r:0,zo.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!o.debug,typeof o.debug=="function"&&(this.logger=o.debug),this.instanceID>0&&ze()){const a=`${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(a),this.logDebugMessages&&console.trace(a)}if(this.persistSession=o.persistSession,this.autoRefreshToken=o.autoRefreshToken,this.experimental=(n=o.experimental)!==null&&n!==void 0?n:{},this.admin=new kR({url:o.url,headers:o.headers,fetch:o.fetch,experimental:this.experimental}),this.url=o.url,this.headers=o.headers,this.fetch=jw(o.fetch),this.lock=o.lock||Vm,this.detectSessionInUrl=o.detectSessionInUrl,this.flowType=o.flowType,this.hasCustomAuthorizationHeader=o.hasCustomAuthorizationHeader,this.throwOnError=o.throwOnError,this.lockAcquireTimeout=o.lockAcquireTimeout,o.lock?this.lock=o.lock:this.persistSession&&ze()&&(!((s=globalThis==null?void 0:globalThis.navigator)===null||s===void 0)&&s.locks)?this.lock=SR:this.lock=Vm,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 $R(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?(o.storage?this.storage=o.storage:Rw()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=Mm(this.memoryStorage)),o.userStorage&&(this.userStorage=o.userStorage)):(this.memoryStorage={},this.storage=Mm(this.memoryStorage)),ze()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(i=this.broadcastChannel)===null||i===void 0||i.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a);try{await this._notifyAllSubscribers(a.data.event,a.data.session,!1)}catch(l){this._debug("#broadcastChannel","error",l)}})}o.skipAutoInitialize||this.initialize().catch(a=>{this._debug("#initialize()","error",a)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${Cw}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let r={},n="none";if(ze()&&(r=nR(window.location.href),this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce")),ze()&&this.detectSessionInUrl&&n!=="none"){const{data:s,error:i}=await this._getSessionFromURL(r,n);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),GN(i)){const l=(e=i.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:i}}return{error:i}}const{session:o,redirectType:a}=s;return this._debug("#_initialize()","detected session in URL",o,"redirect type",a),await this._saveSession(o),setTimeout(async()=>{a==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return L(r)?this._returnResult({error:r}):this._returnResult({error:new Ht("Unexpected error during initialization",r)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,s;try{const i=await z(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:kt}),{data:o,error:a}=i;if(a||!o)return this._returnResult({data:{user:null,session:null},error:a});const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(L(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signUp(e){var r,n,s;try{let i;if("email"in e){const{email:u,password:d,options:f}=e;let h=null,y=null;this.flowType==="pkce"&&([h,y]=await ks(this.storage,this.storageKey)),i=await z(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f==null?void 0:f.emailRedirectTo,body:{email:u,password:d,data:(r=f==null?void 0:f.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:h,code_challenge_method:y},xform:kt})}else if("phone"in e){const{phone:u,password:d,options:f}=e;i=await z(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:d,data:(n=f==null?void 0:f.data)!==null&&n!==void 0?n:{},channel:(s=f==null?void 0:f.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken}},xform:kt})}else throw new La("You must provide either an email or phone number and a password");const{data:o,error:a}=i;if(a||!o)return await Fe(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:a});const l=o.session,c=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(i){if(await Fe(this.storage,`${this.storageKey}-code-verifier`),L(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:i,password:o,options:a}=e;r=await z(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:$m})}else if("phone"in e){const{phone:i,password:o,options:a}=e;r=await z(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:$m})}else throw new La("You must provide either an email or phone number and a password");const{data:n,error:s}=r;if(s)return this._returnResult({data:{user:null,session:null},error:s});if(!n||!n.session||!n.user){const i=new _s;return this._returnResult({data:{user:null,session:null},error:i})}return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),this._returnResult({data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:s})}catch(r){if(L(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOAuth(e){var r,n,s,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}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,n,s,i,o,a,l,c,u,d,f;let h,y;if("message"in e)h=e.message,y=e.signature;else{const{chain:w,wallet:x,statement:m,options:g}=e;let v;if(ze())if(typeof x=="object")v=x;else{const P=window;if("ethereum"in P&&typeof P.ethereum=="object"&&"request"in P.ethereum&&typeof P.ethereum.request=="function")v=P.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 x!="object"||!(g!=null&&g.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");v=x}const _=new URL((r=g==null?void 0:g.url)!==null&&r!==void 0?r:window.location.href),k=await v.request({method:"eth_requestAccounts"}).then(P=>P).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!k||k.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const S=Pw(k[0]);let E=(n=g==null?void 0:g.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!E){const P=await v.request({method:"eth_chainId"});E=CR(P)}const R={domain:_.host,address:S,statement:m,uri:_.href,version:"1",chainId:E,nonce:(s=g==null?void 0:g.signInWithEthereum)===null||s===void 0?void 0:s.nonce,issuedAt:(o=(i=g==null?void 0:g.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(a=g==null?void 0:g.signInWithEthereum)===null||a===void 0?void 0:a.expirationTime,notBefore:(l=g==null?void 0:g.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=g==null?void 0:g.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=g==null?void 0:g.signInWithEthereum)===null||u===void 0?void 0:u.resources};h=NR(R),y=await v.request({method:"personal_sign",params:[TR(h),S]})}try{const{data:w,error:x}=await z(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:h,signature:y},!((d=e.options)===null||d===void 0)&&d.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:kt});if(x)throw x;if(!w||!w.session||!w.user){const m=new _s;return this._returnResult({data:{user:null,session:null},error:m})}return w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),this._returnResult({data:Object.assign({},w),error:x})}catch(w){if(L(w))return this._returnResult({data:{user:null,session:null},error:w});throw w}}async signInWithSolana(e){var r,n,s,i,o,a,l,c,u,d,f,h;let y,w;if("message"in e)y=e.message,w=e.signature;else{const{chain:x,wallet:m,statement:g,options:v}=e;let _;if(ze())if(typeof m=="object")_=m;else{const S=window;if("solana"in S&&typeof S.solana=="object"&&("signIn"in S.solana&&typeof S.solana.signIn=="function"||"signMessage"in S.solana&&typeof S.solana.signMessage=="function"))_=S.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 m!="object"||!(v!=null&&v.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");_=m}const k=new URL((r=v==null?void 0:v.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in _&&_.signIn){const S=await _.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},v==null?void 0:v.signInWithSolana),{version:"1",domain:k.host,uri:k.href}),g?{statement:g}:null));let E;if(Array.isArray(S)&&S[0]&&typeof S[0]=="object")E=S[0];else if(S&&typeof S=="object"&&"signedMessage"in S&&"signature"in S)E=S;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in E&&"signature"in E&&(typeof E.signedMessage=="string"||E.signedMessage instanceof Uint8Array)&&E.signature instanceof Uint8Array)y=typeof E.signedMessage=="string"?E.signedMessage:new TextDecoder().decode(E.signedMessage),w=E.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in _)||typeof _.signMessage!="function"||!("publicKey"in _)||typeof _!="object"||!_.publicKey||!("toBase58"in _.publicKey)||typeof _.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");y=[`${k.host} wants you to sign in with your Solana account:`,_.publicKey.toBase58(),...g?["",g,""]:[""],"Version: 1",`URI: ${k.href}`,`Issued At: ${(s=(n=v==null?void 0:v.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((i=v==null?void 0:v.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${v.signInWithSolana.notBefore}`]:[],...!((o=v==null?void 0:v.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${v.signInWithSolana.expirationTime}`]:[],...!((a=v==null?void 0:v.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${v.signInWithSolana.chainId}`]:[],...!((l=v==null?void 0:v.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${v.signInWithSolana.nonce}`]:[],...!((c=v==null?void 0:v.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${v.signInWithSolana.requestId}`]:[],...!((d=(u=v==null?void 0:v.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||d===void 0)&&d.length?["Resources",...v.signInWithSolana.resources.map(E=>`- ${E}`)]:[]].join(` `);const S=await _.signMessage(new TextEncoder().encode(y),"utf8");if(!S||!(S instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=S}}try{const{data:x,error:m}=await z(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:y,signature:qn(w)},!((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:kt});if(m)throw m;if(!x||!x.session||!x.user){const g=new _s;return this._returnResult({data:{user:null,session:null},error:g})}return x.session&&(await this._saveSession(x.session),await this._notifyAllSubscribers("SIGNED_IN",x.session)),this._returnResult({data:Object.assign({},x),error:m})}catch(x){if(L(x))return this._returnResult({data:{user:null,session:null},error:x});throw x}}async _exchangeCodeForSession(e){const r=await Un(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(r??"").split("/");try{if(!n&&this.flowType==="pkce")throw new JN;const{data:i,error:o}=await z(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:kt});if(await Fe(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!i||!i.session||!i.user){const a=new _s;return this._returnResult({data:{user:null,session:null,redirectType:null},error:a})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers(s==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",i.session)),this._returnResult({data:Object.assign(Object.assign({},i),{redirectType:s??null}),error:o})}catch(i){if(await Fe(this.storage,`${this.storageKey}-code-verifier`),L(i))return this._returnResult({data:{user:null,session:null,redirectType:null},error:i});throw i}}async signInWithIdToken(e){try{const{options:r,provider:n,token:s,access_token:i,nonce:o}=e,a=await z(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:s,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:kt}),{data:l,error:c}=a;if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l||!l.session||!l.user){const u=new _s;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(L(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOtp(e){var r,n,s,i,o;try{if("email"in e){const{email:a,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await ks(this.storage,this.storageKey));const{error:d}=await z(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(r=l==null?void 0:l.data)!==null&&r!==void 0?r:{},create_user:(n=l==null?void 0:l.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo:l==null?void 0:l.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:d})}if("phone"in e){const{phone:a,options:l}=e,{data:c,error:u}=await z(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(s=l==null?void 0:l.data)!==null&&s!==void 0?s:{},create_user:(i=l==null?void 0:l.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken},channel:(o=l==null?void 0:l.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:u})}throw new La("You must provide either an email or phone number.")}catch(a){if(await Fe(this.storage,`${this.storageKey}-code-verifier`),L(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async verifyOtp(e){var r,n;try{let s,i;"options"in e&&(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo,i=(n=e.options)===null||n===void 0?void 0:n.captchaToken);const{data:o,error:a}=await z(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:kt});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,c=o.user;return l!=null&&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(s){if(L(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithSSO(e){var r,n,s,i,o;try{let a=null,l=null;this.flowType==="pkce"&&([a,l]=await ks(this.storage,this.storageKey));const c=await z(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:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:l}),headers:this.headers,xform:xR});return!((i=c.data)===null||i===void 0)&&i.url&&ze()&&!(!((o=e.options)===null||o===void 0)&&o.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(a){if(await Fe(this.storage,`${this.storageKey}-code-verifier`),L(a))return this._returnResult({data:null,error:a});throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new De;const{error:s}=await z(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return this._returnResult({data:{user:null,session:null},error:s})})}catch(e){if(L(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:n,type:s,options:i}=e,{error:o}=await z(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in e){const{phone:n,type:s,options:i}=e,{data:o,error:a}=await z(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:a})}throw new La("You must provide either an email or phone number and a type")}catch(r){if(L(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await n}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.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await Un(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 n=e.expires_at?e.expires_at*1e3-Date.now()await this._getUser());return r.data.user&&(this.suppressGetSessionWarning=!0),r}async _getUser(e){try{return e?await z(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:nn}):await this._useSession(async r=>{var n,s,i;const{data:o,error:a}=r;if(a)throw a;return!(!((n=o.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new De}:await z(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(s=o.session)===null||s===void 0?void 0:s.access_token)!==null&&i!==void 0?i:void 0,xform:nn})})}catch(r){if(L(r))return Ia(r)&&(await this._removeSession(),await Fe(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:r});throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async n=>{const{data:s,error:i}=n;if(i)throw i;if(!s.session)throw new De;const o=s.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await ks(this.storage,this.storageKey));const{data:c,error:u}=await z(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:nn});if(u)throw u;return o.user=c.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(n){if(await Fe(this.storage,`${this.storageKey}-code-verifier`),L(n))return this._returnResult({data:{user:null},error:n});throw n}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new De;const r=Date.now()/1e3;let n=r,s=!0,i=null;const{payload:o}=Da(e.access_token);if(o.exp&&(n=o.exp,s=n<=r),s){const{data:a,error:l}=await this._callRefreshToken(e.refresh_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!a)return{data:{user:null,session:null},error:null};i=a}else{const{data:a,error:l}=await this._getUser(e.access_token);if(l)return this._returnResult({data:{user:null,session:null},error:l});i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(r){if(L(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){const{data:o,error:a}=r;if(a)throw a;e=(n=o.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new De;const{data:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):s?this._returnResult({data:{user:s.user,session:s},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(r){if(L(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async _getSessionFromURL(e,r){var n;try{if(!ze())throw new $a("No browser detected.");if(e.error||e.error_description||e.error_code)throw new $a(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 Rm("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new $a("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 Rm("No code detected.");const{data:v,error:_}=await this._exchangeCodeForSession(e.code);if(_)throw _;const k=new URL(window.location.href);return k.searchParams.delete("code"),window.history.replaceState(window.history.state,"",k.toString()),{data:{session:v.session,redirectType:(n=v.redirectType)!==null&&n!==void 0?n:null},error:null}}const{provider_token:s,provider_refresh_token:i,access_token:o,refresh_token:a,expires_in:l,expires_at:c,token_type:u}=e;if(!o||!l||!a||!u)throw new $a("No session defined in URL");const d=Math.round(Date.now()/1e3),f=parseInt(l);let h=d+f;c&&(h=parseInt(c));const y=h-d;y*1e3<=Ns&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${y}s, should have been closer to ${f}s`);const w=h-f;d-w>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",w,h,d):d-w<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",w,h,d);const{data:x,error:m}=await this._getUser(o);if(m)throw m;const g={provider_token:s,provider_refresh_token:i,access_token:o,expires_in:f,expires_at:h,refresh_token:a,token_type:u,user:x.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:g,redirectType:e.type},error:null})}catch(s){if(L(s))return this._returnResult({data:{session:null,redirectType:null},error:s});throw s}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const r=await Un(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i&&!Ia(i))return this._returnResult({error:i});const o=(n=s.session)===null||n===void 0?void 0:n.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(KN(a)&&(a.status===404||a.status===401||a.status===403)||Ia(a)))return this._returnResult({error:a})}return e!=="others"&&(await this._removeSession(),await Fe(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const r=rR(),n={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,n),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,s;try{const{data:{session:i},error:o}=r;if(o)throw o;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),Ia(i)?console.warn(i):console.error(i)}})}async resetPasswordForEmail(e,r={}){let n=null,s=null;this.flowType==="pkce"&&([n,s]=await ks(this.storage,this.storageKey,!0));try{return await z(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:s,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(i){if(await Fe(this.storage,`${this.storageKey}-code-verifier`),L(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return this._returnResult({data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(r){if(L(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;try{const{data:n,error:s}=await this._useSession(async i=>{var o,a,l,c,u;const{data:d,error:f}=i;if(f)throw f;const h=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(o=e.options)===null||o===void 0?void 0:o.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:!0});return await z(this.fetch,"GET",h,{headers:this.headers,jwt:(u=(c=d.session)===null||c===void 0?void 0:c.access_token)!==null&&u!==void 0?u:void 0})});if(s)throw s;return ze()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),this._returnResult({data:{provider:e.provider,url:n==null?void 0:n.url},error:null})}catch(n){if(L(n))return this._returnResult({data:{provider:e.provider,url:null},error:n});throw n}}async linkIdentityIdToken(e){return await this._useSession(async r=>{var n;try{const{error:s,data:{session:i}}=r;if(s)throw s;const{options:o,provider:a,token:l,access_token:c,nonce:u}=e,d=await z(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(n=i==null?void 0:i.access_token)!==null&&n!==void 0?n:void 0,body:{provider:a,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:kt}),{data:f,error:h}=d;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 _s}):(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("USER_UPDATED",f.session)),this._returnResult({data:f,error:h}))}catch(s){if(await Fe(this.storage,`${this.storageKey}-code-verifier`),L(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}})}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,s;const{data:i,error:o}=r;if(o)throw o;return await z(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(n=i.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:void 0})})}catch(r){if(L(r))return this._returnResult({data:null,error:r});throw r}}async _refreshAccessToken(e){const r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await oR(async s=>(s>0&&await iR(200*Math.pow(2,s-1)),this._debug(r,"refreshing attempt",s),await z(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:kt})),(s,i)=>{const o=200*Math.pow(2,s);return i&&mu(i)&&Date.now()+o-n{try{await a.callback(e,r)}catch(l){i.push(l)}});if(await Promise.all(o),i.length>0){for(let a=0;athis._autoRefreshTokenTick(),Ns);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 _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((n.expires_at*1e3-e)/Ns);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${Ns}ms, refresh threshold is ${Ld} ticks`),s<=Ld&&await this._callRefreshToken(n.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.isAcquireTimeout||e instanceof Aw)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!ze()||!(window!=null&&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==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,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()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){const s=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&s.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&s.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[i,o]=await ks(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});s.push(a.toString())}if(n!=null&&n.queryParams){const i=new URLSearchParams(n.queryParams);s.push(i.toString())}return n!=null&&n.skipBrowserRedirect&&s.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;return i?this._returnResult({data:null,error:i}):await z(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(L(r))return this._returnResult({data:null,error:r});throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,s;const{data:i,error:o}=r;if(o)return this._returnResult({data:null,error:o});const a=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 z(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(n=i==null?void 0:i.session)===null||n===void 0?void 0:n.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&l.type==="totp"&&(!((s=l==null?void 0:l.totp)===null||s===void 0)&&s.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(L(r))return this._returnResult({data:null,error:r});throw r}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;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"?Bm(e.webauthn.credential_response):Wm(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:l}=await z(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});return l?this._returnResult({data:null,error:l}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),this._returnResult({data:a,error:l}))})}catch(r){if(L(r))return this._returnResult({data:null,error:r});throw r}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i)return this._returnResult({data:null,error:i});const o=await z(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});if(o.error)return o;const{data:a}=o;if(a.type!=="webauthn")return{data:a,error:null};switch(a.webauthn.type){case"create":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:Fm(a.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:zm(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(L(r))return this._returnResult({data:null,error:r});throw r}})}async _challengeAndVerify(e){const{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?this._returnResult({data:null,error:n}):await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){var e;const{data:{user:r},error:n}=await this.getUser();if(n)return{data:null,error:n};const s={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=r==null?void 0:r.factors)!==null&&e!==void 0?e:[])s.all.push(i),i.status==="verified"&&s[i.factor_type].push(i);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(e){var r,n,s,i;if(e)try{const{payload:h}=Da(e);let y=null;h.aal&&(y=h.aal);let w=y;const{data:{user:x},error:m}=await this.getUser(e);if(m)return this._returnResult({data:null,error:m});((n=(r=x==null?void 0:x.factors)===null||r===void 0?void 0:r.filter(_=>_.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(w="aal2");const v=h.amr||[];return{data:{currentLevel:y,nextLevel:w,currentAuthenticationMethods:v},error:null}}catch(h){if(L(h))return this._returnResult({data:null,error:h});throw h}const{data:{session:o},error:a}=await this.getSession();if(a)return this._returnResult({data:null,error:a});if(!o)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:l}=Da(o.access_token);let c=null;l.aal&&(c=l.aal);let u=c;((i=(s=o.user.factors)===null||s===void 0?void 0:s.filter(h=>h.status==="verified"))!==null&&i!==void 0?i:[]).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:n},error:s}=r;return s?this._returnResult({data:null,error:s}):n?await z(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:n.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new De})})}catch(r){if(L(r))return this._returnResult({data:null,error:r});throw r}}async _approveAuthorization(e,r){try{return await this._useSession(async n=>{const{data:{session:s},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new De});const o=await z(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"approve"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&ze()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(n){if(L(n))return this._returnResult({data:null,error:n});throw n}}async _denyAuthorization(e,r){try{return await this._useSession(async n=>{const{data:{session:s},error:i}=n;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new De});const o=await z(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"deny"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&ze()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(n){if(L(n))return this._returnResult({data:null,error:n});throw n}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;return n?this._returnResult({data:null,error:n}):r?await z(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,xform:s=>({data:s,error:null})}):this._returnResult({data:null,error:new De})})}catch(e){if(L(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async r=>{const{data:{session:n},error:s}=r;return s?this._returnResult({data:null,error:s}):n?(await z(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new De})})}catch(r){if(L(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(e,r={keys:[]}){let n=r.keys.find(a=>a.kid===e);if(n)return n;const s=Date.now();if(n=this.jwks.keys.find(a=>a.kid===e),n&&this.jwks_cached_at+HN>s)return n;const{data:i,error:o}=await z(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=s,n=i.keys.find(a=>a.kid===e),!n)?null:n}async getClaims(e,r={}){try{let n=e;if(!n){const{data:h,error:y}=await this.getSession();if(y||!h.session)return this._returnResult({data:null,error:y});n=h.session.access_token}const{header:s,payload:i,signature:o,raw:{header:a,payload:l}}=Da(n);r!=null&&r.allowExpired||fR(i.exp);const c=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!c){const{error:h}=await this.getUser(n);if(h)throw h;return{data:{claims:i,header:s,signature:o},error:null}}const u=pR(s.alg),d=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,d,o,eR(`${a}.${l}`)))throw new Md("Invalid JWT signature");return{data:{claims:i,header:s,signature:o},error:null}}catch(n){if(L(n))return this._returnResult({data:null,error:n});throw n}}async signInWithPasskey(e){var r,n,s;Dt(this.experimental);try{if(!Ul())return this._returnResult({data:null,error:new Ht("Browser does not support WebAuthn",null)});const{data:i,error:o}=await this._startPasskeyAuthentication({options:{captchaToken:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}});if(o||!i)return this._returnResult({data:null,error:o});const a=zm(i.options),l=(s=(n=e==null?void 0:e.options)===null||n===void 0?void 0:n.signal)!==null&&s!==void 0?s:Ud.createNewAbortSignal(),{data:c,error:u}=await Lw({publicKey:a,signal:l});if(u||!c)return this._returnResult({data:null,error:u??new Ht("WebAuthn ceremony failed",null)});const d=Wm(c);return this._verifyPasskeyAuthentication({challengeId:i.challenge_id,credential:d})}catch(i){if(L(i))return this._returnResult({data:null,error:i});throw i}}async registerPasskey(e){var r,n;Dt(this.experimental);try{if(!Ul())return this._returnResult({data:null,error:new Ht("Browser does not support WebAuthn",null)});const{data:s,error:i}=await this._startPasskeyRegistration();if(i||!s)return this._returnResult({data:null,error:i});const o=Fm(s.options),a=(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.signal)!==null&&n!==void 0?n:Ud.createNewAbortSignal(),{data:l,error:c}=await Iw({publicKey:o,signal:a});if(c||!l)return this._returnResult({data:null,error:c??new Ht("WebAuthn ceremony failed",null)});const u=Bm(l);return this._verifyPasskeyRegistration({challengeId:s.challenge_id,credential:u})}catch(s){if(L(s))return this._returnResult({data:null,error:s});throw s}}async _startPasskeyRegistration(){Dt(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new De});const{data:s,error:i}=await z(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:r.access_token,body:{}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:s,error:null})})}catch(e){if(L(e))return this._returnResult({data:null,error:e});throw e}}async _verifyPasskeyRegistration(e){Dt(this.experimental);try{return await this._useSession(async r=>{const{data:{session:n},error:s}=r;if(s)return this._returnResult({data:null,error:s});if(!n)return this._returnResult({data:null,error:new De});const{data:i,error:o}=await z(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:n.access_token,body:{challenge_id:e.challengeId,credential:e.credential}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(r){if(L(r))return this._returnResult({data:null,error:r});throw r}}async _startPasskeyAuthentication(e){var r;Dt(this.experimental);try{const{data:n,error:s}=await z(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.captchaToken}}});return s?this._returnResult({data:null,error:s}):this._returnResult({data:n,error:null})}catch(n){if(L(n))return this._returnResult({data:null,error:n});throw n}}async _verifyPasskeyAuthentication(e){Dt(this.experimental);try{const{data:r,error:n}=await z(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:e.challengeId,credential:e.credential},xform:kt});return n?this._returnResult({data:null,error:n}):(r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:r,error:null}))}catch(r){if(L(r))return this._returnResult({data:null,error:r});throw r}}async _listPasskeys(){Dt(this.experimental);try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)return this._returnResult({data:null,error:n});if(!r)return this._returnResult({data:null,error:new De});const{data:s,error:i}=await z(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:r.access_token,xform:o=>({data:o,error:null})});return i?this._returnResult({data:null,error:i}):this._returnResult({data:s,error:null})})}catch(e){if(L(e))return this._returnResult({data:null,error:e});throw e}}async _updatePasskey(e){Dt(this.experimental);try{return await this._useSession(async r=>{const{data:{session:n},error:s}=r;if(s)return this._returnResult({data:null,error:s});if(!n)return this._returnResult({data:null,error:new De});const{data:i,error:o}=await z(this.fetch,"PATCH",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:n.access_token,body:{friendly_name:e.friendlyName}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(r){if(L(r))return this._returnResult({data:null,error:r});throw r}}async _deletePasskey(e){Dt(this.experimental);try{return await this._useSession(async r=>{const{data:{session:n},error:s}=r;if(s)return this._returnResult({data:null,error:s});if(!n)return this._returnResult({data:null,error:new De});const{error:i}=await z(this.fetch,"DELETE",`${this.url}/passkeys/${e.passkeyId}`,{headers:this.headers,jwt:n.access_token,noResolveJson:!0});return i?this._returnResult({data:null,error:i}):this._returnResult({data:null,error:null})})}catch(r){if(L(r))return this._returnResult({data:null,error:r});throw r}}}zo.nextInstanceID={};const MR=zo,UR="2.105.1";let Zi="";typeof Deno<"u"?Zi="deno":typeof document<"u"?Zi="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Zi="react-native":Zi="node";const FR={"X-Client-Info":`supabase-js-${Zi}/${UR}`},zR={headers:FR},BR={schema:"public"},WR={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},VR={};function Bo(t){"@babel/helpers - typeof";return Bo=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},Bo(t)}function HR(t,e){if(Bo(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Bo(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function qR(t){var e=HR(t,"string");return Bo(e)=="symbol"?e:e+""}function KR(t,e,r){return(e=qR(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Hm(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Ce(t){for(var e=1;et?(...e)=>t(...e):(...e)=>fetch(...e),JR=()=>Headers,QR=(t,e,r)=>{const n=GR(r),s=JR();return async(i,o)=>{var a;const l=(a=await e())!==null&&a!==void 0?a:t;let c=new s(o==null?void 0:o.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${l}`),n(i,Ce(Ce({},o),{},{headers:c}))}};function ZR(t){return t.endsWith("/")?t:t+"/"}function YR(t,e){var r,n;const{db:s,auth:i,realtime:o,global:a}=t,{db:l,auth:c,realtime:u,global:d}=e,f={db:Ce(Ce({},l),s),auth:Ce(Ce({},c),i),realtime:Ce(Ce({},u),o),storage:{},global:Ce(Ce(Ce({},d),a),{},{headers:Ce(Ce({},(r=d==null?void 0:d.headers)!==null&&r!==void 0?r:{}),(n=a==null?void 0:a.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?f.accessToken=t.accessToken:delete f.accessToken,f}function XR(t){const e=t==null?void 0: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(ZR(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var ej=class extends MR{constructor(t){super(t)}},tj=class{constructor(t,e,r){var n,s;this.supabaseUrl=t,this.supabaseKey=e;const i=XR(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const o=`sb-${i.hostname.split(".")[0]}-auth-token`,a={db:BR,realtime:VR,auth:Ce(Ce({},WR),{},{storageKey:o}),global:zR},l=YR(r??{},a);if(this.storageKey=(n=l.auth.storageKey)!==null&&n!==void 0?n:"",this.headers=(s=l.global.headers)!==null&&s!==void 0?s:{},l.accessToken)this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(u,d)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(d)} 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=QR(e,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(Ce({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 RT(new URL("rest/v1",i).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit}),this.storage=new FN(this.storageUrl.href,this.headers,this.fetch,r==null?void 0:r.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new wT(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}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 _getAccessToken(){var t=this,e,r;if(t.accessToken)return await t.accessToken();const{data:n}=await t.auth.getSession();return(e=(r=n.session)===null||r===void 0?void 0:r.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:n,userStorage:s,storageKey:i,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u},d,f){const h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new ej({url:this.authUrl.href,headers:Ce(Ce({},h),d),storageKey:i,autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:n,userStorage:s,flowType:o,lock:a,debug:l,throwOnError:c,experimental:u,fetch:f,hasCustomAuthorizationHeader:Object.keys(this.headers).some(y=>y.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new cN(this.realtimeUrl.href,Ce(Ce({},t),{},{params:Ce(Ce({},{apikey:this.supabaseKey}),t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e==null?void 0:e.access_token)})}_handleTokenChanged(t,e,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&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 rj=(t,e,r)=>new tj(t,e,r);function nj(){if(typeof window<"u")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)<=18:!1}nj()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const sj="https://dcmewqhddvkfabzjieji.supabase.co",ij="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImRjbWV3cWhkZHZrZmFiemppZWppIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzczMjA2MDEsImV4cCI6MjA5Mjg5NjYwMX0.5xWhpqir0BJhMchiU05aqlAkP2NN3Mf5DWgeE_v_R3w",zl=rj(sj,ij,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),mf="/assets/charao-logo-Dw8gdLnD.png",$w=({onStart:t,cycleLabel:e,axesCount:r,personalizedFor:n})=>p.jsxs("div",{className:"min-h-screen flex flex-col bg-gradient-subtle",children:[p.jsxs("header",{className:"px-6 sm:px-10 pt-8 pb-4 flex items-center justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:"w-8 h-8 rounded-full bg-primary text-primary-foreground inline-flex items-center justify-center",children:p.jsx(ef,{className:"w-4 h-4",strokeWidth:1.5})}),p.jsx("span",{className:"editorial-label",children:"Pesquisa Semestral · NPS"})]}),p.jsx("div",{className:"flex items-center gap-6",children:p.jsxs(mi,{to:"/auth",className:"group inline-flex items-center gap-2 px-4 py-2 border border-border hover:border-primary text-primary hover:bg-primary hover:text-primary-foreground transition-all duration-300 rounded-sm",children:[p.jsx(tf,{className:"w-3.5 h-3.5",strokeWidth:1.5}),p.jsx("span",{className:"font-mono text-[11px] tracking-[0.15em] uppercase",children:"Login"})]})})]}),p.jsx("div",{className:"gold-rule mx-6 sm:mx-10"}),p.jsx("main",{className:"flex-1 flex items-center justify-center px-6 sm:px-10 py-12",children:p.jsxs("div",{className:"max-w-2xl w-full flex flex-col items-center text-center",children:[p.jsx("div",{className:"flex justify-center mb-5",children:p.jsx("img",{src:mf,alt:"Charão",className:"h-16 sm:h-20 w-auto"})}),p.jsxs("h1",{className:"font-serif text-5xl sm:text-6xl lg:text-7xl text-primary leading-[1.05] tracking-tight",children:["Evoluir é um caminho que trilhamos"," ",p.jsxs("em",{className:"text-accent not-italic font-medium relative",children:["juntos",p.jsx("span",{className:"absolute -bottom-1 left-0 right-0 h-px bg-accent/40"})]}),"."]}),n&&p.jsxs("p",{className:"mt-8 text-lg text-muted-foreground max-w-xl leading-relaxed",children:["Olá, ",p.jsx("span",{className:"text-primary font-medium",children:n.respondentName})," ","— preparamos esta avaliação exclusiva para a"," ",p.jsx("span",{className:"text-primary font-medium",children:n.companyName}),"."]}),p.jsxs("button",{onClick:t,className:"mt-12 group inline-flex items-center gap-3 px-8 py-4 bg-primary text-primary-foreground hover:bg-primary-glow transition-all duration-300 rounded-sm shadow-elegant",style:{transitionTimingFunction:"var(--transition-elegant)"},children:[p.jsx("span",{className:"font-mono text-sm tracking-[0.15em] uppercase",children:"Iniciar avaliação"}),p.jsx(E0,{className:"w-4 h-4 transition-transform group-hover:translate-x-1",strokeWidth:1.5})]})]})})]});var ue;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(const o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(ue||(ue={}));var qm;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(qm||(qm={}));const B=ue.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 B.undefined;case"string":return B.string;case"number":return Number.isNaN(t)?B.nan:B.number;case"boolean":return B.boolean;case"function":return B.function;case"bigint":return B.bigint;case"symbol":return B.symbol;case"object":return Array.isArray(t)?B.array:t===null?B.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?B.promise:typeof Map<"u"&&t instanceof Map?B.map:typeof Set<"u"&&t instanceof Set?B.set:typeof Date<"u"&&t instanceof Date?B.date:B.object;default:return B.unknown}},A=ue.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 $r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};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(i){return i.message},n={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let a=n,l=0;for(;lr.message){const r={},n=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}$r.create=t=>new $r(t);const Fd=(t,e)=>{let r;switch(t.code){case A.invalid_type:t.received===B.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case A.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ue.jsonStringifyReplacer)}`;break;case A.unrecognized_keys:r=`Unrecognized key(s) in object: ${ue.joinValues(t.keys,", ")}`;break;case A.invalid_union:r="Invalid input";break;case A.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ue.joinValues(t.options)}`;break;case A.invalid_enum_value:r=`Invalid enum value. Expected ${ue.joinValues(t.options)}, received '${t.received}'`;break;case A.invalid_arguments:r="Invalid function arguments";break;case A.invalid_return_type:r="Invalid function return type";break;case A.invalid_date:r="Invalid date";break;case A.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}"`:ue.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case A.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 A.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 A.custom:r="Invalid input";break;case A.invalid_intersection_types:r="Intersection results could not be merged";break;case A.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case A.not_finite:r="Number must be finite";break;default:r=e.defaultError,ue.assertNever(t)}return{message:r}};let oj=Fd;function aj(){return oj}const lj=t=>{const{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const l=n.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function D(t,e){const r=aj(),n=lj({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Fd?void 0:Fd].filter(s=>!!s)});t.common.issues.push(n)}class wt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const s of r){if(s.status==="aborted")return G;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const s of r){const i=await s.key,o=await s.value;n.push({key:i,value:o})}return wt.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const s of r){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return G;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}}const G=Object.freeze({status:"aborted"}),Yi=t=>({status:"dirty",value:t}),At=t=>({status:"valid",value:t}),Km=t=>t.status==="aborted",Gm=t=>t.status==="dirty",yi=t=>t.status==="valid",Bl=t=>typeof Promise<"u"&&t instanceof Promise;var W;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(W||(W={}));class jn{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}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 Jm=(t,e)=>{if(yi(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 $r(t.common.issues);return this._error=r,this._error}}};function re(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{const{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??n??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??r??a.defaultError}},description:s}}class le{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 wt,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(Bl(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 n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){const n={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xr(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Jm(n,s)}"~validate"(e){var n,s;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 i=this._parseSync({data:e,path:[],parent:r});return yi(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(s=(n=i==null?void 0:i.message)==null?void 0:n.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>yi(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xr(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Bl(s)?s:Promise.resolve(s));return Jm(n,i)}refine(e,r){const n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:A.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new xi({schema:this,typeName:J.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 kn.create(this,this._def)}nullable(){return bi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pr.create(this)}promise(){return ql.create(this,this._def)}or(e){return Vl.create([this,e],this._def)}and(e){return Hl.create(this,e,this._def)}transform(e){return new xi({...re(this._def),schema:this,typeName:J.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Bd({...re(this._def),innerType:this,defaultValue:r,typeName:J.ZodDefault})}brand(){return new Aj({typeName:J.ZodBranded,type:this,...re(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Wd({...re(this._def),innerType:this,catchValue:r,typeName:J.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return gf.create(this,e)}readonly(){return Vd.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const cj=/^c[^\s-]{8,}$/i,uj=/^[0-9a-z]+$/,dj=/^[0-9A-HJKMNP-TV-Z]{26}$/i,hj=/^[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,fj=/^[a-z0-9_-]{21}$/i,pj=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,mj=/^[-+]?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)?)??$/,gj=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,vj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let yu;const yj=/^(?:(?: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])$/,wj=/^(?:(?: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])$/,xj=/^(([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]))$/,bj=/^(([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])$/,_j=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,kj=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Dw="((\\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])))",Sj=new RegExp(`^${Dw}$`);function Mw(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 Ej(t){return new RegExp(`^${Mw(t)}$`)}function Cj(t){let e=`${Dw}T${Mw(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 Tj(t,e){return!!((e==="v4"||!e)&&yj.test(t)||(e==="v6"||!e)&&xj.test(t))}function Nj(t,e){if(!pj.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Rj(t,e){return!!((e==="v4"||!e)&&wj.test(t)||(e==="v6"||!e)&&bj.test(t))}class fn extends le{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==B.string){const i=this._getOrReturnCtx(e);return D(i,{code:A.invalid_type,expected:B.string,received:i.parsedType}),G}const n=new wt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.lengthi.value&&(s=this._getOrReturnCtx(e,s),D(s,{code:A.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.lengthe.test(s),{validation:r,code:A.invalid_string,...W.errToObj(n)})}_addCheck(e){return new fn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...W.errToObj(e)})}url(e){return this._addCheck({kind:"url",...W.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...W.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...W.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...W.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...W.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...W.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...W.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...W.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...W.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...W.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...W.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...W.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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...W.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...W.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...W.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...W.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...W.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...W.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...W.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...W.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...W.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...W.errToObj(r)})}nonempty(e){return this.min(1,W.errToObj(e))}trim(){return new fn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new fn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new fn({...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.valuenew fn({checks:[],typeName:J.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...re(t)});function jj(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}class Wo extends le{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)!==B.number){const i=this._getOrReturnCtx(e);return D(i,{code:A.invalid_type,expected:B.number,received:i.parsedType}),G}let n;const s=new wt;for(const i of this._def.checks)i.kind==="int"?ue.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),D(n,{code:A.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),D(n,{code:A.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?jj(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),D(n,{code:A.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),D(n,{code:A.not_finite,message:i.message}),s.dirty()):ue.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,W.toString(r))}gt(e,r){return this.setLimit("min",e,!1,W.toString(r))}lte(e,r){return this.setLimit("max",e,!0,W.toString(r))}lt(e,r){return this.setLimit("max",e,!1,W.toString(r))}setLimit(e,r,n,s){return new Wo({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:W.toString(s)}]})}_addCheck(e){return new Wo({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:W.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:W.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:W.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:W.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:W.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:W.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.valuee.kind==="int"||e.kind==="multipleOf"&&ue.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.valuenew Wo({checks:[],typeName:J.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...re(t)});class Vo extends le{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)!==B.bigint)return this._getInvalidInput(e);let n;const s=new wt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),D(n,{code:A.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),D(n,{code:A.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):ue.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return D(r,{code:A.invalid_type,expected:B.bigint,received:r.parsedType}),G}gte(e,r){return this.setLimit("min",e,!0,W.toString(r))}gt(e,r){return this.setLimit("min",e,!1,W.toString(r))}lte(e,r){return this.setLimit("max",e,!0,W.toString(r))}lt(e,r){return this.setLimit("max",e,!1,W.toString(r))}setLimit(e,r,n,s){return new Vo({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:W.toString(s)}]})}_addCheck(e){return new Vo({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:W.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:W.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.valuenew Vo({checks:[],typeName:J.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...re(t)});class Qm extends le{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==B.boolean){const n=this._getOrReturnCtx(e);return D(n,{code:A.invalid_type,expected:B.boolean,received:n.parsedType}),G}return At(e.data)}}Qm.create=t=>new Qm({typeName:J.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...re(t)});class Wl extends le{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==B.date){const i=this._getOrReturnCtx(e);return D(i,{code:A.invalid_type,expected:B.date,received:i.parsedType}),G}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return D(i,{code:A.invalid_date}),G}const n=new wt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()i.value&&(s=this._getOrReturnCtx(e,s),D(s,{code:A.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):ue.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Wl({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:W.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:W.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.valuenew Wl({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:J.ZodDate,...re(t)});class Zm extends le{_parse(e){if(this._getType(e)!==B.symbol){const n=this._getOrReturnCtx(e);return D(n,{code:A.invalid_type,expected:B.symbol,received:n.parsedType}),G}return At(e.data)}}Zm.create=t=>new Zm({typeName:J.ZodSymbol,...re(t)});class Ym extends le{_parse(e){if(this._getType(e)!==B.undefined){const n=this._getOrReturnCtx(e);return D(n,{code:A.invalid_type,expected:B.undefined,received:n.parsedType}),G}return At(e.data)}}Ym.create=t=>new Ym({typeName:J.ZodUndefined,...re(t)});class Xm extends le{_parse(e){if(this._getType(e)!==B.null){const n=this._getOrReturnCtx(e);return D(n,{code:A.invalid_type,expected:B.null,received:n.parsedType}),G}return At(e.data)}}Xm.create=t=>new Xm({typeName:J.ZodNull,...re(t)});class eg extends le{constructor(){super(...arguments),this._any=!0}_parse(e){return At(e.data)}}eg.create=t=>new eg({typeName:J.ZodAny,...re(t)});class tg extends le{constructor(){super(...arguments),this._unknown=!0}_parse(e){return At(e.data)}}tg.create=t=>new tg({typeName:J.ZodUnknown,...re(t)});class An extends le{_parse(e){const r=this._getOrReturnCtx(e);return D(r,{code:A.invalid_type,expected:B.never,received:r.parsedType}),G}}An.create=t=>new An({typeName:J.ZodNever,...re(t)});class rg extends le{_parse(e){if(this._getType(e)!==B.undefined){const n=this._getOrReturnCtx(e);return D(n,{code:A.invalid_type,expected:B.void,received:n.parsedType}),G}return At(e.data)}}rg.create=t=>new rg({typeName:J.ZodVoid,...re(t)});class pr extends le{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==B.array)return D(r,{code:A.invalid_type,expected:B.array,received:r.parsedType}),G;if(s.exactLength!==null){const o=r.data.length>s.exactLength.value,a=r.data.lengths.maxLength.value&&(D(r,{code:A.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>s.type._parseAsync(new jn(r,o,r.path,a)))).then(o=>wt.mergeArray(n,o));const i=[...r.data].map((o,a)=>s.type._parseSync(new jn(r,o,r.path,a)));return wt.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new pr({...this._def,minLength:{value:e,message:W.toString(r)}})}max(e,r){return new pr({...this._def,maxLength:{value:e,message:W.toString(r)}})}length(e,r){return new pr({...this._def,exactLength:{value:e,message:W.toString(r)}})}nonempty(e){return this.min(1,e)}}pr.create=(t,e)=>new pr({type:t,minLength:null,maxLength:null,exactLength:null,typeName:J.ZodArray,...re(e)});function js(t){if(t instanceof Te){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=kn.create(js(n))}return new Te({...t._def,shape:()=>e})}else return t instanceof pr?new pr({...t._def,type:js(t.element)}):t instanceof kn?kn.create(js(t.unwrap())):t instanceof bi?bi.create(js(t.unwrap())):t instanceof as?as.create(t.items.map(e=>js(e))):t}class Te extends le{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=ue.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==B.object){const c=this._getOrReturnCtx(e);return D(c,{code:A.invalid_type,expected:B.object,received:c.parsedType}),G}const{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof An&&this._def.unknownKeys==="strip"))for(const c in s.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=i[c],d=s.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new jn(s,d,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof An){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(c==="strict")a.length>0&&(D(s,{code:A.unrecognized_keys,keys:a}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=s.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new jn(s,d,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>wt.mergeObjectSync(n,c)):wt.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return W.errToObj,new Te({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,o;const s=((o=(i=this._def).errorMap)==null?void 0:o.call(i,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:W.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Te({...this._def,unknownKeys:"strip"})}passthrough(){return new Te({...this._def,unknownKeys:"passthrough"})}extend(e){return new Te({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Te({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:J.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Te({...this._def,catchall:e})}pick(e){const r={};for(const n of ue.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Te({...this._def,shape:()=>r})}omit(e){const r={};for(const n of ue.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new Te({...this._def,shape:()=>r})}deepPartial(){return js(this)}partial(e){const r={};for(const n of ue.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new Te({...this._def,shape:()=>r})}required(e){const r={};for(const n of ue.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof kn;)i=i._def.innerType;r[n]=i}return new Te({...this._def,shape:()=>r})}keyof(){return Uw(ue.objectKeys(this.shape))}}Te.create=(t,e)=>new Te({shape:()=>t,unknownKeys:"strip",catchall:An.create(),typeName:J.ZodObject,...re(e)});Te.strictCreate=(t,e)=>new Te({shape:()=>t,unknownKeys:"strict",catchall:An.create(),typeName:J.ZodObject,...re(e)});Te.lazycreate=(t,e)=>new Te({shape:t,unknownKeys:"strip",catchall:An.create(),typeName:J.ZodObject,...re(e)});class Vl extends le{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new $r(a.ctx.common.issues));return D(r,{code:A.invalid_union,unionErrors:o}),G}if(r.common.async)return Promise.all(n.map(async i=>{const o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const l of n){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"&&!i&&(i={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(l=>new $r(l));return D(r,{code:A.invalid_union,unionErrors:a}),G}}get options(){return this._def.options}}Vl.create=(t,e)=>new Vl({options:t,typeName:J.ZodUnion,...re(e)});function zd(t,e){const r=Xr(t),n=Xr(e);if(t===e)return{valid:!0,data:t};if(r===B.object&&n===B.object){const s=ue.objectKeys(e),i=ue.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(const a of i){const l=zd(t[a],e[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(r===B.array&&n===B.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i{if(Km(i)||Km(o))return G;const a=zd(i.value,o.value);return a.valid?((Gm(i)||Gm(o))&&r.dirty(),{status:r.value,value:a.data}):(D(n,{code:A.invalid_intersection_types}),G)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Hl.create=(t,e,r)=>new Hl({left:t,right:e,typeName:J.ZodIntersection,...re(r)});class as extends le{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.array)return D(n,{code:A.invalid_type,expected:B.array,received:n.parsedType}),G;if(n.data.lengththis._def.items.length&&(D(n,{code:A.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new jn(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>wt.mergeArray(r,o)):wt.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new as({...this._def,rest:e})}}as.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new as({items:t,typeName:J.ZodTuple,rest:null,...re(e)})};class ng extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.map)return D(n,{code:A.invalid_type,expected:B.map,received:n.parsedType}),G;const s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,l],c)=>({key:s._parse(new jn(n,a,n.path,[c,"key"])),value:i._parse(new jn(n,l,n.path,[c,"value"]))}));if(n.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return G;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),a.set(c.value,u.value)}return{status:r.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return G;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),a.set(c.value,u.value)}return{status:r.value,value:a}}}}ng.create=(t,e,r)=>new ng({valueType:e,keyType:t,typeName:J.ZodMap,...re(r)});class Ho extends le{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.set)return D(n,{code:A.invalid_type,expected:B.set,received:n.parsedType}),G;const s=this._def;s.minSize!==null&&n.data.sizes.maxSize.value&&(D(n,{code:A.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const i=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return G;u.status==="dirty"&&r.dirty(),c.add(u.value)}return{status:r.value,value:c}}const a=[...n.data.values()].map((l,c)=>i._parse(new jn(n,l,n.path,c)));return n.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,r){return new Ho({...this._def,minSize:{value:e,message:W.toString(r)}})}max(e,r){return new Ho({...this._def,maxSize:{value:e,message:W.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Ho.create=(t,e)=>new Ho({valueType:t,minSize:null,maxSize:null,typeName:J.ZodSet,...re(e)});class sg extends le{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})}}sg.create=(t,e)=>new sg({getter:t,typeName:J.ZodLazy,...re(e)});class ig extends le{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return D(r,{received:r.data,code:A.invalid_literal,expected:this._def.value}),G}return{status:"valid",value:e.data}}get value(){return this._def.value}}ig.create=(t,e)=>new ig({value:t,typeName:J.ZodLiteral,...re(e)});function Uw(t,e){return new wi({values:t,typeName:J.ZodEnum,...re(e)})}class wi extends le{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return D(r,{expected:ue.joinValues(n),received:r.parsedType,code:A.invalid_type}),G}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return D(r,{received:r.data,code:A.invalid_enum_value,options:n}),G}return At(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 wi.create(e,{...this._def,...r})}exclude(e,r=this._def){return wi.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}wi.create=Uw;class og extends le{_parse(e){const r=ue.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==B.string&&n.parsedType!==B.number){const s=ue.objectValues(r);return D(n,{expected:ue.joinValues(s),received:n.parsedType,code:A.invalid_type}),G}if(this._cache||(this._cache=new Set(ue.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=ue.objectValues(r);return D(n,{received:n.data,code:A.invalid_enum_value,options:s}),G}return At(e.data)}get enum(){return this._def.values}}og.create=(t,e)=>new og({values:t,typeName:J.ZodNativeEnum,...re(e)});class ql extends le{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==B.promise&&r.common.async===!1)return D(r,{code:A.invalid_type,expected:B.promise,received:r.parsedType}),G;const n=r.parsedType===B.promise?r.data:Promise.resolve(r.data);return At(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}ql.create=(t,e)=>new ql({type:t,typeName:J.ZodPromise,...re(e)});class xi extends le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===J.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{D(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return G;const l=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return l.status==="aborted"?G:l.status==="dirty"||r.value==="dirty"?Yi(l.value):l});{if(r.value==="aborted")return G;const a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?G:a.status==="dirty"||r.value==="dirty"?Yi(a.value):a}}if(s.type==="refinement"){const o=a=>{const l=s.refinement(a,i);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?G:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?G:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!yi(o))return G;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>yi(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:r.value,value:a})):G);ue.assertNever(s)}}xi.create=(t,e,r)=>new xi({schema:t,typeName:J.ZodEffects,effect:e,...re(r)});xi.createWithPreprocess=(t,e,r)=>new xi({schema:e,effect:{type:"preprocess",transform:t},typeName:J.ZodEffects,...re(r)});class kn extends le{_parse(e){return this._getType(e)===B.undefined?At(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}kn.create=(t,e)=>new kn({innerType:t,typeName:J.ZodOptional,...re(e)});class bi extends le{_parse(e){return this._getType(e)===B.null?At(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}bi.create=(t,e)=>new bi({innerType:t,typeName:J.ZodNullable,...re(e)});class Bd extends le{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===B.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Bd.create=(t,e)=>new Bd({innerType:t,typeName:J.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...re(e)});class Wd extends le{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Bl(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $r(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new $r(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Wd.create=(t,e)=>new Wd({innerType:t,typeName:J.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...re(e)});class ag extends le{_parse(e){if(this._getType(e)!==B.nan){const n=this._getOrReturnCtx(e);return D(n,{code:A.invalid_type,expected:B.nan,received:n.parsedType}),G}return{status:"valid",value:e.data}}}ag.create=t=>new ag({typeName:J.ZodNaN,...re(t)});class Aj extends le{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class gf extends le{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?G:i.status==="dirty"?(r.dirty(),Yi(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?G:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new gf({in:e,out:r,typeName:J.ZodPipeline})}}class Vd extends le{_parse(e){const r=this._def.innerType._parse(e),n=s=>(yi(s)&&(s.value=Object.freeze(s.value)),s);return Bl(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}Vd.create=(t,e)=>new Vd({innerType:t,typeName:J.ZodReadonly,...re(e)});Te.lazycreate;var J;(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"})(J||(J={}));const lg=fn.create;An.create;pr.create;const Pj=Te.create;Te.strictCreate;Vl.create;Hl.create;as.create;wi.create;ql.create;kn.create;bi.create;const Oj=Pj({respondentName:lg().trim().min(2,"Informe seu nome").max(120),companyName:lg().trim().min(2,"Informe a empresa").max(160)}),Ij=({axes:t,cycleLabel:e,onBack:r,onContinue:n})=>{const[s,i]=b.useState(""),[o,a]=b.useState(""),[l,c]=b.useState(new Set),u=f=>{c(h=>{const y=new Set(h);return y.has(f)?y.delete(f):y.add(f),y})},d=()=>{const f=Oj.safeParse({respondentName:s,companyName:o});if(!f.success){cr.error(f.error.issues[0].message);return}if(l.size===0){cr.error("Selecione ao menos um serviço utilizado");return}n({respondentName:f.data.respondentName,companyName:f.data.companyName,selectedAxisIds:[...l]})};return p.jsxs("div",{className:"min-h-screen bg-gradient-subtle pb-32",children:[p.jsx("header",{className:"sticky top-0 z-10 bg-background/85 backdrop-blur-md border-b border-border",children:p.jsxs("div",{className:"max-w-3xl mx-auto px-6 sm:px-10 py-5 flex items-center justify-between",children:[p.jsxs("button",{onClick:r,className:"editorial-label inline-flex items-center gap-2 hover:text-primary transition-colors",children:[p.jsx(Yh,{className:"w-3 h-3",strokeWidth:1.5}),"Voltar"]}),p.jsx("div",{className:"editorial-label tabular",children:"Etapa 01 / 02"})]})}),p.jsxs("main",{className:"max-w-3xl mx-auto px-6 sm:px-10 pt-12",children:[p.jsxs("p",{className:"editorial-label",children:["Identificação · ",e]}),p.jsxs("h2",{className:"font-serif text-4xl sm:text-5xl text-primary mt-3 leading-[1.1] tracking-tight",children:["Antes de começar, conte-nos quem você é e quais serviços"," ",p.jsx("em",{className:"text-accent not-italic font-medium",children:"utiliza"}),"."]}),p.jsx("p",{className:"mt-5 text-muted-foreground leading-relaxed max-w-2xl",children:"Avaliaremos apenas os serviços que você selecionar. Isso torna a pesquisa mais rápida e relevante."}),p.jsxs("section",{className:"mt-12 grid sm:grid-cols-2 gap-6",children:[p.jsxs("div",{children:[p.jsx("label",{className:"editorial-label block mb-2",children:"Nome do responsável"}),p.jsx("input",{value:s,onChange:f=>i(f.target.value.slice(0,120)),maxLength:120,className:"w-full bg-transparent border-0 border-b border-border focus:border-primary focus:outline-none focus:ring-0 py-2 text-base text-primary font-serif placeholder:text-muted-foreground/40 placeholder:font-sans placeholder:text-sm",placeholder:"Helena Castro Albuquerque"})]}),p.jsxs("div",{children:[p.jsx("label",{className:"editorial-label block mb-2",children:"Nome da empresa"}),p.jsx("input",{value:o,onChange:f=>a(f.target.value.slice(0,160)),maxLength:160,className:"w-full bg-transparent border-0 border-b border-border focus:border-primary focus:outline-none focus:ring-0 py-2 text-base text-primary font-serif placeholder:text-muted-foreground/40 placeholder:font-sans placeholder:text-sm",placeholder:"Albuquerque Holdings Ltda."})]})]}),p.jsxs("div",{className:"mt-16 mb-8 flex items-baseline justify-between",children:[p.jsx("h3",{className:"font-serif text-2xl text-primary",children:"Serviços utilizados"}),p.jsxs("span",{className:"editorial-label tabular",children:[String(l.size).padStart(2,"0")," selecionado",l.size===1?"":"s"]})]}),p.jsx("div",{className:"gold-rule mb-8"}),p.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:t.map((f,h)=>{const y=l.has(f.id);return p.jsx("button",{type:"button",onClick:()=>u(f.id),"data-selected":y,className:"group text-left p-5 border border-border rounded-sm bg-card hover:border-primary/60 transition-all duration-200 data-[selected=true]:border-primary data-[selected=true]:bg-primary/[0.03] data-[selected=true]:shadow-card",children:p.jsxs("div",{className:"flex items-start gap-4",children:[p.jsx("span",{className:"mt-0.5 w-5 h-5 shrink-0 rounded-sm border border-border inline-flex items-center justify-center transition-colors group-data-[selected=true]:bg-primary group-data-[selected=true]:border-primary",children:y&&p.jsx(ef,{className:"w-3.5 h-3.5 text-primary-foreground",strokeWidth:2})}),p.jsx("div",{className:"flex-1",children:p.jsxs("div",{className:"flex items-baseline gap-2",children:[p.jsx("span",{className:"font-mono text-[10px] text-accent tabular",children:String(h+1).padStart(2,"0")}),p.jsx("span",{className:"font-serif text-lg text-primary leading-tight",children:f.name})]})})]})},f.id)})})]}),p.jsx("div",{className:"fixed bottom-0 left-0 right-0 bg-background/90 backdrop-blur-md border-t border-border",children:p.jsxs("div",{className:"max-w-3xl mx-auto px-6 sm:px-10 py-4 flex items-center justify-between gap-4",children:[p.jsxs("span",{className:"editorial-label tabular",children:[String(l.size).padStart(2,"0")," serviço",l.size===1?"":"s"," a avaliar"]}),p.jsxs("button",{onClick:d,className:"group inline-flex items-center gap-3 px-6 sm:px-8 py-3 bg-primary text-primary-foreground hover:bg-primary-glow rounded-sm transition-all duration-300 shadow-elegant",style:{transitionTimingFunction:"var(--transition-elegant)"},children:[p.jsx("span",{className:"font-mono text-xs sm:text-sm tracking-[0.15em] uppercase",children:"Continuar"}),p.jsx(E0,{className:"w-4 h-4 transition-transform group-hover:translate-x-1",strokeWidth:1.5})]})]})})]})},Lj=({value:t,onChange:e,name:r})=>p.jsxs("div",{className:"space-y-3",children:[p.jsx("div",{className:"flex flex-wrap gap-1.5 sm:gap-2",children:Array.from({length:11}).map((n,s)=>p.jsx("button",{type:"button",className:"score-pill","data-selected":t===s,onClick:()=>e(s),"aria-label":`Nota ${s} para ${r}`,children:s},s))}),p.jsxs("div",{className:"flex justify-between editorial-label",children:[p.jsx("span",{children:"Pouco provável"}),p.jsx("span",{children:"Muito provável"})]})]}),$j=({index:t,name:e,score:r,justification:n,onScoreChange:s,onJustificationChange:i})=>{const o=String(t).padStart(2,"0");return p.jsxs("article",{className:"border-t border-border pt-8 first:border-t-0 first:pt-0",children:[p.jsxs("header",{className:"flex items-baseline gap-4 mb-5",children:[p.jsx("span",{className:"font-mono text-xs text-accent tabular",children:o}),p.jsxs("div",{className:"flex-1",children:[p.jsx("h3",{className:"font-serif text-2xl sm:text-3xl text-primary leading-tight",children:e}),p.jsx("p",{className:"editorial-label mt-1",children:"Escala 0 — 10"})]})]}),p.jsx(Lj,{value:r,onChange:s,name:e}),p.jsxs("div",{className:"mt-5",children:[p.jsxs("label",{className:"editorial-label block mb-2",children:["Justifique ",p.jsx("span",{className:"normal-case tracking-normal text-muted-foreground/70",children:"(não obrigatório)"})]}),p.jsx("textarea",{value:n,onChange:a=>i(a.target.value.slice(0,500)),rows:2,maxLength:500,className:"w-full bg-transparent border-0 border-b border-border focus:border-primary focus:outline-none focus:ring-0 py-2 text-sm resize-none transition-colors placeholder:text-muted-foreground/50",placeholder:"Conte-nos mais sobre sua experiência…"})]})]})},Fw=({axes:t,respondentName:e,companyName:r,cycleLabel:n,clientId:s,onBack:i,onSubmitted:o})=>{const[a,l]=b.useState(Object.fromEntries(t.map(m=>[m.id,{score:null,justification:""}]))),[c,u]=b.useState(!1),d=Object.values(a).filter(m=>m.score!==null).length,f=t.length,h=d===f&&!c,y=(m,g)=>l(v=>({...v,[m]:{...v[m],score:g}})),w=(m,g)=>l(v=>({...v,[m]:{...v[m],justification:g}})),x=async()=>{if(d({axis_id:v.id,axis_name:v.name,score:a[v.id].score,justification:a[v.id].justification.trim()||null}))},{error:g}=await zl.from("survey_responses").insert(m);if(u(!1),g){cr.error("Erro ao enviar avaliação. Tente novamente.");return}o()};return p.jsxs("div",{className:"min-h-screen bg-gradient-subtle pb-32",children:[p.jsxs("header",{className:"sticky top-0 z-10 bg-background/85 backdrop-blur-md border-b border-border",children:[p.jsxs("div",{className:"max-w-3xl mx-auto px-6 sm:px-10 py-5 flex items-center justify-between",children:[p.jsxs("button",{onClick:i,className:"editorial-label inline-flex items-center gap-2 hover:text-primary transition-colors",children:[p.jsx(Yh,{className:"w-3 h-3",strokeWidth:1.5}),"Voltar"]}),p.jsxs("div",{className:"editorial-label tabular",children:[String(d).padStart(2,"0")," / ",String(f).padStart(2,"0")]})]}),p.jsx("div",{className:"h-px bg-border",children:p.jsx("div",{className:"h-full bg-primary transition-all duration-500",style:{width:`${d/f*100}%`}})})]}),p.jsxs("main",{className:"max-w-3xl mx-auto px-6 sm:px-10 pt-12",children:[p.jsxs("div",{children:[p.jsxs("p",{className:"editorial-label",children:["Avaliação · ",n," · ",r]}),p.jsx("h2",{className:"font-serif text-4xl sm:text-5xl text-primary mt-3 leading-[1.1] tracking-tight",children:"De 0 a 10, o quanto você recomendaria nossas entregas?"})]}),p.jsxs("div",{className:"mt-12 mb-8 flex items-baseline justify-between",children:[p.jsx("h3",{className:"font-serif text-2xl text-primary",children:"Eixos de Avaliação"}),p.jsxs("span",{className:"editorial-label",children:[String(f).padStart(2,"0")," itens"]})]}),p.jsx("div",{className:"gold-rule mb-10"}),p.jsx("div",{className:"space-y-10",children:t.map((m,g)=>p.jsx($j,{index:g+1,name:m.name,score:a[m.id].score,justification:a[m.id].justification,onScoreChange:v=>y(m.id,v),onJustificationChange:v=>w(m.id,v)},m.id))})]}),p.jsx("div",{className:"fixed bottom-0 left-0 right-0 bg-background/90 backdrop-blur-md border-t border-border",children:p.jsxs("div",{className:"max-w-3xl mx-auto px-6 sm:px-10 py-4 flex items-center justify-between gap-4",children:[p.jsxs("span",{className:"editorial-label tabular",children:[String(d).padStart(2,"0")," / ",String(f).padStart(2,"0")," preenchidos"]}),p.jsx("button",{onClick:x,disabled:!h,className:"inline-flex items-center gap-3 px-6 sm:px-8 py-3 bg-primary text-primary-foreground hover:bg-primary-glow rounded-sm transition-all duration-300 disabled:opacity-40 disabled:cursor-not-allowed shadow-elegant",style:{transitionTimingFunction:"var(--transition-elegant)"},children:p.jsx("span",{className:"font-mono text-xs sm:text-sm tracking-[0.15em] uppercase",children:c?"Enviando…":"Enviar avaliação"})})]})})]})},zw=({onRestart:t})=>p.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-subtle px-6",children:p.jsxs("div",{className:"max-w-xl text-center",children:[p.jsx("span",{className:"w-16 h-16 rounded-full bg-primary text-primary-foreground inline-flex items-center justify-center mb-8",children:p.jsx(ef,{className:"w-8 h-8",strokeWidth:1.5})}),p.jsx("p",{className:"editorial-label mb-4",children:"Avaliação registrada"}),p.jsxs("h1",{className:"font-serif text-5xl sm:text-6xl text-primary leading-[1.05] tracking-tight",children:["Obrigado pela sua"," ",p.jsx("em",{className:"text-accent not-italic font-medium",children:"contribuição"}),"."]}),p.jsx("p",{className:"mt-6 text-muted-foreground text-lg leading-relaxed",children:"Sua avaliação foi recebida com sucesso. Cada resposta orienta nossas próximas entregas e fortalece a parceria entre nossas equipes."})]})}),Dj=()=>{const t=new Date;return`Ciclo ${t.getMonth()<6?"01":"02"} · ${t.getFullYear()}`},Mj=()=>{const[t,e]=b.useState("welcome"),[r,n]=b.useState([]),[s,i]=b.useState(!0),o=Dj(),[a,l]=b.useState(""),[c,u]=b.useState(""),[d,f]=b.useState([]);if(b.useEffect(()=>{(async()=>{const{data:h}=await zl.from("axes").select("id, name").eq("is_active",!0).order("display_order",{ascending:!0});n(h??[]),i(!1)})()},[]),s)return p.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-subtle",children:p.jsx("p",{className:"editorial-label",children:"Carregando…"})});if(t==="welcome")return p.jsx($w,{onStart:()=>e("services"),cycleLabel:o,axesCount:r.length});if(t==="services")return p.jsx(Ij,{axes:r,cycleLabel:o,onBack:()=>e("welcome"),onContinue:({respondentName:h,companyName:y,selectedAxisIds:w})=>{l(h),u(y),f(w),e("form")}});if(t==="form"){const h=d.map(y=>r.find(w=>w.id===y)).filter(y=>!!y);return p.jsx(Fw,{axes:h,respondentName:a,companyName:c,cycleLabel:o,onBack:()=>e("services"),onSubmitted:()=>e("done")})}return p.jsx(zw,{onRestart:()=>{l(""),u(""),f([]),e("welcome")}})},Uj=()=>{const t=new Date;return`Ciclo ${t.getMonth()<6?"01":"02"} · ${t.getFullYear()}`},Fj=()=>{const{token:t}=Sk(),[e,r]=b.useState("welcome"),[n,s]=b.useState(null),[i,o]=b.useState([]),[a,l]=b.useState(!0),[c,u]=b.useState(null),d=Uj();if(b.useEffect(()=>{(async()=>{if(!t){u("Link inválido"),l(!1);return}const[y,w]=await Promise.all([zl.from("clients").select("id, respondent_name, company_name, contracted_axis_ids").eq("token",t).eq("is_active",!0).maybeSingle(),zl.from("axes").select("id, name").eq("is_active",!0).order("display_order",{ascending:!0})]);if(y.error||!y.data){u("Link não encontrado ou desativado."),l(!1);return}s(y.data),o(w.data??[]),l(!1)})()},[t]),a)return p.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-subtle",children:p.jsx("p",{className:"editorial-label",children:"Carregando…"})});if(c||!n)return p.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-gradient-subtle px-6 text-center",children:[p.jsx("p",{className:"editorial-label mb-4",children:"Acesso indisponível"}),p.jsx("h1",{className:"font-serif text-3xl text-primary mb-3",children:c??"Link inválido"}),p.jsx("p",{className:"text-muted-foreground max-w-md mb-8",children:"Verifique se o link está correto ou solicite um novo à equipe Charão."}),p.jsx(mi,{to:"/",className:"font-mono text-xs tracking-[0.15em] uppercase text-primary hover:text-accent transition-colors",children:"Ir para a página inicial"})]});const f=n.contracted_axis_ids.map(y=>i.find(w=>w.id===y)).filter(y=>!!y),h=f.length>0?f:i;return e==="welcome"?p.jsx($w,{onStart:()=>r("form"),cycleLabel:d,axesCount:h.length,personalizedFor:{respondentName:n.respondent_name,companyName:n.company_name}}):e==="form"?p.jsx(Fw,{axes:h,respondentName:n.respondent_name,companyName:n.company_name,cycleLabel:d,clientId:n.id,onBack:()=>r("welcome"),onSubmitted:()=>r("done")}):p.jsx(zw,{onRestart:()=>r("welcome")})},zj=()=>{const t=ds();return b.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),p.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted",children:p.jsxs("div",{className:"text-center",children:[p.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),p.jsx("p",{className:"mb-4 text-xl text-muted-foreground",children:"Oops! Page not found"}),p.jsx("a",{href:"/",className:"text-primary underline hover:text-primary/90",children:"Return to Home"})]})})},Bj=()=>p.jsxs("div",{className:"min-h-screen flex flex-col bg-gradient-subtle",children:[p.jsxs("header",{className:"px-6 sm:px-10 pt-8 pb-4 flex items-center justify-between",children:[p.jsx(mi,{to:"/",children:p.jsx("img",{src:mf,alt:"Charão",className:"h-14 sm:h-16 w-auto"})}),p.jsxs(mi,{to:"/",className:"editorial-label inline-flex items-center gap-2 hover:text-primary transition-colors",children:[p.jsx(Yh,{className:"w-3 h-3"})," Voltar"]})]}),p.jsx("div",{className:"gold-rule mx-6 sm:mx-10"}),p.jsx("main",{className:"flex-1 flex items-center justify-center px-6 py-12",children:p.jsxs("div",{className:"w-full max-w-md text-center",children:[p.jsx("span",{className:"w-14 h-14 rounded-full bg-border text-muted-foreground inline-flex items-center justify-center mb-6",children:p.jsx(tf,{className:"w-6 h-6",strokeWidth:1.5})}),p.jsxs("h1",{className:"font-serif text-4xl sm:text-5xl text-primary leading-[1.05] tracking-tight mb-4",children:["Acesso ",p.jsx("em",{className:"text-accent not-italic font-medium",children:"bloqueado"})]}),p.jsx("p",{className:"text-muted-foreground text-lg",children:"O acesso ao painel administrativo está temporariamente indisponível."})]})})]}),Hd="fake_auth_email",Bw=b.createContext(void 0),Wj=()=>{const t=localStorage.getItem(Hd);return t?{id:"local",email:t}:null},Vj=({children:t})=>{const[e,r]=b.useState(Wj),n=i=>{localStorage.setItem(Hd,i),r({id:"local",email:i})},s=async()=>{localStorage.removeItem(Hd),r(null)};return p.jsx(Bw.Provider,{value:{user:e,session:null,isAdmin:!0,loading:!1,signIn:n,signOut:s},children:t})},Hj=()=>{const t=b.useContext(Bw);if(!t)throw new Error("useAuth must be used within AuthProvider");return t},qj=[{to:"/admin",end:!0,label:"Dashboard NPS",icon:US},{to:"/admin/respostas",label:"Respostas",icon:C0},{to:"/admin/respondentes",label:"Cadastro",icon:KS},{to:"/admin/servicos",label:"Serviços",icon:Xh}],Nc=({children:t})=>{const{user:e,loading:r,signOut:n}=Hj(),s=qh();return r?p.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-subtle",children:p.jsx("p",{className:"editorial-label",children:"Carregando…"})}):e?p.jsxs("div",{className:"min-h-screen flex bg-gradient-subtle",children:[p.jsxs("aside",{className:"w-72 border-r border-border bg-card/40 flex flex-col",children:[p.jsx("div",{className:"px-6 py-6 border-b border-border flex justify-center",children:p.jsx(mi,{to:"/",children:p.jsx("img",{src:mf,alt:"Charão",className:"h-14 w-auto"})})}),p.jsx("div",{className:"px-6 pt-6 pb-3",children:p.jsx("span",{className:"editorial-label",children:"Navegação"})}),p.jsx("nav",{className:"flex-1 px-3 space-y-1",children:qj.map(({to:i,end:o,label:a,icon:l})=>p.jsxs(Zk,{to:i,end:o,className:({isActive:c})=>`flex items-center gap-3 px-4 py-3 rounded-sm text-sm transition-colors ${c?"bg-primary text-primary-foreground":"text-foreground/70 hover:text-primary hover:bg-secondary"}`,children:[p.jsx(l,{className:"w-4 h-4",strokeWidth:1.5}),p.jsx("span",{children:a})]},i))}),p.jsxs("div",{className:"border-t border-border p-6 space-y-3",children:[p.jsxs("div",{children:[p.jsx("p",{className:"font-medium text-sm text-primary",children:"Admin"}),p.jsx("p",{className:"text-xs text-muted-foreground truncate",children:e.email})]}),p.jsxs("button",{onClick:async()=>{await n(),s("/")},className:"w-full inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-destructive transition-colors",children:[p.jsx(FS,{className:"w-4 h-4",strokeWidth:1.5})," Sair"]})]})]}),p.jsx("main",{className:"flex-1 overflow-auto",children:t})]}):p.jsx(Mk,{to:"/auth",replace:!0})},vf=t=>{const e=t.filter(r=>typeof r.score=="number");return e.length?e.reduce((r,n)=>r+n.score,0)/e.length:null},Kl=t=>t==null?null:t>8?"promoter":t>=6?"passive":"detractor",qd=["Contábil","Fiscal","Tributário","Depart. Pessoal","RH"],ls="custom_services",Ww="service_dept_overrides",tl=[{name:"Assessoria tributária",department:"Tributário"},{name:"Assessoria contábil",department:"Contábil"},{name:"Gestão contábil",department:"Contábil"},{name:"Gestão fiscal",department:"Fiscal"},{name:"Assessoria de DP",department:"Depart. Pessoal"},{name:"Gestão de DP",department:"Depart. Pessoal"},{name:"Mentoria da reforma tributária",department:"Tributário"}],Vw=()=>{try{const t=localStorage.getItem(Ww);return t?JSON.parse(t):{}}catch{return{}}},mr=()=>{try{const t=localStorage.getItem(ls),e=t?JSON.parse(t):[],r=new Set(tl.map(o=>o.name.toLowerCase())),n=e.filter(o=>!r.has(o.name.toLowerCase())),s=Vw(),i=o=>o.name in s?{...o,department:s[o.name]}:o;return[...tl.map(i),...n.map(i)]}catch{return[...tl]}},Kd=t=>{var e;return((e=mr().find(r=>r.name===t))==null?void 0:e.department)??null},Kj=(t,e)=>{try{const r=localStorage.getItem(ls),n=r?JSON.parse(r):[],s=n.findIndex(i=>i.name===t);if(s>=0)n[s].department=e,localStorage.setItem(ls,JSON.stringify(n));else{const i=Vw();i[t]=e,localStorage.setItem(Ww,JSON.stringify(i))}}catch{}return mr()},Gj=(t,e)=>{const r=t.trim();if(!r)return mr();const n=mr();if(n.some(s=>s.name.toLowerCase()===r.toLowerCase()))return n;try{const s=localStorage.getItem(ls),i=s?JSON.parse(s):[];i.push({name:r,department:e||null}),localStorage.setItem(ls,JSON.stringify(i))}catch{}return mr()},Jj=t=>{try{const e=localStorage.getItem(ls),n=(e?JSON.parse(e):[]).filter(s=>s.name!==t);localStorage.setItem(ls,JSON.stringify(n))}catch{}return mr()},Qj=[{axis_id:"ax1",axis_name:"Qualidade do Serviço"},{axis_id:"ax2",axis_name:"Comunicação"},{axis_id:"ax3",axis_name:"Pontualidade"},{axis_id:"ax4",axis_name:"Suporte"},{axis_id:"ax5",axis_name:"Satisfação Geral"}],Vi=(t,e)=>Qj.map((r,n)=>({...r,score:t[n],justification:e[n]})),qo=[{id:"c1",respondent_name:"Carlos Oliveira",company_name:"TechBrasil LTDA",respondent_email:"carlos@techbrasil.com",department:"Contábil",service_type:"Gestão contábil",manager:"Rebeca",token:"tok1"},{id:"c2",respondent_name:"Maria Santos",company_name:"Construções Nordeste",respondent_email:"maria@constrnordeste.com",department:"Fiscal",service_type:"Gestão fiscal",manager:null,token:"tok2"},{id:"c3",respondent_name:"João Pereira",company_name:"Farmácia São Lucas",respondent_email:"joao@saolucas.com",department:"Depart. Pessoal",service_type:"Assessoria de DP",manager:null,token:"tok3"},{id:"c4",respondent_name:"Ana Lima",company_name:"Indústrias Coelho S.A.",respondent_email:"ana@indcoelho.com",department:"Tributário",service_type:"Mentoria da reforma tributária",manager:null,token:"tok4"},{id:"c5",respondent_name:"Pedro Costa",company_name:"Comércio Alves ME",respondent_email:"pedro@comercioalves.com",department:"RH",service_type:"Assessoria contábil",manager:null,token:"tok5"}],Gl=[{id:"r1",respondent_name:"Carlos Oliveira",company_name:"TechBrasil LTDA",respondent_email:"carlos@techbrasil.com",client_id:"c1",cycle_label:"Q1 2026",created_at:"2026-03-15T10:00:00Z",ratings:Vi([9,8,10,9,9],["Excelente atendimento","Sempre disponíveis",null,"Resolvem rápido","Muito satisfeito"])},{id:"r2",respondent_name:"Maria Santos",company_name:"Construções Nordeste",respondent_email:"maria@constrnordeste.com",client_id:"c2",cycle_label:"Q1 2026",created_at:"2026-03-18T14:30:00Z",ratings:Vi([5,6,5,7,6],["Poderia melhorar",null,"Atrasos recorrentes",null,"Abaixo do esperado"])},{id:"r3",respondent_name:"João Pereira",company_name:"Farmácia São Lucas",respondent_email:"joao@saolucas.com",client_id:"c3",cycle_label:"Q1 2026",created_at:"2026-03-22T09:15:00Z",ratings:Vi([8,7,8,8,7],[null,"Comunicação boa",null,null,"Satisfatório"])},{id:"r4",respondent_name:"Ana Lima",company_name:"Indústrias Coelho S.A.",respondent_email:"ana@indcoelho.com",client_id:"c4",cycle_label:"Q1 2026",created_at:"2026-04-01T11:45:00Z",ratings:Vi([10,10,9,10,10],["Impecável","Comunicação exemplar",null,"Suporte de altíssimo nível","Superou expectativas"])},{id:"r5",respondent_name:"Pedro Costa",company_name:"Comércio Alves ME",respondent_email:"pedro@comercioalves.com",client_id:"c5",cycle_label:"Q1 2026",created_at:"2026-04-10T16:00:00Z",ratings:Vi([6,5,7,6,5],[null,"Dificuldade de contato",null,"Suporte lento",null])}],Zj=["Rebeca","Andressa"],Yj=()=>{const[t]=b.useState(Gl),[e]=b.useState(qo),[r]=b.useState(!1),n=b.useMemo(()=>{const s=new Map(e.map(m=>[m.id,m.department])),i=new Map(e.map(m=>[m.id,m.service_type])),o=new Map(e.map(m=>[m.id,m.manager])),a=t.map(m=>{const g=vf(m.ratings??[]);return{avg:g,bucket:Kl(g),department:m.client_id?s.get(m.client_id)??null:null,serviceType:m.client_id?i.get(m.client_id)??null:null,manager:m.client_id?o.get(m.client_id)??null:null}}),l=a.length,c=a.filter(m=>m.bucket==="promoter").length,u=a.filter(m=>m.bucket==="detractor").length,d=a.filter(m=>m.bucket==="passive").length,f=qd.map(m=>{const g=a.filter(v=>v.department===m);return{department:m,total:g.length,promoters:g.filter(v=>v.bucket==="promoter").length,detractors:g.filter(v=>v.bucket==="detractor").length}}),y=mr().map(m=>{const g=a.filter(v=>v.serviceType===m.name);return{service:m.name,total:g.length,promoters:g.filter(v=>v.bucket==="promoter").length,detractors:g.filter(v=>v.bucket==="detractor").length}}).filter(m=>m.total>0),w=Zj.map(m=>{const g=a.filter(v=>v.department==="Contábil"&&v.manager===m);return{manager:m,total:g.length,promoters:g.filter(v=>v.bucket==="promoter").length,detractors:g.filter(v=>v.bucket==="detractor").length,passives:g.filter(v=>v.bucket==="passive").length,avgScore:g.length?g.reduce((v,_)=>v+(_.avg??0),0)/g.length:null}}),x=a.filter(m=>!m.department).length;return{total:l,promoters:c,detractors:u,passives:d,byDept:f,byService:y,byManager:w,unassigned:x}},[t,e]);return p.jsx(Nc,{children:p.jsxs("div",{className:"px-10 py-12 max-w-6xl",children:[p.jsx("p",{className:"editorial-label",children:"Visão geral · NPS"}),p.jsxs("h1",{className:"font-serif text-5xl text-primary mt-3 leading-[1.05] tracking-tight",children:["Dashboard ",p.jsx("em",{className:"text-accent not-italic font-medium",children:"geral"})]}),r?p.jsx("p",{className:"editorial-label mt-12",children:"Carregando…"}):p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"mt-12 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5",children:[p.jsx(Ma,{label:"Total de respostas",value:n.total,icon:p.jsx(C0,{className:"w-4 h-4"})}),p.jsx(Ma,{label:"Positivas (> 8)",value:n.promoters,tone:"success",icon:p.jsx(HS,{className:"w-4 h-4"})}),p.jsx(Ma,{label:"Neutras (6 – 8)",value:n.passives,tone:"muted"}),p.jsx(Ma,{label:"Negativas (< 6)",value:n.detractors,tone:"destructive",icon:p.jsx(VS,{className:"w-4 h-4"})})]}),p.jsxs("div",{className:"mt-16",children:[p.jsxs("div",{className:"flex items-baseline justify-between",children:[p.jsxs("h2",{className:"font-serif text-2xl text-primary inline-flex items-center gap-3",children:[p.jsx(LS,{className:"w-5 h-5",strokeWidth:1.5})," Por departamento"]}),n.unassigned>0&&p.jsxs("span",{className:"editorial-label",children:[n.unassigned," sem direcionamento"]})]}),p.jsx("div",{className:"gold-rule mt-3 mb-6"}),p.jsx("div",{className:"bg-card border border-border rounded-sm overflow-hidden",children:p.jsxs("table",{className:"w-full",children:[p.jsx("thead",{className:"bg-secondary/40",children:p.jsxs("tr",{className:"text-left",children:[p.jsx(er,{children:"Departamento"}),p.jsx(er,{align:"right",children:"Respostas"}),p.jsx(er,{align:"right",children:"Positivas"}),p.jsx(er,{align:"right",children:"Negativas"}),p.jsx(er,{align:"right",children:"% Positivas"})]})}),p.jsx("tbody",{children:n.byDept.map(s=>{const i=s.total?Math.round(s.promoters/s.total*100):0;return p.jsxs("tr",{className:"border-t border-border",children:[p.jsx(tr,{className:"font-medium text-primary",children:s.department}),p.jsx(tr,{align:"right",className:"tabular",children:s.total}),p.jsx(tr,{align:"right",className:"tabular text-[hsl(var(--success))]",children:s.promoters}),p.jsx(tr,{align:"right",className:"tabular text-destructive",children:s.detractors}),p.jsxs(tr,{align:"right",className:"tabular font-mono",children:[i,"%"]})]},s.department)})})]})})]}),p.jsxs("div",{className:"mt-16",children:[p.jsxs("h2",{className:"font-serif text-2xl text-primary inline-flex items-center gap-3",children:[p.jsx(MS,{className:"w-5 h-5",strokeWidth:1.5})," Por serviço"]}),p.jsx("div",{className:"gold-rule mt-3 mb-6"}),n.byService.length===0?p.jsx("p",{className:"editorial-label",children:"Nenhuma resposta com serviço atribuído ainda."}):p.jsx("div",{className:"bg-card border border-border rounded-sm overflow-hidden",children:p.jsxs("table",{className:"w-full",children:[p.jsx("thead",{className:"bg-secondary/40",children:p.jsxs("tr",{className:"text-left",children:[p.jsx(er,{children:"Serviço"}),p.jsx(er,{align:"right",children:"Respostas"}),p.jsx(er,{align:"right",children:"Positivas"}),p.jsx(er,{align:"right",children:"Negativas"}),p.jsx(er,{align:"right",children:"% Positivas"})]})}),p.jsx("tbody",{children:n.byService.map(s=>{const i=s.total?Math.round(s.promoters/s.total*100):0;return p.jsxs("tr",{className:"border-t border-border",children:[p.jsx(tr,{className:"font-medium text-primary",children:s.service}),p.jsx(tr,{align:"right",className:"tabular",children:s.total}),p.jsx(tr,{align:"right",className:"tabular text-[hsl(var(--success))]",children:s.promoters}),p.jsx(tr,{align:"right",className:"tabular text-destructive",children:s.detractors}),p.jsxs(tr,{align:"right",className:"tabular font-mono",children:[i,"%"]})]},s.service)})})]})})]}),p.jsxs("div",{className:"mt-16",children:[p.jsxs("h2",{className:"font-serif text-2xl text-primary inline-flex items-center gap-3",children:[p.jsx(qS,{className:"w-5 h-5",strokeWidth:1.5})," Gestão Contábil · por gestor"]}),p.jsx("div",{className:"gold-rule mt-3 mb-6"}),p.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-5",children:n.byManager.map(s=>{const i=s.total?Math.round(s.promoters/s.total*100):null;return p.jsxs("div",{className:"bg-card border border-border rounded-sm p-6",children:[p.jsx("p",{className:"editorial-label mb-1",children:"Gestor"}),p.jsx("h3",{className:"font-serif text-2xl text-primary",children:s.manager}),p.jsx("div",{className:"gold-rule mt-4 mb-4"}),p.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[p.jsx(Es,{label:"Respostas",value:String(s.total)}),p.jsx(Es,{label:"Média geral",value:s.avgScore!==null?s.avgScore.toFixed(1):"—",tone:s.avgScore===null?"muted":s.avgScore>8?"success":s.avgScore>=6?"muted":"destructive"}),p.jsx(Es,{label:"Positivas",value:String(s.promoters),tone:"success"}),p.jsx(Es,{label:"Neutras",value:String(s.passives),tone:"muted"}),p.jsx(Es,{label:"Negativas",value:String(s.detractors),tone:"destructive"}),p.jsx(Es,{label:"% Positivas",value:i!==null?`${i}%`:"—",tone:i!==null&&i>=70?"success":i!==null&&i<40?"destructive":"muted"})]})]},s.manager)})})]})]})]})})},Ma=({label:t,value:e,icon:r,tone:n="default"})=>{const s=n==="success"?"text-[hsl(var(--success))]":n==="destructive"?"text-destructive":n==="muted"?"text-muted-foreground":"text-primary";return p.jsxs("div",{className:"bg-card border border-border rounded-sm p-5",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"editorial-label",children:t}),r&&p.jsx("span",{className:s,children:r})]}),p.jsx("p",{className:`font-serif text-5xl mt-3 tabular ${s}`,children:e})]})},er=({children:t,align:e="left"})=>p.jsx("th",{className:`px-5 py-3 editorial-label ${e==="right"?"text-right":""}`,children:t}),tr=({children:t,align:e="left",className:r=""})=>p.jsx("td",{className:`px-5 py-4 text-sm ${e==="right"?"text-right":""} ${r}`,children:t}),Es=({label:t,value:e,tone:r="default"})=>{const n=r==="success"?"text-[hsl(var(--success))]":r==="destructive"?"text-destructive":r==="muted"?"text-muted-foreground":"text-primary";return p.jsxs("div",{children:[p.jsx("p",{className:"editorial-label text-[10px]",children:t}),p.jsx("p",{className:`font-serif text-2xl tabular mt-0.5 ${n}`,children:e})]})},Xj=()=>{const[t]=b.useState([...Gl].sort((a,l)=>l.created_at.localeCompare(a.created_at))),[e]=b.useState(!1),[r,n]=b.useState(""),[s,i]=b.useState(null),o=b.useMemo(()=>{const a=r.toLowerCase().trim();return a?t.filter(l=>l.respondent_name.toLowerCase().includes(a)||l.company_name.toLowerCase().includes(a)):t},[t,r]);return p.jsx(Nc,{children:p.jsxs("div",{className:"px-10 py-12 max-w-6xl",children:[p.jsx("p",{className:"editorial-label",children:"Avaliações recebidas"}),p.jsxs("h1",{className:"font-serif text-5xl text-primary mt-3 leading-[1.05] tracking-tight",children:["Respostas ",p.jsx("em",{className:"text-accent not-italic font-medium",children:"individuais"})]}),p.jsxs("div",{className:"mt-10 bg-card border border-border rounded-sm",children:[p.jsxs("div",{className:"px-5 py-4 border-b border-border flex items-center gap-3",children:[p.jsx(T0,{className:"w-4 h-4 text-muted-foreground",strokeWidth:1.5}),p.jsx("input",{value:r,onChange:a=>n(a.target.value),placeholder:"Buscar por nome ou empresa…",className:"flex-1 bg-transparent outline-none text-sm"}),p.jsxs("span",{className:"editorial-label tabular",children:[o.length," / ",t.length]})]}),e?p.jsx("p",{className:"editorial-label p-8",children:"Carregando…"}):o.length===0?p.jsx("p",{className:"editorial-label p-8",children:"Nenhuma resposta encontrada."}):p.jsx("ul",{className:"divide-y divide-border",children:o.map(a=>{const l=vf(a.ratings??[]),c=Kl(l),u=c==="promoter"?"text-[hsl(var(--success))]":c==="detractor"?"text-destructive":"text-muted-foreground",d=s===a.id;return p.jsxs("li",{children:[p.jsxs("button",{onClick:()=>i(d?null:a.id),className:"w-full px-5 py-5 flex items-center gap-5 hover:bg-secondary/40 transition-colors text-left",children:[d?p.jsx($S,{className:"w-4 h-4 text-muted-foreground"}):p.jsx(DS,{className:"w-4 h-4 text-muted-foreground"}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("p",{className:"font-medium text-primary",children:a.respondent_name}),p.jsx("p",{className:"text-sm text-muted-foreground truncate",children:a.company_name})]}),p.jsx("div",{className:"hidden md:block text-xs text-muted-foreground tabular",children:new Date(a.created_at).toLocaleDateString("pt-BR")}),p.jsx("div",{className:`font-serif text-2xl tabular ${u}`,children:l!==null?l.toFixed(1):"—"})]}),d&&p.jsx("div",{className:"px-12 pb-6 space-y-3",children:(a.ratings??[]).map((f,h)=>p.jsxs("div",{className:"border-l-2 border-accent/40 pl-4 py-1",children:[p.jsxs("div",{className:"flex items-baseline justify-between",children:[p.jsx("p",{className:"text-sm font-medium text-primary",children:f.axis_name}),p.jsx("span",{className:"font-mono text-sm tabular",children:f.score??"—"})]}),f.justification&&p.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:f.justification})]},h))})]},a.id)})})]})]})})},eA=["Rebeca","Andressa"],tA=()=>{const[t,e]=b.useState([...Gl].sort((h,y)=>y.created_at.localeCompare(h.created_at))),[r,n]=b.useState(qo),[s]=b.useState(!1),[i,o]=b.useState(""),[a,l]=b.useState(null),c=()=>{e([...Gl].sort((h,y)=>y.created_at.localeCompare(h.created_at))),n([...qo])},u=b.useMemo(()=>{const h=new Map,y=x=>x.trim().toLowerCase(),w=(x,m)=>r.find(g=>y(g.respondent_name)===y(x)&&y(g.company_name)===y(m));for(const x of t){const m=`${y(x.respondent_name)}|${y(x.company_name)}`,g=w(x.respondent_name,x.company_name),v=vf(x.ratings??[]),_=h.get(m);_?_.responses+=1:h.set(m,{key:m,name:x.respondent_name,company:x.company_name,email:x.respondent_email??(g==null?void 0:g.respondent_email)??null,clientId:(g==null?void 0:g.id)??null,department:(g==null?void 0:g.department)??null,serviceType:(g==null?void 0:g.service_type)??null,manager:(g==null?void 0:g.manager)??null,responses:1,lastAvg:v,lastDate:x.created_at})}for(const x of r){const m=`${y(x.respondent_name)}|${y(x.company_name)}`;h.has(m)||h.set(m,{key:m,name:x.respondent_name,company:x.company_name,email:x.respondent_email,clientId:x.id,department:x.department,serviceType:x.service_type,manager:x.manager,responses:0,lastAvg:null,lastDate:null})}return Array.from(h.values()).sort((x,m)=>(m.lastDate??"").localeCompare(x.lastDate??""))},[t,r]),d=b.useMemo(()=>{const h=i.toLowerCase().trim();return h?u.filter(y=>y.name.toLowerCase().includes(h)||y.company.toLowerCase().includes(h)):u},[u,i]),f=u.filter(h=>!h.serviceType).length;return p.jsxs(Nc,{children:[p.jsxs("div",{className:"px-10 py-12 max-w-6xl",children:[p.jsx("p",{className:"editorial-label",children:"Quem já respondeu"}),p.jsxs("div",{className:"flex items-start justify-between gap-6 mt-3",children:[p.jsxs("h1",{className:"font-serif text-5xl text-primary leading-[1.05] tracking-tight",children:["Cadastro ",p.jsx("em",{className:"text-accent not-italic font-medium",children:"de clientes"})]}),f>0&&p.jsxs("span",{className:"px-4 py-2 border border-accent text-accent rounded-full font-mono text-xs uppercase tracking-[0.15em]",children:[f," sem serviço"]})]}),p.jsx("p",{className:"text-muted-foreground mt-4 max-w-2xl",children:"Edite cada cadastro para atribuir o serviço contratado. O departamento é definido automaticamente pelo serviço."}),p.jsxs("div",{className:"mt-10 bg-card border border-border rounded-sm",children:[p.jsxs("div",{className:"px-5 py-4 border-b border-border flex items-center gap-3",children:[p.jsx(T0,{className:"w-4 h-4 text-muted-foreground",strokeWidth:1.5}),p.jsx("input",{value:i,onChange:h=>o(h.target.value),placeholder:"Buscar por nome ou empresa…",className:"flex-1 bg-transparent outline-none text-sm"}),p.jsxs("span",{className:"editorial-label tabular",children:[d.length," / ",u.length]})]}),s?p.jsx("p",{className:"editorial-label p-8",children:"Carregando…"}):d.length===0?p.jsx("p",{className:"editorial-label p-8",children:"Nenhum respondente ainda."}):p.jsxs("table",{className:"w-full",children:[p.jsx("thead",{className:"bg-secondary/40",children:p.jsxs("tr",{className:"text-left",children:[p.jsx("th",{className:"px-5 py-3 editorial-label",children:"Contato · Empresa"}),p.jsx("th",{className:"px-5 py-3 editorial-label",children:"Serviço"}),p.jsx("th",{className:"px-5 py-3 editorial-label",children:"Departamento"}),p.jsx("th",{className:"px-5 py-3 editorial-label",children:"Gestor"}),p.jsx("th",{className:"px-5 py-3 editorial-label text-right",children:"Respostas"}),p.jsx("th",{className:"px-5 py-3 editorial-label text-right",children:"Última nota"}),p.jsx("th",{className:"px-5 py-3 editorial-label text-right",children:"Ações"})]})}),p.jsx("tbody",{children:d.map(h=>{const y=Kl(h.lastAvg)==="promoter"?"text-[hsl(var(--success))]":Kl(h.lastAvg)==="detractor"?"text-destructive":"text-muted-foreground",w=h.serviceType?Kd(h.serviceType):null;return p.jsxs("tr",{className:"border-t border-border hover:bg-secondary/20",children:[p.jsxs("td",{className:"px-5 py-4",children:[p.jsx("p",{className:"font-medium text-primary",children:h.name}),p.jsx("p",{className:"text-sm text-muted-foreground",children:h.company})]}),p.jsx("td",{className:"px-5 py-4",children:p.jsx("span",{className:"text-sm text-muted-foreground",children:h.serviceType??p.jsx("em",{className:"text-accent font-medium",children:"Não informado"})})}),p.jsx("td",{className:"px-5 py-4",children:w?p.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-primary",children:[p.jsx(Xh,{className:"w-3.5 h-3.5",strokeWidth:1.5}),w]}):p.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),p.jsx("td",{className:"px-5 py-4",children:p.jsx("span",{className:"text-sm text-muted-foreground",children:h.serviceType==="Gestão contábil"?h.manager??p.jsx("em",{className:"text-accent",children:"—"}):p.jsx("span",{className:"text-border",children:"·"})})}),p.jsx("td",{className:"px-5 py-4 text-right tabular",children:h.responses}),p.jsx("td",{className:`px-5 py-4 text-right font-serif text-xl tabular ${y}`,children:h.lastAvg!==null?h.lastAvg.toFixed(1):"—"}),p.jsx("td",{className:"px-5 py-4 text-right",children:p.jsx("button",{onClick:()=>l(h),className:"text-muted-foreground hover:text-primary transition-colors",children:p.jsx(zS,{className:"w-4 h-4",strokeWidth:1.5})})})]},h.key)})})]})]})]}),a&&p.jsx(rA,{respondent:a,onClose:()=>l(null),onSaved:()=>{l(null),c()}})]})},rA=({respondent:t,onClose:e,onSaved:r})=>{const[n,s]=b.useState(t.name),[i,o]=b.useState(t.company),[a,l]=b.useState(t.email??""),[c,u]=b.useState(t.serviceType??""),[d,f]=b.useState(t.manager??""),[h,y]=b.useState(!1),w=mr(),x=c?Kd(c):null,m=c==="Gestão contábil",g=async()=>{y(!0);try{const v=qo.find(S=>S.id===t.clientId),_=c?Kd(c):null,k=m&&d||null;v?(v.respondent_name=n.trim(),v.company_name=i.trim(),v.respondent_email=a.trim()||null,v.service_type=c||null,v.department=_,v.manager=k):qo.push({id:crypto.randomUUID(),respondent_name:n.trim(),company_name:i.trim(),respondent_email:a.trim()||null,service_type:c||null,department:_,manager:k,token:crypto.randomUUID().replace(/-/g,"").slice(0,16)}),cr.success("Cadastro atualizado"),r()}catch(v){cr.error(v.message??"Erro ao salvar")}finally{y(!1)}};return p.jsx("div",{className:"fixed inset-0 z-50 bg-primary/30 backdrop-blur-sm flex items-center justify-center p-6",children:p.jsxs("div",{className:"bg-card border border-border rounded-sm w-full max-w-lg shadow-elegant",children:[p.jsxs("div",{className:"px-6 py-5 border-b border-border flex items-center justify-between",children:[p.jsxs("div",{children:[p.jsx("p",{className:"editorial-label",children:"Editar cadastro"}),p.jsx("h3",{className:"font-serif text-2xl text-primary mt-1",children:t.name})]}),p.jsx("button",{onClick:e,className:"text-muted-foreground hover:text-primary",children:p.jsx(N0,{className:"w-5 h-5",strokeWidth:1.5})})]}),p.jsxs("div",{className:"p-6 space-y-5",children:[p.jsx(Hi,{label:"Nome",children:p.jsx("input",{value:n,onChange:v=>s(v.target.value),className:"input-base"})}),p.jsx(Hi,{label:"Empresa",children:p.jsx("input",{value:i,onChange:v=>o(v.target.value),className:"input-base"})}),p.jsx(Hi,{label:"Email (opcional)",children:p.jsx("input",{type:"email",value:a,onChange:v=>l(v.target.value),className:"input-base"})}),p.jsx(Hi,{label:"Serviço contratado",children:p.jsxs("select",{value:c,onChange:v=>{u(v.target.value),f("")},className:"input-base",children:[p.jsx("option",{value:"",children:"— Não informado —"}),w.map(v=>p.jsx("option",{value:v.name,children:v.name},v.name))]})}),x&&p.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-secondary/40 rounded-sm border border-border",children:[p.jsx(Xh,{className:"w-3.5 h-3.5 text-muted-foreground",strokeWidth:1.5}),p.jsx("span",{className:"text-sm text-muted-foreground editorial-label",children:"Departamento: "}),p.jsx("span",{className:"text-sm text-primary font-medium",children:x})]}),m&&p.jsx(Hi,{label:"Gestor responsável",children:p.jsxs("select",{value:d,onChange:v=>f(v.target.value),className:"input-base",children:[p.jsx("option",{value:"",children:"— Selecione —"}),eA.map(v=>p.jsx("option",{value:v,children:v},v))]})})]}),p.jsxs("div",{className:"px-6 py-5 border-t border-border flex items-center justify-end gap-3",children:[p.jsx("button",{onClick:e,className:"px-5 py-2.5 border border-border hover:border-primary rounded-sm font-mono text-xs uppercase tracking-[0.15em]",children:"Cancelar"}),p.jsx("button",{onClick:g,disabled:h,className:"px-6 py-2.5 bg-primary text-primary-foreground hover:bg-primary-glow rounded-sm font-mono text-xs uppercase tracking-[0.15em] disabled:opacity-60",children:h?"Salvando…":"Salvar"})]})]})})},Hi=({label:t,children:e})=>p.jsxs("div",{children:[p.jsx("label",{className:"editorial-label block mb-2",children:t}),e]}),nA=()=>{const[t,e]=b.useState(mr),[r,n]=b.useState(""),[s,i]=b.useState(""),[o,a]=b.useState(!1),l=()=>{const d=r.trim();if(!d)return;if(mr().some(y=>y.name.toLowerCase()===d.toLowerCase())){cr.error("Serviço já existe");return}const h=Gj(d,s||null);e(h),cr.success(`Serviço "${d}" adicionado`),n(""),i(""),a(!1)},c=d=>{const f=Jj(d);e(f),cr.success(`Serviço "${d}" removido`)},u=new Set(tl.map(d=>d.name));return p.jsx(Nc,{children:p.jsxs("div",{className:"px-10 py-12 max-w-3xl",children:[p.jsx("p",{className:"editorial-label",children:"Configurações"}),p.jsxs("h1",{className:"font-serif text-5xl text-primary mt-3 leading-[1.05] tracking-tight",children:["Serviços ",p.jsx("em",{className:"text-accent not-italic font-medium",children:"oferecidos"})]}),p.jsx("p",{className:"text-muted-foreground mt-4 max-w-2xl",children:"Cada serviço está vinculado a um departamento. Os serviços padrão não podem ser removidos."}),p.jsxs("div",{className:"mt-12 bg-card border border-border rounded-sm",children:[p.jsxs("div",{className:"px-5 py-4 border-b border-border flex items-center justify-between",children:[p.jsxs("span",{className:"editorial-label",children:[t.length," serviços cadastrados"]}),!o&&p.jsxs("button",{onClick:()=>a(!0),className:"inline-flex items-center gap-2 px-4 py-2 bg-primary text-primary-foreground hover:bg-primary-glow rounded-sm font-mono text-xs uppercase tracking-[0.15em] transition-colors",children:[p.jsx(BS,{className:"w-3.5 h-3.5",strokeWidth:2})," Novo serviço"]})]}),o&&p.jsxs("div",{className:"px-5 py-5 border-b border-border bg-secondary/20 space-y-3",children:[p.jsx("div",{className:"flex items-center gap-3",children:p.jsx("input",{autoFocus:!0,value:r,onChange:d=>n(d.target.value),onKeyDown:d=>{d.key==="Enter"&&l(),d.key==="Escape"&&(a(!1),n(""),i(""))},placeholder:"Nome do novo serviço…",className:"flex-1 bg-card border border-border px-3 py-2 text-sm rounded-sm outline-none focus:border-primary transition-colors"})}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("select",{value:s,onChange:d=>i(d.target.value),className:"flex-1 bg-card border border-border px-3 py-2 text-sm rounded-sm outline-none focus:border-primary transition-colors",children:[p.jsx("option",{value:"",children:"— Departamento responsável —"}),qd.map(d=>p.jsx("option",{value:d,children:d},d))]}),p.jsx("button",{onClick:l,disabled:!r.trim(),className:"px-4 py-2 bg-primary text-primary-foreground hover:bg-primary-glow rounded-sm font-mono text-xs uppercase tracking-[0.15em] disabled:opacity-50 transition-colors",children:"Adicionar"}),p.jsx("button",{onClick:()=>{a(!1),n(""),i("")},className:"px-4 py-2 border border-border hover:border-primary rounded-sm font-mono text-xs uppercase tracking-[0.15em] transition-colors",children:"Cancelar"})]})]}),p.jsxs("div",{className:"px-5 py-3 bg-secondary/40 grid grid-cols-[1fr_200px_auto] gap-4 border-b border-border",children:[p.jsx("span",{className:"editorial-label text-xs",children:"Serviço"}),p.jsx("span",{className:"editorial-label text-xs",children:"Departamento"}),p.jsx("span",{className:"w-6"})]}),p.jsx("ul",{className:"divide-y divide-border",children:t.map(d=>{const f=u.has(d.name);return p.jsxs("li",{className:"px-5 py-3 grid grid-cols-[1fr_200px_auto] gap-4 items-center group",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:"text-sm font-medium text-primary",children:d.name}),f&&p.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-mono uppercase tracking-wider text-muted-foreground border border-border rounded-full px-2 py-0.5",children:[p.jsx(tf,{className:"w-2.5 h-2.5",strokeWidth:2})," padrão"]})]}),p.jsxs("select",{value:d.department??"",onChange:h=>{const y=Kj(d.name,h.target.value||null);e(y),cr.success("Departamento atualizado")},className:"bg-card border border-border rounded-sm px-2 py-1.5 text-sm outline-none focus:border-primary transition-colors w-full",children:[p.jsx("option",{value:"",children:"— Não definido —"}),qd.map(h=>p.jsx("option",{value:h,children:h},h))]}),f?p.jsx("span",{className:"w-4"}):p.jsx("button",{onClick:()=>c(d.name),className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all",title:"Remover serviço",children:p.jsx(WS,{className:"w-4 h-4",strokeWidth:1.5})})]},d.name)})})]})]})})},sA=new G_,iA=()=>p.jsx(Q_,{client:sA,children:p.jsxs(pT,{children:[p.jsx(RE,{}),p.jsx(P1,{}),p.jsx(Gk,{children:p.jsx(Vj,{children:p.jsxs(Fk,{children:[p.jsx(br,{path:"/",element:p.jsx(Mj,{})}),p.jsx(br,{path:"/c/:token",element:p.jsx(Fj,{})}),p.jsx(br,{path:"/auth",element:p.jsx(Bj,{})}),p.jsx(br,{path:"/admin",element:p.jsx(Yj,{})}),p.jsx(br,{path:"/admin/respostas",element:p.jsx(Xj,{})}),p.jsx(br,{path:"/admin/respondentes",element:p.jsx(tA,{})}),p.jsx(br,{path:"/admin/servicos",element:p.jsx(nA,{})}),p.jsx(br,{path:"*",element:p.jsx(zj,{})})]})})})]})});Py(document.getElementById("root")).render(p.jsx(iA,{}));