@fungi.computer/inkcap 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$n as n,$r as r,$t as i,A as a,Ai as o,An as s,Ar as c,B as l,Bi as u,Bn as d,Br as f,C as p,Ci as m,Cn as h,Ct as g,D as _,Di as v,Dn as y,Dr as b,Ei as x,En as S,Er as C,Et as w,F as T,Fr as E,G as D,Gn as O,Gr as k,Gt as A,H as j,Hi as M,I as ee,In as te,J as N,Jn as ne,Jr as re,Jt as ie,K as ae,Kn as oe,Kr as se,Kt as ce,L as le,Li as P,Ln as ue,Lr as de,Lt as F,M as fe,Mi as pe,Mn as me,Mr as he,N as ge,Ni as _e,Nn as ve,Nr as ye,O as be,Oi as xe,On as Se,Or as Ce,P as we,Pi as Te,Pn as Ee,Pr as De,Q as Oe,Qn as ke,Qt as Ae,R as je,Ri as Me,Rn as Ne,Rr as Pe,Rt as Fe,Si as Ie,Sn as I,St as L,T as Le,Ti as Re,Tn as ze,Tr as Be,Tt as Ve,U as He,Un as Ue,V as We,Vi as Ge,Vr as Ke,Wn as qe,X as Je,Xn as Ye,Xr as Xe,Yn as Ze,Yr as R,Z as Qe,Zn as $e,Zr as et,_ as tt,_i as nt,_n as rt,_t as it,ai as z,an as at,at as ot,b as st,bn as ct,bt as B,cn as V,ct as lt,d as ut,dn as dt,ei as ft,en as H,er as pt,et as mt,f as ht,fn as gt,g as _t,gn as vt,h as yt,hn as bt,i as xt,in as St,j as Ct,ji as wt,jn as Tt,jr as Et,k as Dt,ki as Ot,kn as kt,kr as At,l as jt,li as Mt,ln as U,lt as Nt,m as Pt,mn as Ft,ni as It,nn as Lt,nr as Rt,nt as zt,o as Bt,on as Vt,p as Ht,pn as W,pt as Ut,qn as Wt,qt as Gt,r as Kt,rn as qt,rt as Jt,s as Yt,sn as Xt,st as G,t as Zt,tr as Qt,tt as $t,u as en,un as tn,ut as nn,v as rn,vn as an,vt as on,w as sn,wi as cn,wn as ln,wr as un,wt as dn,x as fn,xi as pn,xn as mn,y as hn,yn as gn,z as _n,zi as vn,zn as K,zr as yn}from"./dialog-jssrzu-h.js";import{C as bn,S as xn,_ as Sn,a as Cn,b as wn,c as Tn,d as En,f as Dn,g as On,h as kn,i as An,l as jn,m as Mn,n as Nn,o as Pn,p as Fn,r as In,s as Ln,t as Rn,u as zn,v as Bn,w as Vn,x as Hn,y as Un}from"./useForm-JWOEk10W.js";import{A as Wn,C as Gn,D as Kn,E as qn,F as Jn,I as Yn,M as Xn,N as Zn,O as Qn,P as $n,S as er,T as tr,_ as nr,a as rr,c as ir,d as ar,f as or,g as sr,i as cr,j as lr,k as ur,m as dr,n as fr,p as pr,s as mr,t as hr,v as gr,w as _r,x as vr}from"./index-Bj0ZDQ9x.js";function yr(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var br=class extends lr{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Wn.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!$n(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(yr(e,n).forEach(e=>{e.destroy()}),yr(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){let n=new Set;return t.map((r,i)=>{let a=e[i];return r.defaultedQueryOptions.notifyOnChangeProps?a:r.observer.trackResult(a,e=>{n.has(e)||(n.add(e),t.forEach(t=>{t.observer.trackProp(e)}))})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=Zn(this.#a,t(e))),this.#a}return e}#f(){return!this.#r?.combine||this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new ur(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=this.#t.slice(),this.#t[n]=t,this.#h())}#h(){if(this.hasListeners()){let e=this.#f(),t=this.#a,n=e?t:this.#d(this.#u(this.#t,this.#l),this.#r?.combine);(e||t!==n)&&Wn.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},q=e(Pe(),1);function xr({queries:e,...t},n){let r=Jn(n),i=Qn(),a=Kn(),o=t.subscribed!==!1,s=q.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:o?`optimistic`:void 0,t}),[e,r,i,o]);s.forEach(e=>{vr(e);let t=r.getQueryCache().get(e.queryHash);_r(e,a,t)}),qn(a);let[c]=q.useState(()=>new br(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;q.useSyncExternalStore(q.useCallback(e=>f?c.subscribe(Wn.batchCalls(e)):Xn,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),q.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>Gn(s[t],e))?l.flatMap((e,t)=>{let n=s[t];if(n&&Gn(n,e)){let e=new ur(r,n);return er(n,e,a)}return[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=s[t];return n&&tr({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m)throw m.error;return u(d())}var Sr=E(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);b.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>Ce(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>c(e,t,n),e.parseAsync=async(t,n)=>At(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Et(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>he(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Cr=E(`ZodMiniObject`,(e,t)=>{C.init(e,t),Sr.init(e,t),ye(e,`shape`,()=>t.shape)});function wr(e,t){return new Cr({type:`object`,shape:e??{},...De(t)})}var Tr=E(`ZodMiniLiteral`,(e,t)=>{Be.init(e,t),Sr.init(e,t)});function Er(e,t){return new Tr({type:`literal`,values:Array.isArray(e)?e:[e],...De(t)})}var Dr=Ne(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Or=Ne(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),kr=Ne(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ar=Ne(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),jr=Ne(`FolderPlus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Mr=Ne(`RotateCcw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),J=h*10,Nr=class{constructor(e={}){let t=!rt(e.bounce)||!rt(e.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/h,this.maxIterations=this.maxDuration/this.timeStep/h,this.bn=W(U(e.bounce,.5),-1,1),this.pd=W(U(e.duration,628),10*I.timeScale,J*I.timeScale),this.m=W(U(e.mass,1),1,J),this.s=W(U(e.stiffness,100),ln,J),this.d=W(U(e.damping,10),ln,J),this.v=W(U(e.velocity,0),-J,J),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=e.onComplete||ze,t&&this.calculateSDFromBD(),this.compute(),this.ease=e=>{let t=e*this.settlingDuration,n=this.completed,r=this.pd;return t>=r&&!n&&(this.completed=!0,this.onComplete(this.parent)),t<r&&n&&(this.completed=!1),e===0||e===1?e:this.solve(e*this.solverDuration)}}solve(e){let{zeta:t,w0:n,wd:r,b:i}=this,a=e;return a=t<1?bt(-a*t*n)*(1*Ft(r*a)+i*ct(r*a)):t===1?(1+i*a)*bt(-a*n):((1+i)*bt((-t*n+r)*a)+(1-i)*bt((-t*n-r)*a))/2,1-a}calculateSDFromBD(){let e=I.timeScale===1?this.pd/h:this.pd;this.m=1,this.v=0,this.s=an(2*tn/e,2),this.d=this.bn>=0?(1-this.bn)*4*tn/e:4*tn/(e*(1+this.bn)),this.s=gn(W(this.s,ln,J),3),this.d=gn(W(this.d,ln,300),3)}calculateBDFromSD(){let e=2*tn/mn(this.s);this.pd=e*(I.timeScale===1?h:1),this.bn=this.d/(2*mn(this.s))<=1?1-this.d*e/(4*tn):4*tn/(this.d*e)-1,this.bn=gn(W(this.bn,-1,1),3),this.pd=gn(W(this.pd,10*I.timeScale,J*I.timeScale),3)}compute(){let{maxRestSteps:e,maxIterations:t,restThreshold:n,timeStep:r,m:i,d:a,s:o,v:s}=this,c=this.w0=W(mn(o/i),ln,h),l=this.zeta=a/(2*mn(o*i));l<1?(this.wd=c*mn(1-l*l),this.b=(l*c+-s)/this.wd):l===1?(this.wd=0,this.b=-s+c):(this.wd=c*mn(l*l-1),this.b=(l*c+-s)/this.wd);let u=0,d=0,f=0;for(;d<=e&&f<=t;)dt(1-this.solve(u))<n?d++:d=0,this.solverDuration=u,u+=r,f++;this.settlingDuration=gn(this.solverDuration*h,0)*I.timeScale}get bounce(){return this.bn}set bounce(e){this.bn=W(U(e,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(e){this.pd=W(U(e,1),10*I.timeScale,J*I.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(e){this.s=W(U(e,100),ln,J),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(e){this.d=W(U(e,10),ln,J),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(e){this.m=W(U(e,1),1,J),this.compute()}get velocity(){return this.v}set velocity(e){this.v=W(U(e,0),-J,J),this.compute()}},Pr=e=>new Nr(e),Fr=(e=10,t)=>{let n=t?gt:vt;return t=>n(W(t,0,1)*e)*(1/e)},Ir=e(d(),1),Lr={current:null};function Rr(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=Lr,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,{dataRef:h,events:g}=e.context,_=D(l),v=wn(e),y=q.useRef(!1),b=$t(i),x=$t(r),S=$t(o),C=$t(n),T=$t(p),E=$t(f),O=w(()=>bn(h.current.openEvent?.type,v.interactedInside)),k=w(()=>T.current?.()!==!1),A=w((t,n,r)=>{let i=e.context.triggerElements;if(i.hasElement(n))return!t||!G(t,n);if(!F(r))return!1;let a=r;return i.hasMatchingElement(e=>G(e,a))&&(!t||!G(t,a))}),j=w(()=>{v.handler&&=(dn(e.select(`domReferenceElement`)).removeEventListener(`mousemove`,v.handler),void 0)}),M=w(()=>{Un(v)});return u&&(v.handleCloseOptions=i?.__options),q.useEffect(()=>j,[j]),q.useEffect(()=>{if(!n)return;function e(e){e.open?y.current=!1:(y.current=e.reason===B,j(),v.openChangeTimeout.clear(),v.restTimeout.clear(),v.blockMouseMove=!0,v.restTimeoutPending=!1)}return g.on(`openchange`,e),()=>{g.off(`openchange`,e)}},[n,g,v,j]),q.useEffect(()=>{if(!n)return;function t(t,n=!0){let r=Hn(x.current,`close`,v.pointerType);r?v.openChangeTimeout.start(r,()=>{e.setOpen(!1,L(B,t)),_?.events.emit(`floating.closed`,t)}):n&&(v.openChangeTimeout.clear(),e.setOpen(!1,L(B,t)),_?.events.emit(`floating.closed`,t))}let r=c.current??(u?e.select(`domReferenceElement`):null);if(!F(r))return;function i(t){if(v.openChangeTimeout.clear(),v.blockMouseMove=!1,a&&!Nt(v.pointerType))return;let n=xn(S.current),r=Hn(x.current,`open`,v.pointerType),i=lt(t),o=t.currentTarget??null,s=e.select(`domReferenceElement`),c=o;if(F(i)&&!e.context.triggerElements.hasElement(i)){for(let t of e.context.triggerElements.elements())if(G(t,i)){c=t;break}}F(o)&&F(s)&&!e.context.triggerElements.hasElement(o)&&G(o,s)&&(c=s);let l=c!=null&&A(s,c,i),u=e.select(`open`),d=E.current?.()??e.select(`transitionStatus`)===`ending`,f=!u&&d&&y.current,p=!l&&F(c)&&F(s)&&G(s,c)&&f,m=n>0&&!r,h=l&&(u||f)||p,g=!u||l;if(h){k()&&e.setOpen(!0,L(B,t,c));return}m||(r?v.openChangeTimeout.start(r,()=>{g&&k()&&e.setOpen(!0,L(B,t,c))}):g&&k()&&e.setOpen(!0,L(B,t,c)))}function o(n){if(O()){M();return}j();let r=e.select(`domReferenceElement`),i=dn(r);v.restTimeout.clear(),v.restTimeoutPending=!1;let a=h.current.floatingContext??d?.();if(!ot(n.relatedTarget,e.context.triggerElements)){if(b.current&&a){e.select(`open`)||v.openChangeTimeout.clear();let r=c.current;v.handler=b.current({...a,tree:_,x:n.clientX,y:n.clientY,onClose(){M(),j(),C.current&&!O()&&r===e.select(`domReferenceElement`)&&t(n,!0)}}),i.addEventListener(`mousemove`,v.handler),v.handler(n);return}(v.pointerType!==`touch`||!G(e.select(`floatingElement`),n.relatedTarget))&&t(n)}}function l(e){G(r,e.relatedTarget)||(v.openChangeTimeout.clear(),v.restTimeout.clear(),v.restTimeoutPending=!1)}let f=m?Jt(r,`mouseout`,l):void 0;return s?zt(Jt(r,`mousemove`,i,{once:!0}),Jt(r,`mouseenter`,i),Jt(r,`mouseleave`,o),f):zt(Jt(r,`mouseenter`,i),Jt(r,`mouseleave`,o),f)},[j,M,h,x,e,n,b,v,u,A,O,a,s,S,c,_,C,d,E,k,m]),q.useMemo(()=>{if(!n)return;function t(e){v.pointerType=e.pointerType}return{onPointerDown:t,onPointerEnter:t,onMouseMove(t){let{nativeEvent:n}=t,r=t.currentTarget,i=e.select(`domReferenceElement`),o=e.select(`open`),s=A(i,r,t.target);if(a&&!Nt(v.pointerType))return;if(o&&s&&v.handleCloseOptions?.blockPointerEvents){let t=e.select(`floatingElement`);if(t){let e=v.handleCloseOptions?.getScope?.()??r.ownerDocument.body;Bn(v,{scopeElement:e,referenceElement:r,floatingElement:t})}}let c=xn(S.current);if(o&&!s||c===0||!s&&v.restTimeoutPending&&t.movementX**2+t.movementY**2<2)return;v.restTimeout.clear();function l(){if(v.restTimeoutPending=!1,O())return;let t=e.select(`open`);!v.blockMouseMove&&(!t||s)&&k()&&e.setOpen(!0,L(B,n,r))}v.pointerType===`touch`?Ir.flushSync(()=>{l()}):s&&o?l():(v.restTimeoutPending=!0,v.restTimeout.start(c,l))}}},[n,v,O,A,a,e,S,k])}var zr=.1,Br=zr*zr,Y=.5;function Vr(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Hr(e,t,n,r,i,a,o,s,c,l){let u=!1;return Vr(e,t,n,r,i,a)&&(u=!u),Vr(e,t,i,a,o,s)&&(u=!u),Vr(e,t,o,s,c,l)&&(u=!u),Vr(e,t,c,l,n,r)&&(u=!u),u}function Ur(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Wr(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function Gr(e={}){let{blockPointerEvents:t=!1}=e,n=new nn,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*Br;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=lt(r),g=r.type===`mouseleave`,_=G(u,h),v=G(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&F(r.relatedTarget)&&G(u,r.relatedTarget))return;function y(){return!!(s&&Qe(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=Wr(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=Wr(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=Wr(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=Wr(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Ur(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Y/2:Y*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Y+1,o=C||T?S.bottom-Y:S.top,s=C?T?S.bottom-Y:S.top:S.bottom-Y;M=Hr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Y/2:Y*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Y,o=C||T?S.top+Y:S.bottom,s=C?T?S.top+Y:S.bottom:S.top+Y;M=Hr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Y/2:Y*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Y+1,o=w||E?S.right-Y:S.left,s=w?E?S.right-Y:S.left:S.right-Y;M=Hr(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Y/2:Y*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Y,o=w||E?S.left+Y:S.right,s=w?E?S.left+Y:S.right:S.left+Y;M=Hr(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function Kr(e,t,n){return`${e.endsWith(`/`)?e:`${e}/`}${t}${n===`directory`?`/`:``}`}function qr(e,t,n){let r=t.entries.filter(e=>e.type!==`symlink`).map(e=>Kr(t.path,e.name,e.type)),i=r.filter(e=>!n.has(e));if(i.length>0){let t=i.map(e=>({type:`add`,path:e}));e.batch(t)}n.add(t.path);for(let e of r)n.add(e);return i}function Jr(e,t){let n=t===`/`?`/`:t.replace(/\/+$/,``);if(n!==`/`&&e!==n&&!e.startsWith(`${n}/`))return[];let r=n===`/`?e.split(`/`).filter(Boolean):e.slice(n.length).split(`/`).filter(Boolean),i=[n],a=n;for(let e of r.slice(0,-1))a=`${a===`/`?``:a}/${e}`,i.push(a);return i}function Yr({app:e,rootPath:t,rootLabel:n=`Computer`,activePath:r,onOpenFile:i,onSelectPath:a}){let o=Jn(),s=gr(e),c=(0,q.useCallback)(t=>e.capabilities.subscribe(t),[e]),l=(0,q.useCallback)(()=>e.capabilities.version,[e]),u=(0,q.useSyncExternalStore)(c,l,l),d=(0,q.useMemo)(()=>({app:e,rootPath:t,computerId:s,version:u}),[e,t,s,u]),[f,p]=(0,q.useState)(null),m=f?.scope===d?f:null,h=r?Jr(r,t):[],g=m?.activePath===r?m.path:h.at(-1)??t,_=new Map;for(let e of[t,...h])_.set(`${e}:0`,{path:e,offset:0});for(let e of m?.pages??[])_.set(`${e.path}:${String(e.offset)}`,e);let v=[..._.values()],y=(t,n)=>nr.of(e,`tree`,u,t,n),b=xr({queries:v.map(({path:t,offset:n})=>sr(e,ar,y(t,n),async(e,r)=>{let i=await e.list({path:t,offset:n,limit:256});return r.throwIfAborted(),i})),combine:e=>({listings:e.flatMap((e,t)=>e.data?[{request:v[t],listing:e.data}]:[]),busy:e.some(e=>e.isFetching),failure:e.find(e=>e.error)?.error??null})}),x=(0,q.useRef)({activePath:r,onOpenFile:i,onSelectPath:a,rootLabel:n});x.current={activePath:r,onOpenFile:i,onSelectPath:a,rootLabel:n};let S=(e,t)=>{let n=e.replace(/\/+$/,``)||`/`,i=y(n,t);o.getQueryState(i)?.status===`error`&&o.invalidateQueries({queryKey:i,exact:!0}),p(e=>({scope:d,activePath:r,path:n,pages:[...e?.scope===d?e.pages.filter(e=>e.path!==n||e.offset!==t):[],{path:n,offset:t}]}))},C=(0,q.useRef)(S);C.current=S;let{model:w}=hr({paths:[],itemHeight:32,initialExpansion:1,composition:{contextMenu:{enabled:!0}},renderRowDecoration:({row:e})=>e.path===`/`?{text:x.current.rootLabel}:null,unsafeCSS:`[data-item-section="content"] { display: flex; align-items: center; }[data-item-path="/"] [data-item-section="decoration"] { justify-content: flex-start; color: inherit; }`,onSelectionChange(e){let t=e[0];t&&(x.current.onSelectPath?.(t),t.endsWith(`/`)?C.current(t,0):t!==x.current.activePath&&x.current.onOpenFile(t))}}),T=(0,q.useRef)(new Set),E=(0,q.useRef)(new Map),D=(0,q.useRef)(null);(0,q.useLayoutEffect)(()=>{T.current.clear(),E.current.clear(),w.resetPaths([]),D.current=null},[w,d]),(0,q.useLayoutEffect)(()=>{D.current=null;for(let e of w.getSelectedPaths())!e.endsWith(`/`)&&e!==r&&w.getItem(e)?.deselect()},[r,w]),(0,q.useLayoutEffect)(()=>{b.listings.length===0&&(T.current.clear(),E.current.clear(),w.resetPaths([]),D.current=null);for(let{request:e,listing:t}of b.listings){let n=`${e.path}:${String(e.offset)}`,r=t.entries.filter(e=>e.type!==`symlink`).map(e=>Kr(t.path,e.name,e.type)),i=E.current.get(n)??[];E.current.set(n,r);let a=new Set([...E.current.values()].flat());for(let e of i)if(!a.has(e)){w.getItem(e)&&w.remove(e,{recursive:!0});for(let t of T.current)(t===e||e.endsWith(`/`)&&t.startsWith(e))&&T.current.delete(t)}qr(w,t,T.current)}if(!r||D.current===r)return;let e=Jr(r,t);if(!e.every(e=>T.current.has(e)))return;for(let t of e){let e=w.getItem(t);e&&`expand`in e&&e.expand()}let n=w.getItem(r);n&&(D.current=r,n.select(),w.scrollToPath(r,{focus:!1}))},[r,w,t,d,b.listings]),(0,q.useEffect)(()=>{b.failure&&console.error(`Inkcap directory listing failed`,Yn(b.failure))},[b.failure]);let O=b.listings.filter(({request:e})=>e.path===g).sort((e,t)=>e.request.offset-t.request.offset).at(-1)?.listing,k={path:O?.path??g,next:O?.nextOffset??null};return{model:w,page:k,error:b.failure?`Could not list this directory. Existing files remain available.`:``,busy:b.busy,reloadRoot:()=>{o.invalidateQueries({queryKey:nr.of(e,`tree`,u)})},loadNext:()=>{k.next!==null&&S(k.path,k.next)}}}var Xr=z(R),Zr=z(Xe({message:R}));function Qr(e){for(let t of e.errors){let e=Me(M(u(Zr(t),e=>e.message),()=>Xr(t)));if(e!==void 0&&e.length>0)return e}}var X=Object.freeze({ease:`linear`,duration:0});function $r(e,t){let n=s(e,t.duration);return n<=0?X:e.steps>0?{ease:Fr(e.steps),duration:n}:{ease:Pr({bounce:Se(e,t.bounce),duration:n}),duration:n}}function Z(e,t){let n=Tt(e,t.duration);return{ease:e.steps>0?Fr(e.steps):t.ease,duration:n}}var Q=de(),ei={dot:{y:-4,height:8,cy:0},pill:{y:-16,height:32,cy:0},bang:{y:-16,height:20,cy:12}};function ti({className:e,glyph:t,motion:n}){let r=`caps-status-${(0,q.useId)().replaceAll(`:`,``)}`,i=(0,q.useRef)(null),a=(0,q.useRef)(null),o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(ei[t]).current,d=(0,q.useRef)(t===`dot`?1:4).current,f=(0,q.useRef)(+(t===`bang`)).current,p=(0,q.useRef)(t),m=ve(s),{reduced:h}=m;return(0,q.useLayoutEffect)(()=>{if(!i.current||!a.current||!c.current||!l.current)return;let e=ei[t],n=h||p.current===t;p.current=t;let r=me(i.current),o=n?{duration:0}:$r(r,{bounce:.3,duration:360}),s=V(i.current,{y:e.y,height:e.height,...o}),u=V(a.current,{cy:e.cy,...n?{duration:0}:{delay:Tt(r,35),...$r(r,{bounce:.3,duration:420})}}),d=V(c.current,{gradientTransform:`matrix(1 0 0 ${t===`dot`?`1`:`4`} 0 0)`,...o}),f=V(l.current,{opacity:+(t===`bang`),...n?X:Z(r,{ease:`inOutSine`,duration:220})});return()=>{s.cancel(),u.cancel(),d.cancel(),f.cancel()}},[t,h]),(0,q.useLayoutEffect)(()=>{if(!o.current||!s.current||h||n===`none`)return;let e=n===`pulse`?V(o.current,{opacity:[1,.45],...Z(m,{ease:`inOutSine`,duration:750}),alternate:!0,loop:!0}):V(o.current,{keyframes:{"0%":{translateY:0,scaleX:1,scaleY:1},"18%":{translateY:.25,scaleX:1.1,scaleY:.91},"42%":{translateY:-1.3,scaleX:.94,scaleY:1.06},"62%":{translateY:-1.65,scaleX:1,scaleY:1},"82%":{translateY:.15,scaleX:1.06,scaleY:.95},"100%":{translateY:0,scaleX:1,scaleY:1}},...Z(m,{ease:`inOutSine`,duration:1e3}),loop:!0}),t=Lt(s.current,t=>{t?e.resume():e.pause()});return()=>{t(),e.revert()}},[n,h,m]),(0,Q.jsxs)(`svg`,{ref:s,"aria-hidden":`true`,className:`caps-status-bead ${e??``}`,width:`8`,height:`8`,viewBox:`-4 -4 8 8`,focusable:`false`,children:[(0,Q.jsxs)(`defs`,{children:[(0,Q.jsx)(qt,{id:r,values:Xt}),(0,Q.jsx)(Vt,{ref:c,id:`${r}-surface`,transform:`matrix(1 0 0 ${String(d)} 0 0)`}),(0,Q.jsxs)(`radialGradient`,{id:`${r}-drop-light`,gradientUnits:`userSpaceOnUse`,cx:`-1.2`,cy:`10.4`,r:`5.6`,children:[(0,Q.jsx)(`stop`,{offset:`0`,stopColor:`var(--color-white)`,style:{stopOpacity:`calc(var(--depth) * 0.5)`}}),(0,Q.jsx)(`stop`,{offset:`1`,stopColor:`var(--color-white)`,stopOpacity:`0`})]}),(0,Q.jsx)(at,{id:`${r}-shadow`}),(0,Q.jsx)(`mask`,{id:`${r}-silhouette`,maskUnits:`userSpaceOnUse`,x:`-12`,y:`-24`,width:`24`,height:`48`,style:{maskType:`alpha`},children:(0,Q.jsxs)(`g`,{fill:`var(--color-white)`,filter:`url(#${r})`,children:[(0,Q.jsx)(`rect`,{ref:i,x:`-4`,y:u.y,width:`8`,height:u.height,rx:`4`}),(0,Q.jsx)(`circle`,{ref:a,cx:`0`,cy:u.cy,r:`4`})]})})]}),(0,Q.jsx)(`g`,{ref:o,filter:`url(#${r}-shadow)`,children:(0,Q.jsxs)(`g`,{mask:`url(#${r}-silhouette)`,children:[(0,Q.jsx)(`rect`,{x:`-12`,y:`-24`,width:`24`,height:`48`,fill:`url(#${r}-surface)`}),(0,Q.jsx)(`rect`,{ref:l,x:`-12`,y:`-24`,width:`24`,height:`48`,fill:`url(#${r}-drop-light)`,opacity:f})]})})]})}var ni=.28;function ri(e,t){switch(e){case`ring`:return{dashes:1,track:0,arc:0,sweep:0,disc:0,tick:0,cross:0};case`arc`:return{dashes:0,track:1,arc:1,sweep:t===void 0?ni:Math.min(1,Math.max(0,t)),disc:0,tick:0,cross:0};case`check`:return{dashes:0,track:0,arc:1,sweep:1,disc:1,tick:1,cross:0};case`cross`:return{dashes:0,track:0,arc:1,sweep:1,disc:1,tick:0,cross:1}}}var ii=7.25;function ai({className:e,glyph:t,progress:n}){let r=`caps-status-mark-${(0,q.useId)().replaceAll(`:`,``)}`,i=(0,q.useRef)(null),a=(0,q.useRef)(null),o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=(0,q.useRef)(null),f=(0,q.useRef)(ri(t,n)).current,p=(0,q.useRef)(t),m=Ee();(0,q.useLayoutEffect)(()=>{let e=i.current,r=a.current,c=o.current,f=s.current,h=l.current,g=u.current,_=d.current;if(!e||!r||!c||!f||!h||!g||!_)return;let v=ri(t,n),y=p.current;p.current=t;let b=me(e),x=m||y===t&&t!==`arc`,S=x?m?{ease:b.ease,duration:b.fast}:X:Z(b,{ease:`outQuad`,duration:160}),C=(t===`check`||t===`cross`)&&!x,w=Z(b,{ease:`inOutSine`,duration:220}),T=[V(r,{opacity:v.dashes,...S}),V(c,{opacity:v.track*.28,...S}),V(f,{opacity:v.arc,"stroke-dasharray":`${String(v.sweep)} 1`,...x?m?X:S:w}),V(h,{r:v.disc*ii,...C?{delay:w.duration*.7,...$r(b,{bounce:.35,duration:360})}:m?X:Z(b,{ease:`inCubic`,duration:140})}),V(g,{"stroke-dashoffset":1-v.tick,...C&&v.tick>0?{delay:w.duration*.7+b.fast,...Z(b,{ease:`outCubic`,duration:240})}:X}),V(_,{"stroke-dashoffset":1-v.cross,...C&&v.cross>0?{delay:w.duration*.7+b.fast,...Z(b,{ease:`outCubic`,duration:240})}:X})];return t===`cross`&&C&&b.shake>0&&T.push(V(e,{translateX:[0,-b.shake,b.shake,-b.shake/2,0],delay:w.duration+b.fast,...Z(b,{ease:`linear`,duration:300})})),()=>{for(let e of T)e.cancel()}},[t,n,m]);let h=t===`arc`&&n===void 0&&!m;return(0,q.useLayoutEffect)(()=>{if(!h||!c.current||!i.current)return;let e=me(i.current),t=V(c.current,{rotate:[0,360],...Z(e,{ease:`linear`,duration:900}),loop:!0}),n=Lt(i.current,e=>{e?t.resume():t.pause()});return()=>{n(),t.revert()}},[h]),(0,Q.jsxs)(`svg`,{ref:i,"aria-hidden":`true`,className:`caps-status-mark ${e??``}`,viewBox:`0 0 16 16`,focusable:`false`,children:[(0,Q.jsxs)(`defs`,{children:[(0,Q.jsx)(Vt,{id:`${r}-surface`,transform:`matrix(1.6 0 0 1.6 8 8)`}),(0,Q.jsxs)(`mask`,{id:`${r}-knock`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`16`,height:`16`,children:[(0,Q.jsx)(`rect`,{width:`16`,height:`16`,fill:`var(--color-white)`}),(0,Q.jsx)(`path`,{ref:u,d:`M4.9 8.3 7.1 10.5 11.2 5.9`,fill:`none`,stroke:`var(--color-black)`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,pathLength:1,strokeDasharray:`1 1`,strokeDashoffset:1-f.tick}),(0,Q.jsx)(`path`,{ref:d,d:`M5.4 5.4 10.6 10.6 M10.6 5.4 5.4 10.6`,fill:`none`,stroke:`var(--color-black)`,strokeWidth:`1.9`,strokeLinecap:`round`,pathLength:1,strokeDasharray:`1 1`,strokeDashoffset:1-f.cross})]})]}),(0,Q.jsx)(`circle`,{ref:a,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeDasharray:`1.7 2.2`,opacity:f.dashes}),(0,Q.jsx)(`circle`,{ref:o,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:f.track*.28}),(0,Q.jsx)(`g`,{ref:c,className:`caps-status-mark-spin`,children:(0,Q.jsx)(`circle`,{ref:s,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,pathLength:1,strokeDasharray:`${String(f.sweep)} 1`,transform:`rotate(-90 8 8)`,opacity:f.arc})}),(0,Q.jsx)(`circle`,{ref:l,cx:`8`,cy:`8`,r:f.disc*ii,fill:`url(#${r}-surface)`,mask:`url(#${r}-knock)`})]})}var oi=new Set([`ring`,`arc`,`check`,`cross`]);function si(e){return oi.has(e)}var ci={neutral:`text-base-content`,primary:`text-primary`,secondary:`text-secondary`,accent:`text-accent`,success:`text-success`,info:`text-info`,warning:`text-warning`,error:`text-error`},li=(0,q.forwardRef)(function({className:e,label:t,glyph:n=`dot`,motion:r=`none`,tone:i=`neutral`,size:a=`default`,appearance:o=`plain`,progress:s,...c},l){return(0,Q.jsxs)(`span`,{...c,className:K(`caps-status`,a===`compact`&&`caps-status-compact`,o===`chip`&&`caps-status-chip`,e),"data-tone":o===`chip`?i:void 0,"data-glyph":n,"data-motion":r,ref:l,children:[si(n)?(0,Q.jsx)(ai,{className:ci[i],glyph:n,progress:s}):(0,Q.jsx)(ti,{className:ci[i],glyph:n,motion:r}),t===void 0?null:(0,Q.jsx)(`span`,{children:t})]})}),ui={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},di=(0,q.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,Q.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:K(`progress caps-gooey-motion caps-gooey-progress w-full`,ui[t],e),ref:r})});(0,q.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,Q.jsxs)(`div`,{...a,ref:o,className:K(`caps-game-meter`,i),children:[(0,Q.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,Q.jsx)(`span`,{children:e}),(0,Q.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,Q.jsx)(di,{"aria-label":e,value:t,max:n,tone:r})]})});function fi({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,Q.jsx)(`div`,{"aria-live":`polite`,className:`caps-upload-queue flex w-full min-w-0 flex-col gap-sm ${e??``}`,"data-upload-rows":!0,children:t.map(e=>(0,Q.jsx)(hi,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function pi({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,Q.jsx)(i,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,Q.jsx)(Mr,{}):(0,Q.jsx)(te,{}),onClick:()=>void n(t),type:`button`}):null}function mi({item:e}){return(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,Q.jsx)(`div`,{className:`caps-upload-details`,children:(0,Q.jsxs)(`span`,{"aria-live":e.alert?`assertive`:void 0,className:`caps-upload-status min-w-0 break-words`,"data-upload-status":!0,role:e.alert?`alert`:void 0,children:[e.alert??e.statusLabel,` `,e.progressLabel]})})]})}function hi({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,Q.jsxs)(`div`,{className:`caps-upload-row grid w-full min-w-0 max-w-full grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-sm p-sm text-xs ${i??``}`,children:[e.preview.kind===`image`?(0,Q.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`caps-upload-preview mask mask-squircle flex size-8 shrink-0 items-center justify-center bg-base-300`,children:(0,Q.jsx)(Ar,{className:`size-4`})}),(0,Q.jsx)(mi,{item:e}),(0,Q.jsx)(gi,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,Q.jsx)(di,{"aria-label":`${e.name} progress`,className:`caps-upload-progress`,tone:e.alert?`error`:e.progress===100?`success`:`accent`,max:100,value:e.progress??(e.alert?0:void 0)})]})}function gi({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,Q.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,Q.jsx)(pi,{action:e.retry,id:t,onAction:i,retry:!0}),(0,Q.jsx)(pi,{action:e.cancel,id:t,onAction:n}),(0,Q.jsx)(pi,{action:e.remove,id:t,onAction:r})]})}var _i={unchecked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,checked:`M3.25 5.9 L5.1 7.9 L8.8 3.8`,mixed:`M3.4 6 L6 6 L8.6 6`},vi={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function yi({state:e}){let t=`caps-checkbox-${(0,q.useId)().replaceAll(`:`,``)}`,n=(0,q.useRef)(null),r=(0,q.useRef)(e).current,i=(0,q.useRef)(e),a=Ee();return(0,q.useLayoutEffect)(()=>{if(!n.current)return;let t=e!==`unchecked`,r=i.current!==`unchecked`,o=a||i.current===e;i.current=e;let s=me(n.current),c=Z(s,{ease:`inCubic`,duration:160}),l=V(n.current,{d:{to:_i[e],...o?X:Z(s,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...o?X:t?Z(s,{ease:`inOutSine`,duration:260}):c},"stroke-width":o?{to:t?2.4:0,duration:0}:t&&!r?[{to:2.2,...Z(s,{ease:`outCubic`,duration:65})},{to:2.4,delay:Tt(s,120),...$r(s,{bounce:.35,duration:220})}]:{to:t?2.4:0,...c}});return()=>{l.cancel()}},[e,a]),(0,Q.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,Q.jsxs)(`defs`,{children:[(0,Q.jsx)(Vt,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,Q.jsx)(at,{id:`${t}-shadow`}),(0,Q.jsx)(St,{id:`${t}-inset`}),(0,Q.jsx)(qt,{id:`${t}-goo`,values:vi}),(0,Q.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,Q.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,Q.jsx)(`feSpecularLighting`,{in:`relief`,surfaceScale:`1.2`,specularConstant:`0.55`,specularExponent:`18`,lightingColor:`color-mix(in srgb, var(--color-white) calc(var(--depth) * 100%), var(--color-black))`,result:`light`,children:(0,Q.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,Q.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,Q.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,Q.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,Q.jsx)(`path`,{ref:n,d:_i[r],fill:`none`,stroke:`var(--color-white)`,strokeWidth:r===`unchecked`?0:2.4,pathLength:`1`,strokeDasharray:`1`,strokeDashoffset:+(r===`unchecked`),strokeLinecap:`round`,strokeLinejoin:`round`,filter:e===`mixed`?void 0:`url(#${t}-goo)`})}),(0,Q.jsx)(`clipPath`,{id:`${t}-well`,children:(0,Q.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,Q.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,Q.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,Q.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,Q.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,Q.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,Q.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var bi=(0,q.forwardRef)(function({className:e,appearance:t,indicator:n,invalid:r,indeterminate:i=!1,checked:a,defaultChecked:o=!1,onChange:s,...c},l){let u=(0,q.useRef)(null),[d,f]=(0,q.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,q.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,q.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,q.useEffect)(()=>{let e=u.current?.form;if(!e||a!==void 0)return;let t=e=>{queueMicrotask(()=>{!e.defaultPrevented&&u.current&&f(o)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[a,o,c.form]),(0,Q.jsxs)(`span`,{className:`caps-checkbox`,"data-appearance":t===`compact`?t:void 0,"data-state":m,"data-custom-indicator":n!==void 0||void 0,children:[(0,Q.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:K(`caps-checkbox-input`,e),onChange:e=>{a===void 0&&f(e.target.checked),s?.(e),e.currentTarget.indeterminate=i},ref:u,type:`checkbox`}),n===void 0?(0,Q.jsx)(yi,{state:m}):n]})}),xi=wr({keyCode:Er(229)});function Si(e){return e.nativeEvent.isComposing||c(xi,e.nativeEvent).success}var Ci=q.createContext(void 0);function wi(e){let t=q.useContext(Ci);if(t===void 0&&!e)throw Error(Ae(47));return t}var Ti={...rn,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!rn.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&rn.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>rn.isOpenedByTrigger(e,t)&&!e.focusManagerModal,modal:e=>e.modal,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Ei=class extends hn{constructor(e,t,n){let r=new p;super(Di(e,r,t,n),Oi(r),Ti)}setOpen=(e,t)=>{let n=t.reason===B,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=_(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n=Dt(this.state,e,t.trigger,a());n.openChangeReason=t.reason,this.update(n)};n?(this.context.stickIfOpen=!0,this.context.stickIfOpenTimeout.start(500,()=>{this.context.stickIfOpen=!1}),Ir.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function Di(e,t,n,r=!1){let i={...tt(t,n,r),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i}function Oi(e){return{popupRef:q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:q.createRef(),beforeTriggerFocusGuardRef:q.createRef(),beforeContentFocusGuardRef:q.createRef(),stickIfOpenTimeout:new nn,stickIfOpen:!0,triggerElements:e}}var ki=st(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:o,modal:s=!1,handle:c,triggerId:l,defaultTriggerId:u=null}=e,d=ji(c,{modal:s,open:r,openProp:n,activeTriggerId:u,triggerIdProp:l});d.useControlledProp(`openProp`,n),d.useControlledProp(`triggerIdProp`,l);let f=d.useState(`open`),p=d.useState(`mounted`),m=d.useState(`payload`);d.useContextCallback(`onOpenChange`,i),d.useContextCallback(`onOpenChangeComplete`,o),we(d,f),a(d);let{forceUnmount:h}=Ct(f,d,()=>{d.context.stickIfOpen=!0,d.set(`openChangeReason`,null)});d.useSyncedValues({modal:s}),q.useEffect(()=>{f||d.context.stickIfOpenTimeout.clear()},[d,f]),q.useImperativeHandle(e.actionsRef,()=>({unmount:h,close:()=>d.setOpen(!1,L(on))}),[h,d]);let g=f||p||c!=null;return(0,Q.jsxs)(Ci.Provider,{value:d,children:[c&&(0,Q.jsx)(Le,{handle:c,store:d}),g&&(0,Q.jsx)(Mi,{store:d,modal:s}),typeof t==`function`?t({payload:m}):t]})});function Ai(e){return wi(!0)?(0,Q.jsx)(ki,{props:e}):(0,Q.jsx)(j,{children:(0,Q.jsx)(ki,{props:e})})}function ji(e,t){let n=ge((e,n)=>new Ei(t,e,n));return q.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function Mi({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=je(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return fe(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}function Ni(e,n){function r(t,r,i){let a=t.currentTarget;Ir.flushSync(()=>{e.setOpen(!1,L(it,t.nativeEvent,a))}),Oe(a.isConnected?a:n.current,r,i)?.focus()}function i(t){r(t,-1,e.select(`positionerElement`))}function a(n){let i=e.select(`positionerElement`);i&&t(n,i)?e.context.beforeContentFocusGuardRef.current?.focus():r(n,1,i)}return{handlePreFocusGuardFocus:i,handleFocusTargetFocus:a}}var Pi=fn(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=wi(!0),h=_t(s)??m;if(!h)throw Error(Ae(74));let _=Ut(f),v=h.useState(`isTriggerActive`,_),y=h.useState(`floatingRootContext`),b=h.useState(`isOpenedByTrigger`,_),x=h.useState(`triggerPopupId`,_),S=q.useRef(null),{registerTrigger:C,isMountedByThisTrigger:E}=T(_,S,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),D=h.useState(`isPressOpenedByTrigger`,_),O=h.useState(`isTouchPressOpen`,l),k=h.useState(`hasTriggerFocusGuards`,_),A=Rr(y,{enabled:!a&&l&&!O,mouseOnly:!0,move:!1,handleClose:Gr(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>h.select(`transitionStatus`)===`ending`}),j=w(()=>h.context.stickIfOpen),M=_n(y,{stickIfOpen:j}),ee=ut(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),te=h.useState(`triggerProps`,E),{getButtonProps:ne,buttonRef:re}=g({disabled:a,native:o}),ae={open(e){return D?ce.open(e):Gt.open(e)}},{handlePreFocusGuardFocus:oe,handleFocusTargetFocus:se}=Ni(h,S),le=ie(`button`,e,{state:{disabled:a,open:b},ref:[re,t,C,S],props:[M.reference,A,te,ee,{[N]:``,id:_,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},p,ne],stateAttributesMapping:ae}),P=(0,Q.jsx)(q.Fragment,{children:le},_);return k?(0,Q.jsxs)(q.Fragment,{children:[(0,Q.jsx)(mt,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:oe}),P,(0,Q.jsx)(mt,{ref:h.context.triggerFocusTargetRef,onFocus:se})]}):P}),Fi=q.createContext(void 0);function Ii(){let e=q.useContext(Fi);if(e===void 0)throw Error(Ae(45));return e}var Li=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return wi().useState(`mounted`)||n?(0,Q.jsx)(Fi.Provider,{value:n,children:(0,Q.jsx)(ae,{ref:t,...r})}):null}),Ri=q.createContext(void 0);function zi(){let e=q.useContext(Ri);if(!e)throw Error(Ae(46));return e}function Bi(e){let{store:t,domReference:n,positionerElement:r,open:i}=e,a=q.useRef(null),o=q.useRef(null),s=le(r);Ve(()=>{i||(o.current?.abort(),o.current=null,t.state.instantType===`trigger-change`&&t.set(`instantType`,void 0))},[i,t]),Ve(()=>{let e=n,r=a.current;if(e&&(a.current=e),!r||!e||e===r||!t.select(`open`))return;t.set(`instantType`,void 0);let i=new AbortController;return o.current=i,s(()=>{t.select(`open`)&&t.set(`instantType`,`trigger-change`)},i.signal),()=>{i.abort()}},[n,s,t])}var Vi=20;function Hi(e,t,n,r){let[i,a]=q.useState(!1);Ve(()=>{if(!e||!t||n==null){a(!1);return}let r=dn(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-Vi)},[e,t,n]),ht(e&&(!t||i),r)}var Ui=q.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=Je,..._}=e,v=wi(),y=Ii(),b=He(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=v.useState(`adaptiveOrigin`),M=kn({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:j});Bi({store:v,domReference:x.useState(`domReferenceElement`),positionerElement:O,open:C});let ee=E===!0&&w!==`trigger-hover`;Hi(C&&ee,D===`touch`,O,T);let te=v.useStateSetter(`positionerElement`),N={open:C,side:M.side,align:M.align,anchorHidden:M.anchorHidden,instant:k},ne=Fn(e,N,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,te],hidden:!S,inert:!C});return(0,Q.jsxs)(Ri.Provider,{value:M,children:[S&&ee&&(0,Q.jsx)(Ht,{inert:Pt(!C),cutout:T}),(0,Q.jsx)(We,{id:b,children:ne})]})}),Wi=q.createContext(void 0);function Gi(e){let t=q.useContext(Wi);if(t===void 0&&!e)throw Error(Ae(69));return t}var Ki=q.createContext(void 0);function qi(){let[e,t]=q.useState(0),n=w(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:q.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var Ji=q.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=wi(),u=zi(),d=Gi(!0)!=null,{context:f,hasClosePart:p}=qi(),m=c.useState(`open`),h=c.useState(`openMethod`),g=c.useState(`instantType`),_=c.useState(`transitionStatus`),v=c.useState(`popupProps`),y=c.useState(`titleElementId`),b=c.useState(`descriptionElementId`),x=c.useState(`modal`),S=c.useState(`mounted`),C=c.useState(`openChangeReason`),w=c.useState(`activeTriggerElement`),T=c.useState(`floatingRootContext`),E=T.useState(`floatingId`),D=c.useState(`disabled`),O=c.useState(`openOnHover`),k=c.useState(`closeDelay`);ee({open:m,ref:c.context.popupRef,onComplete(){m&&c.context.onOpenChangeComplete?.(!0)}}),Sn(T,{enabled:O&&!D,closeDelay:k});let j=a===void 0?be(c.context.popupRef):a,M=x!==!1&&p;c.useSyncedValue(`focusManagerModal`,M);let te=c.useStateSetter(`popupElement`),N={open:m,side:u.side,align:u.align,instant:g,transitionStatus:_},ne=ie(`div`,e,{state:N,ref:[t,c.context.popupRef,te],props:[v,{id:E,role:`dialog`,...sn,"aria-labelledby":y,"aria-describedby":b,onKeyDown(e){d&&yt.has(e.key)&&e.stopPropagation()}},Mn(_),s],stateAttributesMapping:A});return(0,Q.jsx)(l,{context:T,openInteractionType:h,modal:M,disabled:!S||C===`trigger-hover`,initialFocus:j,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:Fe(w)?w:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,Q.jsx)(Ki.Provider,{value:f,children:ne})})}),Yi=`data-glide-stand-in`;function Xi(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{x:r.left-n.left+e.scrollLeft-e.clientLeft,y:r.top-n.top+e.scrollTop-e.clientTop,width:r.width,height:r.height}}function Zi(e){return{transform:`translate(${String(e.x)}px, ${String(e.y)}px)`,width:`${String(e.width)}px`,height:`${String(e.height)}px`}}function Qi(e){let t=(0,q.useRef)(null);return(0,q.useCallback)(n=>{t.current?.(),t.current=n?$i(n,e):null},[e])}function $i(e,t){if(!y(e))return()=>void 0;let n=e.ownerDocument,r=e.querySelector(t),i=r?Xi(e,r):null,a=null,o=null,s=new Set,c=()=>{for(let e of s)e.removeAttribute(Yi);s.clear(),a&&(a.hidden=!0),o=null},l=()=>{if(a)return a;let t=n.createElement(`span`);return t.className=`caps-glide`,t.setAttribute(`aria-hidden`,`true`),e.prepend(t),e.classList.add(`caps-glide-host`),getComputedStyle(e).position===`static`&&e.classList.add(`caps-glide-anchor`),a=t,t},u=(t,n)=>{let r=me(e),u=Xi(e,t),d=o&&a?Xi(e,a):i;if(i=u,o?.cancel(),c(),r.reduced||d===null||Math.abs(d.y-u.y)<1&&Math.abs(d.x-u.x)<1)return;t.setAttribute(Yi,`measure`);let f=getComputedStyle(t),p=f.backgroundColor,m=f.borderRadius;for(let e of[t,n])e&&(e.setAttribute(Yi,``),s.add(e));let h=l();h.hidden=!1,h.style.backgroundColor=p,h.style.borderRadius=m;let g=h.animate([Zi(d),Zi(u)],{duration:r.normal,easing:kt(r,r.ease),fill:`forwards`});o=g,g.addEventListener(`finish`,()=>{o===g&&c()})},d=()=>{let n=e.querySelector(t);if(n===r)return;let i=r;r=n,n&&u(n,i)},f=new MutationObserver(d);return f.observe(e,{subtree:!0,attributes:!0,attributeFilter:[`data-highlighted`,`data-active`,`data-navigation`,`aria-selected`]}),e.addEventListener(`pointerover`,d),e.addEventListener(`pointerout`,d),()=>{f.disconnect(),e.removeEventListener(`pointerover`,d),e.removeEventListener(`pointerout`,d),o?.cancel(),c(),a?.remove()}}function ea({getKey:e,isDisabled:t=()=>!1,items:n}){let r=(0,q.useMemo)(()=>{let r=n.map(e);if(r.some(e=>!e))throw Error(`Selectable items require non-empty keys`);if(new Set(r).size!==r.length)throw Error(`Selectable items require unique keys`);return n.filter(e=>!t(e))},[e,t,n]),[i,a]=(0,q.useState)(null);(0,q.useEffect)(()=>{i!==null&&!r.some(t=>e(t)===i)&&a(null)},[i,r,e]);let o=r.find(t=>e(t)===i),s=o?r.findIndex(t=>e(t)===i):-1;return{activeIndex:s,activeItem:o,activeKey:i,enabledItems:r,move:(t,n)=>{if(r.length===0)return;let i=n?n===`start`?0:r.length-1:s<0?t>0?0:r.length-1:(s+t+r.length)%r.length,o=r[i];o&&a(e(o))},setActiveKey:a}}var ta=(0,q.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,Q.jsxs)(`button`,{...r,ref:i,type:n,className:K(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,Q.jsx)(`span`,{children:e}),(0,Q.jsx)(Or,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function na({defaultOpen:e,defaultValue:t,getKey:n,getSearchText:r,groupBy:i,id:a,isDisabled:o,items:s,onOpenChange:c,onCommit:l,multiple:u,controlledOpen:d,controlledKeys:f,trigger:p}){let m=`${a}-listbox`,[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(t),[x,S]=(0,q.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,q.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=ea({getKey:n,isDisabled:o,items:T});(0,q.useEffect)(()=>{if(E.activeKey!==null)return;let e=E.enabledItems.find(e=>C.includes(n(e)))??E.enabledItems[0];e&&E.setActiveKey(n(e))},[E.activeKey,E.enabledItems,E.setActiveKey,n,C]);let D=e=>{v(!1),e||g(``),d===void 0&&S(e),c?.(e)},O=e=>`${m}-option-${encodeURIComponent(e)}`,k=e=>{let t=n(e);f===void 0&&b(t),l(e),p&&!u&&D(!1)},A=e=>{v(!0),g(e.target.value),E.setActiveKey(null)},j=e=>{if(Si(e))return;let t;switch(e.key){case`ArrowDown`:t=[1,void 0];break;case`ArrowUp`:t=[-1,void 0];break;case`End`:t=[1,`end`];break;case`Home`:t=[-1,`start`]}t?(v(!0),e.preventDefault(),E.move(t[0],t[1])):e.key===`Enter`&&E.activeItem&&(e.preventDefault(),k(E.activeItem))},M=(0,q.useMemo)(()=>{if(!i)return[{label:``,items:T}];let e=new Map;for(let t of T){let n=i(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[T,i]);return{keyboardNavigation:_,onPointerMove:()=>{v(!1)},activeKey:E.activeKey,activeItem:E.activeItem,groups:M,inputValue:h,listboxId:m,onInputChange:A,onInputKeyDown:j,optionId:O,open:w,commit:k,selectedKeys:C,setOpen:D}}function ra(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultOpen:l=!1,defaultValue:u=null,emptyMessage:d=`No matches`,getKey:f,getLabel:p,getSearchText:m=p,groupBy:h,id:g,inputProps:_,inputRef:v,isDisabled:y=()=>!1,items:b,onOpenChange:x,onValueChange:S,multiple:C,open:w,placeholder:T=`Search…`,renderItem:E,rootRef:D,trigger:O,triggerRef:k,value:A,...j}=e,M=e=>{let t=f(e);if(C){let e=A.includes(t)?A.filter(e=>e!==t):[...A,t];S?.(e,b.filter(t=>e.includes(f(t))))}else S?.(t,e)},ee;C?ee=A:A!==void 0&&(ee=A===null?[]:[A]);let te=(0,q.useId)(),N=O?.props??_,ne=g??N?.id??te,re={id:ne,"aria-describedby":[t,N?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??N?.[`aria-invalid`],"aria-label":N?.[`aria-label`]??r,"aria-labelledby":N?.[`aria-labelledby`]??i,"aria-required":a??N?.[`aria-required`]},{keyboardNavigation:ie,onPointerMove:ae,activeItem:oe,activeKey:se,commit:ce,groups:le,inputValue:P,listboxId:ue,onInputChange:de,onInputKeyDown:F,open:fe,optionId:pe,selectedKeys:me,setOpen:he}=na({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:ne,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:ee,trigger:O});jt(()=>{O&&he(!1)});let ge=en(`popover`),_e=s===void 0?ge:s,ve=Qi(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),ye=(0,Q.jsx)(On,{..._,...O?{}:re,"aria-activedescendant":oe?pe(f(oe)):void 0,"aria-autocomplete":`list`,"aria-controls":ue,"aria-expanded":!0,className:K(`input-sm`,_?.className),id:O?_?.id??`${ne}-input`:ne,onChange:e=>{_?.onChange?.(e),de(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||F(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:P}),be=(0,Q.jsx)(`div`,{id:ue,ref:ve,className:`caps-combobox-list`,"data-navigation":ie?`keyboard`:`pointer`,onPointerMove:ae,role:`listbox`,"aria-multiselectable":C??void 0,children:le.every(e=>e.items.length===0)?(0,Q.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):le.map(e=>(0,Q.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,Q.jsx)(`div`,{className:`px-md pb-xs pt-sm text-xs text-base-content uppercase tracking-wider`,children:e.label}):null,e.items.map(e=>{let t=f(e),n=y(e),r=se===t,i={active:r,disabled:n,selected:me.includes(t)};return(0,Q.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&ie,disabled:n,id:pe(t),onClick:()=>{ce(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,Q.jsx)(Dr,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,Q.jsx)(`div`,{...j,className:K(j.className),ref:D,children:(0,Q.jsxs)(Ai,{modal:!0,onOpenChange:he,open:fe,children:[(0,Q.jsx)(Pi,{...re,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),_e===null?null:(0,Q.jsx)(Li,{container:_e,children:(0,Q.jsx)(Ui,{align:`start`,side:`bottom`,sideOffset:4,children:(0,Q.jsxs)(Ji,{"data-active-tone":o,className:K(`min-w-40 rounded-box border border-base-300 bg-base-100 p-xs shadow-lg outline-none caps-combobox-panel caps-combobox-popup`,c),children:[(0,Q.jsx)(`div`,{className:`caps-combobox-search`,children:ye}),be]})})})]})}):(0,Q.jsx)(`div`,{...j,className:K(j.className),ref:D,children:(0,Q.jsxs)(`div`,{className:K(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,Q.jsx)(`div`,{className:`caps-combobox-search`,children:ye}),be]})})}function ia({icon:e,caption:t}){return(0,Q.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,Q.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,Q.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,Q.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var aa=(0,q.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,Q.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,Q.jsx)(bi,{...a,appearance:r??`default`,"aria-label":e,className:K(`caps-icon-choice-input`,i),indicator:(0,Q.jsx)(ia,{icon:t,caption:n}),ref:o})})});function oa({checked:e}){let t=`caps-radio-${(0,q.useId)().replaceAll(`:`,``)}`,n=(0,q.useRef)(null),r=(0,q.useRef)(e).current,i=(0,q.useRef)(e),a=(0,q.useRef)(null),o=ve(a),{reduced:s}=o;return(0,q.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=Z(o,{ease:`outCubic`,duration:75}),c=e?$r(o,{bounce:.65,duration:300}):Z(o,{ease:`inCubic`,duration:100}),l=V(n.current,t?{rx:r,ry:r,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...a},{to:r,...c}],ry:[{to:e?4.5:3.85,...a},{to:r,...c}],cy:[{to:e?5.85:6.1,...a},{to:6,...c}]});return()=>{l.cancel()}},[e,s,o]),(0,Q.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,Q.jsxs)(`defs`,{children:[(0,Q.jsx)(Vt,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,Q.jsx)(at,{id:`${t}-shadow`}),(0,Q.jsx)(St,{id:`${t}-inset`}),(0,Q.jsx)(`clipPath`,{id:`${t}-well`,children:(0,Q.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,Q.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,Q.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,Q.jsx)(`ellipse`,{ref:n,cx:`6`,cy:`6`,rx:r?4:0,ry:r?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var sa=(0,q.createContext)(null),ca=(0,q.forwardRef)(function({children:e,className:t,defaultValue:n,disabled:r=!1,name:i,onValueChange:a,orientation:o=`vertical`,value:s,...c},l){let u=(0,q.useId)(),d=(0,q.useRef)(null);(0,q.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,q.useState)(n),h=s??p;return(0,q.useEffect)(()=>{let e=d.current?.form;if(!e||s!==void 0)return;let t=e=>{queueMicrotask(()=>{e.defaultPrevented||m(n)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[s,n,c.form]),(0,Q.jsx)(sa.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,Q.jsx)(`fieldset`,{...c,className:K(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),la=(0,q.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,q.useContext)(sa);if(!s)throw Error(`RadioGroupItem must be used inside <RadioGroup>`);let c=s.value===i,l=e=>{n?.(e),e.target.checked&&s.onValueChange?.(i)};return(0,Q.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,Q.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:K(`caps-radio-input`,e),disabled:s.disabled||a.disabled,name:s.name,onChange:l,onClick:r,ref:o,type:`radio`,value:i}),t===void 0?(0,Q.jsx)(oa,{checked:c}):t]})}),ua=(0,q.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,q.useContext)(sa),s=(0,q.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,Q.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,Q.jsx)(la,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,Q.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,Q.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,Q.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,Q.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),da=(0,q.forwardRef)(function({label:e,icon:t,caption:n,className:r,...i},a){return(0,Q.jsx)(`label`,{className:`caps-icon-choice`,children:(0,Q.jsx)(la,{...i,"aria-label":e,className:K(`caps-icon-choice-input`,r),indicator:(0,Q.jsx)(ia,{icon:t,caption:n}),ref:a})})}),fa=(0,q.forwardRef)(function({className:e,invalid:t,...n},r){return(0,Q.jsxs)(`span`,{className:`caps-select-shell`,children:[(0,Q.jsx)(`select`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:K(`select select-bordered caps-select w-full`,t&&`select-error`,e),ref:r}),!n.multiple&&(!n.size||n.size<=1)?(0,Q.jsx)(Or,{className:`caps-select-chevron`,"aria-hidden":`true`}):null]})});function pa({checked:e}){let t=`caps-switch-${(0,q.useId)().replaceAll(`:`,``)}`,n=(0,q.useRef)(null),r=(0,q.useRef)(null),i=(0,q.useRef)(e).current,a=(0,q.useRef)(e),o=Ee();return(0,q.useLayoutEffect)(()=>{if(!n.current||!r.current)return;let t=o||a.current===e;a.current=e;let i=e?16:8,s=me(n.current),c=$r(s,{bounce:.25,duration:440}),l=Z(s,{ease:`inOutSine`,duration:100}),u=V(n.current,t?{x:2,y:2,width:i,height:8,duration:0}:{x:[{to:e?2.5:1.5,...l},{to:2,...c}],y:[{to:1.5,...l},{to:2,...c}],height:[{to:9,...l},{to:8,...c}],width:[{to:e?7:16.5,...l},{to:i,...c}]}),d=V(r.current,{gradientTransform:e?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`,...t?{duration:0}:{delay:l.duration,...c}});return()=>{u.cancel(),d.cancel()}},[e,o]),(0,Q.jsxs)(`svg`,{className:`caps-switch-visual`,width:`40`,height:`24`,viewBox:`0 0 20 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,Q.jsxs)(`defs`,{children:[(0,Q.jsx)(Vt,{ref:r,id:`${t}-surface`,transform:i?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`}),(0,Q.jsx)(at,{id:`${t}-shadow`}),(0,Q.jsx)(St,{id:`${t}-inset`}),(0,Q.jsx)(`clipPath`,{id:`${t}-track`,children:(0,Q.jsx)(`rect`,{x:`1`,y:`1`,width:`18`,height:`10`,rx:`5`})})]}),(0,Q.jsx)(`rect`,{className:`caps-switch-track`,filter:`url(#${t}-inset)`,x:`0.5`,y:`0.5`,width:`19`,height:`11`,rx:`5.5`}),(0,Q.jsx)(`g`,{clipPath:`url(#${t}-track)`,children:(0,Q.jsx)(`rect`,{ref:n,x:`2`,y:`2`,width:i?16:8,height:`8`,rx:`4`,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var ma=(0,q.forwardRef)(function({className:e,checked:t,defaultChecked:n=!1,onChange:r,onCheckedChange:i,...a},o){let s=(0,q.useRef)(null),[c,l]=(0,q.useState)(n),u=t??c;return(0,q.useImperativeHandle)(o,()=>{if(!s.current)throw Error(`Switch input is not mounted`);return s.current},[]),(0,q.useEffect)(()=>{let e=s.current?.form;if(!e||t!==void 0)return;let r=e=>{queueMicrotask(()=>{!e.defaultPrevented&&s.current&&l(n)})};return e.addEventListener(`reset`,r),()=>{e.removeEventListener(`reset`,r)}},[t,n,a.form]),(0,Q.jsxs)(`span`,{className:`caps-switch`,"data-checked":u,children:[(0,Q.jsx)(`input`,{...a,checked:u,className:K(`caps-switch-input`,e),onChange:e=>{t===void 0&&l(e.target.checked),r?.(e),i?.(e.target.checked)},ref:s,role:`switch`,type:`checkbox`}),(0,Q.jsx)(pa,{checked:u})]})}),ha=(0,q.forwardRef)(function({className:e,invalid:t,...n},r){return(0,Q.jsx)(`textarea`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:K(`textarea textarea-bordered w-full`,t&&`textarea-error`,e),ref:r})}),ga=z(R),_a=z(f),va=z(se(Ke)),ya=z(yn(R)),ba=yn(Mt(File)),xa=z(ba),Sa=ft([R,Ke,f,k,r,yn(R),ba]),Ca=z(Sa),$=e=>P(ga(e.state.value),()=>``),wa=e=>P(_a(e.state.value),()=>!1),Ta=e=>P(va(e.state.value),()=>null),Ea=e=>P(ya(e.state.value),()=>[]),Da=e=>P(xa(e.state.value),()=>[]),Oa=e=>P(Ca(e.state.value),()=>null);function ka({field:e,spec:t,locked:n,...r}){let[i,a]=(0,q.useState)(!1);return(0,Q.jsxs)(En,{children:[(0,Q.jsx)(On,{...r,name:t.name,disabled:n,type:i?`text`:`password`,autoComplete:`off`,spellCheck:!1,className:`caps-field-secret`,placeholder:t.placeholder,readOnly:t.readOnly,value:$(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,Q.jsx)(H,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,Q.jsx)(kr,{"aria-hidden":`true`}):(0,Q.jsx)(Vn,{"aria-hidden":`true`})})]})}var Aa={text:`text`,email:`email`,url:`url`,tel:`tel`};function ja({spec:e,field:t,locked:n,...r}){let i=Da(t),a=n||e.readOnly===!0,o=(0,q.useRef)(null);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,Q.jsx)(S,{asChild:!0,children:(0,Q.jsx)(`input`,{...r,ref:o,type:`file`,tabIndex:-1,required:r.required===!0&&i.length===0,name:e.name,accept:e.accept,multiple:e.multiple,disabled:a,onBlur:t.handleBlur,onChange:e=>{t.handleChange(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),(0,Q.jsx)(H,{type:`button`,variant:`outline`,"aria-label":`Choose files for ${e.label}`,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],disabled:a,onBlur:t.handleBlur,onClick:()=>{o.current?.click()},children:`Choose files`}),(0,Q.jsx)(fi,{items:i.map((e,t)=>({id:String(t),name:e.name,preview:{kind:`file`},progress:0,progressLabel:`${String(e.size)} bytes`,statusLabel:`Selected`,actions:a?{}:{remove:{label:`Remove`,accessibleLabel:`Remove ${e.name}`}}})),onRemove:e=>{t.handleChange(i.filter((t,n)=>String(n)!==e))},onCancel:()=>void 0,onRetry:()=>void 0})]})}function Ma({spec:e,field:t,locked:n,...r}){let i=e=>{t.handleChange(e)},a={...r,name:e.name,disabled:n,onBlur:t.handleBlur};switch(e.kind){case`text`:case`email`:case`url`:case`tel`:return(0,Q.jsx)(On,{...a,type:Aa[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,Q.jsx)(ha,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,Q.jsx)(ka,{...r,field:t,spec:e,locked:n});case`money`:return(0,Q.jsxs)(En,{children:[(0,Q.jsx)(Dn,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,Q.jsx)(On,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,Q.jsx)(On,{...a,type:`date`,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,Q.jsx)(zn,{...a,...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.step===void 0?{}:{step:e.step},...e.unit===void 0?{}:{unit:e.unit},...e.wrap===void 0?{}:{wrap:e.wrap},disabled:n||e.readOnly===!0,decrementLabel:`Decrease ${e.label}`,incrementLabel:`Increase ${e.label}`,value:Ta(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,Q.jsxs)(fa,{...a,value:$(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,Q.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,Q.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,Q.jsx)(ra,{id:r.id??e.name,"aria-describedby":r[`aria-describedby`],"aria-invalid":r[`aria-invalid`],"aria-required":r[`aria-required`],items:e.options,getKey:e=>e.value,getLabel:e=>e.label,isDisabled:t=>t.disabled||n||e.readOnly===!0,value:$(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,Q.jsx)(ta,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===$(t))?.label??e.placeholder??`Choose…`}),inputProps:{"aria-label":`Search ${e.label}`,disabled:n||e.readOnly===!0},onValueChange:e=>{i(e??``),t.handleBlur()}});case`file`:return(0,Q.jsx)(ja,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,Q.jsx)(bi,{...a,disabled:n||e.readOnly===!0,checked:wa(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,Q.jsx)(ma,{...a,disabled:n||e.readOnly===!0,checked:wa(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var Na=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function Pa({spec:e,field:t,locked:n,error:r}){let i=n||e.readOnly===!0,a=e.label;if(e.kind===`checkboxes`||e.kind===`icon-checkboxes`){let n=Ea(t),o=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,Q.jsx)(Pn,{legend:a,description:e.help,disabled:i,error:r??null,children:e.kind===`icon-checkboxes`?(0,Q.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,Q.jsx)(aa,{name:e.name,value:r.value,label:r.label,...r.caption===void 0?{}:{caption:r.caption},icon:r.icon,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{o(r.value,e.currentTarget.checked)}},r.value))}):e.options.map(r=>(0,Q.jsx)(Cn,{label:r.label,description:r.description,orientation:`inline`,children:(0,Q.jsx)(bi,{name:e.name,value:r.value,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{o(r.value,e.currentTarget.checked)}})},r.value))})}let o=e.options.some(e=>e.description!==void 0||e.meta!==void 0);return(0,Q.jsx)(Pn,{legend:a,description:e.help,disabled:i,error:r??null,children:(0,Q.jsx)(ca,{name:e.name,"aria-label":a,value:$(t),onValueChange:e=>{t.handleChange(e),t.handleBlur()},orientation:e.kind===`icon-radio`||o?`horizontal`:`vertical`,children:e.options.map(t=>e.kind===`icon-radio`?(0,Q.jsx)(da,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):o?(0,Q.jsx)(ua,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,Q.jsx)(Cn,{label:t.label,orientation:`inline`,children:(0,Q.jsx)(la,{value:t.value,disabled:t.disabled})},t.value))})})}function Fa({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:Oa(t),onChange:e=>{t.handleChange(e)},onBlur:t.handleBlur,error:r,disabled:n,id:a.id??e.name,"aria-describedby":a[`aria-describedby`],"aria-invalid":r!==void 0})}function Ia({form:e,spec:t,locked:n}){let r=Nn({form:e,name:t.name}),i=In(e.store,e=>e.submissionAttempts>0),a=r.state.meta.isBlurred||i?Qr(r.state.meta):void 0;if(t.render===void 0&&Na.has(t.kind))return(0,Q.jsx)(Pa,{spec:t,field:r,locked:n,error:a});let o=t.kind===`checkbox`?`inline`:(t.layout??(t.kind===`switch`?`row`:`stacked`))===`row`?`horizontal`:`vertical`;return(0,Q.jsx)(Cn,{label:t.label,description:t.help,icon:t.icon,orientation:o,error:a,...t.required===void 0?{}:{required:t.required},...t.optional===void 0?{}:{optional:t.optional},children:t.render===void 0?(0,Q.jsx)(Ma,{spec:t,field:r,locked:n}):(0,Q.jsx)(Fa,{spec:t,field:r,locked:n,error:a,render:t.render})})}var La=z(re(R,Sa));function Ra({form:e,spec:t,locked:n}){let r=t.when;return In(e.store,e=>r===void 0||r(P(La(e.values),()=>({}))))?(0,Q.jsx)(Ia,{form:e,spec:t,locked:n}):null}function za({form:e,section:t,locked:n}){let r=t.fields.map(t=>(0,Q.jsx)(Ra,{form:e,spec:t,locked:n},t.name));return t.title===void 0?r:(0,Q.jsx)(jn,{title:t.title,description:t.description,children:r})}function Ba({model:e,names:t,disabled:n=!1}){let r=e.form;return t===void 0?e.description.sections.map(e=>(0,Q.jsx)(za,{form:r,section:e,locked:n},e.id??``)):t.map(t=>{let i=e.description.fields.find(e=>e.name===t);return i===void 0?null:(0,Q.jsx)(Ra,{form:r,spec:i,locked:n},t)})}var Va=class{annotation;constructor(e){this.annotation=e}},Ha=class{sections;constructor(e){this.sections=e}},Ua=`caps/form`,Wa=0;function Ga(e){Wa+=1;let t={[`${Ua}:${String(Wa)}`]:new Va(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}R.annotate(Ga({kind:`secret`})).pipe(It(`Secret`));var Ka=e=>{let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)};function qa(e){return Object.values(e??{}).reduce((e,t)=>t instanceof Va?{...e,...t.annotation}:e,{})}function Ja(e){return e.reduce((e,t)=>({...e,...qa(t)}),{})}function Ya(e){let t=e?.[Ua];return t instanceof Ha?t.sections:{}}var Xa=z(R);function Za(e){if(cn(e))return Ge(Xa(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!o(e))return null;let t=[];for(let n of e.types){if(Ot(n))continue;let e=Za(n);if(e===null)return null;t.push(...e)}return t}function Qa(e){if(xe(e))return{type:`string`,literals:[]};if(x(e))return{type:`number`,nullable:!1};if(m(e))return{type:`boolean`};let t=Za(e);if(t!==null)return{type:`string`,literals:t};if(Ie(e)){let[t]=e.rest;if(t===void 0)return null;if(xe(t))return{type:`strings`,literals:[]};let n=Za(t);return n===null?null:{type:`strings`,literals:n}}if(o(e)){let t=e.types.filter(e=>!Ot(e)&&!Re(e)),n=e.types.some(e=>Re(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=Qa(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function $a(e){let t=e.ast;if(!v(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=Te(e.type),r=Ja([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:Qa(n);if(i===null)throw Error(`Schema field "${t}" has no form control. Annotate it with field({ render }) or a kind.`);return{name:t,valueType:i,optional:e.type.context?.isOptional===!0,annotation:r,title:_e(e.type),description:pe(e.type)}}),sections:Ya(wt(t))}}function eo(e){let t=e,r=!1,i=!1;for(;;)if(t instanceof ke)r=!0,t=t.unwrap();else if(t instanceof Ze)i=!0,t=t.unwrap();else if(t instanceof oe)t=t.unwrap();else if(t instanceof n)t=t.in;else return{node:t,optional:r,nullable:i}}function to(e){if(e instanceof Rt){let t=e.options.map(e=>to(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof Wt?e.options:e instanceof ne?[...e.values]:null;if(t===null)return null;let n=t.map(e=>Xa(e));return n.every(vn)?n.map(e=>e.value):null}function no(e){let{node:t,nullable:n}=eo(e);if(t instanceof pt)return{type:`string`,literals:[]};if(t instanceof Ye)return{type:`number`,nullable:n};if(t instanceof O)return{type:`boolean`};let r=to(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof qe){let e=eo(t.element).node;if(e instanceof pt)return{type:`strings`,literals:[]};let n=to(e);return n===null?null:{type:`strings`,literals:n}}return null}function ro(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let r=e instanceof ke||e instanceof Ze||e instanceof oe?e.unwrap():e instanceof n?e.in:e;if(r===e)break;t.push(r)}return t.reverse().map(e=>un.get(e))}function io(e){return ro(e).reduce((e,t)=>({...e,...t}),{})}function ao(e){return Object.entries(e.shape)}function oo(e){let t=eo(e).node;if(!(t instanceof $e))throw Error(`A schema form needs a z.object.`);return{fields:ao(t).map(([e,t])=>{let n=Ja(ro(t)),r=n.kind===`file`?{type:`files`}:no(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=io(t);return{name:e,valueType:r,optional:eo(t).optional,annotation:n,title:i.title,description:i.description}}),sections:Ya(io(e))}}function so(e,t){let n=t.options??{};return(e.length>0?e:Object.keys(n)).map(e=>{let t=n[e],r=t===void 0?{}:t instanceof Object?t:{label:t};return{value:e,label:r.label??Ka(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function co(e,t){let n=t.some(e=>e.icon!==void 0);switch(e.type){case`boolean`:return`switch`;case`number`:return`number`;case`strings`:return n?`icon-checkboxes`:`checkboxes`;case`files`:return`file`;case`string`:return t.length===0?`text`:t.length>12?`combobox`:n?`icon-radio`:t.some(e=>e.description!==void 0||e.meta!==void 0)||t.length<=3?`radio`:`select`}}function lo(e,t){switch(e.type){case`boolean`:return!1;case`number`:return e.nullable?null:0;case`strings`:case`files`:return[];case`string`:return t[0]?.value??``}}function uo(e){let t=e instanceof Qt?oo(e):$a(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=so(e.valueType.type===`string`||e.valueType.type===`strings`?e.valueType.literals:[],e.annotation),a=r.help??e.description;return{...r,name:e.name,label:r.label??e.title??Ka(e.name),help:a,kind:n??co(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=lo(e.valueType,i.options))});let i=e=>e.order??e.index,a=e=>e.section!==void 0&&Object.hasOwn(t.sections,e.section)?e.section:null,o=e=>n.filter(t=>a(t)===e).sort((e,t)=>i(e)-i(t)),s=Object.entries(t.sections).map(([e,t])=>({id:e,title:t.title,description:t.description,fields:o(e)}));return{fields:n,sections:[{id:null,title:void 0,description:void 0,fields:o(null)},...s].filter(e=>e.fields.length>0),defaults:r}}function fo(e){let t=e instanceof Qt?e:pn(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>po(e)):po(n)}}}}function po(e){return e.issues===void 0?e:{issues:e.issues.map(e=>e.path===void 0?e:{...e,path:e.path.slice(0,1)})}}var mo=`onServer`;function ho(e){return e.state.meta.errorMap.onServer!==void 0}function go(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[mo]:void 0}}))}function _o(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[mo]:n}}))}function vo(e){let[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(e.defaultValues),[s,c]=(0,q.useState)(null);An(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,q.useMemo)(()=>uo(l),[l]),d=(0,q.useMemo)(()=>fo(l),[l]),f=Rn({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),ho(e)&&go(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await fo(l)[`~standard`].validate(t);if(a.issues){n(a.issues[0]?.message??`Check the form and try again.`);return}let o=await e.onSubmit(a.value,t)??{kind:`saved`};if(o.kind===`refused`){n(o.error??null);let e=r;for(let[t,n]of Object.entries(o.fields??{}))n!==void 0&&n.length>0&&_o(e,t,n);return}let s=o.values??t;c(s),r.reset(s),i(o.message??`Saved`)}});return{description:u,form:f,error:t,saved:r,discard:()=>{n(null),i(null),f.reset()},submit:()=>f.handleSubmit()}}function yo(e){return{dirty:In(e.form.store,e=>!e.isDefaultValue),submitting:In(e.form.store,e=>e.isSubmitting),canSubmit:In(e.form.store,e=>e.canSubmit)}}function bo({model:e,submitLabel:t=`Save changes`,discardLabel:n,allowClean:r,footer:i,children:a,disabled:o=!1,...s}){let{submitting:c}=yo(e);return(0,Q.jsxs)(Ln,{...s,busy:c,noValidate:!0,onSubmit:t=>{t.preventDefault(),e.form.state.isSubmitting||e.submit()},children:[a??(0,Q.jsx)(Ba,{model:e,disabled:o}),i===void 0?(0,Q.jsx)(Co,{model:e,label:t,...n===void 0?{}:{discardLabel:n},...r===void 0?{}:{allowClean:r}}):i]})}function xo({schema:e,defaultValues:t,onSubmit:n,...r}){let i=vo({schema:e,defaultValues:t,onSubmit:n});return(0,Q.jsx)(bo,{...r,model:i})}function So(e){return`model`in e?(0,Q.jsx)(bo,{...e}):(0,Q.jsx)(xo,{...e})}function Co({model:e,label:t,discardLabel:n,allowClean:r=!1,dirtyLabel:i=`Unsaved changes`,buttonProps:a,...o}){let{dirty:s,submitting:c,canSubmit:l}=yo(e),u=c?null:e.saved&&!s?(0,Q.jsx)(li,{tone:`success`,size:`compact`,label:e.saved}):s?(0,Q.jsx)(li,{tone:`neutral`,size:`compact`,label:i}):null;return(0,Q.jsxs)(Tn,{...o,error:e.error,status:u,children:[n&&s?(0,Q.jsx)(H,{type:`button`,variant:`ghost`,disabled:c,onClick:e.discard,children:n}):null,(0,Q.jsx)(H,{...a,type:`submit`,loading:c,disabled:c||!l||!s&&!r,children:t})]})}var wo=et.check(nt(/^(?!\.{1,2}$)[^/]+$/u,{message:`Enter a single file or folder name.`})),To={file:Xe({name:wo.annotate(Ga({label:`File name`}))}),folder:Xe({name:wo.annotate(Ga({label:`Folder name`}))})};function Eo(e){return(0,Q.jsx)(Do,{...e},e.creation?`${e.creation.kind}:${e.creation.directory}`:`closed`)}function Do({creation:e,rootPath:t,onCreate:n,onClose:r}){let i=vo({schema:To[e?.kind??`file`],defaultValues:{name:``},onSubmit:async t=>{if(!e)return;let i=await n(e,t.name);if(i)return i===`That name already exists in this directory.`?{kind:`refused`,fields:{name:i}}:{kind:`refused`,error:i};r()}}),{submitting:a}=yo(i);return(0,Q.jsx)(Zt,{open:e!==null,onOpenChange:e=>{!e&&!i.form.state.isSubmitting&&r()},children:(0,Q.jsxs)(Kt,{children:[(0,Q.jsxs)(Bt,{children:[(0,Q.jsxs)(Yt,{children:[`New `,e?.kind===`folder`?`folder`:`file`]}),(0,Q.jsxs)(xt,{children:[`Create in `,e?.directory??t,` on this Computer.`]})]}),(0,Q.jsx)(So,{model:i,onSubmitCapture:()=>{i.form.state.isSubmitting||i.form.setFieldValue(`name`,e=>e)},footer:(0,Q.jsxs)(Tn,{divider:!1,error:i.error,children:[(0,Q.jsx)(H,{variant:`ghost`,type:`button`,disabled:a,onClick:r,children:`Cancel`}),(0,Q.jsx)(H,{type:`submit`,disabled:a,loading:a,children:a?`Creating…`:`Create`})]})})]})})}function Oo({app:e,onOpenFile:t,activePath:n,rootPath:r=`/`,rootLabel:a=`Computer`,onSelectPath:o}){let s=Yr({app:e,rootPath:r,rootLabel:a,activePath:n,onOpenFile:t,onSelectPath:o}),[c,l]=(0,q.useState)(null),u=e.capabilities.has(or);function d(e,t){l({kind:e,directory:cr(t)})}async function f(n,r){let i=rr(r,n.directory);try{let a=0;for(;a!==null;){let t=a,i=await pr(e.capabilities,{path:n.directory,limit:256,offset:t});if(i.entries.some(e=>e.name===r))return`That name already exists in this directory.`;if(i.nextOffset!==null&&i.nextOffset<=t)return`Could not verify that name is available.`;a=i.nextOffset}n.kind===`folder`?(await e.capabilities.require(or).mkdir({path:i}),s.model.batch([{type:`add`,path:`${i}/`}])):(await dr(e.capabilities,{path:i,content:new Blob([])},{}),s.model.batch([{type:`add`,path:i}]),t(i));return}catch(e){return e instanceof Error?Ue(e).message:`Couldn't create ${n.kind}. Check Computer write access.`}}return(0,Q.jsxs)(`aside`,{className:`inkcap-tree`,"aria-label":`File tree`,children:[(0,Q.jsxs)(`div`,{className:`inkcap-tree-toolbar`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(mr,{"aria-hidden":`true`}),` Explorer`]}),(0,Q.jsx)(i,{icon:(0,Q.jsx)(ue,{}),"aria-label":`Refresh files`,title:`Refresh files`,variant:`ghost`,size:`xs`,disabled:s.busy,onClick:s.reloadRoot})]}),s.error&&(0,Q.jsx)(`p`,{role:`alert`,children:s.error}),(0,Q.jsx)(fr,{model:s.model,style:{flex:`1`,"--trees-item-height":`32px`,"--trees-padding-inline-override":`var(--spacing-xs)`,"--trees-item-margin-x-override":`0px`,"--trees-item-padding-x-override":`var(--spacing-xs)`,"--trees-item-row-gap-override":`var(--spacing-xs)`,"--trees-bg-override":`var(--color-base-100)`,"--trees-fg-override":`var(--color-base-content)`,"--trees-bg-muted-override":`var(--color-base-200)`,"--trees-selected-bg-override":`var(--color-base-300)`,"--trees-border-radius-override":`var(--radius-field)`,"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`12px`},renderContextMenu:(e,t)=>(0,Q.jsxs)(`div`,{className:`flex min-w-36 flex-col gap-xs p-xs`,role:`menu`,children:[(0,Q.jsxs)(H,{className:`w-full justify-start`,disabled:!u,role:`menuitem`,title:u?void 0:`Computer write access is not granted.`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1}),d(`file`,e.path)},children:[(0,Q.jsx)(ir,{"aria-hidden":`true`}),` New file`]}),(0,Q.jsxs)(H,{className:`w-full justify-start`,disabled:!u,role:`menuitem`,title:u?void 0:`Computer write access is not granted.`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1}),d(`folder`,e.path)},children:[(0,Q.jsx)(jr,{"aria-hidden":`true`}),` New folder`]})]})}),(0,Q.jsx)(Eo,{creation:c,rootPath:r,onCreate:f,onClose:()=>{l(null)}}),s.page.next!==null&&(0,Q.jsxs)(H,{disabled:s.busy,onClick:s.loadNext,children:[`More in `,s.page.path]})]})}export{Oo as InkcapFileTree};