Files
Stackq/.svelte-kit/output/client/_app/immutable/chunks/Do7CCxfs.js
T

88 lines
68 KiB
JavaScript

var zs=Object.defineProperty;var ds=i=>{throw TypeError(i)};var Vs=(i,e,t)=>e in i?zs(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var U=(i,e,t)=>Vs(i,typeof e!="symbol"?e+"":e,t),Hs=(i,e,t)=>e.has(i)||ds("Cannot "+t);var _=(i,e,t)=>(Hs(i,e,"read from private field"),t?t.call(i):e.get(i)),D=(i,e,t)=>e.has(i)?ds("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t);import"./Bzak7iHL.js";import{k as P,g as d,q as I,y as $,br as He,p as H,h as L,i as T,j as p,m as G,o as y,as as oe,v as w,l as N,s as C,bs as Gs,bt as Js,w as M,a as us,x as Y,t as re}from"./DScGFiBY.js";import{c as ge,_ as $s}from"./B5gxx3nr.js";import{p as S,r as X,b as ee}from"./DoRZqEmo.js";import{d as V,b as me,c as Ge,r as yt,s as hs,f as ps,a as Qs,g as Ye}from"./BPc-JNDc.js";import{C as Xs,S as Ys,E as Zs,w as At,P as fs,o as er,n as _e,F as tr,a as sr,b as rr,T as nr,c as gs,d as or}from"./CaCQx3BS.js";import{b as Je,g as et,f as B,l as ir,c as ar,d as $e,m as ae,L as ne,a as cr,e as lr}from"./B3aNbgJc.js";import{i as Q}from"./BlbL38UD.js";import{b as Ss}from"./DkOFPg3x.js";import{e as ke,i as Ie}from"./BhGBB4Qh.js";import{e as dr}from"./fb4NW7RP.js";import{s as ve}from"./B7h8GtFa.js";import{B as wt}from"./CcEFwafz.js";import{I as Se}from"./CB0VnWqK.js";const ur=ar({component:"dialog",parts:["content","trigger","overlay","title","description","close","cancel","action"]}),ye=new Xs("Dialog.Root | AlertDialog.Root");var xe,Te,Re,Ae,Ee,je,Ue,Ne,Le,qe,De;const Nt=class Nt{constructor(e,t){U(this,"opts");D(this,xe,$(null));D(this,Te,$(null));D(this,Re,$(null));D(this,Ae,$(null));D(this,Ee,$(void 0));D(this,je,$(void 0));D(this,Ue,$(void 0));D(this,Ne,$(void 0));D(this,Le,$(null));D(this,qe,$(0));U(this,"depth");U(this,"parent");U(this,"contentPresence");U(this,"overlayPresence");U(this,"getBitsAttr",e=>ur.getAttr(e,this.opts.variant.current));D(this,De,P(()=>({"data-state":ir(this.opts.open.current)})));this.opts=e,this.parent=t,this.depth=t?t.depth+1:0,this.handleOpen=this.handleOpen.bind(this),this.handleClose=this.handleClose.bind(this),this.contentPresence=new fs({ref:B(()=>this.contentNode),open:this.opts.open,enabled:!0,onComplete:()=>{this.opts.onOpenChangeComplete.current(this.opts.open.current)}}),this.overlayPresence=new fs({ref:B(()=>this.overlayNode),open:this.opts.open,enabled:!0}),At(()=>this.opts.open.current,s=>{this.parent&&(s?this.parent.incrementNested():this.parent.decrementNested())},{lazy:!0}),er(()=>{var s;this.opts.open.current&&((s=this.parent)==null||s.decrementNested())})}static create(e){const t=ye.getOr(null);return ye.set(new Nt(e,t))}get triggerNode(){return d(_(this,xe))}set triggerNode(e){I(_(this,xe),e,!0)}get contentNode(){return d(_(this,Te))}set contentNode(e){I(_(this,Te),e,!0)}get overlayNode(){return d(_(this,Re))}set overlayNode(e){I(_(this,Re),e,!0)}get descriptionNode(){return d(_(this,Ae))}set descriptionNode(e){I(_(this,Ae),e,!0)}get contentId(){return d(_(this,Ee))}set contentId(e){I(_(this,Ee),e,!0)}get titleId(){return d(_(this,je))}set titleId(e){I(_(this,je),e,!0)}get triggerId(){return d(_(this,Ue))}set triggerId(e){I(_(this,Ue),e,!0)}get descriptionId(){return d(_(this,Ne))}set descriptionId(e){I(_(this,Ne),e,!0)}get cancelNode(){return d(_(this,Le))}set cancelNode(e){I(_(this,Le),e,!0)}get nestedOpenCount(){return d(_(this,qe))}set nestedOpenCount(e){I(_(this,qe),e,!0)}handleOpen(){this.opts.open.current||(this.opts.open.current=!0)}handleClose(){this.opts.open.current&&(this.opts.open.current=!1)}incrementNested(){var e;this.nestedOpenCount++,(e=this.parent)==null||e.incrementNested()}decrementNested(){var e;this.nestedOpenCount!==0&&(this.nestedOpenCount--,(e=this.parent)==null||e.decrementNested())}get sharedProps(){return d(_(this,De))}set sharedProps(e){I(_(this,De),e)}};xe=new WeakMap,Te=new WeakMap,Re=new WeakMap,Ae=new WeakMap,Ee=new WeakMap,je=new WeakMap,Ue=new WeakMap,Ne=new WeakMap,Le=new WeakMap,qe=new WeakMap,De=new WeakMap;let Ct=Nt;var Fe;const Lt=class Lt{constructor(e,t){U(this,"opts");U(this,"root");U(this,"attachment");D(this,Fe,P(()=>({id:this.opts.id.current,[this.root.getBitsAttr(this.opts.variant.current)]:"",onclick:this.onclick,onkeydown:this.onkeydown,disabled:this.opts.disabled.current?!0:void 0,tabindex:0,...this.root.sharedProps,...this.attachment})));this.opts=e,this.root=t,this.attachment=Je(this.opts.ref),this.onclick=this.onclick.bind(this),this.onkeydown=this.onkeydown.bind(this)}static create(e){return new Lt(e,ye.get())}onclick(e){this.opts.disabled.current||e.button>0||this.root.handleClose()}onkeydown(e){this.opts.disabled.current||(e.key===Ys||e.key===Zs)&&(e.preventDefault(),this.root.handleClose())}get props(){return d(_(this,Fe))}set props(e){I(_(this,Fe),e)}};Fe=new WeakMap;let Ot=Lt;var Be;const qt=class qt{constructor(e,t){U(this,"opts");U(this,"root");U(this,"attachment");D(this,Be,P(()=>({id:this.opts.id.current,role:"heading","aria-level":this.opts.level.current,[this.root.getBitsAttr("title")]:"",...this.root.sharedProps,...this.attachment})));this.opts=e,this.root=t,this.root.titleId=this.opts.id.current,this.attachment=Je(this.opts.ref),At.pre(()=>this.opts.id.current,s=>{this.root.titleId=s})}static create(e){return new qt(e,ye.get())}get props(){return d(_(this,Be))}set props(e){I(_(this,Be),e)}};Be=new WeakMap;let Pt=qt;var Ke;const Dt=class Dt{constructor(e,t){U(this,"opts");U(this,"root");U(this,"attachment");D(this,Ke,P(()=>({id:this.opts.id.current,[this.root.getBitsAttr("description")]:"",...this.root.sharedProps,...this.attachment})));this.opts=e,this.root=t,this.root.descriptionId=this.opts.id.current,this.attachment=Je(this.opts.ref,s=>{this.root.descriptionNode=s}),At.pre(()=>this.opts.id.current,s=>{this.root.descriptionId=s})}static create(e){return new Dt(e,ye.get())}get props(){return d(_(this,Ke))}set props(e){I(_(this,Ke),e)}};Ke=new WeakMap;let kt=Dt;var Me,We;const Ft=class Ft{constructor(e,t){U(this,"opts");U(this,"root");U(this,"attachment");D(this,Me,P(()=>({open:this.root.opts.open.current})));D(this,We,P(()=>({id:this.opts.id.current,role:this.root.opts.variant.current==="alert-dialog"?"alertdialog":"dialog","aria-modal":"true","aria-describedby":this.root.descriptionId,"aria-labelledby":this.root.titleId,[this.root.getBitsAttr("content")]:"",style:{pointerEvents:"auto",outline:this.root.opts.variant.current==="alert-dialog"?"none":void 0,"--bits-dialog-depth":this.root.depth,"--bits-dialog-nested-count":this.root.nestedOpenCount,contain:"layout style"},tabindex:this.root.opts.variant.current==="alert-dialog"?-1:void 0,"data-nested-open":et(this.root.nestedOpenCount>0),"data-nested":et(this.root.parent!==null),...this.root.sharedProps,...this.attachment})));this.opts=e,this.root=t,this.attachment=Je(this.opts.ref,s=>{this.root.contentNode=s,this.root.contentId=s==null?void 0:s.id})}static create(e){return new Ft(e,ye.get())}get snippetProps(){return d(_(this,Me))}set snippetProps(e){I(_(this,Me),e)}get props(){return d(_(this,We))}set props(e){I(_(this,We),e)}get shouldRender(){return this.root.contentPresence.shouldRender}};Me=new WeakMap,We=new WeakMap;let It=Ft;var ze,Ve;const Bt=class Bt{constructor(e,t){U(this,"opts");U(this,"root");U(this,"attachment");D(this,ze,P(()=>({open:this.root.opts.open.current})));D(this,Ve,P(()=>({id:this.opts.id.current,[this.root.getBitsAttr("overlay")]:"",style:{pointerEvents:"auto","--bits-dialog-depth":this.root.depth,"--bits-dialog-nested-count":this.root.nestedOpenCount},"data-nested-open":et(this.root.nestedOpenCount>0),"data-nested":et(this.root.parent!==null),...this.root.sharedProps,...this.attachment})));this.opts=e,this.root=t,this.attachment=Je(this.opts.ref,s=>this.root.overlayNode=s)}static create(e){return new Bt(e,ye.get())}get snippetProps(){return d(_(this,ze))}set snippetProps(e){I(_(this,ze),e)}get props(){return d(_(this,Ve))}set props(e){I(_(this,Ve),e)}get shouldRender(){return this.root.overlayPresence.shouldRender}};ze=new WeakMap,Ve=new WeakMap;let xt=Bt;var hr=N("<div><!></div>");function pr(i,e){const t=He();H(e,!0);let s=S(e,"id",19,()=>$e(t)),r=S(e,"ref",15,null),n=S(e,"level",3,2),o=X(e,["$$slots","$$events","$$legacy","id","ref","child","children","level"]);const a=Pt.create({id:B(()=>s()),level:B(()=>n()),ref:B(()=>r(),g=>r(g))}),l=P(()=>ae(o,a.props));var f=L(),R=T(f);{var O=g=>{var m=L(),b=T(m);V(b,()=>e.child,()=>({props:d(l)})),p(g,m)},v=g=>{var m=hr();me(m,()=>({...d(l)}));var b=y(m);V(b,()=>e.children??oe),w(m),p(g,m)};Q(R,g=>{e.child?g(O):g(v,!1)})}p(i,f),G()}var fr=N("<div><!></div>");function gr(i,e){const t=He();H(e,!0);let s=S(e,"id",19,()=>$e(t)),r=S(e,"forceMount",3,!1),n=S(e,"ref",15,null),o=X(e,["$$slots","$$events","$$legacy","id","forceMount","child","children","ref"]);const a=xt.create({id:B(()=>s()),ref:B(()=>n(),v=>n(v))}),l=P(()=>ae(o,a.props));var f=L(),R=T(f);{var O=v=>{var g=L(),m=T(g);{var b=x=>{var j=L(),A=T(j);{let k=P(()=>({props:ae(d(l)),...a.snippetProps}));V(A,()=>e.child,()=>d(k))}p(x,j)},K=x=>{var j=fr();me(j,k=>({...k}),[()=>ae(d(l))]);var A=y(j);V(A,()=>e.children??oe,()=>a.snippetProps),w(j),p(x,j)};Q(m,x=>{e.child?x(b):x(K,!1)})}p(v,g)};Q(R,v=>{(a.shouldRender||r())&&v(O)})}p(i,f),G()}var mr=N("<div><!></div>");function br(i,e){const t=He();H(e,!0);let s=S(e,"id",19,()=>$e(t)),r=S(e,"ref",15,null),n=X(e,["$$slots","$$events","$$legacy","id","children","child","ref"]);const o=kt.create({id:B(()=>s()),ref:B(()=>r(),v=>r(v))}),a=P(()=>ae(n,o.props));var l=L(),f=T(l);{var R=v=>{var g=L(),m=T(g);V(m,()=>e.child,()=>({props:d(a)})),p(v,g)},O=v=>{var g=mr();me(g,()=>({...d(a)}));var m=y(g);V(m,()=>e.children??oe),w(g),p(v,g)};Q(f,v=>{e.child?v(R):v(O,!1)})}p(i,l),G()}function vr(i,e){H(e,!0);let t=S(e,"open",15,!1),s=S(e,"onOpenChange",3,_e),r=S(e,"onOpenChangeComplete",3,_e);Ct.create({variant:B(()=>"dialog"),open:B(()=>t(),a=>{t(a),s()(a)}),onOpenChangeComplete:B(()=>r())});var n=L(),o=T(n);V(o,()=>e.children??oe),p(i,n),G()}var yr=N("<button><!></button>");function wr(i,e){const t=He();H(e,!0);let s=S(e,"id",19,()=>$e(t)),r=S(e,"ref",15,null),n=S(e,"disabled",3,!1),o=X(e,["$$slots","$$events","$$legacy","children","child","id","ref","disabled"]);const a=Ot.create({variant:B(()=>"close"),id:B(()=>s()),ref:B(()=>r(),g=>r(g)),disabled:B(()=>!!n())}),l=P(()=>ae(o,a.props));var f=L(),R=T(f);{var O=g=>{var m=L(),b=T(m);V(b,()=>e.child,()=>({props:d(l)})),p(g,m)},v=g=>{var m=yr();me(m,()=>({...d(l)}));var b=y(m);V(b,()=>e.children??oe),w(m),p(g,m)};Q(R,g=>{e.child?g(O):g(v,!1)})}p(i,f),G()}var Sr=N("<!> <!>",1),_r=N("<!> <div><!></div>",1);function Cr(i,e){const t=He();H(e,!0);let s=S(e,"id",19,()=>$e(t)),r=S(e,"ref",15,null),n=S(e,"forceMount",3,!1),o=S(e,"onCloseAutoFocus",3,_e),a=S(e,"onOpenAutoFocus",3,_e),l=S(e,"onEscapeKeydown",3,_e),f=S(e,"onInteractOutside",3,_e),R=S(e,"trapFocus",3,!0),O=S(e,"preventScroll",3,!0),v=S(e,"restoreScrollDelay",3,null),g=X(e,["$$slots","$$events","$$legacy","id","children","child","ref","forceMount","onCloseAutoFocus","onOpenAutoFocus","onEscapeKeydown","onInteractOutside","trapFocus","preventScroll","restoreScrollDelay"]);const m=It.create({id:B(()=>s()),ref:B(()=>r(),A=>r(A))}),b=P(()=>ae(g,m.props));var K=L(),x=T(K);{var j=A=>{tr(A,{get ref(){return m.opts.ref},loop:!0,get trapFocus(){return R()},get enabled(){return m.root.opts.open.current},get onOpenAutoFocus(){return a()},get onCloseAutoFocus(){return o()},focusScope:(Z,E)=>{let q=()=>E==null?void 0:E().props;sr(Z,ee(()=>d(b),{get enabled(){return m.root.opts.open.current},get ref(){return m.opts.ref},onEscapeKeydown:J=>{l()(J),!J.defaultPrevented&&m.root.handleClose()},children:(J,tt)=>{rr(J,ee(()=>d(b),{get ref(){return m.opts.ref},get enabled(){return m.root.opts.open.current},onInteractOutside:ie=>{f()(ie),!ie.defaultPrevented&&m.root.handleClose()},children:(ie,Qe)=>{nr(ie,ee(()=>d(b),{get ref(){return m.opts.ref},get enabled(){return m.root.opts.open.current},children:(st,rt)=>{var le=L(),Xe=T(le);{var nt=te=>{var de=Sr(),be=T(de);{var ue=se=>{gs(se,{get preventScroll(){return O()},get restoreScrollDelay(){return v()}})};Q(be,se=>{m.root.opts.open.current&&se(ue)})}var we=C(be,2);{let se=P(()=>({props:ae(d(b),q()),...m.snippetProps}));V(we,()=>e.child,()=>d(se))}p(te,de)},Oe=te=>{var de=_r(),be=T(de);gs(be,{get preventScroll(){return O()}});var ue=C(be,2);me(ue,se=>({...se}),[()=>ae(d(b),q())]);var we=y(ue);V(we,()=>e.children??oe),w(ue),p(te,de)};Q(Xe,te=>{e.child?te(nt):te(Oe,!1)})}p(st,le)},$$slots:{default:!0}}))},$$slots:{default:!0}}))},$$slots:{default:!0}}))},$$slots:{focusScope:!0}})};Q(x,A=>{(m.shouldRender||n())&&A(j)})}p(i,K),G()}/**
* @license @lucide/svelte v0.561.0 - ISC
*
* ISC License
*
* Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2023 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2025.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* ---
*
* The MIT License (MIT) (for portions derived from Feather)
*
* Copyright (c) 2013-2023 Cole Bemis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/const Or={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};var Pr=Gs("<svg><!><!></svg>");function kr(i,e){H(e,!0);const t=S(e,"color",3,"currentColor"),s=S(e,"size",3,24),r=S(e,"strokeWidth",3,2),n=S(e,"absoluteStrokeWidth",3,!1),o=S(e,"iconNode",19,()=>[]),a=X(e,["$$slots","$$events","$$legacy","name","color","size","strokeWidth","absoluteStrokeWidth","iconNode","children"]);var l=Pr();me(l,O=>({...Or,...a,width:s(),height:s(),stroke:t(),"stroke-width":O,class:["lucide-icon lucide",e.name&&`lucide-${e.name}`,e.class]}),[()=>n()?Number(r())*24/Number(s()):r()]);var f=y(l);ke(f,17,o,Ie,(O,v)=>{var g=P(()=>Js(d(v),2));let m=()=>d(g)[0],b=()=>d(g)[1];var K=L(),x=T(K);dr(x,m,!0,(j,A)=>{me(j,()=>({...b()}))}),p(O,K)});var R=C(f);V(R,()=>e.children??oe),w(l),p(i,l),G()}function Tn(i,e){H(e,!0);let t=S(e,"open",15,!1),s=X(e,["$$slots","$$events","$$legacy","open"]);var r=L(),n=T(r);ge(n,()=>vr,(o,a)=>{a(o,ee(()=>s,{get open(){return t()},set open(l){t(l)}}))}),p(i,r),G()}function Ir(i,e){let t=X(e,["$$slots","$$events","$$legacy"]);var s=L(),r=T(s);ge(r,()=>or,(n,o)=>{o(n,ee(()=>t))}),p(i,s)}function Rn(i,e){H(e,!0);let t=S(e,"ref",15,null),s=X(e,["$$slots","$$events","$$legacy","ref","class"]);var r=L(),n=T(r);{let o=P(()=>Ge("text-lg leading-none font-semibold",e.class));ge(n,()=>pr,(a,l)=>{l(a,ee({"data-slot":"dialog-title",get class(){return d(o)}},()=>s,{get ref(){return t()},set ref(f){t(f)}}))})}p(i,r),G()}var xr=N("<div><!></div>");function An(i,e){H(e,!0);let t=S(e,"ref",15,null),s=X(e,["$$slots","$$events","$$legacy","ref","class","children"]);var r=xr();me(r,o=>({"data-slot":"dialog-header",class:o,...s}),[()=>Ge("flex flex-col gap-2 text-center sm:text-start",e.class)]);var n=y(r);V(n,()=>e.children??oe),w(r),Ss(r,o=>t(o),()=>t()),p(i,r),G()}function Tr(i,e){H(e,!0);let t=S(e,"ref",15,null),s=X(e,["$$slots","$$events","$$legacy","ref","class"]);var r=L(),n=T(r);{let o=P(()=>Ge("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e.class));ge(n,()=>gr,(a,l)=>{l(a,ee({"data-slot":"dialog-overlay",get class(){return d(o)}},()=>s,{get ref(){return t()},set ref(f){t(f)}}))})}p(i,r),G()}function Rr(i,e){H(e,!0);/**
* @license @lucide/svelte v0.561.0 - ISC
*
* ISC License
*
* Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2023 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2025.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* ---
*
* The MIT License (MIT) (for portions derived from Feather)
*
* Copyright (c) 2013-2023 Cole Bemis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/let t=X(e,["$$slots","$$events","$$legacy"]);const s=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];kr(i,ee({name:"x"},()=>t,{get iconNode(){return s},children:(r,n)=>{var o=L(),a=T(o);V(a,()=>e.children??oe),p(r,o)},$$slots:{default:!0}})),G()}var Ar=N('<!> <span class="sr-only">Close</span>',1),Er=N("<!> <!>",1),jr=N("<!> <!>",1);function En(i,e){H(e,!0);let t=S(e,"ref",15,null),s=S(e,"showCloseButton",3,!0),r=X(e,["$$slots","$$events","$$legacy","ref","class","portalProps","children","showCloseButton"]);Ir(i,ee(()=>e.portalProps,{children:(n,o)=>{var a=jr(),l=T(a);ge(l,()=>Tr,(R,O)=>{O(R,{})});var f=C(l,2);{let R=P(()=>Ge("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e.class));ge(f,()=>Cr,(O,v)=>{v(O,ee({"data-slot":"dialog-content",get class(){return d(R)}},()=>r,{get ref(){return t()},set ref(g){t(g)},children:(g,m)=>{var b=Er(),K=T(b);V(K,()=>e.children??oe);var x=C(K,2);{var j=A=>{var k=L(),Z=T(k);ge(Z,()=>wr,(E,q)=>{q(E,{class:"ring-offset-background focus:ring-ring absolute end-4 top-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:(J,tt)=>{var ie=Ar(),Qe=T(ie);Rr(Qe,{}),M(2),p(J,ie)},$$slots:{default:!0}})}),p(A,k)};Q(x,A=>{s()&&A(j)})}p(g,b)},$$slots:{default:!0}}))})}p(n,a)},$$slots:{default:!0}})),G()}function jn(i,e){H(e,!0);let t=S(e,"ref",15,null),s=X(e,["$$slots","$$events","$$legacy","ref","class"]);var r=L(),n=T(r);{let o=P(()=>Ge("text-muted-foreground text-sm",e.class));ge(n,()=>br,(a,l)=>{l(a,ee({"data-slot":"dialog-description",get class(){return d(o)}},()=>s,{get ref(){return t()},set ref(f){t(f)}}))})}p(i,r),G()}class z extends Error{constructor(e){var t,s,r,n;super("ClientResponseError"),this.url="",this.status=0,this.response={},this.isAbort=!1,this.originalError=null,Object.setPrototypeOf(this,z.prototype),e!==null&&typeof e=="object"&&(this.originalError=e.originalError,this.url=typeof e.url=="string"?e.url:"",this.status=typeof e.status=="number"?e.status:0,this.isAbort=!!e.isAbort||e.name==="AbortError"||e.message==="Aborted",e.response!==null&&typeof e.response=="object"?this.response=e.response:e.data!==null&&typeof e.data=="object"?this.response=e.data:this.response={}),this.originalError||e instanceof z||(this.originalError=e),this.name="ClientResponseError "+this.status,this.message=(t=this.response)==null?void 0:t.message,this.message||(this.isAbort?this.message="The request was aborted (most likely autocancelled; you can find more info in https://github.com/pocketbase/js-sdk#auto-cancellation).":(n=(r=(s=this.originalError)==null?void 0:s.cause)==null?void 0:r.message)!=null&&n.includes("ECONNREFUSED ::1")?this.message="Failed to connect to the PocketBase server. Try changing the SDK URL from localhost to 127.0.0.1 (https://github.com/pocketbase/js-sdk/issues/21).":this.message="Something went wrong."),this.cause=this.originalError}get data(){return this.response}toJSON(){return{...this}}}const Ze=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function Ur(i,e){const t={};if(typeof i!="string")return t;const s=Object.assign({},{}).decode||Nr;let r=0;for(;r<i.length;){const n=i.indexOf("=",r);if(n===-1)break;let o=i.indexOf(";",r);if(o===-1)o=i.length;else if(o<n){r=i.lastIndexOf(";",n-1)+1;continue}const a=i.slice(r,n).trim();if(t[a]===void 0){let l=i.slice(n+1,o).trim();l.charCodeAt(0)===34&&(l=l.slice(1,-1));try{t[a]=s(l)}catch{t[a]=l}}r=o+1}return t}function ms(i,e,t){const s=Object.assign({},t||{}),r=s.encode||Lr;if(!Ze.test(i))throw new TypeError("argument name is invalid");const n=r(e);if(n&&!Ze.test(n))throw new TypeError("argument val is invalid");let o=i+"="+n;if(s.maxAge!=null){const a=s.maxAge-0;if(isNaN(a)||!isFinite(a))throw new TypeError("option maxAge is invalid");o+="; Max-Age="+Math.floor(a)}if(s.domain){if(!Ze.test(s.domain))throw new TypeError("option domain is invalid");o+="; Domain="+s.domain}if(s.path){if(!Ze.test(s.path))throw new TypeError("option path is invalid");o+="; Path="+s.path}if(s.expires){if(!(function(l){return Object.prototype.toString.call(l)==="[object Date]"||l instanceof Date})(s.expires)||isNaN(s.expires.valueOf()))throw new TypeError("option expires is invalid");o+="; Expires="+s.expires.toUTCString()}if(s.httpOnly&&(o+="; HttpOnly"),s.secure&&(o+="; Secure"),s.priority)switch(typeof s.priority=="string"?s.priority.toLowerCase():s.priority){case"low":o+="; Priority=Low";break;case"medium":o+="; Priority=Medium";break;case"high":o+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}if(s.sameSite)switch(typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return o}function Nr(i){return i.indexOf("%")!==-1?decodeURIComponent(i):i}function Lr(i){return encodeURIComponent(i)}const qr=typeof navigator<"u"&&navigator.product==="ReactNative"||typeof global<"u"&&global.HermesInternal;let _s;function Ce(i){if(i)try{const e=decodeURIComponent(_s(i.split(".")[1]).split("").map((function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)})).join(""));return JSON.parse(e)||{}}catch{}return{}}function Cs(i,e=0){let t=Ce(i);return!(Object.keys(t).length>0&&(!t.exp||t.exp-e>Date.now()/1e3))}_s=typeof atob!="function"||qr?i=>{let e=String(i).replace(/=+$/,"");if(e.length%4==1)throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,s,r=0,n=0,o="";s=e.charAt(n++);~s&&(t=r%4?64*t+s:s,r++%4)?o+=String.fromCharCode(255&t>>(-2*r&6)):0)s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(s);return o}:atob;const bs="pb_auth";class Et{constructor(){this.baseToken="",this.baseModel=null,this._onChangeCallbacks=[]}get token(){return this.baseToken}get record(){return this.baseModel}get model(){return this.baseModel}get isValid(){return!Cs(this.token)}get isSuperuser(){var t,s;let e=Ce(this.token);return e.type=="auth"&&(((t=this.record)==null?void 0:t.collectionName)=="_superusers"||!((s=this.record)!=null&&s.collectionName)&&e.collectionId=="pbc_3142635823")}get isAdmin(){return console.warn("Please replace pb.authStore.isAdmin with pb.authStore.isSuperuser OR simply check the value of pb.authStore.record?.collectionName"),this.isSuperuser}get isAuthRecord(){return console.warn("Please replace pb.authStore.isAuthRecord with !pb.authStore.isSuperuser OR simply check the value of pb.authStore.record?.collectionName"),Ce(this.token).type=="auth"&&!this.isSuperuser}save(e,t){this.baseToken=e||"",this.baseModel=t||null,this.triggerChange()}clear(){this.baseToken="",this.baseModel=null,this.triggerChange()}loadFromCookie(e,t=bs){const s=Ur(e||"")[t]||"";let r={};try{r=JSON.parse(s),(typeof r===null||typeof r!="object"||Array.isArray(r))&&(r={})}catch{}this.save(r.token||"",r.record||r.model||null)}exportToCookie(e,t=bs){var l,f;const s={secure:!0,sameSite:!0,httpOnly:!0,path:"/"},r=Ce(this.token);s.expires=r!=null&&r.exp?new Date(1e3*r.exp):new Date("1970-01-01"),e=Object.assign({},s,e);const n={token:this.token,record:this.record?JSON.parse(JSON.stringify(this.record)):null};let o=ms(t,JSON.stringify(n),e);const a=typeof Blob<"u"?new Blob([o]).size:o.length;if(n.record&&a>4096){n.record={id:(l=n.record)==null?void 0:l.id,email:(f=n.record)==null?void 0:f.email};const R=["collectionId","collectionName","verified"];for(const O in this.record)R.includes(O)&&(n.record[O]=this.record[O]);o=ms(t,JSON.stringify(n),e)}return o}onChange(e,t=!1){return this._onChangeCallbacks.push(e),t&&e(this.token,this.record),()=>{for(let s=this._onChangeCallbacks.length-1;s>=0;s--)if(this._onChangeCallbacks[s]==e)return delete this._onChangeCallbacks[s],void this._onChangeCallbacks.splice(s,1)}}triggerChange(){for(const e of this._onChangeCallbacks)e&&e(this.token,this.record)}}class Dr extends Et{constructor(e="pocketbase_auth"){super(),this.storageFallback={},this.storageKey=e,this._bindStorageEvent()}get token(){return(this._storageGet(this.storageKey)||{}).token||""}get record(){const e=this._storageGet(this.storageKey)||{};return e.record||e.model||null}get model(){return this.record}save(e,t){this._storageSet(this.storageKey,{token:e,record:t}),super.save(e,t)}clear(){this._storageRemove(this.storageKey),super.clear()}_storageGet(e){if(typeof window<"u"&&(window!=null&&window.localStorage)){const t=window.localStorage.getItem(e)||"";try{return JSON.parse(t)}catch{return t}}return this.storageFallback[e]}_storageSet(e,t){if(typeof window<"u"&&(window!=null&&window.localStorage)){let s=t;typeof t!="string"&&(s=JSON.stringify(t)),window.localStorage.setItem(e,s)}else this.storageFallback[e]=t}_storageRemove(e){var t;typeof window<"u"&&(window!=null&&window.localStorage)&&((t=window.localStorage)==null||t.removeItem(e)),delete this.storageFallback[e]}_bindStorageEvent(){typeof window<"u"&&(window!=null&&window.localStorage)&&window.addEventListener&&window.addEventListener("storage",(e=>{if(e.key!=this.storageKey)return;const t=this._storageGet(this.storageKey)||{};super.save(t.token||"",t.record||t.model||null)}))}}class ce{constructor(e){this.client=e}}class Fr extends ce{async getAll(e){return e=Object.assign({method:"GET"},e),this.client.send("/api/settings",e)}async update(e,t){return t=Object.assign({method:"PATCH",body:e},t),this.client.send("/api/settings",t)}async testS3(e="storage",t){return t=Object.assign({method:"POST",body:{filesystem:e}},t),this.client.send("/api/settings/test/s3",t).then((()=>!0))}async testEmail(e,t,s,r){return r=Object.assign({method:"POST",body:{email:t,template:s,collection:e}},r),this.client.send("/api/settings/test/email",r).then((()=>!0))}async generateAppleClientSecret(e,t,s,r,n,o){return o=Object.assign({method:"POST",body:{clientId:e,teamId:t,keyId:s,privateKey:r,duration:n}},o),this.client.send("/api/settings/apple/generate-client-secret",o)}}const Br=["requestKey","$cancelKey","$autoCancel","fetch","headers","body","query","params","cache","credentials","headers","integrity","keepalive","method","mode","redirect","referrer","referrerPolicy","signal","window"];function jt(i){if(i){i.query=i.query||{};for(let e in i)Br.includes(e)||(i.query[e]=i[e],delete i[e])}}function Ut(i){const e=[];for(const t in i){const s=encodeURIComponent(t),r=Array.isArray(i[t])?i[t]:[i[t]];for(let n of r)n=Kr(n),n!==null&&e.push(s+"="+n)}return e.join("&")}function Kr(i){return i==null?null:i instanceof Date?encodeURIComponent(i.toISOString().replace("T"," ")):encodeURIComponent(typeof i=="object"?JSON.stringify(i):i)}class Os extends ce{constructor(){super(...arguments),this.clientId="",this.eventSource=null,this.subscriptions={},this.lastSentSubscriptions=[],this.maxConnectTimeout=15e3,this.reconnectAttempts=0,this.maxReconnectAttempts=1/0,this.predefinedReconnectIntervals=[200,300,500,1e3,1200,1500,2e3],this.pendingConnects=[]}get isConnected(){return!!this.eventSource&&!!this.clientId&&!this.pendingConnects.length}async subscribe(e,t,s){var o;if(!e)throw new Error("topic must be set.");let r=e;if(s){jt(s=Object.assign({},s));const a="options="+encodeURIComponent(JSON.stringify({query:s.query,headers:s.headers}));r+=(r.includes("?")?"&":"?")+a}const n=function(a){const l=a;let f;try{f=JSON.parse(l==null?void 0:l.data)}catch{}t(f||{})};return this.subscriptions[r]||(this.subscriptions[r]=[]),this.subscriptions[r].push(n),this.isConnected?this.subscriptions[r].length===1?await this.submitSubscriptions():(o=this.eventSource)==null||o.addEventListener(r,n):await this.connect(),async()=>this.unsubscribeByTopicAndListener(e,n)}async unsubscribe(e){var s;let t=!1;if(e){const r=this.getSubscriptionsByTopic(e);for(let n in r)if(this.hasSubscriptionListeners(n)){for(let o of this.subscriptions[n])(s=this.eventSource)==null||s.removeEventListener(n,o);delete this.subscriptions[n],t||(t=!0)}}else this.subscriptions={};this.hasSubscriptionListeners()?t&&await this.submitSubscriptions():this.disconnect()}async unsubscribeByPrefix(e){var s;let t=!1;for(let r in this.subscriptions)if((r+"?").startsWith(e)){t=!0;for(let n of this.subscriptions[r])(s=this.eventSource)==null||s.removeEventListener(r,n);delete this.subscriptions[r]}t&&(this.hasSubscriptionListeners()?await this.submitSubscriptions():this.disconnect())}async unsubscribeByTopicAndListener(e,t){var n;let s=!1;const r=this.getSubscriptionsByTopic(e);for(let o in r){if(!Array.isArray(this.subscriptions[o])||!this.subscriptions[o].length)continue;let a=!1;for(let l=this.subscriptions[o].length-1;l>=0;l--)this.subscriptions[o][l]===t&&(a=!0,delete this.subscriptions[o][l],this.subscriptions[o].splice(l,1),(n=this.eventSource)==null||n.removeEventListener(o,t));a&&(this.subscriptions[o].length||delete this.subscriptions[o],s||this.hasSubscriptionListeners(o)||(s=!0))}this.hasSubscriptionListeners()?s&&await this.submitSubscriptions():this.disconnect()}hasSubscriptionListeners(e){var t,s;if(this.subscriptions=this.subscriptions||{},e)return!!((t=this.subscriptions[e])!=null&&t.length);for(let r in this.subscriptions)if((s=this.subscriptions[r])!=null&&s.length)return!0;return!1}async submitSubscriptions(){if(this.clientId)return this.addAllSubscriptionListeners(),this.lastSentSubscriptions=this.getNonEmptySubscriptionKeys(),this.client.send("/api/realtime",{method:"POST",body:{clientId:this.clientId,subscriptions:this.lastSentSubscriptions},requestKey:this.getSubscriptionsCancelKey()}).catch((e=>{if(!(e!=null&&e.isAbort))throw e}))}getSubscriptionsCancelKey(){return"realtime_"+this.clientId}getSubscriptionsByTopic(e){const t={};e=e.includes("?")?e:e+"?";for(let s in this.subscriptions)(s+"?").startsWith(e)&&(t[s]=this.subscriptions[s]);return t}getNonEmptySubscriptionKeys(){const e=[];for(let t in this.subscriptions)this.subscriptions[t].length&&e.push(t);return e}addAllSubscriptionListeners(){if(this.eventSource){this.removeAllSubscriptionListeners();for(let e in this.subscriptions)for(let t of this.subscriptions[e])this.eventSource.addEventListener(e,t)}}removeAllSubscriptionListeners(){if(this.eventSource)for(let e in this.subscriptions)for(let t of this.subscriptions[e])this.eventSource.removeEventListener(e,t)}async connect(){if(!(this.reconnectAttempts>0))return new Promise(((e,t)=>{this.pendingConnects.push({resolve:e,reject:t}),this.pendingConnects.length>1||this.initConnect()}))}initConnect(){this.disconnect(!0),clearTimeout(this.connectTimeoutId),this.connectTimeoutId=setTimeout((()=>{this.connectErrorHandler(new Error("EventSource connect took too long."))}),this.maxConnectTimeout),this.eventSource=new EventSource(this.client.buildURL("/api/realtime")),this.eventSource.onerror=e=>{this.connectErrorHandler(new Error("Failed to establish realtime connection."))},this.eventSource.addEventListener("PB_CONNECT",(e=>{const t=e;this.clientId=t==null?void 0:t.lastEventId,this.submitSubscriptions().then((async()=>{let s=3;for(;this.hasUnsentSubscriptions()&&s>0;)s--,await this.submitSubscriptions()})).then((()=>{for(let r of this.pendingConnects)r.resolve();this.pendingConnects=[],this.reconnectAttempts=0,clearTimeout(this.reconnectTimeoutId),clearTimeout(this.connectTimeoutId);const s=this.getSubscriptionsByTopic("PB_CONNECT");for(let r in s)for(let n of s[r])n(e)})).catch((s=>{this.clientId="",this.connectErrorHandler(s)}))}))}hasUnsentSubscriptions(){const e=this.getNonEmptySubscriptionKeys();if(e.length!=this.lastSentSubscriptions.length)return!0;for(const t of e)if(!this.lastSentSubscriptions.includes(t))return!0;return!1}connectErrorHandler(e){if(clearTimeout(this.connectTimeoutId),clearTimeout(this.reconnectTimeoutId),!this.clientId&&!this.reconnectAttempts||this.reconnectAttempts>this.maxReconnectAttempts){for(let s of this.pendingConnects)s.reject(new z(e));return this.pendingConnects=[],void this.disconnect()}this.disconnect(!0);const t=this.predefinedReconnectIntervals[this.reconnectAttempts]||this.predefinedReconnectIntervals[this.predefinedReconnectIntervals.length-1];this.reconnectAttempts++,this.reconnectTimeoutId=setTimeout((()=>{this.initConnect()}),t)}disconnect(e=!1){var t;if(this.clientId&&this.onDisconnect&&this.onDisconnect(Object.keys(this.subscriptions)),clearTimeout(this.connectTimeoutId),clearTimeout(this.reconnectTimeoutId),this.removeAllSubscriptionListeners(),this.client.cancelRequest(this.getSubscriptionsCancelKey()),(t=this.eventSource)==null||t.close(),this.eventSource=null,this.clientId="",!e){this.reconnectAttempts=0;for(let s of this.pendingConnects)s.resolve();this.pendingConnects=[]}}}class Ps extends ce{decode(e){return e}async getFullList(e,t){if(typeof e=="number")return this._getFullList(e,t);let s=1e3;return(t=Object.assign({},e,t)).batch&&(s=t.batch,delete t.batch),this._getFullList(s,t)}async getList(e=1,t=30,s){return(s=Object.assign({method:"GET"},s)).query=Object.assign({page:e,perPage:t},s.query),this.client.send(this.baseCrudPath,s).then((r=>{var n;return r.items=((n=r.items)==null?void 0:n.map((o=>this.decode(o))))||[],r}))}async getFirstListItem(e,t){return(t=Object.assign({requestKey:"one_by_filter_"+this.baseCrudPath+"_"+e},t)).query=Object.assign({filter:e,skipTotal:1},t.query),this.getList(1,1,t).then((s=>{var r;if(!((r=s==null?void 0:s.items)!=null&&r.length))throw new z({status:404,response:{code:404,message:"The requested resource wasn't found.",data:{}}});return s.items[0]}))}async getOne(e,t){if(!e)throw new z({url:this.client.buildURL(this.baseCrudPath+"/"),status:404,response:{code:404,message:"Missing required record id.",data:{}}});return t=Object.assign({method:"GET"},t),this.client.send(this.baseCrudPath+"/"+encodeURIComponent(e),t).then((s=>this.decode(s)))}async create(e,t){return t=Object.assign({method:"POST",body:e},t),this.client.send(this.baseCrudPath,t).then((s=>this.decode(s)))}async update(e,t,s){return s=Object.assign({method:"PATCH",body:t},s),this.client.send(this.baseCrudPath+"/"+encodeURIComponent(e),s).then((r=>this.decode(r)))}async delete(e,t){return t=Object.assign({method:"DELETE"},t),this.client.send(this.baseCrudPath+"/"+encodeURIComponent(e),t).then((()=>!0))}_getFullList(e=1e3,t){(t=t||{}).query=Object.assign({skipTotal:1},t.query);let s=[],r=async n=>this.getList(n,e||1e3,t).then((o=>{const a=o.items;return s=s.concat(a),a.length==o.perPage?r(n+1):s}));return r(1)}}function fe(i,e,t,s){const r=s!==void 0;return r||t!==void 0?r?(console.warn(i),e.body=Object.assign({},e.body,t),e.query=Object.assign({},e.query,s),e):Object.assign(e,t):e}function St(i){var e;(e=i._resetAutoRefresh)==null||e.call(i)}class Mr extends Ps{constructor(e,t){super(e),this.collectionIdOrName=t}get baseCrudPath(){return this.baseCollectionPath+"/records"}get baseCollectionPath(){return"/api/collections/"+encodeURIComponent(this.collectionIdOrName)}get isSuperusers(){return this.collectionIdOrName=="_superusers"||this.collectionIdOrName=="_pbc_2773867675"}async subscribe(e,t,s){if(!e)throw new Error("Missing topic.");if(!t)throw new Error("Missing subscription callback.");return this.client.realtime.subscribe(this.collectionIdOrName+"/"+e,t,s)}async unsubscribe(e){return e?this.client.realtime.unsubscribe(this.collectionIdOrName+"/"+e):this.client.realtime.unsubscribeByPrefix(this.collectionIdOrName)}async getFullList(e,t){if(typeof e=="number")return super.getFullList(e,t);const s=Object.assign({},e,t);return super.getFullList(s)}async getList(e=1,t=30,s){return super.getList(e,t,s)}async getFirstListItem(e,t){return super.getFirstListItem(e,t)}async getOne(e,t){return super.getOne(e,t)}async create(e,t){return super.create(e,t)}async update(e,t,s){return super.update(e,t,s).then((r=>{var n,o,a;if(((n=this.client.authStore.record)==null?void 0:n.id)===(r==null?void 0:r.id)&&(((o=this.client.authStore.record)==null?void 0:o.collectionId)===this.collectionIdOrName||((a=this.client.authStore.record)==null?void 0:a.collectionName)===this.collectionIdOrName)){let l=Object.assign({},this.client.authStore.record.expand),f=Object.assign({},this.client.authStore.record,r);l&&(f.expand=Object.assign(l,r.expand)),this.client.authStore.save(this.client.authStore.token,f)}return r}))}async delete(e,t){return super.delete(e,t).then((s=>{var r,n,o;return!s||((r=this.client.authStore.record)==null?void 0:r.id)!==e||((n=this.client.authStore.record)==null?void 0:n.collectionId)!==this.collectionIdOrName&&((o=this.client.authStore.record)==null?void 0:o.collectionName)!==this.collectionIdOrName||this.client.authStore.clear(),s}))}authResponse(e){const t=this.decode((e==null?void 0:e.record)||{});return this.client.authStore.save(e==null?void 0:e.token,t),Object.assign({},e,{token:(e==null?void 0:e.token)||"",record:t})}async listAuthMethods(e){return e=Object.assign({method:"GET",fields:"mfa,otp,password,oauth2"},e),this.client.send(this.baseCollectionPath+"/auth-methods",e)}async authWithPassword(e,t,s){let r;s=Object.assign({method:"POST",body:{identity:e,password:t}},s),this.isSuperusers&&(r=s.autoRefreshThreshold,delete s.autoRefreshThreshold,s.autoRefresh||St(this.client));let n=await this.client.send(this.baseCollectionPath+"/auth-with-password",s);return n=this.authResponse(n),r&&this.isSuperusers&&(function(a,l,f,R){St(a);const O=a.beforeSend,v=a.authStore.record,g=a.authStore.onChange(((m,b)=>{(!m||(b==null?void 0:b.id)!=(v==null?void 0:v.id)||(b!=null&&b.collectionId||v!=null&&v.collectionId)&&(b==null?void 0:b.collectionId)!=(v==null?void 0:v.collectionId))&&St(a)}));a._resetAutoRefresh=function(){g(),a.beforeSend=O,delete a._resetAutoRefresh},a.beforeSend=async(m,b)=>{var A;const K=a.authStore.token;if((A=b.query)!=null&&A.autoRefresh)return O?O(m,b):{url:m,sendOptions:b};let x=a.authStore.isValid;if(x&&Cs(a.authStore.token,l))try{await f()}catch{x=!1}x||await R();const j=b.headers||{};for(let k in j)if(k.toLowerCase()=="authorization"&&K==j[k]&&a.authStore.token){j[k]=a.authStore.token;break}return b.headers=j,O?O(m,b):{url:m,sendOptions:b}}})(this.client,r,(()=>this.authRefresh({autoRefresh:!0})),(()=>this.authWithPassword(e,t,Object.assign({autoRefresh:!0},s)))),n}async authWithOAuth2Code(e,t,s,r,n,o,a){let l={method:"POST",body:{provider:e,code:t,codeVerifier:s,redirectURL:r,createData:n}};return l=fe("This form of authWithOAuth2Code(provider, code, codeVerifier, redirectURL, createData?, body?, query?) is deprecated. Consider replacing it with authWithOAuth2Code(provider, code, codeVerifier, redirectURL, createData?, options?).",l,o,a),this.client.send(this.baseCollectionPath+"/auth-with-oauth2",l).then((f=>this.authResponse(f)))}authWithOAuth2(...e){if(e.length>1||typeof(e==null?void 0:e[0])=="string")return console.warn("PocketBase: This form of authWithOAuth2() is deprecated and may get removed in the future. Please replace with authWithOAuth2Code() OR use the authWithOAuth2() realtime form as shown in https://pocketbase.io/docs/authentication/#oauth2-integration."),this.authWithOAuth2Code((e==null?void 0:e[0])||"",(e==null?void 0:e[1])||"",(e==null?void 0:e[2])||"",(e==null?void 0:e[3])||"",(e==null?void 0:e[4])||{},(e==null?void 0:e[5])||{},(e==null?void 0:e[6])||{});const t=(e==null?void 0:e[0])||{};let s=null;t.urlCallback||(s=vs(void 0));const r=new Os(this.client);function n(){s==null||s.close(),r.unsubscribe()}const o={},a=t.requestKey;return a&&(o.requestKey=a),this.listAuthMethods(o).then((l=>{const f=l.oauth2.providers.find((O=>O.name===t.provider));if(!f)throw new z(new Error(`Missing or invalid provider "${t.provider}".`));const R=this.client.buildURL("/api/oauth2-redirect");return new Promise((async(O,v)=>{var m,b,K;const g=a?(m=this.client.cancelControllers)==null?void 0:m[a]:void 0;g&&(g.signal.onabort=()=>{n(),v(new z({isAbort:!0,message:"manually cancelled"}))}),r.onDisconnect=x=>{x.length&&v&&(n(),v(new z(new Error("realtime connection interrupted"))))};try{await r.subscribe("@oauth2",(async k=>{var E;const Z=r.clientId;try{if(!k.state||Z!==k.state)throw new Error("State parameters don't match.");if(k.error||!k.code)throw new Error("OAuth2 redirect error or missing code: "+k.error);const q=Object.assign({},t);delete q.provider,delete q.scopes,delete q.createData,delete q.urlCallback,(E=g==null?void 0:g.signal)!=null&&E.onabort&&(g.signal.onabort=null);const J=await this.authWithOAuth2Code(f.name,k.code,f.codeVerifier,R,t.createData,q);O(J)}catch(q){v(new z(q))}n()}));const x={state:r.clientId};(b=t.scopes)!=null&&b.length&&(x.scope=t.scopes.join(" "));const j=this._replaceQueryParams(f.authURL+R,x);await(t.urlCallback||function(k){s?s.location.href=k:s=vs(k)})(j)}catch(x){(K=g==null?void 0:g.signal)!=null&&K.onabort&&(g.signal.onabort=null),n(),v(new z(x))}}))})).catch((l=>{throw n(),l}))}async authRefresh(e,t){let s={method:"POST"};return s=fe("This form of authRefresh(body?, query?) is deprecated. Consider replacing it with authRefresh(options?).",s,e,t),this.client.send(this.baseCollectionPath+"/auth-refresh",s).then((r=>this.authResponse(r)))}async requestPasswordReset(e,t,s){let r={method:"POST",body:{email:e}};return r=fe("This form of requestPasswordReset(email, body?, query?) is deprecated. Consider replacing it with requestPasswordReset(email, options?).",r,t,s),this.client.send(this.baseCollectionPath+"/request-password-reset",r).then((()=>!0))}async confirmPasswordReset(e,t,s,r,n){let o={method:"POST",body:{token:e,password:t,passwordConfirm:s}};return o=fe("This form of confirmPasswordReset(token, password, passwordConfirm, body?, query?) is deprecated. Consider replacing it with confirmPasswordReset(token, password, passwordConfirm, options?).",o,r,n),this.client.send(this.baseCollectionPath+"/confirm-password-reset",o).then((()=>!0))}async requestVerification(e,t,s){let r={method:"POST",body:{email:e}};return r=fe("This form of requestVerification(email, body?, query?) is deprecated. Consider replacing it with requestVerification(email, options?).",r,t,s),this.client.send(this.baseCollectionPath+"/request-verification",r).then((()=>!0))}async confirmVerification(e,t,s){let r={method:"POST",body:{token:e}};return r=fe("This form of confirmVerification(token, body?, query?) is deprecated. Consider replacing it with confirmVerification(token, options?).",r,t,s),this.client.send(this.baseCollectionPath+"/confirm-verification",r).then((()=>{const n=Ce(e),o=this.client.authStore.record;return o&&!o.verified&&o.id===n.id&&o.collectionId===n.collectionId&&(o.verified=!0,this.client.authStore.save(this.client.authStore.token,o)),!0}))}async requestEmailChange(e,t,s){let r={method:"POST",body:{newEmail:e}};return r=fe("This form of requestEmailChange(newEmail, body?, query?) is deprecated. Consider replacing it with requestEmailChange(newEmail, options?).",r,t,s),this.client.send(this.baseCollectionPath+"/request-email-change",r).then((()=>!0))}async confirmEmailChange(e,t,s,r){let n={method:"POST",body:{token:e,password:t}};return n=fe("This form of confirmEmailChange(token, password, body?, query?) is deprecated. Consider replacing it with confirmEmailChange(token, password, options?).",n,s,r),this.client.send(this.baseCollectionPath+"/confirm-email-change",n).then((()=>{const o=Ce(e),a=this.client.authStore.record;return a&&a.id===o.id&&a.collectionId===o.collectionId&&this.client.authStore.clear(),!0}))}async listExternalAuths(e,t){return this.client.collection("_externalAuths").getFullList(Object.assign({},t,{filter:this.client.filter("recordRef = {:id}",{id:e})}))}async unlinkExternalAuth(e,t,s){const r=await this.client.collection("_externalAuths").getFirstListItem(this.client.filter("recordRef = {:recordId} && provider = {:provider}",{recordId:e,provider:t}));return this.client.collection("_externalAuths").delete(r.id,s).then((()=>!0))}async requestOTP(e,t){return t=Object.assign({method:"POST",body:{email:e}},t),this.client.send(this.baseCollectionPath+"/request-otp",t)}async authWithOTP(e,t,s){return s=Object.assign({method:"POST",body:{otpId:e,password:t}},s),this.client.send(this.baseCollectionPath+"/auth-with-otp",s).then((r=>this.authResponse(r)))}async impersonate(e,t,s){(s=Object.assign({method:"POST",body:{duration:t}},s)).headers=s.headers||{},s.headers.Authorization||(s.headers.Authorization=this.client.authStore.token);const r=new ks(this.client.baseURL,new Et,this.client.lang),n=await r.send(this.baseCollectionPath+"/impersonate/"+encodeURIComponent(e),s);return r.authStore.save(n==null?void 0:n.token,this.decode((n==null?void 0:n.record)||{})),r}_replaceQueryParams(e,t={}){let s=e,r="";e.indexOf("?")>=0&&(s=e.substring(0,e.indexOf("?")),r=e.substring(e.indexOf("?")+1));const n={},o=r.split("&");for(const a of o){if(a=="")continue;const l=a.split("=");n[decodeURIComponent(l[0].replace(/\+/g," "))]=decodeURIComponent((l[1]||"").replace(/\+/g," "))}for(let a in t)t.hasOwnProperty(a)&&(t[a]==null?delete n[a]:n[a]=t[a]);r="";for(let a in n)n.hasOwnProperty(a)&&(r!=""&&(r+="&"),r+=encodeURIComponent(a.replace(/%20/g,"+"))+"="+encodeURIComponent(n[a].replace(/%20/g,"+")));return r!=""?s+"?"+r:s}}function vs(i){if(typeof window>"u"||!(window!=null&&window.open))throw new z(new Error("Not in a browser context - please pass a custom urlCallback function."));let e=1024,t=768,s=window.innerWidth,r=window.innerHeight;e=e>s?s:e,t=t>r?r:t;let n=s/2-e/2,o=r/2-t/2;return window.open(i,"popup_window","width="+e+",height="+t+",top="+o+",left="+n+",resizable,menubar=no")}class Wr extends Ps{get baseCrudPath(){return"/api/collections"}async import(e,t=!1,s){return s=Object.assign({method:"PUT",body:{collections:e,deleteMissing:t}},s),this.client.send(this.baseCrudPath+"/import",s).then((()=>!0))}async getScaffolds(e){return e=Object.assign({method:"GET"},e),this.client.send(this.baseCrudPath+"/meta/scaffolds",e)}async truncate(e,t){return t=Object.assign({method:"DELETE"},t),this.client.send(this.baseCrudPath+"/"+encodeURIComponent(e)+"/truncate",t).then((()=>!0))}}class zr extends ce{async getList(e=1,t=30,s){return(s=Object.assign({method:"GET"},s)).query=Object.assign({page:e,perPage:t},s.query),this.client.send("/api/logs",s)}async getOne(e,t){if(!e)throw new z({url:this.client.buildURL("/api/logs/"),status:404,response:{code:404,message:"Missing required log id.",data:{}}});return t=Object.assign({method:"GET"},t),this.client.send("/api/logs/"+encodeURIComponent(e),t)}async getStats(e){return e=Object.assign({method:"GET"},e),this.client.send("/api/logs/stats",e)}}class Vr extends ce{async check(e){return e=Object.assign({method:"GET"},e),this.client.send("/api/health",e)}}class Hr extends ce{getUrl(e,t,s={}){return console.warn("Please replace pb.files.getUrl() with pb.files.getURL()"),this.getURL(e,t,s)}getURL(e,t,s={}){if(!t||!(e!=null&&e.id)||!(e!=null&&e.collectionId)&&!(e!=null&&e.collectionName))return"";const r=[];r.push("api"),r.push("files"),r.push(encodeURIComponent(e.collectionId||e.collectionName)),r.push(encodeURIComponent(e.id)),r.push(encodeURIComponent(t));let n=this.client.buildURL(r.join("/"));s.download===!1&&delete s.download;const o=Ut(s);return o&&(n+=(n.includes("?")?"&":"?")+o),n}async getToken(e){return e=Object.assign({method:"POST"},e),this.client.send("/api/files/token",e).then((t=>(t==null?void 0:t.token)||""))}}class Gr extends ce{async getFullList(e){return e=Object.assign({method:"GET"},e),this.client.send("/api/backups",e)}async create(e,t){return t=Object.assign({method:"POST",body:{name:e}},t),this.client.send("/api/backups",t).then((()=>!0))}async upload(e,t){return t=Object.assign({method:"POST",body:e},t),this.client.send("/api/backups/upload",t).then((()=>!0))}async delete(e,t){return t=Object.assign({method:"DELETE"},t),this.client.send(`/api/backups/${encodeURIComponent(e)}`,t).then((()=>!0))}async restore(e,t){return t=Object.assign({method:"POST"},t),this.client.send(`/api/backups/${encodeURIComponent(e)}/restore`,t).then((()=>!0))}getDownloadUrl(e,t){return console.warn("Please replace pb.backups.getDownloadUrl() with pb.backups.getDownloadURL()"),this.getDownloadURL(e,t)}getDownloadURL(e,t){return this.client.buildURL(`/api/backups/${encodeURIComponent(t)}?token=${encodeURIComponent(e)}`)}}class Jr extends ce{async getFullList(e){return e=Object.assign({method:"GET"},e),this.client.send("/api/crons",e)}async run(e,t){return t=Object.assign({method:"POST"},t),this.client.send(`/api/crons/${encodeURIComponent(e)}`,t).then((()=>!0))}}function Tt(i){return typeof Blob<"u"&&i instanceof Blob||typeof File<"u"&&i instanceof File||i!==null&&typeof i=="object"&&i.uri&&(typeof navigator<"u"&&navigator.product==="ReactNative"||typeof global<"u"&&global.HermesInternal)}function Rt(i){var e;return i&&(((e=i.constructor)==null?void 0:e.name)==="FormData"||typeof FormData<"u"&&i instanceof FormData)}function ys(i){for(const e in i){const t=Array.isArray(i[e])?i[e]:[i[e]];for(const s of t)if(Tt(s))return!0}return!1}const $r=/^[\-\.\d]+$/;function ws(i){if(typeof i!="string")return i;if(i=="true")return!0;if(i=="false")return!1;if((i[0]==="-"||i[0]>="0"&&i[0]<="9")&&$r.test(i)){let e=+i;if(""+e===i)return e}return i}class Qr extends ce{constructor(){super(...arguments),this.requests=[],this.subs={}}collection(e){return this.subs[e]||(this.subs[e]=new Xr(this.requests,e)),this.subs[e]}async send(e){const t=new FormData,s=[];for(let r=0;r<this.requests.length;r++){const n=this.requests[r];if(s.push({method:n.method,url:n.url,headers:n.headers,body:n.json}),n.files)for(let o in n.files){const a=n.files[o]||[];for(let l of a)t.append("requests."+r+"."+o,l)}}return t.append("@jsonPayload",JSON.stringify({requests:s})),e=Object.assign({method:"POST",body:t},e),this.client.send("/api/batch",e)}}class Xr{constructor(e,t){this.requests=[],this.requests=e,this.collectionIdOrName=t}upsert(e,t){t=Object.assign({body:e||{}},t);const s={method:"PUT",url:"/api/collections/"+encodeURIComponent(this.collectionIdOrName)+"/records"};this.prepareRequest(s,t),this.requests.push(s)}create(e,t){t=Object.assign({body:e||{}},t);const s={method:"POST",url:"/api/collections/"+encodeURIComponent(this.collectionIdOrName)+"/records"};this.prepareRequest(s,t),this.requests.push(s)}update(e,t,s){s=Object.assign({body:t||{}},s);const r={method:"PATCH",url:"/api/collections/"+encodeURIComponent(this.collectionIdOrName)+"/records/"+encodeURIComponent(e)};this.prepareRequest(r,s),this.requests.push(r)}delete(e,t){t=Object.assign({},t);const s={method:"DELETE",url:"/api/collections/"+encodeURIComponent(this.collectionIdOrName)+"/records/"+encodeURIComponent(e)};this.prepareRequest(s,t),this.requests.push(s)}prepareRequest(e,t){if(jt(t),e.headers=t.headers,e.json={},e.files={},t.query!==void 0){const r=Ut(t.query);r&&(e.url+=(e.url.includes("?")?"&":"?")+r)}let s=t.body;Rt(s)&&(s=(function(n){let o={};return n.forEach(((a,l)=>{if(l==="@jsonPayload"&&typeof a=="string")try{let f=JSON.parse(a);Object.assign(o,f)}catch(f){console.warn("@jsonPayload error:",f)}else o[l]!==void 0?(Array.isArray(o[l])||(o[l]=[o[l]]),o[l].push(ws(a))):o[l]=ws(a)})),o})(s));for(const r in s){const n=s[r];if(Tt(n))e.files[r]=e.files[r]||[],e.files[r].push(n);else if(Array.isArray(n)){const o=[],a=[];for(const l of n)Tt(l)?o.push(l):a.push(l);if(o.length>0&&o.length==n.length){e.files[r]=e.files[r]||[];for(let l of o)e.files[r].push(l)}else if(e.json[r]=a,o.length>0){let l=r;r.startsWith("+")||r.endsWith("+")||(l+="+"),e.files[l]=e.files[l]||[];for(let f of o)e.files[l].push(f)}}else e.json[r]=n}}}class ks{get baseUrl(){return this.baseURL}set baseUrl(e){this.baseURL=e}constructor(e="/",t,s="en-US"){this.cancelControllers={},this.recordServices={},this.enableAutoCancellation=!0,this.baseURL=e,this.lang=s,t?this.authStore=t:typeof window<"u"&&window.Deno?this.authStore=new Et:this.authStore=new Dr,this.collections=new Wr(this),this.files=new Hr(this),this.logs=new zr(this),this.settings=new Fr(this),this.realtime=new Os(this),this.health=new Vr(this),this.backups=new Gr(this),this.crons=new Jr(this)}get admins(){return this.collection("_superusers")}createBatch(){return new Qr(this)}collection(e){return this.recordServices[e]||(this.recordServices[e]=new Mr(this,e)),this.recordServices[e]}autoCancellation(e){return this.enableAutoCancellation=!!e,this}cancelRequest(e){return this.cancelControllers[e]&&(this.cancelControllers[e].abort(),delete this.cancelControllers[e]),this}cancelAllRequests(){for(let e in this.cancelControllers)this.cancelControllers[e].abort();return this.cancelControllers={},this}filter(e,t){if(!t)return e;for(let s in t){let r=t[s];switch(typeof r){case"boolean":case"number":r=""+r;break;case"string":r="'"+r.replace(/'/g,"\\'")+"'";break;default:r=r===null?"null":r instanceof Date?"'"+r.toISOString().replace("T"," ")+"'":"'"+JSON.stringify(r).replace(/'/g,"\\'")+"'"}e=e.replaceAll("{:"+s+"}",r)}return e}getFileUrl(e,t,s={}){return console.warn("Please replace pb.getFileUrl() with pb.files.getURL()"),this.files.getURL(e,t,s)}buildUrl(e){return console.warn("Please replace pb.buildUrl() with pb.buildURL()"),this.buildURL(e)}buildURL(e){var s;let t=this.baseURL;return typeof window>"u"||!window.location||t.startsWith("https://")||t.startsWith("http://")||(t=(s=window.location.origin)!=null&&s.endsWith("/")?window.location.origin.substring(0,window.location.origin.length-1):window.location.origin||"",this.baseURL.startsWith("/")||(t+=window.location.pathname||"/",t+=t.endsWith("/")?"":"/"),t+=this.baseURL),e&&(t+=t.endsWith("/")?"":"/",t+=e.startsWith("/")?e.substring(1):e),t}async send(e,t){t=this.initSendOptions(e,t);let s=this.buildURL(e);if(this.beforeSend){const r=Object.assign({},await this.beforeSend(s,t));r.url!==void 0||r.options!==void 0?(s=r.url||s,t=r.options||t):Object.keys(r).length&&(t=r,console!=null&&console.warn&&console.warn("Deprecated format of beforeSend return: please use `return { url, options }`, instead of `return options`."))}if(t.query!==void 0){const r=Ut(t.query);r&&(s+=(s.includes("?")?"&":"?")+r),delete t.query}return this.getHeader(t.headers,"Content-Type")=="application/json"&&t.body&&typeof t.body!="string"&&(t.body=JSON.stringify(t.body)),(t.fetch||fetch)(s,t).then((async r=>{var o;let n={};try{n=await r.json()}catch(a){if((o=t.signal)!=null&&o.aborted||(a==null?void 0:a.name)=="AbortError"||(a==null?void 0:a.message)=="Aborted")throw a}if(this.afterSend&&(n=await this.afterSend(r,n,t)),r.status>=400)throw new z({url:r.url,status:r.status,data:n});return n})).catch((r=>{throw new z(r)}))}initSendOptions(e,t){if((t=Object.assign({method:"GET"},t)).body=(function(r){if(typeof FormData>"u"||r===void 0||typeof r!="object"||r===null||Rt(r)||!ys(r))return r;const n=new FormData;for(const o in r){const a=r[o];if(a!==void 0)if(typeof a!="object"||ys({data:a})){const l=Array.isArray(a)?a:[a];for(let f of l)n.append(o,f)}else{let l={};l[o]=a,n.append("@jsonPayload",JSON.stringify(l))}}return n})(t.body),jt(t),t.query=Object.assign({},t.params,t.query),t.requestKey===void 0&&(t.$autoCancel===!1||t.query.$autoCancel===!1?t.requestKey=null:(t.$cancelKey||t.query.$cancelKey)&&(t.requestKey=t.$cancelKey||t.query.$cancelKey)),delete t.$autoCancel,delete t.query.$autoCancel,delete t.$cancelKey,delete t.query.$cancelKey,this.getHeader(t.headers,"Content-Type")!==null||Rt(t.body)||(t.headers=Object.assign({},t.headers,{"Content-Type":"application/json"})),this.getHeader(t.headers,"Accept-Language")===null&&(t.headers=Object.assign({},t.headers,{"Accept-Language":this.lang})),this.authStore.token&&this.getHeader(t.headers,"Authorization")===null&&(t.headers=Object.assign({},t.headers,{Authorization:this.authStore.token})),this.enableAutoCancellation&&t.requestKey!==null){const s=t.requestKey||(t.method||"GET")+e;delete t.requestKey,this.cancelRequest(s);const r=new AbortController;this.cancelControllers[s]=r,t.signal=r.signal}return t}getHeader(e,t){e=e||{},t=t.toLowerCase();for(let s in e)if(s.toLowerCase()==t)return e[s];return null}}const Is="https://pocketbase.ccllc.pro",xs=Is;let _t=null;function Yr(){if(typeof window>"u")throw new Error("PocketBase client is only available in the browser. Use load/actions for server data.");return _t||(_t=new ks(Is)),_t}new Proxy({},{get(i,e){return e==="baseUrl"?xs:Yr()[e]}});const Zr=["EA","BX","CA","PK","PLT","LF"],en=["Framing","Insulation","Drywall","T-Bar","Painting","Masking","Misc"],tn=["ACT","Channel","Fasteners","Finishing Materials","Adhesives","Mud","Corner Bead","Sanding","Tape","Metal Studs","Metal Tracks","FRP","Gyp","Insulation","Paint","Weatherproofing","Misc"];var sn=N('<input type="hidden" name="id"/>'),rn=N('<p class="text-destructive text-sm"> </p>'),nn=N('<video class="border-input w-full rounded-lg border" playsinline=""></video>',2),on=N('<div class="bg-background/95 fixed inset-0 z-50 flex flex-col items-center justify-center gap-4 p-4 backdrop-blur-sm" role="dialog" aria-label="Scan barcode"><div class="flex w-full max-w-sm flex-col gap-2"><!> <div class="flex gap-2"><!></div></div></div>'),an=N('<div class="flex flex-wrap items-center gap-3"><img alt="" class="size-20 rounded border object-cover"/> <span class="text-muted-foreground text-sm">Replace:</span></div>'),cn=N("<option> </option>"),ln=N("<option> </option>"),dn=N("<option> </option>"),un=N("<option> </option>"),hn=N('<p class="text-destructive text-sm"> </p>'),pn=N('<form method="POST" enctype="multipart/form-data" class="flex flex-col gap-4"><!> <div class="grid grid-cols-2 gap-4"><div class="space-y-2"><!> <!></div> <div class="space-y-2"><!> <div class="flex gap-2"><!> <!></div></div></div> <!> <div class="space-y-2"><!> <!></div> <div class="space-y-2"><!> <!> <!></div> <div class="grid grid-cols-2 gap-4"><div class="space-y-2"><!> <select id="UOM" name="UOM" class="border-input bg-background flex h-9 w-full rounded-md border px-3 py-1 text-sm shadow-xs"><option>—</option><!></select></div> <div class="space-y-2"><!> <!></div></div> <div class="space-y-2"><!> <!></div> <div class="grid grid-cols-2 gap-4"><div class="space-y-2"><!> <select id="Catagory" name="Catagory" class="border-input bg-background flex h-9 w-full rounded-md border px-3 py-1 text-sm shadow-xs"><option>—</option><!></select></div> <div class="space-y-2"><!> <select id="Sub_Catagory" name="Sub_Catagory" class="border-input bg-background flex h-9 w-full rounded-md border px-3 py-1 text-sm shadow-xs"><option>—</option><!></select></div></div> <div class="space-y-2"><!> <select id="Parent" name="Parent" class="border-input bg-background flex h-9 w-full rounded-md border px-3 py-1 text-sm shadow-xs"><option>—</option><!></select></div> <div class="flex flex-wrap gap-6"><label class="flex items-center gap-2 text-sm"><input type="checkbox" name="Has_Parent" value="on" class="border-input size-4 rounded"/> Has Parent</label> <label class="flex items-center gap-2 text-sm"><input type="checkbox" name="Stock" value="on" class="border-input size-4 rounded"/> Stock</label></div> <!> <div class="flex justify-end gap-2"><!></div></form>');function Un(i,e){H(e,!0);const t="Stackq_Items";function s(c,u){return`${xs}/api/files/${t}/${c}/${u}`}let r=S(e,"item",3,null),n=S(e,"itemsForParent",19,()=>[]);const o=P(()=>!!r()),a=P(()=>r()?n().filter(c=>c.id!==r().id):n()),l=P(()=>{var c;return((c=r())==null?void 0:c.Item)??""}),f=P(()=>{var c;return((c=r())==null?void 0:c.SKU)??""}),R=P(()=>{var c;return((c=r())==null?void 0:c.Description)??""}),O=P(()=>{var c;return((c=r())==null?void 0:c.UOM)??""}),v=P(()=>{var c;return((c=r())==null?void 0:c.Cost)!=null?String(r().Cost):""}),g=P(()=>{var c;return((c=r())==null?void 0:c.Vendor)??""}),m=P(()=>{var c,u;return Array.isArray((c=r())==null?void 0:c.Catagory)?r().Catagory[0]:((u=r())==null?void 0:u.Catagory)??""}),b=P(()=>{var c,u;return Array.isArray((c=r())==null?void 0:c.Sub_Catagory)?r().Sub_Catagory[0]:((u=r())==null?void 0:u.Sub_Catagory)??""}),K=P(()=>{var c;return((c=r())==null?void 0:c.Parent)??""}),x=P(()=>{var c;return!!((c=r())!=null&&c.Has_Parent)}),j=P(()=>{var c;return!!((c=r())!=null&&c.Stock)});let A=$(""),k=$(!1),Z=$(null),E=$(void 0),q=null,J=0;us(()=>{I(A,d(f),!0)});async function tt(){if(typeof globalThis>"u"||"BarcodeDetector"in globalThis)return!0;try{const c=await $s(()=>import("./Bd99md_0.js"),[],import.meta.url);return globalThis.BarcodeDetector=c.BarcodeDetector,!0}catch{return!1}}async function ie(){if(I(Z,null),!await tt()){I(Z,"Failed to load barcode scanner. Try again or use Chrome/Edge."),I(k,!0);return}try{q=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment",width:{ideal:1280},height:{ideal:720}}}),I(k,!0)}catch(u){I(Z,u instanceof Error?u.message:"Could not access camera.",!0),I(k,!0)}}us(()=>{if(!(!d(k)||!q||!d(E)))return d(E).srcObject=q,d(E).play().then(()=>st()).catch(()=>{}),()=>{d(E).srcObject&&(d(E).srcObject=null)}});const Qe=300;function st(){if(!d(k)||!d(E)||!("BarcodeDetector"in globalThis))return;const c=new globalThis.BarcodeDetector;let u=0;async function h(){if(!d(k)||!d(E))return;if(d(E).readyState<2){J=requestAnimationFrame(h);return}const F=Date.now();if(F-u>=Qe){u=F;try{const W=await c.detect(d(E));if(W.length>0){I(A,W[0].rawValue,!0),rt();return}}catch{}}J=requestAnimationFrame(h)}h()}function rt(){I(k,!1),I(Z,null),J&&(cancelAnimationFrame(J),J=0),q&&(q.getTracks().forEach(c=>c.stop()),q=null),d(E)&&d(E).srcObject&&(d(E).srcObject=null)}var le=pn(),Xe=y(le);{var nt=c=>{var u=sn();yt(u),re(()=>Qs(u,r().id)),p(c,u)};Q(Xe,c=>{d(o)&&c(nt)})}var Oe=C(Xe,2),te=y(Oe),de=y(te);ne(de,{for:"Item",children:(c,u)=>{M();var h=Y("Item");p(c,h)},$$slots:{default:!0}});var be=C(de,2);Se(be,{id:"Item",name:"Item",get value(){return d(l)},required:!0}),w(te);var ue=C(te,2),we=y(ue);ne(we,{for:"SKU",children:(c,u)=>{M();var h=Y("SKU");p(c,h)},$$slots:{default:!0}});var se=C(we,2),Kt=y(se);Se(Kt,{id:"SKU",name:"SKU",class:"flex-1",get value(){return d(A)},set value(c){I(A,c,!0)}});var Ts=C(Kt,2);wt(Ts,{type:"button",variant:"outline",onclick:ie,title:"Scan barcode",children:(c,u)=>{M();var h=Y("Scan");p(c,h)},$$slots:{default:!0}}),w(se),w(ue),w(Oe);var Mt=C(Oe,2);{var Rs=c=>{var u=on(),h=y(u),F=y(h);{var W=he=>{var pe=rn(),Pe=y(pe,!0);w(pe),re(()=>ve(Pe,d(Z))),p(he,pe)},Ms=he=>{var pe=nn();pe.muted=!0,Ss(pe,Pe=>I(E,Pe),()=>d(E)),p(he,pe)};Q(F,he=>{d(Z)?he(W):he(Ms,!1)})}var ls=C(F,2),Ws=y(ls);wt(Ws,{type:"button",variant:"outline",class:"flex-1",onclick:rt,children:(he,pe)=>{M();var Pe=Y("Cancel");p(he,Pe)},$$slots:{default:!0}}),w(ls),w(h),w(u),p(c,u)};Q(Mt,c=>{d(k)&&c(Rs)})}var ot=C(Mt,2),Wt=y(ot);ne(Wt,{for:"Description",children:(c,u)=>{M();var h=Y("Description");p(c,h)},$$slots:{default:!0}});var As=C(Wt,2);Se(As,{id:"Description",name:"Description",get value(){return d(R)}}),w(ot);var it=C(ot,2),zt=y(it);ne(zt,{for:"Image",children:(c,u)=>{M();var h=Y("Image");p(c,h)},$$slots:{default:!0}});var Vt=C(zt,2);{var Es=c=>{var u=an(),h=y(u);M(2),w(u),re(F=>hs(h,"src",F),[()=>s(r().id,r().Image)]),p(c,u)};Q(Vt,c=>{var u;d(o)&&((u=r())!=null&&u.Image)&&c(Es)})}var js=C(Vt,2);Se(js,{id:"Image",name:"Image",type:"file",accept:"image/*"}),w(it);var at=C(it,2),ct=y(at),Ht=y(ct);ne(Ht,{for:"UOM",children:(c,u)=>{M();var h=Y("UOM");p(c,h)},$$slots:{default:!0}});var Gt=C(Ht,2),lt=y(Gt);lt.value=lt.__value="";var Us=C(lt);ke(Us,17,()=>Zr,Ie,(c,u)=>{var h=cn(),F=y(h,!0);w(h);var W={};re(()=>{Ye(h,d(O)===d(u)),ve(F,d(u)),W!==(W=d(u))&&(h.value=(h.__value=d(u))??"")}),p(c,h)}),w(Gt),w(ct);var Jt=C(ct,2),$t=y(Jt);ne($t,{for:"Cost",children:(c,u)=>{M();var h=Y("Cost");p(c,h)},$$slots:{default:!0}});var Ns=C($t,2);Se(Ns,{id:"Cost",name:"Cost",type:"number",step:"any",get value(){return d(v)}}),w(Jt),w(at);var dt=C(at,2),Qt=y(dt);ne(Qt,{for:"Vendor",children:(c,u)=>{M();var h=Y("Vendor");p(c,h)},$$slots:{default:!0}});var Ls=C(Qt,2);Se(Ls,{id:"Vendor",name:"Vendor",get value(){return d(g)}}),w(dt);var ut=C(dt,2),ht=y(ut),Xt=y(ht);ne(Xt,{for:"Catagory",children:(c,u)=>{M();var h=Y("Catagory");p(c,h)},$$slots:{default:!0}});var Yt=C(Xt,2),pt=y(Yt);pt.value=pt.__value="";var qs=C(pt);ke(qs,17,()=>en,Ie,(c,u)=>{var h=ln(),F=y(h,!0);w(h);var W={};re(()=>{Ye(h,d(m)===d(u)),ve(F,d(u)),W!==(W=d(u))&&(h.value=(h.__value=d(u))??"")}),p(c,h)}),w(Yt),w(ht);var Zt=C(ht,2),es=y(Zt);ne(es,{for:"Sub_Catagory",children:(c,u)=>{M();var h=Y("Sub_Catagory");p(c,h)},$$slots:{default:!0}});var ts=C(es,2),ft=y(ts);ft.value=ft.__value="";var Ds=C(ft);ke(Ds,17,()=>tn,Ie,(c,u)=>{var h=dn(),F=y(h,!0);w(h);var W={};re(()=>{Ye(h,d(b)===d(u)),ve(F,d(u)),W!==(W=d(u))&&(h.value=(h.__value=d(u))??"")}),p(c,h)}),w(ts),w(Zt),w(ut);var gt=C(ut,2),ss=y(gt);ne(ss,{for:"Parent",children:(c,u)=>{M();var h=Y("Parent");p(c,h)},$$slots:{default:!0}});var rs=C(ss,2),mt=y(rs);mt.value=mt.__value="";var Fs=C(mt);ke(Fs,17,()=>d(a),Ie,(c,u)=>{var h=un(),F=y(h,!0);w(h);var W={};re(()=>{Ye(h,d(K)===d(u).id),ve(F,d(u).Item||d(u).SKU||d(u).id),W!==(W=d(u).id)&&(h.value=(h.__value=d(u).id)??"")}),p(c,h)}),w(rs),w(gt);var bt=C(gt,2),vt=y(bt),ns=y(vt);yt(ns),M(),w(vt);var os=C(vt,2),is=y(os);yt(is),M(),w(os),w(bt);var as=C(bt,2);{var Bs=c=>{var u=hn(),h=y(u,!0);w(u),re(()=>ve(h,e.error)),p(c,u)};Q(as,c=>{e.error&&c(Bs)})}var cs=C(as,2),Ks=y(cs);wt(Ks,{type:"submit",children:(c,u)=>{M();var h=Y();re(()=>ve(h,e.submitLabel)),p(c,h)},$$slots:{default:!0}}),w(cs),w(le),cr(le,(c,u)=>{var h;return(h=lr)==null?void 0:h(c,u)},()=>()=>async({update:c,result:u})=>{var h,F;await c(),u.type==="success"&&((h=u.data)!=null&&h.success)&&((F=e.onSuccess)==null||F.call(e))}),re(()=>{hs(le,"action",e.action),ps(ns,d(x)),ps(is,d(j))}),p(i,le),G()}export{En as D,Un as I,An as a,Rn as b,jn as c,Tn as d};