@fungi.computer/inkcap 0.10.0 → 0.10.1
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.
- package/dist/assets/{FileTab-CGjo_RbA.js → FileTab-DDpwTFTX.js} +23 -23
- package/dist/assets/InkcapFileTree-CcW_lQ0m.js +1 -0
- package/dist/assets/{InkcapRepositoryApp-Dhj38ovX.js → InkcapRepositoryApp-Ce7OB6Hw.js} +1 -1
- package/dist/assets/folder-open-BIGH7eRS.js +1 -0
- package/dist/assets/index-BKX-loA_.js +2 -0
- package/dist/assets/index-Ly6xqAdZ.css +2 -0
- package/dist/assets/{tree-path-BxrnSpRU.js → tree-path-DZCDmsgc.js} +2 -2
- package/dist/assets/{useFileTree-B2AWKwuB.js → useFileTree-B2iPBKay.js} +1 -1
- package/dist/assets/useForm-D1MrwFQ_.js +1 -0
- package/dist/index.html +4 -4
- package/package.json +5 -5
- package/dist/assets/InkcapFileTree-DpqVh8_T.js +0 -1
- package/dist/assets/folder-open-DGOuHJ0O.js +0 -1
- package/dist/assets/index-DDIqdM7K.css +0 -2
- package/dist/assets/index-DRsgwabK.js +0 -2
- package/dist/assets/useForm-Dpy6Dgw6.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$n as n,A as r,Aa as i,Ai as a,B as o,Bi as s,Br as c,C as l,Ca as u,Ci as d,Di as f,Dr as p,E as m,Ea as h,Ei as g,Er as _,F as v,G as y,Gi as b,Gn as x,Gr as S,Hi as C,Hr as w,I as T,Ir as E,J as D,Ji as O,Jn as k,Jr as A,K as j,Ki as M,Kn as N,Kr as P,L as F,Li as I,Ln as L,Lr as R,M as ee,Ma as z,Mi as te,Mn as ne,N as re,Na as ie,Ni as B,Nn as ae,O as oe,Or as se,P as ce,Pa as le,Pn as ue,Pr as de,Qn as V,R as fe,Ri as pe,Rr as me,S as he,Sa as ge,Si as _e,T as ve,Ta as ye,Ti as be,Tn as xe,Tr as Se,Ui as Ce,Ur as we,Vi as H,Vr as Te,Vt as Ee,W as De,Wn as Oe,Wr as ke,Wt as Ae,Y as je,Yt as Me,Zi as U,Zn as Ne,_a as Pe,_i as Fe,a as Ie,b as Le,ba as Re,bi as ze,br as Be,c as Ve,cn as He,d as Ue,er as We,et as Ge,g as Ke,ga as qe,gi as Je,ha as Ye,ht as Xe,i as Ze,in as Qe,j as $e,ja as et,ji as tt,jr as nt,k as rt,ka as W,ki as it,kr as G,la as at,m as ot,ma as st,n as ct,nr as lt,on as ut,p as dt,pa as ft,pn as pt,q as mt,qn as K,qr as ht,rt as gt,s as _t,ta as vt,u as yt,v as bt,va as xt,vi as St,w as Ct,wa as wt,wi as Tt,x as Et,xa as Dt,xi as Ot,y as kt,ya as At,yi as jt,z as Mt,zr as Nt}from"./tree-path-DZCDmsgc.js";import{At as Pt,Ct as Ft,Dt as It,Et as Lt,Ft as Rt,Mt as zt,Ot as Bt,Pt as Vt,St as Ht,Tt as Ut,a as Wt,bt as Gt,c as Kt,d as qt,g as Jt,i as Yt,jt as Xt,kt as Zt,m as Qt,n as $t,o as en,r as tn,s as q,t as nn,u as rn,w as an,wt as on,xt as sn,yt as cn}from"./folder-open-BIGH7eRS.js";import{C as ln,S as J,T as un,_ as dn,a as fn,b as pn,c as mn,d as hn,f as gn,g as _n,h as vn,i as yn,l as bn,m as xn,n as Sn,o as Cn,p as wn,r as Y,s as Tn,t as En,u as Dn,v as On,w as kn,x as An}from"./useForm-D1MrwFQ_.js";import{n as jn,r as Mn,t as Nn}from"./useFileTree-B2iPBKay.js";function Pn(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var Fn=class extends Zt{#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,Bt.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||!zt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Pn(e,n).forEach(e=>{e.destroy()}),Pn(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=Xt(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 It(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)&&Bt.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},X=e(a(),1);function In({queries:e,...t},n){let r=Vt(n),i=Lt(),a=Ut(),o=t.subscribed!==!1,s=X.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=>{cn(e);let t=r.getQueryCache().get(e.queryHash);Ht(e,a,t)}),on(a);let[c]=X.useState(()=>new Fn(r,s,t)),[l,u,d]=c.getOptimisticResult(s,t.combine),f=!i&&o;X.useSyncExternalStore(X.useCallback(e=>f?c.subscribe(Bt.batchCalls(e)):Pt,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),X.useEffect(()=>{c.setQueries(s,t)},[s,t,c]);let p=l.some((e,t)=>sn(s[t],e))?l.flatMap((e,t)=>{let n=s[t];if(n&&sn(n,e)){let e=new It(r,n);return Gt(n,e,a)}return[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=s[t];return n&&Ft({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 Ln=f(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);jt.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>ze(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>_e(e,t,n),e.parseAsync=async(t,n)=>Ot(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>d(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)=>Tt(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Rn=f(`ZodMiniObject`,(e,t)=>{St.init(e,t),Ln.init(e,t),be(e,`shape`,()=>t.shape)});function zn(e,t){return new Rn({type:`object`,shape:e??{},...g(t)})}var Bn=f(`ZodMiniLiteral`,(e,t)=>{Fe.init(e,t),Ln.init(e,t)});function Vn(e,t){return new Bn({type:`literal`,values:Array.isArray(e)?e:[e],...g(t)})}var Hn=K(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Un=K(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Wn=K(`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`}]]),Gn=K(`Eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Kn=K(`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`}]]),qn=K(`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`}]]),Jn=K(`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`}]]);function Yn(e,t,n){return`${e.endsWith(`/`)?e:`${e}/`}${t}${n===`directory`?`/`:``}`}function Xn(e,t,n){let r=t.entries.filter(e=>e.type!==`symlink`).map(e=>Yn(t.path,e.name,e.type)),i=r.filter(t=>!n.has(t)&&!e.getItem(t));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 Zn(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 Qn({app:e,rootPath:t,rootLabel:n=`Computer`,activePath:r,onOpenFile:i,onSelectPath:a,rowHeight:o=32}){let s=Vt(),c=an(e),l=(0,X.useCallback)(t=>e.capabilities.subscribe(t),[e]),u=(0,X.useCallback)(()=>e.capabilities.version,[e]),d=(0,X.useSyncExternalStore)(l,u,u),f=(0,X.useMemo)(()=>({app:e,rootPath:t,computerId:c,version:d}),[e,t,c,d]),[p,m]=(0,X.useState)(null),h=p?.scope===f?p:null,g=r?Zn(r,t):[],_=h?.activePath===r?h.path:g.at(-1)??t,v=new Map;for(let e of[t,...g])v.set(`${e}:0`,{path:e,offset:0});for(let e of h?.pages??[])v.set(`${e.path}:${String(e.offset)}`,e);let y=[...v.values()],b=(t,n)=>Jt.of(e,`tree`,d,t,n),x=In({queries:y.map(({path:t,offset:n})=>tn(e,t,n)),combine:e=>({listings:e.flatMap((e,t)=>e.data?[{request:y[t],listing:e.data}]:[]),busy:e.some(e=>e.isFetching),failure:e.find(e=>e.error)?.error??null})}),S=(0,X.useRef)({activePath:r,onOpenFile:i,onSelectPath:a,rootLabel:n});S.current={activePath:r,onOpenFile:i,onSelectPath:a,rootLabel:n};let C=(e,t)=>{let n=e.replace(/\/+$/,``)||`/`,i=b(n,t);s.getQueryState(i)?.status===`error`&&s.invalidateQueries({queryKey:i,exact:!0}),m(e=>({scope:f,activePath:r,path:n,pages:[...e?.scope===f?e.pages.filter(e=>e.path!==n||e.offset!==t):[],{path:n,offset:t}]}))},w=(0,X.useRef)(C);w.current=C;let{model:T}=Nn({paths:[],itemHeight:o,initialExpansion:2,flattenEmptyDirectories:!1,composition:{contextMenu:{enabled:!0}},renderRowDecoration:({row:e})=>e.path===`/`?{text:S.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&&(S.current.onSelectPath?.(t),t.endsWith(`/`)?w.current(t,0):t!==S.current.activePath&&S.current.onOpenFile(t))}}),E=(0,X.useRef)(new Set),D=(0,X.useRef)(new Map),O=(0,X.useRef)(null);(0,X.useLayoutEffect)(()=>{E.current.clear(),D.current.clear(),T.resetPaths([]),O.current=null},[T,f]),(0,X.useLayoutEffect)(()=>{O.current=null;for(let e of T.getSelectedPaths())!e.endsWith(`/`)&&e!==r&&T.getItem(e)?.deselect()},[r,T]),(0,X.useLayoutEffect)(()=>{x.listings.length===0&&(E.current.clear(),D.current.clear(),T.resetPaths([]),O.current=null);for(let{request:e,listing:t}of x.listings){let n=`${e.path}:${String(e.offset)}`,r=t.entries.filter(e=>e.type!==`symlink`).map(e=>Yn(t.path,e.name,e.type)),i=D.current.get(n)??[];D.current.set(n,r);let a=new Set([...D.current.values()].flat());for(let e of i)if(!a.has(e)){T.getItem(e)&&T.remove(e,{recursive:!0});for(let t of E.current)(t===e||e.endsWith(`/`)&&t.startsWith(e))&&E.current.delete(t)}Xn(T,t,E.current)}if(!r||O.current===r)return;let e=Zn(r,t);if(!e.every(e=>E.current.has(e)))return;for(let t of e){let e=T.getItem(t);e&&`expand`in e&&e.expand()}let n=T.getItem(r);n&&(O.current=r,n.select(),T.scrollToPath(r,{focus:!1}))},[r,T,t,f,x.listings]),(0,X.useEffect)(()=>{x.failure&&console.error(`Inkcap directory listing failed`,Rt(x.failure))},[x.failure]);let k=x.listings.filter(({request:e})=>e.path===_).sort((e,t)=>e.request.offset-t.request.offset).at(-1)?.listing,A={path:k?.path??_,next:k?.nextOffset??null},j=x.listings.some(({request:e,listing:n})=>e.path===t&&e.offset===0&&n.entries.length===0&&n.nextOffset===null);return{model:T,page:A,error:x.failure?`${de(x.failure).message} Your open files remain available.`:``,busy:x.busy,rootEmpty:j,reloadRoot:()=>{s.invalidateQueries({queryKey:Jt.of(e,`tree`,d)})},loadNext:()=>{A.next!==null&&C(A.path,A.next)}}}var $n=U(H),er=U(C({message:H}));function tr(e){for(let t of e.errors){let e=i(le(z(er(t),e=>e.message),()=>$n(t)));if(e!==void 0&&e.length>0)return e}}var Z=it(),nr={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},rr=(0,X.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,Z.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:G(`progress caps-gooey-motion caps-gooey-progress w-full`,nr[t],e),ref:r})});(0,X.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,Z.jsxs)(`div`,{...a,ref:o,className:G(`caps-game-meter`,i),children:[(0,Z.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,Z.jsx)(rr,{"aria-label":e,value:t,max:n,tone:r})]})});function ir({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,Z.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,Z.jsx)(sr,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function ar({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,Z.jsx)(x,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,Z.jsx)(Jn,{}):(0,Z.jsx)(N,{}),onClick:()=>void n(t),type:`button`}):null}function or({item:e}){return(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,Z.jsx)(`div`,{className:`caps-upload-details`,children:(0,Z.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 sr({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,Z.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,Z.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,Z.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,Z.jsx)(Kn,{className:`size-4`})}),(0,Z.jsx)(or,{item:e}),(0,Z.jsx)(cr,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,Z.jsx)(rr,{"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 cr({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,Z.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,Z.jsx)(ar,{action:e.retry,id:t,onAction:i,retry:!0}),(0,Z.jsx)(ar,{action:e.cancel,id:t,onAction:n}),(0,Z.jsx)(ar,{action:e.remove,id:t,onAction:r})]})}var lr={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`},ur={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function dr({state:e}){let t=`caps-checkbox-${(0,X.useId)().replaceAll(`:`,``)}`,r=(0,X.useRef)(null),i=(0,X.useRef)(e).current,a=(0,X.useRef)(e),o=se();return(0,X.useLayoutEffect)(()=>{if(!r.current)return;let t=e!==`unchecked`,n=a.current!==`unchecked`,i=o||a.current===e;a.current=e;let s=_(r.current),c=q(s,{ease:`inCubic`,duration:160}),l=lt(r.current,{d:{to:lr[e],...i?en:q(s,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...i?en:t?q(s,{ease:`inOutSine`,duration:260}):c},"stroke-width":i?{to:t?2.4:0,duration:0}:t&&!n?[{to:2.2,...q(s,{ease:`outCubic`,duration:65})},{to:2.4,delay:Se(s,120),...Kt(s,{bounce:.35,duration:220})}]:{to:t?2.4:0,...c}});return()=>{l.cancel()}},[e,o]),(0,Z.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,Z.jsxs)(`defs`,{children:[(0,Z.jsx)(We,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,Z.jsx)(n,{id:`${t}-shadow`}),(0,Z.jsx)(V,{id:`${t}-inset`}),(0,Z.jsx)(Ne,{id:`${t}-goo`,values:ur}),(0,Z.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,Z.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,Z.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,Z.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,Z.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,Z.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,Z.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,Z.jsx)(`path`,{ref:r,d:lr[i],fill:`none`,stroke:`var(--color-white)`,strokeWidth:i===`unchecked`?0:2.4,pathLength:`1`,strokeDasharray:`1`,strokeDashoffset:+(i===`unchecked`),strokeLinecap:`round`,strokeLinejoin:`round`,filter:e===`mixed`?void 0:`url(#${t}-goo)`})}),(0,Z.jsx)(`clipPath`,{id:`${t}-well`,children:(0,Z.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,Z.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,Z.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,Z.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,Z.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,Z.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,Z.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var fr=(0,X.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,X.useRef)(null),[d,f]=(0,X.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,X.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,X.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,X.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,Z.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,Z.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:G(`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,Z.jsx)(dr,{state:m}):n]})}),pr=zn({keyCode:Vn(229)});function mr(e){return e.nativeEvent.isComposing||_e(pr,e.nativeEvent).success}var hr=X.createContext(void 0);function Q(e){let t=X.useContext(hr);if(t===void 0&&!e)throw Error(Oe(47));return t}var gr=e(nt(),1),_r={...l,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!l.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&l.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>l.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},vr=class extends Ct{constructor(e,t,n){let r=new oe;super(yr(e,r,t,n),br(r),_r)}setOpen=(e,t)=>{let n=t.reason===Qe,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=$e(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=re(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}),gr.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function yr(e,t,n,r=!1){let i={...he(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 br(e){return{popupRef:X.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:X.createRef(),beforeTriggerFocusGuardRef:X.createRef(),beforeContentFocusGuardRef:X.createRef(),stickIfOpenTimeout:new Ee,stickIfOpen:!0,triggerElements:e}}var xr=ve(function({props:e}){let{children:t,open:n,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,modal:s=!1,handle:c,triggerId:l,defaultTriggerId:u=null}=e,d=Cr(c,{modal:s,open:i,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`,a),d.useContextCallback(`onOpenChangeComplete`,o),fe(d,f),ce(d);let{forceUnmount:h}=v(f,d,()=>{d.context.stickIfOpen=!0,d.set(`openChangeReason`,null)});d.useSyncedValues({modal:s}),X.useEffect(()=>{f||d.context.stickIfOpenTimeout.clear()},[d,f]),X.useImperativeHandle(e.actionsRef,()=>({unmount:h,close:()=>d.setOpen(!1,ut(Me))}),[h,d]);let g=f||p||c!=null;return(0,Z.jsxs)(hr.Provider,{value:d,children:[c&&(0,Z.jsx)(r,{handle:c,store:d}),g&&(0,Z.jsx)(wr,{store:d,modal:s}),typeof t==`function`?t({payload:m}):t]})});function Sr(e){return Q(!0)?(0,Z.jsx)(xr,{props:e}):(0,Z.jsx)(D,{children:(0,Z.jsx)(xr,{props:e})})}function Cr(e,t){let n=F((e,n)=>new vr(t,e,n));return X.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function wr({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=De(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return T(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}var Tr=m(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=Q(!0),h=Et(s)??m;if(!h)throw Error(Oe(74));let g=Ae(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),b=h.useState(`isOpenedByTrigger`,g),x=h.useState(`triggerPopupId`,g),S=X.useRef(null),{registerTrigger:C,isMountedByThisTrigger:w}=Mt(g,S,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),T=h.useState(`isPressOpenedByTrigger`,g),E=h.useState(`isTouchPressOpen`,l),D=h.useState(`hasTriggerFocusGuards`,g),O=kn(v,{enabled:!a&&l&&!E,mouseOnly:!0,move:!1,handleClose:ln(),restMs:u,delay:{close:d},triggerElementRef:S,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=pt(()=>h.context.stickIfOpen),A=y(v,{stickIfOpen:k}),j=Ke(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),M=h.useState(`triggerProps`,w),{getButtonProps:N,buttonRef:P}=He({disabled:a,native:o}),F={open(e){return T?ae.open(e):ue.open(e)}},{handlePreFocusGuardFocus:I,handleFocusTargetFocus:R}=xn(h,S),ee=L(`button`,e,{state:{disabled:a,open:b},ref:[P,t,C,S],props:[A.reference,O,M,j,{[Ge]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},p,N],stateAttributesMapping:F}),z=(0,Z.jsx)(X.Fragment,{children:ee},g);return D?(0,Z.jsxs)(X.Fragment,{children:[(0,Z.jsx)(Xe,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:I}),z,(0,Z.jsx)(Xe,{ref:h.context.triggerFocusTargetRef,onFocus:R})]}):z}),Er=X.createContext(void 0);function Dr(){let e=X.useContext(Er);if(e===void 0)throw Error(Oe(45));return e}var Or=X.forwardRef(function(e,n){let{keepMounted:r=!1,...i}=e;return Q().useState(`mounted`)||r?(0,Z.jsx)(Er.Provider,{value:r,children:(0,Z.jsx)(t,{ref:n,...i})}):null}),kr=X.createContext(void 0);function Ar(){let e=X.useContext(kr);if(!e)throw Error(Oe(46));return e}var jr=X.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=gt,..._}=e,v=Q(),y=Dr(),b=je(),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=On({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}),N=x.useState(`domReferenceElement`);dn({store:v,domReference:N,positionerElement:O,open:C});let P=E===!0&&w!==`trigger-hover`;vn(C&&P,D===`touch`,O,T);let F=v.useStateSetter(`positionerElement`),I={open:C,side:M.side,align:M.align,anchorHidden:M.anchorHidden,instant:k},L=_n(e,I,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,F],hidden:!S,inert:!C});return(0,Z.jsxs)(kr.Provider,{value:M,children:[S&&P&&(0,Z.jsx)(bt,{inert:kt(!C),cutout:T}),(0,Z.jsx)(mt,{id:b,children:L})]})}),Mr=X.createContext(void 0);function Nr(){let[e,t]=X.useState(0),n=pt(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:X.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var Pr=X.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:s,...c}=e,l=Q(),u=Ar(),d=An(!0)!=null,{context:f,hasClosePart:p}=Nr(),m=l.useState(`open`),h=l.useState(`openMethod`),g=l.useState(`instantType`),_=l.useState(`transitionStatus`),v=l.useState(`popupProps`),y=l.useState(`titleElementId`),b=l.useState(`descriptionElementId`),x=l.useState(`modal`),S=l.useState(`mounted`),C=l.useState(`openChangeReason`),w=l.useState(`activeTriggerElement`),T=l.useState(`floatingRootContext`),E=T.useState(`floatingId`),D=l.useState(`disabled`),O=l.useState(`openOnHover`),k=l.useState(`closeDelay`);o({open:m,ref:l.context.popupRef,onComplete(){m&&l.context.onOpenChangeComplete?.(!0)}}),un(T,{enabled:O&&!D,closeDelay:k});let A=a===void 0?ee(l.context.popupRef):a,M=x!==!1&&p;l.useSyncedValue(`focusManagerModal`,M);let N=l.useStateSetter(`popupElement`),P={open:m,side:u.side,align:u.align,instant:g,transitionStatus:_},F=L(`div`,e,{state:P,ref:[t,l.context.popupRef,N],props:[v,{id:E,role:`dialog`,...rt,"aria-labelledby":y,"aria-describedby":b,onKeyDown(e){d&&Le.has(e.key)&&e.stopPropagation()}},pn(_),c],stateAttributesMapping:ne});return(0,Z.jsx)(j,{context:T,openInteractionType:h,modal:M,disabled:!S||C===`trigger-hover`,initialFocus:A,returnFocus:s,restoreFocus:`popup`,getInsideElements:()=>[l.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:xe(w)?w:void 0,nextFocusableElement:l.context.triggerFocusTargetRef,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:(0,Z.jsx)(Mr.Provider,{value:f,children:F})})});function Fr({getKey:e,isDisabled:t=()=>!1,items:n}){let r=(0,X.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,X.useState)(null);(0,X.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 Ir=(0,X.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,Z.jsxs)(`button`,{...r,ref:i,type:n,className:G(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(Un,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function Lr({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,X.useState)(``),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(t),[x,S]=(0,X.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,X.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=Fr({getKey:n,isDisabled:o,items:T});(0,X.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(mr(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,X.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 Rr(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)},N;C?N=A:A!==void 0&&(N=A===null?[]:[A]);let P=(0,X.useId)(),F=O?.props??_,I=g??F?.id??P,L={id:I,"aria-describedby":[t,F?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??F?.[`aria-invalid`],"aria-label":F?.[`aria-label`]??r,"aria-labelledby":F?.[`aria-labelledby`]??i,"aria-required":a??F?.[`aria-required`]},{keyboardNavigation:R,onPointerMove:ee,activeItem:z,activeKey:te,commit:ne,groups:re,inputValue:ie,listboxId:B,onInputChange:ae,onInputKeyDown:oe,open:se,optionId:ce,selectedKeys:le,setOpen:ue}=Lr({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:I,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:N,trigger:O});dt(()=>{O&&ue(!1)});let de=ot(`popover`),V=s===void 0?de:s,fe=wn(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),pe=(0,Z.jsx)(J,{..._,...O?{}:L,"aria-activedescendant":z?ce(f(z)):void 0,"aria-autocomplete":`list`,"aria-controls":B,"aria-expanded":!0,className:G(`input-sm`,_?.className),id:O?_?.id??`${I}-input`:I,onChange:e=>{_?.onChange?.(e),ae(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||oe(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:ie}),me=(0,Z.jsx)(`div`,{id:B,ref:fe,className:`caps-combobox-list`,"data-navigation":R?`keyboard`:`pointer`,onPointerMove:ee,role:`listbox`,"aria-multiselectable":C??void 0,children:re.every(e=>e.items.length===0)?(0,Z.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):re.map(e=>(0,Z.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,Z.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=te===t,i={active:r,disabled:n,selected:le.includes(t)};return(0,Z.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&R,disabled:n,id:ce(t),onClick:()=>{ne(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,Z.jsx)(Hn,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,Z.jsx)(`div`,{...j,className:G(j.className),ref:D,children:(0,Z.jsxs)(Sr,{modal:!0,onOpenChange:ue,open:se,children:[(0,Z.jsx)(Tr,{...L,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),V===null?null:(0,Z.jsx)(Or,{container:V,children:(0,Z.jsx)(jr,{align:`start`,side:`bottom`,sideOffset:4,children:(0,Z.jsxs)(Pr,{"data-active-tone":o,className:G(`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,Z.jsx)(`div`,{className:`caps-combobox-search`,children:pe}),me]})})})]})}):(0,Z.jsx)(`div`,{...j,className:G(j.className),ref:D,children:(0,Z.jsxs)(`div`,{className:G(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,Z.jsx)(`div`,{className:`caps-combobox-search`,children:pe}),me]})})}function zr({icon:e,caption:t}){return(0,Z.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,Z.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,Z.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,Z.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var Br=(0,X.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,Z.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,Z.jsx)(fr,{...a,appearance:r??`default`,"aria-label":e,className:G(`caps-icon-choice-input`,i),indicator:(0,Z.jsx)(zr,{icon:t,caption:n}),ref:o})})}),Vr=(0,X.forwardRef)(function({label:e,icon:t,hint:n,className:r,...i},a){let o=(0,X.useId)(),s=[i[`aria-describedby`],n?o:null].filter(Boolean).join(` `)||void 0;return(0,Z.jsx)(`label`,{className:`caps-check-key`,children:(0,Z.jsx)(fr,{...i,"aria-label":e,"aria-describedby":s,className:G(`caps-check-key-input`,r),indicator:(0,Z.jsxs)(`span`,{className:`caps-check-key-face`,"aria-hidden":`true`,children:[t?(0,Z.jsx)(`span`,{className:`caps-check-key-icon`,children:t}):null,(0,Z.jsxs)(`span`,{className:`caps-check-key-copy`,children:[(0,Z.jsx)(`span`,{className:`caps-check-key-label`,children:e}),n?(0,Z.jsx)(`span`,{className:`caps-check-key-hint`,id:o,children:n}):null]}),(0,Z.jsx)(`span`,{className:`caps-check-key-lamp`})]}),ref:a})})});function Hr({className:e,...t}){return(0,Z.jsx)(`div`,{...t,className:G(`caps-check-keys`,e)})}function Ur({checked:e}){let t=`caps-radio-${(0,X.useId)().replaceAll(`:`,``)}`,r=(0,X.useRef)(null),i=(0,X.useRef)(e).current,a=(0,X.useRef)(e),o=(0,X.useRef)(null),s=p(o),{reduced:c}=s;return(0,X.useLayoutEffect)(()=>{if(!r.current)return;let t=c||a.current===e;a.current=e;let n=e?4:0,i=q(s,{ease:`outCubic`,duration:75}),o=e?Kt(s,{bounce:.65,duration:300}):q(s,{ease:`inCubic`,duration:100}),l=lt(r.current,t?{rx:n,ry:n,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...i},{to:n,...o}],ry:[{to:e?4.5:3.85,...i},{to:n,...o}],cy:[{to:e?5.85:6.1,...i},{to:6,...o}]});return()=>{l.cancel()}},[e,c,s]),(0,Z.jsxs)(`svg`,{ref:o,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,Z.jsxs)(`defs`,{children:[(0,Z.jsx)(We,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,Z.jsx)(n,{id:`${t}-shadow`}),(0,Z.jsx)(V,{id:`${t}-inset`}),(0,Z.jsx)(`clipPath`,{id:`${t}-well`,children:(0,Z.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,Z.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,Z.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,Z.jsx)(`ellipse`,{ref:r,cx:`6`,cy:`6`,rx:i?4:0,ry:i?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var Wr=(0,X.createContext)(null),Gr=(0,X.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,X.useId)(),d=(0,X.useRef)(null);(0,X.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,X.useState)(n),h=s??p;return(0,X.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,Z.jsx)(Wr.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,Z.jsx)(`fieldset`,{...c,className:G(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),Kr=(0,X.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,X.useContext)(Wr);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,Z.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,Z.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:G(`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,Z.jsx)(Ur,{checked:c}):t]})}),qr=(0,X.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,X.useContext)(Wr),s=(0,X.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,Z.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,Z.jsx)(Kr,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,Z.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,Z.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,Z.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,Z.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),Jr=(0,X.forwardRef)(function({label:e,icon:t,caption:n,art:r=`dim`,className:i,...a},o){return(0,Z.jsx)(`label`,{className:`caps-icon-choice`,"data-art":r===`color`?r:void 0,children:(0,Z.jsx)(Kr,{...a,"aria-label":e,className:G(`caps-icon-choice-input`,i),indicator:(0,Z.jsx)(zr,{icon:t,caption:n}),ref:o})})});(0,X.forwardRef)(function({label:e,color:t,className:n,...r},i){return(0,Z.jsx)(`label`,{className:`caps-icon-choice`,"data-art":`color`,"data-swatch":``,title:e,children:(0,Z.jsx)(Kr,{...r,"aria-label":e,className:G(`caps-icon-choice-input`,n),indicator:(0,Z.jsx)(zr,{icon:(0,Z.jsx)(`span`,{className:`caps-swatch-dot`,style:{backgroundColor:t}})}),ref:i})})});var Yr=(0,X.forwardRef)(function({className:e,invalid:t,...n},r){return(0,Z.jsxs)(`span`,{className:`caps-select-shell`,children:[(0,Z.jsx)(`select`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:G(`select select-bordered caps-select w-full`,t&&`select-error`,e),ref:r}),!n.multiple&&(!n.size||n.size<=1)?(0,Z.jsx)(Un,{className:`caps-select-chevron`,"aria-hidden":`true`}):null]})});function Xr({checked:e}){let t=`caps-switch-${(0,X.useId)().replaceAll(`:`,``)}`,r=(0,X.useRef)(null),i=(0,X.useRef)(null),a=(0,X.useRef)(e).current,o=(0,X.useRef)(e),s=se();return(0,X.useLayoutEffect)(()=>{if(!r.current||!i.current)return;let t=s||o.current===e;o.current=e;let n=e?16:8,a=_(r.current),c=Kt(a,{bounce:.25,duration:440}),l=q(a,{ease:`inOutSine`,duration:100}),u=lt(r.current,t?{x:2,y:2,width:n,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:n,...c}]}),d=lt(i.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,s]),(0,Z.jsxs)(`svg`,{className:`caps-switch-visual`,width:`40`,height:`24`,viewBox:`0 0 20 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,Z.jsxs)(`defs`,{children:[(0,Z.jsx)(We,{ref:i,id:`${t}-surface`,transform:a?`matrix(2 0 0 1 10 6)`:`matrix(1 0 0 1 6 6)`}),(0,Z.jsx)(n,{id:`${t}-shadow`}),(0,Z.jsx)(V,{id:`${t}-inset`}),(0,Z.jsx)(`clipPath`,{id:`${t}-track`,children:(0,Z.jsx)(`rect`,{x:`1`,y:`1`,width:`18`,height:`10`,rx:`5`})})]}),(0,Z.jsx)(`rect`,{className:`caps-switch-track`,filter:`url(#${t}-inset)`,x:`0.5`,y:`0.5`,width:`19`,height:`11`,rx:`5.5`}),(0,Z.jsx)(`g`,{clipPath:`url(#${t}-track)`,children:(0,Z.jsx)(`rect`,{ref:r,x:`2`,y:`2`,width:a?16:8,height:`8`,rx:`4`,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var Zr=(0,X.forwardRef)(function({className:e,checked:t,defaultChecked:n=!1,onChange:r,onCheckedChange:i,...a},o){let s=(0,X.useRef)(null),[c,l]=(0,X.useState)(n),u=t??c;return(0,X.useImperativeHandle)(o,()=>{if(!s.current)throw Error(`Switch input is not mounted`);return s.current},[]),(0,X.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,Z.jsxs)(`span`,{className:`caps-switch`,"data-checked":u,children:[(0,Z.jsx)(`input`,{...a,checked:u,className:G(`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,Z.jsx)(Xr,{checked:u})]})}),Qr=(0,X.forwardRef)(function({className:e,invalid:t,...n},r){return(0,Z.jsx)(`textarea`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:G(`textarea textarea-bordered w-full`,t&&`textarea-error`,e),ref:r})}),$r=U(H),ei=U(te),ti=U(pe(B)),ni=U(tt(H)),ri=tt(vt(File)),ii=U(ri),ai=M([H,B,te,I,b,tt(H),ri]),oi=U(ai),$=e=>W($r(e.state.value),()=>``),si=e=>W(ei(e.state.value),()=>!1),ci=e=>W(ti(e.state.value),()=>null),li=e=>W(ni(e.state.value),()=>[]),ui=e=>W(ii(e.state.value),()=>[]),di=e=>W(oi(e.state.value),()=>null);function fi({field:e,spec:t,locked:n,...r}){let[i,a]=(0,X.useState)(!1);return(0,Z.jsxs)(hn,{children:[(0,Z.jsx)(J,{...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,Z.jsx)(k,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,Z.jsx)(Wn,{"aria-hidden":`true`}):(0,Z.jsx)(Gn,{"aria-hidden":`true`})})]})}var pi={text:`text`,email:`email`,url:`url`,tel:`tel`};function mi({spec:e,field:t,locked:n,...r}){let i=ui(t),a=n||e.readOnly===!0,o=(0,X.useRef)(null);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,Z.jsx)(Be,{asChild:!0,children:(0,Z.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,Z.jsx)(k,{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,Z.jsx)(ir,{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 hi({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,Z.jsx)(J,{...a,type:pi[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,Z.jsx)(Qr,{...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,Z.jsx)(fi,{...r,field:t,spec:e,locked:n});case`money`:return(0,Z.jsxs)(hn,{children:[(0,Z.jsx)(gn,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,Z.jsx)(J,{...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,Z.jsx)(J,{...a,type:`date`,readOnly:e.readOnly,value:$(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,Z.jsx)(Dn,{...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:ci(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,Z.jsxs)(Yr,{...a,value:$(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,Z.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,Z.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,Z.jsx)(Rr,{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,Z.jsx)(Ir,{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,Z.jsx)(mi,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,Z.jsx)(fr,{...a,disabled:n||e.readOnly===!0,checked:si(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,Z.jsx)(Zr,{...a,disabled:n||e.readOnly===!0,checked:si(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var gi=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function _i({spec:e,field:t,locked:n,error:r,layout:i}){let a=n||e.readOnly===!0,o=e.label;if(e.kind===`checkboxes`||e.kind===`icon-checkboxes`){let n=li(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,Z.jsx)(Cn,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:e.kind===`icon-checkboxes`?(0,Z.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,Z.jsx)(Br,{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=>{s(r.value,e.currentTarget.checked)}},r.value))}):(0,Z.jsx)(Hr,{children:e.options.map(r=>(0,Z.jsx)(Vr,{name:e.name,value:r.value,label:r.label,icon:r.icon,hint:r.description,disabled:r.disabled,checked:n.includes(r.value),onBlur:t.handleBlur,onChange:e=>{s(r.value,e.currentTarget.checked)}},r.value))})})}let s=e.options.some(e=>e.description!==void 0||e.meta!==void 0);return(0,Z.jsx)(Cn,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,Z.jsx)(Gr,{name:e.name,"aria-label":o,value:$(t),onValueChange:e=>{t.handleChange(e),t.handleBlur()},orientation:e.kind===`icon-radio`||s?`horizontal`:`vertical`,children:e.options.map(t=>e.kind===`icon-radio`?(0,Z.jsx)(Jr,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,Z.jsx)(qr,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,Z.jsx)(fn,{label:t.label,orientation:`inline`,children:(0,Z.jsx)(Kr,{value:t.value,disabled:t.disabled})},t.value))})})}function vi({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:di(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 yi({form:e,spec:t,locked:n,layout:r}){let i=Sn({form:e,name:t.name}),a=Y(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?tr(i.state.meta):void 0;if(t.render===void 0&&gi.has(t.kind))return(0,Z.jsx)(_i,{spec:t,field:i,locked:n,error:o,layout:r});let s=r===`columns`?t.kind===`switch`||t.kind===`checkbox`?`horizontal`:`vertical`:t.kind===`checkbox`?`inline`:(t.layout??(t.kind===`switch`?`row`:`stacked`))===`row`?`horizontal`:`vertical`;return(0,Z.jsx)(fn,{label:t.label,...r===`columns`?{labelTitle:t.label}:{},description:t.help,icon:t.icon,orientation:s,error:o,...t.required===void 0?{}:{required:t.required},...t.optional===void 0?{}:{optional:t.optional},children:t.render===void 0?(0,Z.jsx)(hi,{spec:t,field:i,locked:n}):(0,Z.jsx)(vi,{spec:t,field:i,locked:n,error:o,render:t.render})})}var bi=U(s(H,ai));function xi({form:e,spec:t,locked:n,layout:r}){let i=t.when;return Y(e.store,e=>i===void 0||i(W(bi(e.values),()=>({}))))?(0,Z.jsx)(yi,{form:e,spec:t,locked:n,layout:r}):null}function Si({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,Z.jsx)(xi,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,Z.jsx)(bn,{title:t.title,description:t.description,layout:r,children:i})}function Ci({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,Z.jsx)(Si,{form:i,section:e,locked:n,layout:r},e.id??``)):t.map(t=>{let a=e.description.fields.find(e=>e.name===t);return a===void 0?null:(0,Z.jsx)(xi,{form:i,spec:a,locked:n,layout:r},t)})}var wi=class{annotation;constructor(e){this.annotation=e}},Ti=class{sections;constructor(e){this.sections=e}},Ei=`caps/form`,Di=0;function Oi(e){Di+=1;let t={[`${Ei}:${String(Di)}`]:new wi(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}H.annotate(Oi({kind:`secret`})).pipe(O(`Secret`));var ki=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 Ai(e){return Object.values(e??{}).reduce((e,t)=>t instanceof wi?{...e,...t.annotation}:e,{})}function ji(e){return e.reduce((e,t)=>({...e,...Ai(t)}),{})}function Mi(e){let t=e?.[Ei];return t instanceof Ti?t.sections:{}}var Ni=U(H);function Pi(e){if(qe(e))return ie(Ni(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!ge(e))return null;let t=[];for(let n of e.types){if(Dt(n))continue;let e=Pi(n);if(e===null)return null;t.push(...e)}return t}function Fi(e){if(Re(e))return{type:`string`,literals:[]};if(xt(e))return{type:`number`,nullable:!1};if(Ye(e))return{type:`boolean`};let t=Pi(e);if(t!==null)return{type:`string`,literals:t};if(st(e)){let[t]=e.rest;if(t===void 0)return null;if(Re(t))return{type:`strings`,literals:[]};let n=Pi(t);return n===null?null:{type:`strings`,literals:n}}if(ge(e)){let t=e.types.filter(e=>!Dt(e)&&!Pe(e)),n=e.types.some(e=>Pe(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=Fi(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function Ii(e){let t=e.ast;if(!At(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=h(e.type),r=ji([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:Fi(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:ye(e.type),description:wt(e.type)}}),sections:Mi(u(t))}}function Li(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof ke)n=!0,t=t.unwrap();else if(t instanceof Te)r=!0,t=t.unwrap();else if(t instanceof me)t=t.unwrap();else if(t instanceof S)t=t.in;else return{node:t,optional:n,nullable:r}}function Ri(e){if(e instanceof A){let t=e.options.map(e=>Ri(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof Nt?e.options:e instanceof c?[...e.values]:null;if(t===null)return null;let n=t.map(e=>Ni(e));return n.every(et)?n.map(e=>e.value):null}function zi(e){let{node:t,nullable:n}=Li(e);if(t instanceof P)return{type:`string`,literals:[]};if(t instanceof w)return{type:`number`,nullable:n};if(t instanceof R)return{type:`boolean`};let r=Ri(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof E){let e=Li(t.element).node;if(e instanceof P)return{type:`strings`,literals:[]};let n=Ri(e);return n===null?null:{type:`strings`,literals:n}}return null}function Bi(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof ke||e instanceof Te||e instanceof me?e.unwrap():e instanceof S?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>Je.get(e))}function Vi(e){return Bi(e).reduce((e,t)=>({...e,...t}),{})}function Hi(e){return Object.entries(e.shape)}function Ui(e){let t=Li(e).node;if(!(t instanceof we))throw Error(`A schema form needs a z.object.`);return{fields:Hi(t).map(([e,t])=>{let n=ji(Bi(t)),r=n.kind===`file`?{type:`files`}:zi(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=Vi(t);return{name:e,valueType:r,optional:Li(t).optional,annotation:n,title:i.title,description:i.description}}),sections:Mi(Vi(e))}}function Wi(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??ki(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function Gi(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 Ki(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 qi(e){let t=e instanceof ht?Ui(e):Ii(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=Wi(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??ki(e.name),help:a,kind:n??Gi(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=Ki(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 Ji(e){let t=e instanceof ht?e:ft(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>Yi(e)):Yi(n)}}}}function Yi(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 Xi=`onServer`;function Zi(e){let t=e.querySelector(`[aria-invalid="true"]`),n=t?.matches(`input, select, textarea, button, [tabindex]`)?t:t?.querySelector(`input, select, textarea, button`);return n?.focus(),n!=null}function Qi(e){if(Zi(e))return()=>void 0;let t=new MutationObserver(()=>{Zi(e)&&t.disconnect()});return t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`aria-invalid`]}),()=>{t.disconnect()}}function $i(e){return e.state.meta.errorMap.onServer!==void 0}function ea(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[Xi]:void 0}}))}function ta(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[Xi]:n}}))}function na(e){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(null),[a,o]=(0,X.useState)(e.defaultValues),[s,c]=(0,X.useState)(null);yn(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,X.useMemo)(()=>qi(l),[l]),d=(0,X.useMemo)(()=>Ji(l),[l]),f=En({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),$i(e)&&ea(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await Ji(l)[`~standard`].validate(t);if(a.issues){n(a.issues[0]?.message??`Check the form and try again.`);return}let o;try{o=await e.onSubmit(a.value,t)??{kind:`saved`}}catch(t){console.error(`SchemaForm submit failed`,t),n(e.failure??`Couldn't save changes. Try again.`);return}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&&ta(e,t,n);return}let s=o.values??t;c(s),r.reset(s),i(o.message??`Saved`),e.onSaved?.(s)}});return{description:u,form:f,error:t,saved:r,discard:()=>{n(null),i(null),f.reset()},submit:()=>f.handleSubmit()}}function ra(e){return{dirty:Y(e.form.store,e=>!e.isDefaultValue),submitting:Y(e.form.store,e=>e.isSubmitting),canSubmit:Y(e.form.store,e=>e.canSubmit)}}function ia({model:e,submitLabel:t=`Save changes`,discardLabel:n,onCancel:r,cancelLabel:i,allowClean:a,layout:o,footer:s,children:c,disabled:l=!1,...u}){let{submitting:d}=ra(e),f=(0,X.useRef)(null),p=(0,X.useRef)(()=>void 0);return(0,X.useEffect)(()=>()=>{p.current()},[]),(0,Z.jsxs)(Tn,{...u,ref:f,layout:o,busy:d,noValidate:!0,onSubmit:t=>{t.preventDefault(),e.form.state.isSubmitting||e.submit().then(()=>{p.current();let t=f.current;t!==null&&!e.form.state.isValid&&(p.current=Qi(t))})},children:[c??(0,Z.jsx)(Ci,{model:e,disabled:l,layout:o}),s===void 0?(0,Z.jsx)(sa,{model:e,label:t,discardLabel:r===void 0?n:void 0,onCancel:r,cancelLabel:i,allowClean:a??r!==void 0,divider:r===void 0}):s]})}function aa({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=na({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,Z.jsx)(ia,{...a,model:o})}function oa(e){return`model`in e?(0,Z.jsx)(ia,{...e}):(0,Z.jsx)(aa,{...e})}function sa({model:e,label:t,discardLabel:n,onCancel:r,cancelLabel:i=`Cancel`,allowClean:a=!1,dirtyLabel:o=`Unsaved changes`,buttonProps:s,...c}){let{dirty:l,submitting:u}=ra(e),d=u?null:e.saved&&!l?(0,Z.jsx)(Wt,{tone:`success`,size:`compact`,label:e.saved}):l?(0,Z.jsx)(Wt,{tone:`neutral`,size:`compact`,label:o}):null;return(0,Z.jsxs)(mn,{...c,error:e.error,status:d,children:[r?(0,Z.jsx)(k,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,Z.jsx)(k,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,Z.jsx)(k,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var ca=Ce.check(at(/^(?!\.{1,2}$)[^/]+$/u,{message:`Enter a single file or folder name.`})),la={file:C({name:ca.annotate(Oi({label:`File name`}))}),folder:C({name:ca.annotate(Oi({label:`Folder name`}))})};function ua(e){return(0,Z.jsx)(da,{...e},e.creation?`${e.creation.kind}:${e.creation.directory}:${e.creation.name??``}`:`closed`)}function da({creation:e,rootPath:t,onCreate:n,onClose:r}){let i=na({schema:la[e?.kind??`file`],defaultValues:{name:e?.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}=ra(i);return(0,Z.jsx)(Ie,{open:e!==null,onOpenChange:e=>{!e&&!i.form.state.isSubmitting&&r()},children:(0,Z.jsxs)(_t,{children:[(0,Z.jsxs)(yt,{className:`mb-4`,children:[(0,Z.jsxs)(Ue,{children:[`New `,e?.kind===`folder`?`folder`:`file`]}),(0,Z.jsxs)(Ve,{children:[`Create in `,e?.directory??t,` on this Computer.`]})]}),(0,Z.jsx)(oa,{model:i,onSubmitCapture:()=>{i.form.state.isSubmitting||i.form.setFieldValue(`name`,e=>e)},footer:(0,Z.jsxs)(mn,{divider:!1,error:i.error,children:[(0,Z.jsx)(k,{variant:`ghost`,type:`button`,disabled:a,onClick:r,children:`Cancel`}),(0,Z.jsx)(k,{type:`submit`,disabled:a,loading:a,children:a?`Creating…`:`Create`})]})})]})})}var fa=`That name already exists in this directory.`;function pa({app:e,onOpenFile:t,activePath:n,rootPath:r=`/`,rootLabel:i=`Computer`,onSelectPath:a,creationRequest:o=null,onCreationRequestHandled:s,rowHeight:c=32}){let[l,u]=(0,X.useState)(null),d=Qn({app:e,rootPath:r,rootLabel:i,rowHeight:c,activePath:n,onOpenFile:t,onSelectPath:e=>{u(e),a?.(e)}}),[f,p]=(0,X.useState)(null),m=e.capabilities.has(rn);function h(e,t){p({kind:e,directory:ct(t,r)})}(0,X.useEffect)(()=>{if(!o)return;let e={kind:o.kind,directory:ct(l??`${r}/`,r)};o.name!==void 0&&(e.name=o.name),o.immediate===!0&&o.name!==void 0?g(e,o.name):p(e),s?.()},[o,s,r,l]);async function g(e,n){let r=await _(e,n);r===fa?t(Ze(n,e.directory)):r!==void 0&&p(e)}async function _(n,r){let i=Ze(r,n.directory);try{let a=0;for(;a!==null;){let t=a,i=await qt(e.capabilities,{path:n.directory,limit:256,offset:t});if(i.entries.some(e=>e.name===r))return fa;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(rn).mkdir({path:i}),d.model.getItem(`${i}/`)||d.model.batch([{type:`add`,path:`${i}/`}])):(await Qt(e.capabilities,{path:i,content:new Blob([])},{}),d.model.getItem(i)||d.model.batch([{type:`add`,path:i}]),t(i));return}catch(e){return e instanceof Error?de(e).message:`Couldn't create ${n.kind}. Check Computer write access.`}}let v={flex:`1`,"--trees-item-height":`${String(c)}px`,"--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`};return(0,Z.jsxs)(`aside`,{className:`inkcap-tree`,"aria-label":`File tree`,children:[(0,Z.jsxs)(`div`,{className:`inkcap-tree-toolbar`,children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(nn,{"aria-hidden":`true`}),` Explorer`]}),(0,Z.jsxs)(`span`,{className:`inkcap-tree-actions`,children:[(0,Z.jsx)(x,{icon:(0,Z.jsx)($t,{}),"aria-label":`New file`,title:`New file`,variant:`ghost`,size:`responsive`,disabled:!m,onClick:()=>{h(`file`,l??`${r}/`)}}),(0,Z.jsx)(x,{icon:(0,Z.jsx)(qn,{}),"aria-label":`New folder`,title:`New folder`,variant:`ghost`,size:`responsive`,disabled:!m,onClick:()=>{h(`folder`,l??`${r}/`)}}),(0,Z.jsx)(x,{icon:(0,Z.jsx)(Mn,{}),"aria-label":`Refresh files`,title:`Refresh files`,variant:`ghost`,size:`responsive`,disabled:d.busy,onClick:d.reloadRoot})]})]}),d.error&&(0,Z.jsx)(Yt,{message:d.error,onRetry:d.reloadRoot}),d.rootEmpty?(0,Z.jsx)(`p`,{className:`inkcap-tree-note`,children:`Empty folder`}):null,(0,Z.jsx)(jn,{model:d.model,style:v,renderContextMenu:(e,t)=>(0,Z.jsxs)(`div`,{className:`flex min-w-36 flex-col gap-xs p-xs`,role:`menu`,children:[(0,Z.jsxs)(k,{className:`w-full justify-start`,disabled:!m,role:`menuitem`,title:m?void 0:`Computer write access is not granted.`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1}),h(`file`,e.path)},children:[(0,Z.jsx)($t,{"aria-hidden":`true`}),` New file`]}),(0,Z.jsxs)(k,{className:`w-full justify-start`,disabled:!m,role:`menuitem`,title:m?void 0:`Computer write access is not granted.`,size:`sm`,variant:`ghost`,onClick:()=>{t.close({restoreFocus:!1}),h(`folder`,e.path)},children:[(0,Z.jsx)(qn,{"aria-hidden":`true`}),` New folder`]})]})}),(0,Z.jsx)(ua,{creation:f,rootPath:r,onCreate:_,onClose:()=>{p(null)}}),d.page.next!==null&&(0,Z.jsxs)(k,{disabled:d.busy,onClick:d.loadNext,children:[`More in `,d.page.path]})]})}export{pa as InkcapFileTree};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Kn as t,Nr as n,Oi as r,Wn as i,i as a,jr as o,ki as s,l as c,o as l,qn as u,s as d,u as f}from"./tree-path-BxrnSpRU.js";import{Pt as p,i as m,t as h}from"./folder-open-DGOuHJ0O.js";import{n as g,r as _,t as v}from"./useFileTree-B2AWKwuB.js";import{C as y,_ as b,a as x,b as S,c as C,d as w,f as T,g as E,h as D,l as O,m as k,n as A,p as j,t as M,u as N,v as P,y as F}from"./index-DRsgwabK.js";var I=t(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),L=t(`History`,[[`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`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),R=e(s(),1),z=256;async function B(e,t,n,r,i){r.throwIfAborted();let a=await n(e,t);if(!b.safeParse(a).success)return a;i(!0);try{let i=null,a=!1;for(let e=0;e<z&&!a;e++){r.throwIfAborted();let e=O.parse(await n(`rebuildCopies`,{cursor:i}));a=e.done,i=e.cursor}if(!a)throw new o(`Bonsai is still preparing this repository. Try again shortly.`,{code:`TIMEOUT`,retryable:!0});r.throwIfAborted();let s=await n(e,t);if(b.safeParse(s).success)throw Error(`The repository changed while loading. Refresh to retry.`);return s}finally{i(!1)}}function V({repository:e,branch:t,request:n,onSaved:r,onSaveState:i}){let a=new Map;async function s(r,i){i.throwIfAborted();let a=N.parse(await n(`files.read`,{repo:e,ref:t,path:r}));if(i.throwIfAborted(),a.binary)throw Error(`This Bonsai file is not a text document.`);if(a.text===null&&a.blob!==null)throw new o(`This Bonsai file is too large to edit.`,{code:`FILE_TOO_LARGE`,retryable:!1});return a}async function c(s,c){c.throwIfAborted();let l=E.parse(await n(`files.sync`,{}));c.throwIfAborted();let u=l.settled.find(n=>n.repo===e&&n.branch===t&&n.path===s);if(u){if(u.result.kind===`refused`)throw new o(`Bonsai refused sync: ${u.result.reason}`,{code:`CAPABILITY_DENIED`,retryable:u.result.reason===`background-unavailable`});let e=a.get(s);if(u.result.revision!==e?.version)throw new o(`Your saved file changed. Compare before syncing.`,{code:`CONFLICT`,retryable:!0});i(s,u.result)}r()}async function l(l,u,d,f){f.throwIfAborted();let p=a.get(l);if(d===void 0){let e=await s(l,f);p={file:e,contents:e.pending?.text??e.text??``,version:e.version}}if(!p)throw Error(`Reopen this Bonsai file before saving.`);if(d!==void 0&&p.contents!==d)throw new o(`The file baseline changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});if(d!==void 0){let e=await s(l,f);if(e.version!==p.version||(e.pending?.text??e.text??``)!==p.contents)throw new o(`The file changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});e.pending===void 0&&(p.file=e)}let m=k.parse({repo:e,branch:t,path:l,baseCommit:p.file.commit,baseBlob:p.file.blob,text:u,revision:p.version}),h=D.parse(await n(`files.save`,m));if(h.kind===`refused`)throw new o(`Bonsai refused this save: ${h.reason}`,{code:`CAPABILITY_DENIED`,retryable:h.reason===`background-unavailable`});if(i(l,h),h.kind===`conflict`)throw new o(`Your saved file changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});a.set(l,{file:p.file,contents:u,version:h.revision}),r(),h.kind===`saved`&&c(l,f).catch(e=>{console.error(`Bonsai sync status could not be refreshed`,e),!(a.get(l)?.version!==h.revision||f.aborted)&&i(l,{kind:`failed`,revision:h.revision,reason:`sync_failed`})})}return{kind:`repository`,id:`${e}:${t}`,label:`${e} · ${t}`,async read(e,t,n){let r=n?.revision,o=await s(e,t);if(n?.closed)return{kind:`closed`};if(n&&n.revision!==r)return{kind:`changed`};let c=o.pending?.text??o.text??``;a.set(e,{file:o,contents:c,version:o.version});let l=o.pending;return l?.state===`pending`?i(e,{kind:`saved`,revision:l.revision,state:`pending`}):l?.state===`conflict`?i(e,{kind:`conflict`,revision:l.revision,theirs:l.theirs}):l?.state===`failed`?i(e,{kind:`failed`,revision:l.revision,reason:l.failure??`sync_failed`}):o.version!==null&&i(e,{kind:`synced`,revision:o.version,commit:o.commit}),{kind:`text`,contents:c}},replace:(e,t,n,r)=>l(e,t,n,r),write:(e,t,n)=>l(e,t,void 0,n),retry:c,async discard(s,c){c.throwIfAborted();let l=a.get(s);if(!l)throw Error(`Reopen this saved file before discarding it.`);if(l.version===null)return;let u=w.parse({repo:e,branch:t,path:s,revision:l.version}),d=T.parse(await n(`files.discard`,u));if(c.throwIfAborted(),d.kind===`conflict`)throw new o(`Your saved file changed. Refresh before discarding.`,{code:`CONFLICT`,retryable:!0});a.delete(s),i(s,null),r()},async readCommitted(e,t){let n=await s(e,t),r=n.text??``;return a.has(e)||a.set(e,{file:n,contents:r,version:n.version}),r}}}async function H(e,t,n){let r={repo:t,ref:n},i=P.parse(await e(`files.tree`,{...r,path:``})),a=j.parse(await e(`files.list`,r)),o=C.parse(await e(`commits.list`,{...r,limit:20}));if(i.commit.hash!==a.commit.hash)throw Error(`The repository changed while loading. Refresh to retry.`);return{head:i.commit.hash,branch:n,files:a.paths.map(e=>({path:e})),history:o.commits.map(e=>e.commit),truncated:a.truncated}}var U=r();function W({files:e,rowHeight:t,dirtyPaths:n,activePath:r,busy:a,onRefresh:o,onOpenFile:s}){let c=(0,R.useRef)({files:e,onOpenFile:s});c.current={files:e,onOpenFile:s};let{model:l}=v({paths:[],initialExpansion:`open`,itemHeight:t,onSelectionChange(e){let t=e[0];t&&!t.endsWith(`/`)&&c.current.files.some(e=>e.path===t)&&c.current.onOpenFile(t)}}),u=(0,R.useMemo)(()=>{let t=new Set(n);return e.flatMap(e=>t.has(e.path)?[{path:e.path,status:`modified`}]:[])},[e,n]);(0,R.useEffect)(()=>{l.resetPaths(e.map(e=>e.path))},[l,e]),(0,R.useEffect)(()=>{l.setGitStatus(u)},[l,u]),(0,R.useEffect)(()=>{for(let e of l.getSelectedPaths())e!==r&&l.getItem(e)?.deselect();r&&l.getItem(r)?.select()},[l,r]);let d={flex:`1`,"--trees-item-height":`${String(t)}px`,"--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-border-radius-override":`var(--radius-field)`,"--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-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`12px`};return(0,U.jsxs)(`aside`,{className:`inkcap-tree`,"aria-label":`Repository files`,children:[(0,U.jsxs)(`div`,{className:`inkcap-tree-toolbar`,children:[(0,U.jsxs)(`span`,{children:[(0,U.jsx)(h,{"aria-hidden":`true`}),` Explorer`]}),(0,U.jsx)(i,{icon:(0,U.jsx)(_,{}),"aria-label":`Refresh repository`,variant:`ghost`,size:`responsive`,disabled:a,onClick:o})]}),(0,U.jsx)(`p`,{className:`inkcap-repository-legend`,children:`Changes in latest commit · drafts marked modified`}),(0,U.jsx)(g,{model:l,style:d})]})}var G={all:(e,t)=>[`inkcap-repository`,e,t],branch:(e,t,n)=>[...G.all(e,t),n]},K={branch_missing:`The repository branch no longer exists. Your text is saved; restore the branch before retrying.`,access_changed:`Repository access changed. Your text is saved; restore Bonsai's Git access before retrying.`,sync_failed:`Git could not publish this change. Your text is saved; retry sync.`,permanent_material:`The saved change no longer matches the repository state. Save again to publish your text from the current state.`};function q({connection:e,repository:t,initialBranch:r,initialPath:i,openRequestId:o,transport:s,onReady:h}){let g=p(),[_,v]=(0,R.useState)(!1),[b,C]=(0,R.useState)(0),[w,T]=(0,R.useState)(new Map),[E,D]=(0,R.useState)(``),O=(0,R.useRef)(new AbortController);(0,R.useEffect)(()=>{let e=new AbortController;return O.current=e,()=>{e.abort()}},[]);let k=(0,R.useCallback)((t,n)=>s?s(t,n):e.app.capabilities.require(S).call(`app_bonsai`,t,JSON.stringify(n)),[e.app,s]),j=(0,R.useCallback)((e,t)=>B(e,t,k,O.current.signal,e=>{C(t=>t+(e?1:-1))}),[k]),N=(0,R.useCallback)(()=>{g.invalidateQueries({queryKey:G.all(e.app.identity.surfaceId,t)})},[g,e.app,t]),P=(0,R.useRef)(new Map),z=(0,R.useMemo)(()=>{let n=`${e.app.identity.surfaceId}:${t}:${r}`,i=P.current.get(n);if(i?.app===e.app)return i;let a=V({repository:t,branch:r,request:j,onSaved:N,onSaveState:(e,n)=>{O.current.signal.aborted||T(i=>{let a=new Map(i),o=`${t}:${r}:${e}`;return n===null?a.delete(o):a.set(o,n),a})}}),o={app:e.app,source:a};return P.current.set(n,o),o},[t,r,j,N,e.app]),q=M({connection:z}),J=y({queryKey:G.branch(e.app.identity.surfaceId,t,r),queryFn:()=>H(j,t,r),refetchInterval:15e3});(0,R.useEffect)(()=>e.app.window.onBeforeClose(q.requestWindowClose),[e.app,q.requestWindowClose]),(0,R.useEffect)(()=>{h?.({requestWindowClose:q.requestWindowClose})},[h,q.requestWindowClose]);let Y=(0,R.useRef)(),X=(0,R.useRef)(new Map),Z=(0,R.useRef)(new Set);(0,R.useEffect)(()=>{if(!J.data)return;let e=`${z.app.identity.surfaceId}:${z.source.id}:${o}`;Y.current!==e&&(Y.current=e,q.onOpenFile(i));let t=X.current.get(z.source.id),n=t!==void 0&&t!==J.data.head;X.current.set(z.source.id,J.data.head);let r=new Set(q.tabs.map(e=>e.tabKey));for(let e of Z.current)r.has(e)||Z.current.delete(e);for(let e of q.tabs)if(!(e.target.closed||e.connection!==z||!n&&!Z.current.has(e.tabKey))){if(e.target.saving){Z.current.add(e.tabKey);continue}Z.current.delete(e.tabKey),e.target.dirty||q.onReopen(e,{background:!0})}},[J.data,z,i,o,q]);let Q=q.tabs.find(e=>e.tabKey===q.active),$=Q?.connection?.source?w.get(`${Q.connection.source.id}:${Q.path}`):void 0,ee=$?.kind===`saved`?`Saved · syncing`:$?.kind===`synced`?`Synced · ${$.commit.slice(0,7)}`:$?.kind===`conflict`?`Sync conflict · Compare`:$?.kind===`failed`?`Sync failed · Retry`:void 0;async function te(){if(!Q?.connection?.source)return;let e=P.current.get(`${Q.connection.app.identity.surfaceId}:${Q.connection.source.id}`);if(e)try{D(``),await e.source.retry(Q.path,O.current.signal)}catch(e){console.error(`Bonsai sync retry failed`,e),D(`${n(e).message} Your saved text remains in Bonsai.`)}}async function ne(){if(!Q?.connection?.source)return;let e=()=>!Q.target.dirty&&!Q.target.saving&&!Q.target.closed;if(!e())return;let t=P.current.get(`${Q.connection.app.identity.surfaceId}:${Q.connection.source.id}`);if(t)try{D(``);let n=await t.source.read(Q.path,O.current.signal);if(n.kind!==`text`)throw Error(`This saved text is unavailable.`);if(!e())return;await t.source.replace(Q.path,n.contents,n.contents,O.current.signal)}catch(e){console.error(`Bonsai explicit re-save failed`,e),D(`${n(e).message} Your saved text and open edits remain available.`)}}return(0,U.jsxs)(`div`,{className:`inkcap-repository`,children:[(0,U.jsxs)(`div`,{className:`inkcap-repository-toolbar`,children:[(0,U.jsxs)(`span`,{className:`inkcap-repository-name`,children:[(0,U.jsx)(I,{"aria-hidden":`true`}),` `,t,` · `,r]}),(0,U.jsxs)(u,{size:`sm`,variant:`outline`,onClick:()=>{v(!0)},children:[(0,U.jsx)(L,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),` `,`History`]})]}),b>0&&(0,U.jsx)(x,{message:`Loading this repository…`}),J.data?.truncated&&(0,U.jsx)(F,{tone:`info`,title:`Only the indexed files are shown`}),E&&(0,U.jsx)(m,{message:E,onDismiss:()=>{D(``)}}),$?.kind===`failed`&&!E&&(0,U.jsx)(F,{tone:`warning`,title:$.reason===`permanent_material`?`Sync needs a new save`:`Sync failed`,description:K[$.reason],action:(0,U.jsx)(u,{size:`sm`,disabled:$.reason===`permanent_material`&&Q!==void 0&&(Q.target.dirty||Q.target.saving),onClick:()=>void($.reason===`permanent_material`?ne():te()),children:$.reason===`permanent_material`?`Save again`:`Retry`})}),(0,U.jsx)(A,{model:{...q,repositoryStatus:ee,repositoryStates:w,canList:!0,sourceLabel:z.source.label,onReadCurrent:async(e,t)=>{if(e.connection?.source?.kind!==`repository`)return q.onReadCurrent(e);let n=P.current.get(`${e.connection.app.identity.surfaceId}:${e.connection.source.id}`);if(!n||e.target.closed)throw Error(`This Bonsai file is no longer open.`);return t&&await n.source.discard(e.path,O.current.signal),n.source.readCommitted(e.path,O.current.signal)},error:J.error?`${n(J.error).message} Your open edits remain available.`:q.error,fileTree:(e,t)=>(0,U.jsx)(W,{rowHeight:t?44:32,files:J.data?.files??[],dirtyPaths:q.tabs.filter(e=>e.connection===z&&e.dirty).map(e=>e.path),activePath:Q?.connection===z?Q.path:null,busy:J.isFetching,onRefresh:N,onOpenFile:e},t?`phone`:`desktop`)}}),(0,U.jsx)(a,{open:_,onOpenChange:v,children:(0,U.jsxs)(l,{children:[(0,U.jsxs)(c,{children:[(0,U.jsx)(f,{children:`Commit history`}),(0,U.jsxs)(d,{children:[t,` · `,r]})]}),(0,U.jsx)(`ol`,{className:`inkcap-repository-history`,children:J.data?.history.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`code`,{children:e.hash.slice(0,7)}),` `,e.message,(0,U.jsx)(`span`,{className:`text-dim`,children:e.author.name})]},e.hash))})]})})]})}export{q as InkcapRepositoryApp};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ai as t,Gn as n,Jn as r,Mr as i,Pr as a,a as o,c as s,d as c,ki as l,qn as u,s as d,u as f}from"./tree-path-DZCDmsgc.js";import{Pt as p,i as m,t as h}from"./folder-open-BIGH7eRS.js";import{n as g,r as _,t as v}from"./useFileTree-B2iPBKay.js";import{C as y,_ as b,a as x,b as S,c as C,d as w,f as T,g as E,h as D,l as O,m as k,n as A,p as j,t as M,u as N,v as P,y as F}from"./index-BKX-loA_.js";var I=u(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),L=u(`History`,[[`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`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),R=e(t(),1),z=256;async function B(e,t,n,r,a){r.throwIfAborted();let o=await n(e,t);if(!b.safeParse(o).success)return o;a(!0);try{let a=null,o=!1;for(let e=0;e<z&&!o;e++){r.throwIfAborted();let e=O.parse(await n(`rebuildCopies`,{cursor:a}));o=e.done,a=e.cursor}if(!o)throw new i(`Bonsai is still preparing this repository. Try again shortly.`,{code:`TIMEOUT`,retryable:!0});r.throwIfAborted();let s=await n(e,t);if(b.safeParse(s).success)throw Error(`The repository changed while loading. Refresh to retry.`);return s}finally{a(!1)}}function V({repository:e,branch:t,request:n,onSaved:r,onSaveState:a}){let o=new Map;async function s(r,a){a.throwIfAborted();let o=N.parse(await n(`files.read`,{repo:e,ref:t,path:r}));if(a.throwIfAborted(),o.binary)throw Error(`This Bonsai file is not a text document.`);if(o.text===null&&o.blob!==null)throw new i(`This Bonsai file is too large to edit.`,{code:`FILE_TOO_LARGE`,retryable:!1});return o}async function c(s,c){c.throwIfAborted();let l=E.parse(await n(`files.sync`,{}));c.throwIfAborted();let u=l.settled.find(n=>n.repo===e&&n.branch===t&&n.path===s);if(u){if(u.result.kind===`refused`)throw new i(`Bonsai refused sync: ${u.result.reason}`,{code:`CAPABILITY_DENIED`,retryable:u.result.reason===`background-unavailable`});let e=o.get(s);if(u.result.revision!==e?.version)throw new i(`Your saved file changed. Compare before syncing.`,{code:`CONFLICT`,retryable:!0});a(s,u.result)}r()}async function l(l,u,d,f){f.throwIfAborted();let p=o.get(l);if(d===void 0){let e=await s(l,f);p={file:e,contents:e.pending?.text??e.text??``,version:e.version}}if(!p)throw Error(`Reopen this Bonsai file before saving.`);if(d!==void 0&&p.contents!==d)throw new i(`The file baseline changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});if(d!==void 0){let e=await s(l,f);if(e.version!==p.version||(e.pending?.text??e.text??``)!==p.contents)throw new i(`The file changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});e.pending===void 0&&(p.file=e)}let m=k.parse({repo:e,branch:t,path:l,baseCommit:p.file.commit,baseBlob:p.file.blob,text:u,revision:p.version}),h=D.parse(await n(`files.save`,m));if(h.kind===`refused`)throw new i(`Bonsai refused this save: ${h.reason}`,{code:`CAPABILITY_DENIED`,retryable:h.reason===`background-unavailable`});if(a(l,h),h.kind===`conflict`)throw new i(`Your saved file changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});o.set(l,{file:p.file,contents:u,version:h.revision}),r(),h.kind===`saved`&&c(l,f).catch(e=>{console.error(`Bonsai sync status could not be refreshed`,e),!(o.get(l)?.version!==h.revision||f.aborted)&&a(l,{kind:`failed`,revision:h.revision,reason:`sync_failed`})})}return{kind:`repository`,id:`${e}:${t}`,label:`${e} · ${t}`,async read(e,t,n){let r=n?.revision,i=await s(e,t);if(n?.closed)return{kind:`closed`};if(n&&n.revision!==r)return{kind:`changed`};let c=i.pending?.text??i.text??``;o.set(e,{file:i,contents:c,version:i.version});let l=i.pending;return l?.state===`pending`?a(e,{kind:`saved`,revision:l.revision,state:`pending`}):l?.state===`conflict`?a(e,{kind:`conflict`,revision:l.revision,theirs:l.theirs}):l?.state===`failed`?a(e,{kind:`failed`,revision:l.revision,reason:l.failure??`sync_failed`}):i.version!==null&&a(e,{kind:`synced`,revision:i.version,commit:i.commit}),{kind:`text`,contents:c}},replace:(e,t,n,r)=>l(e,t,n,r),write:(e,t,n)=>l(e,t,void 0,n),retry:c,async discard(s,c){c.throwIfAborted();let l=o.get(s);if(!l)throw Error(`Reopen this saved file before discarding it.`);if(l.version===null)return;let u=w.parse({repo:e,branch:t,path:s,revision:l.version}),d=T.parse(await n(`files.discard`,u));if(c.throwIfAborted(),d.kind===`conflict`)throw new i(`Your saved file changed. Refresh before discarding.`,{code:`CONFLICT`,retryable:!0});o.delete(s),a(s,null),r()},async readCommitted(e,t){let n=await s(e,t),r=n.text??``;return o.has(e)||o.set(e,{file:n,contents:r,version:n.version}),r}}}async function H(e,t,n){let r={repo:t,ref:n},i=P.parse(await e(`files.tree`,{...r,path:``})),a=j.parse(await e(`files.list`,r)),o=C.parse(await e(`commits.list`,{...r,limit:20}));if(i.commit.hash!==a.commit.hash)throw Error(`The repository changed while loading. Refresh to retry.`);return{head:i.commit.hash,branch:n,files:a.paths.map(e=>({path:e})),history:o.commits.map(e=>e.commit),truncated:a.truncated}}var U=l();function W({files:e,rowHeight:t,dirtyPaths:r,activePath:i,busy:a,onRefresh:o,onOpenFile:s}){let c=(0,R.useRef)({files:e,onOpenFile:s});c.current={files:e,onOpenFile:s};let{model:l}=v({paths:[],initialExpansion:`open`,itemHeight:t,onSelectionChange(e){let t=e[0];t&&!t.endsWith(`/`)&&c.current.files.some(e=>e.path===t)&&c.current.onOpenFile(t)}}),u=(0,R.useMemo)(()=>{let t=new Set(r);return e.flatMap(e=>t.has(e.path)?[{path:e.path,status:`modified`}]:[])},[e,r]);(0,R.useEffect)(()=>{l.resetPaths(e.map(e=>e.path))},[l,e]),(0,R.useEffect)(()=>{l.setGitStatus(u)},[l,u]),(0,R.useEffect)(()=>{for(let e of l.getSelectedPaths())e!==i&&l.getItem(e)?.deselect();i&&l.getItem(i)?.select()},[l,i]);let d={flex:`1`,"--trees-item-height":`${String(t)}px`,"--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-border-radius-override":`var(--radius-field)`,"--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-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`12px`};return(0,U.jsxs)(`aside`,{className:`inkcap-tree`,"aria-label":`Repository files`,children:[(0,U.jsxs)(`div`,{className:`inkcap-tree-toolbar`,children:[(0,U.jsxs)(`span`,{children:[(0,U.jsx)(h,{"aria-hidden":`true`}),` Explorer`]}),(0,U.jsx)(n,{icon:(0,U.jsx)(_,{}),"aria-label":`Refresh repository`,variant:`ghost`,size:`responsive`,disabled:a,onClick:o})]}),(0,U.jsx)(`p`,{className:`inkcap-repository-legend`,children:`Changes in latest commit · drafts marked modified`}),(0,U.jsx)(g,{model:l,style:d})]})}var G={all:(e,t)=>[`inkcap-repository`,e,t],branch:(e,t,n)=>[...G.all(e,t),n]},K={branch_missing:`The repository branch no longer exists. Your text is saved; restore the branch before retrying.`,access_changed:`Repository access changed. Your text is saved; restore Bonsai's Git access before retrying.`,sync_failed:`Git could not publish this change. Your text is saved; retry sync.`,permanent_material:`The saved change no longer matches the repository state. Save again to publish your text from the current state.`};function q({connection:e,repository:t,initialBranch:n,initialPath:i,openRequestId:l,transport:u,onReady:h}){let g=p(),[_,v]=(0,R.useState)(!1),[b,C]=(0,R.useState)(0),[w,T]=(0,R.useState)(new Map),[E,D]=(0,R.useState)(``),O=(0,R.useRef)(new AbortController);(0,R.useEffect)(()=>{let e=new AbortController;return O.current=e,()=>{e.abort()}},[]);let k=(0,R.useCallback)((t,n)=>u?u(t,n):e.app.capabilities.require(S).call(`app_bonsai`,t,JSON.stringify(n)),[e.app,u]),j=(0,R.useCallback)((e,t)=>B(e,t,k,O.current.signal,e=>{C(t=>t+(e?1:-1))}),[k]),N=(0,R.useCallback)(()=>{g.invalidateQueries({queryKey:G.all(e.app.identity.surfaceId,t)})},[g,e.app,t]),P=(0,R.useRef)(new Map),z=(0,R.useMemo)(()=>{let r=`${e.app.identity.surfaceId}:${t}:${n}`,i=P.current.get(r);if(i?.app===e.app)return i;let a=V({repository:t,branch:n,request:j,onSaved:N,onSaveState:(e,r)=>{O.current.signal.aborted||T(i=>{let a=new Map(i),o=`${t}:${n}:${e}`;return r===null?a.delete(o):a.set(o,r),a})}}),o={app:e.app,source:a};return P.current.set(r,o),o},[t,n,j,N,e.app]),q=M({connection:z}),J=y({queryKey:G.branch(e.app.identity.surfaceId,t,n),queryFn:()=>H(j,t,n),refetchInterval:15e3});(0,R.useEffect)(()=>e.app.window.onBeforeClose(q.requestWindowClose),[e.app,q.requestWindowClose]),(0,R.useEffect)(()=>{h?.({requestWindowClose:q.requestWindowClose})},[h,q.requestWindowClose]);let Y=(0,R.useRef)(),X=(0,R.useRef)(new Map),Z=(0,R.useRef)(new Set);(0,R.useEffect)(()=>{if(!J.data)return;let e=`${z.app.identity.surfaceId}:${z.source.id}:${l}`;Y.current!==e&&(Y.current=e,q.onOpenFile(i));let t=X.current.get(z.source.id),n=t!==void 0&&t!==J.data.head;X.current.set(z.source.id,J.data.head);let r=new Set(q.tabs.map(e=>e.tabKey));for(let e of Z.current)r.has(e)||Z.current.delete(e);for(let e of q.tabs)if(!(e.target.closed||e.connection!==z||!n&&!Z.current.has(e.tabKey))){if(e.target.saving){Z.current.add(e.tabKey);continue}Z.current.delete(e.tabKey),e.target.dirty||q.onReopen(e,{background:!0})}},[J.data,z,i,l,q]);let Q=q.tabs.find(e=>e.tabKey===q.active),$=Q?.connection?.source?w.get(`${Q.connection.source.id}:${Q.path}`):void 0,ee=$?.kind===`saved`?`Saved · syncing`:$?.kind===`synced`?`Synced · ${$.commit.slice(0,7)}`:$?.kind===`conflict`?`Sync conflict · Compare`:$?.kind===`failed`?`Sync failed · Retry`:void 0;async function te(){if(!Q?.connection?.source)return;let e=P.current.get(`${Q.connection.app.identity.surfaceId}:${Q.connection.source.id}`);if(e)try{D(``),await e.source.retry(Q.path,O.current.signal)}catch(e){console.error(`Bonsai sync retry failed`,e),D(`${a(e).message} Your saved text remains in Bonsai.`)}}async function ne(){if(!Q?.connection?.source)return;let e=()=>!Q.target.dirty&&!Q.target.saving&&!Q.target.closed;if(!e())return;let t=P.current.get(`${Q.connection.app.identity.surfaceId}:${Q.connection.source.id}`);if(t)try{D(``);let n=await t.source.read(Q.path,O.current.signal);if(n.kind!==`text`)throw Error(`This saved text is unavailable.`);if(!e())return;await t.source.replace(Q.path,n.contents,n.contents,O.current.signal)}catch(e){console.error(`Bonsai explicit re-save failed`,e),D(`${a(e).message} Your saved text and open edits remain available.`)}}return(0,U.jsxs)(`div`,{className:`inkcap-repository`,children:[(0,U.jsxs)(`div`,{className:`inkcap-repository-toolbar`,children:[(0,U.jsxs)(`span`,{className:`inkcap-repository-name`,children:[(0,U.jsx)(I,{"aria-hidden":`true`}),` `,t,` · `,n]}),(0,U.jsxs)(r,{size:`sm`,variant:`outline`,onClick:()=>{v(!0)},children:[(0,U.jsx)(L,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),` `,`History`]})]}),b>0&&(0,U.jsx)(x,{message:`Loading this repository…`}),J.data?.truncated&&(0,U.jsx)(F,{tone:`info`,title:`Only the indexed files are shown`}),E&&(0,U.jsx)(m,{message:E,onDismiss:()=>{D(``)}}),$?.kind===`failed`&&!E&&(0,U.jsx)(F,{tone:`warning`,title:$.reason===`permanent_material`?`Sync needs a new save`:`Sync failed`,description:K[$.reason],action:(0,U.jsx)(r,{size:`sm`,disabled:$.reason===`permanent_material`&&Q!==void 0&&(Q.target.dirty||Q.target.saving),onClick:()=>void($.reason===`permanent_material`?ne():te()),children:$.reason===`permanent_material`?`Save again`:`Retry`})}),(0,U.jsx)(A,{model:{...q,repositoryStatus:ee,repositoryStates:w,canList:!0,sourceLabel:z.source.label,onReadCurrent:async(e,t)=>{if(e.connection?.source?.kind!==`repository`)return q.onReadCurrent(e);let n=P.current.get(`${e.connection.app.identity.surfaceId}:${e.connection.source.id}`);if(!n||e.target.closed)throw Error(`This Bonsai file is no longer open.`);return t&&await n.source.discard(e.path,O.current.signal),n.source.readCommitted(e.path,O.current.signal)},error:J.error?`${a(J.error).message} Your open edits remain available.`:q.error,fileTree:(e,t)=>(0,U.jsx)(W,{rowHeight:t?44:32,files:J.data?.files??[],dirtyPaths:q.tabs.filter(e=>e.connection===z&&e.dirty).map(e=>e.path),activePath:Q?.connection===z?Q.path:null,busy:J.isFetching,onRefresh:N,onOpenFile:e},t?`phone`:`desktop`)}}),(0,U.jsx)(o,{open:_,onOpenChange:v,children:(0,U.jsxs)(d,{children:[(0,U.jsxs)(f,{children:[(0,U.jsx)(c,{children:`Commit history`}),(0,U.jsxs)(s,{children:[t,` · `,n]})]}),(0,U.jsx)(`ol`,{className:`inkcap-repository-history`,children:J.data?.history.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`code`,{children:e.hash.slice(0,7)}),` `,e.message,(0,U.jsx)(`span`,{className:`text-dim`,children:e.author.name})]},e.hash))})]})})]})}export{q as InkcapRepositoryApp};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$i as t,$n as n,$r as r,Ai as i,Ba as a,Da as o,Dr as s,Er as c,Fa as l,Fi as u,Fr as d,Ga as f,Gi as p,Hi as m,Ia as h,Ii as g,Jn as _,Ki as v,La as ee,Li as te,Mi as y,Mr as b,Nr as ne,Oa as re,Or as ie,Pi as x,Qi as ae,Qr as oe,Ra as se,Ri as ce,Sr as le,Tr as ue,Ua as de,Vi as fe,Wi as pe,Xn as me,Xr as he,Yi as S,Zi as ge,Zn as _e,Zr as ve,_r as ye,aa as be,ai as C,ar as xe,ca as Se,ci as Ce,cr as we,da as w,di as T,dr as Te,ea as Ee,ei as De,er as Oe,fa as E,fi as ke,fr as Ae,gr as je,hr as Me,ia as Ne,ii as D,ir as Pe,ji as O,ki as Fe,kr as Ie,la as Le,li as Re,lr as ze,mi as Be,mr as Ve,ni as He,nr as Ue,oa as We,oi as Ge,or as Ke,pi as k,pr as qe,qi as A,qn as Je,ra as Ye,ri as Xe,rr as Ze,sa as j,si as M,sr as N,ta as Qe,tr as $e,ua as et,ur as tt,vr as nt,wr as rt,yr as it,za as at,zi as P}from"./tree-path-DZCDmsgc.js";var ot=new WeakMap,st=`~effect/Redacted`,ct=e=>a(e,st),lt=(e,t)=>{let n=Object.create(ut);return t?.label&&(n.label=t.label),ot.set(n,e),n},ut={[st]:{_A:e=>e},label:void 0,...l,toJSON(){return this.toString()},toString(){return`<redacted${de(this.label)?`:`+this.label:``}>`},[at](){return se(ot.get(this))},[ee](e){return ct(e)&&h(ot.get(this),ot.get(e))}},F=e(i(),1),I=Fe(),dt=F.createContext(void 0),ft=e=>{let t=F.useContext(dt);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},pt=({client:e,children:t})=>(F.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,I.jsx)(dt.Provider,{value:e,children:t})),mt={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},ht=new class{#e=mt;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function gt(e){setTimeout(e,0)}var _t=typeof window>`u`||`Deno`in globalThis;function L(){}function vt(e,t){return typeof e==`function`?e(t):e}function yt(e){return typeof e==`number`&&e>=0&&e!==1/0}function bt(e,t){return Math.max(e+(t||0)-Date.now(),0)}function R(e,t){return typeof e==`function`?e(t):e}function xt(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Ct(o,t.options))return!1}else if(!Tt(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function St(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(wt(t.options.mutationKey)!==wt(a))return!1}else if(!Tt(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Ct(e,t){return(t?.queryKeyHashFn||wt)(e)}function wt(e){return JSON.stringify(e,(e,t)=>At(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Tt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!Tt(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Tt(e[r],t[r]))return!1;return!0}return!1}var Et=Object.prototype.hasOwnProperty;function Dt(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=kt(e)&&kt(t);if(!r&&!(At(e)&&At(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:Et.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Dt(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Ot(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function kt(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function At(e){if(!jt(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!jt(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function jt(e){return Object.prototype.toString.call(e)===`[object Object]`}function Mt(e){return new Promise(t=>{ht.setTimeout(t,e)})}function Nt(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Dt(e,t)}function Pt(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Ft(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var It=Symbol();function Lt(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===It?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Rt(e,t){return typeof e==`function`?e(...t):!!e}function zt(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Bt=()=>_t,Vt=()=>Bt(),Ht=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ut=new class extends Ht{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Wt=gt;function Gt(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Wt,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var z=Gt(),Kt=new class extends Ht{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function qt(e){return Math.min(1e3*2**e,3e4)}function Jt(e){return(e??`online`)!==`online`||Kt.isOnline()}var Yt=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Xt(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(L);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new Yt(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>Ut.isFocused()&&(e.networkMode===`always`||Kt.isOnline())&&e.canRun(),p=()=>Jt(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(m).catch(r=>{if(c())return;let i=e.retry??(Vt()?0:3),a=e.retryDelay??qt,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),Mt(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var Zt=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),yt(this.gcTime)&&(this.#e=ht.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Vt()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(ht.clearTimeout(this.#e),this.#e=void 0)}};function Qt(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{zt(e,()=>t.signal,()=>n=!0)},u=Lt(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?Ft:Pt;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?en:$t,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:$t(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function $t(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function en(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var tn=class extends Zt{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=an(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=an(this.options);e.data!==void 0&&(this.setState(rn(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Nt(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(L).catch(L):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>R(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===It||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>R(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!bt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Lt(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Qt(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=Xt({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Yt&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Yt){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...nn(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...rn(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),z.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function nn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Jt(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function rn(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function an(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var on=class extends Ht{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),cn(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ln(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ln(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof R(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Ot(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&un(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||R(this.options.enabled,this.#t)!==R(t.enabled,this.#t)||R(this.options.staleTime,this.#t)!==R(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||R(this.options.enabled,this.#t)!==R(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Ot(this.getCurrentResult(),n)||(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(L)),t}#h(e){return!Vt()&&R(this.options.enabled,this.#t)!==!1&&yt(e)}#g(){this.#b();let e=R(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=bt(this.#r.dataUpdatedAt,e)+1;this.#u=ht.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#f=e,!(this.#f===0||!this.#h(this.#f))&&(this.#d=ht.setInterval(()=>{(this.options.refetchIntervalInBackground||Ut.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(ht.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(ht.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&cn(e,t),o=i&&un(e,n,t,r);(a||o)&&(l={...l,...nn(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=Nt(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=Nt(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,ee=_&&g,te=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:ee,isLoading:ee,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!te,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&te,isStale:dn(e,t),refetch:this.refetch,isEnabled:R(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),Ot(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})();z.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}};function sn(e,t){return R(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||R(t.retryOnMount,e)!==!1)}function cn(e,t){return sn(e,t)||e.state.data!==void 0&&ln(e,t,t.refetchOnMount)}function ln(e,t,n){if(R(t.enabled,e)!==!1&&R(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&dn(e,t)}return!1}function un(e,t,n,r){return(e!==t||R(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&dn(e,n)}function dn(e,t){return R(t.enabled,e)!==!1&&e.isStaleByTime(R(t.staleTime,e))}var fn=class extends Zt{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||pn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=Xt({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),z.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function pn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var mn=class extends Ht{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new fn({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=hn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=hn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=hn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=hn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){z.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>St(t,e))}findAll(e={}){return this.getAll().filter(t=>St(e,t))}notify(e){z.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return z.batch(()=>Promise.all(e.map(e=>e.continue().catch(L))))}};function hn(e){return e.options.scope?.id}var gn=class extends Ht{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??Ct(r,t),a=this.get(i);return a||(a=new tn({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){z.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>xt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>xt(e,t)):t}notify(e){z.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){z.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){z.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},_n=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new gn,this.#t=e.mutationCache||new mn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Ut.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Kt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(R(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=vt(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return z.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;z.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return z.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=z.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(L).catch(L)}invalidateQueries(e,t={}){return z.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=z.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(L)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(L)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(R(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(R(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(L).catch(L)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(L).catch(L)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Kt.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(wt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Tt(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(wt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Tt(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Ct(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===It&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},vn=F.createContext(!1),yn=()=>F.useContext(vn);vn.Provider;function bn(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xn=F.createContext(bn()),Sn=()=>F.useContext(xn),Cn=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Rt(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},wn=e=>{F.useEffect(()=>{e.clearReset()},[e])},Tn=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Rt(n,[e.error,r])),En=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Dn=(e,t)=>e?.suspense&&t.isPending,On=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function kn(e){return e}var An=Xe(),jn=D(()=>He(`status`,[M({status:C(`available`)}).strict(),M({status:C(`unavailable`),reason:T()}).strict()])),Mn=An,Nn=D(()=>Re(T(),Mn)),Pn=e=>Mn.parse(e),Fn=D(()=>M({code:T().min(1).max(160),message:T().min(1).max(512),details:Mn.optional()}).strict()),In=e=>Fn.parse(e),Ln=Nn,B=D(()=>T().refine(e=>e.trim().length>0)),Rn=jn,zn=D(()=>ke([M({type:C(`action`)}).strict(),M({type:C(`custom`),data:Nn}).strict(),M({type:C(`choice`),options:r(M({value:Mn,label:B,description:B.optional()}))}).strict(),M({type:C(`form`),submitLabel:B.optional()}).strict(),M({type:C(`confirmation`),message:B,confirmLabel:B.optional(),cancelLabel:B.optional()}).strict()])),Bn=D(()=>M({inputSchema:Ln.optional(),outputSchema:Ln.optional(),presentation:zn.optional()}).strict()),Vn=D(()=>Ge().int().refine(e=>Number.isSafeInteger(e))),Hn=D(()=>M({hint:B.pipe(T().max(120)),words:r(M({word:T().regex(/^\S{1,64}$/u),description:B.pipe(T().max(512)).optional(),arguments:Nn}).strict()).max(32).optional(),text:M({field:B.pipe(T().max(120)),arguments:Nn,requestIdField:B.pipe(T().max(120)).optional()}).strict().optional()}).strict().refine(e=>e.words!==void 0||e.text!==void 0,`slash arguments need words or text`)),Un=D(()=>M({order:Vn.optional()}).strict()),Wn=D(()=>M({bindings:M({order:Vn.optional(),values:r(B).max(16)}).strict().optional(),agent:M({keybind:B.optional(),order:Vn.optional()}).strict().optional(),help:Un.optional(),menu:Un.optional(),palette:Un.optional(),slash:M({aliases:r(B).max(16),consumesDraft:De().optional(),order:Vn.optional(),arguments:Hn.optional()}).strict().optional()}).strict()),Gn=D(()=>M({id:B.refine(e=>!e.includes(`:`)),title:B,category:B,description:B.optional(),projections:Wn.optional(),action:Bn.optional(),availability:Rn.optional()}).strict()),Kn=e=>Gn.parse(e),qn=D(()=>M({inputSchema:Ln.optional(),outputSchema:Ln.optional()}).strict()),Jn=T().min(1).brand(),Yn=D(()=>M({commandId:Jn,command:M({namespace:T(),id:T()}).strict(),sourceId:T(),scope:T().optional(),title:T(),category:T(),description:T().optional(),order:Ge(),availability:jn,action:qn.optional(),keybind:T().optional()}).strict());r(Yn);var Xn=8192,V=B.pipe(T().max(Xn)),Zn=B.pipe(T().max(60)),Qn=Be({protocol:/^https?$/u}),$n=M({label:V,value:V}).strict(),er={summary:V.optional(),facts:r($n).max(4).optional(),body:V.optional(),bodyLabel:V.optional(),details:r($n).max(24).optional()};He(`type`,[M({type:C(`choice`),message:Zn,...er,current:V.optional(),collapsedGroup:V.optional(),options:r(M({value:V,label:V,description:V.optional(),group:V.optional(),destructive:C(!0).optional()}).strict()).min(1).max(256)}).strict(),M({type:C(`text`),message:Zn,...er,placeholder:V.optional(),secret:De().optional()}).strict(),M({type:C(`confirmation`),message:Zn,...er,confirmLabel:V.optional(),cancelLabel:V.optional(),destructive:C(!0).optional()}).strict(),M({type:C(`decision`),message:Zn,...er,options:r(M({value:V,label:V,description:V.optional(),destructive:C(!0).optional()}).strict()).min(1).max(8).refine(e=>new Set(e.map(e=>e.value)).size===e.length,`Decision option values must be unique`),multiple:De().optional(),other:M({label:V,placeholder:V.optional(),maxLength:Ge().int().min(1).max(Xn),blank:V.optional()}).strict().optional(),escape:V.optional()}).strict().refine(e=>[e.escape,e.other?.blank].every(t=>t===void 0||e.options.some(e=>e.value===t)),`A decision's escape and blank answers must be offered options`)]),D(()=>He(`type`,[M({type:C(`info`),message:V,links:r(M({url:Qn,label:V.optional()}).strict()).max(16).optional()}).strict(),M({type:C(`progress`),message:V}).strict(),M({type:C(`handoff`),url:Qn,code:V.optional(),message:V.optional()}).strict(),M({type:C(`success`),message:V}).strict()]));var tr=class extends Error{code;details;constructor(e,t,n){super(t),this.code=e,this.details=n,this.name=`WhistleActionError`}},nr=class extends Error{constructor(){super(`Whistle runtime is closed`),this.name=`WhistleClosedError`}};function rr(){let e=!1,t=Pr,n=[],r=[],i=!1,a=[],o=new Set,s=()=>{for(let e of o)e()};return Object.freeze({close:()=>{e||(e=!0,n=[],a=[],r=[],t=Pr,s(),o.clear())},contribute:t=>{if(fr(t),e)throw new nr;pr(t,n),mr(t,n);let r=Symbol(`whistle-contribution`);dr(t)||(n=[...n,{contribution:hr(t),generation:r}],i=!0,s());let a=!0;return Nr(o=>{if(!a||e)return;let c={...t,commands:o};fr(c);let l=n.findIndex(e=>e.generation===r),u=n.filter(e=>e.generation!==r);pr(c,u),mr(c,u);let d=hr(c);if(dr(c)){if(l<0)return;n=u}else n=l<0?[...n,{contribution:d,generation:r}]:n.map(e=>e.generation===r?{contribution:d,generation:r}:e);i=!0,s()},()=>{a&&(a=!1,n.find(e=>e.generation===r)!==void 0&&(n=n.filter(e=>e.generation!==r),i=!0,s()))})},execute:async(t,r)=>{if(t.namespace.trim().length===0||t.id.trim().length===0)return{status:`invalid`};if(e)return{status:`closed`};let i=ur(t,n);if(i===void 0)return{status:`missing`};let o;try{let e=Ir(i);if(e.status===`unavailable`)return e;let n=a.at(-1)?.presenter;r.interaction===void 0&&n!==void 0&&ir.has(r.origin)&&(o=n({commandId:lr(t.namespace,t.id),title:i.title}));let s={...r,signal:r.signal??new AbortController().signal};o!==void 0&&(s.interaction=o.interaction,s.signal=AbortSignal.any([s.signal,o.interaction.signal]));let c=await i.handler(s);return o?.settle({status:`handled`}),c===void 0?{status:`handled`}:{status:`handled`,result:c}}catch(e){let t=Rr(e instanceof Error?e:Error(`Command handler threw a non-Error value`));return o?.settle(o.interaction.signal.aborted?{status:`cancelled`}:{status:`failed`,message:t.message}),{status:`failed`,error:t}}},present:t=>{let n={presenter:t};return e||(a=[...a,n]),()=>{a=a.filter(e=>e!==n)}},snapshot:()=>{if(e)return Pr;let a=n.flatMap(e=>e.contribution.commands.map(Ir));return(i||a.some((e,t)=>!Lr(e,r[t])))&&(t=zr(n,a),r=a,i=!1),t},subscribe:t=>e?()=>void 0:(o.add(t),()=>{o.delete(t)})})}var ir=new Set([`browser`,`keyboard`,`menu`,`palette`,`slash`,`terminal`]),ar=16,or=32,sr=64,cr=256;function lr(e,t){return Jn.parse(`${e}:${t}`)}function ur(e,t){for(let n of t)if(n.contribution.namespace===e.namespace){for(let t of n.contribution.commands)if(t.id===e.id)return t}}function dr(e){return e.commands.length===0}function fr(e){H(e.sourceId,`source ID`),H(e.namespace,`namespace`),e.scope!==void 0&&H(e.scope,`scope`);for(let t of e.commands)Dr(t)}function pr(e,t){t.find(t=>t.contribution.namespace===e.namespace&&t.contribution.sourceId!==e.sourceId)!==void 0&&U(`Namespace is already owned by another source`);let n=new Set,r=new Set;for(let i of t){let t=i.contribution.scope===e.scope;for(let e of i.contribution.commands)if(n.add(lr(i.contribution.namespace,e.id)),t)for(let t of e.projections?.slash?.aliases??[])r.add(t)}for(let t of e.commands){let i=lr(e.namespace,t.id);n.has(i)&&U(`Canonical command ID is already registered`),n.add(i);for(let e of t.projections?.slash?.aliases??[])r.has(e)&&U(`Slash alias is already registered`),r.add(e)}}function mr(e,t){t.length>=sr&&U(`Live contribution capacity exceeded`),t.reduce((e,t)=>e+t.contribution.commands.length,0)+e.commands.length>cr&&U(`Live command capacity exceeded`)}function hr(e){let t={sourceId:e.sourceId,namespace:e.namespace,commands:e.commands.map(gr)};return e.scope===void 0?t:{...t,scope:e.scope}}function gr(e){let t={id:e.id,title:e.title,category:e.category,handler:e.handler};return e.description!==void 0&&(t.description=e.description),e.action!==void 0&&(t.action=_r(e.action)),e.availability!==void 0&&(t.availability=e.availability),e.projections!==void 0&&(t.projections=xr(e.projections)),t}function _r(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=vr(e.inputSchema)),e.outputSchema!==void 0&&(t.outputSchema=vr(e.outputSchema)),e.presentation!==void 0&&(t.presentation=br(e.presentation)),Object.freeze(t)}function vr(e){return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,yr(t)])))}function yr(e){return Array.isArray(e)?Object.freeze(e.map(yr)):e!==null&&e instanceof Object?Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,yr(t)]))):e}function br(e){switch(e.type){case`action`:return Object.freeze({type:`action`});case`custom`:return Object.freeze({type:`custom`,data:vr(e.data)});case`choice`:return Object.freeze({type:`choice`,options:Object.freeze(e.options.map(e=>Object.freeze({...e,value:yr(e.value)})))});case`form`:return Object.freeze({...e});case`confirmation`:return Object.freeze({...e})}}function xr(e){let t={};return e.bindings!==void 0&&(t.bindings=Sr(e.bindings)),e.agent!==void 0&&(t.agent=Cr(e.agent)),e.help!==void 0&&(t.help=wr(e.help.order)),e.menu!==void 0&&(t.menu=wr(e.menu.order)),e.palette!==void 0&&(t.palette=wr(e.palette.order)),e.slash!==void 0&&(t.slash=Tr(e.slash)),t}function Sr(e){let t={values:[...e.values]};return e.order!==void 0&&(t.order=e.order),t}function Cr(e){let t={};return e.keybind!==void 0&&(t.keybind=e.keybind),e.order!==void 0&&(t.order=e.order),t}function wr(e){let t={};return e!==void 0&&(t.order=e),t}function Tr(e){let t={aliases:[...e.aliases]};return e.order!==void 0&&(t.order=e.order),e.consumesDraft!==void 0&&(t.consumesDraft=e.consumesDraft),e.arguments!==void 0&&(t.arguments=Er(e.arguments)),t}function Er(e){let t={hint:e.hint};return e.words!==void 0&&(t.words=Object.freeze(e.words.map(e=>Object.freeze({...e,arguments:vr(e.arguments)})))),e.text!==void 0&&(t.text=Object.freeze({...e.text,arguments:vr(e.text.arguments)})),Object.freeze(t)}function Dr(e){H(e.id,`command ID`,!0),H(e.title,`title`),H(e.category,`category`),Or(e.action),kr(e.projections)}function Or(e){if(e?.presentation!==void 0)switch(e.presentation.type){case`action`:case`custom`:return;case`choice`:for(let t of e.presentation.options)H(t.label,`choice label`),t.description!==void 0&&H(t.description,`choice description`);return;case`form`:e.presentation.submitLabel!==void 0&&H(e.presentation.submitLabel,`submit label`);return;case`confirmation`:H(e.presentation.message,`confirmation message`),e.presentation.confirmLabel!==void 0&&H(e.presentation.confirmLabel,`confirmation label`),e.presentation.cancelLabel!==void 0&&H(e.presentation.cancelLabel,`cancellation label`)}}function kr(e){if(e!==void 0){for(let t of[e.bindings,e.palette,e.slash,e.help,e.menu,e.agent])t!==void 0&&Mr(t.order);if(e.bindings!==void 0&&jr(e.bindings.values,`binding`),e.slash!==void 0){jr(e.slash.aliases,`slash alias`);for(let t of e.slash.aliases)/\s/u.test(t)&&U(`slash alias must not contain whitespace`);Ar(e.slash.arguments)}e.agent?.keybind!==void 0&&H(e.agent.keybind,`agent keybind`)}}function Ar(e){if(e===void 0)return;H(e.hint,`argument hint`),e.words===void 0&&e.text===void 0&&U(`slash arguments need words or text`);let t=new Set;for(let n of e.words??[])H(n.word,`argument word`),/\s/u.test(n.word)&&U(`argument word must not contain whitespace`),t.has(n.word)&&U(`argument word is repeated`),t.add(n.word),n.description!==void 0&&H(n.description,`argument word description`);t.size>or&&U(`argument word count exceeds 32`),e.text!==void 0&&(H(e.text.field,`argument text field`),e.text.requestIdField!==void 0&&H(e.text.requestIdField,`request id field`))}function jr(e,t){e.length>ar&&U(`${t} count exceeds 16`);for(let n of e)H(n,t)}function H(e,t,n=!1){e.trim().length===0&&U(`${t} must not be blank`),n&&e.includes(`:`)&&U(`${t} must not contain a colon`)}function Mr(e){e!==void 0&&!Number.isSafeInteger(e)&&U(`order must be a safe integer`)}function Nr(e=()=>void 0,t=()=>void 0){return Object.freeze({update:e,dispose:t})}function U(e){throw Error(e)}var Pr=Object.freeze({bindings:Object.freeze([]),palette:Object.freeze([]),slash:Object.freeze([]),help:Object.freeze([]),menu:Object.freeze([]),agent:Object.freeze([])}),Fr=Object.freeze({status:`available`});function Ir(e){let t=e.availability?.()??Fr;return t.status===`available`?Fr:Object.freeze({status:`unavailable`,reason:t.reason})}function Lr(e,t){return e.status===`available`?t?.status===`available`:t?.status===`unavailable`&&e.reason===t.reason}function Rr(e){if(e instanceof tr){let t={code:e.code,message:e.message};return Object.freeze(e.details===void 0?t:{...t,details:yr(e.details)})}return Object.freeze({code:`command_failed`,message:e.message})}function zr(e,t){let n=[],r=[],i=[],a=[],o=[],s=[],c=0;for(let l of e){let e=l.contribution;for(let l of e.commands){let u=l.projections,d=t[c++]??Fr;if(u?.bindings!==void 0)for(let t of u.bindings.values)n.push({...Kr(e,l,u.bindings.order,d),binding:t});if(u?.palette!==void 0&&r.push({...Kr(e,l,u.palette.order,d)}),u?.slash!==void 0)for(let t of u.slash.aliases){let n={...Kr(e,l,u.slash.order,d),alias:t};u.slash.consumesDraft!==void 0&&(n={...n,consumesDraft:u.slash.consumesDraft}),u.slash.arguments!==void 0&&(n={...n,arguments:u.slash.arguments}),i.push(n)}u?.help!==void 0&&a.push({...Kr(e,l,u.help.order,d)}),u?.menu!==void 0&&o.push({...Kr(e,l,u.menu.order,d)}),u?.agent!==void 0&&s.push(Jr(e,l,u.agent,d))}}return Ur(n),Wr(i),Hr(r),Hr(a),Hr(o),Hr(s),Object.freeze({bindings:Gr(n),palette:Gr(r),slash:Gr(i),help:Gr(a),menu:Gr(o),agent:Gr(s)})}var Br=new TextEncoder;function Vr(e,t){let n=Br.encode(e),r=Br.encode(t),i=Math.min(n.length,r.length);for(let e=0;e<i;e+=1){let t=n[e]??0,i=r[e]??0;if(t!==i)return t<i?-1:1}return n.length<r.length?-1:+(n.length>r.length)}function Hr(e){e.sort((e,t)=>e.order-t.order||Vr(e.commandId,t.commandId))}function Ur(e){e.sort((e,t)=>e.order-t.order||Vr(e.commandId,t.commandId)||Vr(e.binding,t.binding))}function Wr(e){e.sort((e,t)=>e.order-t.order||Vr(e.commandId,t.commandId)||Vr(e.alias,t.alias))}function Gr(e){return Object.freeze(e.map(e=>Object.freeze(e)))}function Kr(e,t,n,r){let i=qr(e,t,n,r);return e.scope===void 0?i:{...i,scope:e.scope}}function qr(e,t,n,r){let i={commandId:lr(e.namespace,t.id),command:Object.freeze({namespace:e.namespace,id:t.id}),sourceId:e.sourceId,title:t.title,category:t.category,order:n??0,availability:r},a=t.description===void 0?i:{...i,description:t.description};return t.action===void 0?a:{...a,action:t.action}}function Jr(e,t,n,r){let i=Kr(e,t,n.order,r),a=i.action===void 0?i:{...i,action:Yr(i.action)};return n.keybind===void 0?a:{...a,keybind:n.keybind}}function Yr(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=e.inputSchema),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),Object.freeze(t)}var Xr=new WeakMap;function Zr(e,t){let n=!1,r=[];for(let i of t){let{availability:t,handler:a,...o}=i,s=a,c=t===void 0?o:{...o,availability:t()},l=Xr.get(e)??new Map;Xr.set(e,l);let u=l.get(i.id),d=()=>e.register(c,async({arguments:e,origin:t,signal:n})=>{let r=await s(e===void 0?{origin:t,signal:n}:{arguments:e,origin:t,signal:n});return r===void 0?void 0:Pn(r)}),f=(u?u.then(d):d()).then(e=>{n?e():r.push(e)},e=>{console.warn(`App command ${i.id} was not registered`,e)});l.set(i.id,f),f.finally(()=>{l.get(i.id)===f&&l.delete(i.id)})}return()=>{if(!n){n=!0;for(let e of r.splice(0))e()}}}function Qr(e,t){console.error(JSON.stringify({source:`agar`,operation:e,failureKind:t instanceof Error?`Error`:`NonErrorThrown`}),lt(t))}var $r=Symbol(`workers-module`);Symbol.dispose||(Symbol.dispose=Symbol.for(`dispose`)),Symbol.asyncDispose||(Symbol.asyncDispose=Symbol.for(`asyncDispose`)),Promise.withResolvers||(Promise.withResolvers=function(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}});var ei=globalThis[$r],ti=ei?ei.RpcTarget:class{},ni=async function(){}.constructor,ri=typeof Buffer<`u`?Buffer.prototype:void 0;function ii(e){switch(typeof e){case`boolean`:case`number`:case`string`:return`primitive`;case`undefined`:return`undefined`;case`object`:case`function`:break;case`bigint`:return`bigint`;default:return`unsupported`}if(e===null)return`primitive`;let t=Object.getPrototypeOf(e);switch(t){case Object.prototype:return`object`;case Function.prototype:case ni.prototype:return`function`;case Array.prototype:return`array`;case Date.prototype:return`date`;case Uint8Array.prototype:case ri:case ArrayBuffer.prototype:case DataView.prototype:case Int8Array.prototype:case Uint8ClampedArray.prototype:case Int16Array.prototype:case Uint16Array.prototype:case Int32Array.prototype:case Uint32Array.prototype:case BigInt64Array.prototype:case BigUint64Array.prototype:case Float32Array.prototype:case Float64Array.prototype:return`bytes`;case WritableStream.prototype:return`writable`;case ReadableStream.prototype:return`readable`;case URL.prototype:return`url`;case Headers.prototype:return`headers`;case Request.prototype:return`request`;case Response.prototype:return`response`;case Blob.prototype:return`blob`;case mi.prototype:return`stub`;case K.prototype:return`rpc-promise`;default:if(ei){if(t==ei.RpcStub.prototype||e instanceof ei.ServiceStub)return`rpc-target`;if(t==ei.RpcPromise.prototype||t==ei.RpcProperty.prototype)return`rpc-thenable`}return e instanceof ti?`rpc-target`:e instanceof Error?`error`:`unsupported`}}function ai(){throw Error(`RPC map() implementation was not loaded.`)}var oi={applyMap:ai,sendMap:ai};function si(){throw Error(`Stream implementation was not loaded.`)}var W={createWritableStreamHook:si,createWritableStreamFromHook:si,createReadableStreamHook:si},ci=class{stream(e,t){let n=this.call(e,t),r;try{r=n.pull()}catch(e){throw n.dispose(),e}let i;return r instanceof Promise?i=r.then(e=>{e.dispose()}):(r.dispose(),i=Promise.resolve()),{promise:i}}},G=class extends ci{error;constructor(e){super(),this.error=e}call(e,t){return t.dispose(),this}map(e,t,n){for(let e of t)e.dispose();return this}get(e){return this}dup(){return this}pull(){return Promise.reject(this.error)}ignoreUnhandledRejections(){}dispose(){}onBroken(e){try{e(this.error)}catch(e){Promise.resolve(e)}}},li=new G(Error(`Attempted to use RPC stub after it has been disposed.`)),ui=(e,t,n)=>e.call(t,n);function di(e,t){let n=ui;ui=e;try{return t()}finally{ui=n}}var fi=Symbol(`realStub`),pi={apply(e,t,n){let r=e.raw;return new K(ui(r.hook,r.pathIfPromise||[],q.fromAppParams(n)),[])},get(e,t,n){let r=e.raw;if(t===fi)return r;if(t in K.prototype)return r[t];if(typeof t==`string`)return new K(r.hook,r.pathIfPromise?[...r.pathIfPromise,t]:[t]);if(t===Symbol.dispose&&(!r.pathIfPromise||r.pathIfPromise.length==0))return()=>{r.hook.dispose(),r.hook=li}},has(e,t){let n=e.raw;return t===fi?!0:t in K.prototype?t in n:typeof t==`string`||t===Symbol.dispose&&(!n.pathIfPromise||n.pathIfPromise.length==0)},construct(e,t){throw Error(`An RPC stub cannot be used as a constructor.`)},defineProperty(e,t,n){throw Error(`Can't define properties on RPC stubs.`)},deleteProperty(e,t){throw Error(`Can't delete properties on RPC stubs.`)},getOwnPropertyDescriptor(e,t){},getPrototypeOf(e){return Object.getPrototypeOf(e.raw)},isExtensible(e){return!1},ownKeys(e){return[]},preventExtensions(e){return!0},set(e,t,n,r){throw Error(`Can't assign properties on RPC stubs.`)},setPrototypeOf(e,t){throw Error(`Can't override prototype of RPC stubs.`)}},mi=class e extends ti{constructor(e,t){if(super(),!(e instanceof ci)){let n=e;if(e=n instanceof ti||n instanceof Function?Ti.create(n,void 0):new Ci(q.fromAppReturn(n)),t)throw TypeError(`RpcStub constructor expected one argument, received two.`)}this.hook=e,this.pathIfPromise=t;let n=()=>{};return n.raw=this,new Proxy(n,pi)}hook;pathIfPromise;dup(){let t=this[fi];return t.pathIfPromise?new e(t.hook.get(t.pathIfPromise)):new e(t.hook.dup())}onRpcBroken(e){this[fi].hook.onBroken(e)}map(e){let{hook:t,pathIfPromise:n}=this[fi];return oi.sendMap(t,n||[],e)}toString(){return`[object RpcStub]`}},K=class extends mi{constructor(e,t){if(e instanceof ci)super(e,t??[]);else{if(t!==void 0)throw TypeError(`RpcPromise constructor expected one argument, received two.`);let n=ii(e);if(n===`rpc-promise`){let t=yi(e);if(t.pathIfPromise.length>0)super(t.hook,t.pathIfPromise);else{let e=t.hook;t.hook=li,super(e,[])}}else if(n===`rpc-thenable`)super(Ti.create(e,void 0),[]);else{let t=new Ei(Promise.resolve(e).then(e=>new Ci(q.fromAppReturn(e))));t.ignoreUnhandledRejections(),super(t,[])}}}then(e,t){return bi(this).then(...arguments)}catch(e){return bi(this).catch(...arguments)}finally(e){return bi(this).finally(...arguments)}toString(){return`[object RpcPromise]`}};function hi(e){let{hook:t,pathIfPromise:n}=e[fi];return n&&n.length>0?t.get(n):t}function gi(e){let{hook:t,pathIfPromise:n}=e[fi];return n?t.get(n):t.dup()}function _i(e){let{hook:t,pathIfPromise:n}=e[fi];if(!(n&&n.length>0))return t}function vi(e){return e[fi].hook}function yi(e){return e[fi]}async function bi(e){let{hook:t,pathIfPromise:n}=e[fi];return n.length>0&&(t=t.get(n)),(await t.pull()).deliverResolve()}var q=class e{value;source;hooks;promises;static fromAppParams(t){return new e(t,`params`)}static fromAppReturn(t){return new e(t,`return`)}static fromArray(t){let n=[],r=[],i=[];for(let e of t){e.ensureDeepCopied();for(let t of e.hooks)n.push(t);for(let t of e.promises)t.parent===e&&(t={parent:i,property:i.length,promise:t.promise}),r.push(t);i.push(e.value)}return new e(i,`owned`,n,r)}static forEvaluate(t,n){return new e(null,`owned`,t,n)}static deepCopyFrom(t,n,r){let i=new e(null,`owned`,[],[]);return i.value=i.deepCopy(t,n,`value`,i,!0,r),i}constructor(e,t,n,r){this.value=e,this.source=t,this.hooks=n,this.promises=r}rpcTargets;getHookForRpcTarget(e,t,n=!0){if(this.source===`params`){if(n){let t=e;typeof t.dup==`function`&&(e=t.dup())}return Ti.create(e,t)}if(this.source===`return`){let r=this.rpcTargets?.get(e);return r?n?r.dup():(this.rpcTargets?.delete(e),r):(r=Ti.create(e,t),n?(this.rpcTargets||=new Map,this.rpcTargets.set(e,r),r.dup()):r)}throw Error(`owned payload shouldn't contain raw RpcTargets`)}getHookForWritableStream(e,t,n=!0){if(this.source===`params`)return W.createWritableStreamHook(e);if(this.source===`return`){let t=this.rpcTargets?.get(e);return t?n?t.dup():(this.rpcTargets?.delete(e),t):(t=W.createWritableStreamHook(e),n?(this.rpcTargets||=new Map,this.rpcTargets.set(e,t),t.dup()):t)}throw Error(`owned payload shouldn't contain raw WritableStreams`)}getHookForReadableStream(e,t,n=!0){if(this.source===`params`)return W.createReadableStreamHook(e);if(this.source===`return`){let t=this.rpcTargets?.get(e);return t?n?t.dup():(this.rpcTargets?.delete(e),t):(t=W.createReadableStreamHook(e),n?(this.rpcTargets||=new Map,this.rpcTargets.set(e,t),t.dup()):t)}throw Error(`owned payload shouldn't contain raw ReadableStreams`)}deepCopy(e,t,n,r,i,a){switch(ii(e)){case`unsupported`:return e;case`primitive`:case`bigint`:case`date`:case`bytes`:case`blob`:case`url`:case`error`:case`undefined`:return e;case`array`:{let t=e,n=t.length,r=Array(n);for(let e=0;e<n;e++)r[e]=this.deepCopy(t[e],t,e,r,i,a);return r}case`object`:{let t={},n=e;for(let e in n)t[e]=this.deepCopy(n[e],n,e,t,i,a);return t}case`stub`:case`rpc-promise`:{let t=e,a;if(a=i?gi(t):hi(t),t instanceof K){let e=new K(a,[]);return this.promises.push({parent:r,property:n,promise:e}),e}return this.hooks.push(a),new mi(a)}case`function`:case`rpc-target`:{let n=e,r;return r=a?a.getHookForRpcTarget(n,t,i):Ti.create(n,t),this.hooks.push(r),new mi(r)}case`rpc-thenable`:{let o=e,s;return s=a?new K(a.getHookForRpcTarget(o,t,i),[]):new K(Ti.create(o,t),[]),this.promises.push({parent:r,property:n,promise:s}),s}case`writable`:{let n=e,r;return r=a?a.getHookForWritableStream(n,t,i):W.createWritableStreamHook(n),this.hooks.push(r),n}case`readable`:{let n=e,r;return r=a?a.getHookForReadableStream(n,t,i):W.createReadableStreamHook(n),this.hooks.push(r),n}case`headers`:return new Headers(e);case`request`:{let t=e;return t.body&&this.deepCopy(t.body,t,`body`,t,i,a),new Request(t)}case`response`:{let t=e;return t.body&&this.deepCopy(t.body,t,`body`,t,i,a),new Response(t.body,t)}default:throw Error(`unreachable`)}}ensureDeepCopied(){if(this.source!==`owned`){let e=this.source===`params`;this.hooks=[],this.promises=[];try{this.value=this.deepCopy(this.value,void 0,`value`,this,e,this)}catch(e){throw this.hooks=void 0,this.promises=void 0,e}if(this.source=`owned`,this.rpcTargets&&this.rpcTargets.size>0)throw Error(`Not all rpcTargets were accounted for in deep-copy?`);this.rpcTargets=void 0}}deliverTo(t,n,r){if(this.ensureDeepCopied(),this.value instanceof K)e.deliverRpcPromiseTo(this.value,t,n,r);else{t[n]=this.value;for(let t of this.promises)e.deliverRpcPromiseTo(t.promise,t.parent,t.property,r)}}static deliverRpcPromiseTo(t,n,r,i){let a=_i(t);if(!a)throw Error(`property promises should have been resolved earlier`);let o=a.pull();o instanceof e?o.deliverTo(n,r,i):i.push(o.then(e=>{let t=[];if(e.deliverTo(n,r,t),t.length>0)return Promise.all(t)}))}async deliverCall(t,n){try{let r=[];this.deliverTo(this,`value`,r),r.length>0&&await Promise.all(r);let i=Function.prototype.apply.call(t,n,this.value);return i instanceof K?e.fromAppReturn(i):e.fromAppReturn(await i)}finally{this.dispose()}}async deliverStreamWrite(t){try{let n=[];this.deliverTo(this,`value`,n),n.length>0&&await Promise.all(n);let r=this.value[0];return(this.hooks.length>0||this.promises.length>0)&&r instanceof Object?(Symbol.dispose in r||Object.defineProperty(r,Symbol.dispose,{value:()=>this.dispose(),writable:!0,enumerable:!1,configurable:!0}),await t.write(r),e.fromAppReturn(void 0)):(await t.write(r),this.dispose(),e.fromAppReturn(void 0))}catch(e){throw this.dispose(),e}}async deliverResolve(){try{let e=[];this.deliverTo(this,`value`,e),e.length>0&&await Promise.all(e);let t=this.value;return t instanceof Object&&(Symbol.dispose in t||Object.defineProperty(t,Symbol.dispose,{value:()=>this.dispose(),writable:!0,enumerable:!1,configurable:!0})),t}catch(e){throw this.dispose(),e}}dispose(){if(this.source===`owned`)this.hooks.forEach(e=>e.dispose()),this.promises.forEach(e=>e.promise[Symbol.dispose]());else if(this.source===`return`&&(this.disposeImpl(this.value,void 0),this.rpcTargets&&this.rpcTargets.size>0))throw Error(`Not all rpcTargets were accounted for in disposeImpl()?`);this.source=`owned`,this.hooks=[],this.promises=[]}disposeImpl(e,t){switch(ii(e)){case`unsupported`:case`primitive`:case`bigint`:case`bytes`:case`blob`:case`date`:case`url`:case`error`:case`undefined`:return;case`array`:{let t=e,n=t.length;for(let e=0;e<n;e++)this.disposeImpl(t[e],t);return}case`object`:{let t=e;for(let e in t)this.disposeImpl(t[e],t);return}case`stub`:case`rpc-promise`:{let t=_i(e);t&&t.dispose();return}case`function`:case`rpc-target`:{let t=e,n=this.rpcTargets?.get(t);n?(n.dispose(),this.rpcTargets.delete(t)):wi(t);return}case`rpc-thenable`:return;case`headers`:return;case`request`:{let t=e;t.body&&this.disposeImpl(t.body,t);return}case`response`:{let t=e;t.body&&this.disposeImpl(t.body,t);return}case`writable`:{let t=e,n=this.rpcTargets?.get(t);n?this.rpcTargets.delete(t):n=W.createWritableStreamHook(t),n.dispose();return}case`readable`:{let t=e,n=this.rpcTargets?.get(t);n?this.rpcTargets.delete(t):n=W.createReadableStreamHook(t),n.dispose();return}default:return}}ignoreUnhandledRejections(){this.hooks?(this.hooks.forEach(e=>{e.ignoreUnhandledRejections()}),this.promises.forEach(e=>vi(e.promise).ignoreUnhandledRejections())):this.ignoreUnhandledRejectionsImpl(this.value)}ignoreUnhandledRejectionsImpl(e){switch(ii(e)){case`unsupported`:case`primitive`:case`bigint`:case`bytes`:case`blob`:case`date`:case`error`:case`undefined`:case`function`:case`rpc-target`:case`writable`:case`readable`:case`url`:case`headers`:case`request`:case`response`:return;case`array`:{let t=e,n=t.length;for(let e=0;e<n;e++)this.ignoreUnhandledRejectionsImpl(t[e]);return}case`object`:{let t=e;for(let e in t)this.ignoreUnhandledRejectionsImpl(t[e]);return}case`stub`:case`rpc-promise`:vi(e).ignoreUnhandledRejections();return;case`rpc-thenable`:e.then(e=>{},e=>{});return;default:return}}};function xi(e,t,n,r){for(let i=0;i<n.length;i++){t=e;let a=n[i];if(a in Object.prototype){e=void 0;continue}switch(ii(e)){case`object`:case`function`:e=Object.hasOwn(e,a)?e[a]:void 0;break;case`array`:e=Number.isInteger(a)&&a>=0?e[a]:void 0;break;case`rpc-target`:case`rpc-thenable`:if(Object.hasOwn(e,a))throw TypeError(`Attempted to access property '${a}', which is an instance property of the RpcTarget. To avoid leaking private internals, instance properties cannot be accessed over RPC. If you want to make this property available over RPC, define it as a method or getter on the class, instead of an instance property.`);e=e[a],r=null;break;case`stub`:case`rpc-promise`:{let{hook:t,pathIfPromise:r}=yi(e);return{hook:t,remainingPath:r?r.concat(n.slice(i)):n.slice(i)}}case`writable`:e=void 0;break;case`readable`:e=void 0;break;case`primitive`:case`bigint`:case`bytes`:case`blob`:case`date`:case`error`:case`url`:case`headers`:case`request`:case`response`:e=void 0;break;case`undefined`:e=e[a];break;case`unsupported`:if(i===0)throw TypeError(`RPC stub points at a non-serializable type.`);{let e=n.slice(0,i).join(`.`),t=n.slice(0,i).join(`.`);throw TypeError(`'${e}' is not a serializable type, so property ${t} cannot be accessed.`)}default:throw TypeError(`unreachable`)}}if(e instanceof K){let{hook:t,pathIfPromise:n}=yi(e);return{hook:t,remainingPath:n||[]}}return{value:e,parent:t,owner:r}}var Si=class extends ci{call(e,t){let n;try{let{value:t,owner:r}=this.getValue();n=xi(t,void 0,e,r)}catch(e){return t.dispose(),new G(e)}return n.hook?n.hook.call(n.remainingPath,t):typeof n.value==`function`?new Ei(t.deliverCall(n.value,n.parent).then(e=>new Ci(e))):(t.dispose(),new G(TypeError(`'${e.join(`.`)}' is not a function.`)))}map(e,t,n){try{let r;try{let{value:t,owner:n}=this.getValue();r=xi(t,void 0,e,n)}catch(e){for(let e of t)e.dispose();throw e}return r.hook?r.hook.map(r.remainingPath,t,n):oi.applyMap(r.value,r.parent,r.owner,t,n)}catch(e){return new G(e)}}get(e){try{let{value:t,owner:n}=this.getValue();if(e.length===0&&n===null){if(t instanceof Object&&`then`in t)return this.dup();throw Error(`Can't dup an RpcTarget stub as a promise.`)}let r=xi(t,void 0,e,n);return r.hook?r.hook.get(r.remainingPath):new Ci(q.deepCopyFrom(r.value,r.parent,r.owner))}catch(e){return new G(e)}}},Ci=class e extends Si{constructor(e){super(),this.payload=e}payload;getPayload(){if(this.payload)return this.payload;throw Error(`Attempted to use an RPC StubHook after it was disposed.`)}getValue(){let e=this.getPayload();return{value:e.value,owner:e}}dup(){let t=this.getPayload();return new e(q.deepCopyFrom(t.value,void 0,t))}pull(){return this.getPayload()}ignoreUnhandledRejections(){this.payload&&this.payload.ignoreUnhandledRejections()}dispose(){this.payload&&=(this.payload.dispose(),void 0)}onBroken(e){this.payload&&this.payload.value instanceof mi&&this.payload.value.onRpcBroken(e)}};function wi(e){if(Symbol.dispose in e)try{e[Symbol.dispose]()}catch(e){Promise.reject(e)}}var Ti=class e extends Si{static create(t,n){return typeof t!=`function`&&(n=void 0),new e(t,n)}constructor(e,t,n){super(),this.target=e,this.parent=t,n?n.refcount&&(this.refcount=n.refcount,++this.refcount.count):Symbol.dispose in e&&(this.refcount={count:1})}target;parent;refcount;getTarget(){if(this.target)return this.target;throw Error(`Attempted to use an RPC StubHook after it was disposed.`)}getValue(){return{value:this.getTarget(),owner:null}}dup(){return new e(this.getTarget(),this.parent,this)}pull(){let e=this.getTarget();return`then`in e?Promise.resolve(e).then(e=>q.fromAppReturn(e)):Promise.reject(Error(`Tried to resolve a non-promise stub.`))}ignoreUnhandledRejections(){}dispose(){this.target&&=(this.refcount&&--this.refcount.count==0&&wi(this.target),void 0)}onBroken(e){let t=this.target;t&&`then`in t&&Promise.resolve(t).then(()=>{},e)}},Ei=class e extends ci{promise;resolution;constructor(e){super(),this.promise=e.then(e=>(this.resolution=e,e))}call(t,n){return n.ensureDeepCopied(),new e(this.promise.then(e=>e.call(t,n),e=>{throw n.dispose(),e}))}stream(e,t){return t.ensureDeepCopied(),{promise:this.promise.then(n=>n.stream(e,t).promise,e=>{throw t.dispose(),e})}}map(t,n,r){return new e(this.promise.then(e=>e.map(t,n,r),e=>{for(let e of n)e.dispose();throw e}))}get(t){return new e(this.promise.then(e=>e.get(t)))}dup(){return this.resolution?this.resolution.dup():new e(this.promise.then(e=>e.dup()))}pull(){return this.resolution?this.resolution.pull():this.promise.then(e=>e.pull())}ignoreUnhandledRejections(){this.resolution?this.resolution.ignoreUnhandledRejections():this.promise.then(e=>{e.ignoreUnhandledRejections()},e=>{})}dispose(){this.promise.then(e=>e.dispose(),()=>{})}onBroken(e){this.resolution?this.resolution.onBroken(e):this.promise.then(t=>{t.onBroken(e)},e)}},Di={maxBigIntDigits:16384,maxDepth:256,maxMessageSize:33554432},Oi=new Uint8Array(new Uint16Array([1]).buffer)[0]===1,ki=[`ArrayBuffer`,`DataView`,`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`BigInt64Array`,`BigUint64Array`,`Float32Array`,`Float64Array`];function Ai(e){return ki.includes(e)}var ji={ArrayBuffer:void 0,DataView:void 0,Int8Array:void 0,Uint8Array:void 0,Uint8ClampedArray:void 0,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,BigInt64Array:8,BigUint64Array:8,Float32Array:4,Float64Array:8},Mi={ArrayBuffer:ArrayBuffer.prototype,DataView:DataView.prototype,Int8Array:Int8Array.prototype,Uint8ClampedArray:Uint8ClampedArray.prototype,Int16Array:Int16Array.prototype,Uint16Array:Uint16Array.prototype,Int32Array:Int32Array.prototype,Uint32Array:Uint32Array.prototype,BigInt64Array:BigInt64Array.prototype,BigUint64Array:BigUint64Array.prototype,Float32Array:Float32Array.prototype,Float64Array:Float64Array.prototype},Ni=new Map;for(let e of Object.keys(Mi))Ni.set(Mi[e],e);function Pi(e,t){if(t!==2&&t!==4&&t!==8)throw RangeError(`Unsupported element size: ${t}`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let r=0;r<e.byteLength;r+=t)switch(t){case 2:n.setUint16(r,n.getUint16(r,!1),!0);break;case 4:n.setUint32(r,n.getUint32(r,!1),!0);break;case 8:n.setBigUint64(r,n.getBigUint64(r,!1),!0)}}var Fi=new class{exportStub(e){throw Error(`Cannot serialize RPC stubs without an RPC session.`)}exportPromise(e){throw Error(`Cannot serialize RPC stubs without an RPC session.`)}getImport(e){}unexport(e){}createPipe(e){throw Error(`Cannot create pipes without an RPC session.`)}onSendError(e){}};async function Ii(e,t){let n=await new Response(e).blob();return n.type===t?n:n.slice(0,n.size,t)}var Li={__proto__:null,Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError},Ri=class e{exporter;source;encodingLevel;constructor(e,t,n){this.exporter=e,this.source=t,this.encodingLevel=n}static devaluate(t,n,r=Fi,i,a=`string`){let o=new e(r,i,a);try{return o.devaluateImpl(t,n,0)}catch(e){if(o.exports)try{r.unexport(o.exports)}catch{}throw e}}exports;devaluateImpl(e,t,n){if(n>=256)throw Error(`Serialization exceeded maximum allowed depth. (Does the message contain cycles?)`);switch(ii(e)){case`unsupported`:{let t;try{t=`Cannot serialize value: ${e}`}catch{t=`Cannot serialize value: (couldn't stringify value)`}throw TypeError(t)}case`primitive`:return typeof e==`number`&&!isFinite(e)?this.encodingLevel===`structuredClonable`?e:e===1/0?[`inf`]:e===-1/0?[`-inf`]:[`nan`]:e;case`object`:{let t=e,r={};for(let e in t)r[e]=this.devaluateImpl(t[e],t,n+1);return r}case`array`:{let t=e,r=t.length,i=Array(r);for(let e=0;e<r;e++)i[e]=this.devaluateImpl(t[e],t,n+1);return[i]}case`bigint`:return this.encodingLevel===`structuredClonable`?e:[`bigint`,e.toString()];case`date`:{if(this.encodingLevel===`structuredClonable`)return e;let t=e.getTime();return[`date`,Number.isNaN(t)?null:t]}case`bytes`:{let t=Ni.get(Object.getPrototypeOf(e)),n;if(t===`ArrayBuffer`)n=new Uint8Array(e);else if(t===void 0)n=e;else{let r=e;n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);let i=ji[t];!Oi&&i&&(n=n.slice(),Pi(n,i))}if(this.encodingLevel===`structuredClonable`||this.encodingLevel===`jsonCompatibleWithBytes`)return t===void 0?[`bytes`,n]:[`bytes`,n,t];let r;if(n.toBase64)r=n.toBase64({omitPadding:!0});else if(typeof Buffer<`u`)r=(n instanceof Buffer?n:Buffer.from(n.buffer,n.byteOffset,n.byteLength)).toString(`base64`);else{let e=``;for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);r=btoa(e)}return r=r.replace(/=+$/,``),t===void 0?[`bytes`,r]:[`bytes`,r,t]}case`url`:return[`url`,e.href];case`headers`:return[`headers`,[...e]];case`request`:{let t=e,r={};t.method!==`GET`&&(r.method=t.method);let i=[...t.headers];if(i.length>0&&(r.headers=i),t.body)r.body=this.devaluateImpl(t.body,t,n+1),r.duplex=t.duplex||`half`;else if(t.body===void 0&&![`GET`,`HEAD`,`OPTIONS`,`TRACE`,`DELETE`].includes(t.method)){let e=t.arrayBuffer(),n=new ReadableStream({async start(t){try{t.enqueue(new Uint8Array(await e)),t.close()}catch(e){t.error(e)}}}),i=W.createReadableStreamHook(n);r.body=[`readable`,this.exporter.createPipe(n,i)],r.duplex=t.duplex||`half`}t.cache&&t.cache!=="default"&&(r.cache=t.cache),t.redirect!==`follow`&&(r.redirect=t.redirect),t.integrity&&(r.integrity=t.integrity),t.mode&&t.mode!==`cors`&&(r.mode=t.mode),t.credentials&&t.credentials!==`same-origin`&&(r.credentials=t.credentials),t.referrer&&t.referrer!==`about:client`&&(r.referrer=t.referrer),t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy),t.keepalive&&(r.keepalive=t.keepalive);let a=t;return a.cf&&(r.cf=a.cf),a.encodeResponseBody&&a.encodeResponseBody!==`automatic`&&(r.encodeResponseBody=a.encodeResponseBody),[`request`,t.url,r]}case`response`:{let t=e,r=this.devaluateImpl(t.body,t,n+1),i={};t.status!==200&&(i.status=t.status),t.statusText&&(i.statusText=t.statusText);let a=[...t.headers];a.length>0&&(i.headers=a);let o=t;if(o.cf&&(i.cf=o.cf),o.encodeBody&&o.encodeBody!==`automatic`&&(i.encodeBody=o.encodeBody),o.webSocket)throw TypeError(`Can't serialize a Response containing a webSocket.`);return[`response`,r,i]}case`blob`:{let t=e,n=t.stream(),r=W.createReadableStreamHook(n),i=this.exporter.createPipe(n,r);return[`blob`,t.type,[`readable`,i]]}case`error`:{let t=e,r=this.exporter.onSendError(t);r&&(t=r);let i=t,a,o=(e,r)=>{let i=this.exports?.length??0;try{let i=this.devaluateImpl(r,t,n+1);a||={},a[e]=i}catch{if(this.exports&&this.exports.length>i){let e=this.exports.splice(i);try{this.exporter.unexport(e)}catch{}}}};for(let e of Object.keys(t))e!==`name`&&e!==`message`&&e!==`stack`&&o(e,i[e]);`cause`in t&&o(`cause`,i.cause),t instanceof AggregateError&&o(`errors`,t.errors);let s=[`error`,t.name,t.message];return a?(s.push(r&&r.stack?r.stack:null),s.push(a)):r&&r.stack&&s.push(r.stack),s}case`undefined`:return this.encodingLevel===`structuredClonable`?void 0:[`undefined`];case`stub`:case`rpc-promise`:{if(!this.source)throw Error(`Can't serialize RPC stubs in this context.`);let{hook:t,pathIfPromise:n}=yi(e),r=this.exporter.getImport(t);return r===void 0?(t=n?t.get(n):t.dup(),this.devaluateHook(n?`promise`:`export`,t)):n?n.length>0?[`pipeline`,r,n]:[`pipeline`,r]:[`import`,r]}case`function`:case`rpc-target`:{if(!this.source)throw Error(`Can't serialize RPC stubs in this context.`);let n=this.source.getHookForRpcTarget(e,t);return this.devaluateHook(`export`,n)}case`rpc-thenable`:{if(!this.source)throw Error(`Can't serialize RPC stubs in this context.`);let n=this.source.getHookForRpcTarget(e,t);return this.devaluateHook(`promise`,n)}case`writable`:{if(!this.source)throw Error(`Can't serialize WritableStream in this context.`);let n=this.source.getHookForWritableStream(e,t);return this.devaluateHook(`writable`,n)}case`readable`:{if(!this.source)throw Error(`Can't serialize ReadableStream in this context.`);let n=e,r=this.source.getHookForReadableStream(n,t);return[`readable`,this.exporter.createPipe(n,r)]}default:throw Error(`unreachable`)}}devaluateHook(e,t){this.exports||=[];let n=e===`promise`?this.exporter.exportPromise(t):this.exporter.exportStub(t);return this.exports.push(n),[e,n]}};new class{importStub(e){throw Error(`Cannot deserialize RPC stubs without an RPC session.`)}importPromise(e){throw Error(`Cannot deserialize RPC stubs without an RPC session.`)}getExport(e){}getPipeReadable(e){throw Error(`Cannot retrieve pipe readable without an RPC session.`)}getLimits(){return Di}};function zi(e,t){return new K(new Ei(new Response(t).arrayBuffer().then(t=>{let n=new Uint8Array(t),r=new Request(e,{body:n});return new Ci(q.fromAppReturn(r))})),[])}function Bi(e,t){return new K(new Ei(Ii(e,t).then(e=>new Ci(q.fromAppReturn(e)))),[])}var Vi=class e{importer;encodingLevel;limits;constructor(e,t=`string`){this.importer=e,this.encodingLevel=t,this.limits=e.getLimits()}hooks=[];promises=[];evaluate(e){return this.evaluateWithDepth(e,0)}evaluateWithDepth(e,t){let n=q.forEvaluate(this.hooks,this.promises);try{return n.value=this.evaluateImpl(e,n,`value`,t),n}catch(e){throw n.dispose(),e}}evaluateCopy(e){return this.evaluate(structuredClone(e))}evaluateImpl(t,n,r,i){let a=this.limits.maxDepth;if(i>=a)throw TypeError(`Deserialization exceeded maximum allowed message depth of ${a}.`);if(this.encodingLevel===`structuredClonable`&&(t instanceof Date||typeof t==`bigint`))return t;if(t instanceof Array){if(t.length==1&&t[0]instanceof Array){let e=t[0];for(let t=0;t<e.length;t++)e[t]=this.evaluateImpl(e[t],e,t,i+1);return e}switch(t[0]){case`bigint`:if(typeof t[1]==`string`){let e=t[1],n=this.limits.maxBigIntDigits;if(e.length>n)throw TypeError(`Deserialized bigint exceeds maximum length of ${n} digits.`);return BigInt(e)}break;case`date`:if(t[1]===null)return new Date(NaN);if(typeof t[1]==`number`)return new Date(t[1]);break;case`bytes`:{let e;if(t[1]instanceof Uint8Array)e=t[1];else if(typeof t[1]==`string`){if(typeof Buffer<`u`)e=Buffer.from(t[1],`base64`);else if(Uint8Array.fromBase64)e=Uint8Array.fromBase64(t[1]);else{let n=atob(t[1]),r=n.length;e=new Uint8Array(r);for(let t=0;t<r;t++)e[t]=n.charCodeAt(t)}}else break;if(t.length===2)return e;if(typeof t[2]!=`string`)throw TypeError(`Unknown bytes type marker type: ${typeof t[2]}`);if(!Ai(t[2])){let e=t[2].slice(0,64);throw TypeError(`Unknown bytes type marker: ${e}`)}let n=t[2],r=ji[n];if(r!==void 0&&e.byteLength%r!==0)throw TypeError(`Invalid byte length ${e.byteLength} for ${n}; expected a multiple of ${r}`);let i=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);switch(!Oi&&r!==void 0&&Pi(new Uint8Array(i),r),n){case`ArrayBuffer`:return i;case`DataView`:return new DataView(i);case`Int8Array`:return new Int8Array(i);case`Uint8Array`:return new Uint8Array(i);case`Uint8ClampedArray`:return new Uint8ClampedArray(i);case`Int16Array`:return new Int16Array(i);case`Uint16Array`:return new Uint16Array(i);case`Int32Array`:return new Int32Array(i);case`Uint32Array`:return new Uint32Array(i);case`BigInt64Array`:return new BigInt64Array(i);case`BigUint64Array`:return new BigUint64Array(i);case`Float32Array`:return new Float32Array(i);case`Float64Array`:return new Float64Array(i)}}case`error`:if(t.length>=3&&typeof t[1]==`string`&&typeof t[2]==`string`){let e=Li[t[1]]||Error,n=e===AggregateError?new e([],t[2]):new e(t[2]);if(typeof t[3]==`string`&&(n.stack=t[3]),t.length>=5){let e=t[4];if(!e||typeof e!=`object`||Array.isArray(e))break;let r=n,a=e;for(let e of Object.keys(a))if(e!==`name`&&e!==`message`&&e!==`stack`){if(e in Object.prototype||e===`toJSON`){this.evaluateImpl(a[e],n,e,i+1);continue}r[e]=this.evaluateImpl(a[e],n,e,i+1)}}return n}break;case`undefined`:if(t.length===1)return;break;case`inf`:return 1/0;case`-inf`:return-1/0;case`nan`:return NaN;case`url`:if(t.length===2&&typeof t[1]==`string`)return new URL(t[1]);break;case`headers`:if(t.length===2&&t[1]instanceof Array)return new Headers(t[1]);break;case`request`:{if(t.length!==3||typeof t[1]!=`string`)break;let e=t[1],a=t[2];if(typeof a!=`object`||!a)break;if(a.body&&(a.body=this.evaluateImpl(a.body,a,`body`,i+1),!(a.body===null||typeof a.body==`string`||a.body instanceof Uint8Array||a.body instanceof ReadableStream)))throw TypeError(`Request body must be of type ReadableStream.`);if(a.signal&&(a.signal=this.evaluateImpl(a.signal,a,`signal`,i+1),!(a.signal instanceof AbortSignal)))throw TypeError(`Request siganl must be of type AbortSignal.`);if(a.headers&&!(a.headers instanceof Array))throw TypeError(`Request headers must be serialized as an array of pairs.`);let o=new Request(e,a);if(a.body instanceof ReadableStream&&o.body===void 0){let e=zi(o,a.body);return this.promises.push({promise:e,parent:n,property:r}),e}return o}case`response`:{if(t.length!==3)break;let e=this.evaluateImpl(t[1],n,r,i+1);if(!(e===null||typeof e==`string`||e instanceof Uint8Array||e instanceof ReadableStream))throw TypeError(`Response body must be of type ReadableStream.`);let a=t[2];if(typeof a!=`object`||!a)break;if(a.webSocket)throw TypeError(`Can't deserialize a Response containing a webSocket.`);if(a.headers&&!(a.headers instanceof Array))throw TypeError(`Request headers must be serialized as an array of pairs.`);return new Response(e,a)}case`blob`:{if(t.length!==3||typeof t[1]!=`string`)break;let e=t[1],a=this.evaluateImpl(t[2],n,r,i+1);if(!(a instanceof ReadableStream))throw TypeError(`Blob content must be serialized as a ReadableStream.`);let o=Bi(a,e);return this.promises.push({promise:o,parent:n,property:r}),o}case`import`:case`pipeline`:{if(t.length<2||t.length>4||typeof t[1]!=`number`)break;let a=this.importer.getExport(t[1]);if(!a)throw Error(`no such entry on exports table: ${t[1]}`);let o=t[0]==`pipeline`,s=e=>{if(o){let t=new K(e,[]);return this.promises.push({promise:t,parent:n,property:r}),t}return this.hooks.push(e),new K(e,[])};if(t.length==2)return s(o?a.get([]):a.dup());let c=t[2];if(!(c instanceof Array)||!c.every(e=>typeof e==`string`||typeof e==`number`))break;if(t.length==3)return s(a.get(c));let l=t[3];if(!(l instanceof Array))break;return l=new e(this.importer).evaluateWithDepth([l],i),s(a.call(c,l))}case`remap`:{if(t.length!==5||typeof t[1]!=`number`||!(t[2]instanceof Array)||!(t[3]instanceof Array)||!(t[4]instanceof Array))break;let e=this.importer.getExport(t[1]);if(!e)throw Error(`no such entry on exports table: ${t[1]}`);let i=t[2];if(!i.every(e=>typeof e==`string`||typeof e==`number`))break;let a=t[3].map(e=>{if(!(e instanceof Array)||e.length!==2||e[0]!==`import`&&e[0]!==`export`||typeof e[1]!=`number`)throw TypeError(`unknown map capture: ${JSON.stringify(e)}`);if(e[0]===`export`)return this.importer.importStub(e[1]);{let t=this.importer.getExport(e[1]);if(!t)throw Error(`no such entry on exports table: ${e[1]}`);return t.dup()}}),o=t[4],s=new K(e.map(i,a,o),[]);return this.promises.push({promise:s,parent:n,property:r}),s}case`export`:case`promise`:if(typeof t[1]==`number`){if(t[0]==`promise`){let e=new K(this.importer.importPromise(t[1]),[]);return this.promises.push({parent:n,property:r,promise:e}),e}{let e=this.importer.importStub(t[1]);return this.hooks.push(e),new mi(e)}}break;case`writable`:if(typeof t[1]==`number`){let e=this.importer.importStub(t[1]),n=W.createWritableStreamFromHook(e);return this.hooks.push(e),n}break;case`readable`:if(typeof t[1]==`number`){let e=this.importer.getPipeReadable(t[1]),n=W.createReadableStreamHook(e);return this.hooks.push(n),e}}throw TypeError(`unknown special value: ${JSON.stringify(t)}`)}if(t instanceof Object){let e=t;for(let t in e)t in Object.prototype||t===`toJSON`?(this.evaluateImpl(e[t],e,t,i+1),delete e[t]):e[t]=this.evaluateImpl(e[t],e,t,i+1);return e}return t}},Hi=16,Ui=8,Wi=16,Gi=64;function Ki(e){return 2+e.length*3}function qi(e,t,n=0){if(n>=Gi)return Ui;switch(typeof e){case`string`:return Ki(e);case`number`:return 16;case`bigint`:return 16;case`boolean`:return 8;case`undefined`:return 16;case`object`:{if(e===null)return 8;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return Wi+e.byteLength;if(typeof Blob<`u`&&e instanceof Blob)return Wi+e.size;if(e instanceof Date)return 16;if(t??=new WeakSet,t.has(e))return Ui;if(t.add(e),e instanceof Array){let r=Hi;for(let i of e)r+=Ui+qi(i,t,n+1);return r}if(e instanceof Error){let r=Hi+Ki(e.name)+Ki(e.message)+Ki(e.stack??``);for(let i of Object.keys(e))r+=Ui+Ki(i)+qi(e[i],t,n+1);return r}let r=Hi;for(let i of Object.keys(e))r+=Ui+Ki(i)+qi(e[i],t,n+1);return r}default:return 16}}var Ji=class{session;importId;constructor(e,t,n){this.session=e,this.importId=t,n&&(this.activePull=Promise.withResolvers())}localRefcount=0;remoteRefcount=1;activePull;resolution;onBrokenRegistrations;resolve(e){if(this.localRefcount==0){e.dispose();return}if(this.resolution=e,this.sendRelease(),this.onBrokenRegistrations){for(let t of this.onBrokenRegistrations){let n=this.session.onBrokenCallbacks[t],r=this.session.onBrokenCallbacks.length;e.onBroken(n),this.session.onBrokenCallbacks[r]===n?delete this.session.onBrokenCallbacks[r]:delete this.session.onBrokenCallbacks[t]}this.onBrokenRegistrations=void 0}this.activePull&&=(this.activePull.resolve(),void 0)}async awaitResolution(){return this.activePull||=(this.session.sendPull(this.importId),Promise.withResolvers()),await this.activePull.promise,this.resolution.pull()}dispose(){this.resolution?this.resolution.dispose():(this.abort(Error(`RPC was canceled because the RpcPromise was disposed.`)),this.sendRelease())}abort(e){if(!this.resolution){if(this.resolution=new G(e),this.activePull&&=(this.activePull.reject(e),void 0),this.onBrokenRegistrations)for(let e of this.onBrokenRegistrations)delete this.session.onBrokenCallbacks[e];this.onBrokenRegistrations=void 0}}onBroken(e){if(this.resolution)this.resolution.onBroken(e);else{let t=this.session.onBrokenCallbacks.length;this.session.onBrokenCallbacks.push(e),this.onBrokenRegistrations||=[],this.onBrokenRegistrations.push(t)}}sendRelease(){this.remoteRefcount>0&&(this.session.sendRelease(this.importId,this.remoteRefcount),this.remoteRefcount=0)}},Yi=class e extends ci{isPromise;entry;constructor(e,t){super(),this.isPromise=e,++t.localRefcount,this.entry=t}collectPath(e){return this}getEntry(){if(this.entry)return this.entry;throw Error(`This RpcImportHook was already disposed.`)}getEntryTakingOwnership(e){try{return this.getEntry()}catch(t){throw e(),t}}call(e,t){let n=this.getEntryTakingOwnership(()=>t.dispose());return n.resolution?n.resolution.call(e,t):n.session.sendCall(n.importId,e,t)}stream(e,t){let n=this.getEntryTakingOwnership(()=>t.dispose());return n.resolution?n.resolution.stream(e,t):n.session.sendStream(n.importId,e,t)}map(e,t,n){let r=this.getEntryTakingOwnership(()=>{for(let e of t)e.dispose()});return r.resolution?r.resolution.map(e,t,n):r.session.sendMap(r.importId,e,t,n)}get(e){let t=this.getEntry();return t.resolution?t.resolution.get(e):t.session.sendCall(t.importId,e)}dup(){return new e(!1,this.getEntry())}pull(){let e=this.getEntry();if(!this.isPromise)throw Error(`Can't pull this hook because it's not a promise hook.`);return e.resolution?e.resolution.pull():e.awaitResolution()}ignoreUnhandledRejections(){}dispose(){let e=this.entry;this.entry=void 0,e&&--e.localRefcount===0&&e.dispose()}onBroken(e){this.entry&&this.entry.onBroken(e)}},Xi=class extends Yi{session;constructor(e){super(!1,e),this.session=e.session}dispose(){if(this.session){let e=this.session;this.session=void 0,e.shutdown()}}},Zi=class{transport;options;exports=[];reverseExports=new Map;imports=[];abortReason;cancelReadLoop;nextExportId=-1;onBatchDone;pullCount=0;onBrokenCallbacks=[];encodingLevel;limits;constructor(e,t,n){this.transport=e,this.options=n;let r=`string`;if(`encodingLevel`in e){let t=e.encodingLevel;if(t!==void 0){if(t!==`string`&&t!==`jsonCompatible`&&t!==`jsonCompatibleWithBytes`&&t!==`structuredClonable`)throw TypeError(`Unknown transport encodingLevel: ${String(t)}`);r=t}}this.encodingLevel=r,this.limits={...Di,...n.limits},this.exports.push({hook:t,refcount:1}),this.imports.push(new Ji(this,0,!1)),this.readLoop().catch(e=>this.abort(e))}getMainImport(){return new Xi(this.imports[0])}shutdown(){this.abort(Error(`RPC session was shut down by disposing the main stub`),!1)}exportStub(e){if(this.abortReason)throw this.abortReason;let t=this.reverseExports.get(e);if(t!==void 0)return++this.exports[t].refcount,t;{let t=this.nextExportId--;return this.exports[t]={hook:e,refcount:1},this.reverseExports.set(e,t),this.watchExport(t,e),t}}exportPromise(e){if(this.abortReason)throw this.abortReason;let t=this.nextExportId--;return this.exports[t]={hook:e,refcount:1},this.reverseExports.set(e,t),this.ensureResolvingExport(t),t}unexport(e){for(let t of e)this.releaseExport(t,1)}watchExport(e,t){t.onBroken(n=>{queueMicrotask(()=>{if(this.abortReason===void 0&&this.exports[e]?.hook===t)try{this.send([`reject`,e,Ri.devaluate(n,void 0,this,void 0,this.encodingLevel)])}catch(e){this.abort(e)}})})}releaseExport(e,t){let n=this.exports[e];if(!n)throw Error(`no such export ID: ${e}`);if(n.refcount<t)throw Error(`refcount would go negative: ${n.refcount} < ${t}`);n.refcount-=t,n.refcount===0&&(delete this.exports[e],this.reverseExports.delete(n.hook),n.hook.dispose())}onSendError(e){if(this.options.onSendError)return this.options.onSendError(e)}ensureResolvingExport(e){let t=this.exports[e];if(!t)throw Error(`no such export ID: ${e}`);if(!t.pull){let n=async()=>{let e=t.hook;for(;;){let t=await e.pull();if(t.value instanceof mi){let{hook:n,pathIfPromise:r}=yi(t.value);if(r&&r.length==0&&this.getImport(e)===void 0){e=n;continue}}return t}},r=t.autoRelease;++this.pullCount,t.pull=n().then(t=>{let n=Ri.devaluate(t.value,void 0,this,t,this.encodingLevel);this.send([`resolve`,e,n]),r&&this.releaseExport(e,1)},t=>{this.send([`reject`,e,Ri.devaluate(t,void 0,this,void 0,this.encodingLevel)]),r&&this.releaseExport(e,1)}).catch(t=>{try{this.send([`reject`,e,Ri.devaluate(t,void 0,this,void 0,this.encodingLevel)]),r&&this.releaseExport(e,1)}catch(e){this.abort(e)}}).finally(()=>{--this.pullCount===0&&this.onBatchDone&&this.onBatchDone.resolve()})}}getImport(e){if(e instanceof Yi&&e.entry&&e.entry.session===this)return e.entry.importId}importStub(e){if(this.abortReason)throw this.abortReason;let t=this.imports[e];return t||(t=new Ji(this,e,!1),this.imports[e]=t),new Yi(!1,t)}importPromise(e){if(this.abortReason)throw this.abortReason;if(this.imports[e])return new G(Error(`Bug in RPC system: The peer sent a promise reusing an existing export ID.`));let t=new Ji(this,e,!0);return this.imports[e]=t,new Yi(!0,t)}getExport(e){return this.exports[e]?.hook}getPipeReadable(e){let t=this.exports[e];if(!t||!t.pipeReadable)throw Error(`Export ${e} is not a pipe or its readable end was already consumed.`);let n=t.pipeReadable;return t.pipeReadable=void 0,n}getLimits(){return this.limits}createPipe(e,t){if(this.abortReason)throw this.abortReason;this.send([`pipe`]);let n=this.imports.length,r=new Ji(this,n,!1);this.imports.push(r);let i=new Yi(!1,r),a=W.createWritableStreamFromHook(i);return e.pipeTo(a).catch(()=>{}).finally(()=>t.dispose()),n}send(e){if(this.abortReason!==void 0)return 0;if(this.encodingLevel===`string`){let t;try{t=JSON.stringify(e)}catch(e){try{this.abort(e)}catch{}throw e}try{let e=this.transport.send(t);e!==void 0&&typeof e.catch==`function`&&e.catch(e=>this.abort(e,!1))}catch(e){queueMicrotask(()=>this.abort(e,!1))}return t.length}try{let t=this.transport.send(e);if(typeof t==`number`)return t;let n=t;n&&typeof n.then==`function`&&Promise.resolve(n).catch(e=>this.abort(e,!1));return}catch(e){queueMicrotask(()=>this.abort(e,!1));return}}sendCall(e,t,n){if(this.abortReason)throw n?.dispose(),this.abortReason;let r=[`pipeline`,e,t];if(n){let e;try{e=Ri.devaluate(n.value,void 0,this,n,this.encodingLevel)}catch(e){throw n.dispose(),e}r.push(e[0])}this.send([`push`,r]);let i=new Ji(this,this.imports.length,!1);return this.imports.push(i),new Yi(!0,i)}sendStream(e,t,n){if(this.abortReason)throw n.dispose(),this.abortReason;let r=[`pipeline`,e,t],i;try{i=Ri.devaluate(n.value,void 0,this,n,this.encodingLevel)}catch(e){throw n.dispose(),e}r.push(i[0]);let a=[`stream`,r],o=this.send(a);o===void 0&&(o=qi(a));let s=this.imports.length,c=new Ji(this,s,!0);return c.remoteRefcount=0,c.localRefcount=1,this.imports.push(c),{promise:c.awaitResolution().then(e=>{e.dispose(),delete this.imports[s]},e=>{throw delete this.imports[s],e}),size:o}}sendMap(e,t,n,r){if(this.abortReason){for(let e of n)e.dispose();throw this.abortReason}let i=[`remap`,e,t,n.map(e=>{let t=this.getImport(e);return t===void 0?[`export`,this.exportStub(e)]:[`import`,t]}),r];this.send([`push`,i]);let a=new Ji(this,this.imports.length,!1);return this.imports.push(a),new Yi(!0,a)}sendPull(e){if(this.abortReason)throw this.abortReason;this.send([`pull`,e])}sendRelease(e,t){this.abortReason||(this.send([`release`,e,t]),delete this.imports[e])}abort(e,t=!0){if(this.abortReason===void 0){if(this.cancelReadLoop?.(e),this.cancelReadLoop=void 0,t)try{let t=[`abort`,Ri.devaluate(e,void 0,this,void 0,this.encodingLevel)];if(this.encodingLevel===`string`){let e=this.transport.send(JSON.stringify(t));e!==void 0&&typeof e.catch==`function`&&e.catch(e=>{})}else{let e=this.transport.send(t);e&&typeof e.then==`function`&&Promise.resolve(e).catch(e=>{})}}catch{}if(e===void 0&&(e=`undefined`),this.abortReason=e,this.onBatchDone&&this.onBatchDone.reject(e),this.transport.abort)try{this.transport.abort(e)}catch(e){Promise.resolve(e)}for(let t of Object.values(this.onBrokenCallbacks))try{t(e)}catch(e){Promise.resolve(e)}for(let t in this.imports)this.imports[t].abort(e);for(let e in this.exports)this.exports[e].hook.dispose()}}async readLoop(){for(;!this.abortReason;){let e=Promise.withResolvers();this.cancelReadLoop=e.reject;let t;try{t=await Promise.race([this.transport.receive(),e.promise])}finally{this.cancelReadLoop===e.reject&&(this.cancelReadLoop=void 0)}if(this.encodingLevel===`string`&&t.length>this.limits.maxMessageSize)throw TypeError(`Incoming message exceeds maximum size of ${this.limits.maxMessageSize} UTF-16 code units.`);if(this.abortReason)break;let n=this.encodingLevel===`string`?JSON.parse(t):t;if(n instanceof Array)switch(n[0]){case`push`:if(n.length>1){let e=new Ci(new Vi(this,this.encodingLevel).evaluate(n[1]));e.ignoreUnhandledRejections(),this.exports.push({hook:e,refcount:1});continue}break;case`stream`:if(n.length>1){let e=new Ci(new Vi(this,this.encodingLevel).evaluate(n[1]));e.ignoreUnhandledRejections();let t=this.exports.length;this.exports.push({hook:e,refcount:1,autoRelease:!0}),this.ensureResolvingExport(t);continue}break;case`pipe`:{let{readable:e,writable:t}=new TransformStream,n=W.createWritableStreamHook(t),r=this.exports.length;this.exports.push({hook:n,refcount:1,pipeReadable:e}),this.watchExport(r,n);continue}case`pull`:{let e=n[1];if(typeof e==`number`){this.ensureResolvingExport(e);continue}break}case`resolve`:case`reject`:{let e=n[1];if(typeof e==`number`&&n.length>2){let t=this.imports[e];if(t){if(n[0]==`resolve`)t.resolve(new Ci(new Vi(this,this.encodingLevel).evaluate(n[2])));else{let e=new Vi(this,this.encodingLevel).evaluate(n[2]);e.dispose(),t.resolve(new G(e.value))}}else n[0]==`resolve`&&new Vi(this,this.encodingLevel).evaluate(n[2]).dispose();continue}break}case`release`:{let e=n[1],t=n[2];if(typeof e==`number`&&typeof t==`number`){this.releaseExport(e,t);continue}break}case`abort`:{let e=new Vi(this,this.encodingLevel).evaluate(n[1]);e.dispose(),this.abort(e.value,!1);break}}throw Error(`bad RPC message: ${JSON.stringify(n)}`)}}async drain(){if(this.abortReason)throw this.abortReason;if(this.pullCount>0){let{promise:e,resolve:t,reject:n}=Promise.withResolvers();this.onBatchDone={resolve:t,reject:n},await e}}getStats(){let e={imports:0,exports:0};for(let t in this.imports)++e.imports;for(let t in this.exports)++e.exports;return e}},Qi=class{#e;#t;constructor(e,t,n={}){let r;r=t?new Ci(q.fromAppReturn(t)):new G(Error(`This connection has no main object.`)),this.#e=new Zi(e,r,n),this.#t=new mi(this.#e.getMainImport())}getRemoteMain(){return this.#t}getStats(){return this.#e.getStats()}drain(){return this.#e.drain()}};function $i(e,t,n){return new Qi(new ea(e),t,n).getRemoteMain()}var ea=class{encodingLevel=`structuredClonable`;constructor(e){this.#e=e,e.start(),e.addEventListener(`message`,e=>{this.#i||(e.data===null?this.#a(Error(`Peer closed MessagePort connection.`)):this.#t?(this.#t(e.data),this.#t=void 0,this.#n=void 0):this.#r.push(e.data))}),e.addEventListener(`messageerror`,e=>{this.#a(Error(`MessagePort message error.`))})}#e;#t;#n;#r=[];#i;send(e){if(this.#i)throw this.#i;this.#e.postMessage(e)}async receive(){if(this.#r.length>0)return this.#r.shift();if(this.#i)throw this.#i;return new Promise((e,t)=>{this.#t=e,this.#n=t})}abort(e){try{this.#e.postMessage(null)}catch{}this.#e.close(),this.#i||=e}#a(e){this.#i||(this.#i=e,this.#n&&=(this.#n(e),this.#t=void 0,void 0))}},ta,na=class{context;captureMap=new Map;instructions=[];constructor(e,t){this.context=ta?{parent:ta,captures:[],subject:ta.capture(e),path:t}:{parent:void 0,captures:[],subject:e,path:t},ta=this}unregister(){ta=this.context.parent}makeInput(){return new ia(this,0)}makeOutput(e){let t;try{t=Ri.devaluate(e.value,void 0,this,e)}finally{e.dispose()}return this.instructions.push(t),this.context.parent?(this.context.parent.instructions.push([`remap`,this.context.subject,this.context.path,this.context.captures.map(e=>[`import`,e]),this.instructions]),new ia(this.context.parent,this.context.parent.instructions.length)):this.context.subject.map(this.context.path,this.context.captures,this.instructions)}pushCall(e,t,n){let r=Ri.devaluate(n.value,void 0,this,n);r=r[0];let i=this.capture(e.dup());return this.instructions.push([`pipeline`,i,t,r]),new ia(this,this.instructions.length)}pushGet(e,t){let n=this.capture(e.dup());return this.instructions.push([`pipeline`,n,t]),new ia(this,this.instructions.length)}capture(e){if(e instanceof ia&&e.mapper===this)return e.idx;let t=this.captureMap.get(e);if(t===void 0){if(this.context.parent){let t=this.context.parent.capture(e);this.context.captures.push(t)}else this.context.captures.push(e);t=-this.context.captures.length,this.captureMap.set(e,t)}return t}exportStub(e){throw Error(`Can't construct an RpcTarget or RPC callback inside a mapper function. Try creating a new RpcStub outside the callback first, then using it inside the callback.`)}exportPromise(e){return this.exportStub(e)}getImport(e){return this.capture(e)}unexport(e){}createPipe(e){throw Error(`Cannot send ReadableStream inside a mapper function.`)}onSendError(e){}};oi.sendMap=(e,t,n)=>{let r=new na(e,t),i;try{i=q.fromAppReturn(di(r.pushCall.bind(r),()=>n(new K(r.makeInput(),[]))))}finally{r.unregister()}if(i instanceof Promise)throw i.catch(e=>{}),Error(`RPC map() callbacks cannot be async.`);return new K(r.makeOutput(i),[])};function ra(){throw Error(`Attempted to use an abstract placeholder from a mapper function. Please make sure your map function has no side effects.`)}var ia=class extends ci{mapper;idx;constructor(e,t){super(),this.mapper=e,this.idx=t}dup(){return this}dispose(){}get(e){if(e.length==0)return this;if(ta)return ta.pushGet(this,e);ra()}call(e,t){t.dispose(),ra()}map(e,t,n){for(let e of t)e.dispose();ra()}pull(){ra()}ignoreUnhandledRejections(){}onBroken(e){ra()}},aa=class{captures;variables;constructor(e,t){this.captures=e,this.variables=[t]}dispose(){for(let e of this.variables)e.dispose()}apply(e){try{if(e.length<1)throw Error(`Invalid empty mapper function.`);for(let t of e.slice(0,-1)){let e=new Vi(this).evaluateCopy(t);if(e.value instanceof mi){let t=_i(e.value);if(t){this.variables.push(t);continue}}this.variables.push(new Ci(e))}return new Vi(this).evaluateCopy(e[e.length-1])}finally{for(let e of this.variables)e.dispose()}}importStub(e){throw Error(`A mapper function cannot refer to exports.`)}importPromise(e){return this.importStub(e)}getExport(e){return e<0?this.captures[-e-1]:this.variables[e]}getPipeReadable(e){throw Error(`A mapper function cannot use pipe readables.`)}getLimits(){return Di}};function oa(e,t,n,r,i){let a=new aa(r,new Ci(q.deepCopyFrom(e,t,n)));try{return a.apply(i)}finally{a.dispose()}}oi.applyMap=(e,t,n,r,i)=>{try{let a;if(e instanceof K)throw Error(`applyMap() can't be called on RpcPromise`);if(e instanceof Array){let t=[];try{for(let a of e)t.push(oa(a,e,n,r,i))}catch(e){for(let e of t)e.dispose();throw e}a=q.fromArray(t)}else a=e==null?q.fromAppReturn(e):oa(e,t,n,r,i);return new Ci(a)}finally{for(let e of r)e.dispose()}};var sa=class e extends ci{state;static create(t){let n=t.getWriter();return new e({refcount:1,writer:n,closed:!1})}constructor(e,t){super(),this.state=e,t&&++e.refcount}getState(){if(this.state)return this.state;throw Error(`Attempted to use a WritableStreamStubHook after it was disposed.`)}call(e,t){try{let n=this.getState();if(e.length!==1||typeof e[0]!=`string`)throw Error(`WritableStream stub only supports direct method calls`);let r=e[0];if(r!==`write`&&r!==`close`&&r!==`abort`)throw Error(`Unknown WritableStream method: ${r}`);return(r===`close`||r===`abort`)&&(n.closed=!0),new Ei((r===`write`?t.deliverStreamWrite(n.writer):t.deliverCall(n.writer[r],n.writer)).then(e=>new Ci(e)))}catch(e){return t.dispose(),new G(e)}}map(e,t,n){for(let e of t)e.dispose();return new G(Error(`Cannot use map() on a WritableStream`))}get(e){return new G(Error(`Cannot access properties on a WritableStream stub`))}dup(){let t=this.getState();return new e(t,this)}pull(){return Promise.reject(Error(`Cannot pull a WritableStream stub`))}ignoreUnhandledRejections(){}dispose(){let e=this.state;this.state=void 0,e&&--e.refcount===0&&(e.closed||e.writer.abort(Error(`WritableStream RPC stub was disposed without calling close()`)).catch(()=>{}),e.writer.releaseLock())}onBroken(e){this.getState().writer.closed.then(void 0,e)}},ca=262144,la=1073741824,ua=65536,da=2,fa=1.25,pa=.9,ma=3,ha=class{now;window=ca;bytesInFlight=0;inStartupPhase=!0;delivered=0;deliveredTime=0;firstAckTime=0;firstAckDelivered=0;minRtt=1/0;roundsWithoutIncrease=0;lastRoundWindow=0;roundStartTime=0;constructor(e){this.now=e}onSend(e){this.bytesInFlight+=e;let t={sentTime:this.now(),size:e,deliveredAtSend:this.delivered,deliveredTimeAtSend:this.deliveredTime,windowAtSend:this.window,windowFullAtSend:this.bytesInFlight>=this.window};return{token:t,shouldBlock:t.windowFullAtSend}}onError(e){this.bytesInFlight-=e.size}onAck(e){let t=this.now();this.delivered+=e.size,this.deliveredTime=t,this.bytesInFlight-=e.size;let n=t-e.sentTime;if(this.minRtt=Math.min(this.minRtt,n),this.firstAckTime===0)this.firstAckTime=t,this.firstAckDelivered=this.delivered;else{let n,r;e.deliveredTimeAtSend===0?(n=this.firstAckTime,r=this.firstAckDelivered):(n=e.deliveredTimeAtSend,r=e.deliveredAtSend);let i=t-n,a=(this.delivered-r)/i,o=this.inStartupPhase?da:fa,s=a*this.minRtt*o;s=Math.min(s,e.windowAtSend*o),s=e.windowFullAtSend?Math.max(s,e.windowAtSend*pa):Math.max(s,this.window),this.window=Math.max(Math.min(s,la),ua),this.inStartupPhase&&e.sentTime>=this.roundStartTime&&(this.window>this.lastRoundWindow*fa?this.roundsWithoutIncrease=0:++this.roundsWithoutIncrease>=ma&&(this.inStartupPhase=!1),this.roundStartTime=t,this.lastRoundWindow=this.window)}return this.bytesInFlight<this.window}};function ga(e){let t,n=!1,r=new ha(()=>performance.now()),i,a,o=()=>{n||(n=!0,e.dispose())};return new WritableStream({start(n){e.onBroken(e=>{t===void 0&&(t=e,n.error(e),o()),a&&=(a(e),i=void 0,void 0)})},write(n,s){if(t!==void 0)throw t;let c=q.fromAppParams([n]),{promise:l,size:u}=e.stream([`write`],c);if(u===void 0)return l.catch(e=>{throw t===void 0&&(t=e),e});{let{token:e,shouldBlock:n}=r.onSend(u);if(l.then(()=>{r.onAck(e)&&i&&(i(),i=void 0,a=void 0)},n=>{r.onError(e),t===void 0&&(t=n,s.error(n),o()),a&&=(a(n),i=void 0,void 0)}),n)return new Promise((e,t)=>{i=e,a=t})}},async close(){if(t!==void 0)throw o(),t;let{promise:n}=e.stream([`close`],q.fromAppParams([]));try{await n}catch(e){throw t??e}finally{o()}},abort(n){if(t!==void 0)return;t=n??Error(`WritableStream was aborted`),a&&=(a(t),i=void 0,void 0);let{promise:r}=e.stream([`abort`],q.fromAppParams([n]));r.then(()=>o(),()=>o())}})}var _a=class e extends ci{state;static create(t){return new e({refcount:1,stream:t,canceled:!1})}constructor(e,t){super(),this.state=e,t&&++e.refcount}call(e,t){return t.dispose(),new G(Error(`Cannot call methods on a ReadableStream stub`))}map(e,t,n){for(let e of t)e.dispose();return new G(Error(`Cannot use map() on a ReadableStream`))}get(e){return new G(Error(`Cannot access properties on a ReadableStream stub`))}dup(){let t=this.state;if(!t)throw Error(`Attempted to dup a ReadableStreamStubHook after it was disposed.`);return new e(t,this)}pull(){return Promise.reject(Error(`Cannot pull a ReadableStream stub`))}ignoreUnhandledRejections(){}dispose(){let e=this.state;this.state=void 0,e&&--e.refcount===0&&(e.canceled||(e.canceled=!0,e.stream.locked||e.stream.cancel(Error(`ReadableStream RPC stub was disposed without being consumed`)).catch(()=>{})))}onBroken(e){}};W.createWritableStreamHook=sa.create,W.createWritableStreamFromHook=ga,W.createReadableStreamHook=_a.create;var va=mi,ya=ti,ba=$i;function xa(e){return e<32||e>=127&&e<=159||e===1564||e>=8203&&e<=8207||e===8232||e===8233||e>=8234&&e<=8238||e>=8294&&e<=8297||e===65279}function Sa(e,t){let n=e.find(e=>e.id===t.itemId);if(n===void 0||n.kind===`text`)return!1;if(n.kind===`menu`){let e=n.options.find(e=>e.id===t.optionId);return e!==void 0&&e.disabled!==!0}return t.optionId===void 0?n.kind!==`button`||n.disabled!==!0:!1}Object.freeze({publish:()=>Promise.resolve(),onBack:()=>()=>void 0,onForward:()=>()=>void 0,onActivate:()=>()=>void 0});function Ca(e,t){if(t.kind===`action`){let n=[...e.primary??[],...e.menu??[]].find(e=>e.id===t.actionId);return n!==void 0&&n.disabled!==!0}let n=e.crumbs?.find(e=>e.id===t.crumbId);return n===void 0?!1:t.siblingId===void 0||n.siblings?.some(e=>e.id===t.siblingId)===!0}var wa=`fungi.app.ready`,Ta=`fungi.app.connect`,J=e=>fe.pipe(S(Se(1)),S(j(e))),Ea=e=>w(J(e)),Da=P.pipe(S(We()),S(et(Number.isSafeInteger,{message:`Expected a safe integer`}))),Oa=Da.pipe(S(be(0))),ka=Da.pipe(S(Ne(0))),Aa=m({appId:J(160),releaseId:J(160),surfaceId:J(160)}),ja=m({editing:y,surface:v([J(160),te])}),Ma=v([m({kind:x(`compose`),requestId:J(160),text:J(2e3)}),m({kind:x(`navigate`),requestId:J(160),params:O(m({key:J(64),value:J(4096)})).pipe(S(j(16)))})]),Y=E(u([`granted`,`missing`])),Na=m({"agent.list":Y,"agent.manage":Y,"agent.read":Y,"agent.send":Y,"computer.list":Y,"computer.readFile":Y,"computer.writeFile":Y,"computer.execute":Y,"git.repository":Y,"workflow.publish":Y,"workflow.arm":Y,"workflow.run":Y,"app.events.emit":Y,"llm.generation":Y,"media.generation":Y,"media.share":Y}),Pa=u([`ready`,`missing`,`unknown`]),Fa=m({models:Pa,media:Pa,git:Pa,terminal:u([`ready`,`exec-only`,`missing`,`unknown`]),terminalReason:w(fe)}),Ia=u([`model`,`media`,`git`,`computer`]),La=u([`opened`,`unavailable`]),Ra=m({computerId:v([J(256),te]),teamHasComputers:w(ce(y)),computerAccessGranted:w(y),setup:w(Fa),permissions:w(Na),focus:ja,openRequest:v([te,Ma]),visibility:u([`visible`,`hidden`])}),za=u([`connecting`,`connected`,`suspended`,`disconnected`,`disposing`,`disposed`]),Ba=m({altKey:y,ctrlKey:y,id:J(160),key:J(64),metaKey:y,shiftKey:y}),Va=m({action:w(A),availability:w(A),category:J(160),description:Ea(512),id:J(160),projections:w(A),title:J(160)}),Ha=m({arguments:w(A),commandId:J(321),origin:u([`agent`,`browser`,`keyboard`,`menu`,`palette`,`programmatic`,`slash`,`terminal`]),requestId:J(160)}),Ua=v([m({result:w(A),status:x(`handled`)}),m({error:A,status:x(`failed`)})]),Wa=e=>J(e).pipe(S(et(e=>{for(let t=0;t<e.length;t+=1)if(xa(e.charCodeAt(t)))return!1;return!0},{message:`Expected one line of plain text`}))),Ga={id:J(64),text:Wa(80),end:E(y),priority:E(x(`low`))},Ka=E(P.pipe(S(We()),S(Ye({minimum:0,maximum:9999})))),qa=O(v([m({...Ga,kind:x(`text`),tone:E(u([`neutral`,`success`,`warning`,`error`]))}),m({...Ga,kind:x(`button`),icon:E(u([`folder`,`ports`,`processes`,`access`])),count:Ka,tone:E(u([`neutral`,`success`,`warning`,`error`])),busy:E(y),title:E(Wa(1024)),disabled:E(y),opens:E(x(`dialog`)),expanded:E(y)}),m({...Ga,kind:x(`toggle`),pressed:y}),m({...Ga,kind:x(`menu`),count:Ka,title:E(Wa(1024)),options:O(m({id:J(64),text:Wa(80),checked:E(y),disabled:E(y)})).pipe(S(j(16)),S(et(e=>new Set(e.map(e=>e.id)).size===e.length,{message:`Expected unique status option ids`})))})])).pipe(S(j(6)),S(et(e=>new Set(e.map(e=>e.id)).size===e.length,{message:`Expected unique status item ids`}))),Ja=m({computerId:J(256),path:J(1024)}),Ya=J(80).pipe(S(et(e=>e.trim()===e,{message:`Expected a trimmed title`}))),Xa=J(64),Za=J(80),Qa=e=>new Set(e.map(e=>e.id)).size===e.length,$a=m({id:Xa,label:Za,siblings:w(O(m({id:Xa,label:Za})).pipe(S(j(16)),S(et(Qa,{message:`Expected unique crumb sibling ids`}))))}),eo=m({id:Xa,label:Za,icon:w(x(`play`)),variant:w(u([`primary`,`outline`,`ghost`])),tone:w(x(`destructive`)),disabled:w(y)}),to=e=>O(eo).pipe(S(j(e)),S(et(Qa,{message:`Expected unique header command ids`}))),no=m({id:Xa,label:Za,presentation:w(x(`bead`)),tone:w(u([`neutral`,`info`,`warning`,`success`,`error`]))}),ro={status:w(O(no).pipe(S(j(4)),S(et(Qa,{message:`Expected unique header status ids`})))),crumbs:w(O($a).pipe(S(j(8)),S(et(Qa,{message:`Expected unique crumb ids`})))),primary:w(to(3)),menu:w(to(12))},io=m({contractVersion:x(2),canGoBack:y,canGoForward:y,title:w(Ya),...ro}),ao=m({canGoBack:y,canGoForward:y,title:w(fe),...ro}),oo=v([m({kind:x(`crumb`),crumbId:Xa,siblingId:w(Xa)}),m({kind:x(`action`),actionId:Xa})]),so=ce(m({agentId:J(256),sessionId:J(256)})),co=e=>w(O(u(e)).pipe(S(j(e.length)))),lo=m({agents:w(O(u([`agent.list`,`agent.manage`,`agent.read`,`agent.send`])).pipe(S(j(4)))),computers:w(O(u([`computer.list`,`computer.readFile`,`computer.writeFile`,`computer.execute`])).pipe(S(j(4)))),git:co([`git.repository`]),workflows:co([`workflow.publish`,`workflow.arm`,`workflow.run`]),events:co([`app.events.emit`]),generation:co([`llm.generation`,`media.generation`,`media.share`])}),uo=u([`granted`,`declined`,`customize`]),fo=m({message:J(512),tone:w(u([`info`,`success`,`warning`,`error`]))}),po=u(ne);m({code:po.pick([`DELIVERY_PENDING`])});var mo=m({code:po,message:J(512),retryable:y,need:E(d)}),ho=m({protocolVersion:x(2),type:x(wa)}),go=m({epoch:J(160),protocolVersion:x(2),type:x(Ta)}),_o=m({epoch:J(160),protocolVersion:x(2)}),vo={[Symbol.dispose]:w(A)},yo=v([m({...vo,ok:x(!0),value:A}),m({...vo,error:mo,ok:x(!1)})]);function X(e,t,n=`PROTOCOL`){return f(ae(e,{onExcessProperty:`error`}),re({onFailure:e=>{throw new b(`The peer sent malformed protocol data`,{cause:e,code:n,retryable:!1})},onSuccess:t}))}function Z(e){return Object.freeze(e)}function bo(e,t){let n=e.arguments===void 0?void 0:Pn(e.arguments),r={origin:e.origin,signal:t};return n!==void 0&&Object.assign(r,{arguments:n}),Z(r)}var xo=X(Va,e=>{let t={category:e.category,id:e.id,title:e.title};return e.action!==void 0&&Object.assign(t,{action:e.action}),e.availability!==void 0&&Object.assign(t,{availability:e.availability}),e.description!==void 0&&Object.assign(t,{description:e.description}),e.projections!==void 0&&Object.assign(t,{projections:e.projections}),Z(fs(()=>Kn(t)))},`INVALID_ARGUMENT`),So=X(J(321),e=>e),Co=X(Ha,e=>{let t=e.arguments===void 0?void 0:Pn(e.arguments),n={commandId:e.commandId,origin:e.origin,requestId:e.requestId};return t!==void 0&&Object.assign(n,{arguments:t}),Z(n)}),wo=X(v([p,A]),e=>e===void 0?void 0:Pn(e)),To=X(go,e=>Z(e));X(_o,e=>Z(e));var Eo=X(Ra,e=>{let t={computerId:e.computerId,focus:Z({...e.focus}),openRequest:e.openRequest===null?null:Z({...e.openRequest}),visibility:e.visibility};return e.teamHasComputers!==void 0&&(t.teamHasComputers=e.teamHasComputers),e.computerAccessGranted!==void 0&&(t.computerAccessGranted=e.computerAccessGranted),e.setup!==void 0&&(t.setup=Z({...e.setup})),e.permissions!==void 0&&(t.permissions=Z({...e.permissions})),Z(t)}),Do=X(mo,e=>Z({...e})),Oo=X(ja,e=>Z({...e}),`INVALID_ARGUMENT`),ko=X(Aa,e=>Z({...e})),Ao=X(za,e=>e),jo=X(qa,e=>Z(e.map(e=>e.kind===`menu`?Z({...e,options:Z(e.options.map(e=>Z(e)))}):Z(e))),`INVALID_ARGUMENT`),Mo=X(m({itemId:J(64),optionId:E(J(64)),anchor:E(m({start:P.pipe(S(Ye({minimum:0,maximum:1e5}))),width:P.pipe(S(Ye({minimum:0,maximum:1e5})))}))}),e=>Z(e.anchor===void 0?{...e}:{...e,anchor:Z({...e.anchor})}),`INVALID_ARGUMENT`),No=X(Ja,e=>Z({...e}),`INVALID_ARGUMENT`);function Po(e){let t={id:e.id,label:e.label};return e.presentation!==void 0&&(t={...t,presentation:e.presentation}),e.tone!==void 0&&(t={...t,tone:e.tone}),Z(t)}function Fo(e){let t={id:e.id,label:e.label};return e.siblings===void 0?Z(t):Z({...t,siblings:Z(e.siblings.map(e=>Z({...e})))})}function Io(e){let t={id:e.id,label:e.label};return e.icon!==void 0&&(t={...t,icon:e.icon}),e.variant!==void 0&&(t={...t,variant:e.variant}),e.tone!==void 0&&(t={...t,tone:e.tone}),e.disabled!==void 0&&(t={...t,disabled:e.disabled}),Z(t)}function Lo(e){let t={canGoBack:e.canGoBack,canGoForward:e.canGoForward};return e.title!==void 0&&(t={...t,title:e.title}),e.crumbs!==void 0&&(t={...t,crumbs:Z(e.crumbs.map(Fo))}),e.primary!==void 0&&(t={...t,primary:Z(e.primary.map(Io))}),e.menu!==void 0&&(t={...t,menu:Z(e.menu.map(Io))}),e.status!==void 0&&(t={...t,status:Z(e.status.map(Po))}),Z(t)}var Ro=X(io,Lo,`INVALID_ARGUMENT`),zo=X(ao,e=>{let t=e.title?.trim();return Bo({...Lo({...e,title:t===void 0||t.length===0?void 0:t}),contractVersion:2})},`INVALID_ARGUMENT`),Bo=X(io,e=>Z({...Lo(e),contractVersion:2}),`INVALID_ARGUMENT`),Vo=X(oo,e=>e.kind===`action`?Z({...e}):Z(e.siblingId===void 0?{kind:e.kind,crumbId:e.crumbId}:e),`INVALID_ARGUMENT`),Ho=X(so,e=>e===null?null:Z({...e}),`INVALID_ARGUMENT`),Uo=X(lo,e=>Z({agents:Z([...new Set(e.agents??[])]),computers:Z([...new Set(e.computers??[])]),...e.git&&{git:Z([...new Set(e.git)])},...e.workflows&&{workflows:Z([...new Set(e.workflows)])},...e.events&&{events:Z([...new Set(e.events)])},...e.generation&&{generation:Z([...new Set(e.generation)])}}),`INVALID_ARGUMENT`),Wo=X(Ia,e=>e,`INVALID_ARGUMENT`);X(ho,e=>Z(e));var Go=X(J(512),e=>e),Ko=X(fo,e=>Z({...e}),`INVALID_ARGUMENT`);X(m({id:J(160),repeat:y}),e=>Z(e));var qo=X(O(Ba).pipe(S(j(64))),e=>{if(new Set(e.map(e=>e.id)).size!==e.length)throw new b(`Reserved chords are invalid`,{code:`PROTOCOL`,retryable:!1});return Z(e.map(e=>Z({...e})))});function Jo(e){return X(m({value:A,version:Oa}),t=>Z({value:e(t.value),version:t.version}))}var Yo=Jo(Eo),Xo=X(m({capabilities:O(A).pipe(S(j(128))),context:A}),e=>Z({capabilities:Z(e.capabilities.map(e=>ns(e))),context:Yo(e.context)})),Zo=Jo(Ao),Qo=Jo(qo),$o=Jo(Go),es=f(Zo,e=>{if(e.value!==`connected`&&e.value!==`suspended`)throw new b(`The host lifecycle is invalid`,{code:`PROTOCOL`,retryable:!1});return Z({value:e.value,version:e.version})});function ts(e){return X(m({handle:A,id:J(160),version:ka}),t=>{if(!(t.handle instanceof va)&&!(e&&t.handle instanceof ya))throw new b(`A capability handle is invalid`,{code:`PROTOCOL`,retryable:!1});return Z({handle:t.handle,id:t.id,version:t.version})})}var ns=ts(!1),rs=ts(!0);function is(e){let t=e?rs:ns;return X(m({capabilities:O(A).pipe(S(j(128))),context:A,identity:A,lifecycle:A,reservedChords:A,theme:A}),e=>Z({capabilities:Z(e.capabilities.map(e=>t(e))),context:Yo(e.context),identity:ko(e.identity),lifecycle:es(e.lifecycle),reservedChords:Qo(e.reservedChords),theme:$o(e.theme)}))}var as=is(!1);is(!0);function os(e){return X(yo,t=>t.ok?Z({ok:!0,value:e(t.value)}):Z({ok:!1,error:Do(t.error)}))}var ss=os(as),cs=os(X(m({commandId:J(321)}),e=>Z(e)));os(X(Ua,e=>{if(e.status===`failed`)return Z({status:`failed`,error:fs(()=>In(e.error))});let t=e.result===void 0?void 0:Pn(e.result);return Z(t===void 0?{status:`handled`}:{status:`handled`,result:t})}));var ls=os(X(p,()=>void 0)),us=os(X(uo,e=>e)),ds=os(X(La,e=>e));os(X(y,e=>e)),os(X(y,e=>e));function fs(e){try{return e()}catch(e){throw new b(`The command metadata is invalid`,{cause:e,code:`INVALID_ARGUMENT`,retryable:!1})}}var ps=v([m({kind:x(`saveFile`),name:J(255).pipe(S(Le(/^[^\p{Cc}/\\]+$/u))),mime:J(255),bytes:pe}),m({kind:x(`copyText`),text:fe})]);function ms(e){let t=ae(ps,{onExcessProperty:`error`})(e);if(o(t))return{kind:`refused`,reason:`invalid-request`};let n=t.success;return n.kind===`saveFile`?n.name===`.`||n.name===`..`?{kind:`refused`,reason:`invalid-request`}:n.bytes.byteLength>33554432?{kind:`refused`,reason:`too-large`}:{...n,bytes:new Uint8Array(n.bytes)}:n.text.length>1048576||new TextEncoder().encode(n.text).byteLength>1048576?{kind:`refused`,reason:`too-large`}:n}var hs=os(X(v([m({kind:x(`saved`)}),m({kind:x(`copied`)}),m({kind:x(`refused`),reason:u([`no-user-gesture`,`too-large`,`invalid-request`,`unavailable`,`denied`,`busy`])})]),e=>Z(e)));function gs(e){let t=e,n=new Set;return{get:()=>t,subscribe(e){n.add(e);let t=!0;return()=>{t&&(t=!1,n.delete(e))}},update(e){if(!Object.is(t,e)){t=e;for(let e of Array.from(n))try{e(t)}catch(e){console.warn(`App store subscriber failed`,e)}}}}}function _s(e){let t=new Map,n=gs(0),r=!1,i=e=>{let t=new Map;try{for(let n of e){let e=ns(n),r=xs(e.id,e.version);if(t.has(r))throw ys(e.handle),new b(`Duplicate capability grant`,{code:`PROTOCOL`,retryable:!1});t.set(r,e.handle)}}catch(e){for(let e of t.values())ys(e);throw e}return t};for(let[n,r]of i(e))t.set(n,r);let a=e=>{for(let t of e)ys(t)},o=e=>{if(r)throw new b(`The app connection is disposed`,{code:`DISCONNECTED`,retryable:!0});let n=xs(e.id,e.version);return t.get(n)};return{directory:Object.freeze({get version(){return n.get()},subscribe:e=>n.subscribe(e),has(e){return!!o(e)},require(e){let t=o(e);if(!t)throw new b(`The capability is not granted`,{code:`CAPABILITY_DENIED`,retryable:!1});try{return e.schema.parse(t)}catch(e){throw new b(`The capability interface is malformed`,{cause:e,code:`PROTOCOL`,retryable:!1})}}}),replace(e){if(r)throw new b(`The app connection is disposed`,{code:`DISCONNECTED`,retryable:!0});let o=i(e),s=[...t.values()];t.clear();for(let[e,n]of o)t.set(e,n);a(s.filter(e=>![...o.values()].includes(e))),n.update(n.get()+1)},disconnect(){r||(r=!0,a(t.values()),t.clear(),n.update(n.get()+1))}}}var vs=k().transform(e=>{let n=ve(Object).safeParse(e);if(!n.success)return;let r=Object.create(n.data),i=t(m({[Symbol.dispose]:w(Qe(Function))}))(r);return{owner:n.data,dispose:i[Symbol.dispose]}});function ys(e){try{let t=vs.parse(e);if(t===void 0||bs.has(t.owner))return;bs.add(t.owner),t.dispose?.call(t.owner)}catch(e){console.warn(`RPC value disposal failed`,e)}}var bs=new WeakSet;function xs(e,t){return`${e}@${String(t)}`}function Ss(e){let t=(0,F.useCallback)(t=>e?.subscribe(t)??(()=>void 0),[e]),n=(0,F.useCallback)(()=>e?.get(),[e]);return(0,F.useSyncExternalStore)(t,n,n)}function Cs(e){return Ss(e?.context)??null}function ws(e){return Cs(e)?.computerId??null}function Ts(e,t,n,r){let i=(0,F.useRef)(t);i.current=t;let a=(0,F.useRef)(n);a.current=n;let o=(0,F.useRef)(r);o.current=r;let s=JSON.stringify(t),c=n!==void 0;(0,F.useEffect)(()=>{e&&e.ui.reportStatus(i.current).catch(e=>{o.current?o.current(e):console.error(`Window status report failed`,e)})},[e,s]),(0,F.useEffect)(()=>{if(!(!e||!c))return e.ui.onStatusAction(e=>a.current?.(e)??!1)},[e,c]),(0,F.useEffect)(()=>()=>{e?.ui.reportStatus([]).catch(e=>{console.error(`Window status report failed`,e)})},[e])}function Es(e,{sourceId:t,namespace:n},r){let i=(0,F.useMemo)(()=>rr(),[]),a=(0,F.useMemo)(r,[r]);return(0,F.useEffect)(()=>{let e=i.contribute({sourceId:t,namespace:n,commands:a});return()=>{e.dispose()}},[i,t,n,a]),(0,F.useEffect)(()=>e?Zr(e.commands,a):void 0,[e,a]),i}function Ds(e,{canGoBack:t,canGoForward:n,title:r,crumbs:i,primary:a,menu:o,status:s,onBack:c,onForward:l,onCrumb:u,onAction:d}){let f=(0,F.useRef)(c),p=(0,F.useRef)(l),m=(0,F.useRef)(u),h=(0,F.useRef)(d);(0,F.useEffect)(()=>{f.current=c,p.current=l,m.current=u,h.current=d},[c,l,u,d]),(0,F.useEffect)(()=>{if(!e)return;let t=e.onBack(()=>f.current()),n=e.onForward(()=>p.current()),r=e.onActivate(e=>{if(e.kind===`action`){let t=h.current;return t?.(e.actionId),t!==void 0}let t=m.current;return e.siblingId===void 0?t?.(e.crumbId):t?.(e.crumbId,e.siblingId),t!==void 0});return()=>{t(),n(),r(),Os(e,{canGoBack:!1,canGoForward:!1})}},[e]);let g=JSON.stringify([i,a,o,s]),_=(0,F.useRef)({crumbs:i,primary:a,menu:o,status:s});(0,F.useEffect)(()=>{_.current={crumbs:i,primary:a,menu:o,status:s}},[i,a,o,s]),(0,F.useEffect)(()=>{if(!e)return;let i={canGoBack:t,canGoForward:n};r!==void 0&&(i={...i,title:r});let a=_.current;a.crumbs!==void 0&&(i={...i,crumbs:a.crumbs}),a.primary!==void 0&&(i={...i,primary:a.primary}),a.menu!==void 0&&(i={...i,menu:a.menu}),a.status!==void 0&&(i={...i,status:a.status}),Os(e,i)},[e,t,n,r,g])}function Os(e,t){e.publish(t).catch(e=>{e instanceof b&&e.code===`DISCONNECTED`||console.warn(`App navigation report failed`,e)})}var ks=class{id;version;#e;constructor(e,t,n){this.id=e,this.version=t,this.#e=n,Object.freeze(this)}get schema(){return this.#e}};function As(e,t,n){return new ks(e,t,n)}function js(e){let t=M(e),n=ve(Object),r=M(Object.fromEntries(Object.keys(e).map(e=>[e,k().optional()])));return k().transform(e=>{let i=n.parse(e),a=Object.create(i),o=r.parse(a),s=Object.fromEntries(Object.entries(o).map(([e,t])=>[e,he().parse(t).bind(i)]));return{...t.parse(s),[Symbol.dispose](){ys(e)}}})}function Q(e){return k().transform(t=>{try{return e.parse(t)}catch(e){throw e instanceof b?e:new b(`The capability returned malformed data`,{cause:e,code:`PROTOCOL`,retryable:!1})}finally{ys(t)}})}function $(e){return he({output:Ce(k().transform(t=>{try{return e.parse(t)}catch(e){throw ys(t),e instanceof b?e:new b(`The capability returned a malformed result`,{cause:e,code:`PROTOCOL`,retryable:!1})}}))})}var Ms=$(Q(oe()));js({fetch:$(ve(Response)),close:Ms});function Ns(e){return e instanceof b?e:new b(`App operation failed`,{cause:e,code:`HOST_FAILURE`,retryable:!1})}var Ps=new WeakMap,Fs={of(e,...t){return[e?.identity.surfaceId??null,e?.context.get().computerId??null,...t]}};function Is(e){let t={};return e&&Ps.set(t,e),t}function Ls(){let e=new _n({defaultOptions:{queries:{retry:!1,staleTime:3e4,refetchOnWindowFocus:!1},mutations:{retry:!1}}}),t=new Map;return e.getQueryCache().subscribe(n=>{let r=n.query;if(n.type===`removed`){t.get(r.queryHash)?.release(),t.delete(r.queryHash);return}let i=r.meta&&Ps.get(r.meta),a=t.get(r.queryHash);if(a?.app===i||(a?.release(),t.delete(r.queryHash),!i))return;let o=()=>{queueMicrotask(()=>{e.getQueryCache().get(r.queryHash)===r&&t.get(r.queryHash)?.app===i&&e.resetQueries({predicate:e=>e===r})})},s=i.capabilities.subscribe(o);t.set(r.queryHash,{app:i,release:s}),a&&o()}),e}function Rs(e,t,n,r){let i=e?.context.get().computerId;return kn({queryKey:n,meta:Is(e),enabled:e!==null,retry:!1,queryFn:async({signal:n})=>{try{if(!e)throw new b(`No App connection`,{code:`DISCONNECTED`,retryable:!0});if(e.context.get().computerId!==i)throw new b(`The selected Computer changed`,{code:`SELECTION_CHANGED`,retryable:!1});return await r(e.capabilities.require(t),n)}catch(e){throw Ns(e)}}})}var zs=ge(Ee(m({error:x(`too_large`)})));async function Bs(e,n){let r,i=()=>r??=e.close(),a=()=>{i().catch(e=>{Qr(`files.read.abort-close`,e)})};n.signal?.addEventListener(`abort`,a,{once:!0});try{n.signal?.throwIfAborted();let r=await e.response();try{let e=t(Qe(Response))(r);if(e.status===413){let t=zs(await e.text());throw new b(`App file exceeds the read bound`,{code:t._tag===`Some`?`FILE_TOO_LARGE`:`PROTOCOL`,retryable:!1})}if(!e.ok)throw Error(`App file unavailable (${String(e.status)})`);let i=await e.blob();return n.signal?.throwIfAborted(),new File([i],n.name,{type:i.type,lastModified:0})}finally{ys(r)}}finally{n.signal?.removeEventListener(`abort`,a);try{await i()}finally{e[Symbol.dispose]()}}}async function Vs(e,t,n){let r,i=()=>r??=e.close(),a=()=>{i().catch(e=>{Qr(`files.write.abort-close`,e)})};n.signal?.addEventListener(`abort`,a,{once:!0});try{n.signal?.throwIfAborted(),await e.write(t.stream())}finally{n.signal?.removeEventListener(`abort`,a);try{await i()}catch(e){Qr(`files.write.remote-close`,e)}try{e[Symbol.dispose]()}catch(e){Qr(`files.write.local-dispose`,e)}}}var Hs=m({path:fe,entries:O(m({name:fe,type:u([`file`,`directory`,`symlink`]),size:P,modifiedAt:P})),nextOffset:ce(P)}),Us=As(`computer.list`,1,D(()=>js({list:$(Q(k().transform(e=>t(Hs)(e))))}))),Ws=v([m({state:u([`running`,`sleeping`,`starting`,`start_failed`])}),m({state:x(`queued`),position:P.pipe(S(We()),S(Ne(0)))})]),Gs=m({enabled:y,effective:y,blockedBy:ce(u([`team`,`global`]))}),Ks=m({computerId:g,name:g,runtime:Ws,backends:O(m({id:g,kind:u([`platform-container`,`on-box-vm`,`local`]),status:u([`ready`,`queued`,`online`,`offline`]),queuePosition:ce(P.pipe(S(We()),S(Ne(0)))),hostId:ce(fe),hostLabel:ce(fe),folderLabel:ce(fe),detachable:y})),internet:Gs});As(`computer.instrument.read`,1,D(()=>js({read:$(Q(k().transform(e=>t(Ks)(e))))}))),As(`computer.instrument.control`,1,D(()=>js({start:$(Q(k().transform(e=>t(Ws)(e)))),setInternetAccess:$(Q(k().transform(e=>t(Gs)(e)))),detachLocal:$(Q(k().transform(e=>t(m({detached:y}))(e))))})));var qs=m({ports:O(m({port:P.pipe(S(We()),S(Ye({minimum:1,maximum:65535}))),previewUrl:g,openMode:u([`inline`,`external-only`]),expiresAt:P.pipe(S(We()),S(Ne(0)))})).pipe(S(j(64)))}),Js=v([qs,m({error:x(`port_previews_not_configured`)})]),Ys=m({port:P.annotate({message:`Use a port from 1 to 65535.`}).check(We({message:`Use a port from 1 to 65535.`}),Ye({minimum:1,maximum:65535},{message:`Use a port from 1 to 65535.`})),exposed:y}),Xs=m({port:P.pipe(S(We()),S(Ye({minimum:1,maximum:65535}))),removed:y});As(`computer.ports`,2,D(()=>js({list:$(Q(k().transform(e=>t(Js)(e)))),expose:$(Q(k().transform(e=>t(Ys)(e)))),unexpose:$(Q(k().transform(e=>t(Xs)(e))))})));var Zs=u([`synced`,`pending`,`unknown`]),Qs=m({port:ce(Ys.fields.port),id:g,command:g,cwd:ce(fe),startedAt:P.pipe(S(We()),S(be(0))),state:u([`running`,`exited`,`uncertain`]),exitCode:ce(P.pipe(S(We()))),sync:Zs,endedAt:ce(P.pipe(S(We()),S(be(0))))}),$s=m({processes:O(Qs)}),ec=m({process:Qs,signalled:y}),tc=m({process:Qs,lines:O(fe.pipe(S(j(2e3)))).pipe(S(j(200))),truncated:y});m({requestId:g.pipe(S(j(256))),command:g.pipe(S(j(16384))),cwd:E(fe),port:E(Ys.fields.port)}),As(`computer.processes`,1,D(()=>js({start:$(Q(k().transform(e=>t(Qs)(e)))),list:$(Q(k().transform(e=>t($s)(e)))),kill:$(Q(k().transform(e=>t(ec)(e)))),logs:$(Q(k().transform(e=>t(tc)(e))))})));var nc=As(`computer.readFile`,1,D(()=>js({open:$(js({response:$(ve(Response)),close:Ms}))})));async function rc(e,t,n){return await Bs(await e.require(nc).open(t),{...n,name:t.path.split(`/`).at(-1)??`file`})}async function ic(e,n){return t(Hs)(await e.require(Us).list(n))}var ac=As(`computer.writeFile`,3,D(()=>js({open:$(js({write:Ms,close:Ms})),mkdir:Ms,replace:$(Q(k().transform(e=>t(oc)(e))))}))),oc=v([m({kind:x(`replaced`),path:g,bytes:P.pipe(S(We()),S(be(0)))}),m({kind:x(`conflict`)})]);async function sc(e,t,n){n.signal?.throwIfAborted();let r=await e.require(ac).replace(t);if(r.kind===`conflict`)throw new b(`Computer file changed since it was opened`,{code:`CONFLICT`,retryable:!1});return{path:r.path,bytes:r.bytes}}var cc=m({computerName:g.pipe(S(j(256))),teamName:g.pipe(S(j(256))),modelDoor:g.pipe(S(j(256))),uptimeSeconds:P.pipe(S(We()),S(be(0))),version:g.pipe(S(j(64)))});As(`computer.terminal`,2,D(()=>js({open:$(js({information:$(Q(k().transform(e=>t(cc)(e)))),output:$(ve(ReadableStream).transform(e=>e.pipeThrough(new TransformStream({transform(e,t){t.enqueue(ve(Uint8Array).parse(e))}})))),input:$(ve(WritableStream)),resize:Ms,close:Ms}))})));async function lc(e,t,n){await Vs(await e.require(ac).open({path:t.path}),t.content,n)}var uc=ye*10,dc=class{constructor(e={}){let t=!Te(e.bounce)||!Te(e.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/ye,this.maxIterations=this.maxDuration/this.timeStep/ye,this.bn=N(Ze(e.bounce,.5),-1,1),this.pd=N(Ze(e.duration,628),10*je.timeScale,uc*je.timeScale),this.m=N(Ze(e.mass,1),1,uc),this.s=N(Ze(e.stiffness,100),nt,uc),this.d=N(Ze(e.damping,10),nt,uc),this.v=N(Ze(e.velocity,0),-uc,uc),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||it,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?ze(-a*t*n)*(1*we(r*a)+i*Ve(r*a)):t===1?(1+i*a)*ze(-a*n):((1+i)*ze((-t*n+r)*a)+(1-i)*ze((-t*n-r)*a))/2,1-a}calculateSDFromBD(){let e=je.timeScale===1?this.pd/ye:this.pd;this.m=1,this.v=0,this.s=Ae(2*Pe/e,2),this.d=this.bn>=0?(1-this.bn)*4*Pe/e:4*Pe/(e*(1+this.bn)),this.s=qe(N(this.s,nt,uc),3),this.d=qe(N(this.d,nt,300),3)}calculateBDFromSD(){let e=2*Pe/Me(this.s);this.pd=e*(je.timeScale===1?ye:1),this.bn=this.d/(2*Me(this.s))<=1?1-this.d*e/(4*Pe):4*Pe/(this.d*e)-1,this.bn=qe(N(this.bn,-1,1),3),this.pd=qe(N(this.pd,10*je.timeScale,uc*je.timeScale),3)}compute(){let{maxRestSteps:e,maxIterations:t,restThreshold:n,timeStep:r,m:i,d:a,s:o,v:s}=this,c=this.w0=N(Me(o/i),nt,ye),l=this.zeta=a/(2*Me(o*i));l<1?(this.wd=c*Me(1-l*l),this.b=(l*c+-s)/this.wd):l===1?(this.wd=0,this.b=-s+c):(this.wd=c*Me(l*l-1),this.b=(l*c+-s)/this.wd);let u=0,d=0,f=0;for(;d<=e&&f<=t;)xe(1-this.solve(u))<n?d++:d=0,this.solverDuration=u,u+=r,f++;this.settlingDuration=qe(this.solverDuration*ye,0)*je.timeScale}get bounce(){return this.bn}set bounce(e){this.bn=N(Ze(e,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(e){this.pd=N(Ze(e,1),10*je.timeScale,uc*je.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(e){this.s=N(Ze(e,100),nt,uc),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(e){this.d=N(Ze(e,10),nt,uc),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(e){this.m=N(Ze(e,1),1,uc),this.compute()}get velocity(){return this.v}set velocity(e){this.v=N(Ze(e,0),-uc,uc),this.compute()}},fc=e=>new dc(e),pc=(e=10,t)=>{let n=t?Ke:tt;return t=>n(N(t,0,1)*e)*(1/e)},mc=Object.freeze({ease:`linear`,duration:0});function hc(e,t){let n=rt(e,t.duration);return n<=0?mc:e.steps>0?{ease:pc(e.steps),duration:n}:{ease:fc({bounce:le(e,t.bounce),duration:n}),duration:n}}function gc(e,t){let n=ue(e,t.duration);return{ease:e.steps>0?pc(e.steps):t.ease,duration:n}}var _c={dot:{y:-4,height:8,cy:0},pill:{y:-16,height:32,cy:0},bang:{y:-16,height:20,cy:12}};function vc({className:e,glyph:t,motion:r}){let i=`caps-status-${(0,F.useId)().replaceAll(`:`,``)}`,a=(0,F.useRef)(null),o=(0,F.useRef)(null),l=(0,F.useRef)(null),u=(0,F.useRef)(null),d=(0,F.useRef)(null),f=(0,F.useRef)(null),p=(0,F.useRef)(_c[t]).current,m=(0,F.useRef)(t===`dot`?1:4).current,h=(0,F.useRef)(+(t===`bang`)).current,g=(0,F.useRef)(t),_=s(u),{reduced:v}=_;return(0,F.useLayoutEffect)(()=>{if(!a.current||!o.current||!d.current||!f.current)return;let e=_c[t],n=v||g.current===t;g.current=t;let r=c(a.current),i=n?{duration:0}:hc(r,{bounce:.3,duration:360}),s=Ue(a.current,{y:e.y,height:e.height,...i}),l=Ue(o.current,{cy:e.cy,...n?{duration:0}:{delay:ue(r,35),...hc(r,{bounce:.3,duration:420})}}),u=Ue(d.current,{gradientTransform:`matrix(1 0 0 ${t===`dot`?`1`:`4`} 0 0)`,...i}),p=Ue(f.current,{opacity:+(t===`bang`),...n?mc:gc(r,{ease:`inOutSine`,duration:220})});return()=>{s.cancel(),l.cancel(),u.cancel(),p.cancel()}},[t,v]),(0,F.useLayoutEffect)(()=>{if(!l.current||!u.current||v||r===`none`)return;let e=r===`pulse`?Ue(l.current,{opacity:[1,.45],...gc(_,{ease:`inOutSine`,duration:750}),alternate:!0,loop:!0}):Ue(l.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}},...gc(_,{ease:`inOutSine`,duration:1e3}),loop:!0}),t=me(u.current,t=>{t?e.resume():e.pause()});return()=>{t(),e.revert()}},[r,v,_]),(0,I.jsxs)(`svg`,{ref:u,"aria-hidden":`true`,className:`caps-status-bead ${e??``}`,width:`8`,height:`8`,viewBox:`-4 -4 8 8`,focusable:`false`,children:[(0,I.jsxs)(`defs`,{children:[(0,I.jsx)(_e,{id:i,values:$e}),(0,I.jsx)(Oe,{ref:d,id:`${i}-surface`,transform:`matrix(1 0 0 ${String(m)} 0 0)`}),(0,I.jsxs)(`radialGradient`,{id:`${i}-drop-light`,gradientUnits:`userSpaceOnUse`,cx:`-1.2`,cy:`10.4`,r:`5.6`,children:[(0,I.jsx)(`stop`,{offset:`0`,stopColor:`var(--color-white)`,style:{stopOpacity:`calc(var(--depth) * 0.5)`}}),(0,I.jsx)(`stop`,{offset:`1`,stopColor:`var(--color-white)`,stopOpacity:`0`})]}),(0,I.jsx)(n,{id:`${i}-shadow`}),(0,I.jsx)(`mask`,{id:`${i}-silhouette`,maskUnits:`userSpaceOnUse`,x:`-12`,y:`-24`,width:`24`,height:`48`,style:{maskType:`alpha`},children:(0,I.jsxs)(`g`,{fill:`var(--color-white)`,filter:`url(#${i})`,children:[(0,I.jsx)(`rect`,{ref:a,x:`-4`,y:p.y,width:`8`,height:p.height,rx:`4`}),(0,I.jsx)(`circle`,{ref:o,cx:`0`,cy:p.cy,r:`4`})]})})]}),(0,I.jsx)(`g`,{ref:l,filter:`url(#${i}-shadow)`,children:(0,I.jsxs)(`g`,{mask:`url(#${i}-silhouette)`,children:[(0,I.jsx)(`rect`,{x:`-12`,y:`-24`,width:`24`,height:`48`,fill:`url(#${i}-surface)`}),(0,I.jsx)(`rect`,{ref:f,x:`-12`,y:`-24`,width:`24`,height:`48`,fill:`url(#${i}-drop-light)`,opacity:h})]})})]})}var yc=.28;function bc(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?yc: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 xc=7.25;function Sc({className:e,glyph:t,progress:n}){let r=`caps-status-mark-${(0,F.useId)().replaceAll(`:`,``)}`,i=(0,F.useRef)(null),a=(0,F.useRef)(null),o=(0,F.useRef)(null),s=(0,F.useRef)(null),l=(0,F.useRef)(null),u=(0,F.useRef)(null),d=(0,F.useRef)(null),f=(0,F.useRef)(null),p=(0,F.useRef)(bc(t,n)).current,m=(0,F.useRef)(t),h=ie();(0,F.useLayoutEffect)(()=>{let e=i.current,r=a.current,l=o.current,p=s.current,g=u.current,_=d.current,v=f.current;if(!e||!r||!l||!p||!g||!_||!v)return;let ee=bc(t,n),te=m.current;m.current=t;let y=c(e),b=h||te===t&&t!==`arc`,ne=b?h?{ease:y.ease,duration:y.fast}:mc:gc(y,{ease:`outQuad`,duration:160}),re=(t===`check`||t===`cross`)&&!b,ie=gc(y,{ease:`inOutSine`,duration:220}),x=[Ue(r,{opacity:ee.dashes,...ne}),Ue(l,{opacity:ee.track*.28,...ne}),Ue(p,{opacity:ee.arc,"stroke-dasharray":`${String(ee.sweep)} 1`,...b?h?mc:ne:ie}),Ue(g,{r:ee.disc*xc,...re?{delay:ie.duration*.7,...hc(y,{bounce:.35,duration:360})}:h?mc:gc(y,{ease:`inCubic`,duration:140})}),Ue(_,{"stroke-dashoffset":1-ee.tick,...re&&ee.tick>0?{delay:ie.duration*.7+y.fast,...gc(y,{ease:`outCubic`,duration:240})}:mc}),Ue(v,{"stroke-dashoffset":1-ee.cross,...re&&ee.cross>0?{delay:ie.duration*.7+y.fast,...gc(y,{ease:`outCubic`,duration:240})}:mc})];return t===`cross`&&re&&y.shake>0&&x.push(Ue(e,{translateX:[0,-y.shake,y.shake,-y.shake/2,0],delay:ie.duration+y.fast,...gc(y,{ease:`linear`,duration:300})})),()=>{for(let e of x)e.cancel()}},[t,n,h]);let g=t===`arc`&&n===void 0&&!h;return(0,F.useLayoutEffect)(()=>{if(!g||!l.current||!i.current)return;let e=c(i.current),t=Ue(l.current,{rotate:[0,360],...gc(e,{ease:`linear`,duration:900}),loop:!0}),n=me(i.current,e=>{e?t.resume():t.pause()});return()=>{n(),t.revert()}},[g]),(0,I.jsxs)(`svg`,{ref:i,"aria-hidden":`true`,className:`caps-status-mark ${e??``}`,viewBox:`0 0 16 16`,focusable:`false`,children:[(0,I.jsxs)(`defs`,{children:[(0,I.jsx)(Oe,{id:`${r}-surface`,transform:`matrix(1.6 0 0 1.6 8 8)`}),(0,I.jsxs)(`mask`,{id:`${r}-knock`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`16`,height:`16`,children:[(0,I.jsx)(`rect`,{width:`16`,height:`16`,fill:`var(--color-white)`}),(0,I.jsx)(`path`,{ref:d,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-p.tick}),(0,I.jsx)(`path`,{ref:f,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-p.cross})]})]}),(0,I.jsx)(`circle`,{ref:a,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeDasharray:`1.7 2.2`,opacity:p.dashes}),(0,I.jsx)(`circle`,{ref:o,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:p.track*.28}),(0,I.jsx)(`g`,{ref:l,className:`caps-status-mark-spin`,children:(0,I.jsx)(`circle`,{ref:s,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,pathLength:1,strokeDasharray:`${String(p.sweep)} 1`,transform:`rotate(-90 8 8)`,opacity:p.arc})}),(0,I.jsx)(`circle`,{ref:u,cx:`8`,cy:`8`,r:p.disc*xc,fill:`url(#${r}-surface)`,mask:`url(#${r}-knock)`})]})}var Cc=new Set([`ring`,`arc`,`check`,`cross`]);function wc(e){return Cc.has(e)}var Tc={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`},Ec=(0,F.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,I.jsxs)(`span`,{...c,className:Ie(`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:[wc(n)?(0,I.jsx)(Sc,{className:Tc[i],glyph:n,progress:s}):(0,I.jsx)(vc,{className:Tc[i],glyph:n,motion:r}),t===void 0?null:(0,I.jsx)(`span`,{children:t})]})}),Dc=(0,F.forwardRef)(function({className:e,count:t,density:n=`row`,dismissAriaLabel:r,dismissLabel:i=`Dismiss`,message:a,onDismiss:o,onRetry:s,retryAriaLabel:c,retryLabel:l=`Retry`,role:u=`status`,...d},f){return(0,I.jsxs)(`div`,{...d,className:Ie(`caps-failure-line`,e),"data-density":n,ref:f,role:u,children:[(0,I.jsx)(Ec,{glyph:`dot`,tone:`error`}),(0,I.jsxs)(`span`,{className:`caps-failure-line-copy`,children:[(0,I.jsx)(`span`,{children:a}),t!==void 0&&t>1?(0,I.jsxs)(`span`,{className:`caps-failure-line-count`,children:[`Failed `,t,` times`]}):null]}),s||o?(0,I.jsxs)(`span`,{className:`caps-failure-line-actions`,children:[s?(0,I.jsx)(_,{"aria-label":c,size:`sm`,variant:`outline`,onClick:s,children:l}):null,o?(0,I.jsx)(_,{"aria-label":r,size:`sm`,variant:`ghost`,onClick:o,children:i}):null]}):null]})});function Oc(e){return e.type===`directory`&&e.name.startsWith(`.`)}function kc(e,t,n=0){return Rs(e,Us,Fs.of(e,`tree`,e?.capabilities.version??0,t,n),async(e,r)=>{let i=await e.list({path:t,offset:n,limit:256});return r.throwIfAborted(),{...i,entries:i.entries.filter(e=>!Oc(e))}})}var Ac=Je(`FilePlus2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M3 15h6`,key:`4e2qda`}],[`path`,{d:`M6 12v6`,key:`1u72j0`}]]),jc=Je(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]);export{cs as $,bo as A,L as At,Eo as B,Cs as C,Tn as Ct,_s as D,on as Dt,Ts as E,yn as Et,xo as F,lt as Ft,ko as G,Jo as H,So as I,Vo as J,Ao as K,Co as L,ss as M,Ot as Mt,ms as N,pt as Nt,ys as O,z as Ot,hs as P,ft as Pt,Uo as Q,wo as R,Es as S,Cn as St,Ds as T,Sn as Tt,Oo as U,Do as V,Xo as W,zo as X,Ro as Y,us as Z,Q as _,In as _t,Ec as a,Go as at,Ms as b,On as bt,hc as c,Ta as ct,ic as d,Sa as dt,qo as et,rc as f,va as ft,Fs as g,tr as gt,Ls as h,Qr as ht,Dc as i,jo as it,Ho as j,Dt as jt,gs as k,Ht as kt,Us as l,wa as lt,lc as m,ba as mt,Ac as n,ds as nt,mc as o,Ko as ot,sc as p,ya as pt,No as q,kc as r,Mo as rt,gc as s,ls as st,jc as t,Wo as tt,ac as u,Ca as ut,js as v,Pn as vt,ws as w,wn as wt,As as x,Dn as xt,$ as y,En as yt,To as z};
|