vendor: 4,277 bytes, line 1
1import{c as Ft,r as p,j as m,q as Cr,e as li,v as ci,L}from"./index-BdPoxQd_.js";const ui=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Hr=Ft("download",ui);const di=[["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"}]],hi=Ft("layout-dashboard",di);const fi=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],pi=Ft("menu",fi);const gi=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],mi=Ft("x",gi);function zr(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Wt(...t){return e=>{let r=!1;const s=t.map(n=>{const i=zr(n,e);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let n=0;n<s.length;n++){const i=s[n];typeof i=="function"?i():zr(t[n],null)}}}}function Ae(...t){return p.useCallback(Wt(...t),t)}var vi=Symbol.for("react.lazy"),It=Cr[" use ".trim().toString()];function bi(t){return typeof t=="object"&&t!==null&&"then"in t}function Ms(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===vi&&"_payload"in t&&bi(t._payload)}function yi(t){const e=_i(t),r=p.forwardRef((s,n)=>{let{children:i,...o}=s;Ms(i)&&typeof It=="function"&&(i=It(i._payload));const a=p.Children.toArray(i),l=a.find(Si);if(l){const c=l.props.children,u=a.map(d=>d===l?p.Children.count(c)>1?p.Children.only(null):p.isValidElement(c)?c.props.children:null:d);return m.jsx(e,{...o,ref:n,children:p.isValidElement(c)?p.cloneElement(c,void 0,u):null})}return m.jsx(e,{...o,ref:n,children:i})});return r.displayName=`${t}.Slot`,r}var wi=yi("Slot");function _i(t){const e=p.forwardRef((r,s)=>{let{children:n,...i}=r;if(Ms(n)&&typeof It=="function"&&(n=It(n._payload)),p.isValidElement(n)){const o=Ti(n),a=Ei(i,n.props);return n.type!==p.Fragment&&(a.ref=s?Wt(s,o):o),p.cloneElement(n,a)}return p.Children.count(n)>1?p.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var ki=Symbol("radix.slottable");function Si(t){return p.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===ki}function Ei(t,e){const r={...e};for(const s in e){const n=t[s],i=e[s];/^on[A-Z]/.test(s)?n&&i?r[s]=(...a)=>{const l=i(...a);return n(...a),l}:n&&(r[s]=n):s==="style"?r[s]={...n,...i}:s==="className"&&(r[s]=[n,i].filter(Boolean).join(" "))}return{...t,...r}}function Ti(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function Fs(t){var e,r,s="";if(typeof t=="string"||typeof t=="number")s+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(e=0;e<n;e++)t[e]&&(r=Fs(t[e]))&&(s&&(s+=" "),s+=r)}else for(r in t)t[r]&&(s&&(s+=" "),s+=r);return s}function Ws(){for(var t,e,r=0,s="",n=arguments.length;r<n;r++)(t=arguments[r])&&(e=Fs(t))&&(s&&(s+=" "),s+=e);return s}const Vr=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,Kr=Ws,qs=(t,e)=>r=>{var s;if(e?.variants==null)return Kr(t,r?.class,r?.className);const{variants:n,defaultVariants:i}=e,o=Object.keys(n).map(c=>{const u=r?.[c],d=i?.[c];if(u===null)return null;const h=Vr(u)||Vr(d);return n[c][h]}),a=r&&Object.entries(r).reduce((c,u)=>{let[d,h]=u;return h===void 0||(c[d]=h),c},{}),l=e==null||(s=e.compoundVariants)===null||s===void 0?void 0:s.reduce((c,u)=>{let{class:d,className:h,...f}=u;return Object.entries(f).every(b=>{let[g,v]=b;return Array.isArray(v)?v.includes({...i,...a}[g]):{...i,...a}[g]===v})?[...c,d,h]:c},[]);return Kr(t,o,l,r?.class,r?.className)},xi=(t,e)=>{const r=new Array(t.length+e.length);for(let s=0;s<t.length;s++)r[s]=t[s];for(let s=0;s<e.length;s++)r[t.length+s]=e[s];return r},Ai=(t,e)=>({classGroupId:t,validator:e}),Hs=(t=new Map,e=null,r)=>({nextPart:t,validators:e,classGroupId:r}),$t="-",Gr=[],Ri="arbitrary..",Ci=t=>{const e=Pi(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:s}=t;return{getClassGroupId:o=>
vendor: 3,581 bytes, line 1
1{if(o.startsWith("[")&&o.endsWith("]"))return Oi(o);const a=o.split($t),l=a[0]===""&&a.length>1?1:0;return zs(a,l,e)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=s[o],c=r[o];return l?c?xi(c,l):l:c||Gr}return r[o]||Gr}}},zs=(t,e,r)=>{if(t.length-e===0)return r.classGroupId;const n=t[e],i=r.nextPart.get(n);if(i){const c=zs(t,e+1,i);if(c)return c}const o=r.validators;if(o===null)return;const a=e===0?t.join($t):t.slice(e).join($t),l=o.length;for(let c=0;c<l;c++){const u=o[c];if(u.validator(a))return u.classGroupId}},Oi=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),r=e.indexOf(":"),s=e.slice(0,r);return s?Ri+s:void 0})(),Pi=t=>{const{theme:e,classGroups:r}=t;return ji(r,e)},ji=(t,e)=>{const r=Hs();for(const s in t){const n=t[s];Or(n,r,s,e)}return r},Or=(t,e,r,s)=>{const n=t.length;for(let i=0;i<n;i++){const o=t[i];Ni(o,e,r,s)}},Ni=(t,e,r,s)=>{if(typeof t=="string"){Ii(t,e,r);return}if(typeof t=="function"){$i(t,e,r,s);return}Li(t,e,r,s)},Ii=(t,e,r)=>{const s=t===""?e:Vs(e,t);s.classGroupId=r},$i=(t,e,r,s)=>{if(Di(t)){Or(t(s),e,r,s);return}e.validators===null&&(e.validators=[]),e.validators.push(Ai(r,t))},Li=(t,e,r,s)=>{const n=Object.entries(t),i=n.length;for(let o=0;o<i;o++){const[a,l]=n[o];Or(l,Vs(e,a),r,s)}},Vs=(t,e)=>{let r=t;const s=e.split($t),n=s.length;for(let i=0;i<n;i++){const o=s[i];let a=r.nextPart.get(o);a||(a=Hs(),r.nextPart.set(o,a)),r=a}return r},Di=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,Ui=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=Object.create(null),s=Object.create(null);const n=(i,o)=>{r[i]=o,e++,e>t&&(e=0,s=r,r=Object.create(null))};return{get(i){let o=r[i];if(o!==void 0)return o;if((o=s[i])!==void 0)return n(i,o),o},set(i,o){i in r?r[i]=o:n(i,o)}}},pr="!",Jr=":",Bi=[],Yr=(t,e,r,s,n)=>({modifiers:t,hasImportantModifier:e,baseClassName:r,maybePostfixModifierPosition:s,isExternal:n}),Mi=t=>{const{prefix:e,experimentalParseClassName:r}=t;let s=n=>{const i=[];let o=0,a=0,l=0,c;const u=n.length;for(let g=0;g<u;g++){const v=n[g];if(o===0&&a===0){if(v===Jr){i.push(n.slice(l,g)),l=g+1;continue}if(v==="/"){c=g;continue}}v==="["?o++:v==="]"?o--:v==="("?a++:v===")"&&a--}const d=i.length===0?n:n.slice(l);let h=d,f=!1;d.endsWith(pr)?(h=d.slice(0,-1),f=!0):d.startsWith(pr)&&(h=d.slice(1),f=!0);const b=c&&c>l?c-l:void 0;return Yr(i,f,h,b)};if(e){const n=e+Jr,i=s;s=o=>o.startsWith(n)?i(o.slice(n.length)):Yr(Bi,!1,o,void 0,!0)}if(r){const n=s;s=i=>r({className:i,parseClassName:n})}return s},Fi=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((r,s)=>{e.set(r,1e6+s)}),r=>{const s=[];let n=[];for(let i=0;i<r.length;i++){const o=r[i],a=o[0]==="[",l=e.has(o);a||l?(n.length>0&&(n.sort(),s.push(...n),n=[]),s.push(o)):n.push(o)}return n.length>0&&(n.sort(),s.push(...n)),s}},Wi=t=>({cache:Ui(t.cacheSize),parseClassName:Mi(t),sortModifiers:Fi(t),...Ci(t)}),qi=/\s+/,Hi=(t,e)=>{const{parseClassName:r,getClassGroupId:s,getConflictingClassGroupIds:n,sortModifiers:i}=e,o=[],a=t.trim().split(qi);let l="";for(let c=a.length-1;c>=0;c-=1){const u=a[c],{isExternal:d,modifiers:h,hasImportantModifier:f,baseClassName:b,maybePostfixModifierPosition:g}=r(u);if(d){l=u+(l.length>0?" "+l:l);continue}let v=!!g,y=s(v?b.substring(0,g):b);if(!y){if(!v){l=u+(l.length>0?" "+l:l);continue}if(y=s(b),!y){l=u+(l.length>0?" "+l:l);continue}v=!1}const _=h.length===0?"":h.length===1?h[0]:i(h).join(":"),w=f?_+pr:_,T=w+y;if(o.indexOf(T)>-1)continue;o.push(T);const N=n(y,v);for(let P=0;P<N.length;++P){const R=N[P];o.push(w+R)}l=u+(l.length>0?" "+l:l)}return l},zi=(...t)=>{let e=0,r,s,n="";for(;e<t.length;
vendor: 4,316 bytes, line 1
1)(r=t[e++])&&(s=Ks(r))&&(n&&(n+=" "),n+=s);return n},Ks=t=>{if(typeof t=="string")return t;let e,r="";for(let s=0;s<t.length;s++)t[s]&&(e=Ks(t[s]))&&(r&&(r+=" "),r+=e);return r},Vi=(t,...e)=>{let r,s,n,i;const o=l=>{const c=e.reduce((u,d)=>d(u),t());return r=Wi(c),s=r.cache.get,n=r.cache.set,i=a,a(l)},a=l=>{const c=s(l);if(c)return c;const u=Hi(l,r);return n(l,u),u};return i=o,(...l)=>i(zi(...l))},Ki=[],B=t=>{const e=r=>r[t]||Ki;return e.isThemeGetter=!0,e},Gs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Js=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Gi=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Ji=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Yi=/\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$/,Xi=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Zi=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Qi=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ce=t=>Gi.test(t),j=t=>!!t&&!Number.isNaN(Number(t)),ue=t=>!!t&&Number.isInteger(Number(t)),er=t=>t.endsWith("%")&&j(t.slice(0,-1)),se=t=>Ji.test(t),Ys=()=>!0,eo=t=>Yi.test(t)&&!Xi.test(t),Pr=()=>!1,to=t=>Zi.test(t),ro=t=>Qi.test(t),so=t=>!k(t)&&!E(t),no=t=>ge(t,Qs,Pr),k=t=>Gs.test(t),ye=t=>ge(t,en,eo),Xr=t=>ge(t,fo,j),io=t=>ge(t,rn,Ys),oo=t=>ge(t,tn,Pr),Zr=t=>ge(t,Xs,Pr),ao=t=>ge(t,Zs,ro),mt=t=>ge(t,sn,to),E=t=>Js.test(t),Je=t=>Re(t,en),lo=t=>Re(t,tn),Qr=t=>Re(t,Xs),co=t=>Re(t,Qs),uo=t=>Re(t,Zs),vt=t=>Re(t,sn,!0),ho=t=>Re(t,rn,!0),ge=(t,e,r)=>{const s=Gs.exec(t);return s?s[1]?e(s[1]):r(s[2]):!1},Re=(t,e,r=!1)=>{const s=Js.exec(t);return s?s[1]?e(s[1]):r:!1},Xs=t=>t==="position"||t==="percentage",Zs=t=>t==="image"||t==="url",Qs=t=>t==="length"||t==="size"||t==="bg-size",en=t=>t==="length",fo=t=>t==="number",tn=t=>t==="family-name",rn=t=>t==="number"||t==="weight",sn=t=>t==="shadow",po=()=>{const t=B("color"),e=B("font"),r=B("text"),s=B("font-weight"),n=B("tracking"),i=B("leading"),o=B("breakpoint"),a=B("container"),l=B("spacing"),c=B("radius"),u=B("shadow"),d=B("inset-shadow"),h=B("text-shadow"),f=B("drop-shadow"),b=B("blur"),g=B("perspective"),v=B("aspect"),y=B("ease"),_=B("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],N=()=>[...T(),E,k],P=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto","contain","none"],x=()=>[E,k,l],I=()=>[ce,"full","auto",...x()],le=()=>[ue,"none","subgrid",E,k],me=()=>["auto",{span:["full",ue,E,k]},ue,E,k],ve=()=>[ue,"auto",E,k],Ur=()=>["auto","min","max","fr",E,k],Jt=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Ce=()=>["start","end","center","stretch","center-safe","end-safe"],J=()=>["auto",...x()],be=()=>[ce,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...x()],Yt=()=>[ce,"screen","full","dvw","lvw","svw","min","max","fit",...x()],Xt=()=>[ce,"screen","full","lh","dvh","lvh","svh","min","max","fit",...x()],C=()=>[t,E,k],Br=()=>[...T(),Qr,Zr,{position:[E,k]}],Mr=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Fr=()=>["auto","cover","contain",co,no,{size:[E,k]}],Zt=()=>[er,Je,ye],q=()=>["","none","full",c,E,k],H=()=>["",j,Je,ye],ht=()=>["solid","dashed","dotted","double"],Wr=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],M=()=>[j,er,Qr,Zr],qr=()=>["","none",b,E,k],ft=()=>["none",j,E,k],pt=()=>["none",j,E,k],Qt=()=>[j,E,k],gt=()=>[ce,"full",...x()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[se],breakpoint:[se],color:[Ys],container:[se],"drop-shadow":[se],ease:["in","out","in-out"],font:[so],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[se],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[se],shadow:[se],spacing:["px",j],text:[se],"text-shadow":[se],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ce,k,E,v]}
vendor: 4,414 bytes, line 1
1],container:["container"],columns:[{columns:[j,k,E,a]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"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"],sr:["sr-only","not-sr-only"],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:N()}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{"inset-s":I(),start:I()}],end:[{"inset-e":I(),end:I()}],"inset-bs":[{"inset-bs":I()}],"inset-be":[{"inset-be":I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[ue,"auto",E,k]}],basis:[{basis:[ce,"full","auto",a,...x()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[j,ce,"auto","initial","none",k]}],grow:[{grow:["",j,E,k]}],shrink:[{shrink:["",j,E,k]}],order:[{order:[ue,"first","last","none",E,k]}],"grid-cols":[{"grid-cols":le()}],"col-start-end":[{col:me()}],"col-start":[{"col-start":ve()}],"col-end":[{"col-end":ve()}],"grid-rows":[{"grid-rows":le()}],"row-start-end":[{row:me()}],"row-start":[{"row-start":ve()}],"row-end":[{"row-end":ve()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Ur()}],"auto-rows":[{"auto-rows":Ur()}],gap:[{gap:x()}],"gap-x":[{"gap-x":x()}],"gap-y":[{"gap-y":x()}],"justify-content":[{justify:[...Jt(),"normal"]}],"justify-items":[{"justify-items":[...Ce(),"normal"]}],"justify-self":[{"justify-self":["auto",...Ce()]}],"align-content":[{content:["normal",...Jt()]}],"align-items":[{items:[...Ce(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Ce(),{baseline:["","last"]}]}],"place-content":[{"place-content":Jt()}],"place-items":[{"place-items":[...Ce(),"baseline"]}],"place-self":[{"place-self":["auto",...Ce()]}],p:[{p:x()}],px:[{px:x()}],py:[{py:x()}],ps:[{ps:x()}],pe:[{pe:x()}],pbs:[{pbs:x()}],pbe:[{pbe:x()}],pt:[{pt:x()}],pr:[{pr:x()}],pb:[{pb:x()}],pl:[{pl:x()}],m:[{m:J()}],mx:[{mx:J()}],my:[{my:J()}],ms:[{ms:J()}],me:[{me:J()}],mbs:[{mbs:J()}],mbe:[{mbe:J()}],mt:[{mt:J()}],mr:[{mr:J()}],mb:[{mb:J()}],ml:[{ml:J()}],"space-x":[{"space-x":x()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":x()}],"space-y-reverse":["space-y-reverse"],size:[{size:be()}],"inline-size":[{inline:["auto",...Yt()]}],"min-inline-size":[{"min-inline":["auto",...Yt()]}],"max-inline-size":[{"max-inline":["none",...Yt()]}],"block-size":[{block:["auto",...Xt()]}],"min-block-size":[{"min-block":["auto",...Xt()]}],"max-block-size":[{"max-block":["none",...Xt()]}],w:[{w:[a,"screen",...be()]}],"min-w":[{"min-w":[a,"screen","none",...be()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...be()]}],h:[{h:["screen","lh",...be()]}],"min-h":[{"min-h":["screen","lh","none",...be()]}],"max-h":[{"max-h":["screen","lh",...be()]}],"font-size":[{text:["base",r,Je,ye]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,ho,io]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",er,k]}],"font-family":[{font:[lo,oo,e]}],"font-features":[{"font-features":[k]}],"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:[n,E,k]}
vendor: 9,130 bytes, line 1
1],"line-clamp":[{"line-clamp":[j,"none",E,Xr]}],leading:[{leading:[i,...x()]}],"list-image":[{"list-image":["none",E,k]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",E,k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:C()}],"text-color":[{text:C()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ht(),"wavy"]}],"text-decoration-thickness":[{decoration:[j,"from-font","auto",E,ye]}],"text-decoration-color":[{decoration:C()}],"underline-offset":[{"underline-offset":[j,"auto",E,k]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",E,k]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",E,k]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Br()}],"bg-repeat":[{bg:Mr()}],"bg-size":[{bg:Fr()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ue,E,k],radial:["",E,k],conic:[ue,E,k]},uo,ao]}],"bg-color":[{bg:C()}],"gradient-from-pos":[{from:Zt()}],"gradient-via-pos":[{via:Zt()}],"gradient-to-pos":[{to:Zt()}],"gradient-from":[{from:C()}],"gradient-via":[{via:C()}],"gradient-to":[{to:C()}],rounded:[{rounded:q()}],"rounded-s":[{"rounded-s":q()}],"rounded-e":[{"rounded-e":q()}],"rounded-t":[{"rounded-t":q()}],"rounded-r":[{"rounded-r":q()}],"rounded-b":[{"rounded-b":q()}],"rounded-l":[{"rounded-l":q()}],"rounded-ss":[{"rounded-ss":q()}],"rounded-se":[{"rounded-se":q()}],"rounded-ee":[{"rounded-ee":q()}],"rounded-es":[{"rounded-es":q()}],"rounded-tl":[{"rounded-tl":q()}],"rounded-tr":[{"rounded-tr":q()}],"rounded-br":[{"rounded-br":q()}],"rounded-bl":[{"rounded-bl":q()}],"border-w":[{border:H()}],"border-w-x":[{"border-x":H()}],"border-w-y":[{"border-y":H()}],"border-w-s":[{"border-s":H()}],"border-w-e":[{"border-e":H()}],"border-w-bs":[{"border-bs":H()}],"border-w-be":[{"border-be":H()}],"border-w-t":[{"border-t":H()}],"border-w-r":[{"border-r":H()}],"border-w-b":[{"border-b":H()}],"border-w-l":[{"border-l":H()}],"divide-x":[{"divide-x":H()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":H()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ht(),"hidden","none"]}],"divide-style":[{divide:[...ht(),"hidden","none"]}],"border-color":[{border:C()}],"border-color-x":[{"border-x":C()}],"border-color-y":[{"border-y":C()}],"border-color-s":[{"border-s":C()}],"border-color-e":[{"border-e":C()}],"border-color-bs":[{"border-bs":C()}],"border-color-be":[{"border-be":C()}],"border-color-t":[{"border-t":C()}],"border-color-r":[{"border-r":C()}],"border-color-b":[{"border-b":C()}],"border-color-l":[{"border-l":C()}],"divide-color":[{divide:C()}],"outline-style":[{outline:[...ht(),"none","hidden"]}],"outline-offset":[{"outline-offset":[j,E,k]}],"outline-w":[{outline:["",j,Je,ye]}],"outline-color":[{outline:C()}],shadow:[{shadow:["","none",u,vt,mt]}],"shadow-color":[{shadow:C()}],"inset-shadow":[{"inset-shadow":["none",d,vt,mt]}],"inset-shadow-color":[{"inset-shadow":C()}],"ring-w":[{ring:H()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:C()}],"ring-offset-w":[{"ring-offset":[j,ye]}],"ring-offset-color":[{"ring-offset":C()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":C()}],"text-shadow":[{"text-shadow":["none",h,vt,mt]}],"text-shadow-color":[{"text-shadow":C()}],opacity:[{opacity:[j,E,k]}],"mix-blend":[{"mix-blend":[...Wr(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Wr()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[j]}],"mask-image-linear-from-pos":[{"mask-linear-from":M()}],"mask-image-linear-to-pos":[{"mask-linear-to":M()}],"mask-image-linear-from-color":[{"mask-linear-from":C()}],"mask-image-linear-to-color":[{"mask-linear-to":C()}],"mask-image-t-from-pos":[{"mask-t-from":M()}],"mask-image-t-to-pos":[{"mask-t-to":M()}],"mask-image-t-from-color":[{"mask-t-from":C()}],"mask-image-t-to-color":[{"mask-t-to":C()}],"mask-image-r-from-pos":[{"mask-r-from":M()}],"mask-image-r-to-pos":[{"mask-r-to":M()}],"mask-image-r-from-color":[{"mask-r-from":C()}],"mask-image-r-to-color":[{"mask-r-to":C()}],"mask-image-b-from-pos":[{"mask-b-from":M()}],"mask-image-b-to-pos":[{"mask-b-to":M()}],"mask-image-b-from-color":[{"mask-b-from":C()}],"mask-image-b-to-color":[{"mask-b-to":C()}],"mask-image-l-from-pos":[{"mask-l-from":M()}],"mask-image-l-to-pos":[{"mask-l-to":M()}],"mask-image-l-from-color":[{"mask-l-from":C()}],"mask-image-l-to-color":[{"mask-l-to":C()}],"mask-image-x-from-pos":[{"mask-x-from":M()}],"mask-image-x-to-pos":[{"mask-x-to":M()}],"mask-image-x-from-color":[{"mask-x-from":C()}],"mask-image-x-to-color":[{"mask-x-to":C()}],"mask-image-y-from-pos":[{"mask-y-from":M()}],"mask-image-y-to-pos":[{"mask-y-to":M()}],"mask-image-y-from-color":[{"mask-y-from":C()}],"mask-image-y-to-color":[{"mask-y-to":C()}],"mask-image-radial":[{"mask-radial":[E,k]}],"mask-image-radial-from-pos":[{"mask-radial-from":M()}],"mask-image-radial-to-pos":[{"mask-radial-to":M()}],"mask-image-radial-from-color":[{"mask-radial-from":C()}],"mask-image-radial-to-color":[{"mask-radial-to":C()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[j]}],"mask-image-conic-from-pos":[{"mask-conic-from":M()}],"mask-image-conic-to-pos":[{"mask-conic-to":M()}],"mask-image-conic-from-color":[{"mask-conic-from":C()}],"mask-image-conic-to-color":[{"mask-conic-to":C()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Br()}],"mask-repeat":[{mask:Mr()}],"mask-size":[{mask:Fr()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",E,k]}],filter:[{filter:["","none",E,k]}],blur:[{blur:qr()}],brightness:[{brightness:[j,E,k]}],contrast:[{contrast:[j,E,k]}],"drop-shadow":[{"drop-shadow":["","none",f,vt,mt]}],"drop-shadow-color":[{"drop-shadow":C()}],grayscale:[{grayscale:["",j,E,k]}],"hue-rotate":[{"hue-rotate":[j,E,k]}],invert:[{invert:["",j,E,k]}],saturate:[{saturate:[j,E,k]}],sepia:[{sepia:["",j,E,k]}],"backdrop-filter":[{"backdrop-filter":["","none",E,k]}],"backdrop-blur":[{"backdrop-blur":qr()}],"backdrop-brightness":[{"backdrop-brightness":[j,E,k]}],"backdrop-contrast":[{"backdrop-contrast":[j,E,k]}],"backdrop-grayscale":[{"backdrop-grayscale":["",j,E,k]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[j,E,k]}],"backdrop-invert":[{"backdrop-invert":["",j,E,k]}],"backdrop-opacity":[{"backdrop-opacity":[j,E,k]}],"backdrop-saturate":[{"backdrop-saturate":[j,E,k]}],"backdrop-sepia":[{"backdrop-sepia":["",j,E,k]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":x()}],"border-spacing-x":[{"border-spacing-x":x()}],"border-spacing-y":[{"border-spacing-y":x()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",E,k]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[j,"initial",E,k]}],ease:[{ease:["linear","initial",y,E,k]}],delay:[{delay:[j,E,k]}],animate:[{animate:["none",_,E,k]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,E,k]}],"perspective-origin":[{"perspective-origin":N()}],rotate:[{rotate:ft()}],"rotate-x":[{"rotate-x":ft()}],"rotate-y":[{"rotate-y":ft()}],"rotate-z":[{"rotate-z":ft()}],scale:[{scale:pt()}],"scale-x":[{"scale-x":pt()}],"scale-y":[{"scale-y":pt()}],"scale-z":[{"scale-z":pt()}],"scale-3d":["scale-3d"],skew:[{skew:Qt()}],"skew-x":[{"skew-x":Qt()}],"skew-y":[{"skew-y":Qt()}],transform:[{transform:[E,k,"","none","gpu","cpu"]}],"transform-origin":[{origin:N()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:gt()}],"translate-x":[{"translate-x":gt()}],"translate-y":[{"translate-y":gt()}],"translate-z":[{"translate-z":gt()}],"translate-none":["translate-none"],accent:[{accent:C()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:C()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","
1none","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",E,k]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mbs":[{"scroll-mbs":x()}],"scroll-mbe":[{"scroll-mbe":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-pbs":[{"scroll-pbs":x()}],"scroll-pbe":[{"scroll-pbe":x()}],"scroll-pt":[{"scroll-pt":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"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",E,k]}],fill:[{fill:["none",...C()]}],"stroke-w":[{stroke:[j,Je,ye,Xr]}],stroke:[{stroke:["none",...C()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","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","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","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-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","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-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","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"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","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-pbs","scroll-pbe","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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},go=Vi(po);function Ve(...t){return go(Ws(t))}const mo=qs("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),V=p.forwardRef(({className:t,variant:e,size:r,asChild:s=!1,...n},i)=>{const o=s?wi:"button";return m.jsx(o,{className:Ve(mo({variant:e,size:r,className:t})),ref:i,...n})});V.displayName="Button";var re=function(){return re=Object.assign||function(e){for(var r,s=1,n=arguments.length;s<n;s++){r=arguments[s];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},re.apply(this,arguments)};function Ke(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r}function vo(t,e,r,s){function n(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(u){try{c(s.next(u))}catch(d){o(d)}}function l(u){try{c(s.throw(u))}catch(d){o(d)}}function c(u){u.done?i(u.value):n(u.value).then(a,l)}c((s=s.apply(t,e||[])).next())})}function bo(t,e,r){if(r||arguments.length===2)for(var s=0,n=e.length,i;s<n;s++)(i||!(s in e))&&(i||(i=Array.prototype.slice.call(e,0,s)),i[s]=e[s]);return t.concat(i||Array.prototype.slice.call(e))}const yo=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);
1class jr extends Error{constructor(e,r="FunctionsError",s){super(e),this.name=r,this.context=s}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class wo extends jr{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class es extends jr{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class ts extends jr{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var gr;(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"})(gr||(gr={}));class _o{constructor(e,{headers:r={},customFetch:s,region:n=gr.Any}={}){this.url=e,this.headers=r,this.region=n,this.fetch=yo(s)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return vo(this,arguments,void 0,function*(r,s={}){var n;let i,o;try{const{headers:a,method:l,body:c,signal:u,timeout:d}=s;let h={},{region:f}=s;f||(f=this.region);const b=new URL(`${this.url}/${r}`);f&&f!=="any"&&(h["x-region"]=f,b.searchParams.set("forceFunctionRegion",f));let g;c&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)?typeof Blob<"u"&&c instanceof Blob||c instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",g=c):typeof c=="string"?(h["Content-Type"]="text/plain",g=c):typeof FormData<"u"&&c instanceof FormData?g=c:(h["Content-Type"]="application/json",g=JSON.stringify(c)):c&&typeof c!="string"&&!(typeof Blob<"u"&&c instanceof Blob)&&!(c instanceof ArrayBuffer)&&!(typeof FormData<"u"&&c instanceof FormData)?g=JSON.stringify(c):g=c;let v=u;d&&(o=new AbortController,i=setTimeout(()=>o.abort(),d),u?(v=o.signal,u.addEventListener("abort",()=>o.abort())):v=o.signal);const y=yield this.fetch(b.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),a),body:g,signal:v}).catch(N=>{throw new wo(N)}),_=y.headers.get("x-relay-error");if(_&&_==="true")throw new es(y);if(!y.ok)throw new ts(y);let w=((n=y.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),T;return w==="application/json"?T=yield y.json():w==="application/octet-stream"||w==="application/pdf"?T=yield y.blob():w==="text/event-stream"?T=y:w==="multipart/form-data"?T=yield y.formData():T=yield y.text(),{data:T,error:null,response:y}}catch(a){return{data:null,error:a,response:a instanceof ts||a instanceof es?a.context:void 0}}finally{i&&clearTimeout(i)}})}}const nn=3,rs=t=>Math.min(1e3*2**t,3e4),ko=[520,503],on=["GET","HEAD","OPTIONS"];var So=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.co
1de=t.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function ss(t,e){return new Promise(r=>{if(e?.aborted){r();return}const s=setTimeout(()=>{e?.removeEventListener("abort",n),r()},t);function n(){clearTimeout(s),r()}e?.addEventListener("abort",n)})}function Eo(t,e,r,s){return!(!s||r>=nn||!on.includes(t)||!ko.includes(e))}var To=class{constructor(t){var e,r,s,n,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=(s=t.shouldStripNulls)!==null&&s!==void 0?s:!1,this.urlLengthLimit=(n=t.urlLengthLimit)!==null&&n!==void 0?n: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 s=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 s(r.url.toString(),{method:r.method,headers:c,body:JSON.stringify(r.body,(d,h)=>typeof h=="bigint"?h.toString():h),signal:r.signal})}catch(d){if(d?.name==="AbortError"||d?.code==="ABORT_ERR"||!on.includes(r.method))throw d;if(r.retryEnabled&&o<nn){const h=rs(o);o++,await ss(h,r.signal);continue}throw d}if(Eo(r.method,u.status,o,r.retryEnabled)){var a,l;const d=(a=(l=u.headers)===null||l===void 0?void 0:l.get("Retry-After"))!==null&&a!==void 0?a:null,h=d!==null?Math.max(0,parseInt(d,10)||0)*1e3:rs(o);await u.text(),o++,await ss(h,r.signal);continue}return await r.processResponse(u)}})();return this.shouldThrowOnError||(i=i.catch(o=>{var a;let l="",c="",u="";const d=o?.cause;if(d){var h,f,b,g;const _=(h=d?.message)!==null&&h!==void 0?h:"",w=(f=d?.code)!==null&&f!==void 0?f:"";l=`${(b=o?.name)!==null&&b!==void 0?b:"FetchError"}: ${o?.message}`,l+=` 2 3Caused by: ${(g=d?.name)!==null&&g!==void 0?g:"Error"}: ${_}`,w&&(l+=` (${w})`),d?.stack&&(l+=` 4${d.stack}`)}else{var v;l=(v=o?.stack)!==null&&v!==void 0?v:""}const y=this.url.toString().length;return o?.name==="AbortError"||o?.code==="ABORT_ERR"?(u="",c="Request was aborted (timeout or manual cancellation)",y>this.urlLengthLimit&&(c+=`. Note: Your request URL is ${y} 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?.name==="HeadersOverflowError"||d?.code==="UND_ERR_HEADERS_OVERFLOW")&&(u="",c="HTTP headers exceeded server limits (typically 16KB)",y>this.urlLengthLimit&&(c+=`. Your request URL is ${y} 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?.name)!==null&&a!==void 0?a:"FetchError"}: ${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,s=null,n=null,i=t.status,o=t.statusText;if(t.ok){var a,l;if(e.method!=="HEAD"){var c;const h=await t.text();h===""||(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"))?s=h:s=JSON.parse(h))}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&&(n=parseInt(d[1])),e.isMaybeSingle&&Array.isArray(s)&&(s.length>1?(r={code:"PGRST116",details:`Results contain ${s.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},s=null,n=null,i=406,o="Not Acceptable"):s.length===1?s=s[0]:s=null)}else{const u=await t.text();try{r=JSON.parse(u),Array.isArray(r)&&t.status===404&&(s=[],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 So(r)}return{success:r===null,error:r,data:s,count:n,status:i,statusText:o}}returns(){return this}overrideTypes(){return this}},xo=class extends To{select(t){let e=!1;const r=(t??"*").split("").map(s=>/\s/.test(s)&&!e?"":(s==='"'&&(e=!e),s)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:s,referencedTable:n=s}={}){const i=n?`${n}.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 s=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:s=r}={}){const n=typeof s>"u"?"offset":`${s}.offset`,i=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(n,`${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}
4explain({analyze:t=!1,verbose:e=!1,settings:r=!1,buffers:s=!1,wal:n=!1,format:i="text"}={}){var o;const a=[t?"analyze":null,e?"verbose":null,r?"settings":null,s?"buffers":null,n?"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 ns=new RegExp("[,()]");var Be=class extends xo{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const r=Array.from(new Set(e)).map(s=>typeof s=="string"&&ns.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}notIn(t,e){const r=Array.from(new Set(e)).map(s=>typeof s=="string"&&ns.test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(t,`not.in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:s}={}){let n="";s==="plain"?n="pl":s==="phrase"?n="ph":s==="websearch"&&(n="w");const i=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${n}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 s=r?`${r}.or`:"or";return this.url.searchParams.append(s,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}},Ao=class{constructor(t,{headers:e={},schema:r,fetch:s,urlLengthLimit:n=8e3,retry:i}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=s,this.urlLengthLimit=n,this.retry=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){const{head:r=!1,count:s}=e??{},n=r?"HEAD":"GET";let 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),s&&l.append("Prefer",`count=${s}`),new Be({method:n,url:a,headers:l,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(t,{count:e,defaultToNull:r=!0}={}){var s;const n="POST",{url: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>
40){const l=[...new Set(a)].map(c=>`"${c}"`);i.searchParams.set("columns",l.join(","))}}return new Be({method:n,url:i,headers:o,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:s,defaultToNull:n=!0}={}){var 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),s&&l.append("Prefer",`count=${s}`),n||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 Be({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 s="PATCH",{url:n,headers:i}=this.cloneRequestState();return e&&i.append("Prefer",`count=${e}`),new Be({method:s,url:n,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:s,headers:n}=this.cloneRequestState();return t&&n.append("Prefer",`count=${t}`),new Be({method:r,url:s,headers:n,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function rt(t){"@babel/helpers - typeof";return rt=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},rt(t)}function Ro(t,e){if(rt(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(rt(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Co(t){var e=Ro(t,"string");return rt(e)=="symbol"?e:e+""}function Oo(t,e,r){return(e=Co(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function is(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function bt(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?is(Object(r),!0).forEach(function(s){Oo(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):is(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}var Po=class an{constructor(e,{headers:r={},schema:s,fetch:n,timeout:i,urlLengthLimit:o=8e3,retry:a}={}){this.url=e,this.headers=new Headers(r),this.schemaName=s,this.urlLengthLimit=o;const l=n??globalThis.fetch;i!==void 0&&i>0?this.fetch=(c,u)=>{const d=new AbortController,h=setTimeout(()=>d.abort(),i),f=u?.signal;if(f){if(f.aborted)return clearTimeout(h),l(c,u);const b=()=>{clearTimeout(h),d.abort()};return f.addEventListener("abort",b,{once:!0}),l(c,bt(bt({},u),{},{signal:d.signal})).finally(()=>{clearTimeout(h),f.removeEventListener("abort",b)})}return l(c,bt(bt({},u),{},{signal:d.signal})).finally(()=>clearTimeout(h))}: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 Ao(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 an(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(e,r={},{head:s=!1,get:n=!1,count:i}={}){var o;let a;const l=new URL(`${this.url}/rpc/${e}`);let c;const u=f=>f!==null&&typeof f=="object"&&(!Array.isArray(f)||f.some(u)),d=s&&Object.values(r).some(u);d?(a="POST",c=r):s||n?(a=s?"HEAD":"GET",Object.entries(r).filter(([f,b])=>b!==void 0).map(([f,b])=>[f,Array.isArray(b)?`{${b.join(",")}}`:`${b}
4`]).forEach(([f,b])=>{l.searchParams.append(f,b)})):(a="POST",c=r);const h=new Headers(this.headers);return d?h.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&h.set("Prefer",`count=${i}`),new Be({method:a,url:l,headers:h,schema:this.schemaName,body:c,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class jo{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 s=r.versions;if(s&&s.node){const n=s.node,i=parseInt(n.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: 5import ws from "ws" 6new 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+=` 7 8Suggested solution: ${e.workaround}`),new Error(r)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const No="2.104.0",Io=`realtime-js/${No}`,$o="1.0.0",ln="2.0.0",Lo=ln,Do=1e4,Uo=100,he={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},cn={close:"phx_close",error:"phx_error",join:"phx_join",leave:"phx_leave",access_token:"access_token"},mr={connecting:"connecting",closing:"closing",closed:"closed"};class Bo{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,r){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return r(this._binaryEncodeUserBroadcastPush(e));let s=[e.join_ref,e.ref,e.topic,e.event,e.payload];return r(JSON.stringify(s))}_binaryEncodeUserBroadcastPush(e){var r;return this._isArrayBuffer((r=e.payload)===null||r===void 0?void 0:r.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var r,s;const n=(s=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&s!==void 0?s:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}_encodeJsonUserBroadcastPush(e){var r,s;const n=(s=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&s!==void 0?s:{},o=new TextEncoder().encode(JSON.stringify(n)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,o)}_encodeUserBroadcastPush(e,r,s){var n,i;const o=e.topic,a=(n=e.ref)!==null&&n!==void 0?n:"",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 h=this.USER_BROADCAST_PUSH_META_LENGTH+l.length+a.length+o.length+c.length+d.length,f=new ArrayBuffer(this.HEADER_LENGTH+h);let b=new DataView(f),g=0;b.setUint8(g++,this.KINDS.userBroadcastPush),b.setUint8(g++,l.length),b.setUint8(g++,a.length),b.setUint8(g++,o.length),b.setUint8(g++,c.length),b.setUint8(g++,d.length),b.setUint8(g++,r),Array.from(l,y=>
8b.setUint8(g++,y.charCodeAt(0))),Array.from(a,y=>b.setUint8(g++,y.charCodeAt(0))),Array.from(o,y=>b.setUint8(g++,y.charCodeAt(0))),Array.from(c,y=>b.setUint8(g++,y.charCodeAt(0))),Array.from(d,y=>b.setUint8(g++,y.charCodeAt(0)));var v=new Uint8Array(f.byteLength+s.byteLength);return v.set(new Uint8Array(f),0),v.set(new Uint8Array(s),f.byteLength),v.buffer}decode(e,r){if(this._isArrayBuffer(e)){let s=this._binaryDecode(e);return r(s)}if(typeof e=="string"){const s=JSON.parse(e),[n,i,o,a,l]=s;return r({join_ref:n,ref:i,topic:o,event:a,payload:l})}return r({})}_binaryDecode(e){const r=new DataView(e),s=r.getUint8(0),n=new TextDecoder;if(s===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,r,n)}_decodeUserBroadcast(e,r,s){const n=r.getUint8(1),i=r.getUint8(2),o=r.getUint8(3),a=r.getUint8(4);let l=this.HEADER_LENGTH+4;const c=s.decode(e.slice(l,l+n));l=l+n;const u=s.decode(e.slice(l,l+i));l=l+i;const d=s.decode(e.slice(l,l+o));l=l+o;const h=e.slice(l,e.byteLength),f=a===this.JSON_ENCODING?JSON.parse(s.decode(h)):h,b={type:this.BROADCAST_EVENT,event:u,payload:f};return o>0&&(b.meta=JSON.parse(d)),{join_ref:null,ref:null,topic:c,event:this.BROADCAST_EVENT,payload:b}}_isArrayBuffer(e){var r;return e instanceof ArrayBuffer||((r=e?.constructor)===null||r===void 0?void 0:r.name)==="ArrayBuffer"}_pick(e,r){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([s])=>r.includes(s)))}}var $;(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"})($||($={}));const os=(t,e,r={})=>{var s;const n=(s=r.skipTypes)!==null&&s!==void 0?s:[];return e?Object.keys(e).reduce((i,o)=>(i[o]=Mo(o,t,e,n),i),{}):{}},Mo=(t,e,r,s)=>{const n=e.find(a=>a.name===t),i=n?.type,o=r[t];return i&&!s.includes(i)?un(i,o):vr(o)},un=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return Ho(e,r)}switch(t){case $.bool:return Fo(e);case $.float4:case $.float8:case $.int2:case $.int4:case $.int8:case $.numeric:case $.oid:return Wo(e);case $.json:case $.jsonb:return qo(e);case $.timestamp:return zo(e);case $.abstime:case $.date:case $.daterange:case $.int4range:case $.int8range:case $.money:case $.reltime:case $.text:case $.time:case $.timestamptz:case $.timetz:case $.tsrange:case $.tstzrange:return vr(e);default:return vr(e)}},vr=t=>t,Fo=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Wo=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},qo=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},Ho=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,s=t[r];if(t[0]==="{"&&s==="}"){let i;const o=t.slice(1,r);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(a=>un(e,a))}return t},zo=t=>typeof t=="string"?t.replace(" ","T"):t,dn=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 Qe=t=>typeof t=="function"?t:function(){return t},Vo=typeof self<"u"?self:null,Me=typeof window<"u"?window:null,ee=Vo||Me||globalThis,Ko="2.0.0",Go=1e4,Jo=1e3,te={connecting:0,open:1,closing:2,closed:3},z={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},ne={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},br={longpoll:"longpoll",websocket:"websocket"},Yo={complete:4},yr="base64url.bearer.phx.",yt=class{constructor(t,e,r,s){this.channel=t,this.event=e,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHo
vendor: 8,686 bytes, line 8
8oks=[],this.sent=!1,this.ref=void 0}resend(t){this.timeout=t,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:t,response:e,_ref:r}){this.recHooks.filter(s=>s.status===t).forEach(s=>s.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},hn=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))}},Xo=class{constructor(t,e,r){this.state=z.closed,this.topic=t,this.params=Qe(e||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new yt(this,ne.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new hn(()=>{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=z.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",s=>{this.state=z.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=z.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=z.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 yt(this,ne.leave,Qe({}),this.timeout).send(),this.state=z.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(ne.reply,(s,n)=>{this.trigger(this.replyEventName(n),s)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=z.closed,this.bindings=[]}onClose(t){this.on(ne.close,t)}onError(t){return this.on(ne.error,e=>t(e))}on(t,e){let r=this.bindingRef++;return this.bindings.push({event:t,ref:r,callback:e}),r}off(t,e){this.bindings=this.bindings.filter(r=>!(r.event===t&&(typeof e>"u"||e===r.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,r=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new yt(this,t,function(){return e},r);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=z.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(ne.close,"leave")},r=new yt(this,ne.leave,Qe({}),t);return r.receive("ok",()=>e()).receive("timeout",()=>e()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(t,e,r){return e}filterBindings(t,e,r){return!0}isMember(t,e,r,s){return this.topic!==t?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:r,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=z.joining,this.joinPush.resend(t))}trigger(t,e,r,s){let n=this.onMessage(t,e,r,s);if(e&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(o=>o.event===t&&this.filterBindings(o,e,r));for(let o=0;o<i.length;o++)i[o].callback(n,r,s||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===z.closed}isErrored(){return this.state===z.errored}isJoined(){return this.state===z.joined}isJoining(){return this.state===z.joining}isLeaving(){return this.state===z.leaving}},Lt=class{static request(t,e,r,s,n,i,o){if(ee.XDomainRequest){let a=new ee.XDomainRequest;return this.xdomainRequest(a,t,e,s,n,i,o)}else if(ee.XMLHttpRequest){let a=new ee.XMLHttpRequest;return this.xhrRequest(a,t,e,r,s,n,i,o)}else{if(ee.fetch&&ee.AbortController)return this.fetchRequest(t,e,r,s,n,i,o);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,e,r,s,n,i,o){let a={method:t,headers:r,body:s},l=null;return n&&(l=new AbortController,setTimeout(()=>l.abort(),n),a.signal=l.signal),ee.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,s,n,i,o){return t.timeout=n,t.open(e,r),t.onload=()=>{let a=this.parseJSON(t.responseText);o&&o(a)},i&&(t.ontimeout=i),t.onprogress=()=>{},t.send(s),t}static xhrRequest(t,e,r,s,n,i,o,a){t.open(e,r,!0),t.timeout=i;for(let[l,c]of Object.entries(s))t.setRequestHeader(l,c);return t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===Yo.complete&&a){let l=this.parseJSON(t.responseText);a(l)}},o&&(t.ontimeout=o),t.send(n),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let r=[];for(var s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let n=e?`${e}[${s}]`:s,i=t[s];typeof i=="object"?r.push(this.serialize(i,n)):r.push(encodeURIComponent(n)+"="+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)}`}},Zo=t=>{let e="",r=new Uint8Array(t),s=r.byteLength;for(let n=0;n<s;n++)e+=String.fromCharCode(r[n]);return btoa(e)},Oe=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(yr)&&(this.authToken=atob(e[1].slice(yr.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=te.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+br.websocket),"$1/"+br.longpoll)}endpointURL(){return Lt.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,r){this.close(t,e,r),this.readyState=te.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===te.open||this.readyState===te.connecting}poll(){const t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),e=>{if(e){var{status:r,token:s,messages:n}=e;if(r===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=s}else r=0;switch(r){case 200:n.forEach(i=>{setTimeout(()=>this.onmessage({data:i}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=te.open,this.onopen({}),this.poll();break;
8case 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=Zo(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(` 9`),()=>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 n of this.reqs)n.abort();this.readyState=te.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:r});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(t,e,r,s,n){let i,o=()=>{this.reqs.delete(i),s()};i=Lt.request(t,this.endpointURL(),e,r,this.timeout,o,a=>{this.reqs.delete(i),this.isActive()&&n(a)}),this.reqs.add(i)}},Qo=class Xe{constructor(e,r={}){let s=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(s.state,n=>{let{onJoin:i,onLeave:o,onSync:a}=this.caller;this.joinRef=this.channel.joinRef(),this.state=Xe.syncState(this.state,n,i,o),this.pendingDiffs.forEach(l=>{this.state=Xe.syncDiff(this.state,l,i,o)}),this.pendingDiffs=[],a()}),this.channel.on(s.diff,n=>{let{onJoin:i,onLeave:o,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=Xe.syncDiff(this.state,n,i,o),a())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(e){return Xe.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,r,s,n){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(g=>g.phx_ref),h=u.metas.map(g=>g.phx_ref),f=c.metas.filter(g=>h.indexOf(g.phx_ref)<0),b=u.metas.filter(g=>d.indexOf(g.phx_ref)<0);f.length>0&&(o[l]=c,o[l].metas=f),b.length>0&&(a[l]=this.clone(u),a[l].metas=b)}else o[l]=c}),this.syncDiff(i,{joins:o,leaves:a},s,n)}static syncDiff(e,r,s,n){let{joins:i,leaves:o}=this.clone(r);return s||(s=function(){}),n||(n=function(){}),this.map(i,(a,l)=>{let c=e[a];if(e[a]=this.clone(l),c){let u=e[a].metas.map(h=>h.phx_ref),d=c.metas.filter(h=>u.indexOf(h.phx_ref)<0);e[a].metas.unshift(...d)}s(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),n(a,c,l),c.metas.length===0&&delete e[a]}),e}static list(e,r){return r||(r=function(s,n){return n}),this.map(e,(s,n)=>r(s,n))}static map(e,r){return Object.getOwnPropertyNames(e).map(s=>r(s,e[s]))}static clone(e){return JSON.parse(JSON.stringify(e))}},wt={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let r=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(r))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[r,s,n,i,o]=JSON.parse(t);return e({join_ref:r,ref:s,topic:n,event:i,payload:o})}},binaryEncode(t){let{join_ref:e,ref:r,event:s,topic:n,payload:i}=t,o=this.META_LENGTH+e.length+r.length+n.length+s.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++,n.length),l.setUint8(c++,s.length),Array.from(e,d=>l.setUint8(c++,d.charCodeAt(0))),Array.from(r,d=>l.setUint8(c++,d.charCodeAt(0))),Array.from(n,d=>l.setUint8(c++,d.charCodeAt(0))),Array.from(s,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),s=new TextDecoder;switch(r){case this.KINDS.push:return this.decodePush(t,e,s);case this.KINDS.reply:return this.decodeReply(t,e,s);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,s)}},decodePush(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),i=e.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=r.decode(t.slice(o,o+s));o=o+s;let l=r.decode(t.slice(o,o+n));o=o+n;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 s=e.getUint8(1),n=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+s));a=a+s;let c=r.decode(t.slice(a,a+n));a=a+n;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 h=t.slice(a,t.byteLength),f={status:d,response:h};return{join_ref:l,ref:c,topic:u,event:ne.reply,payload:f}},decodeBroadcast(t,e,r){let s=e.getUint8(1),n=e.getUint8(2),i=this.HEADER_LENGTH+2,o=r.decode(t.slice(i,i+s));i=i+s;let a=r.decode(t.slice(i,i+n));i=i+n;let l=t.slice(i,t.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},ea=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||Go,this.transport=e.transport||ee.WebSocket||Oe,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=e.sessionStorage||ee&&ee.sessionStorage,this.establishedConnections=0,this.defaultEncoder=wt.encode.bind(wt),this.defaultDecoder=wt.decode.bind(wt),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!==Oe?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let r=null;Me&&Me.addEventListener&&(Me.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),r=this.connectClock)}),Me.addEventListener("pageshow",s=>{r===this.connectClock&&(r=null,this.connect())}),Me.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=s=>e.rejoinAfterMs?e.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>e.reconnectAfterMs?e.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(s,n,i)=>{console.log(`${s}: ${n}`,i)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=Qe(e.params||{}),this.endPoint=`${t}/${br.websocket}`,this.vsn=e.vsn||Ko,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new hn(()=>
9{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 Oe}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=Lt.appendParams(Lt.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=Qe(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==Oe?this.connectWithF
vendor: 4,313 bytes, line 9
9allback(Oe,this.longPollFallbackMs):this.transportConnect())}log(t,e,r){this.logger&&this.logger(t,e,r)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}onHeartbeat(t){this.heartbeatCallback=t}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),r=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let s=this.onMessage(n=>{n.ref===e&&(this.off([s]),t(Date.now()-r))});return!0}transportName(t){return t===Oe?"LongPoll":t.name}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${yr}${btoa(this.authToken).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),t),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let r=!1,s=!0,n,i,o=this.transportName(t),a=l=>{this.log("transport",`falling back to ${o}...`,l),this.off([n,i]),s=!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),s&&!r&&(clearTimeout(this.fallbackTimer),a(l))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(r=!0,!s){let l=this.transportName(t);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${l}`,"true"),this.log("transport",`established ${l} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(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(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Jo,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,r){if(!this.conn)return t&&t();const s=this.conn;this.waitForBufferDone(s,()=>{e?s.close(e,r||""):s.close(),this.waitForSocketClosed(s,()=>{this.conn===s&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,e,r=1){if(r===5||!t.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(t,e,r+1)},150*r)}waitForSocketClosed(t,e,r=1){if(r===5||t.readyState===te.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(),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",t)}onConnError(t){this.hasLogger()&&this.log("transport",t);let e=this.transport,r=this.establishedConnections;this.triggerStateCallbacks("error",t,e,r),(e===this.transport||r>0)&&this.triggerChanError()}
9triggerChanError(){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(ne.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case te.connecting:return"connecting";case te.open:return"open";case te.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 Xo(t,e,this);return this.channels.push(r),r}push(t){if(this.hasLogger()){let{topic:e,event:r,payload:s,ref:n,join_ref:i}=t;this.log("push",`${e} ${r} (${i}, ${n})`,s)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(t){this.log("error","error in heartbeat callback",t)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(t){this.log("error","error in heartbeat callback",t)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:r,event:s,payload:n,ref: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(n.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",`${n.status||""} ${r} ${s} ${i&&"("+i+")"||""}`.trim(),n);for(let a=0;a<this.channels.length;a++){const l=this.channels[a];l.isMember(r,s,n,o)&&l.trigger(s,n,i,o)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(t,...e){try{this.stateChangeCallbacks[t].forEach(([r,s])=>{try{s(...e)}catch(n){this.log("error",`error in ${t} callback`,n)}})}catch(r){this.log("error",`error triggering ${t} callbacks`,r)}}leaveOpenTopic(t){let e=this.channels.find(r=>r.topic===t&&(r.isJoined()||r.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}};class et{constructor(e,r){const s=ra(r);this.presence=new Qo(e.getChannel(),s),this.presence.onJoin((n,i,o)=>{const a=et.onJoinPayload(n,i,o);e.getChannel().trigger("presence",a)}),this.presence.onLeave((n,i,o)=>{const a=et.onLeavePayload(n,i,o);e.getChannel().trigger("presence",a)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return et.transformState(this.presence.state)}static transformState(e){return e=ta(e),Object.getOwnPropertyNames(e).reduce((r,s)=>{const n=e[s];return r[s]=Pt(n),r},{})}static onJoinPayload(e,r,s){const n=as(r),i=Pt(s);return{event:"join",key:e,currentPresences:n,newPresences:i}}static onLeavePayload(e,r,s){const n=as(r),i=Pt(s);return{event:"leave",key:e,currentPresences:n,leftPresences:i}}}function Pt(t){return t.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))}function ta(t){return JSON.parse(JSON.stringify(t))}function ra(t){return t?.events&&{events:t.events}}function as(t){return t?.metas?Pt(t):[]}var ls;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(ls||(ls={}));class sa{get state(){return this.presenceAdapter.state}constructor(e,r){this.channel=e,this.presenceAdapter=new et(this.channel.channelAdapter,r)}}class na{constructor(e,r,s){const n=ia(s);this.channel=e.getSocket().channel(r,n),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,r){return this.channel.on(e,r)}off(e,r){this.channel.off(e,r)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,r,s){let n;try{n=this.channel.push(e,r,s)}catch{throw new Error(`tried to push '${e}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>Uo){const i=this.channel.pushBuffer.shift();i.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${i.event}`,i.payload())}return n}updateJoinPayload(e){const r=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},r),e)}canPush(){return this.socket.isConnected()&&this.state===he.joined}isJoined(){return this.state===he.joined}isJoining(){return this.state===he.joining}isClosed(){return this.state===he.closed}isLeaving(){return this.state===he.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}function ia(t){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config)}}var cs;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELET
9E="DELETE"})(cs||(cs={}));var qe;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(qe||(qe={}));var ie;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(ie||(ie={}));class tt{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,r={config:{}},s){var n,i;if(this.topic=e,this.params=r,this.socket=s,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.channelAdapter=new na(this.socket.socketAdapter,e,this.params),this.presence=new sa(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=dn(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((i=(n=this.params.config)===null||n===void 0?void 0:n.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 s,n,i;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:o,presence:a,private:l}}=this.params,c=(n=(s=this.bindings.postgres_changes)===null||s===void 0?void 0:s.map(f=>f.filter))!==null&&n!==void 0?n:[],u=!!this.bindings[qe.PRESENCE]&&this.bindings[qe.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,d={},h={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(f=>{e?.(ie.CHANNEL_ERROR,f)}),this._onClose(()=>e?.(ie.CLOSED)),this.updateJoinPayload(Object.assign({config:h},d)),this._updateFilterMessage(),this.channelAdapter.subscribe(r).receive("ok",async({postgres_changes:f})=>{if(this.socket._isManualToken()||this.socket.setAuth(),f===void 0){e?.(ie.SUBSCRIBED);return}this._updatePostgresBindings(f,e)}).receive("error",f=>{this.state=he.errored,e?.(ie.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(f).join(", ")||"error")))}).receive("timeout",()=>{e?.(ie.TIMED_OUT)})}return this}_updatePostgresBindings(e,r){var s;const n=this.bindings.postgres_changes,i=(s=n?.length)!==null&&s!==void 0?s:0,o=[];for(let a=0;a<i;a++){const l=n[a],{filter:{event:c,schema:u,table:d,filter:h}}=l,f=e&&e[a];if(f&&f.event===c&&tt.isFilterValueEqual(f.schema,u)&&tt.isFilterValueEqual(f.table,d)&&tt.isFilterValueEqual(f.filter,h))o.push(Object.assign(Object.assign({},l),{id:f.id}));else{this.unsubscribe(),this.state=he.errored,r?.(ie.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=o,this.state!=he.errored&&r&&r(ie.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,s){const n=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),i=e===qe.PRESENCE||e===qe.POSTGRES_CHANGES;if(n&&i)throw this.socket.log("channel",`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`),new Error(`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(e,r,s)}async httpSend(e,r,s={}){var n;if(r==null)return Promise.reject(new Error("Payload is required for httpSend()"));const i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(i.Authorization=`Bearer ${this.socket.accessTokenValue}`);const o={method:"POST",headers:i,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:r,private:this.private}]})},a=await this._fetchWithTimeout(this.broadcastEndpointURL,o,(n=s.timeout)!==null&&n!==void 0?n:this.timeout);if(a.status===202)return{success:!0};let l=a.statusText;
9try{const c=await a.json();l=c.error||c.message||l}catch{}return Promise.reject(new Error(l))}async send(e,r={}){var s,n;if(!this.channelAdapter.canPush()&&e.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:i,payload:o}=e,a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(a.Authorization=`Bearer ${this.socket.accessTokenValue}`);const l={method:"POST",headers:a,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const c=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(s=r.timeout)!==null&&s!==void 0?s:this.timeout);return await((n=c.body)===null||n===void 0?void 0:n.cancel()),c.ok?"ok":"error"}catch(c){return c.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{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,s){const n=new AbortController,i=setTimeout(()=>n.abort(),s),o=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:n.signal}));return clearTimeout(i),o}_on(e,r,s){const n=e.toLocaleLowerCase(),i=this.channelAdapter.on(e,s),o={type:n,filter:r,callback:s,ref:i};return this.bindings[n]?this.bindings[n].push(o):this.bindings[n]=[o],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,r,s)=>{var n,i,o,a,l,c,u;const d=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(d,s))return!1;const h=(n=this.bindings[d])===null||n===void 0?void 0:n.find(f=>f.ref===e.ref);if(!h)return!0;if(["broadcast","presence","postgres_changes"].includes(d))if("id"in h){const f=h.id,b=(i=h.filter)===null||i===void 0?void 0:i.event;return f&&((o=r.ids)===null||o===void 0?void 0:o.includes(f))&&(b==="*"||b?.toLocaleLowerCase()===((a=r.data)===null||a===void 0?void 0:a.type.toLocaleLowerCase()))}else{const f=(c=(l=h?.filter)===null||l===void 0?void 0:l.event)===null||c===void 0?void 0:c.toLocaleLowerCase();return f==="*"||f===((u=r?.event)===null||u===void 0?void 0:u.toLocaleLowerCase())}else return h.type.toLocaleLowerCase()===d})}_notThisChannelEvent(e,r){const{close:s,error:n,leave:i,join:o}=cn;return r&&[s,n,i,o].includes(e)&&r!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,r,s)=>{if(typeof r=="object"&&"ids"in r){const n=r.data,{schema:i,table:o,commit_timestamp:a,type:l,errors:c}=n;return Object.assign(Object.assign({},{schema:i,table:o,commit_timestamp:a,eventType:l,new:{},old:{},errors:c}),this._getPayloadRecords(n))}return r})}copyBindings(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const r in e.bindings)for(const s of e.bindings[r])this._on(s.type,s.filter,s.callback)}static isFilterValueEqual(e,r){return(e??void 0)===(r??void 0)}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=os(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=os(e.columns,e.old_record)),r}}class oa{constructor(e,r){this.socket=new ea(e,r)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,r,s,n=1e4){return new Promise(i=>{setTimeout(()=>i("timeout"),n),this.socket.disconnect(()=>{e(),i("ok")},r,s)})}push(e){this.socket.push(e)}log(e,r,s){this.socket.log(e,r,s)}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()==mr.connecting}isDisconnecting(){return this.socket.connectionState()==mr.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const aa={HEARTBEAT_INTERVAL:25e3},la=[1e3,2e3,5e3,1e4],ca=1e4,ua=` 10 addEventListener("message", (e) => { 11 if (e.data.event === "start") { 12 setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); 13 } 14 });`;class da{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,r){var s;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={}
14,this.ref=0,this.serializer=new Bo,this._manuallySetToken=!1,this._authPromise=null,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._resolveFetch=i=>i?(...o)=>i(...o):(...o)=>fetch(...o),!(!((s=r?.params)===null||s===void 0)&&s.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey;const n=this._initializeOptions(r);this.socketAdapter=new oa(e,n),this.httpEndpoint=dn(e),this.fetch=this._resolveFetch(r?.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(e){const r=e.message;throw r.includes("Node.js")?new Error(`${r} 15 16To use Realtime in Node.js, you need to provide a WebSocket implementation: 17 18Option 1: Use Node.js 22+ which has native WebSocket support 19Option 2: Install and provide the "ws" package: 20 21 npm install ws 22 23 import ws from "ws" 24 const client = new RealtimeClient(url, { 25 ...options, 26 transport: ws 27 })`):new Error(`WebSocket not available: ${r}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,r){return 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(),this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const e=this.channels.map(async s=>{const n=await s.unsubscribe();return s.teardown(),n}),r=await Promise.all(e);return this.disconnect(),r}log(e,r,s){this.socketAdapter.log(e,r,s)}connectionState(){return this.socketAdapter.connectionState()||mr.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,r={config:{}}){const s=`realtime:${e}`,n=this.getChannels().find(i=>i.topic===s);if(n)return n;{const i=new tt(`realtime:${e}`,r,this);return 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)}async _performAuth(e=null){let r,s=!1;if(e)r=e,s=!0;else if(this.accessToken)try{r=await this.accessToken()}catch(n){this.log("error","Error fetching access token from callback",n),r=this.accessTokenValue}else r=this.accessTokenValue;s?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{const i={access_token:r,version:Io};r&&n.updateJoinPayload(i),n.joinedOnce&&n.channelAdapter.isJoined()&&n.channelAdapter.push(cn.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,s)=>{r=="sent"&&this._setAuthSafely(),e&&e(r,s)}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let r;if(e)r=e;else{const s=new Blob([ua],{type:"application/javascript"});r=URL.createObjectURL(s)}return r}_initializeOptions(e){var r,s,n,i,o,a,l,c,u;this.worker=(r=e?.worker)!==null&&r!==void 0?r:!1,this.accessToken=(s=e?.accessToken)!==null&&s!==void 0?s:null;const d={};d.timeout=(n=e?.timeout)!==null&&n!==void 0?n:Do,d.heartbeatIntervalMs=(i=e?.heartbeatIntervalMs)!==null&&i!==void 0?i:aa.HEARTBEAT_INTERVAL,d.transport=(o=e?.transport)!==null&&o!==void 0?o:jo.getWebSocketConstructor(),d.params=e?.params,d.logger=e?.logger,d.heartbeatCallback=this._wrapHeartbeatCallback(e?.heartbeatCallback),d.reconnectAfterMs=(a=e?.reconnectAfterMs)!==null&&a!==void 0?a:(g=>la[g-1]||ca);let h,f;
27const b=(l=e?.vsn)!==null&&l!==void 0?l:Lo;switch(b){case $o:h=(g,v)=>v(JSON.stringify(g)),f=(g,v)=>v(JSON.parse(g));break;case ln:h=this.serializer.encode.bind(this.serializer),f=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${d.vsn}`)}if(d.vsn=b,d.encode=(c=e?.encode)!==null&&c!==void 0?c:h,d.decode=(u=e?.decode)!==null&&u!==void 0?u:f,d.beforeReconnect=this._reconnectAuth.bind(this),(e?.logLevel||e?.log_level)&&(this.logLevel=e.logLevel||e.log_level,d.params=Object.assign(Object.assign({},d.params),{log_level:this.logLevel})),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e?.workerUrl,d.autoSendHeartbeat=!this.worker}return d}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}var st=class extends Error{constructor(t,e){super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&e.icebergType?.includes("CommitState")===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function ha(t,e,r){const s=new URL(e,t);if(r)for(const[n,i]of Object.entries(r))i!==void 0&&s.searchParams.set(n,i);return s.toString()}async function fa(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 pa(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:r,path:s,query:n,body:i,headers:o}){const a=ha(t.baseUrl,s,n),l=await fa(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"),h=d&&u?JSON.parse(u):u;if(!c.ok){const f=d?h:void 0,b=f?.error;throw new st(b?.message??`Request failed with status ${c.status}`,{status:c.status,icebergType:b?.type,icebergCode:b?.code,details:f})}return{status:c.status,headers:c.headers,data:h}}}}function _t(t){return t.join("�")}var ga=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:_t(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(s=>({namespace:s}))}async createNamespace(t,e){const r={namespace:t.namespace,properties:e?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${_t(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${_t(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${_t(t.namespace)}`}),!0}catch(e){if(e instanceof st&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(r){if(r instanceof st&&r.status===409)return;throw r}}};function Pe(t){return t.join("�")}var ma=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/${Pe(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/${Pe(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/${Pe(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/${Pe(t.namespace)}
27/tables/${t.name}`,query:{purgeRequested:String(e?.purge??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Pe(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/${Pe(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(r){if(r instanceof st&&r.status===404)return!1;throw r}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(r){if(r instanceof st&&r.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw r}}},va=class{constructor(t){let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const r=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=pa({baseUrl:r,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=t.accessDelegation?.join(","),this.namespaceOps=new ga(this.client,e),this.tableOps=new ma(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 nt(t){"@babel/helpers - typeof";return nt=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},nt(t)}function ba(t,e){if(nt(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(nt(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ya(t){var e=ba(t,"string");return nt(e)=="symbol"?e:e+""}function wa(t,e,r){return(e=ya(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function us(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function O(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?us(Object(r),!0).forEach(function(s){wa(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):us(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}var qt=class extends Error{constructor(t,e="storage",r,s){super(t),this.__isStorageError=!0,this.namespace=e,this.name=e==="vectors"?"StorageVectorsError":"StorageError",this.status=r,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function Ht(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var wr=class extends qt{constructor(t,e,r,s="storage"){super(t,s,e,r),this.name=s==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=e,this.statusCode=r}toJSON(){return O({},super.toJSON())}},fn=class extends qt{constructor(t,e,r="storage"){super(t,r),this.name=r==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=e}};function Nr(t,e,r){const s=O({},t),n=e.toLowerCase();for(const i of Object.keys(s))i.toLowerCase()===n&&delete s[i];return s[n]=r,s}function _a(t){const e={};for(const[r,s]of Object.entries(t))e[r.toLowerCase()]=s;return e}const ka=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),Sa=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);
27return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},_r=t=>{if(Array.isArray(t))return t.map(r=>_r(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,s])=>{const n=r.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[n]=_r(s)}),e},Ea=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t),ds=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)},Ta=async(t,e,r,s)=>{if(t!==null&&typeof t=="object"&&typeof t.json=="function"){const n=t;let i=parseInt(n.status,10);Number.isFinite(i)||(i=500),n.json().then(o=>{const a=o?.statusCode||o?.code||i+"";e(new wr(ds(o),i,a,s))}).catch(()=>{const o=i+"";e(new wr(n.statusText||`HTTP ${i} error`,i,o,s))})}else e(new fn(ds(t),t,s))},xa=(t,e,r,s)=>{const n={method:t,headers:e?.headers||{}};if(t==="GET"||t==="HEAD"||!s)return O(O({},n),r);if(Sa(s)){var i;const o=e?.headers||{};let a;for(const[l,c]of Object.entries(o))l.toLowerCase()==="content-type"&&(a=c);n.headers=Nr(o,"Content-Type",(i=a)!==null&&i!==void 0?i:"application/json"),n.body=JSON.stringify(s)}else n.body=s;return e?.duplex&&(n.duplex=e.duplex),O(O({},n),r)};async function Ye(t,e,r,s,n,i,o){return new Promise((a,l)=>{t(r,xa(e,s,n,i)).then(c=>{if(!c.ok)throw c;if(s?.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=>Ta(c,l,s,o))})}function pn(t="storage"){return{get:async(e,r,s,n)=>Ye(e,"GET",r,s,n,void 0,t),post:async(e,r,s,n,i)=>Ye(e,"POST",r,n,i,s,t),put:async(e,r,s,n,i)=>Ye(e,"PUT",r,n,i,s,t),head:async(e,r,s,n)=>Ye(e,"HEAD",r,O(O({},s),{},{noResolveJson:!0}),n,void 0,t),remove:async(e,r,s,n,i)=>Ye(e,"DELETE",r,n,i,s,t)}}const Aa=pn("storage"),{get:it,post:X,put:kr,head:Ra,remove:Ir}=Aa,G=pn("vectors");var Ge=class{constructor(t,e={},r,s="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=_a(e),this.fetch=ka(r),this.namespace=s}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=Nr(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(Ht(r))return{data:null,error:r};throw r}}},Ca=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(Ht(e))return{data:null,error:e};throw e}}};let gn;gn=Symbol.toStringTag;var Oa=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[gn]="BlobDownloadBuilder",this.promise=null}asStream(){return new Ca(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(Ht(e))return{data:null,error:e};throw e}}};const Pa={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},hs={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var ja=class extends Ge{constructor(t,e={},r,s){super(t,e,s,"storage"),this.bucketId=r}async uploadOrUpdate(t,e,r,s){var n=this;return n.handleOperation(async()=>{let i;const o=O(O({},hs),s);let a=O(O({},n.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",n.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",n.encodeMetadata(l))):(i=r,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType,l&&(a["x-metadata"]=n.toBase64(n.encodeMetadata(l))),(typeof ReadableStream<"u"&&i instanceof ReadableStream||i&&typeof i=="object"&&"pipe"in i&&typeof i.pipe=="function")&&!o.duplex&&(o.duplex="half")),s?.headers)for(const[h,f]of Object.entries(s.headers))a=Nr(a,h,f);const c=n._removeEmptyFolders(e),u=n._getFinalPath(c),d=await(t=="PUT"?kr:X)(n.fetch,`${n.url}/object/${u}`,i,O({headers:a},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)}
27async uploadToSignedUrl(t,e,r,s){var n=this;const i=n._removeEmptyFolders(t),o=n._getFinalPath(i),a=new URL(n.url+`/object/upload/sign/${o}`);return a.searchParams.set("token",e),n.handleOperation(async()=>{let l;const c=O(O({},hs),s),u=O(O({},n.headers),{"x-upsert":String(c.upsert)});return typeof Blob<"u"&&r instanceof Blob?(l=new FormData,l.append("cacheControl",c.cacheControl),l.append("",r)):typeof FormData<"u"&&r instanceof FormData?(l=r,l.append("cacheControl",c.cacheControl)):(l=r,u["cache-control"]=`max-age=${c.cacheControl}`,u["content-type"]=c.contentType),{path:i,fullPath:(await kr(n.fetch,a.toString(),l,{headers:u})).Key}})}async createSignedUploadUrl(t,e){var r=this;return r.handleOperation(async()=>{let s=r._getFinalPath(t);const n=O({},r.headers);e?.upsert&&(n["x-upsert"]="true");const i=await X(r.fetch,`${r.url}/object/upload/sign/${s}`,{},{headers:n}),o=new URL(r.url+i.url),a=o.searchParams.get("token");if(!a)throw new qt("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 s=this;return s.handleOperation(async()=>await X(s.fetch,`${s.url}/object/move`,{bucketId:s.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r?.destinationBucket},{headers:s.headers}))}async copy(t,e,r){var s=this;return s.handleOperation(async()=>({path:(await X(s.fetch,`${s.url}/object/copy`,{bucketId:s.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r?.destinationBucket},{headers:s.headers})).Key}))}async createSignedUrl(t,e,r){var s=this;return s.handleOperation(async()=>{let n=s._getFinalPath(t);const i=typeof r?.transform=="object"&&r.transform!==null&&Object.keys(r.transform).length>0;let o=await X(s.fetch,`${s.url}/object/sign/${n}`,O({expiresIn:e},i?{transform:r.transform}:{}),{headers:s.headers});const a=new URLSearchParams;r?.download&&a.set("download",r.download===!0?"":r.download),r?.cacheNonce!=null&&a.set("cacheNonce",String(r.cacheNonce));const l=a.toString();return{signedUrl:encodeURI(`${s.url}${o.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(t,e,r){var s=this;return s.handleOperation(async()=>{const n=await X(s.fetch,`${s.url}/object/sign/${s.bucketId}`,{expiresIn:e,paths:t},{headers:s.headers}),i=new URLSearchParams;r?.download&&i.set("download",r.download===!0?"":r.download),r?.cacheNonce!=null&&i.set("cacheNonce",String(r.cacheNonce));const o=i.toString();return n.map(a=>O(O({},a),{},{signedUrl:a.signedURL?encodeURI(`${s.url}${a.signedURL}${o?`&${o}`:""}`):null}))})}download(t,e,r){const s=typeof e?.transform=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image/authenticated":"object",n=new URLSearchParams;e?.transform&&this.applyTransformOptsToQuery(n,e.transform),e?.cacheNonce!=null&&n.set("cacheNonce",String(e.cacheNonce));const i=n.toString(),o=this._getFinalPath(t),a=()=>it(this.fetch,`${this.url}/${s}/${o}${i?`?${i}`:""}`,{headers:this.headers,noResolveJson:!0},r);return new Oa(a,this.shouldThrowOnError)}async info(t){var e=this;const r=e._getFinalPath(t);return e.handleOperation(async()=>_r(await it(e.fetch,`${e.url}/object/info/${r}`,{headers:e.headers})))}async exists(t){var e=this;const r=e._getFinalPath(t);try{return await Ra(e.fetch,`${e.url}/object/${r}`,{headers:e.headers}),{data:!0,error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(Ht(n)){var s;const i=n instanceof wr?n.status:n instanceof fn?(s=n.originalError)===null||s===void 0?void 0:s.status:void 0;if(i!==void 0&&[400,404].includes(i))return{data:!1,error:n}}throw n}}getPublicUrl(t,e){const r=this._getFinalPath(t),s=new URLSearchParams;e?.download&&s.set("download",e.download===!0?"":e.download),e?.transform&&this.applyTransformOptsToQuery(s,e.transform),e?.cacheNonce!=null&&s.set("cacheNonce",String(e.cacheNonce));const n=s.toString(),i=typeof e?.transform=="object"&&e.transform!==null&&Object.keys(e.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${r}`)+(n?`?${n}`:"")}}}async remove(t){var e=this;return e.handleOperation(async()=>await Ir(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}))}async list(t,e,r){var s=this;return s.handleOperation(async()=>{const n=O(O(O({},Pa),e),{},{prefix:t||""});return await X(s.fetch,`${s.url}/object/list/${s.bucketId}`,n,{headers:s.headers},r)})}async listV2(t,e){var r=this;return r.handleOperation(async()=>{const s=O({},t);return await X(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,s,{headers:r.headers},e)})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(t,e){return e.width&&t.set("width",e.width.toString()),e.height&&t.set("height",e.height.toString()),e.resize&&t.set("resize",e.resize),e.format&&t.set("format",e.format),e.quality&&t.set("qual
27ity",e.quality.toString()),t}};const Na="2.104.0",dt={"X-Client-Info":`storage-js/${Na}`};var Ia=class extends Ge{constructor(t,e={},r,s){const n=new URL(t);s?.useNewHostname&&/supabase\.(co|in|red)$/.test(n.hostname)&&!n.hostname.includes("storage.supabase.")&&(n.hostname=n.hostname.replace("supabase.","storage.supabase."));const i=n.href.replace(/\/$/,""),o=O(O({},dt),e);super(i,o,r,"storage")}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=e.listBucketOptionsToQueryString(t);return await it(e.fetch,`${e.url}/bucket${r}`,{headers:e.headers})})}async getBucket(t){var e=this;return e.handleOperation(async()=>await it(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}))}async createBucket(t,e={public:!1}){var r=this;return r.handleOperation(async()=>await X(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 kr(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 X(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Ir(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():""}},$a=class extends Ge{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=O(O({},dt),e);super(s,n,r,"storage")}async createBucket(t){var e=this;return e.handleOperation(async()=>await X(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}))}async listBuckets(t){var e=this;return e.handleOperation(async()=>{const r=new URLSearchParams;t?.limit!==void 0&&r.set("limit",t.limit.toString()),t?.offset!==void 0&&r.set("offset",t.offset.toString()),t?.sortColumn&&r.set("sortColumn",t.sortColumn),t?.sortOrder&&r.set("sortOrder",t.sortOrder),t?.search&&r.set("search",t.search);const s=r.toString(),n=s?`${e.url}/bucket?${s}`:`${e.url}/bucket`;return await it(e.fetch,n,{headers:e.headers})})}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await Ir(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}))}from(t){var e=this;if(!Ea(t))throw new qt("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 va({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),s=this.shouldThrowOnError;return new Proxy(r,{get(n,i){const o=n[i];return typeof o!="function"?o:async(...a)=>{try{return{data:await o.apply(n,a),error:null}}catch(l){if(s)throw l;return{data:null,error:l}}}}})}},La=class extends Ge{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=O(O({},dt),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async createIndex(t){var e=this;return e.handleOperation(async()=>await G.post(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{})}async getIndex(t,e){var r=this;return r.handleOperation(async()=>await G.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers}))}async listIndexes(t){var e=this;return e.handleOperation(async()=>await G.post(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}))}async deleteIndex(t,e){var r=this;return r.handleOperation(async()=>await G.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers})||{})}},Da=class extends Ge{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=O(O({},dt),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async putVectors(t){var e=this;if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return e.handleOperation(async()=>await G.post(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{})}async getVectors(t){var e=this;return e.handleOperation(async()=>await G.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");
27if(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 G.post(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}))}async queryVectors(t){var e=this;return e.handleOperation(async()=>await G.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 G.post(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{})}},Ua=class extends Ge{constructor(t,e={},r){const s=t.replace(/\/$/,""),n=O(O({},dt),{},{"Content-Type":"application/json"},e);super(s,n,r,"vectors")}async createBucket(t){var e=this;return e.handleOperation(async()=>await G.post(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}async getBucket(t){var e=this;return e.handleOperation(async()=>await G.post(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}))}async listBuckets(t={}){var e=this;return e.handleOperation(async()=>await G.post(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}))}async deleteBucket(t){var e=this;return e.handleOperation(async()=>await G.post(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{})}},Ba=class extends Ua{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new Ma(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)}},Ma=class extends La{constructor(t,e,r,s){super(t,e,s),this.vectorBucketName=r}async createIndex(t){var e=()=>super.createIndex,r=this;return e().call(r,O(O({},t),{},{vectorBucketName:r.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,r=this;return e().call(r,O(O({},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 Fa(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},Fa=class extends Da{constructor(t,e,r,s,n){super(t,e,n),this.vectorBucketName=r,this.indexName=s}async putVectors(t){var e=()=>super.putVectors,r=this;return e().call(r,O(O({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async getVectors(t){var e=()=>super.getVectors,r=this;return e().call(r,O(O({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,r=this;return e().call(r,O(O({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,r=this;return e().call(r,O(O({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,r=this;return e().call(r,O(O({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}},Wa=class extends Ia{constructor(t,e={},r,s){super(t,e,r,s)}from(t){return new ja(this.url,this.headers,t,this.fetch)}get vectors(){return new Ba(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new $a(this.url+"/iceberg",this.headers,this.fetch)}};const mn="2.104.0",Fe=30*1e3,Sr=3,tr=Sr*Fe,qa="http://localhost:9999",Ha="supabase.auth.token",za={"X-Client-Info":`gotrue-js/${mn}`},Er="X-Supabase-Api-Version",vn={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},Va=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,Ka=600*1e3;class ot extends Error{constructor(e,r,s){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=s}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function S(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class Ga extends ot{constructor(e,r,s){super(e,r,s),this.name="AuthApiError",this.status=r,this.co
27de=s}}function Ja(t){return S(t)&&t.name==="AuthApiError"}class Ee extends ot{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class oe extends ot{constructor(e,r,s,n){super(e,s,n),this.name=r,this.status=s}}class K extends oe{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function kt(t){return S(t)&&t.name==="AuthSessionMissingError"}class je extends oe{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class St extends oe{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class Et extends oe{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 Ya(t){return S(t)&&t.name==="AuthImplicitGrantRedirectError"}class fs extends oe{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 Xa extends oe{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 Tr extends oe{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function rr(t){return S(t)&&t.name==="AuthRetryableFetchError"}class ps extends oe{constructor(e,r,s){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=s}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class xr extends oe{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const Dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),gs=` 28\r=`.split(""),Za=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<gs.length;e+=1)t[gs[e].charCodeAt(0)]=-2;for(let e=0;e<Dt.length;e+=1)t[Dt[e].charCodeAt(0)]=e;return t})();function ms(t,e,r){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const s=e.queue>>e.queuedBits-6&63;r(Dt[s]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const s=e.queue>>e.queuedBits-6&63;r(Dt[s]),e.queuedBits-=6}}function bn(t,e,r){const s=Za[t];if(s>-1)for(e.queue=e.queue<<6|s,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(s===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function vs(t){const e=[],r=o=>{e.push(String.fromCodePoint(o))},s={utf8seq:0,codepoint:0},n={queue:0,queuedBits:0},i=o=>{tl(o,s,r)};for(let o=0;o<t.length;o+=1)bn(t.charCodeAt(o),n,i);return e.join("")}function Qa(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function el(t,e){for(let r=0;r<t.length;r+=1){let s=t.charCodeAt(r);if(s>55295&&s<=56319){const n=(s-55296)*1024&65535;s=(t.charCodeAt(r+1)-56320&65535|n)+65536,r+=1}Qa(s,e)}}function tl(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let s=1;s<6;s+=1)if((t>>7-s&1)===0){e.utf8seq=s;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function He(t){const e=[],r={queue:0,queuedBits:0},s=n=>{e.push(n)};for(let n=0;n<t.length;n+=1)bn(t.charCodeAt(n),r,s);return new Uint8Array(e)}function rl(t){const e=[];return el(t,r=>e.push(r)),new Uint8Array(e)}function Te(t){const e=[],r={queue:0,queuedBits:0},s=n=>{e.push(n)};return t.forEach(n=>ms(n,r,s)),ms(null,r,s),e.join("")}function sl(t){return Math.round(Date.now()/1e3)+t}function nl(){return Symbol("auth-callback")}const W=()=>typeof window<"u"&&typeof document<"u",we={tested:!1,writable:!1},yn=()=>
28{if(!W())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(we.tested)return we.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),we.tested=!0,we.writable=!0}catch{we.tested=!0,we.writable=!1}return we.writable};function il(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((n,i)=>{e[i]=n})}catch{}return r.searchParams.forEach((s,n)=>{e[n]=s}),e}const wn=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),ol=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",We=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},_e=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},F=async(t,e)=>{await t.removeItem(e)};class zt{constructor(){this.promise=new zt.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}zt.promiseConstructor=Promise;function Tt(t){const e=t.split(".");if(e.length!==3)throw new xr("Invalid JWT structure");for(let s=0;s<e.length;s++)if(!Va.test(e[s]))throw new xr("JWT not in base64url format");return{header:JSON.parse(vs(e[0])),payload:JSON.parse(vs(e[1])),signature:He(e[2]),raw:{header:e[0],payload:e[1]}}}async function al(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function ll(t,e){return new Promise((s,n)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await t(i);if(!e(i,null,o)){s(o);return}}catch(o){if(!e(i,o)){n(o);return}}})()})}function cl(t){return("0"+t.toString(16)).substr(-2)}function ul(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",s=r.length;let n="";for(let i=0;i<56;i++)n+=r.charAt(Math.floor(Math.random()*s));return n}return crypto.getRandomValues(e),Array.from(e,cl).join("")}async function dl(t){const r=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",r),n=new Uint8Array(s);return Array.from(n).map(i=>String.fromCharCode(i)).join("")}async function hl(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 dl(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Ne(t,e,r=!1){const s=ul();let n=s;r&&(n+="/PASSWORD_RECOVERY"),await We(t,`${e}-code-verifier`,n);const i=await hl(s);return[i,s===i?"plain":"s256"]}const fl=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function pl(t){const e=t.headers.get(Er);if(!e||!e.match(fl))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function gl(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 ml(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 vl=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Ie(t){if(!vl.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function sr(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const s=r.toString();if(s==="Symbol(Symbol.toPrimitive)"||s==="Symbol(Symbol.toStringTag)"||s==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function bl(t,e){return new Proxy(t,{get:(r,s,n)=>{if(s==="__isInsecureUserWarningProxy")return!0;
28if(typeof s=="symbol"){const i=s.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,s,n)}return!e.value&&typeof s=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),e.value=!0),Reflect.get(r,s,n)}})}function bs(t){return JSON.parse(JSON.stringify(t))}const Se=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),yl=[502,503,504,520,521,522,523,524,530];async function ys(t){var e;if(!ol(t))throw new Tr(Se(t),0);if(yl.includes(t.status))throw new Tr(Se(t),t.status);let r;try{r=await t.json()}catch(i){throw new Ee(Se(i),i)}let s;const n=pl(t);if(n&&n.getTime()>=vn["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?s=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(s=r.error_code),s){if(s==="weak_password")throw new ps(Se(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(s==="session_not_found")throw new K}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 ps(Se(r),t.status,r.weak_password.reasons);throw new Ga(Se(r),t.status||500,s)}const wl=(t,e,r,s)=>{const n={method:t,headers:e?.headers||{}};return t==="GET"?n:(n.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e?.headers),n.body=JSON.stringify(s),Object.assign(Object.assign({},n),r))};async function A(t,e,r,s){var n;const i=Object.assign({},s?.headers);i[Er]||(i[Er]=vn["2024-01-01"].name),s?.jwt&&(i.Authorization=`Bearer ${s.jwt}`);const o=(n=s?.query)!==null&&n!==void 0?n:{};s?.redirectTo&&(o.redirect_to=s.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",l=await _l(t,e,r+a,{headers:i,noResolveJson:s?.noResolveJson},{},s?.body);return s?.xform?s?.xform(l):{data:Object.assign({},l),error:null}}async function _l(t,e,r,s,n,i){const o=wl(e,s,n,i);let a;try{a=await t(r,Object.assign({},o))}catch(l){throw console.error(l),new Tr(Se(l),0)}if(a.ok||await ys(a),s?.noResolveJson)return a;try{return await a.json()}catch(l){await ys(l)}}function Y(t){var e;let r=null;El(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=sl(t.expires_in)));const s=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:s},error:null}}function ws(t){const e=Y(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,s)=>r&&typeof s=="string",!0)&&(e.data.weak_password=t.weak_password),e}function fe(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function kl(t){return{data:t,error:null}}function Sl(t){const{action_link:e,email_otp:r,hashed_token:s,redirect_to:n,verification_type:i}=t,o=Ke(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:r,hashed_token:s,redirect_to:n,verification_type:i},l=Object.assign({},o);return{data:{properties:a,user:l},error:null}}function _s(t){return t}function El(t){return t.access_token&&t.refresh_token&&t.expires_in}const nr=["global","local","others"];class Tl{constructor({url:e="",headers:r={},fetch:s}){this.url=e,this.headers=r,this.fetch=wn(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)}}async signOut(e,r=nr[0]){if(nr.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${nr.join(", ")}`);try{return await A(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(s){if(S(s))return{data:null,error:s};throw s}}async inviteUserByEmail(e,r={}){try{return await A(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:fe})}catch(s){if(S(s))return{data:{user:null},error:s};throw s}}async generateLink(e){try{const{options:r}=e,s=Ke(e,["options"]),n=Object.assign(Object.assign({},s),r);return"newEmail"in s&&(n.new_email=s?.newEmail,delete n.newEmail),await A(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:n,headers:this.headers,xform:Sl,redirectTo:r?.redirectTo})}catch(r){if(S(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await A(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:fe})}catch(r){if(S(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,s,n,i,o,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await A(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=e?.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(i=(n=e?.perPage)===null||n===void 0?void 0:n.toString())!==null&&i!==void 0?i:""},xform:_s});if(u.error)throw u.error;const d=await u.json(),h=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(b=>{const g=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),v=JSON.parse(b.split(";")[1].split("=")[1]);c[`${v}Page`]=g}),c.total=parseInt(h)),{data:Object.assign(Object.assign({},d),c),error:null}}catch(c){if(S(c))return{data:{users:[]},error:c};throw c}}async getUserById(e){Ie(e);try{return await A(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:fe})}catch(r){if(S(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){Ie(e);try{return await A(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:fe})}catch(s){if(S(s))return{data:{user:null},error:s};throw s}}async deleteUser(e,r=!1){Ie(e);
28try{return await A(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:fe})}catch(s){if(S(s))return{data:{user:null},error:s};throw s}}async _listFactors(e){Ie(e.userId);try{const{data:r,error:s}=await A(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:n=>({data:{factors:n},error:null})});return{data:r,error:s}}catch(r){if(S(r))return{data:null,error:r};throw r}}async _deleteFactor(e){Ie(e.userId),Ie(e.id);try{return{data:await A(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(S(r))return{data:null,error:r};throw r}}async _listOAuthClients(e){var r,s,n,i,o,a,l;try{const c={nextPage:null,lastPage:0,total:0},u=await A(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=e?.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(i=(n=e?.perPage)===null||n===void 0?void 0:n.toString())!==null&&i!==void 0?i:""},xform:_s});if(u.error)throw u.error;const d=await u.json(),h=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(l=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&l!==void 0?l:[];return f.length>0&&(f.forEach(b=>{const g=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),v=JSON.parse(b.split(";")[1].split("=")[1]);c[`${v}Page`]=g}),c.total=parseInt(h)),{data:Object.assign(Object.assign({},d),c),error:null}}catch(c){if(S(c))return{data:{clients:[]},error:c};throw c}}async _createOAuthClient(e){try{return await A(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(S(r))return{data:null,error:r};throw r}}async _getOAuthClient(e){try{return await A(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(S(r))return{data:null,error:r};throw r}}async _updateOAuthClient(e,r){try{return await A(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:r,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(S(s))return{data:null,error:s};throw s}}async _deleteOAuthClient(e){try{return await A(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(S(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(e){try{return await A(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(S(r))return{data:null,error:r};throw r}}async _listCustomProviders(e){try{const r={};return e?.type&&(r.type=e.type),await A(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:r,xform:s=>{var n;return{data:{providers:(n=s?.providers)!==null&&n!==void 0?n:[]},error:null}}})}catch(r){if(S(r))return{data:{providers:[]},error:r};throw r}}async _createCustomProvider(e){try{return await A(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(S(r))return{data:null,error:r};throw r}}async _getCustomProvider(e){try{return await A(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(S(r))return{data:null,error:r};throw r}}async _updateCustomProvider(e,r){try{return await A(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:r,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(S(s))return{data:null,error:s};throw s}}async _deleteCustomProvider(e){try{return await A(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(S(r))return{data:null,error:r};throw r}}}function ks(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}const Q={debug:!!(globalThis&&yn()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};
28class _n extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class Ss extends _n{}async function xl(t,e,r){Q.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const s=new globalThis.AbortController;let n;e>0&&(n=setTimeout(()=>{s.abort(),Q.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:s.signal},async i=>{if(i){clearTimeout(n),Q.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,i.name);try{return await r()}finally{Q.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,i.name)}}else{if(e===0)throw Q.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new Ss(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Q.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(n),await r()}})}catch(i){if(e>0&&clearTimeout(n),i?.name==="AbortError"&&e>0){if(s.signal.aborted)return Q.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){Q.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",t,o.name);try{return await r()}finally{Q.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 Q.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",t),new Ss(`Lock "${t}" was released because another request stole it`)}throw i}}function Al(){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 kn(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function Rl(t){return parseInt(t,16)}function Cl(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,s=>s.toString(16).padStart(2,"0")).join("")}function Ol(t){var e;const{chainId:r,domain:s,expirationTime:n,issuedAt:i=new Date,nonce:o,notBefore:a,requestId:l,resources:c,scheme:u,uri:d,version:h}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!s)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(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(h!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${h}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(` 29`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const f=kn(t.address),b=u?`${u}://${s}`:s,g=t.statement?`${t.statement} 30`:"",v=`${b} wants you to sign in with your Ethereum account: 31${f} 32 33${g}`;let y=`URI: ${d} 34Version: ${h} 35Chain ID: ${r}${o?` 36Nonce: ${o}`:""} 37Issued At: ${i.toISOString()}`;if(n&&(y+=` 38Expiration Time: ${n.toISOString()}`),a&&(y+=` 39Not Before: ${a.toISOString()}`),l&&(y+=` 40Request ID: ${l}`),c){let _=` 41Resources:`;
41for(const w of c){if(!w||typeof w!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${w}`);_+=` 42- ${w}`}y+=_}return`${v} 43${y}`}class U extends Error{constructor({message:e,code:r,cause:s,name:n}){var i;super(e,{cause:s}),this.__isWebAuthnError=!0,this.name=(i=n??(s instanceof Error?s.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=r}}class Ut extends U{constructor(e,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:e}),this.name="WebAuthnUnknownError",this.originalError=r}}function Pl({error:t,options:e}){var r,s,n;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 U({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 U({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((s=i.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new U({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new U({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 U({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new U({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 U({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new U({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(Sn(o)){if(i.rp.id!==o)return new U({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new U({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 U({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 U({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 U({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function jl({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 U({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new U({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const s=window.location.hostname;if(Sn(s)){if(r.rpId!==s)return new U({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new U({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new U({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ER
43ROR",cause:t})}return new U({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class Nl{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 Il=new Nl;function $l(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:r,excludeCredentials:s}=t,n=Ke(t,["challenge","user","excludeCredentials"]),i=He(e).buffer,o=Object.assign(Object.assign({},r),{id:He(r.id).buffer}),a=Object.assign(Object.assign({},n),{challenge:i,user:o});if(s&&s.length>0){a.excludeCredentials=new Array(s.length);for(let l=0;l<s.length;l++){const c=s[l];a.excludeCredentials[l]=Object.assign(Object.assign({},c),{id:He(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return a}function Ll(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:r}=t,s=Ke(t,["challenge","allowCredentials"]),n=He(e).buffer,i=Object.assign(Object.assign({},s),{challenge:n});if(r&&r.length>0){i.allowCredentials=new Array(r.length);for(let o=0;o<r.length;o++){const a=r[o];i.allowCredentials[o]=Object.assign(Object.assign({},a),{id:He(a.id).buffer,type:a.type||"public-key",transports:a.transports})}}return i}function Dl(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t;return{id:t.id,rawId:t.id,response:{attestationObject:Te(new Uint8Array(t.response.attestationObject)),clientDataJSON:Te(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Ul(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const r=t,s=t.getClientExtensionResults(),n=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:Te(new Uint8Array(n.authenticatorData)),clientDataJSON:Te(new Uint8Array(n.clientDataJSON)),signature:Te(new Uint8Array(n.signature)),userHandle:n.userHandle?Te(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:s,authenticatorAttachment:(e=r.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function Sn(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function Es(){var t,e;return!!(W()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator?.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator?.credentials)===null||e===void 0?void 0:e.get)=="function")}async function Bl(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Ut("Browser returned unexpected credential type",e)}:{data:null,error:new Ut("Empty credential response",e)}}catch(e){return{data:null,error:Pl({error:e,options:t})}}}async function Ml(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new Ut("Browser returned unexpected credential type",e)}:{data:null,error:new Ut("Empty credential response",e)}}catch(e){return{data:null,error:jl({error:e,options:t})}}}const Fl={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},Wl={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function Bt(...t){const e=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),r=n=>n instanceof ArrayBuffer||ArrayBuffer.isView(n),s={};for(const n of t)if(n)for(const i in n){const o=n[i];if(o!==void 0)if(Array.isArray(o))s[i]=o;else if(r(o))s[i]=o;else if(e(o)){const a=s[i];
43e(a)?s[i]=Bt(a,o):s[i]=Bt(o)}else s[i]=o}return s}function ql(t,e){return Bt(Fl,t,e||{})}function Hl(t,e){return Bt(Wl,t,e||{})}class zl{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:r,friendlyName:s,signal:n},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=n??Il.createNewAbortSignal();if(a.webauthn.type==="create"){const{user:u}=a.webauthn.credential_options.publicKey;if(!u.name){const d=s;if(d)u.name=`${u.id}:${d}`;else{const f=(await this.client.getUser()).data.user,b=((o=f?.user_metadata)===null||o===void 0?void 0:o.name)||f?.email||f?.id||"User";u.name=`${u.id}:${b}`}}u.displayName||(u.displayName=u.name)}switch(a.webauthn.type){case"create":{const u=ql(a.webauthn.credential_options.publicKey,i?.create),{data:d,error:h}=await Bl({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:h}}case"request":{const u=Hl(a.webauthn.credential_options.publicKey,i?.request),{data:d,error:h}=await Ml(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:h}}}}catch(a){return S(a)?{data:null,error:a}:{data:null,error:new Ee("Unexpected error in challenge",a)}}}async _verify({challengeId:e,factorId:r,webauthn:s}){return this.client.mfa.verify({factorId:r,challengeId:e,webauthn:s})}async _authenticate({factorId:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},i){if(!r)return{data:null,error:new ot("rpId is required for WebAuthn authentication")};try{if(!Es())return{data:null,error:new Ee("Browser does not support WebAuthn",null)};const{data:o,error:a}=await this.challenge({factorId:e,webauthn:{rpId:r,rpOrigins:s},signal:n},{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:s,credential_response:l.credential_response}})}catch(o){return S(o)?{data:null,error:o}:{data:null,error:new Ee("Unexpected error in authenticate",o)}}}async _register({friendlyName:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:s=typeof window<"u"?[window.location.origin]:void 0,signal:n}={}},i){if(!r)return{data:null,error:new ot("rpId is required for WebAuthn registration")};try{if(!Es())return{data:null,error:new Ee("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(h=>h.factor_type==="webauthn"&&h.friendly_name===e&&h.status!=="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId: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:s},signal:n},{create:i});return l?this._verify({factorId:o.id,challengeId:l.challengeId,webauthn:{rpId:r,rpOrigins:s,type:l.webauthn.type,credential_response:l.webauthn.credential_response}}):{data:null,error:c}}catch(o){return S(o)?{data:null,error:o}:{data:null,error:new Ee("Unexpected error in register",o)}}}}Al();const Vl={url:qa,storageKey:Ha,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:za,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1};async function Ts(t,e,r){return await r()}const $e={};class at{get jwks(){var e,r;return(r=(e=$e[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){$e[this.storageKey]=Object.assign(Object.assign({},$e[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=$e[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){$e[this.storageKey]=Object.assign(Object.assign({},$e[this.storageKey]),{cachedAt:e})}constructor(e){var r,s,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const i=Object.assign(Object.assign({},Vl),e);if(this.storageKey=i.storageKey,this.instanceID=(r=at.nextInstanceID[this.storageKey])!==null&&r!==void 0?r:0,at.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!i.debug,typeof i.debug=="function"&&(this.logger=i.debug),this.instanceID>0&&W()){const o=`${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(o),this.logDebugMessages&&console.trace(o)}if(this.persistSession=i.persistSession,this.autoRefreshToken=i.autoRefreshToken,this.admin=new Tl({url:i.url,headers:i.headers,fetch:i.fetch}),this.url=i.url,this.headers=i.headers,this.fetch=wn(i.fetch),this.lock=i.lock||Ts,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,this.throwOnError=i.throwOnError,this.lockAcquireTimeout=i.lockAcquireTimeout,i.lock?this.lock=i.lock:this.persistSession&&W()&&(!((s=globalThis?.navigator)===null||s===void 0)&&s.locks)?this.lock=xl:this.lock=Ts,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 zl(this)}
43,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.persistSession?(i.storage?this.storage=i.storage:yn()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=ks(this.memoryStorage)),i.userStorage&&(this.userStorage=i.userStorage)):(this.memoryStorage={},this.storage=ks(this.memoryStorage)),W()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o);try{await this._notifyAllSubscribers(o.data.event,o.data.session,!1)}catch(a){this._debug("#broadcastChannel","error",a)}})}i.skipAutoInitialize||this.initialize().catch(o=>{this._debug("#initialize()","error",o)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${mn}) ${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={},s="none";if(W()&&(r=il(window.location.href),this._isImplicitGrantCallback(r)?s="implicit":await this._isPKCECallback(r)&&(s="pkce")),W()&&this.detectSessionInUrl&&s!=="none"){const{data:n,error:i}=await this._getSessionFromURL(r,s);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),Ya(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}=n;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 S(r)?this._returnResult({error:r}):this._returnResult({error:new Ee("Unexpected error during initialization",r)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,s,n;try{const i=await A(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(s=(r=e?.options)===null||r===void 0?void 0:r.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:(n=e?.options)===null||n===void 0?void 0:n.captchaToken}},xform:Y}),{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(S(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signUp(e){var r,s,n;try{let i;if("email"in e){const{email:u,password:d,options:h}=e;let f=null,b=null;this.flowType==="pkce"&&([f,b]=await Ne(this.storage,this.storageKey)),i=await A(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:h?.emailRedirectTo,body:{email:u,password:d,data:(r=h?.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:h?.captchaToken},code_challenge:f,code_challenge_method:b},xform:Y})}else if("phone"in e){const{phone:u,password:d,options:h}=e;i=await A(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:d,data:(s=h?.data)!==null&&s!==void 0?s:{},channel:(n=h?.channel)!==null&&n!==void 0?n:"sms",gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:Y})}else throw new St("You must provide either an email or phone number and a password");const{data:o,error:a}=i;if(a||!o)return await F(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 F(this.storage,`${this.storageKey}-code-verifier`),S(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 A(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:ws})}else if("phone"in e){const{phone:i,password:o,options:a}=e;r=await A(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:a?.captchaToken}},xform:ws})}else throw new St("You must provide either an email or phone number and a password");const{data:s,error:n}=r;if(n)return this._returnResult({data:{user:null,session:null},error:n});if(!s||!s.session||!s.user){const i=new je;return this._returnResult({data:{user:null,session:null},error:i})}return s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),this._returnResult({data:Object.assign({user:s.user,session:s.session},s.weak_password?{weakPassword:s.weak_password}:null),error:n})}catch(r){if(S(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOAuth(e){var r,s,n,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(s=e.options)===null||s===void 0?void 0:s.scopes,queryParams:(n=e.options)===null||n===void 0?void 0:n.queryParams,skipBrowserRedirect:(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,s,n,i,o,a,l,c,u,d,h;let f,b;if("message"in e)f=e.message,b=e.signature;else{const{chain:g,wallet:v,statement:y,options:_}=e;let w;if(W())if(typeof v=="object")w=v;else{const I=window;if("ethereum"in I&&typeof I.ethereum=="object"&&"request"in I.ethereum&&typeof I.ethereum.request=="function")w=I.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof v!="object"||!_?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");w=v}const T=new URL((r=_?.url)!==null&&r!==void 0?r:window.location.href),N=await w.request({method:"eth_requestAccounts"}).then(I=>I).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!N||N.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const P=kn(N[0]);let R=(s=_?.signInWithEthereum)===null||s===void 0?void 0:s.chainId;if(!R){const I=await w.request({method:"eth_chainId"});R=Rl(I)}const x={domain:T.host,address:P,statement:y,uri:T.href,version:"1",chainId:R,nonce:(n=_?.signInWithEthereum)===null||n===void 0?void 0:n.nonce,issuedAt:(o=(i=_?.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(a=_?.
43signInWithEthereum)===null||a===void 0?void 0:a.expirationTime,notBefore:(l=_?.signInWithEthereum)===null||l===void 0?void 0:l.notBefore,requestId:(c=_?.signInWithEthereum)===null||c===void 0?void 0:c.requestId,resources:(u=_?.signInWithEthereum)===null||u===void 0?void 0:u.resources};f=Ol(x),b=await w.request({method:"personal_sign",params:[Cl(f),P]})}try{const{data:g,error:v}=await A(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:b},!((d=e.options)===null||d===void 0)&&d.captchaToken?{gotrue_meta_security:{captcha_token:(h=e.options)===null||h===void 0?void 0:h.captchaToken}}:null),xform:Y});if(v)throw v;if(!g||!g.session||!g.user){const y=new je;return this._returnResult({data:{user:null,session:null},error:y})}return g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("SIGNED_IN",g.session)),this._returnResult({data:Object.assign({},g),error:v})}catch(g){if(S(g))return this._returnResult({data:{user:null,session:null},error:g});throw g}}async signInWithSolana(e){var r,s,n,i,o,a,l,c,u,d,h,f;let b,g;if("message"in e)b=e.message,g=e.signature;else{const{chain:v,wallet:y,statement:_,options:w}=e;let T;if(W())if(typeof y=="object")T=y;else{const P=window;if("solana"in P&&typeof P.solana=="object"&&("signIn"in P.solana&&typeof P.solana.signIn=="function"||"signMessage"in P.solana&&typeof P.solana.signMessage=="function"))T=P.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 y!="object"||!w?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");T=y}const N=new URL((r=w?.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in T&&T.signIn){const P=await T.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},w?.signInWithSolana),{version:"1",domain:N.host,uri:N.href}),_?{statement:_}:null));let R;if(Array.isArray(P)&&P[0]&&typeof P[0]=="object")R=P[0];else if(P&&typeof P=="object"&&"signedMessage"in P&&"signature"in P)R=P;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in R&&"signature"in R&&(typeof R.signedMessage=="string"||R.signedMessage instanceof Uint8Array)&&R.signature instanceof Uint8Array)b=typeof R.signedMessage=="string"?R.signedMessage:new TextDecoder().decode(R.signedMessage),g=R.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in T)||typeof T.signMessage!="function"||!("publicKey"in T)||typeof T!="object"||!T.publicKey||!("toBase58"in T.publicKey)||typeof T.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");b=[`${N.host} wants you to sign in with your Solana account:`,T.publicKey.toBase58(),..._?["",_,""]:[""],"Version: 1",`URI: ${N.href}`,`Issued At: ${(n=(s=w?.signInWithSolana)===null||s===void 0?void 0:s.issuedAt)!==null&&n!==void 0?n:new Date().toISOString()}`,...!((i=w?.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${w.signInWithSolana.notBefore}`]:[],...!((o=w?.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${w.signInWithSolana.expirationTime}`]:[],...!((a=w?.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${w.signInWithSolana.chainId}`]:[],...!((l=w?.signInWithSolana)===null||l===void 0)&&l.nonce?[`Nonce: ${w.signInWithSolana.nonce}`]:[],...!((c=w?.signInWithSolana)===null||c===void 0)&&c.requestId?[`Request ID: ${w.signInWithSolana.requestId}`]:[],...!((d=(u=w?.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||d===void 0)&&d.length?["Resources",...w.signInWithSolana.resources.map(R=>`- ${R}`)]:[]].join(` 44`);const P=await T.signMessage(new TextEncoder().encode(b),"utf8");if(!P||!(P instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");g=P}}try{const{data:v,error:y}=await A(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:b,signature:Te(g)}
44,!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:Y});if(y)throw y;if(!v||!v.session||!v.user){const _=new je;return this._returnResult({data:{user:null,session:null},error:_})}return v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),this._returnResult({data:Object.assign({},v),error:y})}catch(v){if(S(v))return this._returnResult({data:{user:null,session:null},error:v});throw v}}async _exchangeCodeForSession(e){const r=await _e(this.storage,`${this.storageKey}-code-verifier`),[s,n]=(r??"").split("/");try{if(!s&&this.flowType==="pkce")throw new Xa;const{data:i,error:o}=await A(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:s},xform:Y});if(await F(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!i||!i.session||!i.user){const a=new je;return this._returnResult({data:{user:null,session:null,redirectType:null},error:a})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),this._returnResult({data:Object.assign(Object.assign({},i),{redirectType:n??null}),error:o})}catch(i){if(await F(this.storage,`${this.storageKey}-code-verifier`),S(i))return this._returnResult({data:{user:null,session:null,redirectType:null},error:i});throw i}}async signInWithIdToken(e){try{const{options:r,provider:s,token:n,access_token:i,nonce:o}=e,a=await A(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:s,id_token:n,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:r?.captchaToken}},xform:Y}),{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 je;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(S(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOtp(e){var r,s,n,i,o;try{if("email"in e){const{email:a,options:l}=e;let c=null,u=null;this.flowType==="pkce"&&([c,u]=await Ne(this.storage,this.storageKey));const{error:d}=await A(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(r=l?.data)!==null&&r!==void 0?r:{},create_user:(s=l?.shouldCreateUser)!==null&&s!==void 0?s:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},code_challenge:c,code_challenge_method:u},redirectTo: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 A(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(n=l?.data)!==null&&n!==void 0?n:{},create_user:(i=l?.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:l?.captchaToken},channel:(o=l?.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:c?.message_id},error:u})}throw new St("You must provide either an email or phone number.")}catch(a){if(await F(this.storage,`${this.storageKey}-code-verifier`),S(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async verifyOtp(e){var r,s;try{let n,i;"options"in e&&(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo,i=(s=e.options)===null||s===void 0?void 0:s.captchaToken);const{data:o,error:a}=await A(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:n,xform:Y});if(a)throw a;if(!o)throw new Error("An error occurred on token verification.");const l=o.session,c=o.user;return l?.access_token&&(await this._saveSession(l),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",l)),this._returnResult({data:{user:c,session:l},error:null})}catch(n){if(S(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithSSO(e){var r,s,n,i,o;try{let a=null,l=null;this.flowType==="pkce"&&([a,l]=await Ne(this.storage,this.storageKey));const c=await A(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:(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&s!==void 0?s:void 0}),!((n=e?.options)===null||n===void 0)&&n.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:kl});return!((i=c.data)===null||i===void 0)&&i.url&&W()&&!(!((o=e.options)===null||o===void 0)&&o.skipBrowserRedirect)&&window.location.assign(c.data.url),this._returnResult(c)}catch(a){if(await F(this.storage,`${this.storageKey}-code-verifier`),S(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:s}=e;if(s)throw s;if(!r)throw new K;const{error:n}=await A(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return this._returnResult({data:{user:null,session:null},error:n})})}catch(e){if(S(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:s,type:n,options:i}=e,{error:o}=await A(this.fetch,"POST",r,{headers:this.headers,body:{email:s,type:n,gotrue_meta_security:{captcha_token:i?.captchaToken}},redirectTo:i?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in e){const{phone:s,type:n,options:i}=e,{data:o,error:a}=await A(this.fetch,"POST",r,{headers:this.headers,body:{phone:s,type:n,gotrue_meta_security:{captcha_token:i?.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o?.message_id},error:a})}throw new St("You must provide either an email or phone number and a type")}catch(r){if(S(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 s=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=(async()=>(await s,await r()))();return this.pendingInLock.push((async()=>{try{await n}catch{}})()),n}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const s=r();for(this.pendingInLock.push((async()=>{try{await s}catch{}})()),await s;this.pendingInLock.length;){const n=[...this.pendingInLock];await Promise.all(n),this.pendingInLock.splice(0,n.length)}return await s}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await _e(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 val
44id"),await this._removeSession())),!e)return{data:{session:null},error:null};const s=e.expires_at?e.expires_at*1e3-Date.now()<tr:!1;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",e.expires_at),!s){if(this.userStorage){const o=await _e(this.userStorage,this.storageKey+"-user");o?.user?e.user=o.user:e.user=sr()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};e.user=bl(e.user,o),o.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{session:null},error:i}):this._returnResult({data:{session:n},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const r=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return r.data.user&&(this.suppressGetSessionWarning=!0),r}async _getUser(e){try{return e?await A(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:fe}):await this._useSession(async r=>{var s,n,i;const{data:o,error:a}=r;if(a)throw a;return!(!((s=o.session)===null||s===void 0)&&s.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new K}:await A(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&i!==void 0?i:void 0,xform:fe})})}catch(r){if(S(r))return kt(r)&&(await this._removeSession(),await F(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 s=>{const{data:n,error:i}=s;if(i)throw i;if(!n.session)throw new K;const o=n.session;let a=null,l=null;this.flowType==="pkce"&&e.email!=null&&([a,l]=await Ne(this.storage,this.storageKey));const{data:c,error:u}=await A(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:l}),jwt:o.access_token,xform:fe});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(s){if(await F(this.storage,`${this.storageKey}-code-verifier`),S(s))return this._returnResult({data:{user:null},error:s});throw s}}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 K;const r=Date.now()/1e3;let s=r,n=!0,i=null;const{payload:o}=Tt(e.access_token);if(o.exp&&(s=o.exp,n=s<=r),n){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:s-r,expires_at:s},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(r){if(S(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 s;if(!e){const{data:o,error:a}=r;if(a)throw a;e=(s=o.session)!==null&&s!==void 0?s:void 0}if(!e?.refresh_token)throw new K;const{data:n,error:i}=await this._callRefreshToken(e.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):n?this._returnResult({data:{user:n.user,session:n},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(r){if(S(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async _getSessionFromURL(e,r){try{if(!W())throw new Et("No browser detected.");
44if(e.error||e.error_description||e.error_code)throw new Et(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 fs("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Et("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 fs("No code detected.");const{data:_,error:w}=await this._exchangeCodeForSession(e.code);if(w)throw w;const T=new URL(window.location.href);return T.searchParams.delete("code"),window.history.replaceState(window.history.state,"",T.toString()),{data:{session:_.session,redirectType:null},error:null}}const{provider_token:s,provider_refresh_token:n,access_token:i,refresh_token:o,expires_in:a,expires_at:l,token_type:c}=e;if(!i||!a||!o||!c)throw new Et("No session defined in URL");const u=Math.round(Date.now()/1e3),d=parseInt(a);let h=u+d;l&&(h=parseInt(l));const f=h-u;f*1e3<=Fe&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${f}s, should have been closer to ${d}s`);const b=h-d;u-b>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",b,h,u):u-b<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",b,h,u);const{data:g,error:v}=await this._getUser(i);if(v)throw v;const y={provider_token:s,provider_refresh_token:n,access_token:i,expires_in:d,expires_at:h,refresh_token:o,token_type:c,user:g.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:y,redirectType:e.type},error:null})}catch(s){if(S(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 _e(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 s;const{data:n,error:i}=r;if(i&&!kt(i))return this._returnResult({error:i});const o=(s=n.session)===null||s===void 0?void 0:s.access_token;if(o){const{error:a}=await this.admin.signOut(o,e);if(a&&!(Ja(a)&&(a.status===404||a.status===401||a.status===403)||kt(a)))return this._returnResult({error:a})}return e!=="others"&&(await this._removeSession(),await F(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const r=nl(),s={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,s),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:s}}}async _emitInitialSession(e){return await this._useSession(async r=>{var s,n;try{const{data:{session:i},error:o}=r;if(o)throw o;await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),kt(i)?console.warn(i):console.error(i)}})}async resetPasswordForEmail(e,r={}){let s=null,n=null;this.flowType==="pkce"&&([s,n]=await Ne(this.storage,this.storageKey,!0));try{return await A(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:s,code_challenge_method:n,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(i){if(await F(this.storage,`${this.storageKey}-code-verifier`),S(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var e;try{const{data:r,error:s}=await this.getUser();if(s)throw s;return this._returnResult({data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(r){if(S(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:s,error:n}=await this._useSession(async i=>{var o,a,l,c,u;const{data:d,error:h}=i;if(h)throw h;const f=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 A(this.fetch,"GET",f,{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(n)throw n;return W()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(s?.url),this._returnResult({data:{provider:e.provider,url:s?.url},error:null})}catch(s){if(S(s))return this._returnResult({data:{provider:e.provider,url:null},error:s});throw s}}async linkIdentityIdToken(e){return await this._useSession(async r=>{var s;try{const{error:n,data:{session:i}}=r;if(n)throw n;const{options:o,provider:a,token:l,access_token:c,nonce:u}=e,d=await A(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(s=i?.access_token)!==null&&s!==void 0?s:void 0,body:{provider:a,id_token:l,access_token:c,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:o?.captchaToken}},xform:Y}),{data:h,error:f}=d;return f?this._returnResult({data:{user:null,session:null},error:f}):!h||!h.session||!h.user?this._returnResult({data:{user:null,session:null},error:new je}):(h.session&&(await this._saveSession(h.session),await this._notifyAllSubscribers("USER_UPDATED",h.session)),this._returnResult({data:h,error:f}))}catch(n){if(await F(this.storage,`${this.storageKey}-code-verifier`),S(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}})}async unlinkIdentity(e){try{return await this._useSession(async r=>{var s,n;const{data:i,error:o}=r;if(o)throw o;
44return await A(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(n=(s=i.session)===null||s===void 0?void 0:s.access_token)!==null&&n!==void 0?n:void 0})})}catch(r){if(S(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 s=Date.now();return await ll(async n=>(n>0&&await al(200*Math.pow(2,n-1)),this._debug(r,"refreshing attempt",n),await A(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Y})),(n,i)=>{const o=200*Math.pow(2,n);return i&&rr(i)&&Date.now()+o-s<Fe})}catch(s){if(this._debug(r,"error",s),S(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){const s=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",s),W()&&!r.skipBrowserRedirect&&window.location.assign(s),{data:{provider:e,url:s},error:null}}async _recoverAndRefresh(){var e,r;const s="#_recoverAndRefresh()";this._debug(s,"begin");try{const n=await _e(this.storage,this.storageKey);if(n&&this.userStorage){let o=await _e(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:n.user},await We(this.userStorage,this.storageKey+"-user",o)),n.user=(e=o?.user)!==null&&e!==void 0?e:sr()}else if(n&&!n.user&&!n.user){const o=await _e(this.storage,this.storageKey+"-user");o&&o?.user?(n.user=o.user,await F(this.storage,this.storageKey+"-user"),await We(this.storage,this.storageKey,n)):n.user=sr()}if(this._debug(s,"session from storage",n),!this._isValidSession(n)){this._debug(s,"session is not valid"),n!==null&&await this._removeSession();return}const i=((r=n.expires_at)!==null&&r!==void 0?r:1/0)*1e3-Date.now()<tr;if(this._debug(s,`session has${i?"":" not"} expired with margin of ${tr}s`),i){if(this.autoRefreshToken&&n.refresh_token){const{error:o}=await this._callRefreshToken(n.refresh_token);o&&(console.error(o),rr(o)||(this._debug(s,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else if(n.user&&n.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:a}=await this._getUser(n.access_token);!a&&o?.user?(n.user=o.user,await this._saveSession(n),await this._notifyAllSubscribers("SIGNED_IN",n)):this._debug(s,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(s,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(s,"error",n),console.error(n);return}finally{this._debug(s,"end")}}async _callRefreshToken(e){var r,s;if(!e)throw new K;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const n=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(n,"begin");try{this.refreshingDeferred=new zt;const{data:i,error:o}=await this._refreshAccessToken(e);if(o)throw o;if(!i.session)throw new K;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const a={data:i.session,error:null};return this.refreshingDeferred.resolve(a),a}catch(i){if(this._debug(n,"error",i),S(i)){const o={data:null,error:i};return rr(i)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(o),o}throw(s=this.refreshingDeferred)===null||s===void 0||s.reject(i),i}finally{this.refreshingDeferred=null,this._debug(n,"end")}}async _notifyAllSubscribers(e,r,s=!0){const n=`#_notifyAllSubscribers(${e})`;this._debug(n,"begin",r,`broadcast = ${s}`);try{this.broadcastChannel&&s&&this.broadcastChannel.postMessage({event:e,session:r});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async a=>{try{await a.callback(e,r)}catch(l){i.push(l)}});if(await Promise.all(o),i.length>0){for(let a=0;a<i.length;a+=1)console.error(i[a]);throw i[0]}}finally{this._debug(n,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await F(this.storage,`${this.storageKey}-code-verifier`);const r=Object.assign({},e),s=r.user&&r.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!s&&r.user&&await We(this.userStorage,this.storageKey+"-user",{user:r.user});const n=Object.assign({},r);delete n.user;const i=bs(n);await We(this.storage,this.storageKey,i)}else{const n=bs(r);await We(this.storage,this.storageKey,n)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await F(this.storage,this.storageKey),await F(this.storage,this.storageKey+"-code-verifier"),await F(this.storage,this.storageKey+"-user"),this.userStorage&&await F(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&W()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}
44catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Fe);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:s}}=r;if(!s||!s.refresh_token||!s.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const n=Math.floor((s.expires_at*1e3-e)/Fe);this._debug("#_autoRefreshTokenTick()",`access token expires in ${n} ticks, a tick lasts ${Fe}ms, refresh threshold is ${Sr} ticks`),n<=Sr&&await this._callRefreshToken(s.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof _n)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!W()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;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,s){const n=[`provider=${encodeURIComponent(r)}`];if(s?.redirectTo&&n.push(`redirect_to=${encodeURIComponent(s.redirectTo)}`),s?.scopes&&n.push(`scopes=${encodeURIComponent(s.scopes)}`),this.flowType==="pkce"){const[i,o]=await Ne(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});n.push(a.toString())}if(s?.queryParams){const i=new URLSearchParams(s.queryParams);n.push(i.toString())}return s?.skipBrowserRedirect&&n.push(`skip_http_redirect=${s.skipBrowserRedirect}`),`${e}?${n.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var s;const{data:n,error:i}=r;return i?this._returnResult({data:null,error:i}):await A(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(s=n?.session)===null||s===void 0?void 0:s.access_token})})}catch(r){if(S(r))return this._returnResult({data:null,error:r});throw r}}async _enroll(e){try{return await this._useSession(async r=>{var s,n;const{data: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 A(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(s=i?.session)===null||s===void 0?void 0:s.access_token});return c?this._returnResult({data:null,error:c}):(e.factorType==="totp"&&l.type==="totp"&&(!((n=l?.totp)===null||n===void 0)&&n.qr_code)&&(l.totp.qr_code=`data:image/svg+xml;utf-8,${l.totp.qr_code}`),this._returnResult({data:l,error:null}))})}catch(r){if(S(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 s;const{data:n,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"?Dl(e.webauthn.credential_response):Ul(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:l}=await A(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:o,headers:this.headers,jwt:(s=n?.session)===null||s===void 0?void 0:s.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(S(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 s;const{data:n,error:i}=r;if(i)return this._returnResult({data:null,error:i});const o=await A(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(s=n?.session)===null||s===void 0?void 0:s.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:$l(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:Ll(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(S(r))return this._returnResult({data:null,error:r});throw r}})}async _challengeAndVerify(e){const{data:r,error:s}=await this._challenge({factorId:e.factorId});return s?this._returnResult({data:null,error:s}):await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){var e;const{data:{user:r},error:s}=await this.getUser();if(s)return{data:null,error:s};const n={all:[],phone:[],totp:[],webauthn:[]};for(const i of(e=r?.factors)!==null&&e!==void 0?e:[])n.all.push(i),i.status==="verified"&&n[i.factor_type].push(i);return{data:n,error:null}}async _getAuthenticatorAssuranceLevel(e){var r,s,n,i;if(e)try{const{payload:f}=Tt(e);let b=null;f.aal&&(b=f.aal);let g=b;const{data:{user:v},error:y}=await this.getUser(e);if(y)return this._returnResult({data:null,error:y});((s=(r=v?.factors)===null||r===void 0?void 0:r.filter(T=>T.status==="verified"))!==null&&s!==void 0?s:[]).length>0&&(g="aal2");const w=f.amr||[];return{data:{currentLevel:b,nextLevel:g,currentAuthenticationMethods:w},error:null}}catch(f){if(S(f))return this._returnResult({data:null,error:f});throw f}const{data:{session:o},error:a}
44=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}=Tt(o.access_token);let c=null;l.aal&&(c=l.aal);let u=c;((i=(n=o.user.factors)===null||n===void 0?void 0:n.filter(f=>f.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(u="aal2");const h=l.amr||[];return{data:{currentLevel:c,nextLevel:u,currentAuthenticationMethods:h},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;return n?this._returnResult({data:null,error:n}):s?await A(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:s.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new K})})}catch(r){if(S(r))return this._returnResult({data:null,error:r});throw r}}async _approveAuthorization(e,r){try{return await this._useSession(async s=>{const{data:{session:n},error:i}=s;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new K});const o=await A(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"approve"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&W()&&!r?.skipBrowserRedirect&&window.location.assign(o.data.redirect_url),o})}catch(s){if(S(s))return this._returnResult({data:null,error:s});throw s}}async _denyAuthorization(e,r){try{return await this._useSession(async s=>{const{data:{session:n},error:i}=s;if(i)return this._returnResult({data:null,error:i});if(!n)return this._returnResult({data:null,error:new K});const o=await A(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:n.access_token,body:{action:"deny"},xform:a=>({data:a,error:null})});return o.data&&o.data.redirect_url&&W()&&!r?.skipBrowserRedirect&&window.location.assign(o.data.redirect_url),o})}catch(s){if(S(s))return this._returnResult({data:null,error:s});throw s}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:r},error:s}=e;return s?this._returnResult({data:null,error:s}):r?await A(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,xform:n=>({data:n,error:null})}):this._returnResult({data:null,error:new K})})}catch(e){if(S(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async r=>{const{data:{session:s},error:n}=r;return n?this._returnResult({data:null,error:n}):s?(await A(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new K})})}catch(r){if(S(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(e,r={keys:[]}){let s=r.keys.find(a=>a.kid===e);if(s)return s;const n=Date.now();if(s=this.jwks.keys.find(a=>a.kid===e),s&&this.jwks_cached_at+Ka>n)return s;const{data:i,error:o}=await A(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=n,s=i.keys.find(a=>a.kid===e),!s)?null:s}async getClaims(e,r={}){try{let s=e;if(!s){const{data:f,error:b}
44=await this.getSession();if(b||!f.session)return this._returnResult({data:null,error:b});s=f.session.access_token}const{header:n,payload:i,signature:o,raw:{header:a,payload:l}}=Tt(s);r?.allowExpired||gl(i.exp);const c=!n.alg||n.alg.startsWith("HS")||!n.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(n.kid,r?.keys?{keys:r.keys}:r?.jwks);if(!c){const{error:f}=await this.getUser(s);if(f)throw f;return{data:{claims:i,header:n,signature:o},error:null}}const u=ml(n.alg),d=await crypto.subtle.importKey("jwk",c,u,!0,["verify"]);if(!await crypto.subtle.verify(u,d,o,rl(`${a}.${l}`)))throw new xr("Invalid JWT signature");return{data:{claims:i,header:n,signature:o},error:null}}catch(s){if(S(s))return this._returnResult({data:null,error:s});throw s}}}at.nextInstanceID={};const Kl=at,Gl="2.104.0";let Ze="";typeof Deno<"u"?Ze="deno":typeof document<"u"?Ze="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Ze="react-native":Ze="node";const Jl={"X-Client-Info":`supabase-js-${Ze}/${Gl}`},Yl={headers:Jl},Xl={schema:"public"},Zl={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Ql={};function lt(t){"@babel/helpers - typeof";return lt=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},lt(t)}function ec(t,e){if(lt(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var s=r.call(t,e);if(lt(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function tc(t){var e=ec(t,"string");return lt(e)=="symbol"?e:e+""}function rc(t,e,r){return(e=tc(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function xs(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,s)}return r}function D(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?xs(Object(r),!0).forEach(function(s){rc(t,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):xs(Object(r)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(r,s))})}return t}const sc=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),nc=()=>Headers,ic=(t,e,r)=>{const s=sc(r),n=nc();return async(i,o)=>{var a;const l=(a=await e())!==null&&a!==void 0?a:t;let c=new n(o?.headers);return c.has("apikey")||c.set("apikey",t),c.has("Authorization")||c.set("Authorization",`Bearer ${l}`),s(i,D(D({},o),{},{headers:c}))}};function oc(t){return t.endsWith("/")?t:t+"/"}function ac(t,e){var r,s;const{db:n,auth:i,realtime:o,global:a}=t,{db:l,auth:c,realtime:u,global:d}=e,h={db:D(D({},l),n),auth:D(D({},c),i),realtime:D(D({},u),o),storage:{},global:D(D(D({},d),a),{},{headers:D(D({},(r=d?.headers)!==null&&r!==void 0?r:{}),(s=a?.headers)!==null&&s!==void 0?s:{})}),accessToken:async()=>""};return t.accessToken?h.accessToken=t.accessToken:delete h.accessToken,h}function lc(t){const e=t?.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(oc(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var cc=class extends Kl{constructor(t){super(t)}},uc=class{constructor(t,e,r){var s,n;this.supabaseUrl=t,this.supabaseKey=e;const i=lc(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:Xl,realtime:Ql,auth:D(D({},Zl),{},{storageKey:o}),global:Yl},l=ac(r??{},a);if(this.storageKey=(s=l.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(n=l.global.headers)!==null&&n!==void 0?n:{},l.accessToken)this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(u,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=ic(e,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(D({headers:this.headers,accessToken:this._getAccessToken.bind(this)},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 Po(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 Wa(this.storageUrl.href,this.headers,this.fetch,r?.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new _o(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:s}=await t.auth.getSession();return(e=(r=s.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:s,userStorage:n,storageKey:i,flowType:o,lock:a,debug:l,throwOnError:c},u,d){const h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new cc({url:this.authUrl.href,headers:D(D({},h),u),storageKey:i,autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:s,userStorage:n,flowType:o,lock:a,debug:l,throwOnError:c,fetch:d,hasCustomAuthorizationHeader:Object.keys(this.headers).some(f=>f.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new da(this.realtimeUrl.href,D(D({},t),{},{params:D(D({},{apikey:this.supabaseKey}),t?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e?.access_token)})}_handleTokenChanged(t,e,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&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 dc=(t,e,r)=>new uc(t,e,r);function hc(){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}hc()&&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 N
44ode.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");function fc(){return dc("https://wrpxwmhygzltfyspnwbj.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndycHh3bWh5Z3psdGZ5c3Bud2JqIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzYzNjU3MDgsImV4cCI6MjA5MTk0MTcwOH0.bZtqLBcROFWRvU4rIqwcVwGqkfBcsGEDqGpO1PNcAyI",{auth:{storage:typeof window<"u"?localStorage:void 0,persistSession:!0,autoRefreshToken:!0}})}let ir;const ke=new Proxy({},{get(t,e,r){return ir||(ir=fc()),Reflect.get(ir,e,r)}});function pc(){const[t,e]=p.useState(null),[r,s]=p.useState(!0),[n,i]=p.useState("free"),o=p.useRef(!1);p.useEffect(()=>{let l=!0,c=null,u=null;async function d(v){const{data:y}=await ke.rpc("get_plan_tier",{_user_id:v});l&&typeof y=="string"&&i(y)}function h(){c&&(ke.removeChannel(c),c=null),u=null}function f(v){if(u===v)return;h(),u=v;const y=`subscriptions-${v}-${Date.now()}-${Math.random().toString(36).slice(2)}`;c=ke.channel(y).on("postgres_changes",{event:"*",schema:"public",table:"subscriptions",filter:`user_id=eq.${v}`},()=>{d(v)}).subscribe()}const{data:b}=ke.auth.onAuthStateChange((v,y)=>{if(!l)return;if(v==="SIGNED_OUT"&&o.current&&typeof window<"u"){window.location.reload();return}const _=y?.user??null;o.current=!!_,e(_),_?window.setTimeout(()=>{d(_.id),f(_.id)},0):(i("free"),h()),s(!1)}),g=async()=>{if(typeof document>"u"||document.visibilityState!=="visible"||!o.current)return;const{data:v,error:y}=await ke.auth.getSession();l&&(y||!v.session)&&window.location.reload()};return typeof document<"u"&&document.addEventListener("visibilitychange",g),ke.auth.getSession().then(({data:{session:v}})=>{if(!l)return;const y=v?.user??null;o.current=!!y,e(y),y?(d(y.id),f(y.id)):(i("free"),h()),s(!1)}),()=>{l=!1,b.subscription.unsubscribe(),h(),typeof document<"u"&&document.removeEventListener("visibilitychange",g)}},[]);async function a(){if(!t)return;const{data:l}=await ke.rpc("get_plan_tier",{_user_id:t.id});typeof l=="string"&&i(l)}return{user:t,loading:r,planTier:n,refreshPlan:a}}function pe(t,e,{checkForDefaultPrevented:r=!0}={}){return function(n){if(t?.(n),r===!1||!n.defaultPrevented)return e?.(n)}}function gc(t,e){const r=p.createContext(e),s=i=>{const{children:o,...a}=i,l=p.useMemo(()=>a,Object.values(a));return m.jsx(r.Provider,{value:l,children:o})};s.displayName=t+"Provider";function n(i){const o=p.useContext(r);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[s,n]}function mc(t,e=[]){let r=[];function s(i,o){const a=p.createContext(o),l=r.length;r=[...r,o];const c=d=>{const{scope:h,children:f,...b}=d,g=h?.[t]?.[l]||a,v=p.useMemo(()=>b,Object.values(b));return m.jsx(g.Provider,{value:v,children:f})};c.displayName=i+"Provider";function u(d,h){const f=h?.[t]?.[l]||a,b=p.useContext(f);if(b)return b;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[c,u]}const n=()=>{const i=r.map(o=>p.createContext(o));return function(a){const l=a?.[t]||i;return p.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return n.scopeName=t,[s,vc(n,...e)]}function vc(...t){const e=t[0];if(t.length===1)return e;const r=()=>{const s=t.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const o=s.reduce((a,{useScope:l,scopeName:c})=>{const d=l(i)[`__scope${c}`];return{...a,...d}},{});return p.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return r.scopeName=e.scopeName,r}var ct=globalThis?.document?p.useLayoutEffect:()=>{},bc=Cr[" useId ".trim().toString()]||(()=>{}),yc=0;function or(t){const[e,r]=p.useState(bc());return ct(()=>{r(s=>s??String(yc++))},[t]),t||(e?`radix-${e}`:"")}var wc=Cr[" useInsertionEffect ".trim().toString()]||ct;function _c({prop:t,defaultProp:e,onChange:r=()=>{},caller:s}){const[n,i,o]=kc({defaultProp:e,onChange:r}),a=t!==void 0,l=a?t:n;{const u=p.useRef(t!==void 0);p.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${s} 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,s])}const c=p.useCallback(u=>{if(a){const d=Sc(u)?u(t):u;d!==t&&o.current?.(d)}else i(u)},[a,t,i,o]);return[l,c]}function kc({defaultProp:t,onChange:e}){const[r,s]=p.useState(t),n=p.useRef(r),i=p.useRef(e);return wc(()=>{i.current=e},[e]),p.useEffect(()=>{n.current!==r&&(i.current?.(r),n.current=r)},[r,n]),[r,s,i]}function Sc(t){return typeof t=="function"}function Ec(t){const e=Tc(t),r=p.forwardRef((s,n)=>{const{children:i,...o}=s,a=p.Children.toArray(i),l=a.find(Ac);if(l){const c=l.props.children,u=a.map(d=>d===l?p.Children.count(c)>1?p.Children.only(null):p.isValidElement(c)?c.props.children:null:d);return m.jsx(e,{...o,ref:n,children:p.isValidElement(c)?p.cloneElement(c,void 0,u):null})}return m.jsx(e,{...o,ref:n,children:i})});return r.displayName=`${t}.Slot`,r}function Tc(t){const e=p.forwardRef((r,s)=>{const{children:n,...i}=r;if(p.isValidElement(n)){const o=Cc(n),a=Rc(i,n.props);return n.type!==p.Fragment&&(a.ref=s?Wt(s,o):o),p.cloneElement(n,a)}return p.Children.count(n)>1?p.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var xc=Symbol("radix.slottable");function Ac(t){return p.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===xc}function Rc(t,e){const r={...e};for(const s in e){const n=t[s],i=e[s];/^on[A-Z]/.test(s)?n&&i?r[s]=(...a)=>{const l=i(...a);return n(...a),l}:n&&(r[s]=n):s==="style"?r[s]={...n,...i}
vendor: 7,900 bytes, line 44
44:s==="className"&&(r[s]=[n,i].filter(Boolean).join(" "))}return{...t,...r}}function Cc(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var Oc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ae=Oc.reduce((t,e)=>{const r=Ec(`Primitive.${e}`),s=p.forwardRef((n,i)=>{const{asChild:o,...a}=n,l=o?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...a,ref:i})});return s.displayName=`Primitive.${e}`,{...t,[e]:s}},{});function Pc(t,e){t&&li.flushSync(()=>t.dispatchEvent(e))}function ut(t){const e=p.useRef(t);return p.useEffect(()=>{e.current=t}),p.useMemo(()=>(...r)=>e.current?.(...r),[])}function jc(t,e=globalThis?.document){const r=ut(t);p.useEffect(()=>{const s=n=>{n.key==="Escape"&&r(n)};return e.addEventListener("keydown",s,{capture:!0}),()=>e.removeEventListener("keydown",s,{capture:!0})},[r,e])}var Nc="DismissableLayer",Ar="dismissableLayer.update",Ic="dismissableLayer.pointerDownOutside",$c="dismissableLayer.focusOutside",As,En=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Tn=p.forwardRef((t,e)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:n,onFocusOutside:i,onInteractOutside:o,onDismiss:a,...l}=t,c=p.useContext(En),[u,d]=p.useState(null),h=u?.ownerDocument??globalThis?.document,[,f]=p.useState({}),b=Ae(e,R=>d(R)),g=Array.from(c.layers),[v]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),_=u?g.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,T=_>=y,N=Uc(R=>{const x=R.target,I=[...c.branches].some(le=>le.contains(x));!T||I||(n?.(R),o?.(R),R.defaultPrevented||a?.())},h),P=Bc(R=>{const x=R.target;[...c.branches].some(le=>le.contains(x))||(i?.(R),o?.(R),R.defaultPrevented||a?.())},h);return jc(R=>{_===c.layers.size-1&&(s?.(R),!R.defaultPrevented&&a&&(R.preventDefault(),a()))},h),p.useEffect(()=>{if(u)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(As=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),Rs(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=As)}},[u,h,r,c]),p.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),Rs())},[u,c]),p.useEffect(()=>{const R=()=>f({});return document.addEventListener(Ar,R),()=>document.removeEventListener(Ar,R)},[]),m.jsx(ae.div,{...l,ref:b,style:{pointerEvents:w?T?"auto":"none":void 0,...t.style},onFocusCapture:pe(t.onFocusCapture,P.onFocusCapture),onBlurCapture:pe(t.onBlurCapture,P.onBlurCapture),onPointerDownCapture:pe(t.onPointerDownCapture,N.onPointerDownCapture)})});Tn.displayName=Nc;var Lc="DismissableLayerBranch",Dc=p.forwardRef((t,e)=>{const r=p.useContext(En),s=p.useRef(null),n=Ae(e,s);return p.useEffect(()=>{const i=s.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),m.jsx(ae.div,{...t,ref:n})});Dc.displayName=Lc;function Uc(t,e=globalThis?.document){const r=ut(t),s=p.useRef(!1),n=p.useRef(()=>{});return p.useEffect(()=>{const i=a=>{if(a.target&&!s.current){let l=function(){xn(Ic,r,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",n.current),n.current=l,e.addEventListener("click",n.current,{once:!0})):l()}else e.removeEventListener("click",n.current);s.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",n.current)}},[e,r]),{onPointerDownCapture:()=>s.current=!0}}function Bc(t,e=globalThis?.document){const r=ut(t),s=p.useRef(!1);return p.useEffect(()=>{const n=i=>{i.target&&!s.current&&xn($c,r,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",n),()=>e.removeEventListener("focusin",n)},[e,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function Rs(){const t=new CustomEvent(Ar);document.dispatchEvent(t)}function xn(t,e,r,{discrete:s}){const n=r.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:r});e&&n.addEventListener(t,e,{once:!0}),s?Pc(n,i):n.dispatchEvent(i)}var ar="focusScope.autoFocusOnMount",lr="focusScope.autoFocusOnUnmount",Cs={bubbles:!1,cancelable:!0},Mc="FocusScope",An=p.forwardRef((t,e)=>{const{loop:r=!1,trapped:s=!1,onMountAutoFocus:n,onUnmountAutoFocus:i,...o}=t,[a,l]=p.useState(null),c=ut(n),u=ut(i),d=p.useRef(null),h=Ae(e,g=>l(g)),f=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(s){let g=function(w){if(f.paused||!a)return;const T=w.target;a.contains(T)?d.current=T:de(d.current,{select:!0})},v=function(w){if(f.paused||!a)return;const T=w.relatedTarget;T!==null&&(a.contains(T)||de(d.current,{select:!0}))},y=function(w){if(document.activeElement===document.body)for(const N of w)N.removedNodes.length>0&&de(a)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const _=new MutationObserver(y);return a&&_.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),_.disconnect()}}},[s,a,f.paused]),p.useEffect(()=>{if(a){Ps.add(f);const g=document.activeElement;if(!a.contains(g)){const y=new CustomEvent(ar,Cs);a.addEventListener(ar,c),a.dispatchEvent(y),y.defaultPrevented||(Fc(Vc(Rn(a)),{select:!0}),document.activeElement===g&&de(a))}return()=>{a.removeEventListener(ar,c),setTimeout(()=>{const y=new CustomEvent(lr,Cs);a.addEventListener(lr,u),a.dispatchEvent(y),y.defaultPrevented||de(g??document.body,{select:!0}),a.removeEventListener(lr,u),Ps.remove(f)},0)}}},[a,c,u,f]);const b=p.useCallback(g=>{if(!r&&!s||f.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(v&&y){const _=g.currentTarget,[w,T]=Wc(_);w&&T?!g.shiftKey&&y===T?(g.preventDefault(),r&&de(w,{select:!0})):g.shiftKey&&y===w&&(g.preventDefault(),r&&de(T,{select:!0})):y===_&&g.preventDefault()}},[r,s,f.paused]);return m.jsx(ae.div,{tabIndex:-1,...o,ref:h,onKeyDown:b})});An.displayName=Mc;function Fc(t,{select:e=!1}={}){const r=document.activeElement;for(const s of t)if(de(s,{select:e}),document.activeElement!==r)return}function Wc(t){const e=Rn(t),r=Os(e,t),s=Os(e.reverse(),t);return[r,s]}function Rn(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const n=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||n?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function Os(t,e){for(const r of t)if(!qc(r,{upTo:e}))return r}function qc(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Hc(t){return t instanceof HTMLInputElement&&"select"in t}function de(t,{select:e=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&Hc(t)&&e&&t.select()}}var Ps=zc();function zc(){let t=[];return{add(e){const r=t[0];e!==r&&r?.pause(),t=js(t,e),t.unshift(e)},remove(e){t=js(t,e),t[0]?.resume()}}}function js(t,e){const r=[...t],s=r.indexOf(e);return s!==-1&&r.splice(s,1),r}function Vc(t){return t.filter(e=>e.tagName!=="A")}var Kc="Portal",Cn=p.forwardRef((t,e)=>{const{container:r,...s}=t,[n,i]=p.useState(!1);ct(()=>i(!0),[]);const o=r||n&&globalThis?.document?.body;return o?ci.createPortal(m.jsx(ae.div,{...s,ref:e}),o):null});Cn.displayName=Kc;function Gc(t,e){return p.useReducer((r,s)=>e[r][s]??r,t)}var Vt=t=>{const{present:e,children:r}
vendor: 4,289 bytes, line 44
44=t,s=Jc(e),n=typeof r=="function"?r({present:s.isPresent}):p.Children.only(r),i=Ae(s.ref,Yc(n));return typeof r=="function"||s.isPresent?p.cloneElement(n,{ref:i}):null};Vt.displayName="Presence";function Jc(t){const[e,r]=p.useState(),s=p.useRef(null),n=p.useRef(t),i=p.useRef("none"),o=t?"mounted":"unmounted",[a,l]=Gc(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const c=xt(s.current);i.current=a==="mounted"?c:"none"},[a]),ct(()=>{const c=s.current,u=n.current;if(u!==t){const h=i.current,f=xt(c);t?l("MOUNT"):f==="none"||c?.display==="none"?l("UNMOUNT"):l(u&&h!==f?"ANIMATION_OUT":"UNMOUNT"),n.current=t}},[t,l]),ct(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,d=f=>{const g=xt(s.current).includes(CSS.escape(f.animationName));if(f.target===e&&g&&(l("ANIMATION_END"),!n.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},h=f=>{f.target===e&&(i.current=xt(s.current))};return e.addEventListener("animationstart",h),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",h),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:p.useCallback(c=>{s.current=c?getComputedStyle(c):null,r(c)},[])}}function xt(t){return t?.animationName||"none"}function Yc(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var cr=0;function Xc(){p.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Ns()),document.body.insertAdjacentElement("beforeend",t[1]??Ns()),cr++,()=>{cr===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),cr--}},[])}function Ns(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var jt="right-scroll-bar-position",Nt="width-before-scroll-bar",Zc="with-scroll-bars-hidden",Qc="--removed-body-scroll-bar-size";function ur(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function eu(t,e){var r=p.useState(function(){return{value:t,callback:e,facade:{get current(){return r.value},set current(s){var n=r.value;n!==s&&(r.value=s,r.callback(s,n))}}}})[0];return r.callback=e,r.facade}var tu=typeof window<"u"?p.useLayoutEffect:p.useEffect,Is=new WeakMap;function ru(t,e){var r=eu(null,function(s){return t.forEach(function(n){return ur(n,s)})});return tu(function(){var s=Is.get(r);if(s){var n=new Set(s),i=new Set(t),o=r.current;n.forEach(function(a){i.has(a)||ur(a,null)}),i.forEach(function(a){n.has(a)||ur(a,o)})}Is.set(r,t)},[t]),r}function su(t){return t}function nu(t,e){e===void 0&&(e=su);var r=[],s=!1,n={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:t},useMedium:function(i){var o=e(i,s);return r.push(o),function(){r=r.filter(function(a){return a!==o})}},assignSyncMedium:function(i){for(s=!0;r.length;){var o=r;r=[],o.forEach(i)}r={push:function(a){return i(a)},filter:function(){return r}}},assignMedium:function(i){s=!0;var o=[];if(r.length){var a=r;r=[],a.forEach(i),o=r}var l=function(){var u=o;o=[],u.forEach(i)},c=function(){return Promise.resolve().then(l)};c(),r={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),r}}}};return n}function iu(t){t===void 0&&(t={});var e=nu(null);return e.options=re({async:!0,ssr:!1},t),e}var On=function(t){var e=t.sideCar,r=Ke(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=e.read();if(!s)throw new Error("Sidecar medium not found");return p.createElement(s,re({},r))};
vendor: 9,383 bytes, lines 44-84
44On.isSideCarExport=!0;function ou(t,e){return t.useMedium(e),On}var Pn=iu(),dr=function(){},Kt=p.forwardRef(function(t,e){var r=p.useRef(null),s=p.useState({onScrollCapture:dr,onWheelCapture:dr,onTouchMoveCapture:dr}),n=s[0],i=s[1],o=t.forwardProps,a=t.children,l=t.className,c=t.removeScrollBar,u=t.enabled,d=t.shards,h=t.sideCar,f=t.noRelative,b=t.noIsolation,g=t.inert,v=t.allowPinchZoom,y=t.as,_=y===void 0?"div":y,w=t.gapMode,T=Ke(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=h,P=ru([r,e]),R=re(re({},T),n);return p.createElement(p.Fragment,null,u&&p.createElement(N,{sideCar:Pn,removeScrollBar:c,shards:d,noRelative:f,noIsolation:b,inert:g,setCallbacks:i,allowPinchZoom:!!v,lockRef:r,gapMode:w}),o?p.cloneElement(p.Children.only(a),re(re({},R),{ref:P})):p.createElement(_,re({},R,{className:l,ref:P}),a))});Kt.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Kt.classNames={fullWidth:Nt,zeroRight:jt};var au=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function lu(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=au();return e&&t.setAttribute("nonce",e),t}function cu(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function uu(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var du=function(){var t=0,e=null;return{add:function(r){t==0&&(e=lu())&&(cu(e,r),uu(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},hu=function(){var t=du();return function(e,r){p.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&r])}},jn=function(){var t=hu(),e=function(r){var s=r.styles,n=r.dynamic;return t(s,n),null};return e},fu={left:0,top:0,right:0,gap:0},hr=function(t){return parseInt(t||"",10)||0},pu=function(t){var e=window.getComputedStyle(document.body),r=e[t==="padding"?"paddingLeft":"marginLeft"],s=e[t==="padding"?"paddingTop":"marginTop"],n=e[t==="padding"?"paddingRight":"marginRight"];return[hr(r),hr(s),hr(n)]},gu=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return fu;var e=pu(t),r=document.documentElement.clientWidth,s=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,s-r+e[2]-e[0])}},mu=jn(),ze="data-scroll-locked",vu=function(t,e,r,s){var n=t.left,i=t.top,o=t.right,a=t.gap;return r===void 0&&(r="margin"),` 45 .`.concat(Zc,` { 46 overflow: hidden `).concat(s,`; 47 padding-right: `).concat(a,"px ").concat(s,`; 48 } 49 body[`).concat(ze,`] { 50 overflow: hidden `).concat(s,`; 51 overscroll-behavior: contain; 52 `).concat([e&&"position: relative ".concat(s,";"),r==="margin"&&` 53 padding-left: `.concat(n,`px; 54 padding-top: `).concat(i,`px; 55 padding-right: `).concat(o,`px; 56 margin-left:0; 57 margin-top:0; 58 margin-right: `).concat(a,"px ").concat(s,`; 59 `),r==="padding"&&"padding-right: ".concat(a,"px ").concat(s,";")].filter(Boolean).join(""),` 60 } 61 62 .`).concat(jt,` { 63 right: `).concat(a,"px ").concat(s,`; 64 } 65 66 .`).concat(Nt,` { 67 margin-right: `).concat(a,"px ").concat(s,`; 68 } 69 70 .`).concat(jt," .").concat(jt,` { 71 right: 0 `).concat(s,`; 72 } 73 74 .`).concat(Nt," .").concat(Nt,` { 75 margin-right: 0 `).concat(s,`; 76 } 77 78 body[`).concat(ze,`] { 79 `).concat(Qc,": ").concat(a,`px; 80 } 81`)},$s=function(){var t=parseInt(document.body.getAttribute(ze)||"0",10);return isFinite(t)?t:0},bu=function(){p.useEffect(function(){return document.body.setAttribute(ze,($s()+1).toString()),function(){var t=$s()-1;t<=0?document.body.removeAttribute(ze):document.body.setAttribute(ze,t.toString())}},[])},yu=function(t){var e=t.noRelative,r=t.noImportant,s=t.gapMode,n=s===void 0?"margin":s;bu();var i=p.useMemo(function(){return gu(n)},[n]);return p.createElement(mu,{styles:vu(i,!e,n,r?"":"!important")})},Rr=!1;if(typeof window<"u")try{var At=Object.defineProperty({},"passive",{get:function(){return Rr=!0,!0}});window.addEventListener("test",At,At),window.removeEventListener("test",At,At)}catch{Rr=!1}var Le=Rr?{passive:!1}:!1,wu=function(t){return t.tagName==="TEXTAREA"},Nn=function(t,e){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[e]!=="hidden"&&!(r.overflowY===r.overflowX&&!wu(t)&&r[e]==="visible")},_u=function(t){return Nn(t,"overflowY")},ku=function(t){return Nn(t,"overflowX")},Ls=function(t,e){var r=e.ownerDocument,s=e;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var n=In(t,s);if(n){var i=$n(t,s),o=i[1],a=i[2];if(o>a)return!0}s=s.parentNode}while(s&&s!==r.body);return!1},Su=function(t){var e=t.scrollTop,r=t.scrollHeight,s=t.clientHeight;return[e,r,s]},Eu=function(t){var e=t.scrollLeft,r=t.scrollWidth,s=t.clientWidth;return[e,r,s]},In=function(t,e){return t==="v"?_u(e):ku(e)},$n=function(t,e){return t==="v"?Su(e):Eu(e)},Tu=function(t,e){return t==="h"&&e==="rtl"?-1:1},xu=function(t,e,r,s,n){var i=Tu(t,window.getComputedStyle(e).direction),o=i*s,a=r.target,l=e.contains(a),c=!1,u=o>0,d=0,h=0;do{if(!a)break;var f=$n(t,a),b=f[0],g=f[1],v=f[2],y=g-v-i*b;(b||y)&&In(t,a)&&(d+=y,h+=b);var _=a.parentNode;a=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!l&&a!==document.body||l&&(e.contains(a)||e===a));return(u&&Math.abs(d)<1||!u&&Math.abs(h)<1)&&(c=!0),c},Rt=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Ds=function(t){return[t.deltaX,t.deltaY]},Us=function(t){return t&&"current"in t?t.current:t},Au=function(t,e){return t[0]===e[0]&&t[1]===e[1]},Ru=function(t){return` 82 .block-interactivity-`.concat(t,` {pointer-events: none;} 83 .allow-interactivity-`).concat(t,` {pointer-events: all;} 84`)},Cu=0,De=[];function Ou(t){var e=p.useRef([]),r=p.useRef([0,0]),s=p.useRef(),n=p.useState(Cu++)[0],i=p.useState(jn)[0],o=p.useRef(t);p.useEffect(function(){o.current=t},[t]),p.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(n));var g=bo([t.lockRef.current],(t.shards||[]).map(Us),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(n))})}}},[t.inert,t.lockRef.current,t.shards]);var a=p.useCallback(function(g,v){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!o.current.allowPinchZoom;var y=Rt(g),_=r.current,w="deltaX"in g?g.deltaX:_[0]-y[0],T="deltaY"in g?g.deltaY:_[1]-y[1],N,P=g.target,R=Math.abs(w)>Math.abs(T)?"h":"v";if("touches"in g&&R==="h"&&P.type==="range")return!1;var x=window.getSelection(),I=x&&x.anchorNode,le=I?I===P||I.contains(P):!1;if(le)return!1;var me=Ls(R,P);if(!me)return!0;if(me?N=R:(N=R==="v"?"h":"v",me=Ls(R,P)),!me)return!1;if(!s.current&&"changedTouches"in g&&(w||T)&&(s.current=N),!N)return!0;var ve=s.current||N;return xu(ve,v,g,ve==="h"?w:T)},[]),l=p.useCallback(function(g){var v=g;if(!(!De.length||De[De.length-1]!==i)){var y="deltaY"in v?Ds(v):Rt(v),_=e.current.filter(function(N){return N.name===v.type&&(N.target===v.target||v.target===N.shadowParent)&&Au(N.delta,y)})[0];if(_&&_.should){v.cancelable&&v.preventDefault();return}if(!_){var w=(o.current.shards||[]).map(Us).filter(Boolean).filter(function(N){return N.contains(v.target)}),T=w.length>0?a(v,w[0]):!o.current.noIsolation;T&&v.cancelable&&v.preventDefault()}}},[]),c=p.useCallback(function(g,v,y,_){var w={name:g,delta:v,target:y,should:_,shadowParent:Pu(y)};e.current.push(w),setTimeout(function(){e.current=e.current.filter(function(T){return T!==w})},1)},[]),u=p.useCallback(function(g){r.current=Rt(g),s.current=void 0},[]),d=p.useCallback(function(g){c(g.type,Ds(g),g.target,a(g,t.lockRef.current))},[]),h=p.useCallback(function(g){c(g.type,Rt(g),g.target,a(g,t.lockRef.current))},[]);p.useEffect(function(){return De.push(i),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Le),document.addEventListener("touchmove",l,Le),document.addEventListener("touchstart",u,Le),function(){De=De.filter(function(g){return g!==i}),document.removeEventListener("wheel",l,Le),document.removeEventListener("touchmove",l,Le),document.removeEventListener("touchstart",u,Le)}},[]);var f=t.removeScrollBar,b=t.inert;return p.createElement(p.Fragment,null,b?p.createElement(i,{styles:Ru(n)}):null,f?p.createElement(yu,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function Pu(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const ju=ou(Pn,Ou);var Ln=p.forwardRef(function(t,e){return p.createElement(Kt,re({},t,{ref:e,sideCar:ju}))});Ln.classNames=Kt.classNames;var Nu=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Ue=new WeakMap,Ct=new WeakMap,Ot={},fr=0,Dn=function(t){return t&&(t.host||Dn(t.parentNode))},Iu=function(t,e){return e.map(function(r){if(t.contains(r))return r;var s=Dn(r);return s&&t.contains(s)?s:(console.error("aria-hidden",r,"in not contained inside",t,". Doing nothing"),null)}).filter(function(r){return!!r})},$u=function(t,e,r,s){var n=Iu(e,Array.isArray(t)?t:[t]);Ot[r]||(Ot[r]=new WeakMap);var i=Ot[r],o=[],a=new Set,l=new Set(n),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};
vendor: 8,450 bytes, lines 84-88
84n.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(h){if(a.has(h))u(h);else try{var f=h.getAttribute(s),b=f!==null&&f!=="false",g=(Ue.get(h)||0)+1,v=(i.get(h)||0)+1;Ue.set(h,g),i.set(h,v),o.push(h),g===1&&b&&Ct.set(h,!0),v===1&&h.setAttribute(r,"true"),b||h.setAttribute(s,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return u(e),a.clear(),fr++,function(){o.forEach(function(d){var h=Ue.get(d)-1,f=i.get(d)-1;Ue.set(d,h),i.set(d,f),h||(Ct.has(d)||d.removeAttribute(s),Ct.delete(d)),f||d.removeAttribute(r)}),fr--,fr||(Ue=new WeakMap,Ue=new WeakMap,Ct=new WeakMap,Ot={})}},Lu=function(t,e,r){r===void 0&&(r="data-aria-hidden");var s=Array.from(Array.isArray(t)?t:[t]),n=Nu(t);return n?(s.push.apply(s,Array.from(n.querySelectorAll("[aria-live], script"))),$u(s,n,r,"aria-hidden")):function(){return null}};function Du(t){const e=Uu(t),r=p.forwardRef((s,n)=>{const{children:i,...o}=s,a=p.Children.toArray(i),l=a.find(Mu);if(l){const c=l.props.children,u=a.map(d=>d===l?p.Children.count(c)>1?p.Children.only(null):p.isValidElement(c)?c.props.children:null:d);return m.jsx(e,{...o,ref:n,children:p.isValidElement(c)?p.cloneElement(c,void 0,u):null})}return m.jsx(e,{...o,ref:n,children:i})});return r.displayName=`${t}.Slot`,r}function Uu(t){const e=p.forwardRef((r,s)=>{const{children:n,...i}=r;if(p.isValidElement(n)){const o=Wu(n),a=Fu(i,n.props);return n.type!==p.Fragment&&(a.ref=s?Wt(s,o):o),p.cloneElement(n,a)}return p.Children.count(n)>1?p.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var Bu=Symbol("radix.slottable");function Mu(t){return p.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Bu}function Fu(t,e){const r={...e};for(const s in e){const n=t[s],i=e[s];/^on[A-Z]/.test(s)?n&&i?r[s]=(...a)=>{const l=i(...a);return n(...a),l}:n&&(r[s]=n):s==="style"?r[s]={...n,...i}:s==="className"&&(r[s]=[n,i].filter(Boolean).join(" "))}return{...t,...r}}function Wu(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var Gt="Dialog",[Un,dd]=mc(Gt),[qu,Z]=Un(Gt),Bn=t=>{const{__scopeDialog:e,children:r,open:s,defaultOpen:n,onOpenChange:i,modal:o=!0}=t,a=p.useRef(null),l=p.useRef(null),[c,u]=_c({prop:s,defaultProp:n??!1,onChange:i,caller:Gt});return m.jsx(qu,{scope:e,triggerRef:a,contentRef:l,contentId:or(),titleId:or(),descriptionId:or(),open:c,onOpenChange:u,onOpenToggle:p.useCallback(()=>u(d=>!d),[u]),modal:o,children:r})};Bn.displayName=Gt;var Mn="DialogTrigger",Fn=p.forwardRef((t,e)=>{const{__scopeDialog:r,...s}=t,n=Z(Mn,r),i=Ae(e,n.triggerRef);return m.jsx(ae.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":Dr(n.open),...s,ref:i,onClick:pe(t.onClick,n.onOpenToggle)})});Fn.displayName=Mn;var $r="DialogPortal",[Hu,Wn]=Un($r,{forceMount:void 0}),qn=t=>{const{__scopeDialog:e,forceMount:r,children:s,container:n}=t,i=Z($r,e);return m.jsx(Hu,{scope:e,forceMount:r,children:p.Children.map(s,o=>m.jsx(Vt,{present:r||i.open,children:m.jsx(Cn,{asChild:!0,container:n,children:o})}))})};qn.displayName=$r;var Mt="DialogOverlay",Hn=p.forwardRef((t,e)=>{const r=Wn(Mt,t.__scopeDialog),{forceMount:s=r.forceMount,...n}=t,i=Z(Mt,t.__scopeDialog);return i.modal?m.jsx(Vt,{present:s||i.open,children:m.jsx(Vu,{...n,ref:e})}):null});Hn.displayName=Mt;var zu=Du("DialogOverlay.RemoveScroll"),Vu=p.forwardRef((t,e)=>{const{__scopeDialog:r,...s}=t,n=Z(Mt,r);return m.jsx(Ln,{as:zu,allowPinchZoom:!0,shards:[n.contentRef],children:m.jsx(ae.div,{"data-state":Dr(n.open),...s,ref:e,style:{pointerEvents:"auto",...s.style}})})}),xe="DialogContent",zn=p.forwardRef((t,e)=>{const r=Wn(xe,t.__scopeDialog),{forceMount:s=r.forceMount,...n}=t,i=Z(xe,t.__scopeDialog);return m.jsx(Vt,{present:s||i.open,children:i.modal?m.jsx(Ku,{...n,ref:e}):m.jsx(Gu,{...n,ref:e})})});zn.displayName=xe;var Ku=p.forwardRef((t,e)=>{const r=Z(xe,t.__scopeDialog),s=p.useRef(null),n=Ae(e,r.contentRef,s);return p.useEffect(()=>{const i=s.current;if(i)return Lu(i)},[]),m.jsx(Vn,{...t,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pe(t.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:pe(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&i.preventDefault()}),onFocusOutside:pe(t.onFocusOutside,i=>i.preventDefault())})}),Gu=p.forwardRef((t,e)=>{const r=Z(xe,t.__scopeDialog),s=p.useRef(!1),n=p.useRef(!1);return m.jsx(Vn,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(s.current||r.triggerRef.current?.focus(),i.preventDefault()),s.current=!1,n.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const o=i.target;r.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&n.current&&i.preventDefault()}})}),Vn=p.forwardRef((t,e)=>{const{__scopeDialog:r,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:i,...o}=t,a=Z(xe,r),l=p.useRef(null),c=Ae(e,l);return Xc(),m.jsxs(m.Fragment,{children:[m.jsx(An,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:n,onUnmountAutoFocus:i,children:m.jsx(Tn,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Dr(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),m.jsxs(m.Fragment,{children:[m.jsx(Ju,{titleId:a.titleId}),m.jsx(Xu,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Lr="DialogTitle",Kn=p.forwardRef((t,e)=>{const{__scopeDialog:r,...s}=t,n=Z(Lr,r);return m.jsx(ae.h2,{id:n.titleId,...s,ref:e})});Kn.displayName=Lr;var Gn="DialogDescription",Jn=p.forwardRef((t,e)=>{const{__scopeDialog:r,...s}=t,n=Z(Gn,r);return m.jsx(ae.p,{id:n.descriptionId,...s,ref:e})});Jn.displayName=Gn;var Yn="DialogClose",Xn=p.forwardRef((t,e)=>{const{__scopeDialog:r,...s}=t,n=Z(Yn,r);return m.jsx(ae.button,{type:"button",...s,ref:e,onClick:pe(t.onClick,()=>n.onOpenChange(!1))})});Xn.displayName=Yn;function Dr(t){return t?"open":"closed"}var Zn="DialogTitleWarning",[hd,Qn]=gc(Zn,{contentName:xe,titleName:Lr,docsSlug:"dialog"}),Ju=({titleId:t})=>{const e=Qn(Zn),r=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users. 85 86If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component. 87 88For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return p.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},Yu="DialogDescriptionWarning",Xu=({contentRef:t,descriptionId:e})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Qn(Yu).contentName}}.`;return p.useEffect(()=>{const n=t.current?.getAttribute("aria-describedby");e&&n&&(document.getElementById(e)||console.warn(s))},[s,t,e]),null},Zu=Bn,Qu=Fn,ed=qn,ei=Hn,ti=zn,ri=Kn,si=Jn,td=Xn;const rd=Zu,sd=Qu,nd=ed,ni=p.forwardRef(({className:t,...e},r)=>m.jsx(ei,{className:Ve("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:r}));ni.displayName=ei.displayName;const id=qs("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ii=p.forwardRef(({side:t="right",className:e,children:r,...s},n)=>m.jsxs(nd,{children:[m.jsx(ni,{}),m.jsxs(ti,{ref:n,className:Ve(id({side:t}),e),...s,children:[m.jsxs(td,{className:"absolute right-4 top-4 roun
88ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[m.jsx(mi,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]}),r]})]}));ii.displayName=ti.displayName;const oi=({className:t,...e})=>m.jsx("div",{className:Ve("flex flex-col space-y-2 text-center sm:text-left",t),...e});oi.displayName="SheetHeader";const ai=p.forwardRef(({className:t,...e},r)=>m.jsx(ri,{ref:r,className:Ve("text-lg font-semibold text-foreground",t),...e}));ai.displayName=ri.displayName;const od=p.forwardRef(({className:t,...e},r)=>m.jsx(si,{ref:r,className:Ve("text-sm text-muted-foreground",t),...e}));od.displayName=si.displayName;const Bs=[{to:"/features",label:"Features"},{to:"/how-it-works",label:"How it works"},{to:"/pricing",label:"Pricing"},{to:"/faq",label:"FAQ"},{to:"/install",label:"Install"}],ad=[{to:"/discover",label:"Discover"},{to:"/library",label:"Library"},{to:"/sequences",label:"Sequences"},{to:"/exports",label:"Exports"},{to:"/dashboard",label:"Dashboard"}];function ld(){const{user:t,loading:e}=pc(),[r,s]=p.useState(!1);return m.jsxs("nav",{className:"container mx-auto flex items-center justify-between gap-3 px-4 py-4 sm:px-6 sm:py-5",children:[m.jsxs(L,{to:"/",className:"flex items-center gap-2 font-bold",children:[m.jsx("span",{className:"inline-block h-3 w-3 rounded-full",style:{background:"var(--gradient-hero)"}}),m.jsx("span",{className:"text-sm sm:text-base",children:"PainPoint Pilot"})]}),m.jsx("div",{className:"hidden items-center gap-6 text-sm text-muted-foreground md:flex",children:Bs.map(n=>m.jsx(L,{to:n.to,activeProps:{className:"text-foreground"},className:"hover:text-foreground",children:n.label},n.to))}),m.jsxs("div",{className:"hidden items-center gap-2 lg:flex",children:[!e&&t?m.jsxs(m.Fragment,{children:[m.jsx(L,{to:"/discover",children:m.jsx(V,{size:"sm",variant:"ghost",children:"Discover"})}),m.jsx(L,{to:"/library",children:m.jsx(V,{size:"sm",variant:"ghost",children:"Library"})}),m.jsx(L,{to:"/sequences",children:m.jsx(V,{size:"sm",variant:"ghost",children:"Sequences"})}),m.jsx(L,{to:"/exports",children:m.jsx(V,{size:"sm",variant:"ghost",children:"Exports"})}),m.jsx(L,{to:"/dashboard",children:m.jsxs(V,{size:"sm",variant:"outline",children:[m.jsx(hi,{className:"mr-2 h-4 w-4"}),"Dashboard"]})})]}):!e&&m.jsx(L,{to:"/auth",children:m.jsx(V,{size:"sm",variant:"ghost",children:"Sign in"})}),m.jsx(L,{to:"/install",children:m.jsxs(V,{size:"sm",style:{background:"var(--gradient-hero)",color:"var(--primary-foreground)"},children:[m.jsx(Hr,{className:"mr-2 h-4 w-4"}),"Get the extension"]})})]}),m.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[!e&&t&&m.jsx(L,{to:"/discover",className:"hidden sm:inline-flex",children:m.jsx(V,{size:"sm",variant:"outline",children:"Discover"})}),!e&&!t&&m.jsx(L,{to:"/auth",children:m.jsx(V,{size:"sm",variant:"ghost",children:"Sign in"})}),m.jsxs(rd,{open:r,onOpenChange:s,children:[m.jsx(sd,{asChild:!0,children:m.jsx(V,{size:"icon",variant:"outline","aria-label":"Open menu",children:m.jsx(pi,{className:"h-4 w-4"})})}),m.jsxs(ii,{side:"right",className:"w-[85vw] max-w-sm",children:[m.jsx(oi,{children:m.jsx(ai,{children:"PainPoint Pilot"})}),m.jsxs("div",{className:"mt-6 flex flex-col gap-1",children:[!e&&t&&m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"App"}),ad.map(n=>m.jsx(L,{to:n.to,onClick:()=>s(!1),className:"rounded-md px-3 py-2 text-sm hover:bg-accent",activeProps:{className:"bg-accent font-medium"},children:n.label},n.to)),m.jsx("div",{className:"my-3 h-px bg-border"})]}),m.jsx("p",{className:"px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Explore"}),Bs.map(n=>m.jsx(L,{to:n.to,onClick:()=>s(!1),className:"rounded-md px-3 py-2 text-sm hover:bg-accent",activeProps:{className:"bg-accent font-medium"},children:n.label},n.to)),m.jsx("div",{className:"my-3 h-px bg-border"}),!e&&!t&&m.jsx(L,{to:"/auth",onClick:()=>s(!1),children:m.jsx(V,{className:"w-full",variant:"outline",children:"Sign in"})}),m.jsx(L,{to:"/install",onClick:()=>s(!1),children:m.jsxs(V,{className:"mt-2 w-full",style:{background:"var(--gradient-hero)",color:"var(--primary-foreground)"},children:[m.jsx(Hr,{className:"mr-2 h-4 w-4"}),"Get the extension"]})}),m.jsx("p",{className:"mt-4 px-2 text-xs text-muted-foreground",children:"Tip: add this
88site to your home screen for an app-like experience on mobile."})]})]})]})]})]})}function cd(){return m.jsxs("footer",{className:"border-t border-border",children:[m.jsxs("div",{className:"container mx-auto grid gap-8 px-6 py-12 md:grid-cols-4",children:[m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center gap-2 font-bold",children:[m.jsx("span",{className:"inline-block h-3 w-3 rounded-full",style:{background:"var(--gradient-hero)"}}),"PainPoint Pilot"]}),m.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Turn social conversations into qualified pipeline. Built for founders and SDRs."})]}),m.jsxs("div",{children:[m.jsx("h4",{className:"text-sm font-semibold",children:"Product"}),m.jsxs("ul",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[m.jsx("li",{children:m.jsx(L,{to:"/features",className:"hover:text-foreground",children:"Features"})}),m.jsx("li",{children:m.jsx(L,{to:"/how-it-works",className:"hover:text-foreground",children:"How it works"})}),m.jsx("li",{children:m.jsx(L,{to:"/pricing",className:"hover:text-foreground",children:"Pricing"})}),m.jsx("li",{children:m.jsx(L,{to:"/install",className:"hover:text-foreground",children:"Install"})}),m.jsx("li",{children:m.jsx(L,{to:"/affiliate",className:"hover:text-foreground",children:"Affiliate program"})})]})]}),m.jsxs("div",{children:[m.jsx("h4",{className:"text-sm font-semibold",children:"Resources"}),m.jsxs("ul",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[m.jsx("li",{children:m.jsx(L,{to:"/pain-point-research",className:"hover:text-foreground",children:"Pain point research"})}),m.jsx("li",{children:m.jsx(L,{to:"/find-customer-pain-points-on-linkedin",className:"hover:text-foreground",children:"Find pain points on LinkedIn"})}),m.jsx("li",{children:m.jsx(L,{to:"/faq",className:"hover:text-foreground",children:"FAQ"})}),m.jsx("li",{children:m.jsx(L,{to:"/privacy",className:"hover:text-foreground",children:"Privacy"})}),m.jsx("li",{children:m.jsx("a",{href:"/sitemap.xml",className:"hover:text-foreground",children:"Sitemap"})}),m.jsx("li",{children:m.jsx("a",{href:"/robots.txt",className:"hover:text-foreground",children:"Robots"})})]})]}),m.jsxs("div",{children:[m.jsx("h4",{className:"text-sm font-semibold",children:"Built with"}),m.jsxs("ul",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[m.jsx("li",{children:"Lovable AI Gateway"}),m.jsx("li",{children:"Manifest V3"}),m.jsx("li",{children:"Privacy-first: only public posts"})]})]})]}),m.jsxs("div",{className:"border-t border-border py-4 text-center text-xs text-muted-foreground",children:["© ",new Date().getFullYear()," PainPoint Pilot. All rights reserved."]})]})}function fd({children:t}){return m.jsxs("div",{className:"min-h-screen text-foreground",style:{background:"var(--gradient-bg), var(--background)"},children:[m.jsx(ld,{}),m.jsx("main",{children:t}),m.jsx(cd,{})]})}export{V as B,ti as C,Hr as D,An as F,ei as O,fd as P,Ln as R,Qu as T,hd as W,mi as X,_c as a,ae as b,or as c,pe as d,Vt as e,mc as f,Ae as g,ct as h,Ve as i,ut as j,Wt as k,Cn as l,Lu as m,Xc as
88n,Tn as o,Zu as p,dd as q,ed as r,ke as s,ri as t,pc as u,si as v,td as w,mo as x,qs as y,yi as z};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.