@fungi.computer/prints 0.14.2 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1268 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./print-download-button-CW13fNbe.js","./rolldown-runtime-hePW80VL.js","./log-event-DzW_bfP7.js","./modules-C4mfDnjH.js","./local-images-C8BsGPrp.js","./print-info-drawer-Ci9I_Ml8.js","./print-cost-DZGIECAo.js"])))=>i.map(i=>d[i]);
2
- import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{$ as n,$n as r,$r as i,$t as a,A as o,Ar as s,At as c,B as l,Bn as u,Br as d,C as f,Cn as p,Cr as m,Ct as h,Dn as g,Dr as _,Dt as v,E as y,En as b,Er as x,Et as S,F as C,Fn as w,Fr as T,G as E,Gn as D,Gr as O,H as k,Hn as A,Hr as j,I as M,Ir as ee,J as N,Jn as P,Jr as te,K as ne,Kn as F,Kr as re,L as ie,Ln as I,Lr as L,M as ae,Mn as oe,Mr as se,Mt as ce,N as le,Nn as R,Nr as ue,O as de,On as fe,Or as pe,Ot as z,P as B,Pn as V,Pr as me,Q as he,Qn as ge,Qr as _e,R as ve,Rr as ye,S as H,Sn as be,Sr as xe,St as Se,T as Ce,Tn as we,Tr as Te,Tt as Ee,U as De,Un as Oe,V as ke,Vr as Ae,Vt as je,W as Me,Wn as Ne,Wr as Pe,X as Fe,Xn as Ie,Y as Le,Yn as Re,Yr as ze,Z as Be,Zn as Ve,Zr as U,_ as W,_i as He,_n as Ue,_r as We,_t as Ge,a as Ke,ai as qe,ar as Je,at as Ye,b as Xe,bn as Ze,br as Qe,bt as $e,c as et,ci as tt,cr as nt,ct as rt,d as it,di as at,dn as ot,dr as st,dt as ct,ei as lt,er as ut,et as dt,f as ft,fi as pt,fn as G,ft as mt,g as ht,gi as gt,gn as _t,gr as vt,gt as yt,h as bt,hi as xt,hn as St,ht as Ct,i as wt,ii as Tt,in as Et,ir as Dt,it as Ot,j as kt,jn as At,jr as jt,jt as Mt,kn as Nt,kr as Pt,kt as Ft,li as It,ln as Lt,lr as Rt,lt as zt,m as Bt,mi as Vt,mn as Ht,mt as Ut,ni as Wt,nn as Gt,nr as Kt,nt as qt,oi as Jt,or as Yt,ot as Xt,p as Zt,pi as Qt,pn as $t,pt as en,q as tn,qr as nn,r as rn,ri as an,rr as on,rt as sn,si as cn,sr as ln,st as un,t as dn,ti as K,tr as fn,tt as pn,u as mn,ui as hn,un as gn,ur as _n,ut as vn,v as yn,vn as bn,vr as xn,vt as Sn,w as Cn,wn,wr as Tn,wt as En,x as Dn,xn as On,xr as kn,xt as An,y as jn,yn as Mn,yr as Nn,yt as Pn,z as Fn,zn as In,zr as Ln,zt as Rn}from"./log-event-DzW_bfP7.js";import{$ as zn,$t as Bn,A as Vn,At as Hn,B as Un,Bt as Wn,C as Gn,Ct as Kn,D as qn,Dt as Jn,E as Yn,Et as Xn,F as Zn,Ft as Qn,G as $n,Gt as er,Ht as tr,I as nr,It as rr,J as ir,Jt as ar,K as or,Kt as sr,L as cr,Lt as lr,M as ur,Mt as dr,N as fr,Nt as pr,O as mr,Ot as hr,P as gr,Pt as _r,Q as vr,Qt as yr,R as br,Rt as xr,S as Sr,St as Cr,T as wr,Tt as Tr,Ut as Er,V as Dr,Vt as Or,W as kr,Wt as Ar,X as jr,Xt as Mr,Y as Nr,Yt as Pr,Z as Fr,Zt as Ir,_ as Lr,_t as Rr,a as zr,at as Br,b as Vr,bt as Hr,c as Ur,ct as Wr,d as Gr,dt as Kr,et as qr,f as Jr,ft as Yr,g as Xr,gt as Zr,h as Qr,ht as $r,it as ei,j as ti,jt as ni,k as ri,kt as ii,lt as ai,m as oi,mt as si,nt as ci,o as li,ot as ui,p as di,pt as fi,q as pi,qt as mi,r as hi,rt as gi,s as _i,st as vi,t as yi,tt as bi,u as xi,ut as Si,v as Ci,vt as wi,w as Ti,wt as Ei,x as Di,xt as Oi,y as ki,yt as Ai,z as ji,zt as Mi}from"./print-cost-DZGIECAo.js";import{$ as Ni,A as Pi,At as Fi,B as Ii,Bt as Li,C as Ri,D as zi,Dt as Bi,E as Vi,Et as Hi,F as Ui,G as Wi,H as Gi,I as Ki,J as qi,K as Ji,L as Yi,Lt as Xi,M as Zi,Mt as Qi,N as $i,O as ea,Ot as ta,P as na,Q as ra,R as ia,Rt as aa,S as oa,St as sa,T as ca,Tt as la,U as ua,V as da,Vt as fa,W as pa,X as ma,Y as ha,Z as ga,_ as _a,_t as va,a as ya,at as ba,b as xa,c as Sa,ct as Ca,d as wa,dt as Ta,et as Ea,f as Da,ft as Oa,g as ka,gt as Aa,h as ja,ht as Ma,i as Na,it as Pa,j as Fa,jt as Ia,k as La,kt as Ra,l as za,lt as Ba,m as Va,mt as Ha,n as Ua,nt as Wa,o as Ga,ot as Ka,p as qa,pt as Ja,q as Ya,r as Xa,rt as Za,s as Qa,st as $a,t as eo,tt as to,u as no,ut as ro,v as io,vt as ao,w as oo,wt as so,x as co,xt as lo,y as uo,z as fo,zt as po}from"./local-images-C8BsGPrp.js";import{r as mo}from"./modules-C4mfDnjH.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var q=e(He(),1),ho=class extends Error{code;details;constructor(e,t,n){super(t),this.code=e,this.details=n,this.name=`WhistleActionError`}},go=class extends Error{constructor(){super(`Whistle runtime is closed`),this.name=`WhistleClosedError`}};function _o(){let e=!1,t=Xo,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=Xo,s(),o.clear())},contribute:t=>{if(Eo(t),e)throw new go;Do(t,n),Oo(t,n);let r=Symbol(`whistle-contribution`);To(t)||(n=[...n,{contribution:ko(t),generation:r}],i=!0,s());let a=!0;return Jo(o=>{if(!a||e)return;let c={...t,commands:o};Eo(c);let l=n.findIndex(e=>e.generation===r),u=n.filter(e=>e.generation!==r);Do(c,u),Oo(c,u);let d=ko(c);if(To(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=wo(t,n);if(i===void 0)return{status:`missing`};let o;try{let e=Qo(i);if(e.status===`unavailable`)return e;let n=a.at(-1)?.presenter;r.interaction===void 0&&n!==void 0&&vo.has(r.origin)&&(o=n({commandId:Co(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=es(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 Xo;let a=n.flatMap(e=>e.contribution.commands.map(Qo));return(i||a.some((e,t)=>!$o(e,r[t])))&&(t=ts(n,a),r=a,i=!1),t},subscribe:t=>e?()=>void 0:(o.add(t),()=>{o.delete(t)})})}var vo=new Set([`browser`,`keyboard`,`menu`,`palette`,`slash`,`terminal`]),yo=16,bo=32,xo=64,So=256;function Co(e,t){return x.parse(`${e}:${t}`)}function wo(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 To(e){return e.commands.length===0}function Eo(e){Ko(e.sourceId,`source ID`),Ko(e.namespace,`namespace`),e.scope!==void 0&&Ko(e.scope,`scope`);for(let t of e.commands)Vo(t)}function Do(e,t){t.find(t=>t.contribution.namespace===e.namespace&&t.contribution.sourceId!==e.sourceId)!==void 0&&Yo(`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(Co(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=Co(e.namespace,t.id);n.has(i)&&Yo(`Canonical command ID is already registered`),n.add(i);for(let e of t.projections?.slash?.aliases??[])r.has(e)&&Yo(`Slash alias is already registered`),r.add(e)}}function Oo(e,t){t.length>=xo&&Yo(`Live contribution capacity exceeded`),t.reduce((e,t)=>e+t.contribution.commands.length,0)+e.commands.length>So&&Yo(`Live command capacity exceeded`)}function ko(e){let t={sourceId:e.sourceId,namespace:e.namespace,commands:e.commands.map(Ao)};return e.scope===void 0?t:{...t,scope:e.scope}}function Ao(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=jo(e.action)),e.availability!==void 0&&(t.availability=e.availability),e.projections!==void 0&&(t.projections=Fo(e.projections)),t}function jo(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=Mo(e.inputSchema)),e.outputSchema!==void 0&&(t.outputSchema=Mo(e.outputSchema)),e.presentation!==void 0&&(t.presentation=Po(e.presentation)),Object.freeze(t)}function Mo(e){return Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,No(t)])))}function No(e){return Array.isArray(e)?Object.freeze(e.map(No)):e!==null&&e instanceof Object?Object.freeze(Object.fromEntries(Object.entries(e).map(([e,t])=>[e,No(t)]))):e}function Po(e){switch(e.type){case`action`:return Object.freeze({type:`action`});case`custom`:return Object.freeze({type:`custom`,data:Mo(e.data)});case`choice`:return Object.freeze({type:`choice`,options:Object.freeze(e.options.map(e=>Object.freeze({...e,value:No(e.value)})))});case`form`:return Object.freeze({...e});case`confirmation`:return Object.freeze({...e})}}function Fo(e){let t={};return e.bindings!==void 0&&(t.bindings=Io(e.bindings)),e.agent!==void 0&&(t.agent=Lo(e.agent)),e.help!==void 0&&(t.help=Ro(e.help.order)),e.menu!==void 0&&(t.menu=Ro(e.menu.order)),e.palette!==void 0&&(t.palette=Ro(e.palette.order)),e.slash!==void 0&&(t.slash=zo(e.slash)),t}function Io(e){let t={values:[...e.values]};return e.order!==void 0&&(t.order=e.order),t}function Lo(e){let t={};return e.keybind!==void 0&&(t.keybind=e.keybind),e.order!==void 0&&(t.order=e.order),t}function Ro(e){let t={};return e!==void 0&&(t.order=e),t}function zo(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=Bo(e.arguments)),t}function Bo(e){let t={hint:e.hint};return e.words!==void 0&&(t.words=Object.freeze(e.words.map(e=>Object.freeze({...e,arguments:Mo(e.arguments)})))),e.text!==void 0&&(t.text=Object.freeze({...e.text,arguments:Mo(e.text.arguments)})),Object.freeze(t)}function Vo(e){Ko(e.id,`command ID`,!0),Ko(e.title,`title`),Ko(e.category,`category`),Ho(e.action),Uo(e.projections)}function Ho(e){if(e?.presentation!==void 0)switch(e.presentation.type){case`action`:case`custom`:return;case`choice`:for(let t of e.presentation.options)Ko(t.label,`choice label`),t.description!==void 0&&Ko(t.description,`choice description`);return;case`form`:e.presentation.submitLabel!==void 0&&Ko(e.presentation.submitLabel,`submit label`);return;case`confirmation`:Ko(e.presentation.message,`confirmation message`),e.presentation.confirmLabel!==void 0&&Ko(e.presentation.confirmLabel,`confirmation label`),e.presentation.cancelLabel!==void 0&&Ko(e.presentation.cancelLabel,`cancellation label`)}}function Uo(e){if(e!==void 0){for(let t of[e.bindings,e.palette,e.slash,e.help,e.menu,e.agent])t!==void 0&&qo(t.order);if(e.bindings!==void 0&&Go(e.bindings.values,`binding`),e.slash!==void 0){Go(e.slash.aliases,`slash alias`);for(let t of e.slash.aliases)/\s/u.test(t)&&Yo(`slash alias must not contain whitespace`);Wo(e.slash.arguments)}e.agent?.keybind!==void 0&&Ko(e.agent.keybind,`agent keybind`)}}function Wo(e){if(e===void 0)return;Ko(e.hint,`argument hint`),e.words===void 0&&e.text===void 0&&Yo(`slash arguments need words or text`);let t=new Set;for(let n of e.words??[])Ko(n.word,`argument word`),/\s/u.test(n.word)&&Yo(`argument word must not contain whitespace`),t.has(n.word)&&Yo(`argument word is repeated`),t.add(n.word),n.description!==void 0&&Ko(n.description,`argument word description`);t.size>bo&&Yo(`argument word count exceeds 32`),e.text!==void 0&&(Ko(e.text.field,`argument text field`),e.text.requestIdField!==void 0&&Ko(e.text.requestIdField,`request id field`))}function Go(e,t){e.length>yo&&Yo(`${t} count exceeds 16`);for(let n of e)Ko(n,t)}function Ko(e,t,n=!1){e.trim().length===0&&Yo(`${t} must not be blank`),n&&e.includes(`:`)&&Yo(`${t} must not contain a colon`)}function qo(e){e!==void 0&&!Number.isSafeInteger(e)&&Yo(`order must be a safe integer`)}function Jo(e=()=>void 0,t=()=>void 0){return Object.freeze({update:e,dispose:t})}function Yo(e){throw Error(e)}var Xo=Object.freeze({bindings:Object.freeze([]),palette:Object.freeze([]),slash:Object.freeze([]),help:Object.freeze([]),menu:Object.freeze([]),agent:Object.freeze([])}),Zo=Object.freeze({status:`available`});function Qo(e){let t=e.availability?.()??Zo;return t.status===`available`?Zo:Object.freeze({status:`unavailable`,reason:t.reason})}function $o(e,t){return e.status===`available`?t?.status===`available`:t?.status===`unavailable`&&e.reason===t.reason}function es(e){if(e instanceof ho){let t={code:e.code,message:e.message};return Object.freeze(e.details===void 0?t:{...t,details:No(e.details)})}return Object.freeze({code:`command_failed`,message:e.message})}function ts(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++]??Zo;if(u?.bindings!==void 0)for(let t of u.bindings.values)n.push({...cs(e,l,u.bindings.order,d),binding:t});if(u?.palette!==void 0&&r.push({...cs(e,l,u.palette.order,d)}),u?.slash!==void 0)for(let t of u.slash.aliases){let n={...cs(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({...cs(e,l,u.help.order,d)}),u?.menu!==void 0&&o.push({...cs(e,l,u.menu.order,d)}),u?.agent!==void 0&&s.push(us(e,l,u.agent,d))}}return as(n),os(i),is(r),is(a),is(o),is(s),Object.freeze({bindings:ss(n),palette:ss(r),slash:ss(i),help:ss(a),menu:ss(o),agent:ss(s)})}var ns=new TextEncoder;function rs(e,t){let n=ns.encode(e),r=ns.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 is(e){e.sort((e,t)=>e.order-t.order||rs(e.commandId,t.commandId))}function as(e){e.sort((e,t)=>e.order-t.order||rs(e.commandId,t.commandId)||rs(e.binding,t.binding))}function os(e){e.sort((e,t)=>e.order-t.order||rs(e.commandId,t.commandId)||rs(e.alias,t.alias))}function ss(e){return Object.freeze(e.map(e=>Object.freeze(e)))}function cs(e,t,n,r){let i=ls(e,t,n,r);return e.scope===void 0?i:{...i,scope:e.scope}}function ls(e,t,n,r){let i={commandId:Co(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 us(e,t,n,r){let i=cs(e,t,n.order,r),a=i.action===void 0?i:{...i,action:ds(i.action)};return n.keybind===void 0?a:{...a,keybind:n.keybind}}function ds(e){let t={};return e.inputSchema!==void 0&&(t.inputSchema=e.inputSchema),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),Object.freeze(t)}var fs=new WeakMap;function ps(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=fs.get(e)??new Map;fs.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:pe(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()}}}j(`light.dark.latte.mocha.readout.readout-night.field-guide.field-guide-night.embed.embed-dark.phosphor.codec.paper.ember.tide.tape.sunrise.pirate-radio.pirate-radio-night.consulting.consulting-ink.consulting-night.consulting-night-ink.consulting-riso-latte.consulting-riso-latte-ink.consulting-riso-glomzy.consulting-riso-glomzy-ink.vishnu.coin.coin-night.chamfer`.split(`.`));var ms=`data-theme`;function hs(e){return e||(globalThis.document?.documentElement??null)}function gs(e){let t=e.trim();if(t.length===0)throw TypeError(`Theme must be a non-empty string`);return t}function _s(e,t){let n=gs(e),r=hs(t);r&&r.setAttribute(ms,n)}function vs(e){return hs(e)?.getAttribute(ms)??null}var ys=class extends Ir{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:yr(t,n.data),hasPreviousPage:Bn(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function bs(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}var xs=class extends je{#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,Rn.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||!Et(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(bs(e,n).forEach(e=>{e.destroy()}),bs(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=Gt(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 Ir(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)&&Rn.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}};function Ss({queries:e,...t},n){let r=gn(n),i=Mr(),o=Pr(),s=t.subscribed!==!1,c=q.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:s?`optimistic`:void 0,t}),[e,r,i,s]);c.forEach(e=>{Er(e);let t=r.getQueryCache().get(e.queryHash);sr(e,o,t)}),ar(o);let[l]=q.useState(()=>new xs(r,c,t)),[u,d,f]=l.getOptimisticResult(c,t.combine),p=!i&&s;q.useSyncExternalStore(q.useCallback(e=>p?l.subscribe(Rn.batchCalls(e)):a,[l,p]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),q.useEffect(()=>{l.setQueries(c,t)},[c,t,l]);let m=u.some((e,t)=>er(c[t],e))?u.flatMap((e,t)=>{let n=c[t];if(n&&er(n,e)){let e=new Ir(r,n);return Ar(n,e,o)}return[]}):[];if(m.length>0)throw Promise.all(m);let h=u.find((e,t)=>{let n=c[t];return n&&mi({result:e,errorResetBoundary:o,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(h)throw h.error;return d(f())}function Cs(e){return e}function ws(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function Ts(e={},t){let n=gn(t).getMutationCache(),r=q.useRef(e),i=q.useRef(null);return i.current===null&&(i.current=ws(n,e)),q.useEffect(()=>{r.current=e}),q.useSyncExternalStore(q.useCallback(e=>n.subscribe(()=>{let t=Gt(i.current,ws(n,r.current));i.current!==t&&(i.current=t,Rn.schedule(e))}),[n]),()=>i.current,()=>i.current)}function Es(e,t){return tr(e,ys,t)}var Ds=t((e=>{var t=Mt();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot}))();function Os(e){let t=e.trim().toLowerCase();if(!t)throw Error(`Invalid keymap token: token cannot be empty`);return t}function ks(e){let t=e.trim().toLowerCase();if(!t)throw Error(`Invalid key name: key name cannot be empty`);return t}function As(e){return{name:ks(e.name),ctrl:e.ctrl??!1,shift:e.shift??!1,meta:e.meta??!1,super:e.super??!1,hyper:e.hyper||void 0}}function js(e){return{name:e.name,ctrl:e.ctrl,shift:e.shift,meta:e.meta,super:e.super,hyper:e.hyper||void 0}}function Ms(e,t){let n=js(As(e));return{stroke:n,display:t?.display??Bs(n),match:t?.match??Is(n),tokenName:t?.tokenName?Os(t.tokenName):void 0}}function Ns(e){return{stroke:js(e.stroke),display:e.display,match:e.match,tokenName:e.tokenName,patternName:e.patternName,payloadKey:e.payloadKey}}function Ps(e){return e.map(e=>Ns(e))}function Fs(e){return`match`in e?e.match:`stroke`in e?Is(e.stroke):Is(e)}function Is(e){return`key:${Vs(As(e))}`}function Ls(e){let t=e.trim();if(!t)throw Error(`Invalid keymap match id: id cannot be empty`);return`text:${t}`}function Rs(e,t){return`stroke`in e?t?.preferDisplay&&e.display?e.display:Bs(e.stroke):Bs(As(e))}function zs(e,t){return e.map(e=>Rs(e,t)).join(t?.separator??``)}function Bs(e){let t=[];return e.ctrl&&t.push(`ctrl`),e.shift&&t.push(`shift`),e.meta&&t.push(`meta`),e.super&&t.push(`super`),e.hyper&&t.push(`hyper`),t.push(e.name===`return`?`enter`:e.name),t.join(`+`)}function Vs(e){return`${e.name}:${+!!e.ctrl}:${+!!e.shift}:${+!!e.meta}:${+!!e.super}:${+!!e.hyper}`}var Hs=Symbol(`keymap-extension-context`);function Us(e){return e.isDestroyed?null:e.getFocusedTarget()}function Ws(e,t,n){let r=t??e.rootTarget,i=t!==null;for(;r;){if(n(r,i)===!1)return;r=e.getParentTarget(r),i=!1}}function Gs(e,t){let n=new Set;return Ws(e,t,e=>{n.add(e)}),n}function Ks(e,t,n){let r=[],i=Gs(t,n),a=Array.isArray(e)?e:qs(e);for(let e of a)Js(t,e,n,i)&&r.push(e);return r}function qs(e){return[...e].sort((e,t)=>t.priority-e.priority||t.order-e.order)}function Js(e,t,n,r=Gs(e,n)){let i=t.target;return i?e.isTargetDestroyed(i)?!1:t.targetMode===`focus`?i===n:r.has(i):!0}function Ys(e){let t=e.binding.sequence[e.index];if(!t?.patternName)return 0;let n=e.patterns?.at(-1);return n?.name===t.patternName?n.values.length:0}function Xs(e,t,n=!0){let r=e.binding.sequence[e.index];if(!r?.patternName)return!0;let i=t.get(r.patternName);return i?Ys(e)>=i.min:n}function Zs(e,t,n=!0){let r=e.binding.sequence[e.index];if(r?.patternName){let n=t.get(r.patternName);if(n&&Ys(e)<n.max)return!0}return Xs(e,t,n)&&e.index+1<e.binding.sequence.length}function Qs(e,t){return e.index===e.binding.sequence.length-1&&Xs(e,t,!1)}function $s(e,t,n,r){return{parent:e,depth:e?e.depth+1:0,stroke:t,match:n,pattern:r,children:new Map,patternChildren:[],bindings:[],reachableBindings:[]}}function ec(e,t){let n=$s(null,null,null);for(let r of e){if(r.event!==`press`)continue;let e=n;for(let n of r.sequence){let i;if(n.patternName){let r=t.get(n.patternName);i=e.patternChildren.find(e=>e.pattern?.name===n.patternName),i||(i=$s(e,n.stroke,n.match,r),e.patternChildren.push(i))}else i=e.children.get(n.match),i||(i=$s(e,n.stroke,n.match),e.children.set(n.match,i));i.reachableBindings.push(r),e=i}e.bindings.push(r)}return n}function tc(e,t){let n=[];for(let r of e){if(!Xs(r,t))continue;let e=r.index+1,i=r.binding.sequence[e];i&&n.push({part:i,binding:r.binding,index:e,exact:e===r.binding.sequence.length-1,continues:e<r.binding.sequence.length-1})}return n}function nc(e,t,n,r){let i=n.patternName;if(!i)return{...e,index:t};let a=[...e.patterns??[]],o=a.at(-1);return o?.name===i?a[a.length-1]={...o,values:[...o.values,r],parts:[...o.parts,n]}:a.push({name:i,payloadKey:n.payloadKey??i,values:[r],parts:[n]}),{layer:e.layer,binding:e.binding,index:t,parts:[...e.parts,n],patterns:a}}function rc(e,t){let n=e.parts.at(-1);if(!n||n.patternName)return t.length;let r=t.indexOf(n.match);return r===-1?t.length:r}function ic(e,t,n,r,i,a,o,s,c){let l=t.sequence[n];if(l){if(l.patternName){let a=s(l.patternName,o);if(!a)return;let u=c(o,l.patternName,a);return nc({layer:e,binding:t,index:n,parts:r,patterns:i},n,u,a.value??o.name)}if(a.includes(l.match))return{layer:e,binding:t,index:n,parts:[...r,l],patterns:i}}}function ac(e,t,n,r,i,a){let o=e.binding.sequence[e.index];if(o?.patternName){let s=r.get(o.patternName);if(s&&Ys(e)<s.max){let t=i(s.name,n);if(t){let r=a(n,s.name,t);return nc(e,e.index,r,t.value??n.name)}}return Xs(e,r,!1)?ic(e.layer,e.binding,e.index+1,e.parts,e.patterns,t,n,i,a):void 0}return ic(e.layer,e.binding,e.index+1,e.parts,e.patterns,t,n,i,a)}function oc(e,t,n,r,i){let a=[],o=1/0;for(let s of e.bindings){if(s.event!==`press`)continue;let c=ic(e,s,0,[],void 0,t,n,r,i);if(!c)continue;let l=rc(c,t);l<o&&(o=l,a.length=0),l===o&&a.push(c)}return a}import.meta.require;function sc(e){let t=Object.create(null),n=(e,n)=>{let r=t[e];if(!r)return;let i=r.filter(e=>e!==n);i.length===0?delete t[e]:i.length!==r.length&&(t[e]=i)};return{hook(e,r){return t[e]=[...t[e]??[],r],()=>n(e,r)},has(e){return(t[e]?.length??0)>0},emit(n,...r){let i=t[n];if(i)for(let t of i)try{r.length===0?t():t(r[0])}catch(t){e(n,t)}}}}function cc(){let e=[];return{get:()=>e,set:t=>{e=t},remove(t){e=e.filter(e=>e!==t)},has:()=>e.length>0,clear:()=>{e=[]}}}function lc(){let e=cc();return{append(t){return e.set([...e.get(),t]),()=>e.remove(t)},prepend(t){return e.set([t,...e.get()]),()=>e.remove(t)},values:e.get,has:e.has,clear:e.clear}}function uc(){let e=cc(),t=0;return{register(n,r){let i={...r,listener:n,order:t++};return e.set([...e.get(),i].sort((e,t)=>t.priority-e.priority||e.order-t.order)),()=>e.remove(i)},entries:e.get,has:e.has,clear:e.clear}}function dc(e){return typeof e==`string`||!!e&&typeof e==`object`&&!Array.isArray(e)}function fc(e){if(!Array.isArray(e))return{ok:!1,reason:`Invalid keymap bindings: expected an array of binding objects`};for(let[t,n]of e.entries()){if(!n||typeof n!=`object`||Array.isArray(n))return{ok:!1,reason:`Invalid keymap binding at index ${t}: expected a binding object`};if(!dc(n.key))return{ok:!1,reason:`Invalid keymap binding at index ${t}: expected "key" to be a string or keystroke object`}}return{ok:!0}}function pc(e){let t=fc(e);if(!t.ok)throw Error(t.reason);return e.map(e=>({...e,key:typeof e.key==`string`?e.key:{...e.key}}))}function mc(e){return{...e,sequence:Ps(e.sequence)}}function hc(e,t){let n=lc();return{prependLayerAnalyzer(e){return n.prepend(e)},appendLayerAnalyzer(e){return n.append(e)},clearLayerAnalyzers(){n.clear()},analyzeLayer(r){let i=n.values();if(i.length===0)return;let a=gc(r.bindings),o={target:r.target,order:r.order,sourceBindings:r.sourceBindings,bindings:a,hasTokenBindings:r.hasTokenBindings,checkCommandResolution(e){return t.getCommandResolutionStatus(e,r.commands)},warn(t,n,r){e.emitWarning(t,n,r)},warnOnce(t,n,r,i){e.warnOnce(t,n,r,i)},error(t,n,r){e.emitError(t,n,r)}};for(let t of i)try{t(o)}catch(t){e.emitError(`layer-analyzer-error`,t,`[Keymap] Error in layer analyzer:`)}}}}function gc(e){return e.map(t=>({sequence:Ps(t.sequence),command:t.command,attrs:t.attrs,event:t.event,preventDefault:t.preventDefault,fallthrough:t.fallthrough,parsedBinding:mc(t.parsedBinding),sourceTarget:t.sourceTarget,sourceLayerOrder:t.sourceLayerOrder,bindingIndex:t.bindingIndex,hasCommandAtSequence:e.some(e=>e.event===`press`&&e.command!==void 0&&_c(e,t)),hasContinuations:e.some(e=>e.event===`press`&&vc(t,e))}))}function _c(e,t){return e.sequence.length===t.sequence.length&&e.sequence.every((e,n)=>e.match===t.sequence[n]?.match)}function vc(e,t){return e.sequence.length<t.sequence.length&&e.sequence.every((e,n)=>e.match===t.sequence[n]?.match)}function yc(){return{version:-1,notifyVersion:-1,focused:void 0,value:[],targets:new WeakMap}}function bc(){return{plain:yc(),bindings:yc(),metadata:yc(),bindingsAndMetadata:yc()}}function xc(e,t){if(t===void 0)return e.plain;let n=t.includeBindings===!0,r=t.includeMetadata===!0;return n?r?e.bindingsAndMetadata:e.bindings:r?e.metadata:e.plain}function Sc(e,t,n){let r=n?e.targets.get(n):e.nullTarget;return r?.version===t?r:void 0}function Cc(e,t,n,r){let i={version:t,value:r};n?e.targets.set(n,i):e.nullTarget=i}function wc(e,t){if(e===t)return!0;if(!e||!t||e.captures.length!==t.captures.length)return!1;for(let n=0;n<e.captures.length;n+=1){let r=e.captures[n],i=t.captures[n];if(!r||!i||r.layer!==i.layer||r.binding!==i.binding||r.index!==i.index||r.parts.length!==i.parts.length)return!1;for(let e=0;e<r.parts.length;e+=1)if(r.parts[e]?.match!==i.parts[e]?.match)return!1;let a=r.patterns??[],o=i.patterns??[];if(a.length!==o.length)return!1;for(let e=0;e<a.length;e+=1){let t=a[e],n=o[e];if(!t||!n||t.name!==n.name||t.values.length!==n.values.length)return!1;for(let e=0;e<t.values.length;e+=1)if(!Object.is(t.values[e],n.values[e]))return!1}}return!0}function Tc(e){let t=e.parts.at(-1);if(!t||e.parts.length<=1)return;let n=e.index-1,r=e.patterns;if(t.patternName){let i=r?.at(-1);i?.name===t.patternName&&(i.values.length>1?(n=e.index,r=[...(r??[]).slice(0,-1),{...i,values:i.values.slice(0,-1),parts:i.parts.slice(0,-1)}]):r=(r??[]).slice(0,-1))}return{layer:e.layer,binding:e.binding,index:n,parts:e.parts.slice(0,-1),patterns:r}}function Ec(e){let t=e.captures[0];if(!t||t.parts.length===0)return[];let n=[];for(let r=0;r<t.parts.length;r+=1){let i=t.parts[r];if(!i)continue;let a,o,s=!1,c=!1;for(let t of e.captures){let e=t.parts[r];if(e){if(a===void 0){a=e.display,o=e.tokenName;continue}!s&&a!==e.display&&(s=!0),!c&&o!==e.tokenName&&(c=!0)}}(a===void 0||s)&&(a=Rs(i.stroke)),c&&(o=void 0),n.push(Ms(i.stroke,{display:a,match:i.match,tokenName:o}))}return n}function Dc(e){if(e.isDestroyed)throw Error(`Cannot use a keymap after its host was destroyed`);return e}function Oc(e,t,n,r,i,a,o={}){let s=bc(),c=-1,l=[],u=()=>Dc(t).getFocusedTarget(),d=()=>Us(t),f=t=>{let n=e.pending;wc(n,t)||(e.pending=t,o.onPendingSequenceChanged?.(n,t),se(),r.queueStateChange())},p=()=>{let t=e.pending;if(!t)return;let n=u(),r=a.getActiveCommandView(n),o=t.captures.filter(t=>e.layers.has(t.layer)&&C(t.layer,n)&&i.matchesConditions(t.layer)&&D(t.binding,n,r)&&Zs(t,e.patterns));if(o.length===0){f(null);return}return o.length!==t.captures.length&&f({captures:o}),e.pending??void 0},m=()=>{t.isDestroyed||!e.pending||p()},h=()=>!t.isDestroyed&&e.pending!==null,g=()=>{if(c===e.cacheVersion)return l;let t=p(),n=t?Ec(t):[];return(!t||T())&&(c=e.cacheVersion,l=n),n},_=()=>{let e=p();if(!e)return!1;let t=e.captures[0];if(!t||t.parts.length<=1)return f(null),!0;let n=[];for(let t of e.captures){let e=Tc(t);e&&n.push(e)}return n.length===0?(f(null),!0):(f({captures:n}),!0)},v=t=>{let n=t?.includeBindings===!0,r=t?.includeMetadata===!0,i=xc(s,t);return i.notifyVersion===e.derivedVersion?i.value:y(i,n,r)},y=(n,r,i)=>{t.isDestroyed&&Dc(t);let o=u(),s=Sc(n,e.cacheVersion,o);if(s)return n.notifyVersion=e.derivedVersion,n.version=e.cacheVersion,n.focused=o,n.value=s.value,s.value;let c=a.getActiveCommandView(o),l=p(),d=l?[]:S(o),f=l?P(l.captures,r,i,o,c):j(d,r,i,o,c);return(l?T():w(d))&&(n.version=e.cacheVersion,n.notifyVersion=e.derivedVersion,n.focused=o,n.value=f,Cc(n,e.cacheVersion,o,f)),f},b=(e,t)=>{let n=t?.includeBindings===!0,r=t?.includeMetadata===!0,i=u(),o=a.getActiveCommandView(i);return P(e,n,r,i,o)},x=(e,t)=>{let n=t?.includeBindings===!0,r=t?.includeMetadata===!0,i=e===d()?p():void 0,o=a.getActiveCommandView(e);return i?P(i.captures,n,r,e,o):j(S(e),n,r,e,o)},S=n=>e.activeLayersCacheVersion===e.cacheVersion&&e.activeLayersCacheFocused===n?e.activeLayersCache:(e.activeLayersCacheVersion=e.cacheVersion,e.activeLayersCacheFocused=n,e.activeLayersCache=Ks(e.sortedLayers,t,n),e.activeLayersCache),C=(e,n)=>Js(t,e,n),w=t=>!e.commandResolvers.has()&&e.activeKeyCacheBlockers===0,T=()=>!e.commandResolvers.has()&&e.activeKeyCacheBlockers===0,E=(e,t,n)=>{let r=[];for(let o of e)i.matchesConditions(o)&&a.isBindingVisible(o,t,n)&&r.push(o);return r},D=(e,t,n)=>i.matchesConditions(e)&&a.isBindingVisible(e,t,n),O=(e,t)=>{let n,r,i=!1,a=!1;for(let o of e){let e=o.sequence[t];if(e){if(n===void 0){n=e.display,r=e.tokenName;continue}!i&&n!==e.display&&(i=!0),!a&&r!==e.tokenName&&(a=!0)}}if(n===void 0||i){let r=e[0]?.sequence[t]?.stroke;n=r?Rs(r):``}return a&&(r=void 0),{display:n,tokenName:r}},k=(e,t,n)=>({sequence:e.sequence,command:e.command,commandAttrs:a.getBindingCommandAttrs(e,t,n),attrs:e.attrs,event:e.event,preventDefault:e.preventDefault,fallthrough:e.fallthrough}),A=(e,t,n)=>e.map(e=>k(e,t,n)),j=(e,t,n,r,a)=>{let o=new Map,s=new Set;for(let n of e)n.root.children.size===0&&n.root.patternChildren.length===0||!i.matchesConditions(n)||(M(n.root.children.values(),o,s,t,r,a),M(n.root.patternChildren,o,s,t,r,a));return F(o,t,n,r,a)},M=(e,t,n,r,i,a)=>{for(let o of e){let e=o.match;if(!e||n.has(e)||!o.stroke)continue;let s=ee(o,r,i,a);if(!s)continue;let c=t.get(e);c?ae(c,s,r):t.set(e,L(o.stroke,s,r)),s.stop&&n.add(e)}},ee=(e,t,n,r)=>{if(!(e.children.size>0||e.patternChildren.length>0)){let i=I(N(e)?E(e.bindings,n,r):e.bindings,n,r);if(!i)return;let a=O(i.bindings,e.depth-1);return{display:a.display,tokenName:a.tokenName,continues:!1,firstBinding:i.bindings[0],commandBinding:i.commandBinding,bindings:t?[...i.bindings]:void 0,stop:i.stop}}let i=E(e.reachableBindings,n,r);if(i.length===0)return;let a=I(e.bindings,n,r),o=O(i,e.depth-1);return{display:o.display,tokenName:o.tokenName,continues:!0,firstBinding:a?.bindings[0],commandBinding:a?.commandBinding,bindings:t&&a?[...a.bindings]:void 0,stop:!0}},N=t=>{if(e.commandResolvers.has())return!0;for(let e of t.bindings)if(e.matchers.length>0)return!0;return!1},P=(t,n,r,i,a)=>{let o=new Map,s=new Set;return te(tc(t,e.patterns),o,s,n,i,a),F(o,n,r,i,a)},te=(e,t,n,r,i,a)=>{let o=new Set;for(let s of e)o.has(s.part.match)||(o.add(s.part.match),ne(s,e,t,n,r,i,a))},ne=(e,t,n,r,i,a,o)=>{let s=e.part.match;if(r.has(s))return;let c=re(e,t,i,a,o);if(!c)return;let l=n.get(s);l?ae(l,c,i):n.set(s,L(e.part.stroke,c,i)),c.stop&&r.add(s)},F=(e,t,n,r,i)=>{let a=[];for(let o of e.values()){let e=oe(o,t,n,r,i);e&&a.push(e)}return a},re=(e,t,n,r,i)=>{let a=t.filter(t=>t.part.match===e.part.match),o=a.filter(e=>e.exact).map(e=>e.binding),s=I(o,r,i),c=a.some(e=>e.continues);if(!c&&!s)return;let l=ie(a);return{display:l.display,tokenName:l.tokenName,continues:c,firstBinding:s?.bindings[0],commandBinding:s?.commandBinding,bindings:n&&s?[...s.bindings]:void 0,stop:c||s?.stop===!0}},ie=e=>{let t,n,r=!1,i=!1;for(let a of e){let e=a.part;if(t===void 0){t=e.display,n=e.tokenName;continue}!r&&t!==e.display&&(r=!0),!i&&n!==e.tokenName&&(i=!0)}let a=e[0]?.part;return(t===void 0||r)&&(t=a?Rs(a.stroke):``),i&&(n=void 0),{display:t,tokenName:n}},I=(e,t,n)=>{let r=[],o;for(let s of e)if(!(!i.matchesConditions(s)||!a.isBindingVisible(s,t,n))&&(r.push(s),s.command!==void 0&&(o??=s,!s.fallthrough)))return{bindings:r,commandBinding:o,stop:!0};if(r.length!==0)return{bindings:r,commandBinding:o,stop:!1}},L=(e,t,n)=>({stroke:e,display:t.display,tokenName:t.tokenName,continues:t.continues,firstBinding:t.firstBinding,commandBinding:t.commandBinding,bindings:n&&t.bindings?[...t.bindings]:void 0}),ae=(e,t,n)=>{if(!e.firstBinding&&t.firstBinding&&(e.firstBinding=t.firstBinding),!e.commandBinding&&t.commandBinding&&(e.commandBinding=t.commandBinding),t.continues&&(e.continues=!0),!(!n||!t.bindings||t.bindings.length===0)){if(!e.bindings){e.bindings=[...t.bindings];return}e.bindings.push(...t.bindings)}},oe=(e,t,n,r,i)=>{if(!e.commandBinding&&!e.continues)return;let o={stroke:js(e.stroke),display:e.display,continues:e.continues};if(e.tokenName&&(o.tokenName=e.tokenName),e.commandBinding&&(o.command=e.commandBinding.command),t&&e.bindings&&e.bindings.length>0&&(o.bindings=e.bindings.length===1?[k(e.bindings[0],r,i)]:A(e.bindings,r,i)),n){e.firstBinding?.attrs&&(o.bindingAttrs=e.firstBinding.attrs);let t=e.commandBinding?a.getBindingCommandAttrs(e.commandBinding,r,i):void 0;t&&(o.commandAttrs=t)}return o},se=()=>{n.has(`pendingSequence`)&&n.emit(`pendingSequence`,e.pending?Ec(e.pending):[])};return{getFocusedTarget:u,getFocusedTargetIfAvailable:d,setPendingSequence:f,ensureValidPendingSequence:p,revalidatePendingSequenceIfNeeded:m,hasPendingSequenceState:h,getPendingSequence:g,popPendingSequence:_,getActiveKeys:v,getActiveKeysForCaptures:b,getActiveKeysForFocused:x,getActiveLayers:S,isLayerActiveForFocused:C,collectSequencePartsFromPending:Ec,collectMatchingBindings:E,collectActiveBindings:A}}var kc=new Set([`name`,`run`,`fields`,`attrs`,`rejectedResult`]),Ac=new Set([`key`,`cmd`,`event`,`preventDefault`,`fallthrough`]),jc=new Set([`target`,`targetMode`,`priority`,`bindings`,`commands`]);function Mc(e){if(e===void 0||typeof e==`function`)return e;let t=e.trim();if(!t)throw Error(`Invalid keymap command: command cannot be empty`);return t}function Nc(e){let t=e.trim();if(!t)throw Error(`Invalid keymap command name: name cannot be empty`);if(/\s/.test(t))throw Error(`Invalid keymap command name "${e}": command names cannot contain whitespace`);return t}function Pc(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}function Fc(e){let t=[],n=new Map;for(let r of e.layers)for(let e of r.commands){let i={layer:r,commandState:e};t.push(i),Pc(n,e.command.name,i)}return{entries:t,chainsByName:n}}function Ic(e,t,n){let r=[],i=[],a=new Map,o=new Map;for(let s of e)if(s.commands.length!==0&&!(n&&!t.matchesConditions(s)))for(let e of s.commands){if(!t.matchesConditions(e))continue;let n={layer:s,commandState:e};r.push(n),Pc(o,e.command.name,n),a.has(e.command.name)||(a.set(e.command.name,n),i.push(n))}return{layers:e,entries:r,reachable:i,reachableByName:a,chainsByName:o}}function Lc(e,t,n,r){return(e.activeLayersCacheVersion!==e.cacheVersion||e.activeLayersCacheFocused!==r)&&(e.activeLayersCacheVersion=e.cacheVersion,e.activeLayersCacheFocused=r,e.activeLayersCache=Ks(e.sortedLayers,t,r)),Ic(e.activeLayersCache,n,!0)}function Rc(e,t,n,r){if(Object.prototype.hasOwnProperty.call(e,t)&&!Object.is(e[t],n))throw Error(`Conflicting keymap requirement for "${t}" from ${r}`);e[t]=n}function zc(e,t,n,r){if(Object.prototype.hasOwnProperty.call(e,t)&&!Object.is(e[t],n))throw Error(`Conflicting keymap attribute for "${t}" from ${r}`);e[t]=n}function Bc(e){let t=`field ${e.fieldName}`;return{require(n,r){Rc(e.requirements,n,r,t)},attr(n,r){if(!e.attrs)throw Error(`Keymap ${t} cannot publish attrs`);zc(e.attrs,n,r,t)},activeWhen(n){e.matchers.push(e.conditions.buildRuntimeMatcher(n,t))}}}function Vc(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Hc(e,t){return e instanceof Error&&e.message?e.message:t}function Uc(e){return!e||typeof e!=`object`&&typeof e!=`function`?!1:typeof e.then==`function`}function Wc(e,t){let n=t?.deep===!0,r=t?.freeze===!0,i=t?.preserveNonPlainObjects===!0;if(Array.isArray(e)){let i=n?e.map(e=>Wc(e,t)):[...e];return r?Object.freeze(i):i}if(e&&typeof e==`object`){if(i&&!Vc(e))return e;let a={};for(let[r,i]of Object.entries(e))a[r]=n?Wc(i,t):i;return r?Object.freeze(a):a}return e}var Gc=[`name`],Kc=Object.freeze({}),qc=new WeakMap;function Jc(e,t,n,r,i){let a=-1,o,s=-1,c,l,u=-1,d,f,p=-1,m,h=-1,g=new Map,_=t=>Xc({commands:t,commandFields:e.commandFields,conditions:r,onError:(e,t,r)=>{n.emitError(e,t,r)}}),v=t=>F(()=>e.commandResolvers.prepend(t),t),y=t=>F(()=>e.commandResolvers.append(t),t),b=()=>{e.commandResolvers.has()&&n.runWithStateChangeBatch(()=>{e.commandResolvers.clear(),i.onCommandResolversChanged(),n.queueStateChange()})},x=e=>le(e).map(e=>Yc(e.commandState)),S=e=>{let t=ce(e),n=le(e,t);if(n.length===0)return[];let r=n.map(e=>({entry:e,command:Yc(e.commandState),commandAttrs:e.commandState.attrs,bindings:[]})),i=new Map;for(let[e,t]of r.entries()){let n=i.get(t.command.name);n?n.push(e):i.set(t.command.name,[e])}return i.size>0&&R(r,i,t),r.map(e=>({command:e.command,bindings:e.bindings}))},C=t=>{if(t.visibility===`registered`&&u===e.derivedVersion&&d===t.commands&&f)return f;let n=new Map;for(let e of t.commands)n.has(e)||n.set(e,[]);return n.size===0?n:(ue(n,ce(t)),t.visibility===`registered`&&(u=e.derivedVersion,d=t.commands,f=n),n)},w=(e,t,n)=>{let r=M(t);if(n){let i=[],a=r.chainsByName.get(e);if(a)for(let e of a)i.push({target:e.layer.target,command:e.commandState.command,attrs:e.commandState.attrs,payload:n.payload});let o=V(e,t,{mode:`active`,execution:n});return o.resolved&&i.push(o.resolved),{entries:i.length>0?i:void 0,hadError:o.hadError}}let i=[];for(let t of r.chainsByName.get(e)??[])i.push({target:t.layer.target,command:t.commandState.command,attrs:t.commandState.attrs});let a=V(e,t,{mode:`active`});return a.resolved&&i.push(a.resolved),{entries:i.length>0?i:void 0,hadError:a.hadError}},T=t=>{if(h!==e.derivedVersion&&(h=e.derivedVersion,g=new Map),g.has(t))return g.get(t)??void 0;let n=L(I(t));return g.set(t,n??null),n},E=(e,t)=>L(M(t).chainsByName.get(e)),D=(e,t)=>V(e,null,{mode:`registered`,execution:t}),O=(e,t,n)=>V(e,t,{mode:`active`,execution:n}),k=(e,t)=>re(e,t)?.command,A=e=>ie(e)?.commandState.command,j=(e,n,i)=>{let a=ee().chainsByName.get(e);if(!a||a.length===0)return;let o,s;for(let e of a){if(!Js(t,e.layer,n)){o??=e;continue}(!r.matchesConditions(e.layer)||!r.matchesConditions(e.commandState))&&(s??=e)}let c=s??o;if(c)return{reason:s?`disabled`:`inactive`,command:i?c.commandState.command:void 0}},M=n=>{if(s===e.derivedVersion&&c===n&&l)return l;let i=Lc(e,t,r,n);return N()&&(s=e.derivedVersion,c=n,l=i),i},ee=()=>a===e.derivedVersion&&o?o:(a=e.derivedVersion,o=Fc(e),o),N=()=>e.activeCommandViewCacheBlockers===0,P=(e,t,n)=>e.command===void 0||e.run?!0:typeof e.command==`string`?n.reachableByName.has(e.command)?!0:ae(e.command,t,`active`)!==void 0:!1,te=(e,t,n)=>{if(typeof e.command!=`string`)return;let r=n.reachableByName.get(e.command);return r?r.commandState.attrs:ae(e.command,t,`active`)?.attrs},ne=(e,n)=>{if(n?.some(t=>t.command.name===e)||ee().chainsByName.has(e))return`resolved`;let r=V(e,Us(t));return r.resolved||r.hadError?r.resolved?`resolved`:`error`:`unresolved`},F=(t,r)=>n.runWithStateChangeBatch(()=>{let a=t();return i.onCommandResolversChanged(),n.queueStateChange(),()=>{n.runWithStateChangeBatch(()=>{a(),!e.commandResolvers.values().includes(r)&&(i.onCommandResolversChanged(),n.queueStateChange())})}}),re=(e,t)=>{let n=M(t).reachableByName.get(e);return n?{target:n.layer.target,command:n.commandState.command,attrs:n.commandState.attrs}:ae(e,t,`active`)},ie=e=>I(e)?.[0],I=t=>{let n=[];for(let r of e.sortedLayers)for(let e of r.commands)e.command.name===t&&n.push({layer:r,commandState:e});return n.length>0?n:void 0},L=e=>{if(e?.length)return e.map(e=>({target:e.layer.target,command:e.commandState.command,attrs:e.commandState.attrs}))},ae=(e,t,n)=>V(e,t,{mode:n}).resolved,oe=()=>ee().entries,se=()=>{if(p===e.derivedVersion&&m)return m;let t=new Map;for(let n of e.layers)for(let e of n.bindings){if(typeof e.command!=`string`)continue;let n=t.get(e.command);n?n.push(e):t.set(e.command,[e])}return p=e.derivedVersion,m=t,t},ce=e=>{let n=e?.visibility??`reachable`,r=e&&Object.prototype.hasOwnProperty.call(e,`focused`)?e.focused??null:Us(t);return n===`registered`?{visibility:n,focused:r}:{visibility:n,focused:r,activeView:M(r)}},le=(e,t=ce(e))=>{let r;return r=t.visibility===`registered`?oe():t.visibility===`active`?t.activeView?.entries??[]:t.activeView?.reachable??[],tl({entries:r,query:e,getCommand:e=>Yc(e),onFilterError:e=>{n.emitError(`command-query-filter-error`,e,`[Keymap] Error in command query filter:`)}})},R=(e,t,n)=>{de(n,n=>{fe(e,t,n)})},ue=(e,t)=>{if(t.visibility===`registered`){let t=se();for(let[n,r]of e){let e=ee().chainsByName.get(n)?.[0]?.commandState.attrs;for(let i of t.get(n)??[])r.push(z(i,e))}return}de(t,n=>{pe(e,n,t)})},de=(t,n)=>{if(t.visibility===`registered`){for(let t of e.layers)for(let e of t.bindings)n(e);return}let i=t.activeView;if(i){for(let e of i.layers)if(!(e.bindings.length===0||!r.matchesConditions(e)))for(let a of e.bindings)r.matchesConditions(a)&&P(a,t.focused,i)&&n(a)}},fe=(e,t,n)=>{if(typeof n.command!=`string`)return;let r=t.get(n.command);if(!(!r||r.length===0))for(let t of r){let r=e[t];r&&r.bindings.push(z(n,r.commandAttrs))}},pe=(e,t,n)=>{if(typeof t.command!=`string`)return;let r=e.get(t.command);r&&r.push(z(t,B(t,n)))},z=(e,t)=>({sequence:e.sequence,command:e.command,commandAttrs:t,attrs:e.attrs,event:e.event,preventDefault:e.preventDefault,fallthrough:e.fallthrough}),B=(e,t)=>{if(typeof e.command!=`string`)return;if(t.visibility===`registered`)return ee().chainsByName.get(e.command)?.[0]?.commandState.attrs;let n=t.activeView;if(n)return te(e,t.focused,n)},V=(t,r,i)=>{let a=i?.mode??`active`,o=i?.execution??{input:t},s=Zc(t,e.commandResolvers.values(),()=>ge(r,a,o),e=>{n.emitError(`command-resolver-error`,e,`[Keymap] Error in command resolver for "${t}":`)}),c=s.resolved;if(c){let e=he(c.command.name,r,a);e?.commandState.command===c.command&&c.target===void 0&&(c={...c,target:e.layer.target},s.resolved=c)}if(c&&!c.attrs){let e=me(c.command.name,r,a)??el(c.command);e&&(s.resolved={...c,attrs:e})}return s},me=(e,t,n)=>n===`registered`?ie(e)?.commandState.attrs:M(t).reachableByName.get(e)?.commandState.attrs,he=(e,t,n)=>n===`registered`?ie(e):M(t).reachableByName.get(e),ge=(e,t,n)=>{let r=n.input,i=n.payload;return{context:{get input(){return r},get payload(){return i},setInput(e){r=e},setPayload(e){i=e},getCommand:n=>t===`registered`?A(n):k(n,e)},getExecutionFields(){return{input:r,payload:i}}}};return{normalizeCommands:_,prependCommandResolver:v,appendCommandResolver:y,clearCommandResolvers:b,getCommands:x,getCommandEntries:S,getCommandBindings:C,getResolvedCommandChain:w,getRegisteredResolvedEntries:T,getActiveRegisteredResolvedEntries:E,resolveRegisteredResolverFallback:D,resolveActiveResolverFallback:O,getTopCommand:k,getDispatchUnavailableCommandState:j,getActiveCommandView:M,isBindingVisible:P,getBindingCommandAttrs:te,getCommandResolutionStatus:ne}}function Yc(e){return e.command}function Xc(e){let t=[],n=new Set;for(let r of e.commands)try{let i={},a=[],o=Nc(r.name),s=Qc(r),c={};if(n.has(o)){e.onError(`duplicate-command`,{command:o},`Duplicate keymap command "${o}" in the same layer`);continue}r.name=o;for(let[t,n]of Object.entries(s)){if(n===void 0)continue;let r=e.commandFields.get(t);r&&r(n,Bc({fieldName:t,conditions:e.conditions,requirements:i,matchers:a,attrs:c}))}let l={command:r,fields:s,attrs:Object.keys(c).length===0?void 0:c,requires:Object.entries(i),matchers:a};n.add(l.command.name),t.push(l)}catch(t){e.onError(`register-command-failed`,t,Hc(t,`Failed to register keymap command "${String(r.name)}"`));continue}return t}function Zc(e,t,n,r){if(t.length===0)return{hadError:!1};let i=!1;for(let a of t){let t,o=n();try{t=a(e,o.context)}catch(e){i=!0,r(e);continue}if(t)return{hadError:i,resolved:$c(t,o.getExecutionFields())}}return{hadError:i}}function Qc(e){let t={};for(let[n,r]of Object.entries(e))!kc.has(n)&&r!==void 0&&(t[n]=r);return Object.keys(t).length===0?Kc:t}function $c(e,t){return{command:e,input:t.input,payload:t.payload}}function el(e){let t=Qc(e);return t===Kc?void 0:t}function tl(e){let t=e.query?.namespace,n=nl(e.query?.limit);if(n===0)return[];let r=e.query?.search?.trim().toLowerCase()??``,i=Gc;e.query?.searchIn&&e.query.searchIn.length>0&&(i=e.query.searchIn);let a=e.query?.filter,o,s,c;if(typeof a==`function`)s=a;else if(a){let e=Object.entries(a),t=[];for(let[n,r]of e){if(n===`name`){if(typeof r==`string`){c=new Set([r]);continue}if(Array.isArray(r)){let e=new Set;for(let t of r)typeof t==`string`&&e.add(t);c=e;continue}}t.push([n,r])}o=t.length>0?t:void 0}let l=[];for(let a of e.entries){let u=a.commandState;if(il(u,t)&&rl(u,r,i)&&!(c&&!c.has(u.command.name))&&al(u,o,e)){if(s){let t=!1;try{t=s(e.getCommand(u))}catch(t){e.onFilterError(t);continue}if(!t)continue}if(l.push(a),n!==void 0&&l.length>=n)break}}return l}function nl(e){if(e===void 0)return;let t=Math.floor(Number(e));return!Number.isFinite(t)||t<=0?0:t}function rl(e,t,n){if(!t)return!0;for(let r of n)if(ol(e,r,t))return!0;return!1}function il(e,t){if(t===void 0)return!0;let n=e.fields;return Object.prototype.hasOwnProperty.call(n,`namespace`)?pl(n.namespace,t):!1}function al(e,t,n){if(!t)return!0;for(let[r,i]of t)if(!ul(e,r,i,n))return!1;return!0}function ol(e,t,n){return sl(e,t)?.includes(n)===!0}function sl(e,t){let n=qc.get(e);if(n||(n=new Map,qc.set(e,n)),n.has(t))return n.get(t);let r=e.fields,i=e.attrs,a;t===`name`?a=e.command.name:Object.prototype.hasOwnProperty.call(r,t)?a=r[t]:i&&Object.prototype.hasOwnProperty.call(i,t)&&(a=i[t]);let o=cl(a);return n.set(t,o),o}function cl(e){if(Array.isArray(e)){let t=[];for(let n of e){let e=cl(n);e!==void 0&&t.push(e)}return t.length>0?t.join(`\0`):void 0}if(typeof e==`string`)return e.toLowerCase();if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e).toLowerCase()}function ll(e,t,n,r){try{return e(t,n)}catch(e){return r(e),!1}}function ul(e,t,n,r){return typeof n==`function`?dl(e,t,n,r):fl(e,t,n)}function dl(e,t,n,r){let i=e.command,a=e.fields,o=e.attrs,s,c=!1,l=()=>s??=r.getCommand(e);return t===`name`&&(c=!0,ll(n,i.name,l(),r.onFilterError))||Object.prototype.hasOwnProperty.call(a,t)&&(c=!0,ll(n,a[t],l(),r.onFilterError))||o&&Object.prototype.hasOwnProperty.call(o,t)&&(c=!0,ll(n,o[t],l(),r.onFilterError))?!0:!c&&ll(n,void 0,l(),r.onFilterError)}function fl(e,t,n){let r=e.command,i=e.fields,a=e.attrs;return t===`name`&&pl(r.name,n)||Object.prototype.hasOwnProperty.call(i,t)&&pl(i[t],n)?!0:!!a&&Object.prototype.hasOwnProperty.call(a,t)&&pl(a[t],n)}function pl(e,t){return Array.isArray(t)?t.some(t=>ml(e,t)):ml(e,t)}function ml(e,t){return Array.isArray(e)?e.some(e=>ml(e,t)):Object.is(e,t)}function hl(e,t,n,r,i){let a=(e,t,n,r,a,o)=>({keymap:i.keymap,event:e,focused:t,target:n,data:r,input:a,payload:o}),o=(t,n,r,i)=>{let a=typeof n==`function`?void 0:n,o=typeof n==`function`?n:n.run,s=i?a:void 0,c;try{c=o(a?{...r,command:a}:r)}catch(n){return e.emitError(`command-execution-error`,n,`[Keymap] Error running command "${t}":`),{status:`error`,result:s?{ok:!1,reason:`error`,command:s}:{ok:!1,reason:`error`}}}if(Uc(c))return c.catch(n=>{e.emitError(`async-command-error`,n,`[Keymap] Async error in command "${t}":`)}),{status:`handled`,result:s?{ok:!0,command:s}:{ok:!0}};if(gl(c)){let e=c;return(!c.ok&&c.reason!==`not-found`&&i&&a&&!c.command||c.ok&&i&&a&&!c.command)&&(e={...c,command:a}),{status:c.ok?`handled`:`rejected`,result:e}}return c===!1?{status:`rejected`,result:s?{ok:!1,reason:`rejected`,command:s}:{ok:!1,reason:`rejected`}}:{status:`handled`,result:s?{ok:!0,command:s}:{ok:!0}}},s=(e,t,n,r,i,s,c,l)=>{let u;for(let d of t??[]){let t=o(e,d.command,a(n,r,i??d.target??null,s,e,c),l);if(t.status===`handled`||t.status===`error`)return[t.result,u];u=t.result}return[void 0,u]},c=(e,c,l)=>{let u;try{u=Mc(e)}catch{return{ok:!1,reason:`invalid-args`}}if(typeof u!=`string`)return{ok:!1,reason:`not-found`};let d=c?.includeCommand===!0,f=c?.focused??n.getFocusedTargetIfAvailable(),p=c?.event??i.createCommandEvent(),m=t.getReadonlyData(),h=c?.payload,g=l===`registered`?r.getRegisteredResolvedEntries(u):r.getActiveRegisteredResolvedEntries(u,f),[_,v]=s(u,g,p,f,c?.target,m,h,d);if(_)return _;let y=v,b=l===`registered`?r.resolveRegisteredResolverFallback(u,{input:u,payload:h}):r.resolveActiveResolverFallback(u,f,{input:u,payload:h});if(b.resolved){let e=o(u,b.resolved.command,a(p,f,c?.target??b.resolved.target??null,m,b.resolved.input??u,b.resolved.payload),d);if(e.status===`handled`||e.status===`error`)return e.result;y=e.result}if(b.hadError)return{ok:!1,reason:`error`};if(l===`active`){let e=r.getDispatchUnavailableCommandState(u,f,d);if(e)return e.command?{ok:!1,reason:e.reason,command:e.command}:{ok:!1,reason:e.reason}}return y??{ok:!1,reason:`not-found`}};return{runCommand(e,t){return c(e,t,`registered`)},dispatchCommand(e,t){return c(e,t,`active`)},runBinding(e,n,i,s,c){let l=t.getReadonlyData();if(n.run)return o(typeof n.command==`string`?n.command:`<function>`,n.run,a(i,s,e.target??null,l,typeof n.command==`string`?n.command:`<function>`,c),!1).status!==`rejected`&&(_l(n,i),!0);if(typeof n.command!=`string`)return!1;let u=r.getResolvedCommandChain(n.command,s,c===void 0?void 0:{input:n.command,payload:c}).entries;for(let t of u??[])if(o(n.command,t.command,a(i,s,t.target??e.target??null,l,t.input??n.command,t.payload),!1).status!==`rejected`)return _l(n,i),!0;return!1}}}function gl(e){return typeof e==`object`&&!!e&&`ok`in e}function _l(e,t){e.preventDefault&&(t.preventDefault(),t.stopPropagation())}var vl=Object.freeze({}),yl=[],bl=[];function xl(e){if(Object.keys(e).length!==0)return Wc(e,{freeze:!0})}function Sl(e,t,n,r){let i=t=>Ol(t,e.bindingParsers.values(),{tokens:e.tokens,patterns:e.patterns,layer:vl,parseObjectKey:(e,t)=>c(e,t)}),a=t=>{if(typeof t!=`string`)return[c(t)];let n=Dl(t,e.bindingParsers.values(),{tokens:e.tokens,patterns:e.patterns,layer:vl,parseObjectKey:(e,t)=>c(e,t)});for(let e of n.unknownTokens)r.warnUnknownToken(e,t);return n.unknownTokens.length>0?[]:n.parts},o=(e,t)=>zs(a(e),t),s=(i,a,o,s,d)=>{let f=[],p=!1,m=e.bindingExpanders.values(),h=e.bindingParsers.values(),g=e.bindingFields,_=e.disambiguationResolvers.has(),v=r.warnUnknownField,y=r.warnUnknownToken;for(let[r,b]of i.entries()){let i;try{i=Tl(b.key,m,{layer:d})}catch(e){t.emitError(`binding-expand-error`,e,Hc(e,`Failed to expand keymap binding`));continue}for(let m of i){let i=m.key,x;try{x=typeof i==`string`?Dl(i,h,{tokens:a,patterns:e.patterns,layer:d,parseObjectKey:(e,t)=>c(e,t)}):{parts:[c(i)],usedTokens:[],unknownTokens:[],hasTokenBindings:!1},x=El(x,m)}catch(e){t.emitError(`binding-parse-error`,e,Hc(e,`Failed to parse keymap binding`));continue}let S=x.parts;p||=x.hasTokenBindings;for(let e of x.unknownTokens)y(e,typeof i==`string`?i:String(i.name));if(!(x.unknownTokens.length>0))for(let i of u(b,S,a,h,d))try{let t=l(i.event),a=i.sequence,c={},u={},d=[];for(let e in i){if(e===`sequence`||Ac.has(e))continue;let t=i[e];if(t===void 0)continue;let r=g.get(e);if(!r){v(`binding`,e);continue}r(t,Bc({fieldName:e,conditions:n,requirements:c,matchers:d,attrs:u}))}let p=Object.keys(u).length>0?xl(u):void 0,m=Mc(i.cmd),h={binding:b,sequence:a,command:m,event:t,parsedBinding:mc(i),sourceTarget:o,sourceLayerOrder:s,bindingIndex:r,requires:Object.keys(c).length>0?Object.entries(c):yl,matchers:d.length>0?d:bl,preventDefault:i.preventDefault!==!1,fallthrough:i.fallthrough??!1};if(p&&(h.attrs=p),typeof m==`function`&&(h.run=m),a.length===0)continue;if(t===`release`&&a.length>1)throw Error(`Keymap release bindings only support a single key stroke`);let y=a.at(-1);if(y?.patternName){let t=e.patterns.get(y.patternName);if(t&&t.max!==t.min)throw Error(`Keymap unbounded sequence patterns must be followed by a concrete continuation`)}t===`press`&&!_&&wl(f,h),f.push(h)}catch(e){t.emitError(`binding-compile-error`,e,Hc(e,`Failed to compile keymap binding`))}}}return{bindings:f,hasTokenBindings:p}},c=(e,t)=>Ms(e,t),l=e=>{if(e===void 0||e===`press`)return`press`;if(e===`release`)return`release`;throw Error(`Invalid keymap binding event "${String(e)}": expected "press" or "release"`)},u=(n,r,i,a,o)=>{let s=e.bindingTransformers.values();if(s.length===0)return[{...n,sequence:Ps(r)}];let l={...n,sequence:Ps(r)},u=[],d=!0,f=o??vl;for(let n of s)try{n(l,{layer:f,parseKey:t=>Ol(t,a,{tokens:i,patterns:e.patterns,layer:f,parseObjectKey:(e,t)=>c(e,t)}),add:e=>{u.push(mc(e))},skipOriginal:()=>{d=!1}})}catch(e){t.emitError(`binding-transformer-error`,e,`[Keymap] Error in binding transformer:`)}return d?u.length===0?[l]:[l,...u]:u};return{parseTokenKey:i,parseKeySequence:a,formatKey:o,compileBindings:s}}function Cl(e,t){if(e.length>=t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.match!==t[n]?.match)return!1;return!0}function wl(e,t){for(let n of e)if(n.event===`press`&&(n.command!==void 0&&Cl(n.sequence,t.sequence)||t.command!==void 0&&Cl(t.sequence,n.sequence)))throw Error(`Keymap bindings cannot use the same sequence as both an exact match and a prefix in the same layer`)}function Tl(e,t,n){if(typeof e!=`string`||t.length===0)return[{key:e}];let r=n?.layer??vl,i=[{key:e}];for(let e of t){let t=[];for(let n of i){let i=e({input:n.key,displays:n.displays,layer:r});if(!i){t.push(n);continue}if(i.length===0)throw Error(`Keymap binding expander must return at least one key sequence for "${n.key}"`);for(let e of i){if(!e||typeof e!=`object`||Array.isArray(e)||typeof e.key!=`string`)throw Error(`Keymap binding expander must return expansion objects with string keys for "${n.key}"`);if(e.displays!==void 0){if(!Array.isArray(e.displays))throw Error(`Keymap binding expander displays must be an array of strings for "${n.key}"`);for(let t of e.displays)if(typeof t!=`string`)throw Error(`Keymap binding expander displays must be an array of strings for "${n.key}"`)}t.push(e)}}i=t}return i}function El(e,t){if(!t.displays)return e;if(t.displays.length!==e.parts.length)throw Error(`Keymap binding expansion displays length must match parsed sequence length for "${String(t.key)}"`);return{...e,parts:e.parts.map((e,n)=>({...e,display:t.displays[n]}))}}function Dl(e,t,n){if(e.length===0)throw Error(`Invalid key sequence: sequence cannot be empty`);if(t.length===0)throw Error(`No keymap binding parsers are registered`);let r=n.tokens??new Map,i=n.patterns??new Map,a=n.layer??vl,o=n.parseObjectKey,s=[],c=new Set,l=new Set,u=0;for(;u<e.length;){let n=!1;for(let d of t){let t=d({input:e,index:u,layer:a,tokens:r,patterns:i,normalizeTokenName:Os,createMatch:Ls,parseObjectKey:o});if(t){if(t.nextIndex<=u||t.nextIndex>e.length)throw Error(`Keymap binding parser must advance the input for "${e}" at index ${u}`);s.push(...t.parts);for(let e of t.usedTokens??[])c.add(e);for(let e of t.unknownTokens??[])l.add(e);u=t.nextIndex,n=!0;break}}if(!n)throw Error(`No keymap binding parser handled input at index ${u} in "${e}"`)}return{parts:s,usedTokens:[...c],unknownTokens:[...l],hasTokenBindings:c.size>0||l.size>0}}function Ol(e,t,n){if(typeof e!=`string`)return n.parseObjectKey(e);let{parts:r}=Dl(e,t,n),[i]=r;if(!i||r.length!==1)throw Error(`Invalid key "${String(e)}": expected a single key stroke`);return i}function kl(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.get==`function`&&typeof t.subscribe==`function`}function Al(e,t){let n=e=>e.requires.length===0&&e.matchers.length===0,r=e=>{try{return e.match()}catch(n){return t.emitError(`runtime-matcher-error`,n,`[Keymap] Error evaluating runtime matcher from ${e.source}:`),!1}},i=e=>{if(e.matchers.length===0)return!0;if(e.matchers.length===1){let[t]=e.matchers;return!t||r(t)}for(let t of e.matchers)if(!r(t))return!1;return!0},a=t=>{if(t.length===0)return!0;for(let[n,r]of t)if(!Object.is(e.data[n],r))return!1;return!0};return{buildRuntimeMatcher(e,t){if(typeof e==`function`)return{source:t,match:e};if(kl(e))return{source:t,match:()=>e.get(),subscribe:t=>e.subscribe(t)};throw Error(`Keymap ${t} expected a function or a reactive matcher`)},matchesConditions:e=>n(e)||a(e.requires)&&i(e)}}var jl=Symbol(`keymap-disambiguation-decision`),Ml=Symbol(`keymap-deferred-disambiguation-decision`);function Nl(e,t){return{[jl]:!0,action:e,handler:t}}function Pl(e){return{[Ml]:!0,action:e}}function Fl(e){return!!e&&typeof e==`object`&&e[jl]===!0}function Il(e){return!!e&&typeof e==`object`&&e[Ml]===!0}function Ll(e,t){return t.aborted?Promise.resolve(!1):new Promise(n=>{let r=setTimeout(()=>{t.removeEventListener(`abort`,i),n(!0)},Math.max(0,e)),i=()=>{clearTimeout(r),t.removeEventListener(`abort`,i),n(!1)};t.addEventListener(`abort`,i,{once:!0})})}function Rl(e,t,n,r){let i=e.get(n);if(i)try{return i.matcher(r)}catch(e){t.emitError(`sequence-pattern-match-error`,e,`[Keymap] Error matching sequence pattern "${i.name}":`);return}}function zl(e,t,n,r){let i=e.get(n)?.payloadKey??n;return{...Ms({name:t.name,ctrl:t.ctrl,shift:t.shift,meta:t.meta,super:t.super??!1,hyper:t.hyper||void 0},{display:r.display??String(r.value??t.name)}),patternName:n,payloadKey:i}}function Bl(e,t,n){if(!n?.patterns||n.patterns.length===0)return;let r={},i=!1;for(let a of n.patterns){let n=e.get(a.name),o;try{o=n?.finalize?n.finalize(a.values):a.values.length===1?a.values[0]:[...a.values]}catch(e){t.emitError(`sequence-pattern-finalize-error`,e,`[Keymap] Error finalizing sequence pattern "${a.name}":`);continue}let s=r[a.payloadKey];s===void 0?(r[a.payloadKey]=o,i=!0):Array.isArray(s)?s.push(o):r[a.payloadKey]=[s,o]}return i?r:void 0}function Vl(e,t,n,r,i,a,o,s,c,l){let u={resolveKey:e=>o.parseTokenKey(e).match},d=null,f=0;function p(t,n,r){if(t===`key`){let t=r;return e.keyHooks.register(n,{priority:t?.priority??0,release:t?.release??!1})}if(t===`key:after`){let t=r;return e.keyAfterHooks.register(n,{priority:t?.priority??0,release:t?.release??!1})}let i=r;return e.rawHooks.register(n,{priority:i?.priority??0})}function m(t){return e.eventMatchResolvers.prepend(t)}function h(t){return e.eventMatchResolvers.append(t)}function g(){e.eventMatchResolvers.clear()}function _(t){return ne(()=>e.disambiguationResolvers.prepend(t),t)}function v(t){return ne(()=>e.disambiguationResolvers.append(t),t)}function y(){e.disambiguationResolvers.has()&&t.runWithStateChangeBatch(()=>{e.disambiguationResolvers.clear(),c.recompileBindings()})}function b(e,t){d&&z()}function x(n){let r=e.rawHooks.entries();if(r.length===0)return!1;let i=!1,a={sequence:n,stop(){i=!0}};for(let e of r){try{e.listener(a)}catch(e){t.emitError(`raw-intercept-error`,e,`[Keymap] Error in raw intercept listener:`)}if(i)return!0}return!1}function S(e,t){return{sequence:Ps(e.sequence),command:e.command,commandAttrs:s.getBindingCommandAttrs(e,t,s.getActiveCommandView(t)),attrs:e.attrs,event:e.event,preventDefault:e.preventDefault,fallthrough:e.fallthrough,sourceLayerOrder:e.sourceLayerOrder,bindingIndex:e.bindingIndex}}function C(e){l.has(`dispatch`)&&l.emit(`dispatch`,e)}function w(e,t,n,r){l.has(`dispatch`)&&C({phase:e,event:n.event,focused:r,layer:{order:t.order,priority:t.priority,target:t.target,targetMode:t.targetMode},binding:S(n,r),sequence:Ps(n.sequence),command:n.command})}function T(e,t,n){if(!l.has(`dispatch`))return;let i=t[0],a=t.length>0?r.collectSequencePartsFromPending({captures:t}):[];C({phase:e,event:`press`,focused:n,layer:i?{order:i.layer.order,priority:i.layer.priority,target:i.layer.target,targetMode:i.layer.targetMode}:void 0,sequence:a})}function E(t){let n=e.keyAfterHooks.entries();for(let e of n)if(e.release===t)return n}function D(e){return e.sequence?Ps(e.sequence):e.captures?r.collectSequencePartsFromPending({captures:e.captures}):[]}function O(e,t){return{handled:e!==`sequence-miss`,reason:e,captures:t}}function k(e,t){return{handled:t,reason:t?`binding-handled`:`binding-rejected`,sequence:e.sequence}}function A(e,t){return t.handled||e.reason===`no-match`?t:e}function j(e,i,a,o,s){let c={event:i,eventType:a?`release`:`press`,focused:o,handled:s.handled,reason:s.reason,sequence:D(s),pendingSequence:r.getPendingSequence(),setData:(e,t)=>{n.setData(e,t)},getData:e=>n.getData(e),consume:e=>{let t=e?.preventDefault??!0,n=e?.stopPropagation??!0;t&&i.preventDefault(),n&&i.stopPropagation()}};for(let n of e)if(n.release===a)try{n.listener(c)}catch(e){t.emitError(`key-after-intercept-error`,e,`[Keymap] Error in key:after intercept listener:`)}}function M(){return{handled:!1,reason:`no-match`}}function ee(e){e.preventDefault(),e.stopPropagation()}function N(e,t,n,i){r.setPendingSequence({captures:t});let a=O(`sequence-pending`,t);return T(e,t,n),ee(i),a}function P(e,t,n,i){let a=O(e,t);return T(`sequence-clear`,t,n),r.setPendingSequence(null),ee(i),a}function te(i,a){a||z();let o=E(a),s=o?r.getFocusedTarget():null,c=e.keyHooks.entries(),l={event:i,setData:(e,t)=>{n.setData(e,t)},getData:e=>n.getData(e),consume:e=>{let t=e?.preventDefault??!0,n=e?.stopPropagation??!0;t&&i.preventDefault(),n&&i.stopPropagation()}};for(let e of c)if(e.release===a){try{e.listener(l)}catch(e){t.emitError(`key-intercept-error`,e,`[Keymap] Error in key intercept listener:`)}if(i.propagationStopped){o&&j(o,i,a,s,{handled:!0,reason:`intercept-consumed`,sequence:[]});return}}if(a){let e=F(i);o&&j(o,i,a,s,e);return}let u=re(i);o&&j(o,i,a,s,u)}function ne(n,r){return t.runWithStateChangeBatch(()=>{let i=e.disambiguationResolvers.has(),a=n();return!i&&e.disambiguationResolvers.has()&&c.recompileBindings(),()=>{t.runWithStateChangeBatch(()=>{let t=e.disambiguationResolvers.has();a(),!e.disambiguationResolvers.values().includes(r)&&t&&!e.disambiguationResolvers.has()&&c.recompileBindings()})}})}function F(e){let t=r.getFocusedTarget(),n=r.getActiveLayers(t),a=_e(e),o=M();for(let r of a)layerLoop:for(let a of n){if(a.bindings.length===0||!i.matchesConditions(a))continue;let n=ve(a,r,e,t);if(o=A(o,n.outcome),n.handled){if(n.stop)return o;continue layerLoop}}return o}function re(e){let t=r.getFocusedTarget(),n=r.ensureValidPendingSequence(),i=_e(e);if(n)return ie(n,i,e,t);let a=r.getActiveLayers(t),o=M();for(let n of i){let r=L(a,[n],e,t);if(o=A(o,r),r.handled)return o}return o}function ie(t,n,i,a){let o=s.getActiveCommandView(a),c=[];for(let r of t.captures){let t=ac(r,n,i,e.patterns,ye,H);t&&c.push(t)}let l=c.reduce((e,t)=>Math.min(e,rc(t,n)),1/0),u=c.filter(e=>rc(e,n)===l);if(u.length===0||!u.some(e=>Ce(e,a,o))){let e=O(`sequence-miss`,t.captures);return T(`sequence-clear`,t.captures,a),r.setPendingSequence(null),e}return I(u,0,!1,i,a)}function I(t,n,i,a,o){let s=i,c=M(),l=new Set;for(let i=n;i<t.length;i+=1){let n=t[i];if(!n||l.has(n))continue;let u=he(t,i,n);if(u.length>0){if(s)continue;let e=ge(t,n);return se(t,i,u,e,a,o,s)||N(`sequence-advance`,u,o,a)}if(!Qs(n,e.patterns))continue;let d=ge(t,n);for(let e of d)l.add(e);let f=we(n.layer,d,a,o);if(c=A(c,f.outcome),f.handled&&(s=!0,f.stop))return T(`sequence-clear`,t,o),r.setPendingSequence(null),c}return T(`sequence-clear`,t,o),r.setPendingSequence(null),c}function L(e,t,n,r){return ae(e,0,t,n,r)}function ae(t,n,r,a,o){let c=s.getActiveCommandView(o),l=M();for(let s=n;s<t.length;s+=1){let n=t[s];if(!n||!i.matchesConditions(n))continue;let u=be(n,r,a,o,c);if(u.length===0)continue;if(u.filter(t=>Zs(t,e.patterns,!1)).length>0){let n=u.filter(t=>Qs(t,e.patterns)),i=me(t,s,r,a,o);return oe(t,s,r,i,n,a,o)||N(`sequence-start`,i,o,a)}let d=we(n,u.filter(t=>Qs(t,e.patterns)),a,o);if(l=A(l,d.outcome),d.handled&&d.stop)return l}return l}function oe(e,t,n,i,a,o,s){return ce({event:o,focused:s,continuationCaptures:i,exactBindingsSource:a.map(e=>e.binding),sequencePhase:`sequence-start`,runExact:()=>{r.setPendingSequence(null);let i=a[0]?.layer;if(!i)return M();let c=we(i,a,o,s);return c.stop?c.outcome:A(c.outcome,ae(e,t+1,n,o,s))}})}function se(e,t,n,i,a,o,s){return ce({event:a,focused:o,continuationCaptures:n,exactBindingsSource:i.map(e=>e.binding),sequencePhase:`sequence-advance`,runExact:()=>{r.setPendingSequence(null);let n=i[0]?.layer;if(!n)return M();let c=we(n,i,a,o);return c.stop?c.outcome:A(c.outcome,I(e,t+1,s||c.handled,a,o))}})}function ce(t){let{event:n,focused:i,continuationCaptures:a,exactBindingsSource:o,sequencePhase:c,runExact:l}=t;if(!e.disambiguationResolvers.has()||a.length===0)return;let u=s.getActiveCommandView(i),d=r.collectMatchingBindings(o,i,u);if(!d.some(e=>e.command!==void 0))return;let f=()=>N(c,a,i,n),p=()=>P(`sequence-cleared`,a,i,n),m,h=()=>(m??=r.collectSequencePartsFromPending({captures:a}),m),g=R({event:n,focused:i,getSequence:h,exactBindings:d,continuationCaptures:a,activeView:u});return g?le(g,a,l,f,p,i,h):(V(h()),f())}function le(e,t,n,r,i,a,o){if(e.action===`run-exact`)return n();if(e.action===`continue-sequence`)return r();if(e.action===`clear`)return i();let s=r();return ue(t,e.handler,a,o(),e=>{if(e){if(e.action===`run-exact`){n();return}if(e.action===`continue-sequence`){r();return}i()}}),s}function R(i){let a,o,s,c,l={event:i.event,focused:i.focused,get sequence(){return a??=Ps(i.getSequence()),a},get stroke(){let e=i.getSequence().at(-1);if(!e)throw Error(`Disambiguation context expected a non-empty sequence`);return c??={...e,stroke:js(e.stroke)},c},get exact(){return o??=r.collectActiveBindings(i.exactBindings,i.focused,i.activeView).map(e=>({...e,sequence:Ps(e.sequence)})),o},get continuations(){return s??=r.getActiveKeysForCaptures(i.continuationCaptures,{includeBindings:!0,includeMetadata:!0}),s},getData:e=>n.getData(e),setData:(e,t)=>{n.setData(e,t)},runExact:()=>Nl(`run-exact`),continueSequence:()=>Nl(`continue-sequence`),clear:()=>Nl(`clear`),defer:e=>Nl(`defer`,e)};for(let n of e.disambiguationResolvers.values()){let e;try{e=n(l)}catch(e){t.emitError(`disambiguation-resolver-error`,e,`[Keymap] Error in disambiguation resolver:`);continue}if(e!==void 0){if(Uc(e)){t.emitError(`invalid-disambiguation-resolver-return`,e,`[Keymap] Disambiguation resolvers must return synchronously; use ctx.defer(...) for async handling`);continue}if(!Fl(e)){t.emitError(`invalid-disambiguation-decision`,e,`[Keymap] Invalid disambiguation decision returned by resolver:`);continue}return e}}}function ue(e,t,n,r,i){z();let a=new AbortController,o={id:f++,controller:a,captures:e,apply:i};d=o,queueMicrotask(()=>{de(o,t,n,r)})}function de(e,n,r,i){if(!B(e))return;let a={signal:e.controller.signal,sequence:Ps(i),focused:r,sleep:t=>Ll(t,e.controller.signal),runExact:()=>Pl(`run-exact`),continueSequence:()=>Pl(`continue-sequence`),clear:()=>Pl(`clear`)},o;try{o=n(a)}catch(n){B(e)&&(t.emitError(`deferred-disambiguation-error`,n,`[Keymap] Error in deferred disambiguation handler:`),pe(e));return}if(Uc(o)){o.then(t=>{fe(e,t)}).catch(n=>{B(e)&&(t.emitError(`deferred-disambiguation-error`,n,`[Keymap] Error in deferred disambiguation handler:`),pe(e))});return}fe(e,o)}function fe(e,n){if(B(e)){if(n!==void 0&&!Il(n)){t.emitError(`invalid-deferred-disambiguation-decision`,n,`[Keymap] Invalid deferred disambiguation decision returned by handler:`),pe(e);return}pe(e),e.apply(n)}}function pe(e){B(e)&&(d=null)}function z(){let e=d;e&&(d=null,e.controller.abort())}function B(e){return d===e}function V(e){let n=zs(e,{preferDisplay:!0});t.warnOnce(`unresolved-disambiguation:${n}`,`unresolved-disambiguation`,{sequence:n},`[Keymap] Ambiguous exact/prefix sequence "${n}" fell back to prefix handling because no disambiguation resolver resolved it`)}function me(t,n,r,a,o){let c=[],l=s.getActiveCommandView(o);for(let s=n;s<t.length;s+=1){let n=t[s];if(n&&i.matchesConditions(n))for(let t of be(n,r,a,o,l))Zs(t,e.patterns,!1)&&c.push(t)}return c}function he(t,n,r){return t.filter((t,i)=>i>=n&&Zs(t,e.patterns,!1)&&Ul(t.parts,r.parts))}function ge(t,n){return t.filter(t=>t.layer===n.layer&&Qs(t,e.patterns)&&Ul(t.parts,n.parts))}function _e(n){let r=e.eventMatchResolvers.values();if(r.length===0)return[];if(r.length===1)return Hl(r[0],n,u,t);let i=[],a=new Set;for(let e of r){let r;try{r=e(n,u)}catch(e){t.emitError(`event-match-resolver-error`,e,`[Keymap] Error in event match resolver:`);continue}if(!(!r||r.length===0))for(let e of r){if(typeof e!=`string`){t.emitError(`invalid-event-match-resolver-candidate`,e,`[Keymap] Invalid event match resolver candidate:`);continue}a.has(e)||(a.add(e),i.push(e))}}return i}function ve(e,t,n,r){let o=!1,s=M();for(let c of e.bindings){if(c.event!==`release`)continue;let l=c.sequence[0];if(!l||l.match!==t||!i.matchesConditions(c))continue;let u=a.runBinding(e,c,n,r);if(s=A(s,k(c,u)),!u){w(`binding-reject`,e,c,r);continue}if(w(`binding-execute`,e,c,r),o=!0,!c.fallthrough)return{handled:!0,stop:!0,outcome:s}}return{handled:o,stop:!1,outcome:s}}function ye(n,r){return Rl(e.patterns,t,n,r)}function H(t,n,r){return zl(e.patterns,t,n,r)}function be(e,t,n,r,i){let a=oc(e,t,n,ye,H);return a.some(e=>Ce(e,r,i))?a:[]}function xe(n){return Bl(e.patterns,t,n)}function Se(e,t,n){return i.matchesConditions(e)&&s.isBindingVisible(e,t,n)}function Ce(e,t,n){return Se(e.binding,t,n)}function we(e,t,n,r){let o=!1,s=M();for(let c of t){let t=c.binding;if(!i.matchesConditions(t))continue;let l=a.runBinding(e,t,n,r,xe(c));if(s=A(s,k(t,l)),!l){w(`binding-reject`,e,t,r);continue}if(w(`binding-execute`,e,t,r),o=!0,!t.fallthrough)return{handled:!0,stop:!0,outcome:s}}return{handled:o,stop:!1,outcome:s}}return{intercept:p,prependEventMatchResolver:m,appendEventMatchResolver:h,clearEventMatchResolvers:g,prependDisambiguationResolver:_,appendDisambiguationResolver:v,clearDisambiguationResolvers:y,handlePendingSequenceChange:b,handleRawSequence:x,handleKeyEvent:te}}function Hl(e,t,n,r){let i;try{i=e(t,n)}catch(e){return r.emitError(`event-match-resolver-error`,e,`[Keymap] Error in event match resolver:`),[]}if(!i||i.length===0)return[];if(i.length===1){let[e]=i;return typeof e==`string`?[e]:(r.emitError(`invalid-event-match-resolver-candidate`,e,`[Keymap] Invalid event match resolver candidate:`),[])}let a=[],o=new Set;for(let e of i){if(typeof e!=`string`){r.emitError(`invalid-event-match-resolver-candidate`,e,`[Keymap] Invalid event match resolver candidate:`);continue}o.has(e)||(o.add(e),a.push(e))}return a}function Ul(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.match!==t[n]?.match)return!1;return!0}var Wl=()=>{};function Gl(e,t,n,r){if(n===void 0)return r;if(typeof n!=`number`||!Number.isInteger(n)||n<0)throw Error(`Keymap sequence pattern "${e}" ${t} must be a non-negative integer`);return n}function Kl(e,t){let{kind:n,reservedFields:r,registeredFields:i,emitError:a}=t,o=Object.entries(e),s=[];for(let[e,t]of o){if(r.has(e)){a(`reserved-${n}-field`,{field:e,kind:n},`Keymap ${n} field "${e}" is reserved`);continue}if(i.has(e)){a(`duplicate-${n}-field`,{field:e,kind:n},`Keymap ${n} field "${e}" is already registered`);continue}i.set(e,t),s.push([e,t])}return()=>{for(let[e,t]of s)i.get(e)===t&&i.delete(e)}}function ql(e,t,n,r,i){let a;try{a=Os(i.name)}catch(e){return t.emitError(`token-name-normalize-error`,e,Hc(e,`Failed to register keymap token`)),Wl}if(e.tokens.has(a)||e.patterns.has(a))return t.emitError(`duplicate-token`,{token:a},`Keymap token "${a}" is already registered`),Wl;let o;try{if(o=n.parseTokenKey(i.key),o.patternName)throw Error(`Invalid key "${String(i.key)}": expected a concrete key stroke`)}catch(e){return t.emitError(`token-parse-error`,e,Hc(e,`Failed to register keymap token "${a}"`)),Wl}let s={stroke:o.stroke,match:o.match},c=new Map(e.tokens);c.set(a,s);try{r.applyTokenState(c)}catch(e){return t.emitError(`token-register-error`,e,Hc(e,`Failed to register keymap token "${a}"`)),Wl}return()=>{if(e.tokens.get(a)!==s)return;let n=new Map(e.tokens);n.delete(a);try{r.applyTokenState(n)}catch(e){t.emitError(`token-unregister-error`,e,Hc(e,`Failed to unregister keymap token "${a}"`))}}}function Jl(e,t,n,r){let i,a;try{i=Os(r.name);let e=Gl(i,`min`,r.min,1),t=Gl(i,`max`,r.max,2**53-1);if(t<e)throw Error(`Keymap sequence pattern "${i}" max must be greater than or equal to min`);a={name:i,display:r.display,payloadKey:r.payloadKey??i,match:Ls(`pattern:${i}`),min:e,max:t,matcher:e=>r.match(e),finalize:r.finalize}}catch(e){return t.emitError(`sequence-pattern-register-error`,e,Hc(e,`Failed to register keymap sequence pattern`)),Wl}return e.tokens.has(i)||e.patterns.has(i)?(t.emitError(`duplicate-sequence-pattern`,{pattern:i},`Keymap sequence pattern "${i}" is already registered`),Wl):(e.patterns.set(i,a),n.recompileBindings(),()=>{e.patterns.get(i)===a&&(e.patterns.delete(i),n.recompileBindings())})}function Yl(e,t,n,r){return Kl(r,{kind:n,reservedFields:n===`layer`?jc:n===`binding`?Ac:kc,registeredFields:n===`layer`?e.layerFields:n===`binding`?e.bindingFields:e.commandFields,emitError:(e,n,r)=>t.emitError(e,n,r)})}var Xl=()=>{};function Zl(e,t){return t.priority-e.priority||t.order-e.order}function Ql(e){if(e.matchers.length>0)return!0;for(let t of e.commands)if(t.matchers.length>0)return!0;for(let t of e.bindings)if(t.matchers.length>0)return!0;return!1}function $l(e){if(e.commands.length===0)return!1;if(e.matchers.length>0)return!0;for(let t of e.commands)if(t.matchers.length>0)return!0;return!1}function eu(e,t,n,r,i){let a=n=>t.runWithStateChangeBatch(()=>{let a=n.target;if(a&&i.host.isTargetDestroyed(a))return t.emitError(`destroyed-layer-target`,{target:a},`Cannot register a keymap layer for a destroyed keymap target`),Xl;let o,s,c,p,m,v,y;try{y=l(n),o=u(pc(n.bindings??[]),n);let e=d(n.commands??[],n);v=e.length===0?[]:i.commands.normalizeCommands(e),{requires:s,matchers:c,fields:p,attrs:m}=f(n)}catch(e){return t.emitError(`register-layer-failed`,e,Hc(e,`Failed to register keymap layer`)),Xl}let b=e.order++,x=i.compiler.compileBindings(o,e.tokens,a,b,p);if(x.bindings.length===0&&!x.hasTokenBindings&&v.length===0)return Xl;i.diagnostics?.analyzeLayer({target:a,order:b,commands:v,sourceBindings:o,bindings:x.bindings,hasTokenBindings:x.hasTokenBindings});let S={order:b,target:a,targetMode:y,priority:n.priority??0,requires:s,matchers:c,fields:p,attrs:m,commands:v,sourceBindings:o,bindings:x.bindings,root:ec(x.bindings,e.patterns),hasTokenBindings:x.hasTokenBindings,activeKeyCacheBlocked:!1,activeCommandViewCacheBlocked:!1};_(S),e.layers.add(S),e.sortedLayers=[...e.sortedLayers,S].sort(Zl),g(S);for(let e of S.commands)g(e);for(let e of S.bindings)g(e);return a&&(S.offTargetDestroy=i.host.onTargetDestroy(a,()=>{h(S)})),S.commands.length>0&&r.ensureValidPendingSequence(),t.queueStateChange(),()=>{h(S)}}),o=n=>{t.runWithStateChangeBatch(()=>{let i=new Map;for(let t of e.layers)t.hasTokenBindings&&i.set(t,p(t,n));e.tokens=n;let a=!1;for(let[e,t]of i)m(e,t)&&(a=!0);a&&r.setPendingSequence(null),i.size>0&&t.queueStateChange()})},s=()=>{t.runWithStateChangeBatch(()=>{let n=0,i=!1;for(let t of e.layers){if(t.sourceBindings.length===0)continue;let r=p(t,e.tokens);m(t,r)&&(i=!0),n+=1}i&&r.setPendingSequence(null),n>0&&t.queueStateChange()})},c=()=>{for(let t of e.layers){y(t);for(let e of t.commands)y(e);for(let e of t.bindings)y(e);t.offTargetDestroy?.(),t.offTargetDestroy=void 0}},l=e=>{if(e.targetMode){if(!e.target)throw Error(`Keymap targetMode "${e.targetMode}" requires a target`);return e.targetMode}return e.target?`focus-within`:void 0},u=(t,n)=>{let r=e.layerBindingsTransformers.values();if(r.length===0)return t;let i=t;for(let e of r){let t=e(i,{layer:n,validateBindings:e=>fc(e)});t&&(i=pc(t))}return i},d=(n,r)=>{let i=e.commandTransformers.values();if(n.length===0||i.length===0)return n;let a=[];for(let e of n){let n={...e},o=[],s=!0;for(let e of i)try{e(n,{layer:r,add(e){o.push({...e})},skipOriginal(){s=!1}})}catch(e){t.emitError(`command-transformer-error`,e,`[Keymap] Error in command transformer:`)}s&&a.push(n),a.push(...o)}return a},f=t=>{let r={},a=[],o=Object.create(null),s={};for(let[c,l]of Object.entries(t)){if(jc.has(c)||l===void 0)continue;o[c]=Wc(l);let t=e.layerFields.get(c);if(!t){i.warnUnknownField(`layer`,c);continue}t(l,Bc({fieldName:c,conditions:n,requirements:r,matchers:a,attrs:s}))}return{requires:Object.entries(r),matchers:a,fields:Object.keys(o).length>0?Object.freeze(o):void 0,attrs:Object.keys(s).length>0?Wc(s,{freeze:!0}):void 0}},p=(e,t)=>i.compiler.compileBindings(e.sourceBindings,t,e.target,e.order,e.fields),m=(t,n)=>{i.diagnostics?.analyzeLayer({target:t.target,order:t.order,commands:t.commands,sourceBindings:t.sourceBindings,bindings:n.bindings,hasTokenBindings:n.hasTokenBindings}),v(t);for(let e of t.bindings)y(e);t.bindings=n.bindings,t.root=ec(n.bindings,e.patterns),t.hasTokenBindings=n.hasTokenBindings,_(t);for(let e of t.bindings)g(e);return e.pending?.captures.some(e=>e.layer===t)??!1},h=n=>{t.runWithStateChangeBatch(()=>{if(e.layers.delete(n)){e.sortedLayers=e.sortedLayers.filter(e=>e!==n),v(n),y(n);for(let e of n.commands)y(e);for(let e of n.bindings)y(e);n.offTargetDestroy?.(),n.offTargetDestroy=void 0,e.pending?.captures.some(e=>e.layer===n)?r.setPendingSequence(null):n.commands.length>0&&!i.host.isDestroyed&&r.ensureValidPendingSequence(),t.queueStateChange()}})},g=e=>{for(let n of e.matchers)if(n.subscribe)try{n.dispose=n.subscribe(()=>{if(!r.hasPendingSequenceState()){t.queueStateChange();return}t.runWithStateChangeBatch(()=>{r.revalidatePendingSequenceIfNeeded(),t.queueStateChange()})})}catch(e){t.emitError(`reactive-matcher-subscribe-error`,e,Hc(e,`Failed to subscribe to reactive matcher from ${n.source}`))}},_=t=>{let n=Ql(t),r=$l(t);t.activeKeyCacheBlocked=n,t.activeCommandViewCacheBlocked=r,n&&(e.activeKeyCacheBlockers+=1),r&&(e.activeCommandViewCacheBlockers+=1)},v=t=>{t.activeKeyCacheBlocked&&=(--e.activeKeyCacheBlockers,!1),t.activeCommandViewCacheBlocked&&=(--e.activeCommandViewCacheBlockers,!1)},y=e=>{for(let n of e.matchers)if(n.dispose){try{n.dispose()}catch(e){t.emitError(`reactive-matcher-dispose-error`,e,Hc(e,`Failed to dispose reactive matcher from ${n.source}`))}n.dispose=void 0}};return{registerLayer:a,applyTokenState:o,recompileBindings:s,cleanup:c}}var tu=1e3;function nu(e,t,n){let r=(e,n,r)=>{if(!t.has(`warning`)){let t=`[${e}] ${r}`;n instanceof Error?console.warn(t,n):console.warn(t);return}t.emit(`warning`,{code:e,message:r,warning:n})},i=(e,n,r)=>{if(!t.has(`error`)){let t=`[${e}] ${r}`;n instanceof Error?console.error(t,n):console.error(t);return}t.emit(`error`,{code:e,message:r,error:n})},a=()=>{if(!(!e.stateChangePending||e.stateChangeDepth>0||e.flushingStateChange)){e.flushingStateChange=!0;try{let t=0;for(;e.stateChangePending&&e.stateChangeDepth===0;){if(t>=tu){e.stateChangePending=!1,i(`state-change-feedback-loop`,{iterations:tu},`[Keymap] Possible infinite state listener feedback loop detected after ${tu} iterations; pending state notifications were dropped`);break}t+=1,e.stateChangePending=!1,n.emit(`state`)}}finally{e.flushingStateChange=!1}}};return{runWithStateChangeBatch(t){e.stateChangeDepth+=1;try{return t()}finally{--e.stateChangeDepth,e.stateChangeDepth===0&&a()}},queueStateChange(t){e.derivedVersion+=1,t?.invalidateCaches!==!1&&(e.cacheVersion+=1),n.has(`state`)&&(e.stateChangePending=!0,e.stateChangeDepth===0&&!e.flushingStateChange&&a())},emitWarning:r,emitError:i,reportListenerError(e,t){if(e===`state`){i(`state-listener-error`,t,`[Keymap] Error in state listener:`);return}if(e===`pendingSequence`){i(`pending-sequence-listener-error`,t,`[Keymap] Error in pending sequence listener:`);return}e===`dispatch`&&i(`dispatch-listener-error`,t,`[Keymap] Error in dispatch listener:`)},warnOnce(t,n,i,a){e.usedWarningKeys.has(t)||(e.usedWarningKeys.add(t),r(n,i,a))}}}function ru(e,t,n){return{getData(t){return e.data[t]},setData(r,i){t.runWithStateChangeBatch(()=>{if(i===void 0){if(!(r in e.data))return;delete e.data[r],e.dataVersion+=1,n.ensureValidPendingSequence(),t.queueStateChange();return}Object.is(e.data[r],i)||(e.data[r]=i,e.dataVersion+=1,n.ensureValidPendingSequence(),t.queueStateChange())})},getReadonlyData(){return e.readonlyDataVersion===e.dataVersion?e.readonlyData:(e.readonlyData=Object.freeze({...e.data}),e.readonlyDataVersion=e.dataVersion,e.readonlyData)}}}var iu=Object.freeze({});function au(){return{order:0,tokens:new Map,patterns:new Map,layerFields:new Map,layerBindingsTransformers:lc(),bindingExpanders:lc(),bindingParsers:lc(),bindingTransformers:lc(),bindingFields:new Map,commandTransformers:lc(),commandFields:new Map,eventMatchResolvers:lc(),disambiguationResolvers:lc(),keyHooks:uc(),keyAfterHooks:uc(),rawHooks:uc(),layers:new Set,sortedLayers:[],activeLayersCacheVersion:-1,activeLayersCacheFocused:void 0,activeLayersCache:[],activeKeyCacheBlockers:0,activeCommandViewCacheBlockers:0,commandResolvers:lc(),pending:null,data:{},dataVersion:0,readonlyDataVersion:-1,readonlyData:iu,cacheVersion:0,derivedVersion:0,stateChangeDepth:0,stateChangePending:!1,flushingStateChange:!1,usedWarningKeys:new Set}}function ou(e){return Fs(e)}var su=class{#e=au();#t=!1;#n=new Map;#r=[];#i=sc(()=>{});#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;getPendingSequence;getActiveKeys;constructor(e){if(this.#b=e,e.isDestroyed)throw Error(`Cannot create a keymap for a destroyed host`);this.#a=sc((e,t)=>{this.#o.reportListenerError(e,t)}),this.#o=nu(this.#e,this.#i,this.#a),this.#l=Al(this.#e,this.#o),this.#u=Jc(this.#e,this.#b,this.#o,this.#l,{onCommandResolversChanged:()=>{this.#s.ensureValidPendingSequence()}}),this.#s=Oc(this.#e,this.#b,this.#a,this.#o,this.#l,this.#u,{onPendingSequenceChanged:(e,t)=>{this.#p?.handlePendingSequenceChange(e,t)}}),this.#c=ru(this.#e,this.#o,this.#s),this.#d=hl(this.#o,this.#c,this.#s,this.#u,{keymap:this,createCommandEvent:()=>this.#b.createCommandEvent()}),this.#f=Sl(this.#e,this.#o,this.#l,{warnUnknownField:(e,t)=>{this.#C(e,t)},warnUnknownToken:(e,t)=>{this.#w(e,t)}}),this.#h=hc(this.#o,this.#u),this.#m=eu(this.#e,this.#o,this.#l,this.#s,{compiler:this.#f,commands:this.#u,host:this.#b,diagnostics:this.#h,warnUnknownField:(e,t)=>{this.#C(e,t)}}),this.#p=Vl(this.#e,this.#o,this.#c,this.#s,this.#l,this.#d,this.#f,this.#u,this.#m,this.#a),this.getPendingSequence=this.#s.getPendingSequence,this.getActiveKeys=this.#s.getActiveKeys,this.#g=e=>{this.#p.handleKeyEvent(e,!1)},this.#_=e=>{this.#p.handleKeyEvent(e,!0)},this.#v=e=>this.#p.handleRawSequence(e),this.#y=e=>{this.#S(e)},this.#r.push(this.#b.onKeyPress(this.#g)),this.#r.push(this.#b.onKeyRelease(this.#_)),this.#b.onRawInput&&this.#r.push(this.#b.onRawInput(this.#v)),this.#r.push(this.#b.onFocusChange(this.#y)),this.#b.onDestroy&&this.#r.push(this.#b.onDestroy(()=>{this.#x()}))}[Hs](){return{state:this.#e,host:this.#b,conditions:this.#l,catalog:this.#u,activation:this.#s}}#x(){if(!this.#t){this.#t=!0,this.#s.setPendingSequence(null);for(let e of this.#n.values())e.dispose();this.#n.clear(),this.#m.cleanup();for(let e of this.#r.splice(0))e()}}setData(e,t){this.#c.setData(e,t)}getData(e){return this.#c.getData(e)}getHostMetadata(){return this.#b.metadata}hasPendingSequence(){return this.#s.ensureValidPendingSequence()!==void 0}createKeyMatcher(e){let t=this.#f.parseTokenKey(e).match;return e=>e?ou(e)===t:!1}parseKeySequence(e){return this.#f.parseKeySequence(e)}formatKey(e,t){return this.#f.formatKey(e,t)}clearPendingSequence(){this.#s.setPendingSequence(null)}popPendingSequence(){return this.#s.popPendingSequence()}getCommands(e){return this.#u.getCommands(e)}getCommandEntries(e){return this.#u.getCommandEntries(e)}getCommandBindings(e){return this.#u.getCommandBindings(e)}acquireResource(e,t){if(this.#t||this.#b.isDestroyed)throw Error(`Cannot use a keymap after its host was destroyed`);let n=this.#n.get(e);if(n)return n.count+=1,()=>{this.#T(e,n)};let r={count:1,dispose:t()};return this.#n.set(e,r),()=>{this.#T(e,r)}}runCommand(e,t){return this.#d.runCommand(e,t)}dispatchCommand(e,t){return this.#d.dispatchCommand(e,t)}on(e,t){return e===`warning`||e===`error`?this.#i.hook(e,t):this.#a.hook(e,t)}intercept(e,t,n){return this.#p.intercept(e,t,n)}registerLayer(e){return this.#m.registerLayer(e)}registerLayerFields(e){return Yl(this.#e,this.#o,`layer`,e)}prependLayerBindingsTransformer(e){return this.#e.layerBindingsTransformers.prepend(e)}appendLayerBindingsTransformer(e){return this.#e.layerBindingsTransformers.append(e)}clearLayerBindingsTransformers(){this.#e.layerBindingsTransformers.clear()}prependBindingTransformer(e){return this.#e.bindingTransformers.prepend(e)}appendBindingTransformer(e){return this.#e.bindingTransformers.append(e)}clearBindingTransformers(){this.#e.bindingTransformers.clear()}prependCommandTransformer(e){return this.#e.commandTransformers.prepend(e)}appendCommandTransformer(e){return this.#e.commandTransformers.append(e)}clearCommandTransformers(){this.#e.commandTransformers.clear()}prependBindingParser(e){return this.#e.bindingParsers.prepend(e)}appendBindingParser(e){return this.#e.bindingParsers.append(e)}clearBindingParsers(){this.#e.bindingParsers.clear()}registerToken(e){return ql(this.#e,this.#o,this.#f,this.#m,e)}registerSequencePattern(e){return Jl(this.#e,this.#o,this.#m,e)}prependBindingExpander(e){return this.#e.bindingExpanders.prepend(e)}appendBindingExpander(e){return this.#e.bindingExpanders.append(e)}clearBindingExpanders(){this.#e.bindingExpanders.clear()}registerBindingFields(e){return Yl(this.#e,this.#o,`binding`,e)}registerCommandFields(e){return Yl(this.#e,this.#o,`command`,e)}prependCommandResolver(e){return this.#u.prependCommandResolver(e)}appendCommandResolver(e){return this.#u.appendCommandResolver(e)}clearCommandResolvers(){this.#u.clearCommandResolvers()}prependLayerAnalyzer(e){return this.#h.prependLayerAnalyzer(e)}appendLayerAnalyzer(e){return this.#h.appendLayerAnalyzer(e)}clearLayerAnalyzers(){this.#h.clearLayerAnalyzers()}prependEventMatchResolver(e){return this.#p.prependEventMatchResolver(e)}appendEventMatchResolver(e){return this.#p.appendEventMatchResolver(e)}clearEventMatchResolvers(){this.#p.clearEventMatchResolvers()}prependDisambiguationResolver(e){return this.#p.prependDisambiguationResolver(e)}appendDisambiguationResolver(e){return this.#p.appendDisambiguationResolver(e)}clearDisambiguationResolvers(){this.#p.clearDisambiguationResolvers()}#S(e){this.#o.runWithStateChangeBatch(()=>{this.#s.setPendingSequence(null),this.#o.queueStateChange({invalidateCaches:!1})})}#C(e,t){this.#o.warnOnce(`${e}:${t}`,`unknown-${e}-field`,{field:t,kind:e},`[Keymap] Unknown ${e} field "${t}" was ignored`)}#w(e,t){this.#o.warnOnce(`token:${e}`,`unknown-token`,{token:e,sequence:t},`[Keymap] Unknown token "${e}" in key sequence "${t}"; binding was skipped until the token is registered`)}#T(e,t){this.#n.get(e)===t&&(--t.count,!(t.count>0)&&(t.dispose(),this.#n.delete(e)))}},cu=new Set(`up.down.left.right.clear.escape.return.linefeed.enter.tab.backspace.delete.insert.home.end.pageup.pagedown.space.lt.gt.plus.minus.equal.comma.period.slash.backslash.semicolon.quote.backquote.leftbracket.rightbracket.capslock.numlock.scrolllock.printscreen.pause.menu.apps.kp0.kp1.kp2.kp3.kp4.kp5.kp6.kp7.kp8.kp9.kpdecimal.kpdivide.kpmultiply.kpminus.kpplus.kpenter.kpequal.kpseparator.kpleft.kpright.kpup.kpdown.kppageup.kppagedown.kphome.kpend.kpinsert.kpdelete.mediaplay.mediapause.mediaplaypause.mediareverse.mediastop.mediafastforward.mediarewind.medianext.mediaprev.mediarecord.volumedown.volumeup.mute.leftshift.leftctrl.leftalt.leftsuper.lefthyper.leftmeta.rightshift.rightctrl.rightalt.rightsuper.righthyper.rightmeta.iso_level3_shift.iso_level5_shift.option.alt.meta.super.hyper.control.ctrl.shift`.split(`.`)),lu=new Set([`ctrl`,`control`,`shift`,`meta`,`alt`,`option`,`super`,`hyper`]),uu=fu(cu),du=fu(lu);function fu(e){let t=new Map;for(let n of e){let e=n.charCodeAt(0);if(Number.isNaN(e))continue;let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}for(let e of t.values())e.sort((e,t)=>t.length-e.length);return t}function pu(e){return e>=65&&e<=90?e+32:e}function mu(e){return e>=48&&e<=57}function hu(e,t,n){if(e.startsWith(t,n))return!0;if(n+t.length>e.length)return!1;for(let r=0;r<t.length;r+=1)if(pu(e.charCodeAt(n+r))!==t.charCodeAt(r))return!1;return!0}function gu(e,t,n){let r=t.charCodeAt(n);if(Number.isNaN(r))return;let i=e.get(pu(r));if(i){for(let e of i)if(hu(t,e,n))return e}}function _u(e,t,n,r,i){return e.parseObjectKey(t,{display:n,match:r,tokenName:i})}function vu(e,t){if(e===` `)return t.parseObjectKey({name:`space`},{display:`space`});if(e===`+`)return t.parseObjectKey({name:`+`},{display:`+`});let n=e.split(`+`),r=``,i=``,a=!1,o=!1,s=!1,c=!1,l=!1;for(let t of n){let n=t.trim();if(!n)continue;let u=n.toLowerCase();if(u===`ctrl`||u===`control`){a=!0;continue}if(u===`shift`){o=!0;continue}if(u===`meta`||u===`alt`||u===`option`){s=!0;continue}if(u===`super`){c=!0;continue}if(u===`hyper`){l=!0;continue}if(r)throw Error(`Invalid key "${e}": multiple key names are not supported`);r=n,i=u}if(!r)throw Error(`Invalid key "${e}": missing key name`);let u=[];return a&&u.push(`ctrl`),o&&u.push(`shift`),s&&u.push(`meta`),c&&u.push(`super`),l&&u.push(`hyper`),u.push(i),t.parseObjectKey({name:r,ctrl:a,shift:o,meta:s,super:c,hyper:l||void 0},{display:u.join(`+`)})}function yu(e,t){let n=e.trim().toLowerCase();return t.parseObjectKey({name:n},{display:n})}function bu(e,t){let n=gu(uu,e,t);if(n)return n;if(pu(e.charCodeAt(t))!==102||!mu(e.charCodeAt(t+1)))return;let r=mu(e.charCodeAt(t+2))?t+3:t+2;return e.slice(t,r).toLowerCase()}function xu(e,t){return gu(du,e,t)}function Su(e,t,n){let r=t,i=!1,a=!1,o=!1,s=!1,c=!1;for(;r<e.length;){let t=xu(e,r);if(!t)break;let n=r+t.length;if(e[n]!==`+`)break;t===`ctrl`||t===`control`?i=!0:t===`shift`?a=!0:t===`meta`||t===`alt`||t===`option`?o=!0:t===`super`?s=!0:t===`hyper`&&(c=!0),r=n+1}if(r===t)return;let l=e[r];if(l===void 0)throw Error(`Invalid key "${e.slice(t)}": missing key name`);let u=bu(e,r)??l,d=u===` `?`space`:u===`+`?`+`:u.toLowerCase(),f=[];return i&&f.push(`ctrl`),a&&f.push(`shift`),o&&f.push(`meta`),s&&f.push(`super`),c&&f.push(`hyper`),f.push(d),{part:n.parseObjectKey({name:u===` `?`space`:u,ctrl:i,shift:a,meta:o,super:s,hyper:c||void 0},{display:f.join(`+`)}),nextIndex:r+u.length}}var Cu=e=>{let{input:t,index:n,tokens:r,normalizeTokenName:i}=e;if(n===0&&t.includes(`+`)&&/\s/.test(t))return{parts:[vu(t,e)],nextIndex:t.length};let a=t[n];if(a===void 0)return;if(a===`<`){let o=t.indexOf(`>`,n);if(o===-1)return{parts:[vu(a,e)],nextIndex:n+1};let s=i(t.slice(n+1,o)),c=r.get(s);return c?{parts:[_u(e,c.stroke,`<${s}>`,c.match,s)],nextIndex:o+1,usedTokens:[s]}:{parts:[],nextIndex:o+1,unknownTokens:[s]}}if(a===`{`){let r=t.indexOf(`}`,n);if(r===-1)return{parts:[vu(a,e)],nextIndex:n+1};let o=i(t.slice(n+1,r)),s=e.patterns.get(o);return s?{parts:[{...e.parseObjectKey({name:o,ctrl:!1,shift:!1,meta:!1,super:!1},{display:s.display??`{${o}}`,match:s.match}),patternName:s.name,payloadKey:s.payloadKey}],nextIndex:r+1,usedTokens:[o]}:{parts:[],nextIndex:r+1,unknownTokens:[o]}}let o=Su(t,n,e);if(o)return{parts:[o.part],nextIndex:o.nextIndex};let s=bu(t,n);return s?{parts:[yu(s,e)],nextIndex:n+s.length}:{parts:[vu(a,e)],nextIndex:n+1}},wu=(e,t)=>[t.resolveKey({name:e.name,ctrl:e.ctrl,shift:e.shift,meta:e.meta,super:e.super??!1,hyper:e.hyper||void 0})];function Tu(e){return e.appendBindingParser(e=>Cu(e))}function Eu(e){return e.appendEventMatchResolver((e,t)=>wu(e,t))}function Du(e){let t=Tu(e),n=Eu(e);return()=>{n(),t()}}var Ou=Symbol(`keymap:mod-bindings`),ku=/(^|[+,\s])mod(?=\s*\+)/i,Au=/(^|[+,\s])mod(?=\s*\+)/gi;function ju(e){let t=e.primaryModifier;return(t===`ctrl`||t===`super`)&&e.modifiers[t]!==`unsupported`?t:e.modifiers.ctrl===`unsupported`?`super`:`ctrl`}function Mu(e){if(e.includes(`,`))return[e];let t=e.trim();return t.includes(` `)?t.split(/\s+/):[e]}function Nu(e){return e.acquireResource(Ou,()=>e.appendBindingExpander(({input:t,displays:n})=>{if(!ku.test(t))return;let r=ju(e.getHostMetadata());return[{key:t.replace(Au,(e,t)=>`${t}${r}`),displays:n??Mu(t)}]}))}var Pu=new Map([[` `,`space`],[`Spacebar`,`space`],[`ArrowUp`,`up`],[`ArrowDown`,`down`],[`ArrowLeft`,`left`],[`ArrowRight`,`right`],[`Escape`,`escape`],[`Esc`,`escape`],[`Enter`,`return`],[`Backspace`,`backspace`],[`Delete`,`delete`],[`Tab`,`tab`],[`Home`,`home`],[`End`,`end`],[`PageUp`,`pageup`],[`PageDown`,`pagedown`],[`Insert`,`insert`],[`CapsLock`,`capslock`],[`NumLock`,`numlock`],[`ScrollLock`,`scrolllock`],[`ContextMenu`,`menu`],[`Meta`,`super`],[`OS`,`super`],[`Alt`,`alt`],[`Control`,`control`],[`Shift`,`shift`]]);function Fu(e){let t=e?.trim().toLowerCase();return t?t.includes(`mac`)||t.includes(`darwin`)?`macos`:t.includes(`win`)?`windows`:t.includes(`linux`)||t.includes(`x11`)?`linux`:`unknown`:`unknown`}function Iu(){let e=globalThis.navigator,t=e?.userAgentData?.platform,n=Fu(t);return n===`unknown`?Fu(e?.platform??e?.userAgent):n}function Lu(){let e=Iu();return{platform:e,primaryModifier:e===`macos`?`super`:e===`unknown`?`unknown`:`ctrl`,modifiers:{ctrl:`supported`,shift:`supported`,meta:`supported`,super:`supported`,hyper:`unsupported`}}}function Ru(e){return e.length===1&&!/^[a-z0-9]$/i.test(e)}function zu(e){let t={name:e.name,ctrl:e.ctrl,shift:e.shift,meta:e.meta,super:e.super??!1,hyper:e.hyper||void 0};return!t.shift||!Ru(t.name)?[t]:[t,{...t,shift:!1}]}var Bu=class{name;ctrl;shift;meta;superKey;originalEvent;propagationStopped=!1;constructor(e,t,n,r,i,a){this.name=e,this.ctrl=t,this.shift=n,this.meta=r,this.superKey=i,this.originalEvent=a}get super(){return this.superKey}preventDefault(){this.originalEvent?.preventDefault()}stopPropagation(){this.propagationStopped=!0,this.originalEvent?.stopPropagation()}};function Vu(){return globalThis.MutationObserver}function Hu(e){return Pu.get(e)||(/^F\d{1,2}$/i.test(e)||e.length===1?e.toLowerCase():e.trim().toLowerCase().replace(/\s+/g,``))}function Uu(e){if(!e)return new Bu(`command`,!1,!1,!1,!1);let t=globalThis.KeyboardEvent;return new Bu(Hu(e.key),e.ctrlKey,e.shiftKey,e.altKey,e.metaKey,t&&e instanceof t?e:void 0)}var Wu=class{metadata=Lu();rootTarget;isDestroyed=!1;observer;targetDestroyListeners=new Map;constructor(e){this.rootTarget=e}getFocusedTarget(){let e=this.rootTarget.ownerDocument.activeElement;return!e||typeof e!=`object`?null:e===this.rootTarget||this.rootTarget.contains(e)?e:null}getParentTarget(e){return e.parentElement}isTargetDestroyed(e){return e===this.rootTarget?!1:!e.isConnected||!this.rootTarget.contains(e)}onKeyPress(e){let t=t=>{e(Uu(t))};return this.rootTarget.addEventListener(`keydown`,t,{capture:!0}),()=>{this.rootTarget.removeEventListener(`keydown`,t,{capture:!0})}}onKeyRelease(e){let t=t=>{e(Uu(t))};return this.rootTarget.addEventListener(`keyup`,t,{capture:!0}),()=>{this.rootTarget.removeEventListener(`keyup`,t,{capture:!0})}}onFocusChange(e){let t=()=>{queueMicrotask(()=>{e(this.getFocusedTarget())})};return this.rootTarget.addEventListener(`focusin`,t,{capture:!0}),this.rootTarget.addEventListener(`focusout`,t,{capture:!0}),()=>{this.rootTarget.removeEventListener(`focusin`,t,{capture:!0}),this.rootTarget.removeEventListener(`focusout`,t,{capture:!0})}}onTargetDestroy(e,t){let n=this.targetDestroyListeners.get(e);return n||(n=new Set,this.targetDestroyListeners.set(e,n)),n.add(t),this.ensureObserver(),this.flushDisconnectedTargets(),()=>{let n=this.targetDestroyListeners.get(e);n&&(n.delete(t),n.size===0&&this.targetDestroyListeners.delete(e),this.targetDestroyListeners.size===0&&this.disconnectObserver())}}createCommandEvent(){return Uu()}ensureObserver(){if(this.observer||this.targetDestroyListeners.size===0)return;let e=Vu();e&&(this.observer=new e(()=>{this.flushDisconnectedTargets()}),this.observer.observe(this.rootTarget,{childList:!0,subtree:!0}))}disconnectObserver(){this.observer&&=(this.observer.disconnect(),void 0)}flushDisconnectedTargets(){for(let[e,t]of this.targetDestroyListeners)if(this.isTargetDestroyed(e)){this.targetDestroyListeners.delete(e);for(let e of[...t])e()}this.targetDestroyListeners.size===0&&this.disconnectObserver()}};function Gu(e){return new Wu(e)}var Ku=(e,t)=>zu(e).map(e=>t.resolveKey(e));function qu(e){return e instanceof G?{code:e.code,message:Yu(e.message),retryable:e.retryable,...e.need!==void 0&&{need:e.need}}:{code:`HOST_FAILURE`,message:`Host operation failed`,retryable:!1}}function Ju(e){try{let t=qt(e);return new G(t.message,{code:t.code,retryable:t.retryable,...t.need!==void 0&&{need:t.need}})}catch(e){return new G(`The host returned a malformed error`,{cause:e,code:`PROTOCOL`,retryable:!1})}}function Yu(e){return e.trim().slice(0,512)||`Host operation failed`}var Xu=e=>({ok:!0,value:e}),Zu=e=>({error:qu(e),ok:!1});async function Qu(e,t){let n,r=new Set;try{return n=await e,$u(t(n))}catch(e){throw ed(e)&&td(e,r),e instanceof G?e:new G(`The remote operation failed`,{cause:e,code:`HOST_FAILURE`,retryable:!0})}finally{n!==e&&ed(n)&&td(n,r)}}function $u(e){if(e.ok)return e.value;throw Ju(e.error)}function ed(e){return Tn(e)&&Symbol.dispose in e&&m(e[Symbol.dispose])}function td(e,t){if(!t.has(e)){t.add(e);try{e[Symbol.dispose]()}catch(e){console.warn(`RPC result disposal failed`,e)}}}function nd(){let e=[],t=new Set;return{get:()=>e,subscribe:e=>(t.add(e),()=>t.delete(e)),update:n=>{e=n;for(let e of Array.from(t))try{e()}catch(e){console.warn(`App binding subscriber failed`,e)}}}}function rd(e){let t=Ct(e),n=new Set;return{get:()=>t,subscribe:e=>(n.add(e),()=>n.delete(e)),update:e=>{t=Ct(e);for(let e of Array.from(n))try{e()}catch(e){console.warn(`Reserved chord subscriber failed`,e)}}}}function id(e){let t=!0,n,r=e.window.document.querySelector(`html`);if(!r)return()=>{t=!1};let i=Gu(r),a=new su(i);Du(a),Nu(a),a.prependEventMatchResolver(Ku);let o=od(e.onBroken),s=ud(a,e.chords,e.remote,o),c=ad(e,o,()=>t,e=>{n=e},()=>n),l=i.onFocusChange(()=>{queueMicrotask(c)}),u=()=>{queueMicrotask(c)};e.window.addEventListener(`focus`,u),e.window.addEventListener(`blur`,u);let d=e.bindings,f=()=>sd(e.window.document,e.identity.surfaceId).editing,p=d===void 0?()=>void 0:cd(a,d,f),m=d===void 0?()=>void 0:d.subscribe(()=>{p(),p=cd(a,d,f)}),h=e.chords.subscribe(()=>{s(),s=ud(a,e.chords,e.remote,o)});return queueMicrotask(c),()=>{t&&(t=!1,l(),e.window.removeEventListener(`focus`,u),e.window.removeEventListener(`blur`,u),h(),s(),m(),p())}}function ad(e,t,n,r,i){return()=>{if(!n())return;let a=sd(e.window.document,e.identity.surfaceId),o=i();(a.editing!==o?.editing||a.surface!==o.surface)&&(r(a),t(()=>e.remote.reportFocus(a)))}}function od(e){return t=>{try{Qu(t(),Se).catch(t=>{fa(`browser-bridge.host-call`,t),e(t)})}catch(t){fa(`browser-bridge.host-call`,t),e(t)}}}function sd(e,t){let n=e.activeElement;return Ot({editing:!!(n?.matches(`input, textarea, select, [contenteditable='true']`)===!0||n?.closest(`[contenteditable='true']`)),surface:e.hasFocus()?t:null})}function cd(e,t,n){let r=t.get();return e.registerLayer({bindings:r.map((e,t)=>({cmd:`app/${String(t)}`,key:e.key})),commands:r.map((e,t)=>({name:`app/${String(t)}`,run:t=>{let r=t.event.originalEvent;if(r?.defaultPrevented||r?.isComposing||ld(e.key)&&n())return!1;e.run()}})),priority:500})}function ld(e){return!/(?:^|\+)(?:ctrl|control|super|meta|cmd|alt|option|mod)\+/iu.test(e)}function ud(e,t,n,r){let i=t.get();return e.registerLayer({bindings:i.map(e=>({cmd:`reserved/${e.id}`,key:{ctrl:e.ctrlKey,meta:e.altKey,name:Hu(e.key),shift:e.shiftKey,super:e.metaKey}})),commands:i.map(e=>({name:`reserved/${e.id}`,run:t=>{let i=t.event.originalEvent;if(i?.defaultPrevented||i?.isComposing)return!1;r(()=>n.invokeReservedChord(e.id,i?.repeat??!1))}})),priority:1e3})}function dd(e){let t=t=>{if(t.defaultPrevented||t.isComposing)return;let n=md(t,e.mac);n!==null&&(t.preventDefault(),!t.repeat&&(n===`back`&&e.canGoBack()&&e.back(),n===`forward`&&e.canGoForward()&&e.forward()))},n=t=>{let n=pd(t.button);if(n===null)return;let r=t.defaultPrevented;t.preventDefault(),!(t.type!==`mouseup`||r)&&(n===`back`&&e.canGoBack()&&e.back(),n===`forward`&&e.canGoForward()&&e.forward())};e.window.addEventListener(`keydown`,t);for(let t of fd)e.window.addEventListener(t,n);return()=>{e.window.removeEventListener(`keydown`,t);for(let t of fd)e.window.removeEventListener(t,n)}}var fd=[`mousedown`,`mouseup`,`auxclick`];function pd(e){return e===3?`back`:e===4?`forward`:null}function md(e,t){return e.shiftKey||e.ctrlKey?null:t?!e.metaKey||e.altKey?null:e.key===`[`?`back`:e.key===`]`?`forward`:hd(e.target)?null:e.key===`ArrowLeft`?`back`:e.key===`ArrowRight`?`forward`:null:!e.altKey||e.metaKey?null:e.key===`ArrowLeft`?`back`:e.key===`ArrowRight`?`forward`:null}function hd(e){return e instanceof HTMLElement?e.isContentEditable||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement:!1}function gd(){return!Te(globalThis.navigator)&&/Mac|iPhone|iPad/u.test(globalThis.navigator.userAgent)}var _d=[];for(let e=0;e<256;++e)_d.push((e+256).toString(16).slice(1));function vd(e,t=0){return(_d[e[t+0]]+_d[e[t+1]]+_d[e[t+2]]+_d[e[t+3]]+`-`+_d[e[t+4]]+_d[e[t+5]]+`-`+_d[e[t+6]]+_d[e[t+7]]+`-`+_d[e[t+8]]+_d[e[t+9]]+`-`+_d[e[t+10]]+_d[e[t+11]]+_d[e[t+12]]+_d[e[t+13]]+_d[e[t+14]]+_d[e[t+15]]).toLowerCase()}var yd,bd=new Uint8Array(16);function xd(){if(!yd){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);yd=crypto.getRandomValues.bind(crypto)}return yd(bd)}var Sd={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Cd(e,t,n){if(Sd.randomUUID&&!t&&!e)return Sd.randomUUID();e||={};let r=e.random??e.rng?.()??xd();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return vd(r)}var wd=Tt({version:`v7`}),Td=K().regex(/^replay_[a-f0-9]{64}$/);re(e=>Td.safeParse(e).success);var Ed=Tt({version:`v4`});re(e=>wd.safeParse(e).success);var Dd=re(e=>Ed.safeParse(e).success);function Od(){return Dd.parse(Cd())}var kd=class extends Ft{#e=!0;#t;#n=new Map;constructor(e){super(),this.#t=e}cancel(e){try{return this.#n.get(Be(e))?.abort(),Promise.resolve(Xu(void 0))}catch(e){return Promise.resolve(Zu(e))}}dispose(){if(this.#e){this.#e=!1;for(let e of this.#n.values())e.abort();this.#n.clear()}}async invoke(e){try{if(!this.#e)throw new G(`The command is disposed`,{code:`DISCONNECTED`,retryable:!0});let t=he(e);if(this.#n.has(t.requestId))throw new G(`Duplicate command request`,{code:`PROTOCOL`,retryable:!1});if(this.#n.size>=64)throw new G(`Too many command requests`,{code:`HOST_FAILURE`,retryable:!0});let r=new AbortController;this.#n.set(t.requestId,r);try{let e=await this.#t(E(t,r.signal)),i=n(e);return Xu(i===void 0?{status:`handled`}:{status:`handled`,result:i})}finally{this.#n.delete(t.requestId)}}catch(e){if(e instanceof ho)try{let t={code:e.code,message:e.message,details:e.details};return Xu({status:`failed`,error:_(t)})}catch(e){return Zu(e)}return Zu(e)}}[Symbol.dispose](){this.dispose()}};function Ad(e){let t=[];for(let n of e.values()){let{commandId:e,definition:r,target:i}=n;if(e===void 0)continue;let a=r.availability?.status!==`unavailable`;for(let n of r.projections?.bindings?.values??[])n.trim().includes(` `)||n.startsWith(`<`)||t.push({key:n,run:()=>{a&&Promise.resolve().then(async()=>{let t=$u(await i.invoke({commandId:e,origin:`keyboard`,requestId:Od()}));if(t.status===`failed`)throw new ho(t.error.code,t.error.message,t.error.details)}).catch(e=>{console.warn(`App key command failed`,e)})}})}return t}function jd(e,t,n,r){let i=new Map,a=!1,o=()=>{r?.update(a?[]:Ad(i))},s=e=>{try{n()}catch(t){console.warn(`App command failure callback failed`,t,e)}},c=e=>{try{Qu(e(),Se).catch(e=>{s(e)})}catch(e){console.warn(`App command RPC supervision failed`,e),s(e)}};return{commands:Nd(e,t,i,()=>a,t=>{let n=i.get(t);if(!n)return;i.delete(t),n.target.dispose(),o();let r=n.commandId;!a&&r!==void 0&&c(()=>e.unregisterCommand(r))},o),dispose(){if(!a){a=!0;for(let e of i.values())e.target[Symbol.dispose]();i.clear(),o()}}}}function Md(e,t,n){let r=t.id;if(e.size>=128||e.has(r))throw n.dispose(),new G(`Command registration is unavailable`,{code:`INVALID_ARGUMENT`,retryable:!1});let i={commandId:void 0,definition:t,target:n};e.set(r,i);let a=!1;return{commit(e){a||(i.commandId=e)},release(){a||(a=!0,e.get(r)===i&&e.delete(r),n.dispose())},target:n}}function Nd(e,t,n,r,i,a){return Object.freeze({async register(o,s){if(t(),!m(s))throw new G(`Command handler must be a function`,{code:`INVALID_ARGUMENT`,retryable:!1});let c=Fe(o),l=new kd(s),u=Md(n,c,l);try{let t=await Pd(e,c,u.target);r()&&await Fd(e,t.commandId,l),u.commit(t.commandId),a()}catch(e){throw u.release(),e}let d=!0;return()=>{d&&(d=!1,i(c.id))}}})}async function Pd(e,t,n){return Qu(e.registerCommand(t,n),Ut)}async function Fd(e,t,n){throw n.dispose(),await Qu(e.unregisterCommand(t),Se),new G(`The command controller is disposed`,{code:`DISCONNECTED`,retryable:!0})}var Id=V(e=>e instanceof z),Ld=class extends Ft{#e=!1;#t;constructor(e){super(),this.#t=e}disconnect(e){try{if(this.#e)throw Jd();let t=e===void 0?void 0:qt(e);return setTimeout(()=>this.#t.disconnect?.(t??Qd()),0),Promise.resolve(Xu(void 0))}catch(e){return Promise.resolve(Zu(e))}}async requestClose(){try{if(this.#e)throw Jd();return Xu(await(this.#t.beforeClose?.()??!0))}catch(e){return Zu(e)}}async requestBack(){try{if(this.#e)throw Jd();return Xu(await(this.#t.back?.()??!1))}catch(e){return Zu(e)}}async requestForward(){try{if(this.#e)throw Jd();return Xu(await(this.#t.forward?.()??!1))}catch(e){return Zu(e)}}async activateNavigation(e){try{if(this.#e)throw Jd();let t=zt(e);return Ee(this.#t.navigation,t)?Xu(await(this.#t.activate?.(t)??!1)):Xu(!1)}catch(e){return Zu(e)}}async activateStatus(e){try{if(this.#e)throw Jd();let t=Sn(e);return S(this.#t.statusItems,t)?Xu(await(this.#t.statusAction?.(t)??!1)):Xu(!1)}catch(e){return Zu(e)}}[Symbol.dispose](){this.#e=!0}async updateContext(e){return this.#e?Zu(Jd()):this.#n(e,`context`,pn,e=>{this.#t.context.update(e)})}reconfigure(e){let t=[];try{if(this.#e)throw Jd();let n=Ye(e);if(n.context.version<=this.#t.versions.context)return Promise.resolve(Xu(void 0));for(let e of n.capabilities)t.push({...e,handle:I(Id)(e.handle).dup()});if(!this.#t.capabilities)throw Jd();return this.#t.capabilities.replace(t),t=[],this.#t.versions.context=n.context.version,this.#t.context.update(n.context.value),Promise.resolve(Xu(void 0))}catch(e){for(let e of t)De(e.handle);return Promise.resolve(Zu(e))}}updateLifecycle(e){try{if(this.#e)throw Jd();let t=sn(un)(e);if(t.version<=this.#t.versions.lifecycle)return Promise.resolve(Xu(void 0));if(!$d(this.#t.lifecycle.get(),t.value))throw new G(`The host sent an invalid lifecycle transition`,{code:`PROTOCOL`,retryable:!1});return this.#t.versions.lifecycle=t.version,this.#t.lifecycle.update(t.value),Promise.resolve(Xu(void 0))}catch(e){return Promise.resolve(Zu(e))}}async updateReservedChords(e){return this.#e?Zu(Jd()):this.#n(e,`chords`,Ct,e=>{this.#t.chords.update(e)})}async updateTheme(e){return this.#e?Zu(Jd()):this.#n(e,`theme`,$e,e=>{this.#t.theme.update(e)})}#n(e,t,n,r){try{let i=sn(n)(e);return i.version>this.#t.versions[t]&&(this.#t.versions[t]=i.version,r(i.value)),Promise.resolve(Xu(void 0))}catch(e){return Promise.resolve(Zu(e))}}};async function Rd(e){let t=Hd(),n=new Ld(t),r=c(e.port,n),i,a=Vd(r);try{performance.mark(`fungi.app-open.agar-rpc-connect-start`);let o=await Promise.race([r.connect({epoch:e.epoch,protocolVersion:2}),a]);performance.mark(`fungi.app-open.agar-rpc-connect-ready`),i=o;let s=$u(tn(o));if(!e.isActive())throw Bd();let c=Ud({bootstrap:s,bootstrapOwner:i,options:e,remote:r,state:t,target:n});return performance.mark(`fungi.app-open.agar-root-created`),i=void 0,c}catch(t){return tf(t,e,n,r,i)}}function zd(e,t){e.context.update(t.context.value),e.theme.update(t.theme.value),e.lifecycle.update(t.lifecycle.value),e.chords.update(t.chords.value),e.versions.context=t.context.version,e.versions.theme=t.theme.version,e.versions.lifecycle=t.lifecycle.version,e.versions.chords=t.chords.version}function Bd(){return new G(`App connection was cancelled`,{code:`CANCELLED`,retryable:!1})}function Vd(e){let t,n=new Promise((e,n)=>{t=n});return n.catch(e=>{fa(`app-session.rpc-disconnect`,e)}),e.onRpcBroken(()=>t?.(new G(`The app host disconnected`,{code:`DISCONNECTED`,retryable:!0}))),n}function Hd(){return{statusItems:[],navigation:{canGoBack:!1,canGoForward:!1},bindings:nd(),chords:rd([]),context:Me({computerId:null,focus:{editing:!1,surface:null},openRequest:null,visibility:`hidden`}),lifecycle:Me(`connecting`),theme:Me(`default`),canGoBack:!1,canGoForward:!1,versions:{chords:-1,context:-1,lifecycle:-1,theme:-1}}}function Ud(e){let t=Xt(e.bootstrap.identity),n=ef(e.bootstrap);zd(e.state,n);let r=k(e.bootstrap.capabilities);return e.state.capabilities=r,Gd(e,t,r)}function Wd(e,t,n){return id({bindings:e.state.bindings,chords:e.state.chords,identity:t,onBroken:e=>{n({code:`DISCONNECTED`,message:e instanceof G?e.message:`The app host rejected a browser bridge operation`,retryable:!0})},remote:e.remote,window:e.options.window})}function Gd(e,t,n){let r=!1,i=t=>{r||(r=!0,Xd([()=>{t&&e.state.lifecycle.update(`disconnected`)},()=>{e.state.lifecycle.update(`disposing`)},l,u,()=>{o.dispose()},()=>{e.state.beforeClose=void 0,e.state.back=void 0,e.state.forward=void 0,e.state.activate=void 0,e.state.statusAction=void 0},()=>{n.disconnect()},()=>{e.target[Symbol.dispose]()},()=>{De(e.bootstrapOwner)},()=>{De(e.remote)},()=>{e.options.port.close()},()=>{e.state.lifecycle.update(`disposed`)},e.options.onDisposed],`app connection disposal`))},a=()=>{if(r)throw new G(`The app connection is disposed`,{code:`DISCONNECTED`,retryable:!0})},o=jd(e.remote,a,()=>{i({code:`DISCONNECTED`,message:`The app host rejected a terminal command operation`,retryable:!0})},e.state.bindings),s=qd(e.remote,a,e.state),c=Kd(e.state,e.remote,a),l=Wd(e,t,i),u=dd({window:e.options.window,mac:gd(),canGoBack:()=>e.state.canGoBack&&e.state.back!==void 0,back:()=>{let t=e.state.back;t&&Promise.resolve().then(t).catch(e=>{fa(`app-window.back-input`,e)})},canGoForward:()=>e.state.canGoForward&&e.state.forward!==void 0,forward:()=>{let t=e.state.forward;t&&Promise.resolve().then(t).catch(e=>{fa(`app-window.forward-input`,e)})}});return e.state.disconnect=i,e.remote.onRpcBroken(()=>{Yd(i)}),Zd({capabilities:n.directory,commands:o.commands,context:e.state.context,dispose:i,identity:t,lifecycle:e.state.lifecycle,theme:e.state.theme,ui:s,window:c})}function Kd(e,t,n){let r=Object.freeze({async publish(r){n();let i=ct(r);e.canGoBack=i.canGoBack,e.canGoForward=i.canGoForward,e.navigation=vn(i),await Qu(t.reportNavigation(i),Se)},onActivate(t){if(n(),e.activate!==void 0)throw new G(`The App already owns navigation activations`,{code:`INVALID_ARGUMENT`,retryable:!1});e.activate=t;let r=!1;return()=>{r||(r=!0,e.activate===t&&(e.activate=void 0))}},onForward(t){if(n(),e.forward!==void 0)throw new G(`The App already owns Forward requests`,{code:`INVALID_ARGUMENT`,retryable:!1});e.forward=t;let r=!1;return()=>{r||(r=!0,e.forward===t&&(e.forward=void 0))}},onBack(t){if(n(),e.back!==void 0)throw new G(`The App already owns Back requests`,{code:`INVALID_ARGUMENT`,retryable:!1});e.back=t;let r=!1;return()=>{r||(r=!0,e.back===t&&(e.back=void 0))}}});return Object.freeze({navigation:r,onBeforeClose(t){if(n(),e.beforeClose!==void 0)throw new G(`The App already owns a close consultation`,{code:`INVALID_ARGUMENT`,retryable:!1});e.beforeClose=t;let r=!1;return()=>{r||(r=!0,e.beforeClose===t&&(e.beforeClose=void 0))}}})}function qd(e,t,n){return Object.freeze({async requestComputerChoice(){t(),await Qu(e.requestComputerChoice(),Se)},async requestBrowserAction(n){t();let r=N(n);return r.kind===`refused`?r:await Qu(e.requestBrowserAction(r),Le)},onStatusAction(e){if(t(),n.statusAction!==void 0)throw new G(`The App already owns its status actions`,{code:`INVALID_ARGUMENT`,retryable:!1});n.statusAction=e;let r=!1;return()=>{r||(r=!0,n.statusAction===e&&(n.statusAction=void 0))}},async requestAppPermissions(n){return t(),await Qu(e.requestAppPermissions(en(n)),mt)},async openDesktopSettings(){t(),await Qu(e.openDesktopSettings(),Se)},async openSetup(n){return t(),await Qu(e.openSetup(yt(n)),Ge)},async openTeamBilling(){t(),await Qu(e.openTeamBilling(),Se)},async openNavigation(n){t(),await Qu(e.openNavigation(rt(n)),Se)},async reportStatus(r){t();let i=Pn(r);n.statusItems=i,await Qu(e.reportStatus(i),Se)},async reportAgentSessionSelection(n){t(),await Qu(e.reportAgentSessionSelection(ne(n)),Se)},async showToast(n){t(),await Qu(e.showToast(An(n)),Se)}})}function Jd(){return new G(`The app connection is disposed`,{code:`DISCONNECTED`,retryable:!0})}function Yd(e){e({code:`DISCONNECTED`,message:`The app host disconnected`,retryable:!0})}function Xd(e,t){for(let n of e)try{n()}catch(e){console.warn(`${t} cleanup failed`,e)}}function Zd(e){return Object.freeze(e)}function Qd(){return{code:`DISCONNECTED`,message:`The app host disconnected`,retryable:!1}}function $d(e,t){return e===t||e===`connected`&&t===`suspended`||e===`suspended`&&t===`connected`}function ef(e){let t=sn(pn)(e.context),n=sn($e)(e.theme),r=sn(un)(e.lifecycle),i=sn(Ct)(e.reservedChords);if(r.value!==`connected`&&r.value!==`suspended`)throw new G(`The bootstrap lifecycle is invalid`,{code:`PROTOCOL`,retryable:!1});return{chords:i,context:t,lifecycle:r,theme:n}}function tf(e,t,n,r,i){throw Xd([()=>{n[Symbol.dispose]()},()=>{i&&De(i)},()=>{De(r)},()=>{t.port.close()},t.onDisposed],`app connection rejection`),e instanceof G?e:new G(`Unable to establish the app RPC session`,{cause:e,code:`PROTOCOL`,retryable:!1})}var nf=!1,rf=class{options;#e;#t;#n=!1;#r;#i;constructor(e){this.options=e,this.#e=globalThis.window}start(){performance.mark(`fungi.app-open.agar-connect-start`);let e=this.#l();return e?Promise.reject(e):(nf=!0,this.#a())}#a(){return new Promise((e,t)=>{let n=(n,a)=>{this.#o(n,a,i,r,e,t)},r=()=>{n(of())},i=e=>{this.#s(e,n,i)};this.#e.addEventListener(`message`,i),this.options.signal?.addEventListener(`abort`,r,{once:!0});let a=()=>{try{performance.mark(`fungi.app-open.agar-ready-sent`),this.#e.parent.postMessage({protocolVersion:2,type:En},`*`)}catch(e){fa(`connect.notify-host`,e),n(ff(e))}};this.#r=setInterval(a,200),this.#i=setTimeout(()=>{n(cf())},1e4),a()})}#o(e,t,n,r,i,a){if(!this.#n){if(this.#n=!0,this.#c(),this.#e.removeEventListener(`message`,n),this.options.signal?.removeEventListener(`abort`,r),e||!t){this.#t?.close(),nf=!1,a(e??cf());return}i(t)}}#s(e,t,n){if(!df(e.data))return;if(performance.mark(`fungi.app-open.agar-connect-received`),e.source!==this.#e.parent||lf(e.origin)===void 0){t(uf());return}let r=pf(e,t);if(!r)return;let i=e.ports.length===1?e.ports[0]:void 0;if(!i){t(mf(`The app host did not transfer exactly one port`));return}this.#t=i,this.#c(),this.#e.removeEventListener(`message`,n),Rd({epoch:r.epoch,isActive:()=>!this.#n,onDisposed:()=>{nf=!1},port:i,window:this.#e}).then(e=>{performance.mark(`fungi.app-open.agar-root-ready`),t(void 0,e)},e=>{t(sf(e))})}#c(){clearInterval(this.#r),clearTimeout(this.#i),this.#r=void 0,this.#i=void 0}#l(){if(this.options.signal?.aborted)return of();if(nf)return new G(`An app connection is already live`,{code:`IDENTITY`,retryable:!1});if(Te(globalThis.window)||this.#e.parent===this.#e)return new G(`The app host is unavailable`,{code:`DISCONNECTED`,retryable:!0})}};function af(e){return new rf(e).start()}function of(){return new G(`App connection was cancelled`,{code:`CANCELLED`,retryable:!1})}function sf(e){return e instanceof G?e:new G(`Unable to connect to the app host`,{cause:e,code:`PROTOCOL`,retryable:!1})}function cf(){return new G(`The app host disconnected`,{code:`DISCONNECTED`,retryable:!0})}function lf(e){if(!URL.canParse(e))return;let t=new URL(e).origin;return t===e?t:void 0}function uf(){return new G(`The app connection identity is invalid`,{code:`IDENTITY`,retryable:!1})}var df=u(g({type:Mn(h)}));function ff(e){return new G(`Unable to notify the app host`,{cause:e,code:`DISCONNECTED`,retryable:!0})}function pf(e,t){try{return dt(e.data)}catch(e){fa(`connect.decode-message`,e),t(e instanceof G?e:new G(`Malformed app connection`,{cause:e,code:`PROTOCOL`,retryable:!1}));return}}function mf(e){return new G(e,{code:`PROTOCOL`,retryable:!1})}function hf(e,t,n){e.style.isolation=`isolate`;let r=(0,Ds.createRoot)(e),i=new AbortController,a=e.ownerDocument.documentElement,o=vs(a),s,c,l,u=!1,d=e=>{let i=(0,q.createElement)(gf,{state:e,render:n});r.render(t.queryClient?(0,q.createElement)(Lt,{client:t.queryClient},i):i)},f=()=>{l?.(),l=void 0,c?.(),c=void 0;let e=s;s=void 0,e?.dispose(),u&&=(o===null?a.removeAttribute(`data-theme`):_s(o,a),!1)},{defaultView:p}=e.ownerDocument;return performance.mark(`fungi.app-open.react-root-render-start`),p?p.parent===p?d({app:null,status:`standalone`}):(d({app:null,status:`connecting`}),af({host:`parent`,signal:i.signal}).then(e=>{if(i.signal.aborted){e.dispose();return}s=e;let t=()=>{let t=e.lifecycle.get();return t===`disposing`||t===`disconnected`||t===`disposed`?(f(),d({app:null,status:`ended`}),!0):!1};l=e.lifecycle.subscribe(t),!t()&&(u=!0,_s(e.theme.get(),a),c=e.theme.subscribe(e=>{_s(e,a)}),d({app:e,status:`live`}))}).catch(e=>{i.signal.aborted&&e instanceof G&&e.code===`CANCELLED`||(console.error(`${t.name} host connection failed`,e),f(),i.signal.aborted||d({app:null,status:`not-hosted`,error:e instanceof G?e:new G(`The App host is unavailable`,{cause:e,code:`HOST_FAILURE`,retryable:!0})}))})):d({app:null,status:`not-hosted`,error:new G(`The App document has no window`,{code:`DISCONNECTED`,retryable:!1})}),()=>{i.signal.aborted||(i.abort(),r.unmount(),f())}}function gf({state:e,render:t}){return(0,q.useLayoutEffect)(()=>{performance.mark(`fungi.app-open.react-initial-commit`)},[]),(0,q.useLayoutEffect)(()=>{e.app&&performance.mark(`fungi.app-open.react-connected-commit`)},[e.app]),(0,q.createElement)(q.Fragment,null,e.status===`not-hosted`?(0,q.createElement)(`p`,{role:`alert`},`App host connection unavailable. Open this App through its host to try again.`):null,t(e))}function _f(e){let t=(0,q.useCallback)(t=>e?.subscribe(t)??(()=>void 0),[e]),n=(0,q.useCallback)(()=>e?.get(),[e]);return(0,q.useSyncExternalStore)(t,n,n)}function vf(e){return _f(e?.context)??null}function yf(e){return vf(e)?.computerId??null}function bf(e,t,n,r){let i=(0,q.useRef)(t);i.current=t;let a=(0,q.useRef)(n);a.current=n;let o=(0,q.useRef)(r);o.current=r;let s=JSON.stringify(t),c=n!==void 0;(0,q.useEffect)(()=>{e&&e.ui.reportStatus(i.current).catch(e=>{o.current?o.current(e):console.error(`Window status report failed`,e)})},[e,s]),(0,q.useEffect)(()=>{if(!(!e||!c))return e.ui.onStatusAction(e=>a.current?.(e)??!1)},[e,c]),(0,q.useEffect)(()=>()=>{e?.ui.reportStatus([]).catch(e=>{console.error(`Window status report failed`,e)})},[e])}function xf(e,{sourceId:t,namespace:n},r){let i=(0,q.useMemo)(()=>_o(),[]),a=(0,q.useMemo)(r,[r]);return(0,q.useEffect)(()=>{let e=i.contribute({sourceId:t,namespace:n,commands:a});return()=>{e.dispose()}},[i,t,n,a]),(0,q.useEffect)(()=>e?ps(e.commands,a):void 0,[e,a]),i}function Sf(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,q.useRef)(c),p=(0,q.useRef)(l),m=(0,q.useRef)(u),h=(0,q.useRef)(d);(0,q.useEffect)(()=>{f.current=c,p.current=l,m.current=u,h.current=d},[c,l,u,d]),(0,q.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(),Cf(e,{canGoBack:!1,canGoForward:!1})}},[e]);let g=JSON.stringify([i,a,o,s]),_=(0,q.useRef)({crumbs:i,primary:a,menu:o,status:s});(0,q.useEffect)(()=>{_.current={crumbs:i,primary:a,menu:o,status:s}},[i,a,o,s]),(0,q.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}),Cf(e,i)},[e,t,n,r,g])}function Cf(e,t){e.publish(t).catch(e=>{e instanceof G&&e.code===`DISCONNECTED`||console.warn(`App navigation report failed`,e)})}var wf=gt(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);tt.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>It(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>at(e,t,n),e.parseAsync=async(t,n)=>hn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>pt(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)=>Qt(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Tf=gt(`ZodMiniObject`,(e,t)=>{cn.init(e,t),wf.init(e,t),Vt(e,`shape`,()=>t.shape)});function Ef(e,t){return new Tf({type:`object`,shape:e??{},...xt(t)})}var Df=gt(`ZodMiniLiteral`,(e,t)=>{Jt.init(e,t),wf.init(e,t)});function Of(e,t){return new Df({type:`literal`,values:Array.isArray(e)?e:[e],...xt(t)})}var kf=j({png:`png`,jpeg:`jpeg`,webp:`webp`}),Af=j({draft:`draft`,balanced:`balanced`,premium:`premium`,max:`max`}),jf=te(()=>lt({transport:j({json:`json`,multipart:`multipart`}),dimensions:j({none:`none`,own:`own`}),maxDimension:U().int().positive().nullable(),maxDimensionDocumented:O(),defaultWidth:U().int().positive(),defaultHeight:U().int().positive(),steps:j({steps:`steps`,num_steps:`num_steps`,fixed:`fixed`}),maxSteps:U().int().positive().nullable(),defaultSteps:U().int().nonnegative().nullable(),referenceField:K().min(1).max(256).nullable(),maxReferences:U().int().nonnegative(),referenceDimension:U().int().positive().nullable(),referenceFormat:j({png:`png`,webp:`webp`})}).readonly()),Mf=j({seedance25:`bytedance/seedance-2.5`,seedance:`bytedance/seedance-2.0`,seedanceFast:`bytedance/seedance-2.0-fast`,seedanceMini:`bytedance/seedance-2.0-mini`,veo:`google/veo-3.1`,veoFast:`google/veo-3.1-fast`,minimaxH3Max:`minimax/h3-max`}),Nf=j({p480:`480p`,p720:`720p`,p768:`768p`,p1080:`1080p`,p4k:`4k`}),Pf=j({wide:`16:9`,landscape:`4:3`,square:`1:1`,portrait:`3:4`,tall:`9:16`,ultrawide:`21:9`,ultratall:`9:21`}),Ff=j({first:`first-frame`,last:`last-frame`,reference:`reference`}),If=te(()=>lt({resolution:Nf,aspectRatio:Pf,width:U().int().positive(),height:U().int().positive()}).readonly()),Lf=te(()=>lt({minSeconds:U().int().positive(),maxSeconds:U().int().positive(),defaultSeconds:U().int().positive(),durations:Pe(U().int().positive()).readonly(),provider:j({seedance:`seedance`,veo:`veo`,minimax:`minimax`}),formats:Pe(If).readonly(),defaultResolution:Nf,defaultAspectRatio:Pf,supportsAudio:O(),defaultGenerateAudio:O().nullable(),referenceRoles:Pe(Ff).readonly(),maxReferenceImages:U().int().nonnegative(),referenceResolutions:Pe(Nf).readonly(),audioReferences:lt({max:U().int().positive(),totalSeconds:U().int().positive()}).readonly().nullable(),prices:Pe(lt({resolution:Nf,silentMilliunitsPerSecond:U().int().positive(),audioMilliunitsPerSecond:U().int().positive()}).readonly()).readonly()}).readonly()),Rf=j({multilingual:`elevenlabs/eleven-multilingual-v2`,v3:`elevenlabs/eleven-v3`,music:`elevenlabs/music-v2`}),zf=te(()=>lt({id:K().min(1).max(64),label:K().min(1).max(128)}).readonly()),Bf=te(()=>lt({provider:ze(`elevenlabs`),mode:j({speech:`speech`,music:`music`}),voices:Pe(zf).readonly(),defaultVoiceId:K().min(1).max(64).nullable(),seconds:lt({min:U().int().positive(),max:U().int().positive(),default:U().int().positive()}).readonly().nullable(),milliunitsPerUnit:U().int().positive()}).readonly()),Vf=32e3,Hf=2048,Uf=lt({id:K().min(1).max(256),label:K().min(1).max(512),kind:j({image:`image`,video:`video`,audio:`audio`}),tier:Af,outputFormats:Pe(kf).max(3).readonly(),maxPromptLength:U().int().positive().max(Vf),input:jf,sizes:Pe(K().regex(/^\d+x\d+$/u)).readonly().nullable(),video:Lf.nullable(),audio:Bf.nullable()}).readonly(),Wf=e=>Object.freeze({kind:`image`,sizes:null,video:null,audio:null,outputFormats:Object.freeze([]),...e,input:Object.freeze(e.input)}),Gf=3840,Kf=8294400,qf=[[1,1],[4,3],[3,4],[3,2],[2,3],[16,9],[9,16],[21,9]],Jf=(()=>{let e=new Set([`1024x1024`,`1024x1536`,`1536x1024`]),t=[],n=[];for(let[r,i]of qf){let a=((e,t)=>{let n=e,r=t;for(;r!==0;)[n,r]=[r,n%r];return n})(r,i),o=16*r/a,s=16*i/a,c=o*s,l=e=>`${String(o*e)}x${String(s*e)}`,u=Math.round(Math.sqrt(1048576/c)),d=[...e].find(e=>{let[t,n]=e.split(`x`).map(Number);return(t??0)*i===(n??0)*r});t.push(d??l(u)),n.push(l(Math.floor(Math.min(Gf/Math.max(o,s),Math.sqrt(Kf/c)))))}return Object.freeze([...t,...n])})(),Yf=(e=>Object.freeze(qf.map(([t,n])=>{let r=t,i=n;for(;i!==0;)[r,i]=[i,r%i];let a=16*t/r,o=16*n/r,s=Math.round(Math.sqrt(e/(a*o)));return`${String(a*s)}x${String(o*s)}`})))(1327104),Xf={"480p":480,"720p":720,"768p":768,"1080p":1080,"4k":2160},Zf={"16:9":[16,9],"4:3":[4,3],"1:1":[1,1],"3:4":[3,4],"9:16":[9,16],"21:9":[21,9],"9:21":[9,21]},Qf={maxSeconds:30,maxReferenceImages:30,audioReferences:{max:10,totalSeconds:30},maxPromptLength:25e3,resolutions:[`480p`,`720p`],aspects:Pf.options.filter(e=>e!==Pf.enum.ultratall)};function $f(e,t,n,r,i,a){let o=r===`seedance`,s=a?.resolutions??i.map(([e])=>e),c=a?.maxSeconds??(o?12:8),l=a?.maxReferenceImages??(o?4:0),u=a?a.aspects:o?Pf.options:[Pf.enum.wide,Pf.enum.tall,Pf.enum.square],d=Object.freeze(s.flatMap(e=>u.map(t=>{let[n,r]=Zf[t],i=Xf[e],a=Math.min(n,r);return Object.freeze({resolution:e,aspectRatio:t,width:Math.ceil(i*n/a/2)*2,height:Math.ceil(i*r/a/2)*2})}))),f=Object.freeze(o?Array.from({length:c-3},(e,t)=>t+4):[4,6,8]),p=Object.freeze({minSeconds:4,maxSeconds:c,defaultSeconds:o?5:6,durations:f,provider:r,formats:d,defaultResolution:`720p`,defaultAspectRatio:`16:9`,supportsAudio:!0,defaultGenerateAudio:!0,referenceRoles:Object.freeze(o?Ff.options:[Ff.enum.first]),maxReferenceImages:l,audioReferences:a===void 0?null:Object.freeze({...a.audioReferences}),referenceResolutions:Object.freeze(o?s.filter(e=>e!==`1080p`):[]),prices:Object.freeze(i.map(([e,t,n])=>Object.freeze({resolution:e,silentMilliunitsPerSecond:t,audioMilliunitsPerSecond:n})))});return Wf({id:e,label:t,tier:n,maxPromptLength:a?.maxPromptLength??(o?1e4:Hf),kind:`video`,video:p,sizes:Object.freeze(d.map(({width:e,height:t})=>`${String(e)}x${String(t)}`)),input:{transport:`json`,dimensions:`own`,maxDimension:Math.max(...d.map(({width:e,height:t})=>Math.max(e,t))),maxDimensionDocumented:!1,defaultWidth:1280,defaultHeight:720,steps:`fixed`,maxSteps:null,defaultSteps:null,referenceField:o?`image`:`image_input`,maxReferences:o?l:1,referenceDimension:null,referenceFormat:`png`}})}function ep(){let e=[`480p`,`768p`],t=[Pf.enum.wide,Pf.enum.landscape,Pf.enum.square,Pf.enum.portrait,Pf.enum.tall,Pf.enum.ultrawide],n=Object.freeze(e.flatMap(e=>t.map(t=>{let[n,r]=Zf[t],i=Xf[e],a=Math.min(n,r);return Object.freeze({resolution:e,aspectRatio:t,width:Math.ceil(i*n/a/2)*2,height:Math.ceil(i*r/a/2)*2})}))),r=Nf.enum.p768,i=Pf.enum.wide,a=n.find(e=>e.resolution===r&&e.aspectRatio===i);if(a===void 0)throw Error(`minimax/h3-max is missing its default format`);let o=Object.freeze(Array.from({length:11},(e,t)=>t+5)),s=Object.freeze({minSeconds:5,maxSeconds:15,defaultSeconds:5,durations:o,provider:`minimax`,formats:n,defaultResolution:r,defaultAspectRatio:i,defaultGenerateAudio:null,supportsAudio:!1,referenceRoles:Object.freeze([Ff.enum.first,Ff.enum.reference]),maxReferenceImages:4,audioReferences:null,referenceResolutions:Object.freeze(e),prices:Object.freeze([{resolution:Nf.enum.p480,silentMilliunitsPerSecond:5e3,audioMilliunitsPerSecond:5e3},{resolution:Nf.enum.p768,silentMilliunitsPerSecond:8e3,audioMilliunitsPerSecond:8e3}])});return Wf({id:Mf.enum.minimaxH3Max,label:`MiniMax H3 Max`,tier:`balanced`,maxPromptLength:7e3,kind:`video`,video:s,sizes:Object.freeze(n.map(({width:e,height:t})=>`${String(e)}x${String(t)}`)),input:{transport:`json`,dimensions:`own`,maxDimension:Math.max(...n.map(({width:e,height:t})=>Math.max(e,t))),maxDimensionDocumented:!1,defaultWidth:a.width,defaultHeight:a.height,steps:`fixed`,maxSteps:null,defaultSteps:null,referenceField:`image_url`,maxReferences:4,referenceDimension:null,referenceFormat:`png`}})}var tp=Object.freeze([Object.freeze({id:`JBFqnCBsd6RMkjVDRZzb`,label:`Default voice`})]);function np(e,t,n,r){return ip(e,t,n,1e4,{provider:`elevenlabs`,mode:`speech`,voices:tp,defaultVoiceId:tp[0]?.id??null,seconds:null,milliunitsPerUnit:r})}function rp(){return ip(Rf.enum.music,`Eleven Music v2`,`premium`,Hf,{provider:`elevenlabs`,mode:`music`,voices:Object.freeze([]),defaultVoiceId:null,seconds:Object.freeze({min:3,max:600,default:30}),milliunitsPerUnit:250})}function ip(e,t,n,r,i){return Wf({id:e,label:t,tier:n,maxPromptLength:r,kind:`audio`,audio:Object.freeze(i),input:{transport:`json`,dimensions:`none`,maxDimension:null,maxDimensionDocumented:!1,defaultWidth:1,defaultHeight:1,steps:`fixed`,maxSteps:null,defaultSteps:null,referenceField:null,maxReferences:0,referenceDimension:null,referenceFormat:`png`}})}Object.freeze([Wf({id:`@cf/black-forest-labs/flux-1-schnell`,maxPromptLength:2048,outputFormats:Object.freeze([`jpeg`]),tier:`draft`,label:`Flux 1 Schnell — cheap/fast sketches`,input:{transport:`json`,dimensions:`none`,maxDimension:null,maxDimensionDocumented:!1,defaultWidth:1024,defaultHeight:768,steps:`steps`,maxSteps:8,defaultSteps:4,referenceField:null,maxReferences:0,referenceDimension:512,referenceFormat:`png`}}),Wf({id:`@cf/black-forest-labs/flux-2-klein-4b`,maxPromptLength:Hf,tier:`balanced`,label:`Flux 2 Klein 4b — balanced default`,input:{transport:`multipart`,dimensions:`own`,maxDimension:1920,maxDimensionDocumented:!1,defaultWidth:1024,defaultHeight:768,steps:`fixed`,maxSteps:null,defaultSteps:4,referenceField:`input_image_`,maxReferences:4,referenceDimension:512,referenceFormat:`png`}}),Wf({id:`@cf/black-forest-labs/flux-2-klein-9b`,maxPromptLength:Hf,tier:`premium`,label:`Flux 2 Klein 9b — higher quality flux-2`,input:{transport:`multipart`,dimensions:`own`,maxDimension:1920,maxDimensionDocumented:!1,defaultWidth:1024,defaultHeight:768,steps:`fixed`,maxSteps:null,defaultSteps:4,referenceField:`input_image_`,maxReferences:4,referenceDimension:512,referenceFormat:`png`}}),Wf({id:`@cf/black-forest-labs/flux-2-dev`,maxPromptLength:Hf,tier:`max`,label:`Flux 2 Dev — best detailed quality, expensive`,input:{transport:`multipart`,dimensions:`own`,maxDimension:1920,maxDimensionDocumented:!1,defaultWidth:1024,defaultHeight:768,steps:`steps`,maxSteps:null,defaultSteps:20,referenceField:`input_image_`,maxReferences:4,referenceDimension:512,referenceFormat:`png`}}),Wf({id:`@cf/leonardo/lucid-origin`,maxPromptLength:Hf,tier:`premium`,label:`Leonardo Lucid Origin — premium prompt adherence`,input:{transport:`json`,dimensions:`own`,maxDimension:2500,maxDimensionDocumented:!0,defaultWidth:1120,defaultHeight:1120,steps:`num_steps`,maxSteps:40,defaultSteps:null,referenceField:null,maxReferences:0,referenceDimension:512,referenceFormat:`png`}}),Wf({id:`@cf/leonardo/phoenix-1.0`,maxPromptLength:Hf,tier:`balanced`,label:`Leonardo Phoenix 1.0 — best prompt adherence`,input:{transport:`json`,dimensions:`own`,maxDimension:2048,maxDimensionDocumented:!0,defaultWidth:1024,defaultHeight:1024,steps:`num_steps`,maxSteps:50,defaultSteps:25,referenceField:null,maxReferences:0,referenceDimension:512,referenceFormat:`png`}}),Wf({id:`openai/gpt-image-2`,maxPromptLength:32e3,outputFormats:Object.freeze([`png`,`jpeg`,`webp`]),tier:`premium`,label:`GPT Image 2 — strong text and layout, premium`,sizes:Jf,input:{transport:`json`,dimensions:`own`,maxDimension:Gf,maxDimensionDocumented:!0,defaultWidth:1024,defaultHeight:1024,steps:`fixed`,maxSteps:null,defaultSteps:null,referenceField:`images`,maxReferences:16,referenceDimension:1024,referenceFormat:`webp`}}),Wf({id:`bytedance/seedream-5-pro`,maxPromptLength:Hf,outputFormats:Object.freeze([`jpeg`]),tier:`premium`,label:`Seedream 5 Pro — ByteDance, high-quality images`,sizes:Yf,input:{transport:`json`,dimensions:`own`,maxDimension:1792,maxDimensionDocumented:!1,defaultWidth:1536,defaultHeight:864,steps:`fixed`,maxSteps:null,defaultSteps:null,referenceField:null,maxReferences:0,referenceDimension:512,referenceFormat:`png`}}),$f(Mf.enum.seedance25,`Seedance 2.5`,`balanced`,`seedance`,[[`480p`,10280,10280],[`720p`,23120,23120]],Qf),$f(Mf.enum.seedance,`Seedance 2.0`,`balanced`,`seedance`,[[`480p`,7e3,7e3],[`720p`,15e3,15e3],[`1080p`,37e3,37e3],[`4k`,78e3,78e3]]),$f(Mf.enum.seedanceFast,`Seedance 2.0 Fast`,`draft`,`seedance`,[[`480p`,6e3,6e3],[`720p`,12e3,12e3]]),$f(Mf.enum.seedanceMini,`Seedance 2.0 Mini`,`draft`,`seedance`,[[`480p`,4e3,4e3],[`720p`,9e3,9e3]]),$f(Mf.enum.veo,`Veo 3.1`,`premium`,`veo`,[[`720p`,2e4,4e4],[`1080p`,2e4,4e4]]),$f(Mf.enum.veoFast,`Veo 3.1 Fast`,`balanced`,`veo`,[[`720p`,8e3,1e4],[`1080p`,1e4,12e3]]),ep(),np(Rf.enum.multilingual,`Eleven Multilingual v2 — natural speech`,`balanced`,10),np(Rf.enum.v3,`Eleven v3 — expressive speech`,`premium`,10),rp()]);var ap=Uf.unwrap().extend({audio:Bf.unwrap().nullable().default(null),video:Lf.unwrap().unwrap().extend({audioReferences:Lf.unwrap().unwrap().shape.audioReferences.default(null),provider:j({seedance:`seedance`,veo:`veo`,minimax:`minimax`,host:`host`})}).readonly().nullable()}).readonly();Pe(ap).min(1).max(256).superRefine((e,t)=>{let n=new Set;e.forEach((e,r)=>{let i=e=>{t.addIssue({code:`custom`,message:e,path:[r]})};n.has(e.id)&&i(`duplicate model id "${e.id}"`),n.add(e.id),e.kind===`video`!=(e.video!==null)&&i(`${e.id} must carry video bounds exactly when kind is video`),e.kind===`audio`!=(e.audio!==null)&&i(`${e.id} must carry audio bounds exactly when kind is audio`);let a=e.video;a!==null&&((a.minSeconds>a.maxSeconds||a.durations.some(e=>e<a.minSeconds||e>a.maxSeconds)||!a.durations.includes(a.defaultSeconds))&&i(`${e.id} durations must sit inside min/max and include the default`),a.formats.some(({resolution:e,aspectRatio:t})=>e===a.defaultResolution&&t===a.defaultAspectRatio)||i(`${e.id} formats must include the default resolution and aspect`))})}).transform(e=>Object.freeze(e.map(e=>Object.freeze({...e,input:Object.freeze(e.input)}))));var op=e=>K().min(1).max(e),sp=U().int().min(-(2**53-1)).max(2**53-1),cp=sp.positive(),lp=sp.nonnegative(),up=lt({printId:op(256),computerId:op(256),kind:j([`image`,`video`,`audio`]),prompt:op(Vf),model:op(256),width:cp.nullable(),height:cp.nullable(),steps:lp.nullable(),durationSeconds:lp.nullable(),format:op(32),bytes:cp,costMilliunits:lp,actorKind:j([`member`,`agent`]),actorId:op(256),derivedFrom:op(256).nullable(),createdAt:lp,source:j([`recorded`,`file`]),schemaVersion:cp}),dp=_e({printId:up.shape.printId,path:K().startsWith(`/`).min(2).max(4096)});function fp(e,t){let n=e?.app??null,r=vf(n),i=r?.openRequest,a=r?.computerId,o=i?.kind===`navigate`?i.params.find(e=>e.key===`print`):void 0,s=up.shape.printId.safeParse(o?.value),c=s.success?s.data:null,l=i?.kind===`navigate`?i.requestId:null,u=(0,q.useRef)({app:n,requestId:l,computerId:a});(u.current.app!==n||u.current.requestId!==l)&&(u.current={app:n,requestId:l,computerId:a});let d=u.current.computerId===a,f=Or({...rr(n,Qn,Mi.of(n,`prints`,`navigate`,a,l,c),async(e,t)=>{if(!n||!a||!c||!l)throw Error(`No print selected`);let r=await e.call(`openOutput`,JSON.stringify({printId:c,byteLength:1}));if(t.throwIfAborted(),n.context.get().computerId!==a)throw Error(`Computer selection changed`);let i=dp.parse(r);if(i.printId!==c)throw Error(`Print selection changed`);return{path:i.path,requestId:l,computerId:a}}),enabled:!!(n&&d&&a&&l&&c&&n.capabilities.has(Qn)),retry:!1,staleTime:1/0}),p=(0,q.useRef)(t);p.current=t;let m=(0,q.useRef)(void 0);return(0,q.useEffect)(()=>{let t=f.data;!e||!t||m.current===t||e.app.context.get().computerId!==t.computerId||(m.current=t,p.current(t.path,e,t.computerId))},[e,f.data]),{target:f.data??null,error:f.error}}var pp=q.createContext(void 0);function mp(e){let t=q.useContext(pp);if(!e&&t===void 0)throw Error(Li(27));return t}var hp=q.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=mp(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`),d={open:c,transitionStatus:s.useState(`transitionStatus`)};return aa(`div`,e,{state:d,ref:[s.context.backdropRef,t],stateAttributesMapping:Fi,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),gp=q.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=mp(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=la({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,so(ao,e.nativeEvent))}return aa(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),_p=q.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=mp(),c=va(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),aa(`p`,e,{ref:t,props:[{id:c},o]})}),vp=q.createContext(void 0);function yp(){let e=q.useContext(vp);if(e===void 0)throw Error(Li(26));return e}var bp=`--nested-dialogs`,xp=`data-nested-dialog-open`,Sp={...Ra,...Xi,nestedDialogOpen(e){return e?{[xp]:``}:null}},J=ot(),Cp=q.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=mp(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);yp(),Ni({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?Wi(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=aa(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...Gi,hidden:!m,onKeyDown(e){Pi.has(e.key)&&e.stopPropagation()},style:{[bp]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:Sp});return(0,J.jsx)(Za,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),wp=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=mp(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,J.jsx)(vp.Provider,{value:n,children:(0,J.jsxs)($a,{ref:t,...r,children:[a&&o===!0&&(0,J.jsx)(ea,{ref:i.context.internalBackdropRef,inert:La(!s)}),e.children]})}):null});function Tp({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`mounted`),a=e.useState(`disablePointerDismissal`),o=e.useState(`modal`),s=e.useState(`popupElement`),c=e.useState(`floatingRootContext`),[l,u]=q.useState(0),[d,f]=q.useState(0),p=l===0,m=to(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:o===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Ja(t);if(p&&!a){if(o){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Oa(n,s)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return zi(r&&o===!0,s),e.useContextCallback(`onNestedDialogOpen`,(t,n)=>{!e.select(`open`)&&!e.select(`mounted`)||(u(t),f(n))}),Hi(()=>{!r&&!i&&(u(0),f(0))},[r,i]),Hi(()=>(t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(l+1,d+ +!!n),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,l,d,t]),ha(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:d}),null}var Ep={...Ki,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Dp=class extends Yi{constructor(e,t,n){let r=new da,i=Op(e,r,t,n);super(i,kp(r),Ep)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(Ji(this.state,e,t.trigger)))}};function Op(e,t,n,r=!1){return{...Ui(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function kp(e){return{popupRef:q.createRef(),backdropRef:q.createRef(),internalBackdropRef:q.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Ap(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=mp(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=ma((e,t)=>new Dp({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);ga(b,x),Ya(b);let{forceUnmount:w}=qi(x,b);q.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,so(lo))}),[w,b]);let T=x||S||u!=null;return(0,J.jsxs)(pp.Provider,{value:b,children:[u&&(0,J.jsx)(ua,{handle:u,store:b}),T&&(0,J.jsx)(Tp,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}var jp=ia(function(e){return Ap(`dialog`,e)}),Mp=q.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=mp(),c=va(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),aa(`h2`,e,{ref:t,props:[{id:c},o]})}),Np=fo(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=mp(!0),f=na(l)??d;if(!f)throw Error(Li(79));let p=va(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=q.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=ra(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=la({disabled:a,native:o}),S=Wa(m),C=Vi(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return aa(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[Ca]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:Qi})}),Pp=(0,q.createContext)(null);function Fp({children:e,interactionOwner:t=`local`,modal:n=!0,onOpenChange:r,...i}){return(0,J.jsx)(Pp.Provider,{value:{interactionOwner:t,modal:n},children:(0,J.jsx)(jp,{...i,modal:n,onOpenChange:(e,n)=>{if(t===`host`&&!e&&n.reason===`escape-key`){n.cancel(),n.allowPropagation();return}r?.(e,n)},children:e})})}function Ip(){let e=(0,q.useContext)(Pp);if(!e)throw Error(`Dialog parts must be used inside <Dialog>`);return e}(0,q.forwardRef)(function({className:e,type:t=`button`,...n},r){return(0,J.jsx)(Np,{...n,className:t=>B(`btn`,C(e,t)),ref:r,type:t})});var Lp=(0,q.forwardRef)(function({container:e,...t},n){let r=ca(`dialog`);return e==null&&r===null?null:(0,J.jsx)(wp,{...t,container:e??r,ref:n})}),Rp=(0,q.forwardRef)(function({className:e,...t},n){return(0,J.jsx)(hp,{...t,ref:n,className:t=>B(`caps-dialog-backdrop fixed inset-0 bg-black/40`,C(e,t))})}),zp=(0,q.forwardRef)(function({className:e,finalFocus:t,size:n=`default`,...r},i){let a=Ip();return(0,J.jsx)(Cp,{...r,"data-size":n,className:t=>B(`caps-dialog-popup overflow-y-auto overscroll-contain rounded-box bg-base-100 p-lg text-base-content shadow-xl`,n===`fill`?`fixed inset-0 h-full w-full max-w-none`:`caps-dialog-popup-default`,C(e,t)),finalFocus:a.interactionOwner===`host`?!1:t??!0,ref:i})}),Bp=(0,q.forwardRef)(function({container:e,keepMounted:t=!0,forceBackdrop:n=!1,className:r,size:i=`default`,...a},o){let{modal:s}=Ip();return(0,J.jsxs)(Lp,{container:e,keepMounted:t,children:[s===!0?(0,J.jsx)(Rp,{forceRender:n}):null,(0,J.jsx)(zp,{...a,size:i,className:e=>B(i==="default"&&`fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2`,C(r,e)),ref:o})]})});function Vp({className:e,...t}){return(0,J.jsx)(`div`,{...t,className:B(`flex justify-end gap-sm`,e)})}function Hp({className:e,...t}){return(0,J.jsx)(`div`,{...t,className:B(`flex flex-col gap-sm`,e)})}var Up=(0,q.forwardRef)(function({className:e,...t},n){return(0,J.jsx)(Mp,{...t,className:t=>B(`text-lg font-semibold`,C(e,t)),ref:n})});(0,q.forwardRef)(function({className:e,...t},n){return(0,J.jsx)(_p,{...t,className:t=>B(`text-sm text-base-content`,C(e,t)),ref:n})});var Wp=(0,q.forwardRef)(function({className:e,type:t=`button`,...n},r){return(0,J.jsx)(gp,{...n,className:t=>B(`btn btn-ghost`,C(e,t)),ref:r,type:t})}),Gp={dot:{y:-4,height:8,cy:0},pill:{y:-16,height:32,cy:0},bang:{y:-16,height:20,cy:12}};function Kp({className:e,glyph:t,motion:n}){let r=`caps-status-${(0,q.useId)().replaceAll(`:`,``)}`,i=(0,q.useRef)(null),a=(0,q.useRef)(null),s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=(0,q.useRef)(Gp[t]).current,p=(0,q.useRef)(t===`dot`?1:4).current,m=(0,q.useRef)(+(t===`bang`)).current,h=(0,q.useRef)(t),g=ae(c),{reduced:_}=g;return(0,q.useLayoutEffect)(()=>{if(!i.current||!a.current||!l.current||!u.current)return;let e=Gp[t],n=_||h.current===t;h.current=t;let r=kt(i.current),s=n?{duration:0}:ni(r,{bounce:.3,duration:360}),c=mo(i.current,{y:e.y,height:e.height,...s}),d=mo(a.current,{cy:e.cy,...n?{duration:0}:{delay:o(r,35),...ni(r,{bounce:.3,duration:420})}}),f=mo(l.current,{gradientTransform:`matrix(1 0 0 ${t===`dot`?`1`:`4`} 0 0)`,...s}),p=mo(u.current,{opacity:+(t===`bang`),...n?ii:Hn(r,{ease:`inOutSine`,duration:220})});return()=>{c.cancel(),d.cancel(),f.cancel(),p.cancel()}},[t,_]),(0,q.useLayoutEffect)(()=>{if(!s.current||!c.current||_||n===`none`)return;let e=n===`pulse`?mo(s.current,{opacity:[1,.45],...Hn(g,{ease:`inOutSine`,duration:750}),alternate:!0,loop:!0}):mo(s.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}},...Hn(g,{ease:`inOutSine`,duration:1e3}),loop:!0}),t=jn(c.current,t=>{t?e.resume():e.pause()});return()=>{t(),e.revert()}},[n,_,g]),(0,J.jsxs)(`svg`,{ref:c,"aria-hidden":`true`,className:`caps-status-bead ${e??``}`,width:`8`,height:`8`,viewBox:`-4 -4 8 8`,focusable:`false`,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsx)(Xe,{id:r,values:Cn}),(0,J.jsx)(f,{ref:l,id:`${r}-surface`,transform:`matrix(1 0 0 ${String(p)} 0 0)`}),(0,J.jsxs)(`radialGradient`,{id:`${r}-drop-light`,gradientUnits:`userSpaceOnUse`,cx:`-1.2`,cy:`10.4`,r:`5.6`,children:[(0,J.jsx)(`stop`,{offset:`0`,stopColor:`var(--color-white)`,style:{stopOpacity:`calc(var(--depth) * 0.5)`}}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:`var(--color-white)`,stopOpacity:`0`})]}),(0,J.jsx)(H,{id:`${r}-shadow`}),(0,J.jsx)(`mask`,{id:`${r}-silhouette`,maskUnits:`userSpaceOnUse`,x:`-12`,y:`-24`,width:`24`,height:`48`,style:{maskType:`alpha`},children:(0,J.jsxs)(`g`,{fill:`var(--color-white)`,filter:`url(#${r})`,children:[(0,J.jsx)(`rect`,{ref:i,x:`-4`,y:d.y,width:`8`,height:d.height,rx:`4`}),(0,J.jsx)(`circle`,{ref:a,cx:`0`,cy:d.cy,r:`4`})]})})]}),(0,J.jsx)(`g`,{ref:s,filter:`url(#${r}-shadow)`,children:(0,J.jsxs)(`g`,{mask:`url(#${r}-silhouette)`,children:[(0,J.jsx)(`rect`,{x:`-12`,y:`-24`,width:`24`,height:`48`,fill:`url(#${r}-surface)`}),(0,J.jsx)(`rect`,{ref:u,x:`-12`,y:`-24`,width:`24`,height:`48`,fill:`url(#${r}-drop-light)`,opacity:m})]})})]})}var qp=.28;function Jp(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?qp: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 Yp=7.25;function Xp({className:e,glyph:t,progress:n}){let r=`caps-status-mark-${(0,q.useId)().replaceAll(`:`,``)}`,i=(0,q.useRef)(null),a=(0,q.useRef)(null),o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(null),d=(0,q.useRef)(null),p=(0,q.useRef)(Jp(t,n)).current,m=(0,q.useRef)(t),h=le();(0,q.useLayoutEffect)(()=>{let e=i.current,r=a.current,c=o.current,f=s.current,p=l.current,g=u.current,_=d.current;if(!e||!r||!c||!f||!p||!g||!_)return;let v=Jp(t,n),y=m.current;m.current=t;let b=kt(e),x=h||y===t&&t!==`arc`,S=x?h?{ease:b.ease,duration:b.fast}:ii:Hn(b,{ease:`outQuad`,duration:160}),C=(t===`check`||t===`cross`)&&!x,w=Hn(b,{ease:`inOutSine`,duration:220}),T=[mo(r,{opacity:v.dashes,...S}),mo(c,{opacity:v.track*.28,...S}),mo(f,{opacity:v.arc,"stroke-dasharray":`${String(v.sweep)} 1`,...x?h?ii:S:w}),mo(p,{r:v.disc*Yp,...C?{delay:w.duration*.7,...ni(b,{bounce:.35,duration:360})}:h?ii:Hn(b,{ease:`inCubic`,duration:140})}),mo(g,{"stroke-dashoffset":1-v.tick,...C&&v.tick>0?{delay:w.duration*.7+b.fast,...Hn(b,{ease:`outCubic`,duration:240})}:ii}),mo(_,{"stroke-dashoffset":1-v.cross,...C&&v.cross>0?{delay:w.duration*.7+b.fast,...Hn(b,{ease:`outCubic`,duration:240})}:ii})];return t===`cross`&&C&&b.shake>0&&T.push(mo(e,{translateX:[0,-b.shake,b.shake,-b.shake/2,0],delay:w.duration+b.fast,...Hn(b,{ease:`linear`,duration:300})})),()=>{for(let e of T)e.cancel()}},[t,n,h]);let g=t===`arc`&&n===void 0&&!h;return(0,q.useLayoutEffect)(()=>{if(!g||!c.current||!i.current)return;let e=kt(i.current),t=mo(c.current,{rotate:[0,360],...Hn(e,{ease:`linear`,duration:900}),loop:!0}),n=jn(i.current,e=>{e?t.resume():t.pause()});return()=>{n(),t.revert()}},[g]),(0,J.jsxs)(`svg`,{ref:i,"aria-hidden":`true`,className:`caps-status-mark ${e??``}`,viewBox:`0 0 16 16`,focusable:`false`,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsx)(f,{id:`${r}-surface`,transform:`matrix(1.6 0 0 1.6 8 8)`}),(0,J.jsxs)(`mask`,{id:`${r}-knock`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`16`,height:`16`,children:[(0,J.jsx)(`rect`,{width:`16`,height:`16`,fill:`var(--color-white)`}),(0,J.jsx)(`path`,{ref:u,d:`M4.9 8.3 7.1 10.5 11.2 5.9`,fill:`none`,stroke:`var(--color-black)`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,pathLength:1,strokeDasharray:`1 1`,strokeDashoffset:1-p.tick}),(0,J.jsx)(`path`,{ref:d,d:`M5.4 5.4 10.6 10.6 M10.6 5.4 5.4 10.6`,fill:`none`,stroke:`var(--color-black)`,strokeWidth:`1.9`,strokeLinecap:`round`,pathLength:1,strokeDasharray:`1 1`,strokeDashoffset:1-p.cross})]})]}),(0,J.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,J.jsx)(`circle`,{ref:o,cx:`8`,cy:`8`,r:`6.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,opacity:p.track*.28}),(0,J.jsx)(`g`,{ref:c,className:`caps-status-mark-spin`,children:(0,J.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,J.jsx)(`circle`,{ref:l,cx:`8`,cy:`8`,r:p.disc*Yp,fill:`url(#${r}-surface)`,mask:`url(#${r}-knock)`})]})}var Zp=new Set([`ring`,`arc`,`check`,`cross`]);function Qp(e){return Zp.has(e)}var $p={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`},em=(0,q.forwardRef)(function({className:e,label:t,glyph:n=`dot`,motion:r=`none`,tone:i=`neutral`,size:a=`default`,appearance:o=`plain`,progress:s,...c},l){return(0,J.jsxs)(`span`,{...c,className:B(`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:[Qp(n)?(0,J.jsx)(Xp,{className:$p[i],glyph:n,progress:s}):(0,J.jsx)(Kp,{className:$p[i],glyph:n,motion:r}),t===void 0?null:(0,J.jsx)(`span`,{children:t})]})}),tm=(0,q.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,J.jsxs)(`div`,{...d,className:B(`caps-failure-line`,e),"data-density":n,ref:f,role:u,children:[(0,J.jsx)(em,{glyph:`dot`,tone:`error`}),(0,J.jsxs)(`span`,{className:`caps-failure-line-copy`,children:[(0,J.jsx)(`span`,{children:a}),t!==void 0&&t>1?(0,J.jsxs)(`span`,{className:`caps-failure-line-count`,children:[`Failed `,t,` times`]}):null]}),s||o?(0,J.jsxs)(`span`,{className:`caps-failure-line-actions`,children:[s?(0,J.jsx)(W,{"aria-label":c,size:`sm`,variant:`outline`,onClick:s,children:l}):null,o?(0,J.jsx)(W,{"aria-label":r,size:`sm`,variant:`ghost`,onClick:o,children:i}):null]}):null]})}),nm={queued:`Waiting to start`,generating:`Generating`,refining:`Refining`,done:void 0,failed:void 0},rm=(0,q.forwardRef)(function({status:e,children:t,aspectRatio:n,label:r,indicator:i,failure:a,className:o,style:s,...c},l){let u=(0,q.useRef)(null);(0,q.useImperativeHandle)(l,()=>u.current);let d=(0,q.useRef)(e),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(e);m!==e&&(h(e),p(e===`done`)),(0,q.useLayoutEffect)(()=>{let t=u.current,n=d.current;if(d.current=e,!t||n===e)return;if(!y(t)){p(!1);return}let r=kt(t),i=de(r,r.ease),a=[],o=t.querySelector(`:scope > [data-layer="media"]`),s=t.querySelector(`:scope > [data-layer="placeholder"]`),c=t.querySelector(`:scope > [data-layer="failure"]`);if(e===`done`&&o){let e=o.animate(r.reduced?[{opacity:0},{opacity:1}]:[{opacity:0,filter:`blur(10px)`,transform:`scale(1.03)`},{opacity:1,filter:`blur(0px)`,transform:`none`}],{duration:r.reduced?r.fast:r.slow*2,easing:i,fill:`backwards`});e.addEventListener(`finish`,()=>{p(!1)}),a.push(e),s&&a.push(s.animate([{opacity:1},{opacity:0}],{duration:r.reduced?r.fast:r.slow,easing:i,fill:`forwards`}))}return e===`failed`&&c&&a.push(c.animate([{opacity:0,transform:`translateY(${String(r.distance)}px)`},{opacity:1,transform:`none`}],{duration:r.normal,easing:i})),n===`failed`&&s&&a.push(s.animate([{opacity:.4},{opacity:1}],{duration:r.normal,easing:i})),()=>{for(let e of a)e.cancel()}},[e]);let g=e===`queued`||e===`generating`||e===`refining`,_=r??nm[e],v=e===`done`||e===`refining`;return(0,J.jsxs)(`div`,{...c,ref:u,className:B(`caps-generation-frame`,o),"data-status":e,"data-aspect":n===void 0?void 0:``,"aria-busy":g,style:n===void 0?s:{aspectRatio:n,...s},children:[e===`done`&&!f?null:(0,J.jsxs)(`div`,{className:B(`caps-generation-placeholder`,e===`queued`&&`skeleton`),"data-layer":`placeholder`,role:e===`done`?void 0:`status`,"aria-hidden":e===`done`||void 0,children:[e===`generating`||e===`refining`||e===`done`?i??(0,J.jsx)(yn,{decorative:!0,size:`lg`,variant:`bloom`}):null,_===void 0?null:(0,J.jsx)(Ce,{children:_})]}),v?(0,J.jsx)(`div`,{className:`caps-generation-media`,"data-layer":`media`,children:t}):null,e===`failed`&&a!==void 0?(0,J.jsx)(`div`,{className:`caps-generation-failure`,"data-layer":`failure`,role:`alert`,children:a}):null]})}),im=q.createContext(void 0);function am(){let e=q.useContext(im);if(e===void 0)throw Error(Li(53));return e}function om(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var sm=`base-ui-disable-scrollbar`,cm={className:sm,getElement(e){return(0,J.jsx)(`style`,{nonce:e,href:sm,precedence:`base-ui:low`,children:`.${sm}{scrollbar-width:none}.${sm}::-webkit-scrollbar{display:none}`})}},lm=`data-has-overflow-x`,um=`data-has-overflow-y`,dm=`data-overflow-x-start`,fm=`data-overflow-x-end`,pm=`data-overflow-y-start`,mm=`data-overflow-y-end`,hm=e=>t=>t?{[e]:``}:null,gm={hasOverflowX:hm(lm),hasOverflowY:hm(um),overflowXStart:hm(dm),overflowXEnd:hm(fm),overflowYStart:hm(pm),overflowYEnd:hm(mm),cornerHidden:()=>null},_m=q.createContext(void 0),vm={disableStyleElements:!1};function ym(){return q.useContext(_m)??vm}var bm=`--scroll-area-corner-height`,xm=`--scroll-area-corner-width`,Sm=`data-orientation`,Cm={x:0,y:0},wm={width:0,height:0},Tm={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},Em={x:!0,y:!0,corner:!0},Dm=q.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=Om(i),d=va(),f=Aa(),p=Aa(),{nonce:m,disableStyleElements:h}=ym(),[g,_]=q.useState(!1),[v,y]=q.useState(!1),[b,x]=q.useState(!1),[S,C]=q.useState(!1),[w,T]=q.useState(!1),[E,D]=q.useState(wm),[O,k]=q.useState(wm),[A,j]=q.useState(Tm),[M,ee]=q.useState(Em),N=q.useRef(null),P=q.useRef(null),te=q.useRef(null),ne=q.useRef(null),F=q.useRef(null),re=q.useRef(null),ie=q.useRef(null),I=q.useRef(null),L=q.useRef(0),ae=q.useRef(0),oe=q.useRef(0),se=q.useRef(0),ce=q.useRef(`vertical`),le=q.useRef(Cm),R=q.useRef(null);function ue(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let de=Bi(e=>{let t=e.x-le.current.x,n=e.y-le.current.y;le.current=e,n!==0&&ue(!0),t!==0&&ue(!1)}),fe=Bi(()=>{let e=P.current;e&&R.current===null&&(R.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),pe=Bi(e=>{if(e.button!==0||I.current!==null&&(ce.current===`vertical`?F.current:re.current)?.hasPointerCapture(I.current))return;I.current=e.pointerId,L.current=e.clientY,ae.current=e.clientX,ce.current=e.currentTarget.getAttribute(Sm);let t=P.current;t&&(oe.current=t.scrollTop,se.current=t.scrollLeft,fe()),(ce.current===`vertical`?F.current:re.current)?.setPointerCapture(e.pointerId)}),z=Bi(e=>{if(e.pointerId!==I.current)return;I.current=null,(ce.current===`vertical`?x:y)(!1),R.current!==null&&(P.current&&(P.current.style.scrollSnapType=R.current),R.current=null);let t=ce.current===`vertical`?F.current:re.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),B=Bi(e=>{if(e.pointerId!==I.current)return;if(e.buttons%2==0){z(e);return}let t=P.current;if(!t)return;let n=ce.current===`vertical`,r=n?F.current:re.current,i=n?te.current:ne.current;if(!r||!i)return;let a=n?`y`:`x`,o=om(i,`padding`,a),s=om(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-L.current:e.clientX-ae.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?oe.current:se.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),ue(n)});function V(e){C(e.pointerType===`touch`)}function me(e){if(V(e),e.pointerType!==`touch`){let t=Oa(N.current,e.target);_(t)}}let he=q.useMemo(()=>({scrolling:v||b,hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:A.xStart,overflowXEnd:A.xEnd,overflowYStart:A.yStart,overflowYEnd:A.yEnd,cornerHidden:M.corner}),[v,b,M.x,M.y,M.corner,A]),ge={role:`presentation`,onPointerEnter:me,onPointerMove:me,onPointerDown:V,onPointerLeave(){_(!1)},style:{position:`relative`,[bm]:`${E.height}px`,[xm]:`${E.width}px`}},_e=aa(`div`,e,{state:he,ref:[t,N],props:[ge,o],stateAttributesMapping:gm}),ve=q.useMemo(()=>({handlePointerDown:pe,handlePointerMove:B,handlePointerUp:z,handleScroll:de,disableViewportSnap:fe,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:ie,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:P,scrollbarYRef:te,scrollbarXRef:ne,thumbYRef:F,thumbXRef:re,rootId:d,hiddenState:M,setHiddenState:ee,overflowEdges:A,setOverflowEdges:j,viewportState:he,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[pe,B,z,de,fe,E,O,w,S,v,b,g,d,M,A,he,s,c,l,u]);return(0,J.jsxs)(im.Provider,{value:ve,children:[!h&&cm.getElement(m),_e]})});function Om(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}function km(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}var Am=q.createContext(void 0);function jm(){let e=q.useContext(Am);if(e===void 0)throw Error(Li(55));return e}function Mm(e,t){if(t<=0)return 0;let n=km(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}var Nm=`--scroll-area-overflow-x-start`,Pm=`--scroll-area-overflow-x-end`,Fm=`--scroll-area-overflow-y-start`,Im=`--scroll-area-overflow-y-end`,Lm=`--scroll-area-thumb-height`,Rm=`--scroll-area-thumb-width`,zm=[Nm,Pm,Fm,Im],Bm=!1;function Vm(){Bm||Ha||(typeof CSS<`u`&&`registerProperty`in CSS&&zm.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),Bm=!0)}var Hm=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:_,setHasMeasuredScrollbar:v,handleScroll:y,touchModality:b,setHovering:x,setOverflowEdges:S,overflowEdgeThreshold:C,viewportState:w}=am(),T=co(),E=q.useRef(!0),D=q.useRef([NaN,NaN,NaN,NaN]),O=Aa(),k=Aa(),A=Bi(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,y=e.clientHeight,b=e.clientWidth,x=e.scrollTop,w=e.scrollLeft,E=D.current,O=Number.isNaN(E[0]);if(E[0]=y,E[1]=h,E[2]=b,E[3]=_,O&&v(!0),h===0||_===0)return;let k=Um(e),A=k.y,j=k.x,M=b/_,ee=y/h,N=Math.max(0,_-b),P=Math.max(0,h-y),te=0,ne=0;j||(te=Mm(T===`rtl`?-w:w,N),ne=N-te);let F=A?0:Mm(x,P),re=A?0:P-F,ie=j?0:b,I=A?0:y,L=0,ae=0;!j&&!A&&(L=t?.offsetWidth||0,ae=n?.offsetHeight||0);let oe=f.width===0&&f.height===0,se=oe?L:0,ce=oe?ae:0,le=om(n,`padding`,`x`),R=om(t,`padding`,`y`),ue=om(i,`margin`,`x`),de=om(r,`margin`,`y`),fe=ie-le-ue,pe=I-R-de,z=n?Math.min(n.offsetWidth-se,fe):fe,B=t?Math.min(t.offsetHeight-ce,pe):pe,V=Math.max(16,z*M),me=Math.max(16,B*ee);if(m(e=>Wm(e,{width:V,height:me})),t&&r){let e=Gm(r,Lm,x,P,h,me,t.offsetHeight-me-R-de);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-V-le-ue,t=Gm(i,Rm,T===`rtl`?-w:w,N,_,V,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let he=[te,ne,F,re];zm.forEach((t,n)=>{e.style.setProperty(t,`${he[n]}px`)}),a&&p(e=>Wm(e,{width:L,height:ae})),g(e=>Wm(e,k));let ge={xStart:!j&&te>C.xStart,xEnd:!j&&ne>C.xEnd,yStart:!A&&F>C.yStart,yEnd:!A&&re>C.yEnd};S(e=>Wm(e,ge))});Hi(()=>{Vm()},[]),Hi(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),Hi(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),Hi(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=D.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}A()});return n.observe(e),k.start(0,()=>{let t=Ea(e,{subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished.then(po))).then(A).catch(()=>{})}),()=>{n.disconnect(),k.clear()}},[A,o,k]);function j(){E.current=!1}let M={...h&&{"data-id":`${h}-viewport`},tabIndex:_.x&&_.y?-1:0,className:cm.className,style:{overflow:`scroll`},onScroll(){o.current&&(A(),(b||!E.current)&&y({x:o.current.scrollLeft,y:o.current.scrollTop}),O.start(100,()=>{E.current=!0}))},onWheel:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},ee=aa(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:gm}),N=q.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,J.jsx)(Am.Provider,{value:N,children:ee})});function Um(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function Wm(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function Gm(e,t,n,r,i,a,o){let s=km(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var Km=q.createContext(void 0);function qm(){let e=q.useContext(Km);if(e===void 0)throw Error(Li(54));return e}var Jm=q.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,handleScroll:y,disableViewportSnap:b,rootId:x,thumbSize:S,hasMeasuredScrollbar:C,viewportState:w}=am(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=co(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;q.useEffect(()=>{if(!A)return;let e=m.current,t=T?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!T,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&D===`rtl`?-a:0,s=n&&D===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),y({x:e.scrollLeft,y:e.scrollTop}))}return Ta(t,`wheel`,n,{passive:!1})},[D,y,T,p,f,A,m]);let j={...x&&{"data-id":`${x}-scrollbar`},"aria-hidden":!0,onPointerDown(e){if(e.button!==0)return;let t=Ja(e.nativeEvent),n=T?h.current:g.current;if(n&&Oa(n,t))return;let r=m.current;if(!r)return;let i=T?f.current:p.current;if(!n||!i)return;let a=T?`y`:`x`,o=om(n,`margin`,a),s=om(i,`padding`,a),c=T?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=T?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=T?r.scrollHeight:r.scrollWidth,v=T?r.clientHeight:r.clientWidth,x=(T?i.offsetHeight:i.offsetWidth)-c-s-o;if(x<=0)return;let S=u/x,C=d-v;b(),T?r.scrollTop=S*C:r.scrollLeft=D===`rtl`?-(1-S)*C:S*C,y({x:r.scrollLeft,y:r.scrollTop}),_(e)},onMouseDown(e){e.preventDefault()},onPointerUp:v,onPointerCancel:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:O?`hidden`:void 0,...T?{top:0,bottom:`var(${bm})`,insetInlineEnd:0,[Lm]:`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${xm})`,bottom:0,[Rm]:`${S.width}px`}}},M=aa(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:gm});return A?(0,J.jsx)(Km.Provider,{value:i,children:M}):null}),Ym=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{computeThumbPosition:o}=jm(),{hasMeasuredScrollbar:s,viewportState:c}=am(),l=q.useRef(null),u=q.useRef(s);return Hi(()=>{if(typeof ResizeObserver>`u`)return;let e=!1,t=new ResizeObserver(()=>{!e&&(e=!0,!u.current)||o()});return l.current&&t.observe(l.current),()=>{t.disconnect()}},[o]),aa(`div`,e,{ref:[t,l],state:c,stateAttributesMapping:gm,props:[{role:`presentation`,style:{minWidth:`fit-content`}},a]})}),Xm=q.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=am(),m=qm(),h=m===`vertical`;return aa(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})});function Zm(e,t,n){let r=(Math.abs(t)-Math.abs(e))/Math.max(16,n);if(Math.abs(r)<.035)return null;let i=Math.min(.04,Math.abs(r)*.3),a=r>0,o=Math.sign(t||e);return{scaleY:1+(a?i:-i),scaleX:1+(a?-i/2:i/2),origin:(a?o>0:o<0)?`center top`:`center bottom`}}function Qm(e,t,n){if(t<=0||Math.abs(n)<4)return null;let r=e<=0&&n<0,i=e>=t-1&&n>0;if(!r&&!i)return null;let a=Math.min(.06,Math.abs(n)/120*.06);return{scaleY:1-a,scaleX:1+a/2,origin:r?`center top`:`center bottom`}}var $m=(0,q.forwardRef)(function({children:e,className:t,surface:n=!1,surfaceSize:r,surfaceDepth:i,screen:a=!1,...o},s){let c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=le();(0,q.useEffect)(()=>{let e=c.current,t=e?.querySelector(`.caps-scroll-viewport`);if(!t||!e)return;let n=null,r,i=t.scrollTop,a=performance.now(),o=0,s=e=>{let t=l.current;if(!e||u||!t)return;n?.cancel(),t.style.transformOrigin=e.origin;let r=kt(t),i=Hn(r,{ease:`outQuad`,duration:45}),a=ni(r,{bounce:.18,duration:180});n=mo(t,{scaleY:[{to:e.scaleY,...i},{to:1,...a}],scaleX:[{to:e.scaleX,...i},{to:1,...a}]})},d=(e,t)=>{let n=Zm(o,e,t);o=e,s(n)},f=e=>{if(e.ctrlKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;let n=e.deltaMode===1?16:e.deltaMode===2?t.clientHeight:1,i=Qm(t.scrollTop,t.scrollHeight-t.clientHeight,e.deltaY*n);i&&(clearTimeout(r),o=0,s(i))},p=()=>{let e=performance.now(),n=e-a,s=n>100?16:Math.max(16,n),c=t.scrollTop-i;n>100&&(o=0),d(c/s,s),i=t.scrollTop,a=e,clearTimeout(r),r=setTimeout(()=>{d(0,32)},64)};return t.addEventListener(`scroll`,p,{passive:!0}),e.addEventListener(`wheel`,f,{passive:!0}),()=>{clearTimeout(r),n?.cancel(),l.current&&(l.current.style.transform=`none`),t.removeEventListener(`scroll`,p),e.removeEventListener(`wheel`,f)}},[a,n,u]);let d=(0,J.jsx)(Hm,{render:a?(0,J.jsx)(dr,{}):(0,J.jsx)(`div`,{}),...o,ref:s,className:`caps-scroll-viewport`,children:(0,J.jsx)(Ym,{style:{minWidth:0},children:e})});return(0,J.jsxs)(Dm,{render:n?(0,J.jsx)(pr,{size:r??`md`,depth:i??`shallow`}):(0,J.jsx)(`div`,{}),ref:c,className:B(`caps-scroll-area`,t),children:[a?(0,J.jsx)(`div`,{className:`caps-display-gasket caps-scroll-display`,children:d}):d,(0,J.jsx)(pr,{size:`sm`,depth:`deep`,placement:`embedded`,className:`caps-scroll-track-surface`,children:(0,J.jsx)(Jm,{className:`caps-scroll-track`,children:(0,J.jsx)(Xm,{className:`caps-scroll-thumb`,children:(0,J.jsx)(`span`,{className:`caps-scroll-thumb-surface`,ref:l})})})})]})}),eh=Bt(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),th=Bt(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),nh=Bt(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),rh=Bt(`AudioLines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),ih=Bt(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),ah=Bt(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),oh=Bt(`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`}]]),sh=Bt(`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`}]]),ch=Bt(`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`}]]),lh=Bt(`FolderTree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),uh=Bt(`Folder`,[[`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`}]]),dh=Bt(`ImagePlus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),fh=Bt(`Info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),ph=Bt(`ListChecks`,[[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),mh=Bt(`Maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),hh=Bt(`Mic`,[[`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`,key:`131961`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),gh=Bt(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),_h=Bt(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),vh=Bt(`Pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),yh=Bt(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),bh=Bt(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),xh=Bt(`SlidersHorizontal`,[[`line`,{x1:`21`,x2:`14`,y1:`4`,y2:`4`,key:`obuewd`}],[`line`,{x1:`10`,x2:`3`,y1:`4`,y2:`4`,key:`1q6298`}],[`line`,{x1:`21`,x2:`12`,y1:`12`,y2:`12`,key:`1iu8h1`}],[`line`,{x1:`8`,x2:`3`,y1:`12`,y2:`12`,key:`ntss68`}],[`line`,{x1:`21`,x2:`16`,y1:`20`,y2:`20`,key:`14d8ph`}],[`line`,{x1:`12`,x2:`3`,y1:`20`,y2:`20`,key:`m0wm8r`}],[`line`,{x1:`14`,x2:`14`,y1:`2`,y2:`6`,key:`14e1ph`}],[`line`,{x1:`8`,x2:`8`,y1:`10`,y2:`14`,key:`1i6ji0`}],[`line`,{x1:`16`,x2:`16`,y1:`18`,y2:`22`,key:`1lctlv`}]]),Sh=Bt(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Ch=Bt(`Upload`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`17 8 12 3 7 8`,key:`t8dd8p`}],[`line`,{x1:`12`,x2:`12`,y1:`3`,y2:`15`,key:`widbto`}]]),wh=At([g({kind:Mn(`compose`),text:b.pipe(R(F(1)),R(D(2e3)))}),g({kind:Mn(`navigate`),params:St(g({key:b.pipe(R(F(1)),R(D(64))),value:b.pipe(R(D(1024)))})).pipe(R(D(16)))})]);At([g({role:b.pipe(R(F(1)),R(D(80))),intent:wh}),g({appId:b.pipe(R(F(1)),R(D(128))),intent:wh})],{mode:`oneOf`});var Th=lt({displayName:K().min(1).max(80).nullable()}).nullable(),Eh=ke(`apps.open`,1,te(()=>ve({open:l,role:Fn(ie(Th))})));ke(`apps.call`,1,te(()=>ve({call:Fn(ie(an().transform(e=>pe(e))))})));var Dh=K().regex(/^[a-zA-Z0-9._-]{1,128}$/).refine(e=>e!==`.`&&e!==`..`),Oh=K().regex(/^[0-9a-f]{40}$/);lt({ref:K().startsWith(`refs/`).max(1024),before:Oh,after:Oh}),te(()=>K().min(1).max(512));var kh=`files`,Ah=lt({name:K(),email:K()}),jh=lt({hash:Oh,treeHash:Oh,message:K(),author:Ah,committer:Ah,parents:Pe(Oh),authoredAt:U(),committedAt:U()}),Mh=lt({name:K(),mode:K(),hash:Oh,type:j([`blob`,`tree`,`commit`])});lt({ref:K(),commit:jh,path:K(),entries:Pe(Mh)});var Nh=65536,Ph=K().min(1).max(1024).refine(e=>!e.startsWith(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&e!==`.git`),`Choose a relative repository file path.`),Fh=K().min(1).max(256),Ih={repo:Dh,branch:Fh,path:Ph},Lh=j([`pending`,`synced`,`conflict`,`failed`]),Rh=lt({text:K(),revision:U().int().positive(),state:Lh,theirs:lt({blob:Oh.nullable(),commit:Oh}).optional(),failure:j([`branch_missing`,`access_changed`,`sync_failed`,`permanent_material`]).optional()});lt({...Ih,baseBlob:Oh.nullable(),baseCommit:Oh,text:K().max(Nh),revision:U().int().positive().nullable()});var zh=Wt([lt({kind:ze(`saved`),revision:U().int().positive(),state:ze(`pending`)}),lt({kind:ze(`synced`),revision:U().int().positive(),commit:Oh}),lt({kind:ze(`conflict`),revision:U().int().nonnegative(),theirs:Rh.shape.theirs.optional()}),lt({kind:ze(`failed`),revision:U().int().positive(),reason:j([`branch_missing`,`access_changed`,`sync_failed`,`permanent_material`])}),lt({kind:ze(`refused`),reason:j([`not-source-writer`,`background-unavailable`])})]);lt({...Ih,revision:U().int().positive()}),Wt([lt({kind:j([`discarded`,`not_found`])}),lt({kind:ze(`conflict`),revision:U().int().positive()})]),lt({settled:Pe(lt({...Ih,result:zh})),more:O()}),lt({version:U().int().positive().nullable(),commit:Oh,blob:Oh.nullable(),pending:Rh.optional(),ref:K(),path:K(),size:U(),binary:O(),text:K().nullable()}),lt({ref:K(),commits:Pe(lt({commit:jh,agent:K().nullable()})),next:K().optional()}),lt({ref:K(),commit:jh,paths:Pe(K()),truncated:O()}),lt({kind:ze(`rebuilding`)}),lt({done:O(),cursor:K().nullable()}),Wt([lt({repository:Dh,branch:Fh,path:Ph}),lt({path:K().min(1).max(1024)})]);var Bh=e(Mt(),1);function Vh({className:e,...t}){let n=ca(`toast`);return n?(0,Bh.createPortal)((0,J.jsx)(ft,{position:`top-right`,swipeDirections:[`right`,`top`],offset:16,gap:8,icons:{close:(0,J.jsx)(Hr,{"aria-hidden":`true`,size:12}),success:(0,J.jsx)(em,{glyph:`dot`,tone:`success`}),error:(0,J.jsx)(em,{glyph:`dot`,tone:`error`}),warning:(0,J.jsx)(em,{glyph:`dot`,tone:`warning`}),info:(0,J.jsx)(em,{glyph:`dot`,tone:`info`}),loading:(0,J.jsx)(yn,{decorative:!0,size:`sm`,tone:`current`,variant:`wander`})},className:B(`caps-toaster`,e),...t}),n):null}var Hh=4096,Uh=255,Wh=new TextEncoder,Gh=b.pipe(R(F(1)),R(D(Hh)),R(P(e=>!e.includes(`\0`)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&Wh.encode(e).byteLength<=Uh),{description:`a relative folder inside the library`}))),Kh=u(Gh);function qh(e,t){return t===void 0?e:`${e}/${t}`}function Jh(e,t){let n=`${e}/`;if(!t.startsWith(n))return;let r=t.slice(n.length).split(`/`).slice(0,-1).join(`/`);return Kh(r)?r:void 0}function Yh(e){if(e===void 0)return[];let t=e.split(`/`);return t.map((e,n)=>({name:e,folder:t.slice(0,n+1).join(`/`)}))}g({queue:St(b.pipe(R(D(Hh)))).pipe(R(F(1))),offset:wn.pipe(R(Ne()),R(Oe(0)))});var Xh=_e({error:K()}),Zh=K().min(1).max(4096),Qh=j([`not_granted`,`not_found`,`conflict`,`invalid`,`unavailable`]),$h=_e({moved:Pe(_e({from:Zh,to:Zh})),failed:Pe(_e({path:Zh,error:Qh}))}),eg=_e({files:Pe(_e({path:Zh,kind:j([`image`,`video`,`audio`]).nullable(),model:K().nullable(),modelLabel:K().nullable(),durationSeconds:U().nullable(),favorite:O()}))}),tg=_e({paths:Pe(Zh),next:Zh.nullable()});async function ng(e,t,n,r){let i=await e.capabilities.require(Qn).call(t,JSON.stringify(n)),a=r.safeParse(i);if(a.success)return a.data;let o=Xh.safeParse(i);throw new G(o.success?`Prints refused ${t}: ${o.data.error}`:`Prints answered ${t} in an unexpected shape`,{code:`PROTOCOL`,retryable:!1})}function rg(e,t){return ng(e,`moveFiles`,{paths:[...t.paths],folder:t.folder,createFolder:t.createFolder??!1,name:t.name},$h)}async function ig(e,t){return(await ng(e,`describeFiles`,{paths:[...t]},eg)).files}async function ag(e,t,n){await ng(e,`setFavorite`,{paths:[...t],favorite:n},_e({favorite:O(),count:U()}))}function og(e,t,n){return ng(e,`listFavorites`,{after:t,limit:n},tg)}var sg=24,cg=e=>e===null?null:e.kind===`folder`?e.path:`${e.kind}:${e.path}`,lg={all:e=>Mi.of(e,`prints`,`gallery`),listings:e=>[...lg.all(e),`listing`],listing:(e,t)=>[...lg.listings(e),t],file:(e,t)=>[...lg.all(e),`file`,t],describedAll:e=>[...lg.all(e),`described`],described:(e,t)=>[...lg.describedAll(e),...t]},ug=/\.(avif|gif|jpe?g|png|svg|webp|mp4|mp3)$/i;function dg(e,t){let n=e?.context.get().computerId,r=t?.path??null,i={queue:r===null?[]:[r],offset:0,after:null};return Cs({queryKey:lg.listing(e,cg(t)),initialPageParam:i,enabled:!!(n&&r&&e.capabilities.has(Xa)&&e.capabilities.has(Na)),queryFn:async({pageParam:r,signal:i})=>{if(!e||!n||!t)throw new G(`No Computer folder selected`,{code:`SELECTION_CHANGED`,retryable:!1});let a=()=>{if(i.throwIfAborted(),e.context.get().computerId!==n)throw new G(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1})};if(t.kind===`favorites`){let n=[];a();let i=await og(e,r.after,sg);return a(),{entries:i.paths.filter(e=>ug.test(e)).map(e=>({path:e,name:e.slice(e.lastIndexOf(`/`)+1),modifiedAt:0,size:0,...fg(t.path,e)})),folders:n,next:i.next===null?null:{queue:[],offset:0,after:i.next}}}let o=[],s=[],c=[...r.queue],l=r.offset;for(;o.length<sg&&c.length>0;){a();let n=c[0],r=await Ga(e.capabilities,{path:n,limit:sg-o.length,offset:l});if(a(),r.nextOffset!==null&&r.nextOffset<=l)throw new G(`Directory pagination did not advance`,{code:`PROTOCOL`,retryable:!1});let i=r.path.replace(/\/$/,``);for(let e of r.entries)e.name.startsWith(`.`)||(e.type===`directory`?t.kind===`all`?c.push(`${i}/${e.name}`):s.push(e.name):e.type===`file`&&ug.test(e.name)&&o.push({...e,path:`${i}/${e.name}`,...fg(t.path,`${i}/${e.name}`)}));r.nextOffset===null?(c=c.slice(1),l=0):l=r.nextOffset}return{entries:o,folders:s,next:c.length===0?null:{queue:c,offset:l,after:null}}},getNextPageParam:e=>e.next})}function fg(e,t){let n=Jh(e,t);return n===void 0?{}:{folder:n}}function pg(e,t,n){return{...rr(e,Na,[...lg.file(e,t.path),t.modifiedAt,t.size],async(n,r)=>{if(!e)throw new G(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0});let i=await Qa(e.capabilities,{path:t.path},{signal:r});return new File([i],i.name,{type:i.type,lastModified:t.modifiedAt})}),enabled:!!(n&&e?.context.get().computerId&&e.capabilities.has(Na)),structuralSharing:!1}}function mg(e,t){let n=e?.app??null,r=yf(n),i=gn(),[a,o]=(0,q.useState)(()=>new Set),s=(0,q.useCallback)(e=>{if(!r)return;let t=`${r}:${e}`;o(e=>e.has(t)?e:new Set([...e,t]))},[r]),c=(0,q.useCallback)(e=>{s(e),i.resetQueries({queryKey:lg.file(n,e)})},[n,i,s]),l=dg(n,t),u=Es(l),d=(0,q.useMemo)(()=>l.enabled?u.data?.pages.flatMap(e=>e.entries)??[]:[],[u.data,l.enabled]),f=(0,q.useCallback)(e=>({files:e.flatMap((e,t)=>e.data?[{path:d[t].path,file:e.data}]:[]),failures:e.flatMap((e,t)=>e.isError?[d[t].name]:[]),loading:e.some(e=>e.isLoading)}),[d]),p=Ss({queries:d.map(e=>pg(n,e,!!(r&&a.has(`${r}:${e.path}`)))),combine:f});return(0,q.useEffect)(()=>{if(!n)return;let e=lg.all(n),t=lg.listings(n),a=!0;i.invalidateQueries({queryKey:e});let o=()=>{i.cancelQueries({queryKey:e})},s=n.context.subscribe(e=>{e.computerId!==r&&o()}),c=n.lifecycle.subscribe(e=>{(e===`disconnected`||e===`disposing`||e===`disposed`)&&o()}),l=n.capabilities.subscribe(()=>{queueMicrotask(()=>{!a||n.context.get().computerId!==r||i.resetQueries({queryKey:t})})});return()=>{a=!1,s(),c(),l(),o()}},[n,r,e,i]),{entries:d,folders:(0,q.useMemo)(()=>[...new Set(u.data?.pages.flatMap(e=>e.folders)??[])],[u.data]),loadFile:s,retryFile:c,files:p.files,failures:p.failures,error:u.error,loading:u.isFetching||p.loading,hasNextPage:u.hasNextPage,nextPageReady:u.hasNextPage&&!u.isFetching&&!u.error,refresh:()=>{u.refetch({cancelRefetch:!1})},loadMore:()=>{u.isFetching||u.fetchNextPage({cancelRefetch:!1})}}}function hg(e){return e.replace(/\s/gu,` `).replace(/ +/g,` `).trim()}function gg(e,t,n){let r=e.replace(/\/$/,``),i=t.lastIndexOf(`.`),a=i>0?t.slice(0,i):t,o=i>0?t.slice(i):``,s=`${r}/${t}`;for(let e=2;n(s);e+=1)s=`${r}/${a} ${String(e)}${o}`;return s}async function _g(e,t){let n=e.replace(/\/$/,``),r=new Set,i=0;for(;i!==null;){let e=await t(i);if(e.nextOffset!==null&&e.nextOffset<=i)throw Error(`Directory pagination did not advance`);for(let t of e.entries)r.add(`${n}/${t.name}`);i=e.nextOffset}return r}function vg(e,t){let[n,r]=(0,q.useState)([]),i=(0,q.useRef)(new Map),a=(0,q.useRef)(Promise.resolve()),[o,s]=(0,q.useState)(null),c=(0,q.useRef)(new Map),l=(0,q.useRef)(e);l.current=e;let u=(0,q.useRef)(t);u.current=t;let d=(e,t,n)=>{let a=i.current.get(e);a&&i.current.set(e,{...a,status:t,message:n}),r([...i.current.values()])},f=(0,q.useCallback)(async(e,t)=>{let n=()=>t.signal.aborted;if(n()){d(e.id,`cancelled`,`Cancelled before sending`),c.current.delete(e.id);return}let r=e.dimensions;if(!r)try{let t=await eo(e.file,e.previewUrl);r={width:t.width,height:t.height},e.dimensions=r;let n=i.current.get(e.id);n&&i.current.set(e.id,{...n,dimensions:r})}catch(t){dn(`decode-upload-image`,t),d(e.id,`error`,`Could not decode this image. No upload was sent.`),c.current.delete(e.id);return}try{if(n()){d(e.id,`cancelled`,`Cancelled before sending`);return}if(e.app.context.get().computerId!==e.computerId){d(e.id,`error`,`Computer changed. Select the original Computer and retry. No upload was sent.`);return}u.current({id:e.id,path:e.path,computerId:e.computerId,app:e.app,width:r.width,height:r.height}),d(e.id,`sending`,`Sending; awaiting Computer completion`),await Sa(e.app.capabilities,{path:e.path,content:e.file.slice()},{signal:t.signal}),d(e.id,`complete`,`Written to Computer`);try{await l.current(e.path,e.app,e.computerId)}catch(t){dn(`refresh-upload-preview`,t),d(e.id,`complete`,`Written; fresh preview unavailable`)}}catch(t){n()||dn(`write-computer-upload`,t),d(e.id,n()?`cancelled`:`error`,n()?`Cancelled request; check Computer before retrying`:`Completion not confirmed; check Computer or retry`)}finally{c.current.delete(e.id)}},[]),p=e=>{let t=new AbortController;c.current.set(e.id,t),d(e.id,`queued`,`Queued`),a.current=a.current.then(()=>f(e,t))},m=(0,q.useCallback)(()=>{for(let e of c.current.values())e.abort()},[]);return(0,q.useEffect)(()=>()=>{m();for(let e of i.current.values())URL.revokeObjectURL(e.previewUrl)},[m]),{items:n,error:o,cancelAll:m,add(e,t,n,r=new Set){s(null);let a=[...i.current.values()].reduce((e,t)=>e+t.file.size,0);for(let o of e){if(!o.type.startsWith(`image/`)){s(`Only image files can be uploaded here`);continue}if(i.current.size>=8||a+o.size>67108864){s(`Upload queue limit: eight files and 64 MiB. Remove finished rows before adding more.`);break}let e=n.context.get().computerId;if(!e){s(`Select a Computer before uploading images.`);continue}let c=gg(t,hg(o.name),e=>r.has(e)||i.current.has(e)),l={computerId:e,id:c,file:o,previewUrl:URL.createObjectURL(o),app:n,path:c,status:`queued`,message:`Queued`};i.current.set(l.id,l),a+=o.size,p(l)}},cancel(e){c.current.get(e)?.abort()},retry(e){let t=n.find(t=>t.id===e);t&&!c.current.has(e)&&p(t)},remove(e){if(!c.current.has(e)){let t=i.current.get(e);t&&URL.revokeObjectURL(t.previewUrl),i.current.delete(e),r([...i.current.values()])}}}}function yg(e){return e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name}function bg(e){return e.connection.app.ui.openNavigation({computerId:e.computerId,path:e.path})}function xg(e){let[t,n]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(n(!1),!e?.capabilities.has(Eh))return;let t=!0;return e.capabilities.require(Eh).role(kh).then(e=>{t&&n(e!==null)},e=>{dn(`files-editor-role`,e)}),()=>{t=!1}},[e]),t}function Sg(e,t){let n=t.landingPath,r=yf(e?.app),i=(0,q.useRef)(new Set),a=(0,q.useRef)(0),o=(0,q.useRef)(e);o.current=e;let s=e?.app.capabilities.has(Xa)===!0,c=e?.app.capabilities.has(Na)===!0,l=e?.app.capabilities.has(ya)===!0,u=mg(e,t.source),[d,f]=(0,q.useState)([]),[p,m]=(0,q.useState)([]),[h,g]=(0,q.useState)([]),[_,v]=(0,q.useState)([]);(0,q.useEffect)(()=>{v([])},[e]);let y=e=>{v(t=>t.some(t=>t.key===e.key)?t.map(t=>t.key===e.key?e:t):[...t,e])},[b,x]=(0,q.useState)(!1),S=(0,q.useMemo)(()=>[...u.error?[`Could not refresh the Media gallery`]:[],...u.failures],[u.error,u.failures]),C=(0,q.useRef)(new WeakMap),w=(0,q.useMemo)(()=>{if(!c||!s)return d.filter(e=>e.kind===`local`);let t=r?u.files.map(({file:t,path:n})=>({kind:`computer`,computerId:r,connection:e,file:t,path:n})):[],i=d.filter(t=>t.kind===`local`||t.computerId===r&&t.connection===e&&t.path.slice(0,t.path.lastIndexOf(`/`))===n?.replace(/\/$/,``));return[...t.filter(e=>!i.some(t=>t.kind===`computer`&&e.kind===`computer`&&t.path===e.path)),...i]},[e,r,n,u.files,d,c,s]),T=(0,q.useCallback)(()=>{a.current+=1;for(let e of i.current)e.abort();i.current.clear()},[]);(0,q.useEffect)(()=>{if(!e)return()=>{T()};let t=e.app.lifecycle.subscribe(e=>{(e===`disconnected`||e===`disposing`||e===`disposed`)&&T()});return()=>{t(),T()}},[e,T]),(0,q.useEffect)(()=>{if(e)return e.app.context.subscribe(e=>{e.computerId!==r&&T()})},[e,r,T]),(0,q.useEffect)(()=>{v([]),f(e=>e.filter(e=>e.kind===`local`))},[r]);let E=(0,q.useCallback)(async(e,t,n)=>{let r=n??t.app.context.get().computerId;if(!r){g([`The selected Computer is unavailable`]);return}if(o.current!==t){g([`Computer selection changed`]);return}if(t.app.context.get().computerId!==r){g([`Computer selection changed before the preview was loaded`]);return}let s=a.current,c=new AbortController;i.current.add(c);try{let n=await Qa(t.app.capabilities,{path:e},{signal:c.signal});if(c.signal.aborted||s!==a.current)return;v(t=>t.map(t=>t.key===`${r}:${e}`?{...t,previewFile:n}:t)),f(i=>[...i.filter(t=>t.kind!==`computer`||t.path!==e||t.computerId!==r),{kind:`computer`,computerId:r,file:n,path:e,connection:t}])}catch(t){c.signal.aborted||(dn(`read-computer-file`,t),g([`Could not read ${e}`]),v(t=>t.map(t=>t.key===`${r}:${e}`?{...t,error:`Saved; preview unavailable. Retry loading it.`}:t)))}finally{i.current.delete(c)}},[]),D=(0,q.useCallback)(t=>{let n=d.find(n=>n.kind===`computer`&&n.connection===e&&n.computerId===r&&n.path===t);n?.kind===`computer`?E(t,n.connection,n.computerId):u.retryFile(t)},[d,e,r,E,u.retryFile]),O=(0,q.useRef)(new Set),k=(0,q.useRef)(new Set),A=(0,q.useCallback)(e=>{URL.revokeObjectURL(e),O.current.delete(e)},[]);(0,q.useEffect)(()=>{let e=!0,t=new Set,n=new Map,r=new Set,i=[...w].sort((e,t)=>t.file.lastModified-e.file.lastModified||e.file.name.localeCompare(t.file.name)).map(e=>{let t=URL.createObjectURL(e.file);return O.current.add(t),{source:e,file:e.file,url:t}}),a=i.length;return g(S),x(a>0),a===0&&m([]),i.forEach(({file:o,url:s,source:c},l)=>{let u=C.current.get(o);u||(u=(async()=>{let e=URL.createObjectURL(o);try{let{width:t,height:n}=await eo(o,e);return{width:t,height:n}}finally{URL.revokeObjectURL(e)}})(),C.current.set(o,u)),u.then(r=>{e&&(n.set(l,{...r,file:o,url:s,source:c}),t.add(s),m(i.flatMap((e,t)=>{let r=n.get(t);return r?[r]:[]})),v(e=>e.map(e=>e.previewFile===o?{...e,resolved:!0,previewFile:void 0,error:void 0}:e)))}).catch(t=>{e&&(dn(`decode-gallery-image`,t),A(s),r.add(o.name),g([...S,...r]),c.kind===`computer`&&v(e=>e.map(e=>e.key===`${c.computerId}:${c.path}`?{...e,error:`Could not decode the saved image.`}:e)))}).finally(()=>{--a,e&&a===0&&(x(!1),m(i.flatMap((e,t)=>{let r=n.get(t);return r?[r]:[]})))})}),()=>{e=!1;for(let{url:e}of i)t.has(e)||A(e)}},[w,S,A]),(0,q.useEffect)(()=>{let e=new Set(p.map(e=>e.url));for(let t of k.current)e.has(t)||A(t);k.current=e},[p,A]),(0,q.useEffect)(()=>{let e=O.current;return()=>{for(let t of e)URL.revokeObjectURL(t);e.clear()}},[]);let j=vg(async(e,t,n)=>{let r=o.current,i=r?.app===t&&t.context.get().computerId===n?r:null;i&&await E(e,i,n)},e=>{o.current?.app===e.app&&e.app.context.get().computerId===e.computerId&&y({key:`${e.computerId}:${e.path}`,path:e.path,computerId:e.computerId,width:e.width,height:e.height,uploadId:e.id})});return(0,q.useEffect)(()=>{let t=j.cancelAll,n=e?.app.lifecycle.subscribe(e=>{(e===`disposing`||e===`disconnected`||e===`disposed`)&&t()});return()=>{n?.(),t()}},[e,j.cancelAll]),{images:p,failed:h,loading:b,gallery:u,gallerySlots:_,canBrowse:s,canRead:c,canWrite:l,reserveSlot:y,addComputerFile:E,retryFile:D,uploads:j,uploadFiles:async i=>{if(!e||!l||n===null)return;let a=e,s=r,c=await t.ensureCreated();if(c){g([c]);return}if(o.current!==a||a.app.context.get().computerId!==s)return;let u;try{u=await _g(n,e=>Ga(a.app.capabilities,{path:n,limit:500,offset:e}))}catch(e){dn(`list-upload-destination`,e),g([`Could not check the Computer folder. No upload was sent.`]);return}o.current===a&&a.app.context.get().computerId===s&&j.add(i,n,a.app,u)},failSlot:(e,t)=>{v(n=>n.map(n=>n.key===e?{...n,error:t}:n))},clearSlotError:e=>{v(t=>t.map(t=>t.key===e?{...t,error:void 0}:t))},removeSlot:e=>{v(t=>t.filter(t=>t.key!==e))}}}function Cg(e){return e.map(e=>e.key)}function wg(e,t,n){let r=e.indexOf(t);return r<0?null:e[r+n]??null}function Tg(e,t,n){if(e.includes(t))return t;let r=n.indexOf(t);if(r>=0){let t=new Set(e);for(let e=1;e<n.length;e+=1)for(let i of[e,-e]){let e=r+i;if(e<0||e>=n.length)continue;let a=n[e];if(t.has(a))return a}}return e[0]??null}var Eg=M(`badge caps-badge`,{variants:{tone:{neutral:`badge-neutral`,primary:`badge-primary`,secondary:`badge-secondary`,accent:`badge-accent`,success:`badge-success`,info:`badge-info`,warning:`badge-warning`,error:`badge-error`},size:{sm:`badge-sm`,default:`badge-md`,lg:`badge-lg`},variant:{solid:``,quiet:`caps-badge-quiet`}},defaultVariants:{tone:`neutral`,size:`default`}}),Dg=(0,q.forwardRef)(function({className:e,size:t,tone:n,variant:r,...i},a){return(0,J.jsx)(`span`,{...i,className:B(Eg({size:t,tone:n,variant:r}),e),ref:a})}),Og=(0,q.createContext)(null),kg=(0,q.forwardRef)(function({children:e,defaultValue:t,onValueChange:n,value:r,...i},a){let[o,s]=(0,q.useState)(t),c=r??o,l=(0,q.useId)(),u=e=>{r===void 0&&s(e),n?.(e)},d=(e,t)=>`${l}-${e}-${encodeURIComponent(t)}`;return(0,J.jsx)(Og.Provider,{value:{onValueChange:u,panelId:e=>d(`panel`,e),selectedValue:c,tabId:e=>d(`tab`,e)},children:(0,J.jsx)(`div`,{...i,className:B(`w-full`,i.className),ref:a,children:e})})});function Ag(){let e=(0,q.useContext)(Og);if(!e)throw Error(`Tabs parts must be used inside <Tabs>`);return e}var jg=(0,q.forwardRef)(function({className:e,variant:t=`bordered`,...n},r){return(0,J.jsx)(`div`,{...n,"aria-orientation":n[`aria-orientation`]??`horizontal`,className:B(t===`segmented`?`tabs caps-tabs-segmented w-full`:`tabs tabs-border flex w-full items-center gap-xs`,e),"data-variant":t,ref:r,role:`tablist`})}),Mg=(0,q.forwardRef)(function({className:e,disabled:t,onClick:n,onKeyDown:r,value:i,...a},o){let s=Ag(),c=s.selectedValue===i,l=e=>{let t=e.currentTarget.closest(`[role="tablist"]`);if(!(t instanceof HTMLElement))return;let n=Array.from(t.querySelectorAll(`[role="tab"]`)).filter(e=>!e.disabled&&e.getAttribute(`aria-disabled`)!==`true`),r=n.indexOf(e.currentTarget);if(r<0||n.length===0)return;let a;if(e.key===`ArrowRight`)a=(r+1)%n.length;else if(e.key===`ArrowLeft`)a=(r-1+n.length)%n.length;else if(e.key===`Home`)a=0;else if(e.key===`End`)a=n.length-1;else return;e.preventDefault();let o=n[a];o?.focus(),o&&s.onValueChange(o.dataset.tabValue??i)};return(0,J.jsx)(`button`,{...a,"aria-controls":s.panelId(i),"aria-disabled":t?!0:void 0,"aria-selected":c,className:B(`tab whitespace-nowrap text-base-content transition-colors focus-visible:outline-none focus-visible:ring-2 caps-focus-color`,c&&`tab-active`,e),"data-tab-value":i,disabled:t,id:s.tabId(i),onClick:e=>{n?.(e),!e.defaultPrevented&&!t&&s.onValueChange(i)},onKeyDown:e=>{r?.(e),e.defaultPrevented||l(e)},ref:o,role:`tab`,tabIndex:t?-1:c?0:-1,type:a.type??`button`})});(0,q.forwardRef)(function({children:e,className:t,forceMount:n=!1,value:r,...i},a){let o=Ag(),s=o.selectedValue===r;return!s&&!n?null:(0,J.jsx)(`div`,{...i,"aria-labelledby":o.tabId(r),className:B(`mt-md focus-visible:outline-none`,t),hidden:!s,id:o.panelId(r),ref:a,role:`tabpanel`,tabIndex:0,children:e})});function Ng(e){return e?.closest(`[data-app-pane="media"]`)??e}var Pg={voice:`Voice`,sfx:`Sound effects`,music:`Music`};function Fg(e){return e.audio.mode===`speech`?`voice`:`music`}function Ig(e){return e.flatMap(e=>e.audio===null?[]:[{id:e.id,label:e.label,audio:e.audio}])}function Lg(e){return e.audio===null?null:e.audio.mode===`speech`?`voice`:`music`}function Rg(e){let t=new Set(e.map(Fg));return[`voice`,`sfx`,`music`].filter(e=>t.has(e))}function zg(e,t){return e.filter(e=>Fg(e)===t)}function Bg({modes:e,value:t,onChange:n,disabled:r=!1}){return(0,J.jsx)(kg,{className:`prints-audio-modes`,value:t,onValueChange:t=>{let r=e.find(e=>e===t);r!==void 0&&n(r)},children:(0,J.jsx)(jg,{"aria-label":`Audio type`,className:`prints-audio-modes-list`,variant:`segmented`,children:e.map(e=>(0,J.jsx)(Mg,{"data-audio-mode":e,disabled:r,value:e,children:Pg[e]},e))})})}function Vg({label:e,name:t,options:n,value:r,disabled:i,onChange:a,icon:o,compact:s=!1}){let[c,l]=(0,q.useState)(null);return(0,J.jsx)(`span`,{className:`contents`,ref:l,children:(0,J.jsxs)(no,{children:[(0,J.jsx)(Va,{"aria-label":t,disabled:i||n.length===0,render:(t,n)=>(0,J.jsx)(bt,{...t,className:B(`parakeet-composer-model-key`,s&&`prints-audio-key-compact`),expanded:n.open,icon:o,label:e,readout:(0,J.jsx)(Jn,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`})})}),(0,J.jsx)(Da,{align:`start`,"aria-label":t,container:Ng(c),side:`top`,children:n.map(e=>(0,J.jsx)(wa,{checked:e.value===r,closeOnClick:!0,onSelect:()=>{a(e.value)},children:e.label},String(e.value)))})]})})}function Hg({models:e,value:t,onChange:n,disabled:r=!1}){let i=e.find(e=>e.id===t);return(0,J.jsx)(Vg,{disabled:r,label:i===void 0?`Model`:ui(i),name:`Generation model`,onChange:n,options:e.map(e=>({value:e.id,label:e.label})),value:t})}function Ug({voices:e,value:t,onChange:n,disabled:r=!1}){let i=e.find(e=>e.id===t);return(0,J.jsx)(Vg,{disabled:r,compact:!0,icon:(0,J.jsx)(hh,{}),label:i?.label??`Voice`,name:`Voice`,onChange:n,options:e.map(e=>({value:e.id,label:e.label})),value:t})}var Wg=[10,15,30,60,90,120,180,300,600];function Gg(e){let t=Wg.filter(t=>t>=e.min&&t<=e.max);return[...new Set([...t,e.default])].sort((e,t)=>e-t)}function Kg({seconds:e,value:t,onChange:n,disabled:r=!1}){return(0,J.jsx)(Vg,{disabled:r,compact:!0,icon:(0,J.jsx)(Xn,{}),label:Un(t),name:`Length`,onChange:n,options:Gg(e).map(e=>({value:e,label:Un(e)})),value:t})}var qg=null;function Jg(e,t){let n=(0,q.useRef)(null),r=(0,q.useRef)(t);r.current=t;let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(0);(0,q.useEffect)(()=>()=>{let e=n.current;e!==null&&(e.pause(),qg===e&&(qg=null),n.current=null)},[e]),(0,q.useEffect)(()=>{if(!i)return;let e=0,t=()=>{let r=n.current;r!==null&&r.duration>0&&s(Math.min(1,r.currentTime/r.duration)),e=requestAnimationFrame(t)};return e=requestAnimationFrame(t),()=>{cancelAnimationFrame(e)}},[i]);let c=(0,q.useCallback)(()=>{if(n.current!==null)return n.current;let t=new Audio(e);return t.preload=`auto`,t.addEventListener(`ended`,()=>{a(!1),s(0),qg===t&&(qg=null)}),t.addEventListener(`pause`,()=>{a(!1)}),t.addEventListener(`error`,()=>{a(!1),r.current(`This audio could not be played.`)}),n.current=t,t},[e]);return{playing:i,progress:o,toggle:(0,q.useCallback)(()=>{let e=c();if(!e.paused){e.pause();return}qg!==null&&qg!==e&&qg.pause(),qg=e,a(!0),e.play().catch(e=>{dn(`play-audio`,e),a(!1),r.current(`This audio could not be played.`)})},[c]),seek:(0,q.useCallback)(e=>{let t=c();Number.isFinite(t.duration)&&t.duration>0&&(t.currentTime=Math.min(1,Math.max(0,e))*t.duration,s(Math.min(1,Math.max(0,e))))},[c])}}function Yg({url:e,progress:t=0,bars:n=64,className:r}){let i=Dr(e,n),a=i.status===`ready`?i.peaks:null;return(0,J.jsx)(`span`,{"aria-hidden":`true`,className:B(`prints-waveform`,r),"data-waveform":i.status,children:Array.from({length:n},(e,r)=>(0,J.jsx)(`span`,{className:`prints-waveform-bar`,"data-played":r/n<t?``:void 0,style:{height:`max(2px, ${String((a?.[r]??0)*100)}%)`}},r))})}function Xg({facts:e}){let t=Jg(e.url,it),n=Dr(e.url,96),r=e.durationSeconds??(n.status===`ready`?n.durationSeconds:void 0),i=e.mode===void 0?`Audio`:Pg[e.mode],a=t.progress*(r??0);return(0,J.jsxs)(`section`,{"aria-label":`${i} print`,className:`prints-audio-stage`,"data-audio-stage":!0,children:[(0,J.jsx)(Dg,{size:`sm`,variant:`quiet`,children:i}),(0,J.jsx)(`button`,{"aria-label":`Seek`,className:`prints-audio-stage-seek`,type:`button`,onClick:e=>{let n=e.currentTarget.getBoundingClientRect();t.seek((e.clientX-n.left)/n.width)},children:(0,J.jsx)(Yg,{bars:96,className:`prints-audio-stage-waveform`,progress:t.progress,url:e.url})}),(0,J.jsxs)(`div`,{className:`prints-audio-stage-controls`,children:[(0,J.jsx)(ht,{"aria-label":t.playing?`Pause`:`Play`,icon:t.playing?(0,J.jsx)(_h,{}):(0,J.jsx)(yh,{}),iconSize:`md`,size:`default`,variant:`accent`,onClick:t.toggle}),(0,J.jsxs)(`span`,{className:`prints-audio-stage-time`,children:[Un(a,`elapsed`),r===void 0?null:` / ${Un(r)}`]})]})]})}var Zg=(0,q.lazy)(async()=>({default:(await ji(()=>import(`./print-download-button-CW13fNbe.js`),__vite__mapDeps([0,1,2,3,4]),import.meta.url)).PrintDownloadButton}));function Qg({url:e,path:t,onError:n,autoPlay:r}){let i=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let t=i.current;if(!t)return;let a=!1;return r&&t.play().catch(t=>{a||t instanceof DOMException&&(t.name===`NotAllowedError`||t.name===`AbortError`)||(dn(`play-print-video`,t),n(e))}),()=>{a=!0,t.pause()}},[e,n,r]),(0,J.jsx)(`video`,{ref:i,src:e,"aria-label":t,controls:!0,playsInline:!0,preload:`auto`,className:`block max-h-full max-w-full object-contain`,onError:()=>{n(e)}})}function $g({item:e,actualSize:t}){let[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(null),o=e.pending===!0&&!e.onVisible,[s,c]=(0,q.useState)(o);o&&!s&&c(!0);let l=e.pendingLabel??`Loading print…`,u=o?`Not saved`:`Prints can’t show this file`,d=(0,J.jsx)(`img`,{src:e.url,alt:e.path,decoding:`async`,width:t?e.width:void 0,height:t?e.height:void 0,className:t?`block max-w-none`:`block max-h-full max-w-full object-contain`,onLoad:()=>{r(e.url)},onError:()=>{a(e.url)}},e.url);return(0,J.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 items-center justify-center overflow-hidden`,"data-print-viewer-stage":!0,children:e.error||i===e.url?(0,J.jsx)(rm,{status:`failed`,className:`h-full w-full`,failure:(0,J.jsxs)(`div`,{className:`flex max-w-full flex-col items-center gap-sm px-md text-center`,children:[(0,J.jsx)(`p`,{className:`max-w-full break-words text-sm`,children:e.path}),(0,J.jsx)(tm,{density:`tile`,message:e.error?`${u}: ${e.error}`:u,onRetry:e.onRetry,onDismiss:e.onDismiss})]})}):mn(e.path)&&e.url?(0,J.jsx)(Xg,{facts:{url:e.url}}):Ua(e.path)&&e.url?(0,J.jsx)(Qg,{url:e.url,path:e.path,onError:a,autoPlay:!s}):e.url?(0,J.jsxs)(J.Fragment,{children:[t?(0,J.jsx)($m,{className:`h-full w-full`,role:`region`,"aria-label":`Actual-size print`,tabIndex:0,"data-print-viewer-scroll":!0,children:d}):d,n===e.url?null:(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,J.jsx)(yn,{label:`Loading print`,variant:`bloom`})})]}):(0,J.jsx)(rm,{status:`generating`,label:l,className:`h-full w-full`,indicator:(0,J.jsxs)(`div`,{"aria-hidden":`true`,className:`flex max-w-full flex-col items-center gap-sm px-md text-center`,children:[(0,J.jsx)(yn,{decorative:!0,variant:`bloom`}),(0,J.jsx)(`p`,{className:`text-sm`,children:l})]})})})}var e_=`(max-width: 640px)`;function t_(){return(0,q.useSyncExternalStore)(e=>{let t=globalThis.matchMedia(e_);return t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)}},()=>globalThis.matchMedia(e_).matches,()=>!1)}function n_(e){let[t,n]=(0,q.useState)(!1),[r,i]=(0,q.useState)(!1);return{pending:t,failed:r,open:()=>{e&&(n(!0),i(!1),bg(e).catch(e=>{dn(`open-print-in-inkcap`,e),i(!0)}).finally(()=>{n(!1)}))}}}function r_({source:e}){return(0,J.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Could not open `,e.path,` in Inkcap.`]})}function i_({source:e,app:t,inkcap:n,phone:r}){let i=e.kind===`computer`&&n?e:null,a=n_(i);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(Zg,{source:e,app:t,presentation:r?`menu`:`key`,menuItems:i?(0,J.jsx)(qa,{disabled:a.pending,onSelect:a.open,children:`Open in Inkcap`}):void 0})}),i&&!r?(0,J.jsx)(bt,{label:`Open in Inkcap`,icon:(0,J.jsx)(ah,{}),disabled:a.pending,onClick:a.open}):null,i&&a.failed?(0,J.jsx)(r_,{source:i}):null]})}function a_({items:e,images:t,viewerKey:n,app:r,onNavigate:i,onClose:a,renderInfo:o}){let s=(0,q.useRef)(null),c=xg(r),l=t_(),u=Cg(e),d=(0,q.useRef)(u),f=n===null?null:Tg(u,n,d.current);(0,q.useEffect)(()=>{d.current=u,n!==null&&f!==n&&(f===null?a(n):i(f))},[u,f,n,a,i]),(0,q.useEffect)(()=>{if(f===null)return;let t=e.findIndex(e=>e.key===f);for(let n of e.slice(Math.max(0,t-1),t+2))n.onVisible?.()},[e,f]);let[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(null);(0,q.useEffect)(()=>{g(null)},[f]),(0,q.useEffect)(()=>{m(null)},[n]);let _=e.find(e=>e.key===f),v=t.find(e=>yg(e)===f);if(!_||f===null)return null;let y=wg(u,f,-1),b=wg(u,f,1),x=_.path.split(`/`).at(-1)??_.path,S=()=>{a(f)},C=e=>{e!==null&&i(e)};return(0,J.jsx)(Fp,{open:!0,onOpenChange:e=>{e||S()},children:(0,J.jsxs)(Lp,{children:[(0,J.jsx)(Rp,{}),(0,J.jsxs)(zp,{ref:s,size:`fill`,initialFocus:s,finalFocus:!1,className:`flex min-h-0 flex-col gap-sm`,onKeyDown:e=>{e.altKey||e.ctrlKey||e.metaKey||e.target instanceof HTMLElement&&e.target.closest(`input, textarea, select, video, [data-print-viewer-scroll], [contenteditable=true]`)||(e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),C(e.key===`ArrowLeft`?y:b)):e.key.toLowerCase()===`i`&&v&&(e.preventDefault(),m(p===f?null:f)))},children:[(0,J.jsx)(dr,{className:`prints-viewer-frame`,children:(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,J.jsxs)(`div`,{className:`prints-viewer-caption`,"data-print-viewer-caption":!0,children:[(0,J.jsx)(Up,{className:`prints-viewer-caption-name truncate text-xs font-normal`,children:x}),(0,J.jsxs)(`span`,{className:`prints-viewer-caption-position`,"aria-live":`polite`,"aria-atomic":`true`,children:[(0,J.jsxs)(`span`,{className:`sr-only`,children:[x,`, `]}),u.indexOf(f)+1,` of `,u.length]})]}),(0,J.jsxs)(`div`,{className:`@container relative flex min-h-0 min-w-0 flex-1`,children:[(0,J.jsx)($g,{item:_,actualSize:h===f},f),p===f&&v?o(v,()=>{m(null)}):null]})]})}),(0,J.jsxs)(`div`,{className:`prints-viewer-actions`,children:[(0,J.jsx)(ht,{size:`default`,iconSize:`md`,"aria-label":`Previous print`,title:`Previous print (Left arrow)`,"aria-keyshortcuts":`ArrowLeft`,icon:(0,J.jsx)(eh,{}),disabled:y===null,onClick:()=>{C(y)}}),(0,J.jsx)(ht,{size:`default`,iconSize:`md`,"aria-label":`Next print`,title:`Next print (Right arrow)`,"aria-keyshortcuts":`ArrowRight`,icon:(0,J.jsx)(th,{}),disabled:b===null,onClick:()=>{C(b)}}),(0,J.jsx)(ht,{size:`default`,iconSize:`md`,"aria-label":`Image info`,title:`Image info (I)`,"aria-keyshortcuts":`i`,"aria-expanded":p===f,icon:(0,J.jsx)(fh,{}),disabled:!v,onClick:()=>{m(p===f?null:f)}}),!Ua(_.path)&&!mn(_.path)?(0,J.jsx)(ht,{size:`default`,iconSize:`md`,"aria-label":`Actual size`,title:`Actual size`,"aria-pressed":h===f,active:h===f,icon:(0,J.jsx)(mh,{}),disabled:!_.url||!!_.error,onClick:()=>{g(h===f?null:f)}}):null,v?(0,J.jsx)(i_,{source:v.source,app:r,inkcap:c,phone:l},`${f}\n${v.url}`):null,(0,J.jsx)(ht,{size:`default`,iconSize:`md`,"aria-label":`Close viewer`,title:`Close viewer (Escape)`,icon:(0,J.jsx)(Hr,{}),onClick:S})]})]})]})})}var o_=e=>b.pipe(R(F(1)),R(D(e))),s_=wn.pipe(R(Ne()),R(P(Number.isSafeInteger,{message:`Expected a safe integer`}))),c_=s_.pipe(R(A(0))),l_=s_.pipe(R(Oe(0))),u_=g({bytes:c_,costMilliunits:l_,destination:g({computerId:o_(256),path:o_(4096)}),format:Ze([`png`,`jpeg`,`gif`,`webp`,`mp4`,`mp3`]),height:Re(c_),model:o_(256),width:Re(c_)}),d_=g({operation:Mn(`complete-generation`),reference:Ke,result:u_,derivedFrom:Re(o_(256)),references:Re(St(p(o_(256))))}),f_=g({prompt:On,references:bn.pipe(R(Oe(0)))}),p_=g({reason:Ze([...$t,`UNKNOWN`]),message:On.pipe(R(D(512)))}),m_=g({reference:Ke,input:wt,typed:f_,style:Re(nr),characters:Re(St(oi)),failure:Re(p_)});At([g({operation:Mn(`remember-generation`),record:m_}),g({operation:Mn(`fail-generation`),reference:Ke,failure:p_}),g({operation:Mn(`forget-generation`),reference:Ke}),g({operation:Mn(`list-generations`),after:p(b)})]);function h_(e){return{reference:e.reference,input:et(e.input),typed:e.typed,style:e.style,characters:e.characters,failure:e.failure}}async function g_(e,t){let n=h_(I(m_,{onExcessProperty:`error`})(t)),r=h_(I(m_,{onExcessProperty:`error`})(await e.require(_r).request(JSON.stringify({operation:`remember-generation`,record:n}))));if(JSON.stringify(r)!==JSON.stringify(n))throw new G(`Prints did not confirm the original generation command`,{code:`PROTOCOL`,retryable:!1});return r}async function __(e,t,n){I(m_,{onExcessProperty:`error`})(await e.require(_r).request(JSON.stringify({operation:`fail-generation`,reference:t,failure:n})))}async function v_(e,t){I(g({removed:_t}))(await e.require(_r).request(JSON.stringify({operation:`forget-generation`,reference:t})))}async function y_(e,t=null){let n=I(g({records:St(m_),next:p(b)}),{onExcessProperty:`error`})(await e.require(_r).request(JSON.stringify({operation:`list-generations`,after:t})));return{records:n.records.map(h_),next:n.next}}async function b_(e,t,n){let r=I(d_,{onExcessProperty:`error`})({operation:`complete-generation`,reference:t,result:n}),i=I(g({printId:b,computerId:b}))(await e.require(_r).request(JSON.stringify(r)));if(i.printId!==t.requestId||i.computerId!==t.computerId)throw new G(`Prints did not confirm the saved generation`,{code:`PROTOCOL`,retryable:!1})}var x_=w(g({reference:Ke}));function S_({connection:e,folder:t,effects:n,styles:r,characters:i}){let a=e?.app??null,o=yf(a),s=(0,q.useRef)(e);s.current=e;let c=(0,q.useRef)(n);c.current=n;let l=gn(),u=Mi.of(a,`prints`,`generation`),d=[...u,`recovery`],f=Or(_i(a)),p=f.isError?void 0:f.data,m=p?.models??[],h=a?.capabilities.has(rn)===!0,g=p?.canGenerate??!1,_=f.error?Ht(f.error).message:p?.models.length===0?`The granted Media model registry is empty.`:null,v=Es({queryKey:d,enabled:a!==null&&o!==null,initialPageParam:null,queryFn:async({pageParam:e,signal:t})=>{if(!a)throw new G(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0});if(a.context.get().computerId!==o)throw new G(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1});let n=await y_(a.capabilities,e);return t.throwIfAborted(),n},getNextPageParam:e=>e.next}),y=(0,q.useMemo)(()=>Array.from(new Map(v.data?.pages.flatMap(e=>e.records).map(e=>[e.reference.requestId,e])??[]).values()),[v.data]),b=(0,q.useRef)(new Map),x=(0,q.useRef)(new Set),S=(0,q.useRef)(0),C=(0,q.useRef)(null),[w,T]=(0,q.useState)(null),[E,D]=(0,q.useState)(null),O=e=>{T(e),c.current.notifyFailure(e.message)},k=e=>{D(e),c.current.notifyFailure(e)},A=(0,q.useRef)(null);(0,q.useEffect)(()=>{A.current!==v.error&&(A.current=v.error,v.error&&c.current.notifyFailure(Ht(v.error).message))},[v.error]);let j=e=>s.current===e.connection&&e.connection.app.context.get().computerId===e.reference.computerId,M=(e,t,n)=>{l.setQueryData(e,e=>e&&{...e,pages:e.pages.map(e=>({...e,records:e.records.map(e=>e.reference.requestId===t?{...e,failure:n}:e)}))})},ee=(e,t)=>{l.setQueryData(e,e=>e&&{...e,pages:e.pages.map(e=>({...e,records:e.records.filter(e=>e.reference.requestId!==t)}))})},N=ce({mutationKey:[...u,`run`],mutationFn:async e=>{e.controller.signal.throwIfAborted();let t=h_({reference:e.reference,input:e.input,typed:e.typed,style:e.style,characters:e.characters});await g_(e.connection.app.capabilities,t),M(e.recoveryKey,e.reference.requestId,void 0),e.controller.signal.throwIfAborted();let n=await e.session.restoreAttempt(e.reference),r;try{r=await n.generate(t.input,{signal:e.controller.signal})}finally{n[Symbol.dispose]()}return await b_(e.connection.app.capabilities,t.reference,r),{input:e.input,result:r}},onMutate:e=>{if(!j(e)||e.controller.signal.aborted)return;let t=Br(e.session.models,e.input.settings.model),n={key:`${e.reference.computerId}:${e.input.destination.path}`,computerId:e.reference.computerId,path:e.input.destination.path,...wi(t,e.draft),pendingLabel:ci(t)};t?.kind===`video`&&(n.startedAt=Date.now(),n.resumed=e.resumed===!0),c.current.reserve(n)},onSuccess:(e,t)=>{ee(t.recoveryKey,t.reference.requestId),C.current?.reference.requestId===t.reference.requestId&&(C.current=null),!(!j(t)||t.controller.signal.aborted)&&c.current.saved(e,t.connection)},onError:(e,n)=>{if(dn(`generate-media`,e),n.controller.signal.aborted)return;let r=qr(e);__(n.connection.app.capabilities,n.reference,r).catch(e=>{dn(`fail-generation`,e)}),j(n)&&(M(n.recoveryKey,n.reference.requestId,r),t.recheck(),c.current.failed(`${n.reference.computerId}:${n.input.destination.path}`,r.message))},onSettled:(e,t,n)=>{b.current.get(n.reference.requestId)===n.controller&&b.current.delete(n.reference.requestId)}}),P=ce({mutationKey:[...u,`discard`],mutationFn:async e=>{await v_(e.connection.app.capabilities,e.reference)},onSuccess:(e,t)=>{ee(t.recoveryKey,t.reference.requestId),C.current?.reference.requestId===t.reference.requestId&&(C.current=null)},onError:(e,t)=>{j(t)&&k(Ht(e).message)},onSettled:(e,t,n)=>{b.current.get(n.reference.requestId)===n.controller&&b.current.delete(n.reference.requestId)}}),te=Ts({filters:{mutationKey:u,status:`pending`},select:e=>We(x_(e.state.variables))?.reference.requestId}),ne=new Set(te.filter(e=>e!==void 0));(0,q.useEffect)(()=>{x.current.clear(),T(null),D(null),C.current=null;let e=Mi.of(a,`prints`,`generation`,`recovery`),t=a?.capabilities.subscribe(()=>{queueMicrotask(()=>{l.resetQueries({queryKey:e,exact:!0})})}),n=()=>{S.current+=1;for(let e of b.current.values())e.abort();b.current.clear(),l.cancelQueries({queryKey:e})},r=a?.context.subscribe(e=>{e.computerId!==o&&n()}),i=a?.lifecycle.subscribe(e=>{(e===`disposing`||e===`disposed`||e===`disconnected`)&&n()});return()=>{r?.(),i?.(),t?.(),n()}},[a,o,e,l]);let F=e=>{let t=e.reference.requestId;if(b.current.has(t))return!1;if(!j(e))return k(`Select the original Computer to retry this generation.`),!1;if(p?.computerId!==e.reference.computerId)return k(`Media access is unavailable for the original Computer.`),!1;let n=new AbortController;return b.current.set(t,n),C.current=e,T(null),D(null),S.current+=1,N.mutate({...e,session:p,controller:n,ticket:S.current,recoveryKey:d}),!0};(0,q.useEffect)(()=>{if(!(!e||!p||!v.isSuccess))for(let t of y){let n=t.reference.requestId;x.current.has(n)||t.reference.computerId!==o||Br(p.models,t.input.settings.model)?.kind!==`video`||F({connection:e,...t,resumed:!0,draft:Fr(t.input)})&&x.current.add(n)}},[e,o,p,v.isSuccess,y]);let re=async(n,a=n.references.map((e,t)=>t+1))=>{if(!e?.app.capabilities.has(ya)||!g)return!1;if(t.path===null)return t.setEditing(!0),!1;C.current=null;let c=Br(m,n.model);if(c===void 0)return O({kind:`error`,mediaKind:null,message:`Choose a model from the granted registry.`}),!1;let l=wr(n.prompt).length>0,u=c.kind===`audio`?ki(n.prompt):Vr({prompt:n.prompt,saved:i,references:n.references,labels:a,wording:e=>ri(Yr(e,c,l),c),computerId:o,model:{label:c.label,maxReferences:c.input.maxReferences}});if(u.kind===`refused`)return O({kind:`error`,mediaKind:c.kind,message:u.message}),!1;let d=Rr({...n,references:Yr(u.references,c,l)},c);if(d)return O({kind:`error`,mediaKind:c.kind,message:d}),!1;let f=c.kind===`audio`?void 0:n.style,_=f===void 0?void 0:r.find(e=>e.name===f);if(f!==void 0&&_===void 0)return O({kind:`error`,mediaKind:c.kind,message:`The "${f}" style no longer exists. Pick another or none.`}),!1;let v=u.characters.map(e=>e.name),y=ti(_?.text,u.prompt),b=fr(y,gr(c),_?.name,v);if(b!==void 0)return O({kind:`error`,mediaKind:c.kind,message:b}),!1;if(!h||!p)return T(null),!1;let x=e,w=x.app.context.get().computerId,E=S.current,D={...n,prompt:y,references:Yr(u.references,c,l),destination:zn(n,t.landingPath??t.path,c)},k=bi(D,c),A;try{let e=await t.ensureCreated();if(e)return O({kind:`error`,mediaKind:c.kind,message:e}),!1;if(S.current!==E||s.current!==x||x.app.context.get().computerId!==w)return!1;let n=await p.createAttempt();A=n.reference,n[Symbol.dispose]()}catch(e){return S.current===E&&s.current===x&&x.app.context.get().computerId===w&&O({kind:`error`,mediaKind:c.kind,...Nr(e)}),!1}return S.current!==E||s.current!==x||x.app.context.get().computerId!==w?!1:F({connection:x,reference:A,input:k,draft:D,typed:{prompt:Vn(n.prompt.trim(),e=>{let t=a.indexOf(e);return t<0?void 0:t+1}),references:n.references.length},style:_?.name,characters:v})},ie=N.variables;return{state:w??(ie&&j(ie)&&ie.ticket===S.current?N.isPending?{kind:`pending`,draft:ie.draft}:N.isError?{kind:`error`,mediaKind:Br(ie.session.models,ie.input.settings.model)?.kind??null,...Nr(N.error)}:{kind:`completed`,record:N.data}:null)??(!e||!h||o===null?{kind:`unavailable`,reason:`Image creation is unavailable for this Computer right now.`}:_?{kind:`unavailable`,reason:_}:p?{kind:`ready`}:{kind:`loading`}),models:m,session:p,modelsLoading:f.isFetching,modelsError:_,canGenerate:g,mediaCapability:h,retryModels:()=>{f.refetch()},submit:re,isRunning:()=>b.current.size>0,activeGenerations:ne,pendingGenerations:y,recoveryError:E??(v.error?Ht(v.error).message:null),reportRecoveryError:e=>{k(Ht(e).message)},hasMore:v.hasNextPage,loadMore:()=>{v.isFetching||v.fetchNextPage()},resume:t=>{if(!e||p?.computerId!==t.reference.computerId){k(`Select the original Computer to retry this generation.`);return}F({connection:e,...t,draft:Fr(t.input)})},discard:t=>{if(!e||b.current.has(t.reference.requestId))return;let n=new AbortController;b.current.set(t.reference.requestId,n),P.mutate({...t,connection:e,controller:n,draft:Fr(t.input),recoveryKey:d})},retryPath:e=>{let t=C.current;return t?.input.destination.path!==e||!j(t)?!1:(F(t),!0)},retry:C.current&&j(C.current)?()=>{C.current&&F(C.current)}:void 0,failedPrompt:C.current?.typed.prompt,dismissFailed:()=>{let e=C.current;if(!e||b.current.has(e.reference.requestId)){N.reset();return}C.current=null,N.reset();let t=new AbortController;b.current.set(e.reference.requestId,t),P.mutate({...e,controller:t,recoveryKey:d})},errorKey:`generation:${C.current?.reference.requestId??`draft`}:${String(S.current)}`}}function C_({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function w_(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var T_=[],E_=0,{link:D_,unlink:O_,propagate:k_,checkDirty:A_,shallowPropagate:j_}=C_({update(e){return e._update()},notify(e){T_[N_++]=e,e.flags&=-3},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,L_(e))}}),M_=0,N_=0,P_,F_=0;function I_(e){try{++F_,e()}finally{--F_||R_()}}function L_(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=O_(n,e)}function R_(){if(!(F_>0)){for(;M_<N_;){let e=T_[M_];T_[M_++]=void 0,e.notify()}M_=0,N_=0}}function z_(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:+!n,get(){return P_!==void 0&&D_(i,P_,E_),i._snapshot},subscribe(e){let t=w_(e),n={current:!1},r=B_(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=P_,o=t?.compare??Object.is;if(n)P_=i,++E_,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=5);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{P_=a,n&&(i.flags&=-5),L_(i)}}};return n?(i.flags=17,i.get=function(){let e=i.flags;if(e&16||e&32&&A_(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&j_(e)}}else e&32&&(i.flags=e&-33);return P_!==void 0&&D_(i,P_,E_),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(k_(e),j_(e),R_())}},i}function B_(e){let t=()=>{let t=P_;P_=n,++E_,n.depsTail=void 0,n.flags=6;try{return e()}finally{P_=t,n.flags&=-5,L_(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let e=this.flags;e&16||e&32&&A_(this.deps,this)?t():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,L_(this)}};return t(),n}var V_=class{constructor(e,t){this.atom=z_(e),this.get=this.get.bind(this),this.setState=this.setState.bind(this),this.subscribe=this.subscribe.bind(this),t&&(this.actions=t(this))}setState(e){this.atom.set(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(w_(e))}},H_=class{constructor(e){this.atom=z_(e)}get state(){return this.atom.get()}get(){return this.state}subscribe(e){return this.atom.subscribe(w_(e))}};function U_(e,t){return typeof e==`function`?new H_(e):t?new V_(e,t):new V_(e)}var W_=class{constructor(e,t){this.fn=e,this.options=t,this.lastExecutionTime=0,this.isPending=!1,this.maybeExecute=(...e)=>{let t=Date.now()-this.lastExecutionTime;if(this.options.leading&&t>=this.options.wait)this.execute(...e);else if(this.lastArgs=e,!this.timeoutId&&this.options.trailing){let e=this.options.wait-t;this.isPending=!0,this.timeoutId=setTimeout(()=>{this.lastArgs!==void 0&&this.execute(...this.lastArgs)},e)}},this.execute=(...e)=>{this.fn(...e),this.options.onExecute?.(e,this),this.lastExecutionTime=Date.now(),this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.flush=()=>{this.isPending&&this.lastArgs&&this.execute(...this.lastArgs)},this.cancel=()=>{this.clearTimeout(),this.lastArgs=void 0,this.isPending=!1},this.clearTimeout=()=>{this.timeoutId&&=(clearTimeout(this.timeoutId),void 0)},this.options.leading===void 0&&this.options.trailing===void 0&&(this.options.leading=!0,this.options.trailing=!0)}};function G_(e,t){return new W_(e,t).maybeExecute}var K_=class{#e=!0;#t;#n;#r;#i;#a;#o;#s;#c=0;#l=5;#u=!1;#d=!1;#f=null;#p=()=>{this.debugLog(`Connected to event bus`),this.#a=!0,this.#u=!1,this.debugLog(`Emitting queued events`,this.#i),this.#i.forEach(e=>this.emitEventToBus(e)),this.#i=[],this.stopConnectLoop(),this.#n().removeEventListener(`tanstack-connect-success`,this.#p)};#m=()=>{if(this.#c<this.#l){this.#c++,this.dispatchCustomEvent(`tanstack-connect`,{});return}this.#n().removeEventListener(`tanstack-connect`,this.#m),this.#d=!0,this.debugLog(`Max retries reached, giving up on connection`),this.stopConnectLoop()};#h=()=>{this.#u||(this.#u=!0,this.#n().addEventListener(`tanstack-connect-success`,this.#p),this.#m())};constructor({pluginId:e,debug:t=!1,enabled:n=!0,reconnectEveryMs:r=300}){this.#t=e,this.#e=n,this.#n=this.getGlobalTarget,this.#r=t,this.debugLog(` Initializing event subscription for plugin`,this.#t),this.#i=[],this.#a=!1,this.#d=!1,this.#o=null,this.#s=r}startConnectLoop(){this.#o!==null||this.#a||(this.debugLog(`Starting connect loop (every ${this.#s}ms)`),this.#o=setInterval(this.#m,this.#s))}stopConnectLoop(){this.#u=!1,this.#o!==null&&(clearInterval(this.#o),this.#o=null,this.#i=[],this.debugLog(`Stopped connect loop`))}debugLog(...e){this.#r&&console.log(`🌴 [tanstack-devtools:${this.#t}-plugin]`,...e)}getGlobalTarget(){if(typeof globalThis<`u`&&globalThis.__TANSTACK_EVENT_TARGET__)return this.debugLog(`Using global event target`),globalThis.__TANSTACK_EVENT_TARGET__;if(typeof window<`u`&&window.addEventListener!==void 0)return this.debugLog(`Using window as event target`),window;let e=typeof EventTarget<`u`?new EventTarget:void 0;return e===void 0||e.addEventListener===void 0?(this.debugLog(`No event mechanism available, running in non-web environment`),{addEventListener:()=>{},removeEventListener:()=>{},dispatchEvent:()=>!1}):(this.debugLog(`Using new EventTarget as fallback`),e)}getPluginId(){return this.#t}dispatchCustomEventShim(e,t){try{let n=new Event(e,{detail:t});this.#n().dispatchEvent(n)}catch{this.debugLog(`Failed to dispatch shim event`)}}dispatchCustomEvent(e,t){try{this.#n().dispatchEvent(new CustomEvent(e,{detail:t}))}catch{this.dispatchCustomEventShim(e,t)}}emitEventToBus(e){this.debugLog(`Emitting event to client bus`,e),this.dispatchCustomEvent(`tanstack-dispatch-event`,e)}createEventPayload(e,t){return{type:`${this.#t}:${e}`,payload:t,pluginId:this.#t}}emit(e,t){if(!this.#e){this.debugLog(`Event bus client is disabled, not emitting event`,e,t);return}if(this.#f&&(this.debugLog(`Emitting event to internal event target`,e,t),this.#f.dispatchEvent(new CustomEvent(`${this.#t}:${e}`,{detail:this.createEventPayload(e,t)}))),this.#d){this.debugLog(`Previously failed to connect, not emitting to bus`);return}if(!this.#a){this.debugLog(`Bus not available, will be pushed as soon as connected`),this.#i.push(this.createEventPayload(e,t)),typeof CustomEvent<`u`&&!this.#u&&(this.#h(),this.startConnectLoop());return}return this.emitEventToBus(this.createEventPayload(e,t))}on(e,t,n){let r=n?.withEventTarget??!1,i=`${this.#t}:${e}`;if(r&&(this.#f||=new EventTarget,this.#f.addEventListener(i,e=>{t(e.detail)})),!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`,i),()=>{};let a=e=>{this.debugLog(`Received event from bus`,e.detail),t(e.detail)};return this.#n().addEventListener(i,a),this.debugLog(`Registered event to bus`,i),()=>{r&&this.#f?.removeEventListener(i,a),this.#n().removeEventListener(i,a)}}onAll(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}onAllPluginEvents(e){if(!this.#e)return this.debugLog(`Event bus client is disabled, not registering event`),()=>{};let t=t=>{let n=t.detail;this.#t&&n.pluginId!==this.#t||e(n)};return this.#n().addEventListener(`tanstack-devtools-global`,t),()=>this.#n().removeEventListener(`tanstack-devtools-global`,t)}},q_=new class extends K_{constructor(){super({pluginId:`form-devtools`,reconnectEveryMs:1e3})}};function J_(e,t){return typeof e==`function`?e(t):e}function Y_(e,t){return rv(t).reduce((e,t)=>{if(e===null)return null;if(e!==void 0)return e[t]},e)}function X_(e,t,n){let r=rv(t);function i(e){if(!r.length)return J_(n,e);let t=r.shift();if(typeof t==`string`||typeof t==`number`&&!Array.isArray(e))return typeof e==`object`?(e===null&&(e={}),{...e,[t]:i(e[t])}):{[t]:i()};if(Array.isArray(e)&&typeof t==`number`){let n=e.slice(0,t);return[...n.length?n:Array(t),i(e[t]),...e.slice(t+1)]}return[...Array(t),i()]}return i(e)}function Z_(e,t){let n=rv(t);function r(e){if(!e)return;if(n.length===1){let t=n[0];if(Array.isArray(e)&&typeof t==`number`)return e.filter((e,n)=>n!==t);let{[t]:r,...i}=e;return i}let t=n.shift();if((typeof t==`string`||typeof t==`number`&&!Array.isArray(e))&&typeof e==`object`)return{...e,[t]:r(e[t])};if(typeof t==`number`&&Array.isArray(e)){if(t>=e.length)return e;let n=e.slice(0,t);return[...n.length?n:Array(t),r(e[t]),...e.slice(t+1)]}throw Error(`It seems we have created an infinite loop in deleteBy. `)}return r(e)}var Q_=46,$_=91,ev=93,tv=48,nv=57;function rv(e){if(Array.isArray(e))return[...e];if(typeof e!=`string`)throw Error(`Path must be a string.`);let t=e.length,n=[],r=+(t>0&&e.charCodeAt(0)===$_),i=!0,a=-1;for(let o=r;o<=t;o++){let s=o<t?e.charCodeAt(o):-1;if(o===t||s===Q_||s===$_||s===ev){let t=o-r;if(t>0){let a=i&&(t===1||e.charCodeAt(r)!==tv),s=e.slice(r,o);if(a){let e=parseInt(s,10);t<=15||String(e)===s?n.push(e):n.push(s)}else n.push(s)}else a!==ev&&(a!==-1||s!==ev)&&(a!==s||s!==Q_&&s!==$_)&&n.push(``);r=o+1,i=!0}else(s<tv||s>nv)&&(i=!1);a=s}return n.length||n.push(``),n}function iv(e){return!(Array.isArray(e)&&e.length===0)}function av(e,t){return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!1},runValidation:e=>e.validators.filter(Boolean).map(e=>({cause:e.cause,validate:e.fn}))})}function ov(e,t){let{asyncDebounceMs:n}=t,{onBlurAsyncDebounceMs:r,onChangeAsyncDebounceMs:i,onDynamicAsyncDebounceMs:a}=t.validators||{},o=n??0;return t.validationLogic({form:t.form,group:t.group,validators:t.validators,event:{type:e,fieldName:t.fieldName,async:!0},runValidation:t=>t.validators.filter(Boolean).map(t=>{let n=t?.cause||e,s=o;switch(n){case`change`:s=i??o;break;case`blur`:s=r??o;break;case`dynamic`:s=a??o;break;case`submit`:s=0}return e===`submit`&&(s=0),{cause:n,validate:t.fn,debounceMs:s}})})}var sv=e=>!!e&&typeof e==`object`&&`fields`in e;function cv(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!t.has(n)||!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length||n.length===0&&!Array.isArray(e)&&!Array.isArray(t)&&(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype))return!1;for(let i of n)if(!r.includes(i)||!cv(e[i],t[i]))return!1;return!0}var lv=({newFormValidatorError:e,isPreviousErrorFromFormValidator:t,previousErrorValue:n})=>e?{newErrorValue:e,newSource:`form`}:t?{newErrorValue:void 0,newSource:void 0}:n?{newErrorValue:n,newSource:`field`}:{newErrorValue:void 0,newSource:void 0},uv=({formLevelError:e,fieldLevelError:t})=>t?{newErrorValue:t,newSource:`field`}:e?{newErrorValue:e,newSource:`form`}:{newErrorValue:void 0,newSource:void 0};function dv(e,t){return e==null?t:{...e,...t}}for(var fv=256,pv=[],mv;fv--;)pv[fv]=(fv+256).toString(16).substring(1);function hv(){let e=0,t,n=``;if(!mv||fv+16>256){for(mv=Array(256),e=256;e--;)mv[e]=256*Math.random()|0;e=0,fv=0}for(;e<16;e++)t=mv[fv+e],n+=e===6?pv[t&15|64]:e===8?pv[t&63|128]:pv[t],e&1&&e>1&&e<11&&(n+=`-`);return fv++,n}var gv=G_(e=>q_.emit(`form-state`,{id:e.formId,state:e.store.state}),{wait:300});function _v(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++)t[n]=_v(e[n]);return t}if(e instanceof Map){let t=new Map;return e.forEach((e,n)=>{t.set(n,_v(e))}),t}if(e instanceof Set){let t=new Set;return e.forEach(e=>{t.add(_v(e))}),t}let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=_v(e[n]));return t}function vv(e,t){return t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}[`)}var yv=e=>{if(!e.validators)return e.runValidation({validators:[],form:e.form});let t=e.event.async,n=t?void 0:{fn:e.validators.onMount,cause:`mount`},r={fn:t?e.validators.onChangeAsync:e.validators.onChange,cause:`change`},i={fn:t?e.validators.onBlurAsync:e.validators.onBlur,cause:`blur`},a={fn:t?e.validators.onSubmitAsync:e.validators.onSubmit,cause:`submit`},o=t?void 0:{fn:()=>void 0,cause:`server`};switch(e.event.type){case`mount`:return e.runValidation({validators:[n],form:e.form});case`submit`:return e.runValidation({validators:[r,i,a,o],form:e.form});case`server`:return e.runValidation({validators:[],form:e.form});case`blur`:return e.runValidation({validators:[i,o],form:e.form});case`change`:return e.runValidation({validators:[r,o],form:e.form});default:throw Error(`Unknown validation event type: ${e.event.type}`)}};function bv(e,t){let n=new Map;for(let r of e){let e=r.path??[],i=t,a=``;for(let t=0;t<e.length;t++){let n=e[t];if(n===void 0)continue;let r=typeof n==`object`?n.key:n,o=Number(r);a+=Array.isArray(i)&&!Number.isNaN(o)?`[${o}]`:(t>0?`.`:``)+String(r),i=typeof i==`object`&&i?i[r]:void 0}n.set(a,(n.get(a)??[]).concat(r))}return Object.fromEntries(n)}var xv=(e,t)=>{let n=bv(e,t);return{form:n,fields:n}},Sv={validate({value:e,validationSource:t},n){let r=n[`~standard`].validate(e);if(r instanceof Promise)throw Error(`async function passed to sync validator`);if(r.issues)return t===`field`?r.issues:xv(r.issues,e)},async validateAsync({value:e,validationSource:t},n){let r=await n[`~standard`].validate(e);if(r.issues)return t===`field`?r.issues:xv(r.issues,e)}},Cv=e=>!!e&&`~standard`in e,wv={isValidating:!1,isTouched:!1,isBlurred:!1,isDirty:!1,isPristine:!0,isValid:!0,isDefaultValue:!0,errors:[],errorMap:{},errorSourceMap:{},_arrayVersion:0,_pendingValidationsCount:0};function Tv(e){function t(t){let n=e.getFieldMeta(t)??wv;e.setFieldMeta(t,{...n,_arrayVersion:(n._arrayVersion||0)+1})}function n(n,r,i){t(n);let a=s(n,r,`move`,i),c=Math.min(r,i),u=Math.max(r,i);for(let e=c;e<=u;e++)a.push(o(n,e));let d=Object.keys(e.fieldInfo).reduce((t,i)=>(i.startsWith(o(n,r))&&t.set(i,e.getFieldMeta(i)),t),new Map);l(a,r<i?`up`:`down`),Object.keys(e.fieldInfo).filter(e=>e.startsWith(o(n,i))).forEach(t=>{let a=t.replace(o(n,i),o(n,r)),s=d.get(a);s&&e.setFieldMeta(t,s)})}function r(e,n){t(e),l(s(e,n,`remove`),`up`)}function i(n,r,i){t(n),s(n,r,`swap`,i).forEach(t=>{if(!t.toString().startsWith(o(n,r)))return;let a=t.toString().replace(o(n,r),o(n,i)),[s,c]=[e.getFieldMeta(t),e.getFieldMeta(a)];s&&e.setFieldMeta(a,s),c&&e.setFieldMeta(t,c)})}function a(n,r){t(n);let i=s(n,r,`insert`);l(i,`down`),i.forEach(t=>{t.toString().startsWith(o(n,r))&&e.setFieldMeta(t,u())})}function o(e,t){return`${e}[${t}]`}function s(t,n,r,i){let a=[o(t,n)];switch(r){case`swap`:a.push(o(t,i));break;case`move`:{let[e,r]=[Math.min(n,i),Math.max(n,i)];for(let n=e;n<=r;n++)a.push(o(t,n));break}default:{let r=e.getFieldValue(t),i=Array.isArray(r)?r.length:0;for(let e=n+1;e<i;e++)a.push(o(t,e));break}}return Object.keys(e.fieldInfo).filter(e=>a.some(t=>e.startsWith(t)))}function c(e,t){return e.replace(/\[(\d+)\]/,(e,n)=>{let r=parseInt(n,10);return`[${t===`up`?r+1:Math.max(0,r-1)}]`})}function l(t,n){(n===`up`?t:[...t].reverse()).forEach(t=>{let r=c(t.toString(),n),i=e.getFieldMeta(r);i?e.setFieldMeta(t,i):e.setFieldMeta(t,u())})}let u=()=>wv;return{bumpArrayVersion:t,handleArrayMove:n,handleArrayRemove:r,handleArraySwap:i,handleArrayInsert:a}}function Ev(e){return{values:e.values??{},errorMap:e.errorMap??{},fieldMetaBase:e.fieldMetaBase??{},formGroupStateBase:e.formGroupStateBase??{},isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1,validationMetaMap:e.validationMetaMap??{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}}}var Dv=class{constructor(e){this.options={},this.fieldInfo={},this.formGroupApis=new Set,this.mount=()=>{let e=this.store.subscribe(()=>{gv(this)}),t=q_.on(`request-form-state`,e=>{e.payload.id===this._formId&&q_.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}),n=q_.on(`request-form-reset`,e=>{e.payload.id===this._formId&&this.reset()}),r=q_.on(`request-form-force-submit`,e=>{e.payload.id===this._formId&&(this._devtoolsSubmissionOverride=!0,this.handleSubmit(),this._devtoolsSubmissionOverride=!1)}),i=()=>{r(),n(),t(),e.unsubscribe(),q_.emit(`form-unmounted`,{id:this._formId})};this.options.listeners?.onMount?.({formApi:this});let{onMount:a}=this.options.validators||{};return q_.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options}),a&&this.validateSync(`mount`),i},this.update=e=>{if(!e)return;let t=this.options;this.options=e;let n=e.defaultValues&&!cv(e.defaultValues,t.defaultValues)&&!this.state.isTouched,r=!cv(e.defaultState,t.defaultState)&&!this.state.isTouched;if(!(!n&&!r)){if(I_(()=>{this.baseStore.setState(()=>Ev(Object.assign({},this.state,r?e.defaultState:{},n?{values:e.defaultValues}:{})))}),n){let e=Tv(this);for(let t of Object.keys(this.fieldInfo))Array.isArray(this.getFieldValue(t))&&e.bumpArrayVersion(t)}q_.emit(`form-api`,{id:this._formId,state:this.store.state,options:this.options})}},this.reset=(e,t)=>{let{fieldMeta:n}=this.state,r=this.resetFieldMeta(n);e&&!t?.keepDefaultValues&&(this.options={...this.options,defaultValues:e}),this.baseStore.setState(()=>{let t=e??this.options.defaultValues??this.options.defaultState?.values;return e||Object.values(this.fieldInfo).forEach(e=>{e.instance&&e.instance.options.defaultValue!==void 0&&(t=X_(t,e.instance.name,e.instance.options.defaultValue))}),Ev({...this.options.defaultState,values:t,fieldMetaBase:r})})},this.validateAllFields=async e=>{let t=[];return I_(()=>{Object.values(this.fieldInfo).forEach(n=>{if(!n.instance)return;let r=n.instance;t.push(Promise.resolve().then(()=>r.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.instance.store.state.meta.isTouched||n.instance.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null,a=[`${e}[${t}]`];for(let n=t+1;n<=(i??0);n++)a.push(`${e}[${n}]`);let o=Object.keys(this.fieldInfo).filter(e=>a.some(t=>e.startsWith(t))),s=[];return I_(()=>{o.forEach(e=>{s.push(Promise.resolve().then(()=>this.validateField(e,n)))})}),(await Promise.all(s)).flat()},this.validateField=(e,t)=>{let n=this.fieldInfo[e]?.instance;if(!n){let{hasErrored:n}=this.validateSync(t);return n&&!this.options.asyncAlways?this.getFieldMeta(e)?.errors??[]:this.validateAsync(t).then(()=>this.getFieldMeta(e)?.errors??[])}return n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0})),n.validate(t)},this.validateSync=(e,t)=>{let n=av(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||yv}),r=!1,i={};return I_(()=>{for(let e of n){if(!e.validate)continue;let{formError:n,fieldErrors:a}=Ov(this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`},type:`validate`})),o=kv(e.cause),s=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(a||{})]);t?.filterFieldNames&&(s=new Set([...s].filter(t.filterFieldNames)));for(let e of s){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!a?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??wv,r=a?.[e],{newErrorValue:s,newSource:c}=lv({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[o]===`form`,previousErrorValue:t?.[o]});c===`form`&&(i[e]={...i[e],[o]:r}),t?.[o]!==s&&this.setFieldMeta(e,(e=wv)=>({...e,errorMap:{...e.errorMap,[o]:s},errorSourceMap:{...e.errorSourceMap,[o]:c}}))}t?.dontUpdateFormErrorMap||this.state.errorMap?.[o]!==n&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:n}})),(n||a)&&(r=!0)}if(t?.dontUpdateFormErrorMap)return;let a=kv(`submit`);this.state.errorMap?.[a]&&e!==`submit`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[a]:void 0}}));let o=kv(`server`);this.state.errorMap?.[o]&&e!==`server`&&!r&&this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[o]:void 0}}))}),{hasErrored:r,fieldsErrorMap:i}},this.validateAsync=async(e,t)=>{let n=ov(e,{...this.options,form:this,group:t?.group,validationLogic:this.options.validationLogic||yv});this.state.isFormValidating||this.baseStore.setState(e=>({...e,isFormValidating:!0}));let r=[],i;for(let e of n){if(!e.validate)continue;let n=kv(e.cause);this.state.validationMetaMap[n]?.lastAbortController.abort();let a=new AbortController;this.state.validationMetaMap[n]={lastAbortController:a},r.push(new Promise(async n=>{let r;try{r=await new Promise((t,n)=>{setTimeout(async()=>{if(a.signal.aborted)return t(void 0);try{t(await this.runValidator({validate:e.validate,value:{value:this.state.values,formApi:this,validationSource:`form`,signal:a.signal},type:`validateAsync`}))}catch(e){n(e)}},e.debounceMs)})}catch(e){r=e}let{formError:o,fieldErrors:s}=Ov(r);s&&(i=i?{...i,...s}:s);let c=kv(e.cause),l=new Set([...Object.keys(this.state.fieldMeta),...Object.keys(i||{})]),u=Array.from(l);t?.filterFieldNames&&(u=u.filter(t.filterFieldNames));for(let e of u){if(this.baseStore.state.fieldMetaBase[e]===void 0&&!i?.[e])continue;let{errorMap:t,errorSourceMap:n}=this.getFieldMeta(e)??wv,r=i?.[e],{newErrorValue:a,newSource:o}=lv({newFormValidatorError:r,isPreviousErrorFromFormValidator:n?.[c]===`form`,previousErrorValue:t?.[c]});t?.[c]!==a&&this.setFieldMeta(e,(e=wv)=>({...e,errorMap:{...e.errorMap,[c]:a},errorSourceMap:{...e.errorSourceMap,[c]:o}}))}t?.dontUpdateFormErrorMap||this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[c]:o}})),n(i?{fieldErrors:i,errorMapKey:c}:void 0)}))}let a=[],o={};if(r.length){a=await Promise.all(r);for(let e of a)if(e?.fieldErrors){let{errorMapKey:t}=e;for(let[n,r]of Object.entries(e.fieldErrors))o[n]={...o[n]||{},[t]:r}}}return this.baseStore.setState(e=>({...e,isFormValidating:!1})),o},this.validate=(e,t)=>{let{hasErrored:n,fieldsErrorMap:r}=this.validateSync(e,t);return n&&!this.options.asyncAlways?r:this.validateAsync(e,t)},this._handleSubmit=async e=>{this.baseStore.setState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),I_(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance&&(e.instance.store.state.meta.isTouched||e.instance.setMeta(e=>({...e,isTouched:!0})))})});let t=e??this.options.onSubmitMeta;if(!this.state.canSubmit&&!this._devtoolsSubmissionOverride&&this.baseStore.state.submissionAttempts<=1){this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t});return}this.baseStore.setState(e=>({...e,isSubmitting:!0}));let n=()=>{this.baseStore.setState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.state.isFieldsValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),q_.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validateAllFields`,errors:Object.values(this.state.fieldMeta).map(e=>e.errors).flat()});return}if(await this.validate(`submit`),!this.state.isValid){n(),this.options.onSubmitInvalid?.({value:this.state.values,formApi:this,meta:t}),q_.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`validate`,errors:this.state.errors});return}I_(()=>{Object.values(this.fieldInfo).forEach(e=>{e.instance?.triggerOnSubmitListener()})}),this.options.listeners?.onSubmit?.({formApi:this,meta:t});try{await this.options.onSubmit?.({value:this.state.values,formApi:this,meta:t}),I_(()=>{this.baseStore.setState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),q_.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!0}),n()})}catch(e){throw this.baseStore.setState(e=>({...e,isSubmitSuccessful:!1})),q_.emit(`form-submission`,{id:this._formId,submissionAttempt:this.state.submissionAttempts,successful:!1,stage:`inflight`,onError:e}),n(),e}},this.getFieldValue=e=>Y_(this.state.values,e),this.getFieldMeta=e=>this.state.fieldMeta[e],this.getFormGroupMeta=e=>this.formGroupMetaDerived.state[e],this.getFieldInfo=e=>this.fieldInfo[e]||={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.setFieldMeta=(e,t)=>{this.baseStore.setState(n=>({...n,fieldMetaBase:{...n.fieldMetaBase,[e]:J_(t,n.fieldMetaBase[e])}}))},this.resetFieldMeta=e=>Object.keys(e).reduce((e,t)=>{let n=t;return e[n]=wv,e},{}),this.setFieldValue=(e,t,n)=>{let r=n?.dontUpdateMeta??!1,i=n?.dontRunListeners??!1,a=n?.dontValidate??!1;I_(()=>{r||this.setFieldMeta(e,e=>({...e,isTouched:!0,isDirty:!0,errorMap:{...e?.errorMap,onMount:void 0}})),this.baseStore.setState(n=>({...n,values:X_(n.values,e,t)}))}),i||this.getFieldInfo(e).instance?.triggerOnChangeListener(),a||this.validateField(e,`change`)},this.deleteField=e=>{let t=[...Object.keys(this.fieldInfo).filter(t=>{let n=e.toString();return t!==n&&t.startsWith(n)}),e];this.baseStore.setState(e=>{let n={...e};return t.forEach(e=>{n.values=Z_(n.values,e),delete this.fieldInfo[e],delete n.fieldMetaBase[e]}),n})},this.pushFieldValue=(e,t,n)=>{this.setFieldValue(e,e=>[...Array.isArray(e)?e:[],t],n),Tv(this).bumpArrayVersion(e)},this.insertFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>[...e.slice(0,t),n,...e.slice(t)],dv(r,{dontValidate:!0}));let i=r?.dontValidate??!1;i||await this.validateField(e,`change`),Tv(this).handleArrayInsert(e,t),i||await this.validateArrayFieldsStartingFrom(e,t,`change`)},this.replaceFieldValue=async(e,t,n,r)=>{this.setFieldValue(e,e=>e.map((e,r)=>r===t?n:e),dv(r,{dontValidate:!0})),Tv(this).bumpArrayVersion(e),(r?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.removeFieldValue=async(e,t,n)=>{let r=this.getFieldValue(e),i=Array.isArray(r)?Math.max(r.length-1,0):null;if(this.setFieldValue(e,e=>e.filter((e,n)=>n!==t),dv(n,{dontValidate:!0})),Tv(this).handleArrayRemove(e,t),i!==null){let t=`${e}[${i}]`;this.deleteField(t)}(n?.dontValidate??!1)||(await this.validateField(e,`change`),await this.validateArrayFieldsStartingFrom(e,t,`change`))},this.swapFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=e[t],i=e[n];return X_(X_(e,`${t}`,i),`${n}`,r)},dv(r,{dontValidate:!0})),Tv(this).handleArraySwap(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.moveFieldValues=(e,t,n,r)=>{this.setFieldValue(e,e=>{let r=[...e];return r.splice(n,0,r.splice(t,1)[0]),r},dv(r,{dontValidate:!0})),Tv(this).handleArrayMove(e,t,n),(r?.dontValidate??!1)||(this.validateField(e,`change`),this.validateField(`${e}[${t}]`,`change`),this.validateField(`${e}[${n}]`,`change`))},this.clearFieldValues=(e,t)=>{let n=this.getFieldValue(e),r=Array.isArray(n)?Math.max(n.length-1,0):null;if(this.setFieldValue(e,[],dv(t,{dontValidate:!0})),Tv(this).bumpArrayVersion(e),r!==null)for(let t=0;t<=r;t++){let n=`${e}[${t}]`;this.deleteField(n)}(t?.dontValidate??!1)||this.validateField(e,`change`)},this.resetField=e=>{this.baseStore.setState(t=>{let n=this.getFieldInfo(e).instance?.options.defaultValue,r=Y_(this.options.defaultValues,e),i=n??r;return{...t,fieldMetaBase:{...t.fieldMetaBase,[e]:wv},values:i===void 0?t.values:X_(t.values,e,i)}})},this.setErrorMap=e=>{I_(()=>{Object.entries(e).forEach(([e,t])=>{let n=e;if(sv(t)){let{formError:e,fieldErrors:r}=Ov(t);for(let e of Object.keys(this.fieldInfo))this.getFieldMeta(e)&&this.setFieldMeta(e,t=>({...t,errorMap:{...t.errorMap,[n]:r?.[e]},errorSourceMap:{...t.errorSourceMap,[n]:`form`}}));this.baseStore.setState(t=>({...t,errorMap:{...t.errorMap,[n]:e}}))}else this.baseStore.setState(e=>({...e,errorMap:{...e.errorMap,[n]:t}}))})})},this.getAllErrors=()=>({form:{errors:this.state.errors,errorMap:this.state.errorMap},fields:Object.entries(this.state.fieldMeta).reduce((e,[t,n])=>(Object.keys(n).length&&n.errors.length&&(e[t]={errors:n.errors,errorMap:n.errorMap}),e),{})}),this.parseValuesWithSchema=e=>Sv.validate({value:this.state.values,validationSource:`form`},e),this.parseValuesWithSchemaAsync=e=>Sv.validateAsync({value:this.state.values,validationSource:`form`},e),this.timeoutIds={validations:{},listeners:{},formListeners:{}},this._formId=e?.formId??hv(),this._devtoolsSubmissionOverride=!1;let t=Ev({...e?.defaultState,values:e?.defaultValues??e?.defaultState?.values});if(e?.transform){t=e.transform({state:t}).state;for(let e of Object.keys(t.errorMap)){let n=t.errorMap[e];if(!(n===void 0||!sv(n)))for(let r of Object.keys(n.fields)){let i=n.fields[r];if(i===void 0)continue;let a=t.fieldMetaBase[r];t.fieldMetaBase[r]={isTouched:!1,isValidating:!1,isBlurred:!1,isDirty:!1,_arrayVersion:0,_pendingValidationsCount:0,...a??{},errorSourceMap:{...a?.errorSourceMap??{},onChange:`form`},errorMap:{...a?.errorMap??{},[e]:i}}}}}this.baseStore=U_(t);let n;this.fieldMetaDerived=U_(e=>{let t=this.baseStore.get(),r=0,i={};for(let a of Object.keys(t.fieldMetaBase)){let o=t.fieldMetaBase[a],s=n?.fieldMetaBase[a],c=e?.[a],l=Y_(t.values,a),u=c?.errors;if(!s||o.errorMap!==s.errorMap){u=Object.values(o.errorMap??{}).filter(e=>e!==void 0);let e=this.getFieldInfo(a)?.instance;(!e||!e.options.disableErrorFlat)&&(u=u.flat(1))}let d=!iv(u),f=!o.isDirty,p=cv(l,this.getFieldInfo(a)?.instance?.options.defaultValue??Y_(this.options.defaultValues,a));if(c&&c.isPristine===f&&c.isValid===d&&c.isDefaultValue===p&&c.errors===u&&o===s){i[a]=c,r++;continue}i[a]={...o,errors:u??[],isPristine:f,isValid:d,isDefaultValue:p}}return Object.keys(t.fieldMetaBase).length?e&&r===Object.keys(t.fieldMetaBase).length?e:(n=this.baseStore.get(),i):i}),this.formGroupMetaDerived=U_(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),r={};for(let i of this.formGroupApis){let a=i.name,o=t.formGroupStateBase[a]??{isSubmitted:!1,isSubmitting:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1},s=n[a],c=!1,l=!0,u=!1,d=!1,f=!0,p=!1;for(let e in n){if(e===a||!vv(a,e))continue;let t=n[e];t&&(t.isValidating&&(c=!0),t.isValid||(l=!1),t.isTouched&&(u=!0),t.isBlurred&&(d=!0),t.isDefaultValue||(f=!1),t.isDirty&&(p=!0))}let m=!p,h=!!c||o.isValidating,g=s?.errorMap??{},_=s?.errorSourceMap??{},v=!!(g.onMount||Object.entries(n).some(([e,t])=>t&&e!==a&&vv(a,e)&&t.errorMap.onMount)),y=e?.[a],b=y?.errors??[];(!y||y.__srcErrorMap!==g)&&(b=Object.values(g).reduce((e,t)=>{if(t===void 0)return e;if(t&&typeof t==`object`&&`fields`in t){let n=t.group;return n!==void 0&&e.push(n),e}return e.push(t),e},[]));let x=b.length===0,S=l&&x,C=i.options.canSubmitWhenInvalid??!1,w=o.submissionAttempts===0&&!u&&!v||!h&&!o.isSubmitting&&S||C;if(y&&y.errorMap===g&&y.errorSourceMap===_&&y.errors===b&&y.isFieldsValidating===c&&y.isFieldsValid===l&&y.isGroupValid===x&&y.isValid===S&&y.canSubmit===w&&y.isTouched===u&&y.isBlurred===d&&y.isPristine===m&&y.isDefaultValue===f&&y.isDirty===p&&y.isValidating===h&&y.isSubmitting===o.isSubmitting&&y.isSubmitted===o.isSubmitted&&y.submissionAttempts===o.submissionAttempts&&y.isSubmitSuccessful===o.isSubmitSuccessful){r[a]=y;continue}let T={...o,errorMap:g,errorSourceMap:_,_arrayVersion:s?._arrayVersion??0,isTouched:u,isBlurred:d,isDirty:p,isPristine:m,isDefaultValue:f,isValid:S,errors:b,isValidating:h,isFieldsValidating:c,isFieldsValid:l,isGroupValid:x,canSubmit:w};Object.defineProperty(T,"__srcErrorMap",{value:g,enumerable:!1,configurable:!0}),r[a]=T}return r});let r;this.store=U_(e=>{let t=this.baseStore.get(),n=this.fieldMetaDerived.get(),i=Object.values(n).filter(Boolean),a=i.some(e=>e.isValidating),o=i.every(e=>e.isValid),s=i.some(e=>e.isTouched),c=i.some(e=>e.isBlurred),l=i.every(e=>e.isDefaultValue),u=s&&t.errorMap?.onMount,d=i.some(e=>e.isDirty),f=!d,p=!!(t.errorMap?.onMount||i.some(e=>e?.errorMap?.onMount)),m=!!a,h=e?.errors??[];(!r||t.errorMap!==r.errorMap)&&(h=Object.values(t.errorMap).reduce((e,t)=>t===void 0?e:t&&sv(t)?(e.push(t.form),e):(e.push(t),e),[]));let g=h.length===0,_=o&&g,v=this.options.canSubmitWhenInvalid??!1,y=t.submissionAttempts===0&&!s&&!p||!m&&!t.isSubmitting&&_||v,b=t.errorMap;if(u&&(h=h.filter(e=>e!==t.errorMap.onMount),b=Object.assign(b,{onMount:void 0})),e&&r&&e.errorMap===b&&e.fieldMeta===this.fieldMetaDerived.state&&e.errors===h&&e.isFieldsValidating===a&&e.isFieldsValid===o&&e.isFormValid===g&&e.isValid===_&&e.canSubmit===y&&e.isTouched===s&&e.isBlurred===c&&e.isPristine===f&&e.isDefaultValue===l&&e.isDirty===d&&cv(r,t))return e;let x={...t,errorMap:b,fieldMeta:this.fieldMetaDerived.state,errors:h,isFieldsValidating:a,isFieldsValid:o,isFormValid:g,isValid:_,canSubmit:y,isTouched:s,isBlurred:c,isPristine:f,isDefaultValue:l,isDirty:d};return r=this.baseStore.get(),x}),this.handleSubmit=this.handleSubmit.bind(this),this.update(e||{})}get state(){return this.store.state}get formId(){return this._formId}runValidator(e){return Cv(e.validate)?Sv[e.type](e.value,e.validate):e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function Ov(e){return e?sv(e)?{formError:Ov(e.form).formError,fieldErrors:e.fields}:{formError:e}:{formError:void 0}}function kv(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}var Av=class e{constructor(t){this.options={},this.mount=()=>{this.options.defaultValue!==void 0&&!this.getMeta().isTouched&&this.form.setFieldValue(this.name,this.options.defaultValue,{dontUpdateMeta:!0});let e=this.getInfo();e.instance=this,this.update(this.options);let{onMount:t}=this.options.validators||{};if(t){let e=this.runValidator({validate:t,value:{value:this.state.value,fieldApi:this,validationSource:`field`},type:`validate`});e&&this.setMeta(t=>({...t,errorMap:{...t?.errorMap,onMount:e},errorSourceMap:{...t?.errorSourceMap,onMount:`field`}}))}return this.options.listeners?.onMount?.({value:this.state.value,fieldApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);let e=this.form.fieldInfo[this.name];if(e&&e.instance===this){for(let[t,n]of Object.entries(e.validationMetaMap))n?.lastAbortController.abort(),e.validationMetaMap[t]=void 0;this.form.baseStore.setState(e=>({...e,fieldMetaBase:{...e.fieldMetaBase,[this.name]:{...wv,isTouched:e.fieldMetaBase[this.name]?.isTouched??wv.isTouched,isBlurred:e.fieldMetaBase[this.name]?.isBlurred??wv.isBlurred,isDirty:e.fieldMetaBase[this.name]?.isDirty??wv.isDirty}}})),e.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,fieldApi:this}),this.form.options.listeners?.onFieldUnmount?.({formApi:this.form,fieldApi:this})}}},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(cv(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,dv(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=(e,t)=>{this.form.pushFieldValue(this.name,e,dv(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.insertValue=(e,t,n)=>{this.form.insertFieldValue(this.name,e,t,dv(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.replaceValue=(e,t,n)=>{this.form.replaceFieldValue(this.name,e,t,dv(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.removeValue=(e,t)=>{this.form.removeFieldValue(this.name,e,dv(t,{dontRunListeners:!0})),t?.dontRunListeners||this.triggerOnChangeListener()},this.swapValues=(e,t,n)=>{this.form.swapFieldValues(this.name,e,t,dv(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.moveValue=(e,t,n)=>{this.form.moveFieldValues(this.name,e,t,dv(n,{dontRunListeners:!0})),n?.dontRunListeners||this.triggerOnChangeListener()},this.clearValues=e=>{this.form.clearFieldValues(this.name,dv(e,{dontRunListeners:!0})),e?.dontRunListeners||this.triggerOnChangeListener()},this.getLinkedFields=t=>{let n=Object.values(this.form.fieldInfo),r=[];for(let i of n){if(!i.instance||!(i.instance instanceof e))continue;let{onChangeListenTo:n,onBlurListenTo:a}=i.instance.options.validators||{};t===`change`&&n?.includes(this.name)&&r.push(i.instance),t===`blur`&&a?.includes(this.name)&&r.push(i.instance)}return r},this.validateSync=(e,t)=>{let n=av(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||yv}),r=this.getLinkedFields(e).reduce((t,n)=>{let r=av(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||yv});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),i=!1;I_(()=>{let e=(e,n)=>{let r=Mv(n.cause),a=n.validate?jv(e.runValidator({validate:n.validate,value:{value:e.store.state.value,validationSource:`field`,fieldApi:e},type:`validate`})):void 0,o=t[r],{newErrorValue:s,newSource:c}=uv({formLevelError:o,fieldLevelError:a});e.state.meta.errorMap?.[r]!==s&&e.setMeta(e=>({...e,errorMap:{...e.errorMap,[r]:s},errorSourceMap:{...e.errorSourceMap,[r]:c}})),s&&(i=!0)};for(let t of n)e(this,t);for(let t of r)t.validate&&e(t.field,t)});let a=Mv(`submit`);return this.state.meta.errorMap?.[a]&&e!==`submit`&&!i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[a]:void 0},errorSourceMap:{...e.errorSourceMap,[a]:void 0}})),{hasErrored:i}},this.validateAsync=async(e,t)=>{let n=ov(e,{...this.options,form:this.form,fieldName:this.name,validationLogic:this.form.options.validationLogic||yv}),r=await t,i=this.getLinkedFields(e).reduce((t,n)=>{let r=ov(e,{...n.options,form:n.form,fieldName:n.name,validationLogic:n.form.options.validationLogic||yv});return r.forEach(e=>{e.field=n}),t.concat(r)},[]),a=[],o=[],s=n.some(e=>e.validate),c=Array.from(new Set(i.filter(e=>e.validate).map(e=>e.field)));I_(()=>{s&&this.startValidation();for(let e of c)e.startValidation()});let l=(e,t,n)=>{let i=Mv(t.cause),a=e.getInfo();a.validationMetaMap[i]?.lastAbortController.abort();let o=new AbortController;a.validationMetaMap[i]={lastAbortController:o},n.push(new Promise(async n=>{let a;try{a=await new Promise((n,r)=>{e.timeoutIds.validations[t.cause]&&(clearTimeout(e.timeoutIds.validations[t.cause]),e.endValidation()),e.timeoutIds.validations[t.cause]=setTimeout(async()=>{if(o.signal.aborted)return n(void 0);try{n(await this.runValidator({validate:t.validate,value:{value:e.store.state.value,fieldApi:e,signal:o.signal,validationSource:`field`},type:`validateAsync`}))}catch(e){r(e)}},t.debounceMs)})}catch(e){a=e}if(o.signal.aborted)return n(void 0);let s=jv(a),c=r[e.name]?.[i],{newErrorValue:l,newSource:u}=uv({formLevelError:c,fieldLevelError:s});if(e.getInfo().instance!==e)return n(void 0);e.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:l},errorSourceMap:{...e.errorSourceMap,[i]:u}})),n(l)}))};for(let e of n)e.validate&&l(this,e,a);for(let e of i)e.validate&&l(e.field,e,o);let u=[];return(a.length||o.length)&&(u=await Promise.all(a),await Promise.all(o)),I_(()=>{s&&this.endValidation();for(let e of c)e.endValidation()}),u.filter(Boolean)},this.validate=(e,t)=>{if(!this.state.meta.isTouched)return[];let n=t?.skipGroupValidation?[]:Array.from(this.form.formGroupApis).filter(e=>this.name.startsWith(e.name)),r=(t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e)).fieldsErrorMap[this.name]??{};if(!t?.skipFormValidation)for(let t of n){if(t.state.meta.submissionAttempts===0)continue;let{fieldsErrorMap:n}=this.form.validateSync(e,{group:t,dontUpdateFormErrorMap:!0,filterFieldNames:e=>vv(t.name,e)});r={...r,...n[this.name]??{}}}let{hasErrored:i}=this.validateSync(e,r),a=new WeakMap;for(let t of n){let{hasErrored:n}=t.validateSync(e,{},{skipRelatedFieldValidation:!0});a.set(t,n)}if(i&&!this.options.asyncAlways){this.getInfo().validationMetaMap[Mv(e)]?.lastAbortController.abort();let t=[];for(let r of n)r.getInfo().validationMetaMap[Mv(e)]?.lastAbortController.abort(),t.push(r.state.meta.errors);return[...this.state.meta.errors,...t.flat()]}let o=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e),s=this.validateAsync(e,o),c=[];for(let t of n)a.get(t)&&!t.options.asyncAlways||c.push(t.validateAsync(e,o,{skipRelatedFieldValidation:!0}));return c.length===0?s:Promise.all([s,...c]).then(e=>e.flat())},this.handleChange=e=>{this.setValue(e)},this.handleBlur=()=>{this.state.meta.isTouched||this.setMeta(e=>({...e,isTouched:!0})),this.state.meta.isBlurred||this.setMeta(e=>({...e,isBlurred:!0})),this.validate(`blur`),this.triggerOnBlurListener()},this.setErrorMap=e=>{this.setMeta(t=>({...t,errorMap:{...t.errorMap,...e}}))},this.parseValueWithSchema=e=>Sv.validate({value:this.state.value,validationSource:`field`},e),this.parseValueWithSchemaAsync=e=>Sv.validateAsync({value:this.state.value,validationSource:`field`},e),this.triggerOnBlurListener=()=>{let e=this.form.options.listeners?.onBlurDebounceMs;e&&e>0?(this.timeoutIds.formListeners.blur&&clearTimeout(this.timeoutIds.formListeners.blur),this.timeoutIds.formListeners.blur=setTimeout(()=>{this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onBlur?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onBlurDebounceMs;t&&t>0?(this.timeoutIds.listeners.blur&&clearTimeout(this.timeoutIds.listeners.blur),this.timeoutIds.listeners.blur=setTimeout(()=>{this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onBlur?.({value:this.state.value,fieldApi:this})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this})},e)):this.form.options.listeners?.onChange?.({formApi:this.form,fieldApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,fieldApi:this});for(let e of this.form.formGroupApis)vv(e.name,this.name)&&e.triggerOnChangeListener()},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,fieldApi:this})},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.store=U_(e=>{this.form.store.get();let n=this.form.getFieldMeta(this.name)??{...wv,...t.defaultMeta},r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!cv(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}})}get state(){return this.store.state}runValidator(e){return Cv(e.validate)?Sv[e.type](e.value,e.validate):e.validate(e.value)}startValidation(){this.setMeta(e=>{let t=e._pendingValidationsCount+1;return{...e,_pendingValidationsCount:t,isValidating:t>0&&!e.isValidating||e.isValidating}})}endValidation(){this.setMeta(e=>{let t=Math.max(0,e._pendingValidationsCount-1);return{...e,_pendingValidationsCount:t,isValidating:t===0&&e.isValidating?!1:e.isValidating}})}};function jv(e){if(e)return e}function Mv(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function Nv(e){return{isSubmitted:e.isSubmitted??!1,isSubmitting:e.isSubmitting??!1,isValidating:e.isValidating??!1,submissionAttempts:e.submissionAttempts??0,isSubmitSuccessful:e.isSubmitSuccessful??!1}}function Pv(e){return{...wv,...e,errors:[],isPristine:!0,isValid:!0,isDefaultValue:!0,isFieldsValidating:!1,isFieldsValid:!0,isGroupValid:!0,canSubmit:!0,isSubmitting:!1,isSubmitted:!1,isValidating:!1,submissionAttempts:0,isSubmitSuccessful:!1}}var Fv=class e{constructor(t){this.options={},this.setFormGroupState=e=>{this.form.baseStore.setState(t=>{let n=t.formGroupStateBase[this.name]??Nv({});return{...t,formGroupStateBase:{...t.formGroupStateBase,[this.name]:e(n)}}})},this._lastDistributedFieldNames={},this.update=e=>{this.options=e,this.name=e.name,!this.state.meta.isTouched&&this.options.defaultValue!==void 0&&(cv(this.form.getFieldValue(this.name),e.defaultValue)||this.form.setFieldValue(this.name,e.defaultValue,{dontUpdateMeta:!0,dontValidate:!0,dontRunListeners:!0})),this.form.getFieldMeta(this.name)||this.form.setFieldMeta(this.name,{...wv,...this.options.defaultMeta})},this.mount=()=>{this.update(this.options),this.form.formGroupApis.add(this),this.fieldInfo.instance=this,this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:e.formGroupStateBase[this.name]??Nv({...this.options.defaultState})}}));let{onMount:e}=this.options.validators||{};if(e){let t=this.runValidator({validate:e,value:{value:this.state.value,groupApi:this,validationSource:`form`},type:`validate`}),n=t,r;Lv(t)&&(n=t.group,r=t.fields);let i=Iv(n);i&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,onMount:i},errorSourceMap:{...e.errorSourceMap,onMount:`field`}})),this.distributeFieldErrors(`onMount`,r)}return this.options.listeners?.onMount?.({value:this.state.value,groupApi:this}),()=>{for(let[e,t]of Object.entries(this.timeoutIds.validations))t&&(clearTimeout(t),this.timeoutIds.validations[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.listeners))t&&(clearTimeout(t),this.timeoutIds.listeners[e]=null);for(let[e,t]of Object.entries(this.timeoutIds.formListeners))t&&(clearTimeout(t),this.timeoutIds.formListeners[e]=null);if(this.fieldInfo.instance===this){for(let[e,t]of Object.entries(this.fieldInfo.validationMetaMap))t?.lastAbortController.abort(),this.fieldInfo.validationMetaMap[e]=void 0;this.form.formGroupApis.delete(this),this.form.baseStore.setState(e=>({...e,formGroupStateBase:{...e.formGroupStateBase,[this.name]:Nv({})}})),this.fieldInfo.instance=null,this.options.listeners?.onUnmount?.({value:this.state.value,groupApi:this})}}},this.setValue=(e,t)=>{this.form.setFieldValue(this.name,e,dv(t,{dontRunListeners:!0,dontValidate:!0})),t?.dontRunListeners||this.triggerOnChangeListener(),t?.dontValidate||this.validate(`change`)},this.getMeta=()=>this.store.state.meta,this.setMeta=e=>this.form.setFieldMeta(this.name,e),this.getInfo=()=>this.fieldInfo,this.getRelatedFields=()=>{let e=Object.values(this.form.fieldInfo),t=[];for(let n of e)n.instance&&n.instance instanceof Av&&n.instance.name.startsWith(this.name)&&t.push(n.instance);return t},this.getRelatedFieldMetasDerived=()=>{let e=Object.entries(this.form.fieldMetaDerived.state),t=[];for(let[n,r]of e)n!==this.name&&vv(this.name,n)&&t.push({...r,name:n});return t},this.buildChildFieldName=e=>e===``?this.name:e.startsWith(`[`)?`${this.name}${e}`:`${this.name}.${e}`,this.distributeFieldErrors=(e,t)=>{let n=this._lastDistributedFieldNames[e]??new Set,r=new Set;if(t)for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.add(this.buildChildFieldName(e));let i=new Set([...n,...r]),a=!1;for(let n of i){let r=n.startsWith(this.name+`[`)?n.slice(this.name.length):n.slice(this.name.length+1),i=t?.[r],o=this.form.getFieldMeta(n);if(!o&&!i)continue;let s=o?.errorMap[e],{newErrorValue:c,newSource:l}=lv({newFormValidatorError:i,isPreviousErrorFromFormValidator:o?.errorSourceMap[e]===`form`,previousErrorValue:s});c&&(a=!0),(s!==c||o?.errorSourceMap[e]!==l)&&this.form.setFieldMeta(n,(t=wv)=>({...t,errorMap:{...t.errorMap,[e]:c},errorSourceMap:{...t.errorSourceMap,[e]:l}}))}return this._lastDistributedFieldNames[e]=r,a},this.validateSync=(t,n,r={})=>{let i=av(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||yv}),a=(r.skipRelatedFieldValidation?[]:this.getRelatedFields()).reduce((e,n)=>{let r=av(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||yv});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),o=!1;I_(()=>{let t=(t,r)=>{let i=zv(r.cause),a=t===this,s;r.validate&&(s=t.runValidator({validate:r.validate,value:{value:t.store.state.value,validationSource:a?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validate`}));let c=s,l;a&&Lv(s)&&(c=s.group,l=s.fields);let u=Iv(c),d=n[i],{newErrorValue:f,newSource:p}=uv({formLevelError:d,fieldLevelError:u});t.state.meta.errorMap?.[i]!==f&&t.setMeta(e=>({...e,errorMap:{...e.errorMap,[i]:f},errorSourceMap:{...e.errorSourceMap,[i]:p}})),f&&(o=!0),a&&this.distributeFieldErrors(i,l)&&(o=!0)};for(let e of i)t(this,e);for(let e of a)e.validate&&t(e.field,e)});let s=zv(`submit`);return this.state.meta.errorMap?.[s]&&t!==`submit`&&!o&&this.setMeta(e=>({...e,errorMap:{...e.errorMap,[s]:void 0},errorSourceMap:{...e.errorSourceMap,[s]:void 0}})),{hasErrored:o}},this.validateAsync=async(t,n,r={})=>{let i=ov(t,{...this.options,form:this.form,group:this,validationLogic:this.options.validationLogic||this.form.options.validationLogic||yv}),a=await n,o=r.skipRelatedFieldValidation?[]:this.getRelatedFields(),s=o.reduce((e,n)=>{let r=ov(t,{...n.options,form:n.form,validationLogic:n.form.options.validationLogic||yv});return r.forEach(e=>{e.field=n}),e.concat(r)},[]),c=[],l=[],u=i.some(e=>e.validate)||s.some(e=>e.validate);if(u){this.state.meta.isValidating||this.setMeta(e=>({...e,isValidating:!0}));for(let e of o)e.setMeta(e=>({...e,isValidating:!0}))}let d=(t,n,r)=>{let i=zv(n.cause),o=t.getInfo();o.validationMetaMap[i]?.lastAbortController.abort();let s=new AbortController;o.validationMetaMap[i]={lastAbortController:s};let c=t===this;r.push(new Promise(async r=>{let o;try{o=await new Promise((r,i)=>{t.timeoutIds.validations[n.cause]&&clearTimeout(t.timeoutIds.validations[n.cause]),t.timeoutIds.validations[n.cause]=setTimeout(async()=>{if(s.signal.aborted)return r(void 0);try{r(await this.runValidator({validate:n.validate,value:{value:t.store.state.value,signal:s.signal,validationSource:c?`form`:`field`,...t instanceof e?{groupApi:t}:{fieldApi:t}},type:`validateAsync`}))}catch(e){i(e)}},n.debounceMs)})}catch(e){o=e}if(s.signal.aborted)return r(void 0);let l=o,u;c&&Lv(o)&&(l=o.group,u=o.fields);let d=Iv(l),f=a[t.name]?.[i],{newErrorValue:p,newSource:m}=uv({formLevelError:f,fieldLevelError:d});if(t.getInfo().instance!==t)return r(void 0);t.setMeta(e=>({...e,errorMap:{...e?.errorMap,[i]:p},errorSourceMap:{...e.errorSourceMap,[i]:m}})),c&&this.distributeFieldErrors(i,u),r(p)}))};for(let e of i)e.validate&&d(this,e,c);for(let e of s)e.validate&&d(e.field,e,l);let f=[];if((c.length||l.length)&&(f=await Promise.all(c),await Promise.all(l)),u){this.setMeta(e=>({...e,isValidating:!1}));for(let e of o)e.setMeta(e=>({...e,isValidating:!1}))}return f.filter(Boolean)},this.validateAllFields=async e=>{let t=[];return I_(()=>{Object.values(this.getRelatedFields()).forEach(n=>{t.push(Promise.resolve().then(()=>n.validate(e,{skipFormValidation:!0,skipGroupValidation:!0}))),n.store.state.meta.isTouched||n.setMeta(e=>({...e,isTouched:!0}))})}),(await Promise.all(t)).flat()},this.validateArrayFieldsStartingFrom=(e,t,n)=>this.form.validateArrayFieldsStartingFrom(e,t,n),this.validateField=(e,t)=>this.form.validateField(e,t),this.getFieldValue=e=>this.form.getFieldValue(e),this.getFieldMeta=e=>this.form.getFieldMeta(e),this.setFieldMeta=(e,t)=>this.form.setFieldMeta(e,t),this.setFieldValue=(e,t)=>this.form.setFieldValue(e,t),this.deleteField=e=>this.form.deleteField(e),this.pushFieldValue=(e,t)=>this.form.pushFieldValue(e,t),this.insertFieldValue=(e,t,n)=>this.form.insertFieldValue(e,t,n),this.replaceFieldValue=(e,t,n)=>this.form.replaceFieldValue(e,t,n),this.swapFieldValues=(e,t,n)=>this.form.swapFieldValues(e,t,n),this.moveFieldValues=(e,t,n)=>this.form.moveFieldValues(e,t,n),this.clearFieldValues=e=>this.form.clearFieldValues(e),this.resetField=e=>this.form.resetField(e),this.removeFieldValue=(e,t)=>this.form.removeFieldValue(e,t),this.areRelatedFieldsValid=()=>Object.values(this.getRelatedFields()).every(e=>e.state.meta.isValid),this.validate=(e,t)=>{let{fieldsErrorMap:n}=t?.skipFormValidation?{fieldsErrorMap:{}}:this.form.validateSync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>vv(this.name,e)}),{hasErrored:r}=this.validateSync(e,n[this.name]??{},{skipRelatedFieldValidation:t?.skipRelatedFieldValidation});if(r&&!this.options.asyncAlways)return this.getInfo().validationMetaMap[zv(e)]?.lastAbortController.abort(),this.state.meta.errors;let i=t?.skipFormValidation?Promise.resolve({}):this.form.validateAsync(e,{dontUpdateFormErrorMap:!0,filterFieldNames:e=>vv(this.name,e)});return this.validateAsync(e,i,{skipRelatedFieldValidation:t?.skipRelatedFieldValidation})},this.triggerOnChangeListener=()=>{let e=this.form.options.listeners?.onChangeGroupDebounceMs;e&&e>0?(this.timeoutIds.formListeners.change&&clearTimeout(this.timeoutIds.formListeners.change),this.timeoutIds.formListeners.change=setTimeout(()=>{this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this})},e)):this.form.options.listeners?.onChangeGroup?.({formApi:this.form,groupApi:this});let t=this.options.listeners?.onChangeDebounceMs;t&&t>0?(this.timeoutIds.listeners.change&&clearTimeout(this.timeoutIds.listeners.change),this.timeoutIds.listeners.change=setTimeout(()=>{this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},t)):this.options.listeners?.onChange?.({value:this.state.value,groupApi:this})},this.triggerOnSubmitListener=()=>{this.options.listeners?.onSubmit?.({value:this.state.value,groupApi:this})},this._handleSubmit=async e=>{this.setFormGroupState(e=>({...e,isSubmitted:!1,submissionAttempts:e.submissionAttempts+1,isSubmitSuccessful:!1})),I_(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.state.meta.isTouched||e.setMeta(e=>({...e,isTouched:!0}))})});let t=e??this.options.onSubmitMeta;this.setFormGroupState(e=>({...e,isSubmitting:!0}));let n=()=>{this.setFormGroupState(e=>({...e,isSubmitting:!1}))};if(await this.validateAllFields(`submit`),!this.areRelatedFieldsValid()){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}if(await this.validate(`submit`,{skipRelatedFieldValidation:!0}),!this.areRelatedFieldsValid()||!this.state.meta.isValid){n(),this.options.onGroupSubmitInvalid?.({value:this.state.value,groupApi:this,meta:t});return}I_(()=>{Object.values(this.getRelatedFields()).forEach(e=>{e.options.listeners?.onGroupSubmit?.({value:e.state.value,fieldApi:e})})}),this.options.listeners?.onSubmit?.({groupApi:this,value:this.state.value});try{await this.options.onGroupSubmit?.({value:this.state.value,groupApi:this,meta:t}),I_(()=>{this.setFormGroupState(e=>({...e,isSubmitted:!0,isSubmitSuccessful:!0})),n()})}catch(e){throw this.setFormGroupState(e=>({...e,isSubmitSuccessful:!1})),n(),e}},this.form=t.form,this.name=t.name,this.options=t,this.timeoutIds={validations:{},listeners:{},formListeners:{}},this.fieldInfo={instance:null,validationMetaMap:{onChange:void 0,onBlur:void 0,onSubmit:void 0,onMount:void 0,onServer:void 0,onDynamic:void 0}},this.store=U_(e=>{this.form.formGroupMetaDerived.get(),this.form.baseStore.get();let n=this.form.getFormGroupMeta(this.name)??Pv(t.defaultMeta),r=this.form.getFieldValue(this.name);return!n.isTouched&&r===void 0&&this.options.defaultValue!==void 0&&!cv(r,this.options.defaultValue)&&(r=this.options.defaultValue),e&&e.value===r&&e.meta===n?e:{value:r,meta:n}}),this.handleSubmit=this.handleSubmit.bind(this)}get state(){return this.store.state}runValidator(e){if(Cv(e.validate)){let t=Sv[e.type](e.value,e.validate);return e.type===`validate`?Rv(t):t.then(Rv)}return e.validate(e.value)}handleSubmit(e){return this._handleSubmit(e)}};function Iv(e){if(e)return e}function Lv(e){return!!e&&typeof e==`object`&&`fields`in e}function Rv(e){if(!e||typeof e!=`object`||!(`form`in e)&&!(`fields`in e))return e;let{form:t,fields:n,...r}=e;return{...r,group:t,fields:n}}function zv(e){switch(e){case`submit`:return`onSubmit`;case`blur`:return`onBlur`;case`mount`:return`onMount`;case`server`:return`onServer`;case`dynamic`:return`onDynamic`;default:return`onChange`}}function Bv(e,t){if(!t)return;let n=Object.assign({},e,{state:_v(e.state)});t(n),n.fieldInfo!==e.fieldInfo&&(e.fieldInfo=n.fieldInfo),n.options!==e.options&&(e.options=n.options);let r=Object.keys({values:null,validationMetaMap:null,fieldMetaBase:null,formGroupStateBase:null,isSubmitting:null,isSubmitted:null,isValidating:null,submissionAttempts:null,isSubmitSuccessful:null,_force_re_eval:null}).reduce((t,r)=>(e.state[r]!==n.state[r]&&(t[r]=n.state[r]),t),{});return I_(()=>{Object.keys(r).length&&e.baseStore.setState(e=>({...e,...r})),n.state.errorMap!==e.state.errorMap&&e.setErrorMap(n.state.errorMap)}),n}var Vv=Ii();function Hv(e,t){return e===t}function Uv(e,t=e=>e,n){let r=n?.compare??Hv,i=(0,q.useCallback)(t=>{let{unsubscribe:n}=e.subscribe(t);return n},[e]),a=(0,q.useCallback)(()=>e.get(),[e]);return(0,Vv.useSyncExternalStoreWithSelector)(i,a,a,t,r)}var Wv=typeof window<`u`?q.useLayoutEffect:q.useEffect;function Gv(e){let[t,n]=(0,q.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,q.useState)(()=>new Av({...e})),a=r;(t.form!==e.form||t.name!==e.name)&&(a=new Av({...e}),i(a),n({form:e.form,name:e.name}));let o=Uv(a.store,e.mode===`array`?e=>e.meta._arrayVersion||0:e=>e.value),s=Uv(a.store,e=>e.meta.isTouched),c=Uv(a.store,e=>e.meta.isBlurred),l=Uv(a.store,e=>e.meta.isDirty),u=Uv(a.store,e=>e.meta.errorMap),d=Uv(a.store,e=>e.meta.errorSourceMap),f=Uv(a.store,e=>e.meta.isValidating),p=(0,q.useMemo)(()=>({...a,get state(){return{value:e.mode===`array`?a.state.value:o,get meta(){return{...a.state.meta,isTouched:s,isBlurred:c,isDirty:l,errorMap:u,errorSourceMap:d,isValidating:f}}}}}),[a,e.mode,o,s,c,l,u,d,f]);return Wv(a.mount,[a]),Wv(()=>{a.update(e)}),p}var Kv=(({children:e,...t})=>{let n=Gv(t),r=(0,q.useMemo)(()=>J_(e,n),[e,n]);return(0,J.jsx)(J.Fragment,{children:r})});function qv(){return(0,q.useState)(()=>hv())[0]}var Jv=q,Yv=`18.3.1`.split(`.`)[0]===`17`?qv:Jv.useId;function Xv(e){let[t,n]=(0,q.useState)(()=>({form:e.form,name:e.name})),[r,i]=(0,q.useState)(()=>new Fv({...e}));(t.form!==e.form||t.name!==e.name)&&(i(new Fv({...e})),n({form:e.form,name:e.name}));let a=Uv(r.store,e=>e.value),o=Uv(r.store,e=>e.meta.isTouched),s=Uv(r.store,e=>e.meta.isBlurred),c=Uv(r.store,e=>e.meta.isDirty),l=Uv(r.store,e=>e.meta.errorMap),u=Uv(r.store,e=>e.meta.errorSourceMap),d=Uv(r.store,e=>e.meta.isValidating),f=Uv(r.store,e=>e.meta.isSubmitting),p=Uv(r.store,e=>e.meta.isSubmitted),m=Uv(r.store,e=>e.meta.submissionAttempts),h=Uv(r.store,e=>e.meta.isSubmitSuccessful),g=Uv(r.store,e=>e.meta.canSubmit),_=Uv(r.store,e=>e.meta.isValid),v=Uv(r.store,e=>e.meta.isFieldsValid),y=Uv(r.store,e=>e.meta.isFieldsValidating),b=Uv(r.store,e=>e.meta.isGroupValid),x=(0,q.useMemo)(()=>({...r,handleSubmit:((...e)=>r._handleSubmit(...e)),get state(){return{...r.state,value:a,get meta(){return{...r.state.meta,isTouched:o,isBlurred:s,isDirty:c,errorMap:l,errorSourceMap:u,isValidating:d,isSubmitting:f,isSubmitted:p,submissionAttempts:m,isSubmitSuccessful:h,canSubmit:g,isValid:_,isFieldsValid:v,isFieldsValidating:y,isGroupValid:b}}}}}),[r,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b]);return Wv(r.mount,[r]),Wv(()=>{r.update(e)}),x}var Zv=(({children:e,...t})=>{let n=Xv(t),r=(0,q.useMemo)(()=>J_(e,n),[e,n]);return(0,J.jsx)(J.Fragment,{children:r})});function Qv({form:e,selector:t=e=>e,children:n}){let r=Uv(e.store,t);return(0,J.jsx)(J.Fragment,{children:J_(n,r)})}function $v(e){let t=Yv(),[n,r]=(0,q.useState)(e?.formId),[i,a]=(0,q.useState)(()=>new Dv({...e,formId:e?.formId??t}));if(n!==e?.formId){let n=e?.formId??t;a(new Dv({...e,formId:n})),r(n)}let o=(0,q.useMemo)(()=>{let e={...i,handleSubmit:((...e)=>i._handleSubmit(...e)),get formId(){return i._formId},get state(){return i.store.state}};return e.Field=function(e){return(0,J.jsx)(Kv,{...e,form:i})},e.FormGroup=function(e){return(0,J.jsx)(Zv,{...e,form:i})},e.Subscribe=function(e){return(0,J.jsx)(Qv,{form:i,selector:e.selector,children:e.children})},e},[i]);Wv(i.mount,[]),Wv(()=>{i.update(e)});let s=(0,q.useRef)(!1);return Wv(()=>{s.current&&e?.transform&&Bv(i,e.transform)},[i,e?.transform]),Wv(()=>{s.current=!0}),o}var ey=(0,q.forwardRef)(function({className:e,invalid:t,...n},r){return(0,J.jsx)(`input`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:B(`input caps-input w-full`,e),ref:r})});(0,q.forwardRef)(function({leading:e,className:t,...n},r){return(0,J.jsxs)(`span`,{className:`caps-search-input`,"data-leading":e?`true`:void 0,children:[e?(0,J.jsx)(`span`,{className:`caps-search-leading`,"aria-hidden":`true`,children:e}):null,(0,J.jsx)(ey,{...n,type:`search`,className:t,ref:r})]})});var ty=(0,q.forwardRef)(function({children:e,className:t,optional:n,required:r,...i},a){return(0,J.jsxs)(`label`,{...i,className:B(`label caps-label cursor-pointer justify-start gap-sm text-sm font-semibold text-base-content`,t),ref:a,children:[e,r?(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`text-error`,children:`*`}):null,n&&!r?(0,J.jsx)(`span`,{className:`caps-label-optional`,children:`Optional`}):null]})}),ny=(0,q.forwardRef)(function({children:e,className:t,...n},r){return(0,J.jsx)(`div`,{...n,className:B(`caps-input-group join flex w-full items-stretch [&>*]:join-item [&>*:first-child]:rounded-e-none [&>*:last-child]:rounded-s-none [&>*:not(:first-child):not(:last-child)]:rounded-none [&>.btn]:shrink-0 [&>.input]:min-w-0 [&>.input]:flex-1 [&>.select]:min-w-0 [&>.select]:flex-1`,t),ref:r,children:q.Children.map(e,e=>(0,q.isValidElement)(e)?(0,q.cloneElement)(e,{className:B(`join-item caps-input-group-control`,e.props.className)}):e)})}),ry=(0,q.forwardRef)(function({className:e,...t},n){return(0,J.jsx)(`div`,{...t,className:B(`join-item flex items-center border border-base-300 bg-base-200 px-md text-sm text-base-content`,e),ref:n})});function iy(e){let t=e.parentElement;if(!t||e.previousElementSibling===null)return 0;let n=getComputedStyle(t);if(!(n.display.includes(`grid`)||n.display.includes(`flex`)&&n.flexDirection.startsWith(`column`)))return 0;let r=Number.parseFloat(n.rowGap);return Number.isFinite(r)?r:0}(0,q.forwardRef)(function({show:e,appear:t=!1,children:n,className:r,...i},a){let o=(0,q.useRef)(null);(0,q.useImperativeHandle)(a,()=>o.current);let s=le(),[c,l]=(0,q.useState)(e),u=(0,q.useRef)(!0);return e&&!c&&l(!0),(0,q.useLayoutEffect)(()=>{let n=o.current,r=u.current;if(u.current=!1,!n||r&&!t)return;if(!y(n)){e||l(!1);return}let i=kt(n),a=`translateY(${String(i.distance)}px)`,c=de(i,i.ease),d=n.getBoundingClientRect().height,f=iy(n),p=(e,t)=>{n.style.overflow=`clip`;let r=e=>({height:`${String(e)}px`,marginBlockStart:`${String(e===0?-f:0)}px`}),a=n.animate([r(e),r(t)],{duration:i.normal,easing:c}),o=()=>{n.style.removeProperty(`overflow`)};return a.addEventListener(`finish`,o),a.addEventListener(`cancel`,o),a};if(e){let e=[n.animate([{opacity:0,transform:a},{opacity:1,transform:`none`}],{duration:i.normal,easing:c})];return!s&&d>0&&e.push(p(0,d)),()=>{for(let t of e)t.cancel()}}let m=n.animate([{opacity:1,transform:`none`},{opacity:0,transform:a}],{duration:i.fast,easing:de(i,i.easeExit),fill:`forwards`}),h=!s&&d>0?p(d,0):m;return h!==m&&h.effect?.updateTiming({fill:`forwards`}),h.addEventListener(`finish`,()=>{l(!1)}),()=>{m.cancel(),h.cancel()}},[e,t,s]),c?(0,J.jsx)(`div`,{...i,ref:o,className:B(`caps-presence`,r),"data-present":e,"aria-hidden":!e||void 0,children:n}):null});var ay=(0,q.forwardRef)(function({open:e,children:t,className:n,...r},i){return(0,J.jsx)(`div`,{...r,ref:i,className:B(`caps-collapse`,n),"data-open":e,"aria-hidden":!e||void 0,children:(0,J.jsx)(`div`,{className:`caps-collapse-clip`,children:t})})});(0,q.forwardRef)(function({swapKey:e,anchor:t=`start`,children:n,className:r,...i},a){let o=(0,q.useRef)(null);(0,q.useImperativeHandle)(a,()=>o.current);let s=le(),[c,l]=(0,q.useState)({key:e,content:n}),[u,d]=(0,q.useState)([]);c.key===e?c.content!==n&&l({key:e,content:n}):(d([...u.filter(t=>t.key!==e&&t.key!==c.key),c]),l({key:e,content:n}));let f=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{let e=o.current;if(!e||!(`ResizeObserver`in globalThis))return;f.current=e.getBoundingClientRect();let t=new ResizeObserver(()=>{e.getAnimations().length===0&&(f.current=e.getBoundingClientRect())});return t.observe(e),()=>{t.disconnect()}},[]),(0,q.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=[...e.querySelectorAll(`:scope > [data-swap-leaving]`)],n=e.querySelector(`:scope > [data-swap-current]`);if(n===null||t.length===0)return;if(!y(e)){d([]);return}let r=f.current,i=e.getBoundingClientRect(),a=kt(e),c=[n.animate([{opacity:0,filter:`blur(${String(a.blur)}px)`,transform:`translateY(${String(a.distance/2)}px)`},{opacity:1,filter:`blur(0px)`,transform:`none`}],{duration:a.normal,easing:de(a,a.ease)})];for(let e of t){let t=e.animate([{opacity:1,filter:`blur(0px)`,transform:`none`},{opacity:0,filter:`blur(${String(a.blur)}px)`,transform:`translateY(${String(-a.distance/2)}px)`}],{duration:a.fast,easing:de(a,a.easeExit),fill:`forwards`}),n=e.dataset.swapLeaving;t.onfinish=()=>{d(e=>e.filter(e=>e.key!==n))},c.push(t)}let l=r!==null&&(Math.abs(r.height-i.height)>.5||Math.abs(r.width-i.width)>.5);return!s&&l&&c.push(e.animate([{width:`${String(r.width)}px`,height:`${String(r.height)}px`},{width:`${String(i.width)}px`,height:`${String(i.height)}px`}],{duration:a.normal,easing:de(a,a.ease)})),()=>{for(let e of c)e.cancel()}},[e,s]),(0,J.jsx)(`div`,{...i,ref:o,className:B(`caps-swap`,r),"data-anchor":t,children:[...u.map(e=>(0,J.jsx)(`div`,{className:`caps-swap-layer`,"data-swap-leaving":e.key,"aria-hidden":`true`,children:e.content},e.key)),(0,J.jsx)(`div`,{className:`caps-swap-layer`,"data-swap-current":``,children:n},e)]})});function oy({children:e,...t}){let[n,r]=(0,q.useState)(e);return e&&e!==n&&r(e),(0,J.jsx)(ay,{...t,className:B(`caps-field-error-reveal`,t.className),open:!!e,children:(0,J.jsx)(`div`,{className:`caps-field-error`,role:`alert`,"aria-hidden":!e,children:n})})}function sy({children:e,divider:t=!0,error:n,layout:r=`end`,status:i,...a}){return(0,J.jsxs)(`footer`,{...a,className:B(`caps-form-footer`,a.className),"data-divider":t,"data-layout":r,children:[(0,J.jsx)(oy,{children:n}),(0,J.jsxs)(`div`,{className:`caps-form-footer-row`,children:[i?(0,J.jsx)(`div`,{className:`caps-form-footer-status`,role:`status`,children:i}):null,(0,J.jsx)(`div`,{className:`caps-form-footer-actions`,children:e})]})]})}var cy=(0,q.forwardRef)(function({busy:e=!1,children:t,className:n,layout:r,...i},a){return(0,J.jsx)(`form`,{...i,"aria-busy":e||void 0,className:B(`caps-form`,n),"data-layout":r,ref:a,children:(0,J.jsx)(`fieldset`,{className:`caps-form-body`,disabled:e,children:t})})}),ly={2:`h2`,3:`h3`,4:`h4`},uy=(0,q.forwardRef)(function({children:e,className:t,description:n,layout:r,level:i=3,title:a,...o},s){let c=(0,q.useId)(),l=ly[i];return(0,J.jsxs)(`section`,{...o,"aria-labelledby":`${c}-title`,className:B(`caps-form-section`,t),"data-layout":r,ref:s,children:[(0,J.jsxs)(`header`,{className:`caps-form-section-copy`,children:[(0,J.jsx)(l,{className:`caps-form-section-title`,id:`${c}-title`,children:a}),n?(0,J.jsx)(`p`,{className:`caps-form-section-description`,children:n}):null]}),(0,J.jsx)(`div`,{className:`caps-form-section-fields`,children:e})]})}),dy=(0,q.forwardRef)(function({children:e,className:t,description:n,error:r,icon:i,layout:a,legend:o,legendTitle:s,...c},l){let u=(0,q.useId)(),d=[n?`${u}-description`:c[`aria-describedby`],r?`${u}-error`:null].filter(Boolean).join(` `)||void 0;return(0,J.jsxs)(`fieldset`,{...c,"aria-describedby":d,"aria-invalid":r?!0:c[`aria-invalid`],className:B(`caps-fieldset`,t),"data-layout":a,ref:l,children:[(0,J.jsxs)(`legend`,{className:`caps-fieldset-legend`,title:s,children:[i?(0,J.jsx)(`span`,{className:`caps-field-icon`,"aria-hidden":`true`,children:i}):null,o]}),n?(0,J.jsx)(`p`,{className:`caps-fieldset-description`,id:`${u}-description`,children:n}):null,(0,J.jsx)(`div`,{className:`caps-fieldset-fields`,children:e}),r===void 0?null:(0,J.jsx)(oy,{id:`${u}-error`,children:r})]})});function fy(e){let t=[];return q.Children.forEach(e.props.children,e=>{(0,q.isValidElement)(e)&&e.type!==ry&&t.push(e)}),t[0]??null}var py=(0,q.forwardRef)(function({children:e,className:t,description:n,error:r,icon:i,label:a,labelTitle:o,optional:s,orientation:c=`vertical`,readout:l=!1,required:u,...d},f){let p=(0,q.useId)(),m=(0,q.isValidElement)(e)?e:null,h=m?.type===ny,g=h?fy(m):m,_=g?.props.id??p,v=`${_}-description`,y=`${_}-error`,b=[g?.props[`aria-describedby`],n?v:null,r?y:null].filter(Boolean).join(` `)||void 0,x=u===!0||g?.props.required,S=r?!0:g?.props[`aria-invalid`],C=u===!0||g?.props[`aria-required`],w={id:_};x!==void 0&&(w.required=x),b!==void 0&&(w[`aria-describedby`]=b),S!==void 0&&(w[`aria-invalid`]=S),C!==void 0&&(w[`aria-required`]=C);let T=m&&g&&!l?h?(0,q.cloneElement)(m,void 0,q.Children.map(m.props.children,e=>e===g?(0,q.cloneElement)(g,w):e)):(0,q.cloneElement)(m,w):e,E=a?(0,J.jsx)(ty,{htmlFor:l?void 0:_,title:o,className:c===`inline`?`font-normal`:void 0,...u===void 0?{}:{required:u},...s===void 0?{}:{optional:s},children:a}):null,D=a||n?(0,J.jsxs)(`div`,{className:`caps-field-copy`,children:[E,n?(0,J.jsx)(`p`,{className:`caps-field-description`,id:v,children:n}):null]}):null,O=i?(0,J.jsxs)(`div`,{className:`caps-field-lead`,children:[(0,J.jsx)(`span`,{className:`caps-field-icon`,"aria-hidden":`true`,children:i}),D]}):D;return(0,J.jsxs)(`div`,{...d,className:B(`caps-field`,t),"data-orientation":c,ref:f,children:[c===`horizontal`?(0,J.jsxs)(`div`,{className:`caps-field-row`,children:[O,T]}):c===`inline`?(0,J.jsxs)(`div`,{className:`caps-field-row`,children:[T,O]}):(0,J.jsxs)(J.Fragment,{children:[O,T]}),(0,J.jsx)(oy,{id:y,children:r})]})});function my(e){let t=String(e),n=t.indexOf(`.`);return n===-1?0:t.length-n-1}var hy=`M 9.86 38.14 A 20 20 0 1 1 38.14 38.14`,gy=6,_y=new Map([[`ArrowUp`,1],[`ArrowDown`,-1],[`PageUp`,10],[`PageDown`,-10]]),vy=(0,q.forwardRef)(function({className:e,decrementLabel:t=`Decrease`,defaultValue:n=null,disabled:r,incrementLabel:i=`Increase`,invalid:a,max:o,min:s,onBlur:c,onKeyDown:l,onValueChange:u,step:d=1,unit:f,value:p,wrap:m=!1,...h},g){let[_,v]=(0,q.useState)(n),[y,b]=(0,q.useState)(null),x=p===void 0?_:p,S=my(d),C=e=>{let t=Number(e.toFixed(S));return s!==void 0&&t<s?s:o!==void 0&&t>o?o:t},w=e=>{let t=e===null?null:C(e);v(t),b(null),t!==x&&u?.(t)},T=()=>{if(y===null)return;let e=Number(y);w(y.trim()===``||!Number.isFinite(e)?null:e)},E=e=>{let t=(x??s??0)+e*d;if(m&&s!==void 0&&o!==void 0){if(t>o){w(s);return}if(t<s){w(o);return}}w(t)},D=s!==void 0&&x!==null&&x<=s,O=o!==void 0&&x!==null&&x>=o,k=r===!0,A=(0,q.useRef)(null),j=s!==void 0&&o!==void 0&&o>s?((x??s)-s)/(o-s):null,M=e=>{k||(e.currentTarget.setPointerCapture(e.pointerId),A.current={y:e.clientY,value:x??s??0})},ee=e=>{if(!A.current)return;let t=Math.trunc((A.current.y-e.clientY)/gy),n=C(A.current.value+t*d);n!==x&&w(n)},N=()=>{A.current=null};return(0,J.jsxs)(`span`,{className:B(`caps-number-field`,e),"data-at-max":O||void 0,"data-at-min":D||void 0,"data-disabled":k||void 0,"data-wrap":m||void 0,children:[j===null?null:(0,J.jsxs)(`svg`,{className:`caps-number-field-dial`,viewBox:`0 0 48 48`,"aria-hidden":`true`,focusable:`false`,onPointerDown:M,onPointerMove:ee,onPointerUp:N,onPointerCancel:N,children:[(0,J.jsx)(`path`,{className:`caps-number-field-dial-track`,d:hy,pathLength:100}),(0,J.jsx)(`path`,{className:`caps-number-field-dial-level`,d:hy,pathLength:100,strokeDasharray:`${String(Math.max(.5,j*100))} 100`})]}),(0,J.jsx)(W,{type:`button`,variant:`outline`,size:`icon`,className:`caps-number-field-decrement`,"aria-label":t,"aria-controls":h.id,tabIndex:-1,disabled:k||D&&!m,onClick:()=>{E(-1)},children:(0,J.jsx)(gh,{"aria-hidden":`true`})}),(0,J.jsxs)(`span`,{className:`caps-number-field-readout`,children:[(0,J.jsx)(`input`,{...h,"aria-invalid":a?!0:h[`aria-invalid`]===!1?void 0:h[`aria-invalid`],className:`input caps-input caps-number-field-input`,disabled:r,inputMode:h.inputMode??(S>0?`decimal`:`numeric`),max:o,min:s,onBlur:e=>{T(),c?.(e)},onChange:e=>{b(e.target.value)},onKeyDown:e=>{if(l?.(e),e.defaultPrevented)return;let t=_y.get(e.key);t===void 0?e.key===`Home`&&s!==void 0?(e.preventDefault(),w(s)):e.key===`End`&&o!==void 0?(e.preventDefault(),w(o)):e.key===`Enter`&&T():(e.preventDefault(),E(t))},ref:g,step:d,type:`number`,value:y??(x===null?``:String(x))}),f?(0,J.jsx)(`span`,{className:`caps-number-field-unit`,"aria-hidden":`true`,children:f}):null]}),(0,J.jsx)(W,{type:`button`,variant:`outline`,size:`icon`,className:`caps-number-field-increment`,"aria-label":i,"aria-controls":h.id,tabIndex:-1,disabled:k||O&&!m,onClick:()=>{E(1)},children:(0,J.jsx)(bh,{"aria-hidden":`true`})})]})}),yy=(0,q.forwardRef)(function({className:e,invalid:t,...n},r){return(0,J.jsxs)(`span`,{className:`caps-select-shell`,children:[(0,J.jsx)(`select`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:B(`select select-bordered caps-select w-full`,t&&`select-error`,e),ref:r}),!n.multiple&&(!n.size||n.size<=1)?(0,J.jsx)(Jn,{className:`caps-select-chevron`,"aria-hidden":`true`}):null]})}),by={2:`h2`,3:`h3`,4:`h4`};function xy(e,t){let{reduced:n}=t,r=e&&!n,i=o(t,600),[a,s]=(0,q.useState)(r);return(0,q.useEffect)(()=>{if(s(r),!r)return;let e=globalThis.setTimeout(()=>{s(!1)},i);return()=>{globalThis.clearTimeout(e)}},[r,i]),a}var Sy=(0,J.jsx)(yn,{decorative:!0,pace:`idle`,size:`md`,tone:`primary`,variant:`wander`}),Cy=(0,q.forwardRef)(function({actions:e,secondaryAction:t,className:n,description:r,headingLevel:i=2,primaryAction:a,suggestions:o,thinking:s=!1,title:c,visual:l,renderVisual:u,variant:d=`plain`,...f},p){let m=(0,q.useId)(),h=(0,q.useRef)(null),g=ae(h),_=xy(d===`speech`,g)&&!s,v=by[i],y=l??(d===`panel`?`blobs`:void 0),b=u?u({speaking:_,thinking:s}):y===`blobs`?Sy:y,x=`${m}-reason`,S=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(v,{ref:h,className:`empty-state-title`,id:f[`aria-labelledby`]?void 0:m,children:c}),(0,J.jsx)(`p`,{children:r}),a?(0,J.jsxs)(`div`,{className:`empty-state-primary`,children:[(0,J.jsxs)(`div`,{className:`empty-state-action-row`,children:[(0,J.jsx)(W,{"aria-describedby":a.disabled&&a.disabledReason?x:void 0,disabled:a.disabled,loading:a.pending===!0,onClick:a.onSelect,variant:`primary`,children:a.label}),t]}),a.disabled&&a.disabledReason?(0,J.jsx)(`span`,{className:`empty-state-reason`,id:x,children:a.disabledReason}):null]}):null,o&&o.length>0?(0,J.jsx)(`ul`,{"aria-label":`Try one of these`,className:`empty-state-suggestions`,children:o.map((e,t)=>(0,J.jsx)(`li`,{children:(0,J.jsx)(W,{disabled:e.disabled,loading:e.pending===!0,size:`sm`,variant:`outline`,onClick:e.onSelect,children:e.label})},`${String(t)}:${e.label}`))}):null,e?(0,J.jsx)(`div`,{className:`empty-state-actions`,children:e}):null]});return(0,J.jsxs)(`section`,{...f,"aria-labelledby":f[`aria-labelledby`]??m,className:B(`empty-state`,d!==`plain`&&`empty-state-${d}`,n),ref:p,children:[b?(0,J.jsx)(`div`,{"aria-hidden":`true`,className:`empty-state-visual`,children:b}):null,d===`speech`?(0,J.jsx)(`div`,{className:`empty-state-bubble`,children:S}):S]})}),wy=8e3,Ty=(0,q.forwardRef)(function({className:e,detail:t,framed:n=!0,icon:r,message:i,onRetry:a,size:o=`md`,slowAfterMs:s=wy,variant:c=`line`,...l},u){let[d,f]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(f(!1),!Number.isFinite(s))return;let e=globalThis.setTimeout(()=>{f(!0)},s);return()=>{globalThis.clearTimeout(e)}},[s,i]),(0,J.jsxs)(`div`,{...l,className:B(`caps-loading-state`,e),"data-framed":n?void 0:`false`,"data-icon":r?``:void 0,"data-size":o,"data-slow":d||void 0,ref:u,role:`status`,children:[r?(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`caps-loading-state-icon`,children:r}):null,(0,J.jsx)(yn,{decorative:!0,size:o,variant:c}),(0,J.jsxs)(`span`,{className:`caps-loading-state-copy`,children:[(0,J.jsx)(`span`,{children:i}),t?(0,J.jsx)(`span`,{className:`caps-loading-state-detail`,children:t}):null,d?(0,J.jsx)(`span`,{className:`caps-loading-state-detail`,children:`Still working…`}):null]}),d&&a?(0,J.jsx)(W,{className:`caps-loading-state-retry`,size:`sm`,variant:`outline`,onClick:a,children:`Retry`}):null]})}),Ey=`file-tree-container`,Dy=`data-file-tree-style`,Oy=`data-file-tree-unsafe-css`,ky=`data-file-tree-scrollbar-measure`,Ay=`data-file-tree-scrollbar-gutter-measured`,jy=`--trees-scrollbar-gutter-measured`,My=`header`,Ny=`context-menu`,Py=`context-menu-trigger`,Fy=typeof window>`u`?q.useEffect:q.useLayoutEffect;function Iy(e,t,n){let r=e==null?null:(0,J.jsx)(`div`,{slot:My,children:e}),i=t!=null&&n!=null?(0,J.jsx)(`div`,{slot:Ny,children:t(n.item,n.context)}):null;return r==null&&i==null?null:(0,J.jsxs)(J.Fragment,{children:[r,i]})}function Ly(e,t){return typeof window>`u`&&t!=null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t.shadowHtml}}),e]}):(0,J.jsx)(J.Fragment,{children:e})}function Ry(e){let t=e.shadowRoot;return t?.querySelector(`[data-file-tree-id]`)instanceof HTMLElement||t?.querySelector(`[data-file-tree-id]`)instanceof SVGElement||e.querySelector(`template[shadowrootmode="open"]`)instanceof HTMLTemplateElement}function zy(e,t,n,r,i){let a={...e??{}};if(t!=null&&delete a.header,n){let t=e?.contextMenu,n=t?.onClose,o=t?.onOpen;a.contextMenu={...t??{},enabled:!0,onClose:()=>{n?.(),r()},onOpen:(e,t)=>{i(e,t),o?.(e,t)}},delete a.contextMenu.render}return a.header!=null||a.contextMenu!=null?a:void 0}function By({header:e,id:t,model:n,preloadedData:r,renderContextMenu:i,...a}){let[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),u=(0,q.useRef)(n.getComposition()),d=(0,q.useRef)(n);d.current!==n&&(d.current=n,u.current=n.getComposition());let f=i!=null,p=(0,q.useCallback)(()=>{s(null)},[]),m=(0,q.useCallback)((e,t)=>{s({context:t,item:e})},[]),h=u.current,g=(0,q.useMemo)(()=>zy(h,e,f,p,m),[h,p,m,f,e]),_=(0,q.useCallback)(e=>{l(e)},[]);(0,q.useEffect)(()=>{f||s(null)},[f]),Fy(()=>{n.setComposition(g)},[g,n]),Fy(()=>{if(c!=null)return r!=null&&Ry(c)?n.hydrate({fileTreeContainer:c}):n.render({fileTreeContainer:c}),()=>{n.unmount(),n.setComposition(h)}},[h,c,n,r]);let v=Ly(Iy(e,i,o),r),y=t??r?.id,b={"--trees-item-height":`${String(n.getItemHeight())}px`,"--trees-density-override":n.getDensityFactor(),...a.style};return(0,J.jsx)(Ey,{...a,id:y,ref:_,style:b,suppressHydrationWarning:r!=null,children:v})}var Vy=`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
3
- <symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
4
- <path d="M12.4697 5.46973C12.7626 5.17684 13.2374 5.17684 13.5303 5.46973C13.8232 5.76262 13.8232 6.23738 13.5303 6.53028L8.53028 11.5303C8.23738 11.8232 7.76262 11.8232 7.46973 11.5303L2.46973 6.53028C2.17684 6.23738 2.17684 5.76262 2.46973 5.46973C2.76262 5.17684 3.23738 5.17684 3.53028 5.46973L8 9.93946L12.4697 5.46973Z" fill="currentcolor"/>
5
- </symbol>
6
- <symbol id="file-tree-icon-dot" viewBox="0 0 6 6">
7
- <circle cx="3" cy="3" r="3" />
8
- </symbol>
9
- <symbol id="file-tree-icon-file" viewBox="0 0 16 16">
10
- <path fill="currentColor" d="M8 1v3a3 3 0 0 0 3 3h3v5.5a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 2 12.5v-9A2.5 2.5 0 0 1 4.5 1z" class="bg" opacity=".5"/>
11
- <path fill="currentColor" d="M9.5 1a.5.5 0 0 1 .354.146l4 4A.5.5 0 0 1 14 5.5V6h-3a2 2 0 0 1-2-2V1z" class="fg"/>
12
- </symbol>
13
- <symbol id="file-tree-icon-lock" viewBox="0 0 16 16">
14
- <path fill="currentcolor" d="M4 5.336V4a4 4 0 1 1 8 0v1.336c1.586.54 2 1.843 2 4.664v1c0 4.118-.883 5-5 5H7c-4.117 0-5-.883-5-5v-1c0-2.821.414-4.124 2-4.664M5.5 4v1.054Q6.166 4.998 7 5h2q.834-.002 1.5.054V4a2.5 2.5 0 0 0-5 0m-2 6v1c0 .995.055 1.692.167 2.193.107.483.246.686.35.79s.307.243.79.35c.5.112 1.198.167 2.193.167h2c.995 0 1.692-.055 2.193-.166.483-.108.686-.247.79-.35.104-.105.243-.308.35-.791.112-.5.167-1.198.167-2.193v-1c0-.995-.055-1.692-.166-2.193-.108-.483-.247-.686-.35-.79-.105-.104-.308-.243-.791-.35C10.693 6.555 9.995 6.5 9 6.5H7c-.995 0-1.692.055-2.193.167-.483.107-.686.246-.79.35s-.243.307-.35.79C3.555 8.307 3.5 9.005 3.5 10" />
15
- </symbol>
16
- <symbol id="file-tree-icon-ellipsis" viewBox="0 0 16 16">
17
- <path d="M5 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M9.5 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M14 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0" />
18
- </symbol>
19
- </svg>`,Hy=`<symbol id="file-tree-builtin-astro" viewBox="0 0 16 16">
20
- <path fill="currentColor" d="M6.08 13.92c-.63-.57-.81-1.79-.55-2.67.45.56 1.08.73 1.73.83 1 .15 1.99.1 2.92-.37l.32-.19q.13.38.08.78a2.1 2.1 0 0 1-.9 1.5q-.3.24-.61.43c-.64.44-.81.95-.57 1.69l.02.08a1.7 1.7 0 0 1-.74-.64 2 2 0 0 1-.3-.98q0-.27-.02-.52-.07-.61-.61-.62a.7.7 0 0 0-.75.6z" class="bg" opacity=".6"/>
21
- <path fill="currentColor" d="M2.5 11.1s1.86-.9 3.72-.9l1.4-4.39c.05-.21.2-.36.38-.36s.33.15.38.36l1.4 4.38c2.2 0 3.72.92 3.72.92l-3.16-8.69q-.13-.4-.45-.42H6.11q-.3.02-.45.42z" class="fg"/>
22
- </symbol>`,Uy=`<symbol id="file-tree-builtin-babel" viewBox="0 0 16 16">
23
- <path fill="currentColor" fill-rule="evenodd" d="M9.49.5q1.92.05 2.66.54 1.27.6 1.35 1.52v.23a4 4 0 0 1-.53 1.9l-1.38 1.24q-.74.38-.72.63c.77.82 1.33 1.29.85 2.42q-.47 1.1-2.04 2.28c-.5.32-1.88 1.35-2.96 1.86-1.64.77-3.1 1.4-4.65 1.89-.51.16-1.5.16-1.5.16L.5 15A76 76 0 0 0 5.76 3.49q-.1-.08-.1-.2.1 0 .32-.35l-.03-.09q-1.17.39-2.38 1.3l-.13.03q0-.1-.21-.16-.46.31-.82.7l-.13-.19.16-.06-.03-.16-.34.29L2 4.5q.36-.48.72-.54l.04-.1V3.8q.16 0 .15-.06l.13-.06a6 6 0 0 0 1.13-.9v-.03H4.1l-.12.07q0-.1-.1-.1l-.15.07-.04-.1q.93-.52 1.63-1.05Q7.89.65 9.5.5M8.46 7.83l-.32.04c-1.31.54-2.31.82-2.91.88a71 71 0 0 0-2.2 4.54h.07q.58-.04 3.04-1.42.13 0 1.66-1.05L9.18 9.7v.03q.45-.2.81-1.3v-.2q-.5-.46-1.53-.4m.28-5.75c-.5.1-.75.19-.72.38l-1.16 2.6q-.17.1-.34.95-.3.48-.25.77v.1l.22.05A15 15 0 0 1 8.86 6c1.1-.71 2.12-1.38 2.8-2.54q.24-.33.21-.54-.02-.33-.4-.54c-.54 0-1.07-.34-1.63-.28l-.94-.03z" clip-rule="evenodd"/>
24
- </symbol>`,Wy=`<symbol id="file-tree-builtin-bash" viewBox="0 0 16 16">
25
- <path fill="currentColor" d="M8 1C2.24 1 1 2.24 1 8s1.24 7 7 7 7-1.24 7-7-1.24-7-7-7" class="bg" opacity=".2"/>
26
- <path fill="currentColor" d="M11.5 11a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1zM7 6.75C7 6.42 6.64 6 6 6s-1 .42-1 .75q-.01.25.22.41.26.21.89.35.74.14 1.28.53c.37.29.61.7.61 1.21 0 .87-.68 1.5-1.5 1.7v.55a.5.5 0 0 1-1 0v-.56c-.82-.18-1.5-.82-1.5-1.69a.5.5 0 0 1 1 0c0 .33.36.75 1 .75s1-.42 1-.75q.01-.25-.22-.41a2 2 0 0 0-.89-.35q-.74-.14-1.28-.53A1.5 1.5 0 0 1 4 6.75c0-.87.68-1.5 1.5-1.7V4.5a.5.5 0 0 1 1 0v.56c.82.18 1.5.82 1.5 1.69a.5.5 0 0 1-1 0" class="fg-stroke"/>
27
- </symbol>`,Gy=`<symbol id="file-tree-builtin-biome" viewBox="0 0 16 16">
28
- <path fill="currentColor" d="M8 2 4.88 7.35a7 7 0 0 1 3.7-.13l1.04.25-.99 4.16-1.05-.25a2.7 2.7 0 0 0-3.07 1.45l-.98-.47a4 4 0 0 1 1.07-1.31 3.8 3.8 0 0 1 3.23-.71l.5-2.08a6 6 0 0 0-5.07 1.12A5.9 5.9 0 0 0 1 14h14z"/>
29
- </symbol>`,Ky=`<symbol id="file-tree-builtin-bootstrap" viewBox="0 0 16 16">
30
- <path fill="currentColor" fill-rule="evenodd" d="M11.72 1.5A2.5 2.5 0 0 1 14.2 4q.02 1.08.3 2.09c.22.73.56 1.24 1.08 1.45.22.08.4.27.4.5s-.18.43-.4.51q-.76.34-1.08 1.45c-.2.65-.27 1.32-.3 2a2.5 2.5 0 0 1-2.48 2.5H4.25A2.6 2.6 0 0 1 1.7 12c-.04-.85-.1-1.68-.22-2.04C1.26 9.23.92 8.7.4 8.5.18 8.42 0 8.23 0 8s.18-.42.4-.5q.77-.35 1.09-1.46c.1-.36.17-1.19.2-2.04a2.6 2.6 0 0 1 2.56-2.5z" class="bg" clip-rule="evenodd" opacity=".2"/>
31
- <path fill="currentColor" fill-rule="evenodd" d="M8.47 4.54c1.23 0 2.04.68 2.04 1.73 0 .73-.55 1.39-1.24 1.5v.04c.94.1 1.58.77 1.58 1.7 0 1.2-.9 1.95-2.37 1.95H5.97a.3.3 0 0 1-.2-.08.3.3 0 0 1-.08-.2V4.82a.3.3 0 0 1 .08-.2.3.3 0 0 1 .2-.08zm-1.7 6.04h1.49q1.47-.01 1.49-1.15Q9.74 8.31 8.2 8.3H6.77zm0-5.16v2.06h1.21c.93 0 1.45-.38 1.45-1.06 0-.65-.44-1-1.22-1z" class="fg" clip-rule="evenodd"/>
32
- </symbol>`,qy=`<symbol id="file-tree-builtin-browserslist" viewBox="0 0 16 16">
33
- <path fill="currentColor" d="M8.88 6.96c0 3.82 3.72 4.7 5.7 3.74-.23.9-1.04 1.67-2.35 1.93-.02.4.42 1.28.82 1.63-.9.35-1.94-.12-2.51-.48a5 5 0 0 0-.32 1.87c-.68 0-1.57-1-1.8-1.37-.3.18-.85 1.15-.96 1.72a2.4 2.4 0 0 1-.81-.86 2.4 2.4 0 0 1-.3-1.15c-.38.27-1.48.95-1.99 1.18-.25-.58-.15-1.3 0-2.06-.21.12-1.8.27-2.43.12.32-.36.75-1.19.94-1.57A4.5 4.5 0 0 1 .44 10.6c.48-.22.97-.53 1.49-1.06C1.26 9.17.24 8.64 0 7.7a6 6 0 0 0 1.79-.32C1.28 7.08.44 6.15.6 5.01c.42.21 1.3.37 1.73.3a3.4 3.4 0 0 1-.25-2.75 5 5 0 0 0 1.48 1c-.08-.8.3-2.31.8-2.71.2.46.73 1.21 1.08 1.4.09-.61.87-2.06 1.57-2.25 0 .5.27 1.4.5 1.67.51-.54 2.25-1.44 3.64-1.13-.43.45-.75.61-.86.98 1.05 0 2.78.34 4.27 1.93-2.34-.89-5.69.56-5.69 3.5" class="bg" opacity=".5"/>
34
- <path fill="currentColor" d="M11.21 3.59a4.1 4.1 0 0 0 2.47 2.89c.24-.22.61-.38.95-.19.76.44.2 1.26-.34 1.66l-.07.06a13 13 0 0 1-4.49 1.61l-.3-.43a10.5 10.5 0 0 0 4.13-1.31 1 1 0 0 0 .23-.25.5.5 0 0 0-.21-.69l-.15-.06a4.5 4.5 0 0 1-1.77-1.31 4.5 4.5 0 0 1-.88-1.77q.2-.12.43-.21"/>
35
- <path fill="currentColor" d="M10.36 5.18a.4.4 0 0 0-.03.38c.09.2.3.3.46.23s.24-.3.15-.5l-.01-.02q.23.13.34.39a.83.83 0 0 1-.43 1.08.8.8 0 0 1-1.08-.43.83.83 0 0 1 .6-1.13"/>
36
- </symbol>`,Jy=`<symbol id="file-tree-builtin-bun" viewBox="0 0 16 16">
37
- <path fill="currentColor" d="M8 14c3.87 0 7-2.46 7-5.49 0-1.88-1.2-3.53-3.04-4.52q-1.1-.61-1.84-1.07C9.2 2.35 8.64 2 8 2s-1.36.45-2.31 1.03A29 29 0 0 1 4.04 4C2.2 4.98 1 6.63 1 8.51 1 11.54 4.13 14 8 14M7.18 3.88q.3-.66.3-1.37c0-.08.11-.1.13-.01.38 1.57-.53 2.35-1.2 2.61-.08.03-.12-.07-.06-.12a3 3 0 0 0 .83-1.12m1.2-.05a3 3 0 0 0-.45-1.3V2.5c-.04-.07.05-.15.1-.1 1.15 1.2.77 2.3.33 2.87-.05.05-.13 0-.11-.08q.21-.67.13-1.37m1.04-.32a3 3 0 0 0-.94-1.02v-.01c-.06-.05-.01-.16.07-.12 1.51.61 1.61 1.8 1.43 2.5l-.03.03a.07.07 0 0 1-.1-.06 3 3 0 0 0-.43-1.32m-2.97.32c-.36.3-.74.43-1.2.56q-.11 0-.1-.1a3.5 3.5 0 0 0 1.76-1.57s.09-.07.1.04c0 .18-.2.76-.56 1.07m2.89 6.36q-.13.52-.55.88a1.3 1.3 0 0 1-.75.35 1.3 1.3 0 0 1-.77-.35 1.7 1.7 0 0 1-.54-.88.13.13 0 0 1 .15-.15h2.31a.14.14 0 0 1 .15.15M6.15 8.95a1.1 1.1 0 0 1-1.39-.14A1.1 1.1 0 0 1 5.12 7a1.1 1.1 0 0 1 1.2.25 1.1 1.1 0 0 1-.17 1.69m4.96 0a1.1 1.1 0 0 1-1.4-.14 1.1 1.1 0 0 1 .37-1.8 1.1 1.1 0 0 1 1.2.25 1.1 1.1 0 0 1 .24 1.2 1 1 0 0 1-.41.5"/>
38
- </symbol>`,Yy=`<symbol id="file-tree-builtin-c" viewBox="0 0 16 16">
39
- <path fill="currentColor" fill-rule="evenodd" d="M8 1q.084 0 .166.021.098.023.186.075c1.055.624 4.22 2.486 5.277 3.11.085.05.15.112.209.192h-.002l.028.037a.5.5 0 0 1 .103.21q.031.102.033.21v6.29a.71.71 0 0 1-.347.616l-5.307 3.144a.68.68 0 0 1-.693 0l-5.307-3.144A.72.72 0 0 1 2 11.145V4.832a.71.71 0 0 1 .346-.612l5.288-3.126A.7.7 0 0 1 7.992 1zm2.901 4.349a3.75 3.75 0 1 0 0 5.302l-1.06-1.06a2.25 2.25 0 1 1 0-3.182z" clip-rule="evenodd"/>
40
- </symbol>`,Xy=`<symbol id="file-tree-builtin-claude" viewBox="0 0 16 16">
41
- <path fill="currentColor" d="M3.75 10.31 6.5 8.77l.04-.14-.04-.07h-.14l-.46-.03-1.57-.04-1.38-.07-1.33-.07-.34-.07L1 7.86l.03-.21.28-.18.4.03.89.07 1.33.08.97.06 1.43.16h.22l.03-.1-.07-.05-.06-.06-1.39-.92-1.48-.98-.79-.57-.42-.28-.2-.28-.1-.6.39-.41.52.04.12.03.52.4 1.12.86L6.2 6.04l.2.17.09-.06.01-.04-.1-.15-.76-1.46-.85-1.46-.37-.6-.1-.36a1 1 0 0 1-.06-.42l.42-.59.25-.07.6.08.22.2.36.84.58 1.3.9 1.77.29.53.14.47.04.14h.1v-.07l.07-1 .14-1.22.14-1.57.04-.45.23-.53.42-.28.36.15.28.41-.04.25-.16 1.08-.36 1.7-.21 1.14h.12l.14-.15.58-.76.97-1.2.42-.5.5-.51.32-.25h.6l.44.66-.2.68-.61.79-.52.65-.74 1-.45.8.04.05h.1l1.68-.36.9-.16 1.06-.18.5.23.05.22-.2.48-1.15.28-1.34.28-2 .46-.04.01.03.04.9.09.4.03h.94l1.77.14.46.28.27.37-.04.28-.72.37-.95-.23-2.24-.53-.76-.18h-.11v.06l.64.63L12 10.86l1.48 1.35.07.34-.18.28-.2-.03-1.29-.98-.5-.42-1.12-.95h-.07v.1l.25.38 1.37 2.05.07.63-.1.2-.36.14-.38-.08-.8-1.12-.85-1.26-.66-1.15-.07.05-.4 4.23-.19.21-.42.17-.35-.28-.2-.42.2-.87.23-1.12.18-.9.17-1.1.1-.36v-.03h-.1l-.84 1.16-1.27 1.72-1 1.07-.24.1-.42-.22.04-.39.22-.32 1.4-1.8.84-1.1.57-.64-.02-.07h-.04l-3.7 2.4-.66.09-.28-.28.03-.42.14-.14 1.12-.77z"/>
42
- </symbol>`,Zy=`<symbol id="file-tree-builtin-cpp" viewBox="0 0 16 16">
43
- <path fill="currentColor" fill-rule="evenodd" d="M8 1q.084 0 .166.021.098.023.186.075c1.055.624 4.22 2.486 5.277 3.11.085.05.15.112.209.192h-.002l.028.037a.5.5 0 0 1 .103.21q.031.102.033.21v6.29a.71.71 0 0 1-.347.616l-5.307 3.144a.68.68 0 0 1-.693 0l-5.307-3.144A.72.72 0 0 1 2 11.145V4.832a.71.71 0 0 1 .346-.612l5.288-3.126A.7.7 0 0 1 7.992 1zm2.901 4.349a3.75 3.75 0 1 0 0 5.302l-1.06-1.06a2.25 2.25 0 1 1 0-3.182z" clip-rule="evenodd"/>
44
- </symbol>`,Qy=`<symbol id="file-tree-builtin-css" viewBox="0 0 16 16">
45
- <path fill="currentColor" d="M8 15c-5.76 0-7-1.24-7-7V2a1 1 0 0 1 1-1h6c5.77 0 7 1.24 7 7s-1.24 7-7 7" class="vector" opacity=".2"/>
46
- <path fill="currentColor" d="M10.1 9.19h.73c.03.49.22.6 1 .6.76 0 .93-.12.93-.68 0-.52-.17-.67-.94-.85-1.38-.3-1.68-.56-1.68-1.47 0-1.05.3-1.29 1.67-1.29 1.29 0 1.57.2 1.6 1.13h-.74c-.01-.34-.17-.42-.85-.42-.77 0-.94.1-.94.58 0 .42.17.55.96.73 1.36.3 1.66.58 1.66 1.59 0 1.14-.31 1.39-1.73 1.39-1.39 0-1.69-.24-1.67-1.31m-3.9 0h.74c.03.49.21.6.99.6.76 0 .93-.12.93-.68 0-.52-.17-.67-.93-.85-1.39-.3-1.69-.56-1.69-1.47 0-1.05.3-1.29 1.67-1.29 1.3 0 1.58.2 1.6 1.13h-.73c-.02-.34-.18-.42-.85-.42-.78 0-.95.1-.95.58 0 .42.17.55.96.73 1.37.3 1.67.58 1.67 1.59 0 1.14-.32 1.39-1.74 1.39-1.38 0-1.68-.24-1.66-1.31m-1.22 0h.75c-.09 1.07-.37 1.31-1.56 1.31-1.37 0-1.68-.45-1.68-2.5 0-1.96.36-2.5 1.68-2.5 1.16 0 1.44.25 1.52 1.35h-.76c-.08-.52-.22-.64-.76-.64-.74 0-.9.33-.9 1.78 0 1.47.16 1.8.9 1.8.58 0 .74-.11.8-.6"/>
47
- </symbol>`,$y=`<symbol id="file-tree-builtin-database" viewBox="0 0 16 16">
48
- <path fill="currentColor" d="M14.953 9.733a12.4 12.4 0 0 1-.244 1.936c-.207.933-.532 1.58-.996 2.044s-1.11.789-2.044.996C10.73 14.918 9.533 15 8 15s-2.73-.082-3.669-.291c-.933-.207-1.58-.532-2.044-.996s-.789-1.11-.996-2.044c-.122-.547-.2-1.182-.244-1.92q.23.364.532.667c.64.639 1.482 1.031 2.533 1.265 1.046.232 2.33.315 3.884.315 1.555 0 2.838-.083 3.884-.315 1.051-.234 1.893-.626 2.532-1.265a4 4 0 0 0 .541-.683"/>
49
- <path fill="currentColor" d="M14.93 5.924c-.046.663-.118 1.24-.23 1.743-.207.932-.532 1.579-.995 2.042s-1.11.789-2.042.996c-.938.209-2.135.291-3.667.291-1.531 0-2.729-.082-3.667-.29-.932-.208-1.579-.534-2.042-.997s-.789-1.11-.996-2.042a12 12 0 0 1-.227-1.683l.016-.188a4 4 0 0 0 .5.62c.638.639 1.48 1.031 2.532 1.265 1.046.232 2.33.315 3.884.315 1.555 0 2.838-.083 3.884-.315 1.051-.234 1.893-.626 2.532-1.265.192-.192.357-.404.506-.633z"/>
50
- <path fill="currentColor" d="M8 1c1.533 0 2.73.082 3.669.291.933.207 1.58.533 2.044.996.403.404.904.944.91 1.695.004.764-.509 1.318-.918 1.727-.463.463-1.11.789-2.042.996-.938.209-2.135.291-3.667.291-1.531 0-2.729-.082-3.667-.29-.932-.208-1.579-.534-2.042-.997-.406-.406-.915-.953-.915-1.71 0-.758.509-1.305.915-1.712.464-.463 1.11-.789 2.044-.996C5.27 1.082 6.467 1 8 1"/>
51
- </symbol>`,eb=`<symbol id="file-tree-builtin-default" viewBox="0 0 16 16">
52
- <path fill="currentColor" d="M8 1v3a3 3 0 0 0 3 3h3v5.5a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 2 12.5v-9A2.5 2.5 0 0 1 4.5 1z" class="bg" opacity=".4"/>
53
- <path fill="currentColor" d="M9.5 1a.5.5 0 0 1 .354.146l4 4A.5.5 0 0 1 14 5.5V6h-3a2 2 0 0 1-2-2V1z" class="fg"/>
54
- </symbol>`,tb=`<symbol id="file-tree-builtin-docker" viewBox="0 0 16 16">
55
- <path fill="currentColor" d="M15.85 6.54c-.05-.04-.45-.36-1.31-.36q-.34 0-.68.06a2.7 2.7 0 0 0-1.14-1.79l-.23-.14-.15.23a3 3 0 0 0-.4 1q-.24 1.01.26 1.84c-.4.24-1.03.3-1.17.3H.5a.5.5 0 0 0-.5.52q-.01 1.46.46 2.83.55 1.5 1.6 2.18c.79.5 2.08.79 3.54.79q.96 0 1.94-.18a8 8 0 0 0 2.55-.97 7 7 0 0 0 1.73-1.5 10 10 0 0 0 1.7-3.06h.15a2.4 2.4 0 0 0 1.8-.7 2 2 0 0 0 .47-.74l.06-.2z"/>
56
- <path fill="currentColor" d="M1.48 7.36h1.4a.14.14 0 0 0 .14-.13V5.91q-.01-.12-.13-.14H1.48a.13.13 0 0 0-.13.14v1.32q.02.13.13.13m1.94 0h1.41a.14.14 0 0 0 .13-.13V5.91q-.01-.12-.13-.14h-1.4a.13.13 0 0 0-.13.14v1.32q0 .13.12.13m1.98 0h1.4q.13 0 .14-.13V5.91a.13.13 0 0 0-.14-.14H5.4q-.1.01-.12.14v1.32q0 .13.12.13m1.95 0h1.42q.1 0 .12-.13V5.91q0-.12-.12-.14H7.35q-.1.01-.12.14v1.32q.01.13.12.13M3.42 5.5h1.41c.07 0 .13-.08.13-.15V4.03a.13.13 0 0 0-.13-.14h-1.4q-.12 0-.13.14v1.31q0 .13.12.15m1.98 0h1.4c.08 0 .14-.08.14-.15V4.03q0-.13-.14-.14H5.4q-.1 0-.12.14v1.31q0 .13.12.15m1.95 0h1.42c.06 0 .12-.08.12-.15V4.03q-.01-.13-.12-.14H7.35q-.1 0-.12.14v1.31q.01.13.12.15m0-1.9h1.42q.1-.02.12-.14v-1.3Q8.88 2 8.77 2H7.35q-.1 0-.12.14v1.3q.01.13.12.14m1.97 3.78h1.4a.13.13 0 0 0 .14-.13V5.91q-.01-.12-.13-.14H9.32q-.1.01-.12.14v1.32q.01.13.12.13" opacity=".5"/>
57
- </symbol>`,nb=`<symbol id="file-tree-builtin-eslint" viewBox="0 0 16 16">
58
- <path fill="currentColor" d="M11.16 6.1 8.12 4.35a.3.3 0 0 0-.24 0L4.84 6.1a.3.3 0 0 0-.12.2v3.5q0 .14.12.22l3.04 1.74q.12.08.24 0l3.04-1.74a.2.2 0 0 0 .13-.22V6.3a.3.3 0 0 0-.13-.2" opacity=".5"/>
59
- <path fill="currentColor" d="m.1 7.69 3.63-6.3A.8.8 0 0 1 4.37 1h7.26c.26 0 .5.17.64.4l3.63 6.27a.8.8 0 0 1 0 .75l-3.63 6.24a.7.7 0 0 1-.64.34H4.37a.7.7 0 0 1-.64-.34L.1 8.41a.7.7 0 0 1 0-.72m3 3.02q.01.15.14.23l4.63 2.66q.13.06.26 0l4.63-2.66a.3.3 0 0 0 .14-.23V5.4a.3.3 0 0 0-.14-.23L8.13 2.52a.3.3 0 0 0-.26 0L3.24 5.17a.3.3 0 0 0-.14.23z"/>
60
- </symbol>`,rb=`<symbol id="file-tree-builtin-font" viewBox="0 0 16 16">
61
- <path fill="currentColor" d="M12.3 13c-1.59 0-2.68-.99-2.68-2.5 0-1.43 1-2.34 2.88-2.35h2.16v-.83c0-1.08-.62-1.68-1.73-1.68-1.05 0-1.66.54-1.73 1.36H9.93c.09-1.43 1.06-2.48 3.05-2.48 1.75 0 3.02.95 3.02 2.68v5.66h-1.29v-1.02h-.04c-.41.66-1.16 1.16-2.37 1.16m.36-1.12c1.14 0 2-.72 2-1.74v-.96H12.6c-1.12 0-1.6.54-1.6 1.28 0 .97.8 1.42 1.66 1.42m-11.24.98H0L3.8 2h1.39l3.8 10.86H7.54l-1.08-3.2H2.5zm3.09-9.25h-.04l-1.6 4.95H6.1z"/>
62
- </symbol>`,ib=`<symbol id="file-tree-builtin-git" viewBox="0 0 16 16">
63
- <path fill="currentColor" d="M14.74 7.38 8.62 1.26a.9.9 0 0 0-1.27 0L6.08 2.53l1.61 1.61a1.07 1.07 0 0 1 1.36 1.37l1.55 1.55a1.07 1.07 0 0 1 1.1 1.77 1.07 1.07 0 0 1-1.74-1.16L8.5 6.22v3.8a1.07 1.07 0 1 1-.89-.02V6.15a1.07 1.07 0 0 1-.58-1.4l-1.58-1.6-4.2 4.2a.9.9 0 0 0 0 1.27l6.12 6.12a.9.9 0 0 0 1.27 0l6.09-6.09a.9.9 0 0 0 0-1.27"/>
64
- </symbol>`,ab=`<symbol id="file-tree-builtin-go" viewBox="0 0 16 16">
65
- <path fill="currentColor" fill-rule="evenodd" d="M4.41 4.57A3.2 3.2 0 0 1 6.87 5q.74.49 1.08 1.29.08.12-.1.16l-1.55.4c-.14.03-.15.04-.27-.1a1 1 0 0 0-.44-.34 1.6 1.6 0 0 0-1.68.14q-.95.61-.94 1.73c0 .73.52 1.33 1.25 1.43q.95.1 1.58-.6l.25-.34h-1.8c-.19 0-.24-.12-.17-.27.12-.28.34-.76.47-1a.3.3 0 0 1 .24-.14h2.98a4 4 0 0 1 .64-1.19 4 4 0 0 1 2.6-1.52 3.5 3.5 0 0 1 2.64.46q1.13.73 1.31 2.04a3.5 3.5 0 0 1-1.06 3.09q-.93.92-2.23 1.17l-.74.08a3.5 3.5 0 0 1-2.27-.8 3 3 0 0 1-.93-1.42 4 4 0 0 1-.39.61 4 4 0 0 1-2.64 1.56 3.3 3.3 0 0 1-2.5-.6 3 3 0 0 1-1.18-2.03 3.5 3.5 0 0 1 .8-2.67 4 4 0 0 1 2.6-1.58M13.1 7.5a1.53 1.53 0 0 0-1.9-1.21q-1.3.3-1.62 1.59a1.5 1.5 0 0 0 .85 1.72q.77.33 1.52-.05a2 2 0 0 0 1.18-1.74q0-.17-.03-.3" clip-rule="evenodd"/>
66
- </symbol>`,ob=`<symbol id="file-tree-builtin-graphql" viewBox="0 0 16 16">
67
- <path fill="currentColor" fill-rule="evenodd" d="M8 1a1.25 1.25 0 0 1 1.18 1.65l2.8 1.61q.33-.25.77-.26a1.25 1.25 0 0 1 .48 2.4v3.2a1.25 1.25 0 1 1-1.25 2.13l-2.8 1.62A1.25 1.25 0 0 1 8 15a1.25 1.25 0 0 1-1.18-1.65l-2.8-1.62q-.33.26-.77.27a1.25 1.25 0 0 1-.48-2.4V6.4a1.25 1.25 0 1 1 1.25-2.14l2.8-1.61A1.25 1.25 0 0 1 8 1M4.44 11.14l-.06.13 2.75 1.58a1.25 1.25 0 0 1 1.74 0l2.74-1.58-.05-.13zm3.89-7.68a1.3 1.3 0 0 1-.66 0L4.03 9.77q.37.3.45.78h7.04q.08-.48.45-.78zM4.38 4.73a1.24 1.24 0 0 1-1.02 1.76v3.02l.13.01 3.67-6.35-.03-.02zm4.46-1.56 3.67 6.35.13-.01V6.49a1.25 1.25 0 0 1-1.03-1.76L8.87 3.15z" clip-rule="evenodd"/>
68
- </symbol>`,sb=`<symbol id="file-tree-builtin-html" viewBox="0 0 16 16">
69
- <path fill="currentColor" d="M8 1C2.24 1 1 2.24 1 8s1.24 7 7 7 7-1.24 7-7-1.24-7-7-7" class="bg" opacity=".2"/>
70
- <path fill="currentColor" d="M10.48 3.76a.5.5 0 0 1 .4.58L10.6 5.8h1.14a.5.5 0 0 1 0 1h-1.32L10 9.2h1.08a.5.5 0 0 1 0 1H9.8l-.3 1.64a.5.5 0 1 1-.98-.18l.27-1.46H6.4l-.3 1.64a.5.5 0 1 1-.98-.18l.27-1.46H4.25a.5.5 0 0 1 0-1h1.32L6 6.8H4.93a.5.5 0 0 1 0-1H6.2l.3-1.64a.5.5 0 1 1 .98.18L7.2 5.8h2.4l.3-1.64a.5.5 0 0 1 .58-.4M6.58 9.2h2.4l.44-2.4h-2.4z" class="fg"/>
71
- </symbol>`,cb=`<symbol id="file-tree-builtin-image" viewBox="0 0 16 16">
72
- <path fill="currentColor" d="M12.5 2A2.5 2.5 0 0 1 15 4.5v4.67l-4.05-3.54-4.08 4.08-3-2L1 10.6V4.5A2.5 2.5 0 0 1 3.5 2z" opacity=".3"/>
73
- <path fill="currentColor" d="M15 10.5v1a2.5 2.5 0 0 1-2.5 2.5h-9a2.5 2.5 0 0 1-2.46-2.04L4 9l3 2 4-4zm-7-5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0"/>
74
- </symbol>`,lb=`<symbol id="file-tree-builtin-javascript" viewBox="0 0 16 16">
75
- <path fill="currentColor" d="M8 1C2.24 1 1 2.24 1 8s1.24 7 7 7 7-1.24 7-7-1.24-7-7-7" class="bg" opacity=".2"/>
76
- <path fill="currentColor" d="M8.1 9.64h.95c.04.62.28.76 1.28.76s1.2-.14 1.2-.85c0-.66-.2-.85-1.2-1.07-1.79-.38-2.18-.7-2.18-1.86C8.15 5.3 8.54 5 10.31 5c1.67 0 2.04.26 2.07 1.42h-.95c-.02-.43-.23-.53-1.1-.53-1 0-1.22.14-1.22.74 0 .52.22.7 1.24.92 1.76.38 2.15.73 2.15 2 0 1.44-.4 1.75-2.24 1.75-1.8 0-2.18-.3-2.15-1.66M3.5 9.5h.98c0 .76.15.92.85.92.77 0 .94-.18.94-1.02V5.1h1v4.34c0 1.54-.35 1.87-1.92 1.87-1.55 0-1.89-.32-1.86-1.8"/>
77
- </symbol>`,ub=`<symbol id="file-tree-builtin-json" viewBox="0 0 16 16">
78
- <path fill="currentColor" d="M13.25 11.5V9.75a.5.5 0 0 1 .36-.48l.55-.15a1.16 1.16 0 0 0 0-2.24l-.55-.15a.5.5 0 0 1-.36-.48V4.5a2.5 2.5 0 0 0-2.5-2.5h-.25a.5.5 0 0 0 0 1h.25a1.5 1.5 0 0 1 1.5 1.5v1.75a1.5 1.5 0 0 0 1.09 1.44l.54.15a.16.16 0 0 1 0 .32l-.54.15a1.5 1.5 0 0 0-1.09 1.44v1.75a1.5 1.5 0 0 1-1.5 1.5h-.25a.5.5 0 0 0 0 1h.25a2.5 2.5 0 0 0 2.5-2.5m-10.5 0V9.75a.5.5 0 0 0-.36-.48l-.55-.15a1.16 1.16 0 0 1 0-2.24l.55-.15a.5.5 0 0 0 .36-.48V4.5A2.5 2.5 0 0 1 5.25 2h.25a.5.5 0 0 1 0 1h-.25a1.5 1.5 0 0 0-1.5 1.5v1.75a1.5 1.5 0 0 1-1.09 1.44l-.54.15a.16.16 0 0 0 0 .32l.54.15a1.5 1.5 0 0 1 1.09 1.45v1.74a1.5 1.5 0 0 0 1.5 1.5h.25a.5.5 0 0 1 0 1h-.25a2.5 2.5 0 0 1-2.5-2.5"/>
79
- </symbol>`,db=`<symbol id="file-tree-builtin-markdown" viewBox="0 0 16 16">
80
- <path fill="currentColor" d="M1 12V4h2l2 2.5L7 4h2v8H7V7.5l-2 2-2-2V12zm9-3 3 3.5L16 9h-2V4h-2v5z"/>
81
- </symbol>`,fb=`<symbol id="file-tree-builtin-mcp" viewBox="0 0 16 16">
82
- <path fill="currentColor" d="M9.26-.04a3 3 0 0 1 2 .82 2.8 2.8 0 0 1 .8 2.35 2.9 2.9 0 0 1 2.41.8l.03.02a2.74 2.74 0 0 1 0 3.94l-5.8 5.69-.04.06-.02.07q0 .04.02.07.01.04.04.06l1.2 1.17a.55.55 0 0 1 0 .79.6.6 0 0 1-.81 0l-1.2-1.17a1.3 1.3 0 0 1 0-1.84L13.7 7.1a1.65 1.65 0 0 0 .37-1.82 2 2 0 0 0-.37-.54l-.03-.03a1.73 1.73 0 0 0-2.4 0L6.47 9.4l-.07.06a.58.58 0 0 1-.92-.18.6.6 0 0 1 .12-.6l4.85-4.76a1.65 1.65 0 0 0 0-2.36 1.73 1.73 0 0 0-2.4 0l-6.43 6.3a.6.6 0 0 1-.8 0 .55.55 0 0 1 0-.8L7.25.79a3 3 0 0 1 2-.82"/>
83
- <path fill="currentColor" d="M9.26 2.19a.6.6 0 0 1 .52.34.6.6 0 0 1 0 .43l-.12.18L4.9 7.79a1.65 1.65 0 0 0 0 2.36 1.73 1.73 0 0 0 2.4 0l4.75-4.66a.58.58 0 0 1 .93.18.6.6 0 0 1-.12.61l-4.75 4.66a2.9 2.9 0 0 1-4.01 0 2.75 2.75 0 0 1-.62-3.04A3 3 0 0 1 4.1 7l4.74-4.65a.6.6 0 0 1 .4-.16"/>
84
- </symbol>`,pb=`<symbol id="file-tree-builtin-nextjs" viewBox="0 0 16 16">
85
- <defs>
86
- <linearGradient id="a" x1="4.522" x2="14" y1="3.943" y2="16" gradientUnits="userSpaceOnUse">
87
- <stop stop-color="currentColor"/>
88
- <stop offset="1" stop-color="currentColor" stop-opacity="0"/>
89
- </linearGradient>
90
- </defs>
91
- <path fill="currentColor" d="M3 2h1.522v9.09H3z"/>
92
- <path fill="url(#a)" d="M4.903 2 15 15.075q-.565.5-1.195.925L4.522 3.943z"/>
93
- <path fill="currentColor" d="M12.172 2h-1.508v9.094h1.508z"/>
94
- </symbol>`,mb=`<symbol id="file-tree-builtin-npm" viewBox="0 0 16 16">
95
- <path fill="currentColor" d="M2 1a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1z" class="vector" opacity=".2"/>
96
- <path fill="currentColor" d="M10.5 13H13V3H3v10h5V5.5h2.5z"/>
97
- </symbol>`,hb=`<symbol id="file-tree-builtin-oxc" viewBox="0 0 16 16">
98
- <path fill="currentColor" d="M9.5 1a.5.5 0 0 1 .5.5V3h3.5a.5.5 0 0 1 .38.83L10.5 7.69v1.44q.41.04.95-.16a4 4 0 0 0 .72-.35l.04-.03h.01a.5.5 0 0 1 .67.1l2 2.5a.5.5 0 0 1 0 .62c-.76.96-3.14 2.69-6.89 2.69s-6.13-1.73-6.89-2.69a.5.5 0 0 1 0-.62l2-2.5a.5.5 0 0 1 .67-.1l.05.03.16.09q.22.13.56.26.54.2.95.16V7.69L2.12 3.83A.5.5 0 0 1 2.5 3H6V1.5a.5.5 0 0 1 .5-.5zM7 3.5a.5.5 0 0 1-.5.5H3.6l2.78 3.17a.5.5 0 0 1 .12.33v2a.5.5 0 0 1-.28.45c-.7.35-1.5.15-2.02-.05a5 5 0 0 1-.58-.26l-1.46 1.84c.82.78 2.8 2.02 5.84 2.02s5.02-1.24 5.84-2.02l-1.46-1.83a5 5 0 0 1-.58.26c-.52.2-1.33.39-2.02.04a.5.5 0 0 1-.28-.45v-2a.5.5 0 0 1 .12-.33L12.4 4H9.5a.5.5 0 0 1-.5-.5V2H7z"/>
99
- </symbol>`,gb=`<symbol id="file-tree-builtin-postcss" viewBox="0 0 16 16">
100
- <path fill="currentColor" d="M14.5 8a6.5 6.5 0 0 0-5.9-6.47l5.42 8.93A7 7 0 0 0 14.5 8M2.88 12A6.5 6.5 0 0 0 8 14.5c2.08 0 3.93-.98 5.12-2.5zm8.62-1h1.68L11.5 8.24zm-1-.55a4 4 0 0 1-.7.55h.7zM8 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5M5.5 11h.7a4 4 0 0 1-.7-.55zm-2.68 0H4.5V8.24zm3.76-6.2A4 4 0 0 1 8 4.5q.76 0 1.42.3L8 2.46zM1.5 8q0 1.31.48 2.46L7.4 1.53A6.5 6.5 0 0 0 1.5 8m14 0a7.5 7.5 0 0 1-.99 3.72l-.01.03-.02.03A7.5 7.5 0 0 1 8 15.5a7.5 7.5 0 0 1-6.5-3.75l-.01-.03A7.5 7.5 0 1 1 15.5 8"/>
101
- </symbol>`,_b=`<symbol id="file-tree-builtin-prettier" viewBox="0 0 16 16">
102
- <path fill="currentColor" d="M6 12v1H4.93v-1zm1-2v1H2v-1zm6-4v1h-3V6zm-1-4v1H9V2z"/>
103
- <path fill="currentColor" d="M11.5 10v1H8v-1zM5 6v1H2V6zm5-2v1H9V4z" opacity=".8"/>
104
- <path fill="currentColor" d="M6 14v1H2v-1zm-.5-6v1H2V8zM13 4v1h-3V4zM4.93 2v1H2V2z" opacity=".6"/>
105
- <path fill="currentColor" d="M4.93 12v1H2v-1zM13 8v1H9V8zM5.5 4v1H2V4zM9 2v1H4.93V2z" opacity=".4"/>
106
- </symbol>`,vb=`<symbol id="file-tree-builtin-python" viewBox="0 0 16 16">
107
- <path fill="currentColor" d="M8.33 8.4H10c1.16 0 1.9-.73 1.9-1.86V5.08q0-.24.25-.24h.74c.75 0 1.33.32 1.66.97q.4.73.41 1.46c.09.9.09 1.78-.24 2.67-.25.73-.75 1.3-1.58 1.46h-4.8c-.08 0-.25 0-.25.08v.4s.17.09.25.09h2.82q.34-.02.33.32v1.06c0 .56-.25.97-.75 1.13-.41.16-.83.33-1.24.4a7 7 0 0 1-2.98-.07 3 3 0 0 1-1.16-.49c-.33-.32-.58-.65-.5-1.14v-2.91c0-1.13.67-1.78 1.82-1.78q.89-.1 1.66-.08m2.32 4.86a.65.65 0 0 0-.66-.65c-.34 0-.67.33-.67.65s.33.57.67.65a.65.65 0 0 0 .66-.65" class="bg" opacity=".8"/>
108
- <path fill="currentColor" d="M7.67 7.6H6c-1.16 0-1.9.73-1.9 1.86v1.46q0 .24-.25.24h-.74c-.75 0-1.33-.32-1.66-.97a3 3 0 0 1-.41-1.46 6 6 0 0 1 .24-2.67c.25-.73.75-1.3 1.58-1.46h4.8c.08 0 .25 0 .25-.08v-.4s-.17-.09-.25-.09H4.85c-.24 0-.33-.08-.33-.32V2.65c0-.56.25-.97.75-1.13.41-.16.83-.33 1.24-.4a7 7 0 0 1 2.98.07c.41.09.83.25 1.16.49.33.32.58.65.5 1.13v2.92c0 1.14-.67 1.78-1.82 1.78-.58.08-1.16.08-1.66.08M5.35 2.73c0 .33.25.65.66.65.33 0 .66-.32.66-.65 0-.32-.33-.56-.66-.64a.65.65 0 0 0-.66.64" class="fg"/>
109
- </symbol>`,yb=`<symbol id="file-tree-builtin-react" viewBox="0 0 16 16">
110
- <path fill="currentColor" d="M8 6.65c.73 0 1.31.6 1.31 1.35S8.73 9.35 8 9.35 6.69 8.75 6.69 8 7.27 6.65 8 6.65"/>
111
- <path fill="currentColor" fill-rule="evenodd" d="M8 2.55c1.3-.99 2.59-1.34 3.5-.8.92.55 1.27 1.87 1.08 3.53C14.06 5.94 15 6.9 15 8s-.94 2.06-2.42 2.72c.19 1.65-.16 2.98-1.08 3.52-.91.55-2.2.2-3.5-.8-1.3 1-2.58 1.35-3.5.8-.91-.54-1.27-1.87-1.08-3.52C1.94 10.06 1 9.1 1 8s.94-2.06 2.42-2.72c-.19-1.66.17-2.98 1.08-3.52s2.2-.2 3.5.8M4.26 11.2c-.08 1.34.28 2.03.68 2.26s1.15.22 2.25-.52l.11-.09a12 12 0 0 1-1.24-1.39 11 11 0 0 1-1.8-.41zm7.47-.15q-.83.27-1.79.41-.6.8-1.24 1.4l.11.08c1.1.74 1.86.76 2.25.52.4-.23.76-.92.68-2.26zm-3.04.54a14 14 0 0 1-1.38 0q.34.38.69.7.35-.32.7-.7M8 5.29q-.76 0-1.47.1A13 13 0 0 0 5.07 8a14 14 0 0 0 1.46 2.62 13 13 0 0 0 2.94 0A13 13 0 0 0 10.93 8a14 14 0 0 0-1.46-2.62A13 13 0 0 0 8 5.3M4.64 9.18q-.15.5-.25.96.44.16.94.27a15 15 0 0 1-.7-1.23m6.73 0a15 15 0 0 1-.7 1.23q.5-.11.95-.27a10 10 0 0 0-.25-.96M3.44 6.26C2.27 6.86 1.87 7.53 1.87 8s.4 1.14 1.57 1.74l.13.07q.18-.88.55-1.81a12 12 0 0 1-.55-1.8q-.07.02-.13.06m8.99-.07A12 12 0 0 1 11.88 8q.36.94.55 1.8l.13-.06c1.17-.6 1.56-1.27 1.56-1.74s-.39-1.14-1.56-1.74zm-7.1-.6q-.5.11-.94.27.1.46.25.96a15 15 0 0 1 .69-1.23m5.34 0a15 15 0 0 1 .7 1.23q.14-.5.24-.96-.44-.15-.94-.27M7.18 3.06c-1.09-.74-1.85-.76-2.24-.52s-.76.92-.69 2.26l.01.15a11 11 0 0 1 1.8-.41q.6-.8 1.24-1.4zm3.88-.52c-.4-.24-1.15-.22-2.25.52l-.12.08q.65.6 1.25 1.4.96.15 1.8.41v-.14c.08-1.35-.28-2.04-.68-2.27M8 3.7a10 10 0 0 0-.7.7 14 14 0 0 1 1.4 0 10 10 0 0 0-.7-.7" clip-rule="evenodd"/>
112
- </symbol>`,bb=`<symbol id="file-tree-builtin-ruby" viewBox="0 0 16 16">
113
- <path fill="currentColor" fill-rule="evenodd" d="M11.04 2c.48 0 .92.23 1.18.6l2.54 3.65c.37.52.3 1.23-.15 1.69l-5.58 5.64a1.47 1.47 0 0 1-2.06 0L1.39 7.94a1.3 1.3 0 0 1-.15-1.7l2.54-3.63q.2-.3.5-.45.33-.16.68-.16zm.84 2.17a.5.5 0 0 0-.7-.05L8 6.84 4.83 4.12a.5.5 0 0 0-.65.76L6.65 7H3.5a.5.5 0 0 0 0 1h9a.5.5 0 0 0 0-1H9.35l2.48-2.12a.5.5 0 0 0 .05-.7" clip-rule="evenodd"/>
114
- </symbol>`,xb=`<symbol id="file-tree-builtin-rust" viewBox="0 0 16 16">
115
- <path fill="currentColor" fill-rule="evenodd" d="M8 .8a.2.2 0 0 1 .18.1l.38.6.16.02.5-.53.01-.01a.2.2 0 0 1 .33.08l.25.68.16.05.59-.43h.02a.2.2 0 0 1 .3.14l.12.71.15.08.65-.3a.2.2 0 0 1 .2.02.2.2 0 0 1 .1.18l-.03.72.12.1.71-.16a.2.2 0 0 1 .25.25l-.17.7q.06.06.1.13l.73-.03A.2.2 0 0 1 14 4a.2.2 0 0 1 .02.2l-.3.66.08.14.71.12a.2.2 0 0 1 .14.32l-.43.59.05.16.68.25a.2.2 0 0 1 .07.35l-.53.49.01.16.62.38a.2.2 0 0 1 0 .36l-.62.38-.01.16.53.5a.2.2 0 0 1-.07.34l-.68.25-.05.16.43.59a.2.2 0 0 1-.14.32l-.72.12-.07.15.3.65a.2.2 0 0 1-.02.2.2.2 0 0 1-.18.1l-.72-.03-.1.13.16.7a.2.2 0 0 1-.25.25l-.7-.17-.13.1.03.73a.2.2 0 0 1-.1.18.2.2 0 0 1-.2.02l-.66-.3-.14.08-.12.71a.2.2 0 0 1-.32.14l-.59-.43-.16.05-.25.68a.2.2 0 0 1-.34.07l-.5-.53-.16.01-.38.62a.2.2 0 0 1-.36 0l-.38-.62-.16-.01-.5.53a.2.2 0 0 1-.34-.07l-.25-.68-.16-.05-.59.43a.2.2 0 0 1-.32-.14L5 13.78l-.15-.07-.65.3a.2.2 0 0 1-.2-.02.2.2 0 0 1-.1-.18l.03-.72-.13-.1-.7.16a.2.2 0 0 1-.25-.25l.17-.7-.1-.13-.73.03a.2.2 0 0 1-.2-.3l.3-.66-.08-.14-.71-.12a.2.2 0 0 1-.14-.32l.43-.59-.05-.16-.68-.25A.2.2 0 0 1 1 9.22l.53-.5-.02-.16-.6-.38A.2.2 0 0 1 .8 8a.2.2 0 0 1 .1-.18l.6-.38.02-.16-.53-.5a.2.2 0 0 1 .07-.34l.68-.25.05-.16-.43-.59a.2.2 0 0 1 .14-.32L2.2 5l.08-.15L2 4.2a.2.2 0 0 1 .2-.3l.72.03.1-.13-.16-.7a.2.2 0 0 1 .25-.25l.7.16.13-.1-.03-.72A.2.2 0 0 1 4 2a.2.2 0 0 1 .2-.02l.65.3L5 2.2l.12-.71v-.03a.2.2 0 0 1 .32-.1l.59.41.16-.04.25-.68.01-.02A.2.2 0 0 1 6.8.99l.49.53.16-.02.38-.61.02-.02A.2.2 0 0 1 8 .79M6.8 9.45h1.26l.06.01q.03.01.03.05v1.52q0 .07-.09.06h-4.5A5.4 5.4 0 0 0 8 13.42a5.4 5.4 0 0 0 4.45-2.33h-2.42c-.36 0-.68-.5-.77-.75-.08-.22-.2-.91-.25-1.12-.15-.61-.59-.71-.78-.73H6.8zM8 2.58a5.4 5.4 0 0 0-4.07 1.85h5.74l.17.02c.23.03.6.12.96.35.34.23.83.68.83 1.4 0 .66-.55 1.16-1.08 1.5.42.33.7.53.86 1.44.04.17.34.32.62.29.29-.03.62-.16.62-.75v-.24q0-.1.07-.1h.68A5.43 5.43 0 0 0 8 2.59M2.96 6.03a5.4 5.4 0 0 0-.19 3.37h1.66V6.03zM6.8 7.06h1.66c.35 0 .77-.12.77-.47 0-.42-.55-.53-.65-.53H6.8z" clip-rule="evenodd"/>
116
- </symbol>`,Sb=`<symbol id="file-tree-builtin-sass" viewBox="0 0 16 16">
117
- <path fill="currentColor" fill-rule="evenodd" d="M8.08 1.44c2.41-.91 4.96-.37 5.35 1.27.39 1.62-.92 3.56-2.6 4.25a5 5 0 0 1-3.26.35c-.58-.2-.92-.62-1-.85-.03-.09-.09-.24 0-.3.05-.03.08-.02.22.15s.7.6 1.75.48c2.78-.34 4.45-2.64 3.92-3.88-.37-.87-2.5-1.26-5.18.16C4.03 4.81 3.85 6.24 3.82 6.8c-.08 1.5 1.73 2.28 2.7 3.4q.04.03.07.08c.3-.12.7-.19 1.35-.2 1.58-.03 2.47 1.08 2.43 2.08-.03.78-.7 1.1-.82 1.13-.1.01-.14.02-.15-.06q-.03-.06.13-.15c.16-.09.42-.3.48-.72.05-.43-.24-1.44-1.76-1.63a3 3 0 0 0-1.33.08c.27.62.32 1.87-.29 2.83-.63 1-1.8 1.61-2.93 1.27-.37-.1-.93-.92-.45-2.05.46-1.07 2.4-2.12 2.66-2.26-.9-.83-3.08-1.95-3.4-3.65-.08-.49.13-1.65 1.46-2.98a12 12 0 0 1 4.11-2.52m-1.88 9.7c-.01.01-.9.47-1.52 1.17-.59.66-.75 1.48-.43 1.69.3.18 1-.04 1.51-.62a3 3 0 0 0 .5-.9q.2-.64.02-1.39z" clip-rule="evenodd"/>
118
- </symbol>`,Cb=`<symbol id="file-tree-builtin-stylelint" viewBox="0 0 16 16">
119
- <path fill="currentColor" d="M4 3v3.5l1.5-1L7 15 .5 6l1-1.5L0 3l2.5-2h1zm12 0-1.5 1.5 1 1.5L9 15l1.5-9.5 1.5 1V3l.5-2h1zm-8 8.5a.5.5 0 1 1 0 1 .5.5 0 0 1 0-1m0-3a.5.5 0 1 1 0 1 .5.5 0 0 1 0-1m0-3a.5.5 0 1 1 0 1 .5.5 0 0 1 0-1"/>
120
- <path fill="currentColor" d="M6.5 2.5V4l-2 1.5v-4zm5 3L9.5 4V2.5l2-1zM9 4H7V2.5h2z"/>
121
- </symbol>`,wb=`<symbol id="file-tree-builtin-svelte" viewBox="0 0 16 16">
122
- <path fill="currentColor" d="m3.98 3.7 3.36-2.08a4.5 4.5 0 0 1 5.9 1.23 4 4 0 0 1 .7 3.02q-.16.75-.58 1.4c.42.77.56 1.66.4 2.52a3.7 3.7 0 0 1-1.57 2.4l-.17.1-3.36 2.09a4.5 4.5 0 0 1-5.9-1.23 4 4 0 0 1-.66-1.44 4 4 0 0 1-.04-1.58 4 4 0 0 1 .58-1.4 4 4 0 0 1-.4-2.52 3.7 3.7 0 0 1 1.57-2.4zl3.36-2.08zm7.87 0a2.7 2.7 0 0 0-1.26-.95 2.7 2.7 0 0 0-1.6-.07 3 3 0 0 0-.52.2l-.16.09-3.36 2.08a2 2 0 0 0-.69.64 2 2 0 0 0-.36.86 2.3 2.3 0 0 0 .42 1.81A2.7 2.7 0 0 0 7.18 9.4q.28-.06.53-.2l.16-.09 1.28-.79.2-.09a.8.8 0 0 1 .87.31.7.7 0 0 1 .13.55.7.7 0 0 1-.24.4l-.08.05-3.36 2.08-.2.09a1 1 0 0 1-.49-.02 1 1 0 0 1-.38-.3 1 1 0 0 1-.13-.37v-.1l.01-.13-.13-.03a4 4 0 0 1-1.1-.5l-.2-.14-.18-.12-.07.18-.08.3a2.3 2.3 0 0 0 .43 1.82q.45.64 1.19.93.73.28 1.51.14l.16-.04q.27-.07.52-.2l.16-.09 3.36-2.08q.4-.25.69-.64.27-.4.36-.86a2.3 2.3 0 0 0-.42-1.82 2.7 2.7 0 0 0-1.27-.95 2.7 2.7 0 0 0-1.6-.08q-.27.07-.52.2l-.16.1-1.28.79-.2.09a1 1 0 0 1-.49-.03 1 1 0 0 1-.38-.29.7.7 0 0 1-.13-.54.7.7 0 0 1 .24-.4l.08-.06L9.33 4.4l.2-.1a.8.8 0 0 1 .87.32 1 1 0 0 1 .13.38v.22l.11.04q.6.18 1.12.5l.2.14.17.12.06-.19.08-.3a2.3 2.3 0 0 0-.42-1.81z"/>
123
- </symbol>`,Tb=`<symbol id="file-tree-builtin-svg" viewBox="0 0 16 16">
124
- <path fill="currentColor" d="M5 7a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2z"/>
125
- <path fill="currentColor" d="M6 1a5 5 0 0 1 4.58 3H7a3 3 0 0 0-3 3v3.58A5 5 0 0 1 6 1" opacity=".5"/>
126
- </symbol>`,Eb=`<symbol id="file-tree-builtin-svgo" viewBox="0 0 16 16">
127
- <path fill="currentColor" d="M9.43 4.8A.6.6 0 1 1 9.19 6l-.56.96a1.2 1.2 0 0 1 .32 1.58l.7.53a.89.89 0 1 1-.17.22l-.7-.52a1.2 1.2 0 0 1-1.4.25l-.56.87a.75.75 0 1 1-.57-.2 1 1 0 0 1 .32.05l.56-.87a1.2 1.2 0 0 1-.4-1.24l-1.2-.47a.56.56 0 1 1 .1-.28v.02l1.2.47a1.2 1.2 0 0 1 1.56-.55l.56-.97a.6.6 0 0 1-.15-.64.6.6 0 0 1 .63-.4"/>
128
- <path fill="currentColor" fill-rule="evenodd" d="M9.17 1q.16.63.27 1.26a6 6 0 0 1 1.61.67q.52-.38 1.08-.71l1.65 1.64q-.32.56-.68 1.05.48.78.72 1.67.6.09 1.18.25v2.32q-.55.15-1.11.24a6 6 0 0 1-.7 1.82q.31.44.59.91l-1.65 1.65-.85-.55a6 6 0 0 1-1.9.83q-.08.47-.2.95H6.84q-.12-.46-.2-.93a6 6 0 0 1-1.96-.81q-.39.27-.8.51l-1.65-1.65q.25-.43.53-.84a6 6 0 0 1-.75-1.9L1 9.16V6.83q.54-.14 1.09-.24a6 6 0 0 1 .77-1.74q-.33-.47-.63-.98l1.65-1.65q.54.32 1.03.68a6 6 0 0 1 1.66-.66q.1-.61.26-1.24zM7.96 3.73a4 4 0 0 0-1.74.36 4.5 4.5 0 0 0-2.3 2.3 4.4 4.4 0 0 0-.1 3.29l.03.06a4.4 4.4 0 0 0 2.4 2.47 4.4 4.4 0 0 0 3.48-.02l.03-.02a4.4 4.4 0 0 0 2.3-2.42l.06-.14a4.4 4.4 0 0 0-.2-3.4 4.4 4.4 0 0 0-2.13-2.07L9.47 4a4 4 0 0 0-1.51-.27" clip-rule="evenodd"/>
129
- </symbol>`,Db=`<symbol id="file-tree-builtin-swift" viewBox="0 0 16 16">
130
- <path fill="currentColor" d="M9.63 1c6.15 4.35 4.16 9.15 4.16 9.15s1.75 2.05 1.04 3.85c0 0-.72-1.26-1.93-1.26-1.17 0-1.85 1.26-4.2 1.26C3.47 14 1 9.46 1 9.46c4.71 3.22 7.93.94 7.93.94C6.8 9.12 2.29 3 2.29 3c3.93 3.47 5.63 4.39 5.63 4.39-1.01-.87-3.86-5.13-3.86-5.13C6.34 4.66 10.86 8 10.86 8c1.28-3.7-1.23-7-1.23-7"/>
131
- </symbol>`,Ob=`<symbol id="file-tree-builtin-table" viewBox="0 0 16 16">
132
- <path fill="currentColor" d="M8 4a3 3 0 0 0 3 3h3v5.5a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 2 12.5v-9A2.5 2.5 0 0 1 4.5 1H8z" class="bg" opacity=".4"/>
133
- <path fill="currentColor" d="M11.5 8a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-7a.5.5 0 0 1-.5-.5v-4a.5.5 0 0 1 .5-.5zM5 12h2.5v-1H5zm3.5 0H11v-1H8.5zM5 10h2.5V9H5zm3.5 0H11V9H8.5zm1-9a.5.5 0 0 1 .354.146l4 4A.5.5 0 0 1 14 5.5V6h-3a2 2 0 0 1-2-2V1z" class="fg"/>
134
- </symbol>`,kb=`<symbol id="file-tree-builtin-tailwind" viewBox="0 0 16 16">
135
- <path fill="currentColor" fill-rule="evenodd" d="M8 4Q5.2 4 4.5 6.67q1.05-1.34 2.45-1c.53.12.91.5 1.33.9C8.98 7.23 9.77 8 11.5 8q2.8 0 3.5-2.67-1.05 1.34-2.45 1c-.53-.12-.91-.5-1.33-.9C10.52 4.77 9.73 4 8 4M4.5 8Q1.7 8 1 10.67q1.05-1.34 2.45-1c.53.12.91.5 1.33.9C5.48 11.23 6.26 12 8 12q2.8 0 3.5-2.67-1.05 1.34-2.45 1c-.53-.12-.91-.5-1.33-.9C7.02 8.77 6.24 8 4.5 8" clip-rule="evenodd"/>
136
- </symbol>`,Ab=`<symbol id="file-tree-builtin-terraform" viewBox="0 0 16 16">
137
- <path fill="currentColor" d="M1 0v5.05l4.35 2.53V2.53zm9.18 5.34L5.83 2.82v5.05l4.35 2.53zm.47 5.06V5.34L15 2.82v5.05zm-.48 5.6-4.35-2.53V8.42l4.35 2.53z"/>
138
- </symbol>`,jb=`<symbol id="file-tree-builtin-text" viewBox="0 0 16 16">
139
- <path fill="currentColor" fill-rule="evenodd" d="M8 4a3 3 0 0 0 3 3h3v5.5a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 2 12.5v-9A2.5 2.5 0 0 1 4.5 1H8z" class="bg" clip-rule="evenodd" opacity=".4"/>
140
- <path fill="currentColor" d="M8.5 11a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1zm2-2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1zm-1-8a.5.5 0 0 1 .354.146l4 4A.5.5 0 0 1 14 5.5V6h-3a2 2 0 0 1-2-2V1z"/>
141
- </symbol>`,Mb=`<symbol id="file-tree-builtin-typescript" viewBox="0 0 16 16">
142
- <path fill="currentColor" d="M8 1C2.24 1 1 2.24 1 8s1.24 7 7 7 7-1.24 7-7-1.24-7-7-7" class="bg" opacity=".2"/>
143
- <path fill="currentColor" d="M8.1 9.64h.95c.04.62.28.76 1.28.76s1.2-.14 1.2-.85c0-.66-.2-.85-1.2-1.07-1.79-.38-2.18-.7-2.18-1.86C8.15 5.3 8.54 5 10.31 5c1.67 0 2.04.26 2.07 1.42h-.95c-.02-.43-.23-.53-1.1-.53-1 0-1.22.14-1.22.74 0 .52.22.7 1.24.92 1.76.38 2.15.73 2.15 2 0 1.44-.4 1.75-2.24 1.75-1.8 0-2.18-.3-2.15-1.66m-3 1.57V5.99H3.5v-.9h4.21v.9H6.1v5.22z"/>
144
- </symbol>`,Nb=`<symbol id="file-tree-builtin-vite" viewBox="0 0 16 16">
145
- <path fill="currentColor" d="M8.57 14.87c-.18.26-.55.11-.55-.22v-3.18l-.05-.27-.13-.22-.2-.15-.24-.06H4.29c-.26 0-.4-.32-.26-.55L6.08 7c.3-.46 0-1.1-.5-1.1H1.8c-.25 0-.4-.32-.25-.56l2.65-4.2A.3.3 0 0 1 4.46 1h7.9c.26 0 .4.32.26.55l-2.05 3.23c-.29.46 0 1.1.5 1.1h3.12c.26 0 .4.34.24.57z"/>
146
- </symbol>`,Pb=`<symbol id="file-tree-builtin-vscode" viewBox="0 0 16 16">
147
- <path fill="currentColor" d="m5.11 9.68-2.4 1.84a.6.6 0 0 1-.75-.04l-.77-.7a.6.6 0 0 1 0-.87L3.28 8zm5.52-8.42a.51.51 0 0 1 .87.36V4.8L7.32 8 5.1 6.32z" opacity=".75"/>
148
- <path fill="currentColor" d="M11.1 14.99h.03zM1.96 4.52a.6.6 0 0 1 .75-.04l8.8 6.71v3.19a.51.51 0 0 1-.88.36L1.19 6.1a.6.6 0 0 1 0-.87z" opacity=".65"/>
149
- <path fill="currentColor" d="M11.62 14.91a.9.9 0 0 1-1-.17.51.51 0 0 0 .88-.36V1.62a.51.51 0 0 0-.87-.36.9.9 0 0 1 1-.17l2.87 1.39a.9.9 0 0 1 .5.8v9.44a.9.9 0 0 1-.5.8z"/>
150
- </symbol>`,Fb=`<symbol id="file-tree-builtin-vue" viewBox="0 0 16 16">
151
- <path fill="currentColor" d="M9.62 2.25 8 5.02 6.38 2.25H1l7 12 7-12z" opacity=".5"/>
152
- <path fill="currentColor" d="M9.54 2.25 8 4.95l-1.54-2.7H4l4 7 4-7z"/>
153
- </symbol>`,Ib=`<symbol id="file-tree-builtin-wasm" viewBox="0 0 16 16">
154
- <path fill="currentColor" d="M13 1a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h3a2 2 0 1 0 4 0z" class="subtract" opacity=".2"/>
155
- <path fill="currentColor" d="M4.64 11.4h.02l.8-3.4h.91l.73 3.45L7.88 8h.96l-1.25 5h-.97L5.9 9.6 5.1 13h-1L3 8h.98z"/>
156
- <path fill="currentColor" fill-rule="evenodd" d="M13 13h-1.02l-.33-1.11H9.9L9.64 13h-.97l1.26-5h1.54zm-2.49-3.77-.42 1.84h1.32l-.49-1.84z" clip-rule="evenodd"/>
157
- </symbol>`,Lb=`<symbol id="file-tree-builtin-webpack" viewBox="0 0 16 16">
158
- <path fill="currentColor" d="M14.1 11.79 8.26 15v-2.5l3.64-1.94zm.4-.35V4.73l-2.14 1.2v4.3zm-12.6.35L7.74 15v-2.5L4.1 10.56zm-.4-.35V4.73l2.14 1.2v4.3zm.25-7.15 6-3.29v2.42L3.9 5.47l-.03.01zm12.5 0L8.25 1v2.42l3.85 2.05.03.01z" class="bg" opacity=".4"/>
159
- <path fill="currentColor" d="m7.74 11.93-3.59-1.92v-3.8l3.6 2.02zm.52 0 3.59-1.92v-3.8l-3.6 2.02zM4.4 5.77 8 3.85l3.6 1.93L8 7.8z" class="fg"/>
160
- </symbol>`,Rb=`<symbol id="file-tree-builtin-yml" viewBox="0 0 16 16">
161
- <path fill="currentColor" d="M7.5 2A1.5 1.5 0 0 1 9 3.5v3A1.5 1.5 0 0 1 7.5 8h-2v2A1.5 1.5 0 0 0 7 11.5v-1A1.5 1.5 0 0 1 8.5 9h5a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1-1.5 1.5h-5A1.5 1.5 0 0 1 7 13.5v-1A2.5 2.5 0 0 1 4.5 10V8h-2A1.5 1.5 0 0 1 1 6.5v-3A1.5 1.5 0 0 1 2.5 2zm1 8a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h5a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5zm-6-7a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h5a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5z"/>
162
- </symbol>`,zb=`<symbol id="file-tree-builtin-zig" viewBox="0 0 16 16">
163
- <path fill="currentColor" d="m14.73 1.5-7.29 8.82h4.17l-1.73 2.04H5.76L1.27 14.5l7.3-8.91H4.39l1.73-2.05h4.12z"/>
164
- <path fill="currentColor" d="M5.21 3.54 3.56 5.6h-.55v4.73h.83L2.1 12.36H1V3.54zm9.79 0v8.82h-4.3l1.74-2.04h.55V5.68h-.83l1.74-2.14z"/>
165
- </symbol>`,Bb=[Wy,Yy,Zy,Qy,$y,eb,rb,ib,ab,sb,cb,lb,ub,db,fb,vb,bb,xb,Db,Ob,jb,Mb,`<symbol id="file-tree-builtin-zip" viewBox="0 0 16 16">
166
- <path fill="currentColor" d="M4.585 2a2 2 0 0 1 1.028.285l1.788 1.072a1 1 0 0 0 .514.143H12A2 2 0 0 1 13.935 5H0V4a2 2 0 0 1 2-2z" class="bg" opacity=".5"/>
167
- <path fill="currentColor" fill-rule="evenodd" d="M14 12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-1.25h1v-1H0V6h14zM9.9 8.25c-.883 0-1.9.5-1.9.5H7v1h1v1s1.017.5 1.9.5c.884 0 1.6-.672 1.6-1.5s-.716-1.5-1.6-1.5M2 9.75v1h1v-1zm2 0v1h1v-1zm2 0v1h1v-1zm-5-1v1h1v-1zm2 0v1h1v-1zm2 0v1h1v-1z" class="fg" clip-rule="evenodd"/>
168
- </symbol>`],Vb=[Hy,Uy,Gy,Ky,qy,Jy,Xy,tb,nb,ob,pb,mb,hb,gb,_b,yb,Sb,Cb,wb,Tb,Eb,kb,Ab,Nb,Pb,Fb,Ib,Lb,Rb,zb];function Hb(e,t){return t.length===0?e:e.replace(`</svg>`,`\n ${t.join(`
169
- `)}\n</svg>`)}var Ub=Hb(Vy,Bb),Wb={minimal:Vy,standard:Ub,complete:Hb(Ub,Vb)},Gb={".babelrc":`babel`,".babelrc.json":`babel`,".bash_profile":`bash`,".bashrc":`bash`,".browserslistrc":`browserslist`,".dockerignore":`docker`,".eslintignore":`eslint`,".eslintrc":`eslint`,".eslintrc.cjs":`eslint`,".eslintrc.js":`eslint`,".eslintrc.json":`eslint`,".eslintrc.yaml":`eslint`,".eslintrc.yml":`eslint`,".gitattributes":`git`,".gitignore":`git`,".gitkeep":`git`,".gitmodules":`git`,".oxlintrc.json":`oxc`,".postcssrc":`postcss`,".postcssrc.json":`postcss`,".postcssrc.yaml":`postcss`,".postcssrc.yml":`postcss`,".prettierignore":`prettier`,".prettierrc":`prettier`,".prettierrc.cjs":`prettier`,".prettierrc.js":`prettier`,".prettierrc.json":`prettier`,".prettierrc.mjs":`prettier`,".prettierrc.toml":`prettier`,".prettierrc.yaml":`prettier`,".prettierrc.yml":`prettier`,".stylelintignore":`stylelint`,".stylelintrc":`stylelint`,".stylelintrc.cjs":`stylelint`,".stylelintrc.js":`stylelint`,".stylelintrc.json":`stylelint`,".stylelintrc.mjs":`stylelint`,".stylelintrc.yaml":`stylelint`,".stylelintrc.yml":`stylelint`,".terraform.lock.hcl":`terraform`,".zprofile":`bash`,".zshenv":`bash`,".zshrc":`bash`,"babel.config.cjs":`babel`,"babel.config.js":`babel`,"babel.config.json":`babel`,"babel.config.mjs":`babel`,"biome.json":`biome`,"biome.jsonc":`biome`,"bootstrap.bundle.js":`bootstrap`,"bootstrap.bundle.min.js":`bootstrap`,"bootstrap.css":`bootstrap`,"bootstrap.js":`bootstrap`,"bootstrap.min.css":`bootstrap`,"bootstrap.min.js":`bootstrap`,"bun.lock":`bun`,"bun.lockb":`bun`,"bunfig.toml":`bun`,"claude.md":`claude`,"compose.yaml":`docker`,"compose.yml":`docker`,"docker-compose.override.yml":`docker`,"docker-compose.yaml":`docker`,"docker-compose.yml":`docker`,dockerfile:`docker`,"eslint.config.cjs":`eslint`,"eslint.config.js":`eslint`,"eslint.config.mjs":`eslint`,"eslint.config.mts":`eslint`,"eslint.config.ts":`eslint`,gemfile:`ruby`,"next.config.js":`nextjs`,"next.config.mjs":`nextjs`,"next.config.mts":`nextjs`,"next.config.ts":`nextjs`,"postcss.config.cjs":`postcss`,"postcss.config.js":`postcss`,"postcss.config.mjs":`postcss`,"postcss.config.ts":`postcss`,"prettier.config.cjs":`prettier`,"prettier.config.js":`prettier`,"prettier.config.mjs":`prettier`,rakefile:`ruby`,"readme.md":`markdown`,"stylelint.config.cjs":`stylelint`,"stylelint.config.js":`stylelint`,"stylelint.config.mjs":`stylelint`,"svgo.config.cjs":`svgo`,"svgo.config.js":`svgo`,"svgo.config.mjs":`svgo`,"svgo.config.ts":`svgo`,"tailwind.config.cjs":`tailwind`,"tailwind.config.js":`tailwind`,"tailwind.config.mjs":`tailwind`,"tailwind.config.ts":`tailwind`,"vite.config.js":`vite`,"vite.config.mjs":`vite`,"vite.config.mts":`vite`,"vite.config.ts":`vite`,"webpack.config.babel.js":`webpack`,"webpack.config.cjs":`webpack`,"webpack.config.js":`webpack`,"webpack.config.mjs":`webpack`,"webpack.config.ts":`webpack`},Kb={"7z":`zip`,astro:`astro`,AUTHORS:`text`,avif:`image`,bash:`bash`,bmp:`image`,bz2:`zip`,c:`c`,cc:`cpp`,cfg:`text`,CHANGELOG:`text`,cjs:`javascript`,"code-workspace":`vscode`,conf:`text`,CONTRIBUTORS:`text`,cpp:`cpp`,csh:`bash`,css:`css`,csv:`table`,cts:`typescript`,cxx:`cpp`,db:`database`,editorconfig:`text`,env:`text`,"env.development":`text`,"env.local":`text`,"env.production":`text`,eot:`font`,erb:`ruby`,fish:`bash`,gemspec:`ruby`,gif:`image`,go:`go`,gql:`graphql`,graphql:`graphql`,gz:`zip`,h:`c`,hh:`cpp`,hpp:`cpp`,htm:`html`,html:`html`,hxx:`cpp`,icns:`image`,ico:`image`,ini:`text`,inl:`cpp`,jar:`zip`,jpeg:`image`,jpg:`image`,js:`javascript`,json:`json`,json5:`json`,jsonc:`json`,jsonl:`json`,jsx:`javascript`,ksh:`bash`,less:`css`,LICENSE:`text`,log:`text`,markdown:`markdown`,mcp:`mcp`,md:`markdown`,mdx:`markdown`,"mdx.tsx":`markdown`,mjs:`javascript`,mm:`cpp`,mts:`typescript`,ods:`table`,otf:`font`,png:`image`,postcss:`css`,py:`python`,pyi:`python`,pyw:`python`,pyx:`python`,rake:`ruby`,rar:`zip`,rb:`ruby`,rs:`rust`,rst:`text`,rtf:`text`,sass:`css`,scss:`css`,sh:`bash`,sql:`database`,sqlite:`database`,sqlite3:`database`,styl:`css`,svelte:`svelte`,svg:`svg`,swift:`swift`,tar:`zip`,tf:`terraform`,tfstate:`terraform`,tfvars:`terraform`,tgz:`zip`,tif:`image`,tiff:`image`,ts:`typescript`,tsv:`table`,tsx:`typescript`,ttf:`font`,txt:`text`,vue:`vue`,war:`zip`,wasm:`wasm`,wast:`wasm`,wat:`wasm`,webp:`image`,woff:`font`,woff2:`font`,xhtml:`html`,xls:`table`,xlsx:`table`,xz:`zip`,yaml:`yml`,yml:`yml`,zig:`zig`,zip:`zip`,zsh:`bash`},qb={jsx:`react`,sass:`sass`,scss:`sass`,tsx:`react`},Jb=new Set([`bash`,`c`,`cpp`,`css`,`database`,`default`,`font`,`git`,`go`,`html`,`image`,`javascript`,`json`,`markdown`,`mcp`,`python`,`ruby`,`rust`,`swift`,`table`,`text`,`typescript`,`zip`]),Yb=new Set([`complete`]);function Xb(e){return Wb[e===`none`?`minimal`:e]}function Zb(e){return`file-tree-builtin-${e}`}function Qb(e){return e!==`none`&&Yb.has(e)}function $b(e,t,n){if(e===`minimal`||e===`none`)return;let r=e===`complete`,i=Gb[t.toLowerCase()];if(i!=null&&(r||Jb.has(i)))return i;for(let e of n){if(r){let t=qb[e];if(t!=null)return t}let t=Kb[e];if(t!=null&&(r||Jb.has(t)))return t}return`default`}function ex(e){return e.spriteSheet!=null||e.remap!=null||e.byFileName!=null||e.byFileExtension!=null||e.byFileNameContains!=null}function tx(e){return e==null?{set:`complete`,colored:!0}:typeof e==`string`?{set:e,colored:!0}:{...e,set:e.set??(ex(e)?`none`:`complete`),colored:e.colored??!0}}var nx={compact:{itemHeight:24,factor:.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function rx(e,t){if(typeof e==`number`)return{itemHeight:t??nx.default.itemHeight,factor:e};let n=nx[e??`default`];return{itemHeight:t??n.itemHeight,factor:n.factor}}var ix=nx.default.itemHeight,ax=`@layer base {
170
- :host {
171
- --trees-accent: var(--trees-accent-override, #009fff);
172
- --trees-fg: var(--trees-fg-override, var(--trees-theme-sidebar-fg, light-dark(#6c6c71, #adadb1)));
173
- --trees-fg-muted: var(--trees-fg-muted-override, var(--trees-theme-sidebar-header-fg, light-dark(#84848a, #84848a)));
174
- --trees-bg: var(--trees-bg-override, var(--trees-theme-sidebar-bg, light-dark(#f8f8f8, #141415)));
175
- --trees-bg-muted: var(--trees-bg-muted-override, var(--trees-theme-list-hover-bg, light-dark(color-mix(in lab,
176
- var(--trees-accent) var(--trees-bg-alpha-light, 8%),
177
- var(--trees-bg)), color-mix(in lab,
178
- var(--trees-accent) var(--trees-bg-alpha-dark, 10%),
179
- var(--trees-bg)))));
180
- --trees-input-bg: var(--trees-input-bg-override, light-dark(#f8f8f8, #070707));
181
- --trees-added-light: #16a994;
182
- --trees-added-dark: #00cab1;
183
- --trees-ignored-light: #adadb1;
184
- --trees-ignored-dark: #4a4a4e;
185
- --trees-modified-light: #1ca1c7;
186
- --trees-modified-dark: #08c0ef;
187
- --trees-renamed-light: #d5a910;
188
- --trees-renamed-dark: #ffd452;
189
- --trees-untracked-light: #16a994;
190
- --trees-untracked-dark: #00cab1;
191
- --trees-deleted-light: #ff2e3f;
192
- --trees-deleted-dark: #ff6762;
193
- --trees-border-color: var(--trees-border-color-override, var(--trees-theme-sidebar-border, light-dark(#eeeeef, #070707)));
194
- --trees-indent-guide-bg: var(--trees-indent-guide-bg-override, color-mix(in lab, var(--trees-fg-muted) 25%, transparent));
195
- --trees-density: var(--trees-density-override, 1);
196
- --trees-border-radius: var(--trees-border-radius-override, calc(6px * var(--trees-density)));
197
- --trees-font-family: var(--trees-font-family-override, system-ui);
198
- --trees-font-size: var(--trees-font-size-override, 13px);
199
- --trees-font-weight-regular: var(--trees-font-weight-regular-override, 400);
200
- --trees-font-weight-semibold: var(--trees-font-weight-semibold-override, 600);
201
- --trees-focus-ring-color: var(--trees-focus-ring-color-override, var(--trees-theme-focus-ring, var(--trees-accent)));
202
- --trees-focus-ring-width: var(--trees-focus-ring-width-override, 1px);
203
- --trees-focus-ring-offset: var(--trees-focus-ring-offset-override, -1px);
204
- --trees-search-fg: var(--trees-search-fg-override, var(--trees-theme-input-fg, var(--trees-fg)));
205
- --trees-search-font-weight: var(--trees-search-font-weight-override, 600);
206
- --trees-search-bg: var(--trees-search-bg-override, var(--trees-theme-input-bg, var(--trees-input-bg)));
207
- --trees-scrollbar-thumb: var(--trees-scrollbar-thumb-override, var(--trees-theme-scrollbar-thumb, color-mix(in lab, var(--trees-fg) 25%, var(--trees-bg))));
208
- --trees-selected-fg: var(--trees-selected-fg-override, var(--trees-theme-list-active-selection-fg, var(--trees-fg)));
209
- --trees-selected-bg: var(--trees-selected-bg-override, var(--trees-theme-list-active-selection-bg, light-dark(color-mix(in lab, var(--trees-accent) 12%, var(--trees-bg)), color-mix(in lab, var(--trees-accent) 15%, var(--trees-bg)))));
210
- --trees-selected-focused-border-color: var(--trees-selected-focused-border-color-override, var(--trees-theme-focus-ring, var(--trees-accent)));
211
- --trees-status-added: var(--trees-status-added-override, var(--trees-theme-git-added-fg, light-dark(var(--trees-added-light), var(--trees-added-dark))));
212
- --trees-status-ignored: var(--trees-status-ignored-override, var(--trees-theme-git-ignored-fg, light-dark(var(--trees-ignored-light), var(--trees-ignored-dark))));
213
- --trees-status-modified: var(--trees-status-modified-override, var(--trees-theme-git-modified-fg, light-dark(var(--trees-modified-light), var(--trees-modified-dark))));
214
- --trees-status-renamed: var(--trees-status-renamed-override, var(--trees-theme-git-renamed-fg, light-dark(var(--trees-renamed-light), var(--trees-renamed-dark))));
215
- --trees-status-untracked: var(--trees-status-untracked-override, var(--trees-theme-git-untracked-fg, light-dark(var(--trees-untracked-light), var(--trees-untracked-dark))));
216
- --trees-status-deleted: var(--trees-status-deleted-override, var(--trees-theme-git-deleted-fg, light-dark(var(--trees-deleted-light), var(--trees-deleted-dark))));
217
- --trees-git-modified-color: var(--trees-git-modified-color-override, var(--trees-status-modified));
218
- --trees-git-added-color: var(--trees-git-added-color-override, var(--trees-status-added));
219
- --trees-git-ignored-color: var(--trees-git-ignored-color-override, var(--trees-status-ignored));
220
- --trees-git-deleted-color: var(--trees-git-deleted-color-override, var(--trees-status-deleted));
221
- --trees-git-renamed-color: var(--trees-git-renamed-color-override, var(--trees-status-renamed));
222
- --trees-git-untracked-color: var(--trees-git-untracked-color-override, var(--trees-status-untracked));
223
- --trees-icon-gray: light-dark(#84848a, #adadb1);
224
- --trees-icon-red: light-dark(#d52c36, #ff6762);
225
- --trees-icon-vermilion: light-dark(#ff8c5b, #d5512f);
226
- --trees-icon-orange: light-dark(#d47628, #ffa359);
227
- --trees-icon-yellow: light-dark(#d5a910, #ffd452);
228
- --trees-icon-green: light-dark(#199f43, #5ecc71);
229
- --trees-icon-teal: light-dark(#17a5af, #64d1db);
230
- --trees-icon-cyan: light-dark(#1ca1c7, #68cdf2);
231
- --trees-icon-blue: light-dark(#1a85d4, #69b1ff);
232
- --trees-icon-indigo: light-dark(#693acf, #9d6afb);
233
- --trees-icon-purple: light-dark(#a631be, #d568ea);
234
- --trees-icon-pink: light-dark(#d32a61, #ff678d);
235
- --trees-icon-mauve: light-dark(#594c5b, #79697b);
236
- --trees-file-icon-color-default: var(--trees-file-icon-color, var(--trees-icon-gray));
237
- --trees-file-icon-color-astro: var(--trees-file-icon-color, var(--trees-icon-purple));
238
- --trees-file-icon-color-babel: var(--trees-file-icon-color, var(--trees-icon-yellow));
239
- --trees-file-icon-color-bash: var(--trees-file-icon-color, var(--trees-icon-green));
240
- --trees-file-icon-color-biome: var(--trees-file-icon-color, var(--trees-icon-blue));
241
- --trees-file-icon-color-bootstrap: var(--trees-file-icon-color, var(--trees-icon-indigo));
242
- --trees-file-icon-color-browserslist: var(--trees-file-icon-color, var(--trees-icon-yellow));
243
- --trees-file-icon-color-bun: var(--trees-file-icon-color, var(--trees-icon-mauve));
244
- --trees-file-icon-color-c: var(--trees-file-icon-color, var(--trees-icon-blue));
245
- --trees-file-icon-color-cpp: var(--trees-file-icon-color, var(--trees-icon-blue));
246
- --trees-file-icon-color-claude: var(--trees-file-icon-color, var(--trees-icon-orange));
247
- --trees-file-icon-color-css: var(--trees-file-icon-color, var(--trees-icon-indigo));
248
- --trees-file-icon-color-database: var(--trees-file-icon-color, var(--trees-icon-purple));
249
- --trees-file-icon-color-docker: var(--trees-file-icon-color, var(--trees-icon-blue));
250
- --trees-file-icon-color-eslint: var(--trees-file-icon-color, var(--trees-icon-indigo));
251
- --trees-file-icon-color-git: var(--trees-file-icon-vermilion, var(--trees-icon-vermilion));
252
- --trees-file-icon-color-go: var(--trees-file-icon-color, var(--trees-icon-cyan));
253
- --trees-file-icon-color-graphql: var(--trees-file-icon-color, var(--trees-icon-pink));
254
- --trees-file-icon-color-html: var(--trees-file-icon-color, var(--trees-icon-orange));
255
- --trees-file-icon-color-image: var(--trees-file-icon-color, var(--trees-icon-pink));
256
- --trees-file-icon-color-javascript: var(--trees-file-icon-color, var(--trees-icon-yellow));
257
- --trees-file-icon-color-json: var(--trees-file-icon-color, var(--trees-icon-orange));
258
- --trees-file-icon-color-markdown: var(--trees-file-icon-color, var(--trees-icon-green));
259
- --trees-file-icon-color-mcp: var(--trees-file-icon-color, var(--trees-icon-teal));
260
- --trees-file-icon-color-npm: var(--trees-file-icon-color, var(--trees-icon-red));
261
- --trees-file-icon-color-oxc: var(--trees-file-icon-cyan, var(--trees-icon-cyan));
262
- --trees-file-icon-color-postcss: var(--trees-file-icon-color, var(--trees-icon-red));
263
- --trees-file-icon-color-prettier: var(--trees-file-icon-color, var(--trees-icon-teal));
264
- --trees-file-icon-color-python: var(--trees-file-icon-color, var(--trees-icon-blue));
265
- --trees-file-icon-color-react: var(--trees-file-icon-color, var(--trees-icon-cyan));
266
- --trees-file-icon-color-ruby: var(--trees-file-icon-color, var(--trees-icon-red));
267
- --trees-file-icon-color-rust: var(--trees-file-icon-color, var(--trees-icon-orange));
268
- --trees-file-icon-color-sass: var(--trees-file-icon-color, var(--trees-icon-pink));
269
- --trees-file-icon-color-svg: var(--trees-file-icon-color, var(--trees-icon-orange));
270
- --trees-file-icon-color-svelte: var(--trees-file-icon-color, var(--trees-icon-red));
271
- --trees-file-icon-color-svgo: var(--trees-file-icon-color, var(--trees-icon-green));
272
- --trees-file-icon-color-swift: var(--trees-file-icon-color, var(--trees-icon-orange));
273
- --trees-file-icon-color-table: var(--trees-file-icon-color, var(--trees-icon-teal));
274
- --trees-file-icon-color-text: var(--trees-file-icon-color, var(--trees-icon-gray));
275
- --trees-file-icon-color-tailwind: var(--trees-file-icon-color, var(--trees-icon-cyan));
276
- --trees-file-icon-color-terraform: var(--trees-file-icon-color, var(--trees-icon-indigo));
277
- --trees-file-icon-color-typescript: var(--trees-file-icon-color, var(--trees-icon-blue));
278
- --trees-file-icon-color-vite: var(--trees-file-icon-color, var(--trees-icon-purple));
279
- --trees-file-icon-color-vscode: var(--trees-file-icon-color, var(--trees-icon-blue));
280
- --trees-file-icon-color-vue: var(--trees-file-icon-color, var(--trees-icon-green));
281
- --trees-file-icon-color-wasm: var(--trees-file-icon-color, var(--trees-icon-indigo));
282
- --trees-file-icon-color-webpack: var(--trees-file-icon-color, var(--trees-icon-blue));
283
- --trees-file-icon-color-yml: var(--trees-file-icon-color, var(--trees-icon-red));
284
- --trees-file-icon-color-zig: var(--trees-file-icon-color, var(--trees-icon-orange));
285
- --trees-file-icon-color-zip: var(--trees-file-icon-color, var(--trees-icon-orange));
286
- --trees-level-gap: var(--trees-level-gap-override, calc(8px * var(--trees-density)));
287
- --trees-item-padding-x: var(--trees-item-padding-x-override, calc(8px * var(--trees-density)));
288
- --trees-item-margin-x: var(--trees-item-margin-x-override, calc(2px * var(--trees-density)));
289
- --trees-item-row-gap: var(--trees-item-row-gap-override, calc(6px * var(--trees-density)));
290
- --trees-icon-width: var(--trees-icon-width-override, 16px);
291
- --trees-icon-nudge: var(--trees-icon-nudge-override, calc(1px * var(--trees-density)));
292
- --trees-row-height: var(--trees-item-height, 30px);
293
- --trees-git-lane-width: var(--trees-git-lane-width-override, 12px);
294
- --trees-action-lane-width: var(--trees-action-lane-width-override, calc(var(--trees-icon-width) + 2px));
295
- --trees-context-menu-trigger-inline-offset: calc(var(--trees-padding-inline) + var(--trees-item-padding-x) -
296
- var(--trees-focus-ring-width));
297
- --trees-scrollbar-gutter: var(--trees-scrollbar-gutter-override, 6px);
298
- --trees-padding-inline: var(--trees-padding-inline-override, 16px);
299
- color-scheme: light dark;
300
- font-size: var(--trees-font-size);
301
- color: var(--trees-fg);
302
- background-color: var(--trees-bg);
303
- --truncate-marker-background-color: var(--trees-bg);
304
- --truncate-marker-background-overlay-color: transparent;
305
- font-family: var(--trees-font-family);
306
- font-weight: var(--trees-font-weight-regular);
307
- flex-direction: column;
308
- display: flex;
309
- }
310
-
311
- :host([data-file-tree-virtualized="true"]) {
312
- height: 100%;
313
- overflow: hidden;
314
- }
315
-
316
- [data-file-tree-virtualized-wrapper="true"], [data-file-tree-virtualized-root="true"] {
317
- flex-direction: column;
318
- height: 100%;
319
- display: flex;
320
- overflow: hidden;
321
- }
322
-
323
- [data-file-tree-virtualized-scroll="true"], [data-file-tree-scrollbar-measure="true"] {
324
- --trees-scrollbar-thumb-current: transparent;
325
- scrollbar-gutter: stable;
326
- overflow-y: auto;
327
-
328
- &:hover {
329
- --trees-scrollbar-thumb-current: var(--trees-scrollbar-thumb);
330
- }
331
-
332
- &::-webkit-scrollbar {
333
- width: var(--trees-scrollbar-gutter);
334
- height: var(--trees-scrollbar-gutter);
335
- }
336
-
337
- &::-webkit-scrollbar-track {
338
- background: none;
339
- }
340
-
341
- &::-webkit-scrollbar-thumb {
342
- background-color: var(--trees-scrollbar-thumb-current);
343
- border-radius: calc(var(--trees-scrollbar-gutter) / 2);
344
- background-clip: content-box;
345
- border: 1px solid #0000;
346
- }
347
-
348
- &::-webkit-scrollbar-corner {
349
- background-color: #0000;
350
- }
351
- }
352
-
353
- [data-file-tree-scrollbar-measure="true"] {
354
- visibility: hidden;
355
- pointer-events: none;
356
- width: 100px;
357
- height: 100px;
358
- position: absolute;
359
- top: 0;
360
- left: 0;
361
- }
362
-
363
- @supports ((-moz-appearance: none)) {
364
- [data-file-tree-virtualized-scroll="true"], [data-file-tree-scrollbar-measure="true"] {
365
- scrollbar-width: thin;
366
- scrollbar-color: var(--trees-scrollbar-thumb-current) transparent;
367
- }
368
- }
369
-
370
- [data-file-tree-virtualized-scroll="true"] {
371
- min-height: 0;
372
- padding-inline: max(calc(var(--trees-padding-inline) - var(--trees-item-margin-x)),
373
- 0px)
374
- /* NOTE(amadeus): We can assume that all Webkit based browser gutters
375
- * will align to the value of '--trees-scrollbar-gutter', however if not, then
376
- * \`--trees-scrollbar-gutter-measured\` should correct it. Mostly we are
377
- * hoping to avoid SSR alignment jumps if possible. In non-SSR'd environments
378
- * \`--trees-scrollbar-gutter-measured\` should always be immediately available.
379
- */
380
- max(calc(var(--trees-padding-inline) - var(--trees-item-margin-x) -
381
- var(--trees-scrollbar-gutter-measured, var(--trees-scrollbar-gutter))),
382
- 0px);
383
- flex: 1 1 0;
384
- position: relative;
385
- overflow-y: auto;
386
- }
387
-
388
- @supports ((-moz-appearance: none)) {
389
- [data-file-tree-virtualized-scroll="true"] {
390
- padding-inline: max(calc(var(--trees-padding-inline) - var(--trees-item-margin-x)),
391
- 0px)
392
- /* NOTE(amadeus): However on Firefox it can vary a little bit, but most
393
- * likely the majority of cases will default to a 0px width scrollbar lets
394
- * inherit that first to avoid SSR jumps. In non-SSR'd environments
395
- * \`--trees-scrollbar-gutter-measured\` should always be immediately available.
396
- */
397
- max(calc(var(--trees-padding-inline) - var(--trees-item-margin-x) -
398
- var(--trees-scrollbar-gutter-measured, 0px)),
399
- 0px);
400
- }
401
- }
402
-
403
- [data-file-tree-sticky-overlay="true"] {
404
- z-index: 4;
405
- pointer-events: none;
406
- height: 0;
407
- position: sticky;
408
- top: 0;
409
- overflow: visible;
410
- }
411
-
412
- [data-file-tree-virtualized-root="true"][data-scroll-at-top="true"]:not([data-overlay-reveal]) [data-file-tree-sticky-overlay="true"] {
413
- visibility: hidden;
414
- }
415
-
416
- [data-file-tree-sticky-overlay-content="true"] {
417
- background-color: var(--trees-bg);
418
- pointer-events: none;
419
- position: relative;
420
- }
421
-
422
- [data-file-tree-virtualized-list="true"] {
423
- background-color: var(--trees-bg);
424
- overflow-anchor: none;
425
- width: 100%;
426
- min-height: 100%;
427
- position: relative;
428
-
429
- &[data-is-scrolling] {
430
- pointer-events: none;
431
- }
432
- }
433
-
434
- [data-file-tree-virtualized-sticky-offset="true"] {
435
- contain: layout size;
436
- }
437
-
438
- [data-file-tree-virtualized-sticky="true"] {
439
- isolation: isolate;
440
- will-change: transform;
441
- flex-direction: column;
442
- width: 100%;
443
- display: flex;
444
- position: sticky;
445
- top: 0;
446
- }
447
-
448
- [data-file-tree-search-container] {
449
- padding: 0;
450
- padding-inline: var(--trees-padding-inline);
451
- margin-bottom: var(--trees-item-row-gap);
452
- display: flex;
453
- }
454
-
455
- [data-file-tree-search-input] {
456
- --trees-focus-ring-width: 2px;
457
- font-family: var(--trees-font-family);
458
- font-size: var(--trees-font-size);
459
- height: var(--trees-row-height);
460
- padding-inline: var(--trees-item-padding-x);
461
- line-height: var(--trees-row-height);
462
- color: var(--trees-search-fg);
463
- background-color: var(--trees-search-bg);
464
- border: 1px solid var(--trees-border-color);
465
- border-radius: var(--trees-border-radius);
466
- outline: none;
467
- flex: 1;
468
- margin-block: 1px;
469
-
470
- &::placeholder {
471
- color: color-mix(in lab,
472
- var(--trees-search-fg) 65%,
473
- var(--trees-search-bg));
474
- }
475
-
476
- &:focus-visible, &[data-file-tree-search-input-fake-focus="true"] {
477
- outline: var(--trees-focus-ring-width) solid var(--trees-focus-ring-color);
478
- outline-offset: var(--trees-focus-ring-offset);
479
- }
480
- }
481
-
482
- [role="tree"] {
483
- gap: var(--trees-gap-override, 0);
484
- flex-direction: column;
485
- display: flex;
486
- position: relative;
487
- }
488
-
489
- [data-type="item"] {
490
- color: inherit;
491
- font-family: var(--trees-font-family);
492
- font-size: var(--trees-font-size);
493
- text-align: start;
494
- background-color: var(--trees-bg);
495
- padding: 0 var(--trees-item-padding-x);
496
- margin: 0 var(--trees-item-margin-x);
497
- cursor: pointer;
498
- user-select: none;
499
- -webkit-touch-callout: none;
500
- touch-action: manipulation;
501
- flex: 0 0 var(--trees-row-height);
502
- height: var(--trees-row-height);
503
- line-height: var(--trees-row-height);
504
- align-items: center;
505
- gap: var(--trees-item-row-gap);
506
- border-radius: var(--trees-border-radius);
507
- --truncate-marker-background-color: var(--trees-bg);
508
- --truncate-marker-background-overlay-color: transparent;
509
- --truncate-marker-block-inset: 0px;
510
- border: none;
511
- outline: none;
512
- display: flex;
513
- position: relative;
514
-
515
- &:hover, &[data-item-context-hover="true"] {
516
- background-color: var(--trees-bg-muted);
517
- --truncate-marker-background-overlay-color: var(--trees-bg-muted);
518
- }
519
-
520
- &[data-item-focused="true"], &:focus-visible {
521
- z-index: 2;
522
-
523
- & [data-item-flattened-subitems] {
524
- --truncate-marker-block-inset: var(--trees-focus-ring-width);
525
- }
526
-
527
- &:before {
528
- content: "";
529
- border-radius: var(--trees-border-radius);
530
- outline: var(--trees-focus-ring-width) solid
531
- var(--trees-focus-ring-color);
532
- outline-offset: var(--trees-focus-ring-offset);
533
- pointer-events: none;
534
- display: block;
535
- position: absolute;
536
- inset: 0;
537
- }
538
-
539
- &[data-item-selected="true"]:before {
540
- outline-color: var(--trees-selected-focused-border-color);
541
- }
542
- }
543
-
544
- &[data-item-selected="true"] {
545
- color: var(--trees-selected-fg);
546
- background-color: var(--trees-selected-bg);
547
- --truncate-marker-background-overlay-color: var(--trees-selected-bg);
548
- z-index: 3;
549
-
550
- & [data-item-section="icon"] {
551
- color: var(--trees-selected-fg);
552
- }
553
- }
554
-
555
- &[data-item-search-match="true"] {
556
- font-weight: var(--trees-search-font-weight);
557
- }
558
- }
559
-
560
- [data-type="item"][data-file-tree-sticky-row="true"] {
561
- pointer-events: auto;
562
- }
563
-
564
- [data-file-tree-virtualized-root="true"][data-is-scrolling] [data-type="item"][data-file-tree-sticky-row="true"] {
565
- pointer-events: none;
566
- }
567
-
568
- [data-file-tree-virtualized-root="true"][data-is-scrolling] [data-type="item"][data-file-tree-sticky-row="true"]:hover:not([data-item-selected="true"]), [data-file-tree-virtualized-root="true"][data-is-scrolling] [data-type="item"][data-file-tree-sticky-row="true"][data-item-context-hover="true"]:not([data-item-selected="true"]) {
569
- background-color: var(--trees-bg);
570
- --truncate-marker-background-overlay-color: transparent;
571
- }
572
-
573
- [data-item-selected="true"]:has( + [data-item-selected="true"]) {
574
- border-bottom-right-radius: 0;
575
- border-bottom-left-radius: 0;
576
- }
577
-
578
- [data-item-selected="true"] + [data-item-selected="true"] {
579
- border-top-left-radius: 0;
580
- border-top-right-radius: 0;
581
- }
582
-
583
- [data-item-flattened-subitems] {
584
- align-items: center;
585
- gap: 2px;
586
- display: inline-flex;
587
- }
588
-
589
- [data-item-flattened-subitem]:hover, [data-item-flattened-subitem-drag-target="true"] {
590
- text-decoration: underline;
591
- }
592
-
593
- [data-item-section="icon"] {
594
- color: var(--trees-fg-muted);
595
- fill: currentColor;
596
- width: var(--trees-icon-width);
597
- flex-shrink: 0;
598
- justify-content: center;
599
- align-items: center;
600
- display: flex;
601
- }
602
-
603
- :where([data-item-section="icon"] > [data-icon-token]) {
604
- color: var(--trees-fg-muted);
605
- }
606
-
607
- [data-file-tree-colored-icons="true"] {
608
- & [data-icon-token="astro"] {
609
- color: var(--trees-file-icon-color-astro);
610
- }
611
-
612
- & [data-icon-token="babel"] {
613
- color: var(--trees-file-icon-color-babel);
614
- }
615
-
616
- & [data-icon-token="bash"] {
617
- color: var(--trees-file-icon-color-bash);
618
- }
619
-
620
- & [data-icon-token="biome"] {
621
- color: var(--trees-file-icon-color-biome);
622
- }
623
-
624
- & [data-icon-token="bootstrap"] {
625
- color: var(--trees-file-icon-color-bootstrap);
626
- }
627
-
628
- & [data-icon-token="browserslist"] {
629
- color: var(--trees-file-icon-color-browserslist);
630
- }
631
-
632
- & [data-icon-token="bun"] {
633
- color: var(--trees-file-icon-color-bun);
634
- }
635
-
636
- & [data-icon-token="c"] {
637
- color: var(--trees-file-icon-color-c);
638
- }
639
-
640
- & [data-icon-token="cpp"] {
641
- color: var(--trees-file-icon-color-cpp);
642
- }
643
-
644
- & [data-icon-token="claude"] {
645
- color: var(--trees-file-icon-color-claude);
646
- }
647
-
648
- & [data-icon-token="css"] {
649
- color: var(--trees-file-icon-color-css);
650
- }
651
-
652
- & [data-icon-token="database"] {
653
- color: var(--trees-file-icon-color-database);
654
- }
655
-
656
- & [data-icon-token="default"] {
657
- color: var(--trees-file-icon-color-default);
658
- }
659
-
660
- & [data-icon-token="docker"] {
661
- color: var(--trees-file-icon-color-docker);
662
- }
663
-
664
- & [data-icon-token="eslint"] {
665
- color: var(--trees-file-icon-color-eslint);
666
- }
667
-
668
- & [data-icon-token="git"] {
669
- color: var(--trees-file-icon-color-git);
670
- }
671
-
672
- & [data-icon-token="go"] {
673
- color: var(--trees-file-icon-color-go);
674
- }
675
-
676
- & [data-icon-token="graphql"] {
677
- color: var(--trees-file-icon-color-graphql);
678
- }
679
-
680
- & [data-icon-token="html"] {
681
- color: var(--trees-file-icon-color-html);
682
- }
683
-
684
- & [data-icon-token="image"] {
685
- color: var(--trees-file-icon-color-image);
686
- }
687
-
688
- & [data-icon-token="javascript"] {
689
- color: var(--trees-file-icon-color-javascript);
690
- }
691
-
692
- & [data-icon-token="json"] {
693
- color: var(--trees-file-icon-color-json);
694
- }
695
-
696
- & [data-icon-token="markdown"] {
697
- color: var(--trees-file-icon-color-markdown);
698
- }
699
-
700
- & [data-icon-token="mcp"] {
701
- color: var(--trees-file-icon-color-mcp);
702
- }
703
-
704
- & [data-icon-token="npm"] {
705
- color: var(--trees-file-icon-color-npm);
706
- }
707
-
708
- & [data-icon-token="oxc"] {
709
- color: var(--trees-file-icon-color-oxc);
710
- }
711
-
712
- & [data-icon-token="postcss"] {
713
- color: var(--trees-file-icon-color-postcss);
714
- }
715
-
716
- & [data-icon-token="prettier"] {
717
- color: var(--trees-file-icon-color-prettier);
718
- }
719
-
720
- & [data-icon-token="python"] {
721
- color: var(--trees-file-icon-color-python);
722
- }
723
-
724
- & [data-icon-token="react"] {
725
- color: var(--trees-file-icon-color-react);
726
- }
727
-
728
- & [data-icon-token="ruby"] {
729
- color: var(--trees-file-icon-color-ruby);
730
- }
731
-
732
- & [data-icon-token="rust"] {
733
- color: var(--trees-file-icon-color-rust);
734
- }
735
-
736
- & [data-icon-token="sass"] {
737
- color: var(--trees-file-icon-color-sass);
738
- }
739
-
740
- & [data-icon-token="svg"] {
741
- color: var(--trees-file-icon-color-svg);
742
- }
743
-
744
- & [data-icon-token="svelte"] {
745
- color: var(--trees-file-icon-color-svelte);
746
- }
747
-
748
- & [data-icon-token="svgo"] {
749
- color: var(--trees-file-icon-color-svgo);
750
- }
751
-
752
- & [data-icon-token="swift"] {
753
- color: var(--trees-file-icon-color-swift);
754
- }
755
-
756
- & [data-icon-token="table"] {
757
- color: var(--trees-file-icon-color-table);
758
- }
759
-
760
- & [data-icon-token="text"] {
761
- color: var(--trees-file-icon-color-text);
762
- }
763
-
764
- & [data-icon-token="tailwind"] {
765
- color: var(--trees-file-icon-color-tailwind);
766
- }
767
-
768
- & [data-icon-token="terraform"] {
769
- color: var(--trees-file-icon-color-terraform);
770
- }
771
-
772
- & [data-icon-token="typescript"] {
773
- color: var(--trees-file-icon-color-typescript);
774
- }
775
-
776
- & [data-icon-token="vite"] {
777
- color: var(--trees-file-icon-color-vite);
778
- }
779
-
780
- & [data-icon-token="vscode"] {
781
- color: var(--trees-file-icon-color-vscode);
782
- }
783
-
784
- & [data-icon-token="vue"] {
785
- color: var(--trees-file-icon-color-vue);
786
- }
787
-
788
- & [data-icon-token="wasm"] {
789
- color: var(--trees-file-icon-color-wasm);
790
- }
791
-
792
- & [data-icon-token="webpack"] {
793
- color: var(--trees-file-icon-color-webpack);
794
- }
795
-
796
- & [data-icon-token="yml"] {
797
- color: var(--trees-file-icon-color-yml);
798
- }
799
-
800
- & [data-icon-token="zig"] {
801
- color: var(--trees-file-icon-color-zig);
802
- }
803
-
804
- & [data-icon-token="zip"] {
805
- color: var(--trees-file-icon-color-zip);
806
- }
807
- }
808
-
809
- [data-icon-name="file-tree-icon-chevron"] {
810
- &[data-align-capitals="false"] {
811
- transform: translate(0, var(--trees-icon-nudge));
812
- }
813
-
814
- &[data-align-capitals="true"] {
815
- transform: translate(0);
816
- }
817
- }
818
-
819
- [data-item-section="content"] {
820
- text-align: start;
821
- text-overflow: ellipsis;
822
- flex: 0 auto;
823
- min-width: 0;
824
- max-width: 100%;
825
- overflow: hidden;
826
- }
827
-
828
- [data-item-section="decoration"] {
829
- text-align: end;
830
- min-width: 0;
831
- color: var(--trees-fg-muted);
832
- flex: 1 1 0;
833
- justify-content: flex-end;
834
- display: flex;
835
- overflow: hidden;
836
- }
837
-
838
- [data-item-section="decoration"] > span {
839
- text-overflow: ellipsis;
840
- white-space: nowrap;
841
- justify-content: flex-end;
842
- align-items: center;
843
- min-width: 0;
844
- max-width: 100%;
845
- display: inline-flex;
846
- overflow: hidden;
847
- }
848
-
849
- [data-item-section="git"], [data-item-section="action"] {
850
- flex: none;
851
- justify-content: center;
852
- align-items: center;
853
- display: flex;
854
- }
855
-
856
- [data-item-section="git"] {
857
- width: var(--trees-git-lane-width);
858
- }
859
-
860
- [data-item-section="action"] {
861
- width: var(--trees-action-lane-width);
862
- color: var(--trees-fg-muted);
863
- fill: currentColor;
864
- pointer-events: none;
865
- }
866
-
867
- [data-item-section="git"] > span, [data-item-section="action"] > span {
868
- justify-content: center;
869
- align-items: center;
870
- width: 100%;
871
- display: inline-flex;
872
- }
873
-
874
- [data-item-action-affordance="decorative"] {
875
- opacity: .85;
876
- }
877
-
878
- [data-item-rename-input] {
879
- appearance: none;
880
- width: 100%;
881
- min-width: 0;
882
- height: calc(var(--trees-row-height) - 4px);
883
- font-family: inherit;
884
- font-size: inherit;
885
- color: inherit;
886
- box-sizing: border-box;
887
- background-color: #0000;
888
- border: 0;
889
- outline: none;
890
- padding-inline: 6px;
891
- }
892
-
893
- [data-item-section="content"]:has([data-item-rename-input]) ~ [data-item-section="action"], [data-item-section="content"]:has([data-item-rename-input]) ~ [data-item-section="decoration"] {
894
- display: none;
895
- }
896
-
897
- [aria-expanded="false"][data-item-type="folder"] > [data-item-section="icon"] > [data-icon-name="file-tree-icon-chevron"] {
898
- &[data-align-capitals="true"] {
899
- transform: rotate(-90deg)
900
- translate(calc(var(--trees-icon-nudge) / 2),
901
- calc(var(--trees-icon-nudge) / 2));
902
- }
903
-
904
- &[data-align-capitals="false"] {
905
- transform: rotate(-90deg)
906
- translate(calc(var(--trees-icon-nudge) / 2 * -1),
907
- calc(var(--trees-icon-nudge) / 2));
908
- }
909
- }
910
-
911
- [data-item-section="spacing"] {
912
- height: var(--trees-row-height);
913
- padding-left: calc(calc(var(--trees-icon-width) / 2) - .5px);
914
- flex-direction: row;
915
- justify-content: center;
916
- align-items: center;
917
- display: flex;
918
-
919
- &:empty {
920
- padding-left: 0;
921
- }
922
- }
923
-
924
- [data-item-section="spacing-item"] {
925
- border-left: 1px solid var(--trees-indent-guide-bg);
926
- height: 100%;
927
- margin-right: calc(var(--trees-level-gap) - 1px);
928
- opacity: 0;
929
- transition: opacity .15s;
930
- display: inline-block;
931
- transform: translateX(-.25px);
932
-
933
- & + & {
934
- margin-left: calc(var(--trees-item-row-gap) + calc(var(--trees-icon-width) / 2) - .5px);
935
- }
936
- }
937
-
938
- :host(:hover) [data-item-section="spacing-item"] {
939
- opacity: .75;
940
- }
941
-
942
- [data-item-contains-git-change="true"] > [data-item-section="git"] {
943
- color: var(--trees-git-modified-color);
944
- opacity: .5;
945
- fill: currentColor;
946
- }
947
-
948
- [data-item-git-status] {
949
- & > :where([data-item-section="icon"]) > :where(:not([data-icon-name="file-tree-icon-chevron"])), & > [data-item-section="content"] {
950
- color: var(--trees-item-git-status-color);
951
- }
952
-
953
- & > [data-item-section="git"] {
954
- color: var(--trees-item-git-status-color);
955
- font-weight: var(--trees-font-weight-semibold);
956
- }
957
- }
958
-
959
- [data-item-git-status="added"] {
960
- --trees-item-git-status-color: var(--trees-git-added-color);
961
- }
962
-
963
- [data-item-git-status="deleted"] {
964
- --trees-item-git-status-color: var(--trees-git-deleted-color);
965
- }
966
-
967
- [data-item-git-status="ignored"] {
968
- --trees-item-git-status-color: var(--trees-git-ignored-color);
969
-
970
- & > [data-item-section="icon"] {
971
- opacity: .5;
972
- }
973
- }
974
-
975
- [data-item-section="git"] [data-icon-name="file-tree-icon-dot"] {
976
- transform: translateY(calc(.65ex - 50%));
977
- }
978
-
979
- [data-item-git-status="modified"] {
980
- --trees-item-git-status-color: var(--trees-git-modified-color);
981
- }
982
-
983
- [data-item-git-status="renamed"] {
984
- --trees-item-git-status-color: var(--trees-git-renamed-color);
985
- }
986
-
987
- [data-item-git-status="untracked"] {
988
- --trees-item-git-status-color: var(--trees-git-untracked-color);
989
- }
990
-
991
- [data-item-drag-target="true"] {
992
- background-color: var(--trees-selected-bg);
993
- }
994
-
995
- [data-item-dragging="true"] {
996
- opacity: .5;
997
- }
998
-
999
- [data-item-section="lock"] {
1000
- color: var(--trees-fg-muted);
1001
- flex: none;
1002
- align-items: center;
1003
- margin-left: auto;
1004
- display: flex;
1005
- }
1006
-
1007
- [data-item-section="lock"] svg {
1008
- display: block;
1009
- }
1010
-
1011
- [data-type="header-slot"] {
1012
- flex: none;
1013
- display: block;
1014
- }
1015
-
1016
- [data-type="context-menu-wash"] {
1017
- z-index: 3;
1018
- touch-action: none;
1019
- background-color: #0000;
1020
- position: absolute;
1021
- inset: 0;
1022
- }
1023
-
1024
- [data-type="context-menu-anchor"] {
1025
- top: 0;
1026
- right: var(--trees-context-menu-trigger-inline-offset);
1027
- z-index: 4;
1028
- align-items: center;
1029
- display: none;
1030
- position: absolute;
1031
-
1032
- &[data-visible="true"] {
1033
- display: flex;
1034
- }
1035
- }
1036
-
1037
- [data-file-tree-virtualized-root="true"][data-is-scrolling] [data-type="context-menu-anchor"] {
1038
- display: none;
1039
- }
1040
-
1041
- [data-type="context-menu-anchor"] > slot[name="context-menu"] {
1042
- flex: 0 0 0;
1043
- width: 0;
1044
- min-width: 0;
1045
- display: block;
1046
- overflow: visible;
1047
- }
1048
-
1049
- [data-type="context-menu-trigger"] {
1050
- all: unset;
1051
- width: var(--trees-action-lane-width);
1052
- color: var(--trees-fg-muted);
1053
- fill: currentColor;
1054
- cursor: pointer;
1055
- font-family: var(--trees-font-family);
1056
- font-size: var(--trees-font-size);
1057
- border-top-right-radius: var(--trees-border-radius);
1058
- border-bottom-right-radius: var(--trees-border-radius);
1059
- margin: var(--trees-focus-ring-width);
1060
- height: calc(var(--trees-row-height) - var(--trees-focus-ring-width) * 2);
1061
- border-width: 0;
1062
- justify-content: center;
1063
- align-items: center;
1064
- transition: color .12s;
1065
- display: flex;
1066
- }
1067
-
1068
- [data-type="context-menu-trigger"]:hover, [data-type="context-menu-trigger"][aria-expanded="true"] {
1069
- color: var(--trees-fg);
1070
- }
1071
-
1072
- [data-truncate-container] {
1073
- --truncate-internal-marker-fade-width: var(--truncate-marker-fade-width, 2px);
1074
- --truncate-internal-marker-gap: var(--truncate-marker-gap, 0px);
1075
- --truncate-internal-marker-opacity: var(--truncate-marker-opacity, 50%);
1076
- --truncate-internal-middle-marker-opacity: var(--truncate-middle-marker-opacity, 80%);
1077
- --truncate-internal-marker-background-color: var(--truncate-marker-background-color, light-dark(#fff, #000));
1078
- --truncate-internal-marker-background-overlay-color: var(--truncate-marker-background-overlay-color, transparent);
1079
- --truncate-internal-marker-block-inset: var(--truncate-marker-block-inset, 0px);
1080
- --truncate-internal-marker-fade-out-duration: var(--truncate-marker-fade-out-duration, 0s);
1081
- --truncate-internal-marker-fade-in-duration: var(--truncate-marker-fade-in-duration, .1s);
1082
- --truncate-internal-fade-marker-color: var(--truncate-fade-marker-color, #000);
1083
- --truncate-internal-fade-marker-width: var(--truncate-fade-marker-width, .2lh);
1084
- --truncate-internal-single-line-height: 1lh;
1085
- height: var(--truncate-internal-single-line-height);
1086
- min-width: 0;
1087
- margin-top: -1px;
1088
- margin-bottom: -1px;
1089
- overflow: hidden;
1090
- }
1091
-
1092
- [data-truncate-marker] {
1093
- height: var(--truncate-internal-single-line-height);
1094
- padding-block: var(--truncate-internal-marker-block-inset);
1095
- box-sizing: border-box;
1096
- z-index: 2;
1097
- color: color-mix(in srgb,
1098
- currentColor var(--truncate-internal-marker-opacity),
1099
- transparent);
1100
- opacity: 0;
1101
- transition: opacity var(--truncate-internal-marker-fade-out-duration)
1102
- ease-in-out;
1103
- background-clip: content-box;
1104
- align-items: center;
1105
- display: flex;
1106
- position: absolute;
1107
- }
1108
-
1109
- @container measure (height > 1lh) {
1110
- [data-truncate-marker] {
1111
- opacity: 1;
1112
- transition: opacity var(--truncate-internal-marker-fade-in-duration)
1113
- ease-in-out;
1114
- }
1115
- }
1116
-
1117
- [data-truncate-grid] {
1118
- display: grid;
1119
- position: relative;
1120
- }
1121
-
1122
- [data-truncate-content="visible"] {
1123
- white-space: nowrap;
1124
- }
1125
-
1126
- [data-truncate-content="overflow"] {
1127
- opacity: 0;
1128
- pointer-events: none;
1129
- user-select: none;
1130
- word-break: break-all;
1131
- margin-top: calc(-1 * var(--truncate-internal-single-line-height));
1132
- }
1133
-
1134
- [data-truncate-marker-cell] {
1135
- user-select: none;
1136
- pointer-events: none;
1137
- overflow: visible;
1138
- container: measure / size;
1139
- }
1140
-
1141
- [data-truncate-container="truncate"] {
1142
- & [data-truncate-grid] {
1143
- grid-template-columns: minmax(0, max-content) 0;
1144
- }
1145
-
1146
- & [data-truncate-marker] {
1147
- right: 0;
1148
- }
1149
-
1150
- & [data-truncate-fade] {
1151
- margin-right: calc(-2 * var(--truncate-internal-fade-marker-width));
1152
- }
1153
- }
1154
-
1155
- [data-truncate-container="fruncate"] {
1156
- & [data-truncate-grid] {
1157
- grid-template-columns: 0 minmax(0, max-content) auto;
1158
- }
1159
-
1160
- & [data-truncate-content] {
1161
- direction: rtl;
1162
- }
1163
-
1164
- & [data-truncate-content] > span {
1165
- unicode-bidi: plaintext;
1166
- }
1167
-
1168
- & [data-truncate-fade] {
1169
- margin-left: calc(-2 * var(--truncate-internal-fade-marker-width));
1170
- }
1171
- }
1172
-
1173
- [data-truncate-variant="default"] {
1174
- & [data-truncate-marker] {
1175
- background-color: var(--truncate-internal-marker-background-color);
1176
- background-image: linear-gradient(var(--truncate-internal-marker-background-overlay-color),
1177
- var(--truncate-internal-marker-background-overlay-color));
1178
- }
1179
-
1180
- & [data-truncate-marker]:after, & [data-truncate-marker]:before {
1181
- content: "";
1182
- width: calc(var(--truncate-internal-marker-fade-width) +
1183
- var(--truncate-internal-marker-gap));
1184
- height: max(0px,
1185
- calc(var(--truncate-internal-single-line-height) -
1186
- var(--truncate-internal-marker-block-inset) * 2));
1187
- background-color: var(--truncate-internal-marker-background-color);
1188
- background-image: linear-gradient(var(--truncate-internal-marker-background-overlay-color),
1189
- var(--truncate-internal-marker-background-overlay-color));
1190
- -webkit-mask-image: linear-gradient(var(--truncate-internal-fade-dir),
1191
- #000 0%,
1192
- #000 var(--truncate-internal-marker-gap),
1193
- transparent 100%);
1194
- mask-image: linear-gradient(var(--truncate-internal-fade-dir),
1195
- #000 0%,
1196
- #000 var(--truncate-internal-marker-gap),
1197
- transparent 100%);
1198
- position: absolute;
1199
- inset-block-start: var(--truncate-internal-marker-block-inset);
1200
- }
1201
-
1202
- & [data-truncate-marker]:after {
1203
- --truncate-internal-fade-dir: to right;
1204
- right: calc(-1 *
1205
- (
1206
- var(--truncate-internal-marker-fade-width) +
1207
- var(--truncate-internal-marker-gap)
1208
- ));
1209
- }
1210
-
1211
- & [data-truncate-marker]:before {
1212
- --truncate-internal-fade-dir: to left;
1213
- left: calc(-1 *
1214
- (
1215
- var(--truncate-internal-marker-fade-width) +
1216
- var(--truncate-internal-marker-gap)
1217
- ));
1218
- }
1219
- }
1220
-
1221
- [data-truncate-variant="fade"] {
1222
- & [data-truncate-marker] {
1223
- background: none;
1224
- }
1225
- }
1226
-
1227
- [data-truncate-fade] {
1228
- box-shadow: 0 0 calc(var(--truncate-internal-fade-marker-width) / 2)
1229
- var(--truncate-internal-fade-marker-color),
1230
- 0 0 var(--truncate-internal-fade-marker-width)
1231
- var(--truncate-internal-fade-marker-color);
1232
- width: calc(var(--truncate-internal-fade-marker-width) * 2);
1233
- height: calc(var(--truncate-internal-single-line-height) -
1234
- (var(--truncate-internal-fade-marker-width) * 2));
1235
- margin: var(--truncate-internal-fade-marker-width) 0;
1236
- }
1237
-
1238
- [data-truncate-group-container="middle"] {
1239
- & [data-truncate-container] {
1240
- --truncate-marker-opacity: var(--truncate-internal-middle-marker-opacity);
1241
- }
1242
-
1243
- min-width: 0;
1244
- display: flex;
1245
-
1246
- & > div {
1247
- min-width: 0;
1248
- }
1249
-
1250
- & > div[data-truncate-segment-priority="1"] {
1251
- flex: 0 1 max-content;
1252
- }
1253
-
1254
- & > div[data-truncate-segment-priority="2"] {
1255
- flex: 0 999999 max-content;
1256
- }
1257
- }
1258
- }
1259
-
1260
- @layer theme, unsafe;
1261
- `,ox=`@layer base, unsafe;`;function sx(e){return`${ox}
1262
- @layer base {
1263
- ${e}
1264
- }`}function cx(e){return`${ox}
1265
- @layer unsafe {
1266
- ${e}
1267
- }`}var lx=new WeakMap;function ux(e){let t=lx.get(e);if(t!=null)return t;let n=document.createElement(`div`);n.setAttribute(ky,`true`);let r=document.createElement(`div`);r.style.position=`relative`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n);let i=Math.max(n.offsetWidth-n.clientWidth,0);return n.remove(),lx.set(e,i),i}function dx(e,t){if(!e.isConnected)return;let n=ux(t);if(n==null)return;let r=t.querySelector(`style[${Ay}]`),i=r instanceof HTMLStyleElement?r:document.createElement(`style`);r instanceof HTMLStyleElement||(i.setAttribute(Ay,``),t.appendChild(i)),i.textContent=`:host { ${jy}: ${n}px; }`}var fx;function px(e){if(typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&`adoptedStyleSheets`in e){fx??(fx=new CSSStyleSheet,fx.replaceSync(sx(ax)));let t=!1;try{e.adoptedStyleSheets=[fx],t=!0}catch{}if(t){e.querySelector(`style[${Dy}]`)?.remove();return}}if(e.querySelector(`style[data-file-tree-style]`)==null){let t=document.createElement(`style`);t.setAttribute(Dy,``),t.textContent=sx(ax),e.prepend(t)}}function mx(e,t){hx(e,t),px(t),dx(e,t)}function hx(e,t){let n=e.querySelector(`template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]`);n instanceof HTMLTemplateElement&&(t.childNodes.length>0||(t.appendChild(n.content.cloneNode(!0)),n.hasAttribute(`shadowrootmode`)&&n.remove()))}if(typeof HTMLElement<`u`&&customElements.get(`file-tree-container`)==null){class e extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.shadowRoot??this.attachShadow({mode:`open`});mx(this,e)}}if(customElements.define(Ey,e),typeof document<`u`)for(let e of Array.from(document.querySelectorAll(Ey)))e instanceof HTMLElement&&mx(e,e.shadowRoot??e.attachShadow({mode:`open`}))}var gx=5,_x=32,vx=128;function yx(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function bx(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function xx(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function Sx(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function Cx(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function wx(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function Tx(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,kx(e,t)}function Ex(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Sx(e).get(t);if(i===void 0)return;let a=i>>gx;e.childVisibleChunkSums[a]+=r}function Dx(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=Ax(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=_x}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function Ox(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>gx;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<gx}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function kx(e,t){if(t.childIds.length<vx){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/_x),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>gx]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function Ax(e,t,n,r){let i=Math.min(t.childIds.length,n+_x),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var jx=7,Mx=3,Nx=8,Px=4;function Fx(e,t,n=0){return e<<Px|n<<Mx|t}function Ix(e){return e.depthAndFlags>>>Px}function Lx(e){return(e.depthAndFlags&Nx)>>Mx}function Y(e){return(e.depthAndFlags&Nx)!==0}function Rx(e){return e.depthAndFlags&jx}function zx(e,t){return(Rx(e)&t)!==0}function Bx(e,t){e.depthAndFlags|=t}function Vx(e,t){e.depthAndFlags=Fx(t,Rx(e),Lx(e))}var Hx=Symbol(`benchmarkInstrumentation`);function Ux(e,t){return t==null||Object.defineProperty(e,Hx,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function Wx(e){return e==null?null:e[Hx]??null}function X(e,t,n){return e==null?n():e.measurePhase(t,n)}function Gx(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function Kx(e){return e>=48&&e<=57}function qx(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!Kx(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&Kx(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function Jx(e){let t=e.toLowerCase();return{lowerValue:t,tokens:qx(t)}}function Yx(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function Xx(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=Yx(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function Zx(e,t,n){let r=Xx(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function Qx(e,t){return Zx(e,t,Jx)}function $x(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function eS(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=$x(e,r);return a===$x(t,r)?Qx(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function tS(e,t){return eS(e,t)}function nS(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=Jx(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=$x(e,n);return o===$x(t,n)?Zx(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function rS(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=Jx(r);return e.sortKeyById[t]=i,i}function iS(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function aS(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function oS(e){let{hasTrailingSlash:t,segments:n}=aS(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function sS(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=aS(e);return{requiresDirectory:t,segments:n}}function cS(){let e=new Map;return e.set(``,0),{idByValue:e,valueById:[``],sortKeyById:[Jx(``)]}}function lS(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function uS(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var dS=Symbol(`pathStorePreparedInputKind`);function fS(e,t){return e[dS]=t,e}function pS(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function mS(e,t,n){return n==="default"?tS(e,t):n(pS(e),pS(t))}function hS(){return{depthAndFlags:Fx(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function gS(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function _S(e){return e.isDirectory?e.segments.length:e.segments.length-1}function vS(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function yS(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function bS(e,t={}){return ES(e,t).map(e=>e.path)}function xS(e,t={}){let n=ES(e,t);return fS({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function SS(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return fS({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function CS(e){let t=e,n=t.preparedPaths;if(t[dS]===`prepared`&&n!=null)return n;if(!vS(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function wS(e){let t=e;return t[dS]===`presorted`&&t.presortedPaths!=null||yS(t.presortedPaths)?t.presortedPaths:null}function TS(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function ES(e,t={}){let n=iS(t),r=Wx(t);Gx(r,`workload.inputFiles`,e.length);let i=X(r,`store.preparePathEntries.parse`,()=>e.map(e=>oS(e)));return X(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>mS(e,t,n.sort))),i}var DS=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[hS()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=cS();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=Wx(e),this.options=iS(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,yx())}appendPaths(e){return X(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>oS(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,X(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return X(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null){if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:Fx(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:Fx(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d,m=a+1}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:Fx(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=oS(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null){if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:Fx(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:Fx(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=oS(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(X(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||X(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort==="default"?nS(this.lastPreparedPath,e,this.segmentSortKeyCache):mS(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=_S(e),i=n==null?0:_S(n),a=n==null?0:gS(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=lS(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:Fx(Ix(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),Cx(i,s),s}createFileChildUnchecked(e,t){let n=lS(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Fx(Ix(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Cx(r,a),a}getOrCreateDirectoryChild(e,t){let n=lS(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!Y(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Fx(Ix(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Cx(r,a),this.directories.set(a,yx()),a}createDirectoryChild(e,t){let n=lS(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Fx(Ix(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Cx(r,a),this.directories.set(a,yx()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!Y(n))throw Error(`Path is not a directory: "${t}"`);if(zx(n,1))throw Error(`Duplicate path: "${t}"`);Bx(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,bx());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(Y(a)){let t=bx();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;Y(n)&&this.directories.set(t,yx());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),Cx(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!Y(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return Tx(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function OS(e,t=`closed`,n=null){let r=AS(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function kS(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function AS(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function jS(e,t){return zx(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion!==`closed`&&Ix(t)<=e.defaultExpansion}function MS(e,t,n=e.snapshot.nodes[t]){return n==null||!Y(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:jS(e,n)}function NS(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!Y(r))return;let i=jS(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function PS(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function FS(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function IS(e,t){let n=PS(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function LS(e,t){let n=PS(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function RS(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function zS(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function BS(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function VS(e,t){e.directoryLoadInfoById.delete(t)}function HS(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function US(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function WS(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function GS(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function KS(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function qS(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function JS(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function YS(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function XS(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function ZS(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function QS(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function $S(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function eC(e,t,n){return{...n,visibleCountDelta:dC(e)-t}}function tC(e,t){let n=dC(e),r=kS();e.transactionStack.push(r);try{t()}catch(t){throw iC(e,r,!1),t}iC(e,r,!0,dC(e)-n)}function nC(e,t){let n=e.instrumentation;if(n==null){rC(e,t);return}X(n,`store.events.record`,()=>rC(e,t))}function rC(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){lC(e,t);return}n.events.push(t),cC(n,t)}function iC(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?sC(i,t):X(n,`store.events.batch.merge`,()=>sC(i,t));return}let a=aC(t,r),o=e.instrumentation;if(o==null){lC(e,a);return}X(o,`store.events.batch.commit`,()=>lC(e,a))}function aC(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function oC(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function sC(e,t){for(let n of t.events)e.events.push(n);oC(e,t)}function cC(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function lC(e,t){let n=e.instrumentation;if(n==null){uC(e,t);return}X(n,`store.events.emit`,()=>uC(e,t))}function uC(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function dC(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function fC(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!Y(n)||zx(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!Y(a)?null:i}function pC(e,t){let n=t;for(;;){let t=fC(e,n);if(t==null)return n;n=t}}function mC(e,t){let n=[t],r=t;for(;;){let t=fC(e,r);if(t==null)return n;n.push(t),r=t}}function hC(e,t){let n=t==null?e.snapshot.rootId:TC(e,t);return n==null?[]:OC(e,n)}function gC(e,t){let n=oS(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=UC(e,HC(e,r)),{createdNodeIds:a,directoryId:o}=kC(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=Z(e,o);if(zx(n,1))throw Error(`Path already exists: "${t}"`);Bx(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=jC(e,o,n.basename),s.add(c);SC(e,o);let l=UC(e,o);return US({affectedAncestorIds:wC(e,c),affectedNodeIds:[...s],path:t,projectionChanged:WC(i,l)})}function _C(e,t,n){let r=TC(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=Z(e,r);if(zx(i,2))throw Error(`The root node cannot be removed`);if(Y(i)&&DC(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=UC(e,a),s=BC(e,r);PC(e,a,r,i.nameId),VC(e,a),SC(e,a);let c=UC(e,a);return WS({affectedAncestorIds:wC(e,a),affectedNodeIds:s,path:t,projectionChanged:WC(o,c),recursive:n.recursive===!0})}function vC(e,t,n,r){let i=TC(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=Z(e,i);if(zx(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=RC(e,i,n),c=UC(e,a.parentId),l=UC(e,s.parentId),u=uS(e.snapshot.segmentTable,a.nameId),d=lS(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(Y(a)&&JC(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=xx(e.snapshot.nodes,DC(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&zC(e,p,o,Lx(a))===`skip`)return null;let m=a.parentId;PC(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),qC(e,i),NC(e,s.parentId,i),VC(e,m),e.pathCacheVersion++,SC(e,m),s.parentId!==m&&SC(e,s.parentId);let h=UC(e,m),g=UC(e,s.parentId);return GS({affectedAncestorIds:[...new Set([...wC(e,m),...wC(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:GC([c,l],[h,g]),to:xC(e,i)})}function yC(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function bC(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function xC(e,t){let n=Z(e,t),r=yC(e,t);if(r!=null)return r;if(zx(n,2))return bC(e,t,``);let i=xC(e,n.parentId),a=uS(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return bC(e,t,Y(n)?`${o}/`:o)}function SC(e,t){let n=e.instrumentation;if(n==null){XC(e,t);return}X(n,`store.recomputeCountsUpwardFrom`,()=>XC(e,t))}function CC(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!Y(o)){YC(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){YC(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function wC(e,t){let n=[],r=t;for(;r!=null;){let t=Z(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function TC(e,t){if(t.length===0)return e.snapshot.rootId;let n=sS(t);return EC(e,n.segments,n.requiresDirectory)}function EC(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=DC(e,r),a=xx(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=Z(e,r);return n&&!Y(i)?null:r}function DC(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function Z(e,t){let n=e.snapshot.nodes[t];if(n===void 0||zx(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function OC(e,t){let n=e.snapshot.nodes[t];if(n===void 0||zx(n,4))return[];if(!Y(n))return[xC(e,t)];if(DC(e,t).childIds.length===0)return zx(n,1)&&!zx(n,2)?[xC(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||zx(n,4)){i.pop();continue}if(!Y(n)){r.push(xC(e,t.nodeId)),i.pop();continue}let a=DC(e,t.nodeId);if(a.childIds.length===0){zx(n,1)&&!zx(n,2)&&r.push(xC(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function kC(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=lS(e.snapshot.segmentTable,i),a=DC(e,r),o=xx(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!Y(Z(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=AC(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function AC(e,t,n){let r=Z(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Fx(Ix(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,yx()),NC(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function jC(e,t,n){let r=lS(e.snapshot.segmentTable,n),i=DC(e,t);if(xx(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${QC(e,t,n)}"`);let a=Z(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Fx(Ix(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),NC(e,t,o),e.activeNodeCount++,o}function MC(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}FC(e,n,o)<0?i=a:r=a+1}return r}function NC(e,t,n){let r=DC(e,t),i=Z(e,n);xx(e.snapshot.nodes,r).set(i.nameId,n),Ex(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=MC(e,r,n);r.childIds.splice(a,0,n),wx(r,a),kx(e.snapshot.nodes,r)}function PC(e,t,n,r){let i=DC(e,t),a=Sx(i),o=a.get(n)??-1;xx(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Ex(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),wx(i,o),kx(e.snapshot.nodes,i))}function FC(e,t,n){let r=e.snapshot.options.sort;return r==="default"?IC(e,t,n):r(LC(e,t),LC(e,n))}function IC(e,t,n){let r=Z(e,t),i=Z(e,n),a=Y(r);if(a!==Y(i))return a?-1:1;let o=Xx(rS(e.snapshot.segmentTable,r.nameId),rS(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=uS(e.snapshot.segmentTable,r.nameId),c=uS(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function LC(e,t){let n=Z(e,t),r=xC(e,t),i=Y(n),a=i?r.slice(0,-1):r;return{basename:uS(e.snapshot.segmentTable,n.nameId),depth:Ix(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function RC(e,t,n){let r=Z(e,t),i=TC(e,n);if(i!=null){let t=Z(e,i);if(Y(t))return{basename:uS(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=sS(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=sS(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:EC(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function zC(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${xC(e,t)}"`);let i=Z(e,t);if(Lx(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(Y(i)&&DC(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return BC(e,t),PC(e,a,t,o),VC(e,a),SC(e,a),`handled`}function BC(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=Z(e,t.nodeId);if(t.visitedChildren||!Y(i)){Y(i)&&e.snapshot.directories.delete(t.nodeId),Bx(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),VS(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=DC(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function VC(e,t){let n=t;for(;n!=null;){let t=Z(e,n);if(!Y(t)||zx(t,2)||DC(e,n).childIds.length>0)return;Bx(t,1),n=t.parentId===n?null:t.parentId}}function HC(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=xx(e.snapshot.nodes,DC(e,n)).get(t);if(i==null||!Y(Z(e,i)))break;n=i}return n}function UC(e,t){let n=KC(e,t);if(n==null)return null;let r=pC(e,n),i=Z(e,r),a=n===r?null:mC(e,n).map(t=>xC(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:DC(e,r).childIds.length>0,path:xC(e,r),terminalKind:Lx(i)})}function WC(e,t){return GC([e],[t])}function GC(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function KC(e,t){let n=t;for(;n!=null;){let t=Z(e,n);if(!Y(t)||zx(t,2))return null;if(!MS(e,n,t))return n;n=t.parentId}return null}function qC(e,t){let n=Z(e,t);if(Vx(n,(t===e.snapshot.rootId?-1:Ix(Z(e,n.parentId)))+1),!Y(n))return;let r=DC(e,t);for(let t of r.childIds)qC(e,t)}function JC(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=Z(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function YC(e,t,n=Z(e,t),r=!1){let i=e.instrumentation;if(i==null){ZC(e,t,n,r);return}X(i,`store.recomputeNodeCounts`,()=>ZC(e,t,n,r))}function XC(e,t){let n=t;for(;n!=null;){let t=Z(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(YC(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Ex(DC(e,s),n,a,o),n=s}}function ZC(e,t,n,r){if(!Y(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=DC(e,t);if(r){let t=e.instrumentation;t==null?Tx(e.snapshot.nodes,i):X(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>Tx(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,zx(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=fC(e,t)==null?MS(e,t,n)?1+o:1:o}function QC(e,t,n){let r=xC(e,t);return r.length===0?n:`${r}${n}`}function $C(e){return e!=null&&!zx(e,4)}function ew(e,t){let n=e.snapshot.nodes[t];return!$C(n)||!Y(n)||zx(n,2)?null:n}function tw(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&$C(e.snapshot.nodes[n])&&(t+=1);return t}function nw(e){return Math.max(0,e.valueById.length-1)}function rw(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:tw(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:nw(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function iw(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function aw(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)ew(e,n)!=null&&t.push(xC(e,n));for(let t of e.expandedDirectoryIds)ew(e,t)!=null&&n.push(xC(e,t));return{collapsedPaths:t,expandedPaths:n}}function ow(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)ew(e,n)!=null&&FS(e,n)!==`loaded`&&t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:xC(e,n)});return t}function sw(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=TC(e,n);t!=null&&NS(e,t,!0,Z(e,t))}for(let n of t.collapsedPaths){let t=TC(e,n);t!=null&&NS(e,t,!1,Z(e,t))}}function cw(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=TC(e,n.path);t!=null&&ew(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function lw(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function uw(e){let t=e.snapshot.segmentTable,n=cS();for(let r of e.snapshot.nodes)if($C(r)){if(zx(r,2)){r.nameId=0;continue}r.nameId=lS(n,uS(t,r.nameId))}e.snapshot.segmentTable=n}function dw(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!$C(r)||!Y(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return $C(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[Z(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),Tx(e.snapshot.nodes,n)}}function fw(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if($C(n))break;--t}e.snapshot.nodes.length=t+1}function pw(e){let t=aw(e),n=ow(e);X(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>lw(e)),X(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>uw(e)),X(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>dw(e)),X(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>fw(e)),X(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>sw(e,t)),X(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>cw(e,n)),X(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>CC(e,e.snapshot.rootId))}function mw(e){let t=aw(e),n=ow(e),r=X(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>hC(e)),i=Ux({...e.snapshot.options},e.instrumentation),a=X(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new DS(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,X(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>sw(e,t)),X(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>cw(e,n)),X(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>CC(e,e.snapshot.rootId))}function hw(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function gw(e,t){let n=rw(e);t===`stable`?X(e.instrumentation,`store.cleanup.stable`,()=>pw(e)):X(e.instrumentation,`store.cleanup.aggressive`,()=>mw(e));let r=rw(e);return iw(t,t===`stable`,n,r)}var _w=64;function vw(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function yw(e){return Z(e,e.snapshot.rootId).visibleSubtreeCount}function bw(e,t,n,r){let i=Z(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function xw(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Bw(e,t.cursor),setSize:t.setSize,subtreeEndIndex:bw(e,t.cursor,t.index,n)}}function Sw(e,t,n,r,i,a){let o=DC(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=Dx(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return Cw(e,u,l,r+c,i+1,s,o.childIds.length,a)}function Cw(e,t,n,r,i,a,o,s){if(!Y(Z(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=Pw(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=Z(e,c.terminalNodeId);if(!Y(l)||!MS(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Sw(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function ww(e,t){let n=yw(e);if(t<0||t>=n)return null;let r=Sw(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>xC(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=xw(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Bw(e,r.cursor),setSize:r.setSize,subtreeEndIndex:bw(e,r.cursor,r.index,n)}}function Tw(e,t,n){let r=e.instrumentation,i=yw(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return zw(e,o+1);let t=[],n=jw(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Bw(e,n);t.push(r),n=Iw(e,n)}return t}let s=[],c=0,l=0,u=X(r,`store.getVisibleSlice.selectFirstRow`,()=>jw(e,a));for(let t=a;t<=o&&u!=null;t++){let t=X(r,`store.getVisibleSlice.materializeRow`,()=>Bw(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=X(r,`store.getVisibleSlice.advanceCursor`,()=>Iw(e,u))}return Gx(r,`workload.visibleRowsRead`,s.length),Gx(r,`workload.flattenedRowsRead`,c),Gx(r,`workload.flattenedSegmentsRead`,l),s}function Ew(e,t=yw(e)){let n=e.instrumentation;return n==null?Rw(e,t):X(n,`store.getVisibleTreeProjection`,()=>Rw(e,t))}function Dw(e){return Lw(Ew(e))}function Ow(e,t){let n=TC(e,t);if(n==null||n===e.snapshot.rootId||Y(Z(e,n))&&pC(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=Z(e,i).parentId,n=DC(e,t),s=Sx(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=Ox(a,n,s),t!==o){let n=Z(e,t),a=fC(e,t);if(!MS(e,t,n)&&a!==i)return null;pC(e,t)===t&&(r+=1)}i=t}return r}function kw(e,t){let n=TC(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=Z(e,n);if(!Y(r))throw Error(`Path is not a directory: "${t}"`);return MS(e,n,r)?null:(NS(e,n,!0,r),SC(e,n),KS({affectedAncestorIds:wC(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Aw(e,t){let n=TC(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=Z(e,n);if(!Y(r))throw Error(`Path is not a directory: "${t}"`);return MS(e,n,r)?(NS(e,n,!1,r),SC(e,n),qS({affectedAncestorIds:wC(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function jw(e,t){return t<0||t>=yw(e)?null:Mw(e,e.snapshot.rootId,t,-1)}function Mw(e,t,n,r){let i=DC(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?Dx(e.snapshot.nodes,i,n):X(a,`store.getVisibleSlice.selectChildIndex`,()=>Dx(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Nw(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Nw(e,t,n,r){if(!Y(Z(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=Pw(e,t,r);if(n===0)return i;let a=Z(e,i.terminalNodeId);if(!Y(a)||!MS(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Mw(e,i.terminalNodeId,n-1,i.visibleDepth)}function Pw(e,t,n){return Y(Z(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:pC(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:X(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>pC(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function Fw(e,t){let n=Z(e,t);if(!Y(n))return!0;let r=n.parentId;return r===e.snapshot.rootId||fC(e,r)!==t}function Iw(e,t){let n=Z(e,t.terminalNodeId);if(Y(n)){let r=DC(e,t.terminalNodeId);if(MS(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Nw(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=Z(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=DC(e,n),o=Sx(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return Nw(e,s,0,i);Fw(e,r)&&i--,r=n}}function Lw(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function Rw(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(_w);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=vw(o,y);let x,S=_;if(Y(v))S=f?pC(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:xC(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&Y(C)&&MS(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function zw(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!Y(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:xC(e,f)};continue}let h=l?pC(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Bw(e,g);let _=i[h];_!=null&&Y(_)&&MS(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Bw(e,t){let n=Z(e,t.terminalNodeId),r=Y(n)?Vw(e,t):null,i=xC(e,t.terminalNodeId),a=uS(e.snapshot.segmentTable,n.nameId),o=Y(n)&&DC(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?mC(e,t.headNodeId).map(n=>{let r=Z(e,n);return{isTerminal:n===t.terminalNodeId,name:uS(e.snapshot.segmentTable,r.nameId),nodeId:n,path:xC(e,n)}}):X(c,`store.getVisibleSlice.flatten.collectSegments`,()=>mC(e,t.headNodeId).map(n=>{let r=Z(e,n);return{isTerminal:n===t.terminalNodeId,name:uS(e.snapshot.segmentTable,r.nameId),nodeId:n,path:xC(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:Y(n)&&MS(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:Y(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Vw(e,t){if(t.headNodeId===t.terminalNodeId)return FS(e,t.terminalNodeId);let n=mC(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=FS(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}var Hw=8;function Uw(e){let{nodes:t,directories:n,rootId:r,options:i}=e,a=t.length,o=new Int32Array(a),s=new Int32Array(a),c=new Int32Array(a),l=new Int32Array(a),u=new Int32Array(a),d=new Int32Array(a),f=new Int32Array(a);for(let e=0;e<a;e+=1){let n=t[e];n!=null&&(o[e]=n.parentId,s[e]=n.nameId,c[e]=n.depthAndFlags,l[e]=n.subtreeNodeCount,u[e]=n.visibleSubtreeCount)}let p=0;for(let e of n.values())p+=e.childIds.length;let m=new Int32Array(p),h=0;for(let[e,t]of n){let n=t.childIds;d[e]=h,f[e]=n.length;for(let e=0;e<n.length;e+=1)m[h]=n[e],h+=1}return{nodeCount:a,rootId:r,flattenEmptyDirectories:i.flattenEmptyDirectories===!0,parentId:o,nameId:s,depthAndFlags:c,subtreeNodeCount:l,visibleSubtreeCount:u,childStart:d,childCount:f,childIdsFlat:m}}function Ww(e){let{nodeCount:t,rootId:n,flattenEmptyDirectories:r,depthAndFlags:i,subtreeNodeCount:a,visibleSubtreeCount:o,childStart:s,childCount:c,childIdsFlat:l}=e;for(let e=t-1;e>=1;--e){if((i[e]&Hw)===0)continue;let t=s[e],n=c[e],u=0,d=0;for(let e=0;e<n;e+=1){let n=l[t+e];u+=a[n],d+=o[n]}a[e]=1+u;let f;f=r&&n===1?(i[l[t]]&Hw)===0?1+d:d:1+d,o[e]=f}let u=s[n],d=c[n],f=0,p=0;for(let e=0;e<d;e+=1){let t=l[u+e];f+=a[t],p+=o[t]}a[n]=1+f,o[n]=p}function Gw(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!Y(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&kx(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&Y(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,kx(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Kw(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=Uw(e.snapshot);Ww(i);let a=i.subtreeNodeCount,o=i.visibleSubtreeCount;for(let e=0;e<n.length;e+=1){let t=n[e];t!=null&&(t.subtreeNodeCount=a[e],t.visibleSubtreeCount=o[e])}for(let[e,i]of t){let t=i.childIds,a=t.length,o=0,s=0;for(let e=0;e<a;e++){let r=t[e];if(r==null)continue;let i=n[r];o+=i.subtreeNodeCount,s+=i.visibleSubtreeCount}i.totalChildSubtreeNodeCount=o,i.totalChildVisibleSubtreeCount=s,(e===r||a>=128)&&kx(n,i)}}function qw(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Jw=class e{#e;constructor(e={}){let t=Wx(e),n=X(t,`store.builder.create`,()=>new DS(e));if(e.preparedInput!=null){let t=wS(e.preparedInput);t==null?n.appendPreparedPaths(CS(e.preparedInput),!1):n.appendPresortedPaths(t,TS(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(X(t,`store.preparePathEntries`,()=>ES(r,e)))}let r=X(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=X(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=X(t,`store.state.create`,()=>OS(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:X(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||qw(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&X(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?e.useSoaCountSweep===!0?X(t,`store.state.initializeOpenVisibleCountsViaSoa`,()=>Kw(this.#e)):X(t,`store.state.initializeOpenVisibleCounts`,()=>Gw(this.#e)):X(t,`store.state.recomputeCounts`,()=>CC(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return bS(e,t)}static prepareInput(e,t={}){return xS(e,t)}static preparePresortedInput(e){return SS(e)}list(e){return X(this.#e.instrumentation,`store.list`,()=>hC(this.#e,e))}add(e){X(this.#e.instrumentation,`store.add`,()=>{let t=yw(this.#e);nC(this.#e,eC(this.#e,t,gC(this.#e,e)))})}remove(e,t={}){X(this.#e.instrumentation,`store.remove`,()=>{let n=yw(this.#e);nC(this.#e,eC(this.#e,n,_C(this.#e,e,t)))})}move(e,t,n={}){X(this.#e.instrumentation,`store.move`,()=>{let r=yw(this.#e),i=vC(this.#e,e,t,n);i!=null&&nC(this.#e,eC(this.#e,r,i))})}batch(e){tC(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision})}})}getVisibleCount(){return X(this.#e.instrumentation,`store.getVisibleCount`,()=>yw(this.#e))}getVisibleSlice(e,t){return X(this.#e.instrumentation,`store.getVisibleSlice`,()=>Tw(this.#e,e,t))}getVisibleRowContext(e){return X(this.#e.instrumentation,`store.getVisibleRowContext`,()=>ww(this.#e,e))}getVisibleTreeProjection(){return Dw(this.#e)}getVisibleTreeProjectionData(e){return Ew(this.#e,e)}getVisibleIndex(e){return X(this.#e.instrumentation,`store.getVisibleIndex`,()=>Ow(this.#e,e))}getPathInfo(e){return X(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=TC(this.#e,e);if(t==null)return null;let n=Z(this.#e,t);return{depth:Ix(n),kind:Y(n)?`directory`:`file`,path:xC(this.#e,t)}})}isExpanded(e){return X(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=Z(this.#e,t);return MS(this.#e,t,n)})}expand(e){X(this.#e.instrumentation,`store.expand`,()=>{let t=yw(this.#e),n=kw(this.#e,e);n!=null&&nC(this.#e,eC(this.#e,t,n))})}collapse(e){X(this.#e.instrumentation,`store.collapse`,()=>{let t=yw(this.#e),n=Aw(this.#e,e);n!=null&&nC(this.#e,eC(this.#e,t,n))})}on(e,t){return HS(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return FS(this.#e,t)}markDirectoryUnloaded(e){X(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(DC(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=yw(this.#e);LS(this.#e,t),nC(this.#e,eC(this.#e,n,JS({affectedAncestorIds:wC(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return X(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=yw(this.#e),r=IS(this.#e,t);return nC(this.#e,eC(this.#e,n,YS({affectedAncestorIds:wC(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return X(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||FS(this.#e,n)!==`loading`||!zS(this.#e,n,e.attemptId))return!1;let r=xC(this.#e,n);this.validateChildPatch(r,t);let i=yw(this.#e),a=[];for(let e of t.operations){Yw(r,e);let t=yw(this.#e);switch(e.type){case`add`:a.push(eC(this.#e,t,gC(this.#e,e.path)));break;case`remove`:a.push(eC(this.#e,t,_C(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=vC(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(eC(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return nC(this.#e,eC(this.#e,i,XS({affectedAncestorIds:wC(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:xC(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return X(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=yw(this.#e),r=RS(this.#e,t,e.attemptId);return nC(this.#e,eC(this.#e,n,ZS({affectedAncestorIds:wC(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:xC(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return X(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=yw(this.#e),i=BS(this.#e,n,e.attemptId,t);return nC(this.#e,eC(this.#e,r,QS({affectedAncestorIds:wC(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:xC(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return X(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(hw(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=yw(this.#e),n=gw(this.#e,e.mode??`stable`);return nC(this.#e,eC(this.#e,t,$S({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=DC(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??Jx(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=Xx(rS(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!Y(Z(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=Z(this.#e,n);MS(this.#e,n,i)||(NS(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=Z(this.#e,e);if(!MS(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=TC(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!Y(Z(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!Y(Z(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=Z(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=Z(this.#e,e),r=fC(this.#e,e);if(!MS(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function Yw(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`)}}var Xw=e=>e.startsWith(`f::`)?e.slice(3):e;function Zw(e){let t=e.lastIndexOf(`/`);return t<0?{parentPath:``,baseName:e}:{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function Qw(e,t){return e===``?t:`${e}/${t}`}function $w({files:e,path:t,isFolder:n,nextBasename:r}){let i=Xw(t),a=r.trim();if(a.length===0)return{error:`Name cannot be empty.`};if(a.includes(`/`))return{error:`Name cannot include "/".`};let{parentPath:o,baseName:s}=Zw(i);if(a===s)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let c=Qw(o,a),l=Array(e.length),u=new Set;if(!n){let t=`${c}/`,r=!1;for(let n=0;n<e.length;n++){let a=e[n];if(a!==i&&a.startsWith(t))return{error:`"${c}" already exists.`};let o=a===i?c:a;if(u.has(o))return{error:`"${c}" already exists.`};u.add(o),l[n]=o,a===i&&(r=!0)}return r?{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}:{error:`Could not find the selected file to rename.`}}let d=`${i}/`,f=`${c}/`,p=0;for(let t=0;t<e.length;t++){let n=e[t],r=n===i||n.startsWith(d);if(!r&&(n===c||n.startsWith(f)))return{error:`"${c}" already exists.`};let a=r?`${c}${n.slice(i.length)}`:n;if(u.has(a))return{error:`"${c}" already exists.`};u.add(a),l[t]=a,r&&p++}return p===0?{error:`Could not find the selected folder to rename.`}:{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}}function eT(e){return e.endsWith(`/`)}function tT(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`),r=n<0?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function nT(e){let t=[],n=new Set;for(let r of e)n.has(r)||(n.add(r),t.push(r));let r=new Set;for(let e of t.toSorted((e,t)=>e.length===t.length?e.localeCompare(t):e.length-t.length)){let t=(e.endsWith(`/`)?e.slice(0,-1):e).split(`/`),n=!1;for(let e=0;e<t.length-1;e+=1){let i=`${t.slice(0,e+1).join(`/`)}/`;if(r.has(i)){n=!0;break}}n||r.add(e)}return t.filter(e=>r.has(e))}function rT(e,t){return t.includes(e)?nT(t):[e]}function iT(e,t){return e===t?!0:e==null||t==null?!1:e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function aT(e,t){return{draggedPaths:e,target:t}}function oT(e,t){if(t.kind!==`directory`||t.directoryPath==null)return!1;for(let n of e)if(eT(n)&&(t.directoryPath===n||t.directoryPath.startsWith(n)))return!0;return!1}function sT(e,t){return t.kind===`root`||t.directoryPath==null?tT(e):t.directoryPath}function cT(e,t){let n=e.map(e=>{let n=sT(e,t);return n===e?null:{from:e,to:n,type:`move`}}).filter(e=>e!=null);return n.length===0?null:{operations:n,result:{draggedPaths:e,operation:n.length===1?`move`:`batch`,target:t}}}function lT(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function uT(e,t,n){let{paths:r,preparedInput:i}=e;if(i==null){if(r==null)throw Error(`FileTree requires paths or preparedInput`);return{paths:r,preparedInput:void 0}}let a=i.paths;if(r==null)return{paths:a,preparedInput:i};if(!lT(Jw.preparePaths(r,n==null?{}:{sort:n}),a))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:a,preparedInput:i}}function dT(e){return e.operation===`add`||e.operation===`remove`||e.operation===`move`||e.operation===`batch`}function fT(e,t,n){if(e===t)return n;let r=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(r)?`${n.endsWith(`/`)?n:`${n}/`}${e.slice(r.length)}`:e}function pT(e,t){if(e===t)return!0;let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)}function mT(e,t,n=!1){if(e==null)return null;switch(t.operation){case`add`:case`expand`:case`collapse`:case`mark-directory-unloaded`:case`begin-child-load`:case`apply-child-patch`:case`complete-child-load`:case`fail-child-load`:case`cleanup`:return e;case`remove`:return pT(e,t.path)?n?e:null:e;case`move`:return fT(e,t.from,t.to);case`batch`:{let r=e;for(let e of t.events)if(r=mT(r,e,n),r==null)return null;return r}}}function hT(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function gT(e){switch(e.operation){case`add`:return{...hT(e),operation:`add`,path:e.path};case`remove`:return{...hT(e),operation:`remove`,path:e.path,recursive:e.recursive};case`move`:return{...hT(e),from:e.from,operation:`move`,to:e.to}}}function _T(e){return{...hT(e),events:e.events.filter(e=>e.operation===`add`||e.operation===`remove`||e.operation===`move`).map(e=>gT(e)),operation:`batch`}}function vT(e){switch(e.operation){case`add`:case`remove`:case`move`:return gT(e);case`batch`:return _T(e);default:return null}}function yT(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function bT(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split(`/`);return n.slice(0,-1).map((e,t)=>`${n.slice(0,t+1).join(`/`)}/`)}function xT(e){return bT(e).at(-1)??null}function ST(e,t){return t==null?e:e.startsWith(t)?e.slice(t.length):e}function CT(e){return e.endsWith(`/`)}var wT=e=>e.toLowerCase();function TT(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?t:t.slice(n+1)}function ET(e){return e.endsWith(`/`)?e.slice(0,-1):e}function DT(e,t){return t&&!e.endsWith(`/`)?`${e}/`:e}var OT=e=>{let t=e.trim();return t.length===0?``:(t.includes(`\\`)?t.replaceAll(`\\`,`/`):t).toLowerCase()},kT=Symbol(`FILE_TREE_RENAME_VIEW`),AT=512,jT=512;function MT(e){return e===`top`||e===`center`?e:`nearest`}function NT(e,t,n){if(e===0)return-1;if(n!=null){let e=t(n);if(e!=null)return e;let r=bT(n);for(let e=r.length-1;e>=0;--e){let n=r[e];if(n==null)continue;let i=t(n);if(i!=null)return i}}return 0}function PT(e,t,n){if(e.paths.length===0)return{focusedIndex:-1,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};if(t==null)return{focusedIndex:0,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};let r=n??(t=>e.visibleIndexByPath.get(t)??null);return{focusedIndex:NT(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var FT=class e{static{Object.defineProperty(e.prototype,kT,{configurable:!0,value(){return{cancel:()=>{this.#q()},commit:()=>{this.#J()},getPath:()=>this.#T,getValue:()=>this.#E,isActive:()=>this.#T!=null,setValue:e=>{this.#Y(e)}}},writable:!0})}#e;#t=new Set;#n=new Map;#r=null;#i=null;#a=new Map;#o=new Map;#s=-1;#c=null;#l=!1;#u=e=>-1;#d=new Map;#f=null;#p=null;#m=null;#h=null;#g=null;#_;#v;#y;#b=[];#x=new Int32Array;#S=new Int32Array;#C=void 0;#w=!1;#T=null;#E=``;#D=!1;#O=new Set;#k=[];#A;#j=null;#M=null;#N=null;#P=null;#F=null;#I=null;#L=null;#R=0;#z=null;#B=new Set;#V=0;#H;#U=0;#W=!1;#G=0;#K;constructor(e){let{dragAndDrop:t,fileTreeSearchMode:n,initialSearchQuery:r,initialSelectedPaths:i,renaming:a,onSearchChange:o,paths:s,preparedInput:c,...l}=e,u=uT({paths:s,preparedInput:c},`constructor`,l.sort);this.#e=l,t!=null&&t!==!1&&(this.#r=t===!0?{}:t),this.#w=a!=null&&a!==!1,a!=null&&a!==!1&&a!==!0&&(this.#C=a.canRename,this.#v=a.onError,this.#_=a.onRename),this.#y=o,this.#A=n??`hide-non-matches`,this.#H=this.#le(u.paths,u.preparedInput);let d=i?.map(e=>this.#Ne(e)).filter(e=>e!=null)??[],f=d.at(-1)??null;d.length>0&&(this.#B=new Set(d),this.#z=f,this.#V=1),this.#je(f,!1),r!=null&&this.#Te(r,!1),this.#K=this.#Re()}destroy(){this.#K?.(),this.#K=null,this.#n.clear(),this.#t.clear(),this.#d.clear(),this.#i=null,this.#he()}focusFirstItem(){this.#be().length>0&&this.#Fe(0)}focusLastItem(){this.#G<=0||(this.#Ie(),this.#Fe(this.#G-1))}focusNextItem(){this.#Ae(1)}focusParentItem(){if(this.#c==null)return;let e=xT(this.#c);if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t)}focusPath(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;this.#Ie();let n=this.#Z(t);n>=0&&this.#Fe(n)}scrollToPath(e,t){let n=this.#H.getPathInfo(e)?.path??null;if(n==null)return;this.#Ie();let r=this.#xe(n);r<0||this.#Me(r)!=null&&(t?.focus!==!1&&this.#Fe(r,!1),this.#L={id:this.#R+=1,offset:MT(t?.offset),visibleIndex:r},this.#De())}focusMountedPathFromInput(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;let n=this.#Z(t);n>=0&&this.#Fe(n)}focusNearestPath(e){let t=this.resolveNearestVisiblePath(e);if(t==null)return null;let n=this.#Z(t);return n>=0?(this.#Fe(n),this.#be()[n]??t):null}focusPreviousItem(){this.#Ae(-1)}getFocusedIndex(){return this.#s}getFocusedItem(){return this.#c==null?null:this.#Q(this.#c)}getFocusedPath(){return this.#c}getScrollRequest(){return this.#L}clearScrollRequest(e){this.#L?.id===e&&(this.#L=null)}resolveNearestVisiblePath(e){let t=this.#be();if(this.#G===0)return null;if(e==null)return this.#c??t[0]??null;let n=this.#H.getPathInfo(e)?.path??e,r=this.#Z(n);return r>=0?t[r]??n:this.#X(n)??this.#c??t[0]??null}getSelectedPaths(){return[...this.#B]}getSelectionVersion(){return this.#V}getVisibleCount(){return this.#G}getVisibleRows(e,t){if(t<e||this.#G===0)return[];let n=Math.max(0,e),r=Math.min(this.#G-1,t);if(r<n)return[];let i=r-n+1;if(this.#F==null&&!this.#l&&r>=this.#b.length&&i<=jT){let e=[];for(let t=n;t<=r;t+=1){let n=this.#H.getVisibleRowContext(t);if(n==null)break;e.push(this.#ee(n))}return e}if(!this.#l&&r>=this.#b.length&&this.#Ie(),this.#F!=null){let e=Array.from({length:r-n+1},(e,t)=>this.#Se(n+t)),t=new Map,i=e[0]??-1,a=i;for(let n=1;n<=e.length;n+=1){let r=e[n];if(r!=null&&r===a+1){a=r;continue}if(i>=0&&this.#H.getVisibleSlice(i,a).forEach((e,n)=>{t.set(i+n,e)}),r==null){i=-1,a=-1;continue}i=r,a=r}return Array.from({length:r-n+1},(e,r)=>{let i=n+r,a=this.#Se(i),o=t.get(a),s=this.#b[a];if(o==null||s==null)throw Error(`Missing projection row for filtered visible index ${String(i)}`);return this.#$(o,i,a,{ancestorPaths:this.#re(a),path:s})})}return this.#H.getVisibleSlice(n,r).map((e,t)=>{let r=n+t,i=this.#b[r];if(i==null)throw Error(`Missing projection path for visible index ${String(r)}`);return this.#$(e,r,r,{ancestorPaths:this.#re(r),path:i})})}getStickyRowCandidates(e,t){if(this.#F!=null)return null;if(this.#G===0||e<=0||t<=0)return[];let n=[];for(let r=0;r<this.#G;r+=1){let i=e+r*t,a=Math.min(this.#G-1,Math.floor(i/t)),o=this.#te(a,r)??(a>0?this.#te(a-1,r):void 0);if(o==null)break;n.push({row:this.#ee(o),subtreeEndIndex:o.subtreeEndIndex})}return n}getItem(e){let t=this.#H.getPathInfo(e);return t==null?null:this.#Q(t.path,t)}resolveMountedDirectoryPathFromInput(e){let t=this.#H.getPathInfo(e);return t?.kind===`directory`?t.path:null}toggleMountedDirectoryFromInput(e){let t=this.resolveMountedDirectoryPathFromInput(e);t!=null&&this.#ze(t)}selectAllVisiblePaths(){this.#Ie();let e=[...this.#be()];this.#ae(e,this.#c??this.#z)}selectOnlyPath(e){let t=this.#Ne(e);t!=null&&this.#ae([t],t)}selectOnlyMountedPathFromInput(e){this.#ae([e],e)}selectPath(e){let t=this.#Ne(e);t==null||this.#B.has(t)||this.#ae([...this.#B,t])}deselectPath(e){let t=this.#Ne(e);t==null||!this.#B.has(t)||this.#ae([...this.#B].filter(e=>e!==t))}toggleFocusedSelection(){this.#c!=null&&this.togglePathSelectionFromInput(this.#c)}togglePathSelection(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.deselectPath(t);return}this.selectPath(t)}}togglePathSelectionFromInput(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.#ae([...this.#B].filter(e=>e!==t),t);return}this.#ae([...this.#B,t],t)}}selectPathRange(e,t){let n=this.#Ne(e);if(n==null)return;this.#Ie();let r=this.#z,i=r==null?-1:this.#Ce(r),a=this.#Ce(n);if(i===-1||a===-1){let e=t?[...this.#B,n]:[n];this.#ae(e,n);return}let[o,s]=i<=a?[i,a]:[a,i],c=this.#be().slice(o,s+1),l=t?[...this.#B,...c]:c;this.#ae(l,r)}extendSelectionFromFocused(e){if(this.#c==null)return;let t=this.#s;if(t===-1)return;let n=Math.min(this.#G-1,Math.max(0,t+e));if(n===t)return;!this.#l&&n>=this.#b.length&&this.#Ie();let r=this.#be(),i=r[t]??null,a=r[n]??null;if(i==null||a==null)return;let o=new Set(this.#B);o.has(i)&&o.has(a)?o.delete(i):o.add(a),this.#ae([...o],this.#z??i,!1),this.#Fe(n)}getDragAndDropConfig(){return this.#r}isDragAndDropEnabled(){return this.#r!=null}getDragSession(){return this.#i==null?null:{draggedPaths:[...this.#i.draggedPaths],primaryPath:this.#i.primaryPath,target:this.#i.target==null?null:{...this.#i.target}}}startDrag(e){if(this.#r==null)return!1;let t=this.#Ne(e);if(t==null||this.#M!=null&&this.#M.length>0)return!1;let n=this.getSelectedPaths(),r=rT(t,n);return this.#r.canDrag?.(r)!==!1&&(n.includes(t)||this.#ae([t],t,!1),this.#Pe(t),this.#i={draggedPaths:r,primaryPath:t,target:null},this.#De(),!0)}setDragTarget(e){let t=this.#i;if(t==null)return;let n=e;if(n!=null){let e=aT(t.draggedPaths,n);(oT(t.draggedPaths,n)||this.#r?.canDrop?.(e)===!1)&&(n=null)}iT(t.target,n)||(this.#i={...t,target:n},this.#De())}cancelDrag(){this.#i!=null&&(this.#i=null,this.#De())}completeDrag(){let e=this.#i;if(e==null)return!1;this.#i=null;let t=e.target==null?null:{...e.target};if(t==null)return this.#De(),!1;let n=aT(e.draggedPaths,t);if(oT(e.draggedPaths,t)||this.#r?.canDrop?.(n)===!1)return this.#De(),!1;let r=cT(e.draggedPaths,t);if(r==null)return this.#De(),!1;try{if(r.operations.length===1){let e=r.operations[0];if(e==null||e.type!==`move`)throw Error(`Expected a single move operation for one-item drops`);this.#H.move(e.from,e.to,{collision:e.collision})}else this.#ce(r.operations),this.#H.batch(r.operations)}catch(e){return this.#De(),this.#r?.onDropError?.(e instanceof Error?e.message:String(e),n),!1}return this.#r?.onDropComplete?.(r.result),!0}subscribe(e){return this.#t.add(e),e(),()=>{this.#t.delete(e)}}add(e){this.#H.add(e)}remove(e,t={}){this.#H.remove(e,t)}move(e,t,n={}){this.#H.move(e,t,n)}batch(e){this.#H.batch(e)}onMutation(e,t){let n=e,r=t,i=this.#n.get(n);return i??(i=new Set,this.#n.set(n,i)),i.add(r),()=>{let e=this.#n.get(n);e?.delete(r),e?.size===0&&this.#n.delete(n)}}setSearch(e){this.#Te(e,!0)}openSearch(e=``){this.#Te(e,!0)}closeSearch(){this.#Te(null,!0)}isSearchOpen(){return this.#M!==null}getSearchValue(){return this.#M??``}getSearchMatchingPaths(){return this.#k}focusNextSearchMatch(){this.#we(1)}focusPreviousSearchMatch(){this.#we(-1)}startRenaming(e=this.#c??``,t={}){if(!this.#w)return!1;let n=this.#H.getPathInfo(e);if(n==null)return!1;let r=n.path,i=CT(r),a=ET(r);if(this.#C?.({isFolder:i,path:a})===!1)return!1;for(let e of bT(r))this.#H.isExpanded(e)||this.#H.expand(e);return this.#ae([r],r,!1),this.#M!=null&&(this.#Te(null,!1),this.#y?.(this.#M)),this.#Pe(r),this.#T=r,this.#E=TT(r),this.#D=t.removeIfCanceled??!1,this.#De(),!0}#q(){if(this.#T==null)return;let e=this.#T,t=this.#D;if(this.#T=null,this.#E=``,this.#D=!1,t){this.remove(e,CT(e)?{recursive:!0}:void 0);return}this.#Pe(e),this.#De()}#J(){let e=this.#T;if(e==null)return;if(this.#D&&this.#E.trim().length===0){this.#T=null,this.#E=``,this.#D=!1,this.remove(e,CT(e)?{recursive:!0}:void 0);return}let t=CT(e),n=$w({files:this.#H.list(),isFolder:t,nextBasename:this.#E,path:ET(e)});if(this.#T=null,this.#E=``,this.#D=!1,`error`in n){this.#Pe(e),this.#v?.(n.error),this.#De();return}if(n.sourcePath===n.destinationPath){this.#Pe(e),this.#De();return}this.#_?.({destinationPath:n.destinationPath,isFolder:n.isFolder,sourcePath:n.sourcePath}),this.move(DT(n.sourcePath,t),DT(n.destinationPath,t))}#Y(e){this.#T!=null&&this.#E!==e&&(this.#E=e,this.#De())}resetPaths(e,t={}){let n=!Array.isArray(e),r=n?void 0:e,i=n?e:t,a=this.#H.list().length,o=this.#G,s=uT({paths:r,preparedInput:i.preparedInput},`resetPaths`,this.#e.sort),c=this.#le(s.paths,s.preparedInput,i.initialExpandedPaths),l=this.#c,u=this.#T,d=this.getSelectedPaths(),f=this.#z;this.#K?.(),this.#H=c,this.#d.clear(),this.#he();let p=d.map(e=>c.getPathInfo(e)?.path??null).filter(e=>e!=null),m=!yT(this.#B,p);this.#B=new Set(p),m&&(this.#V+=1),this.#z=f==null?null:c.getPathInfo(f)?.path??null,this.#T=u==null?null:c.getPathInfo(u)?.path??null,this.#T??(this.#E=``,this.#D=!1),this.#je(l,l!=null||p.length>0||this.#z!=null),this.#K=this.#Re(),this.#De(),this.#Oe({canonicalChanged:!0,operation:`reset`,pathCountAfter:s.paths.length,pathCountBefore:a,projectionChanged:!0,usedPreparedInput:i.preparedInput!=null,visibleCountDelta:this.#G-o})}#X(e){this.#Ie();let t=xT(e),n=ST(e,t),r=null,i=null;for(let e of this.#be()){if(xT(e)!==t)continue;let a=ST(e,t);if(a<n){r=e;continue}if(a>n){i=e;break}}return r??i}#Z(e){let t=this.#Ce(e);if(t!==-1)return t;let n=bT(e);for(let e=n.length-1;e>=0;--e){let t=n[e];if(t==null)continue;let r=this.#Ce(t);if(r!==-1)return r}return this.#be().length>0?0:-1}#Q(e,t){let n=this.#d.get(e);if(n!=null)return n;let r=t??this.#H.getPathInfo(e);if(r==null)return null;let i=r.kind===`directory`?this.#oe(r.path):this.#se(r.path);return this.#d.set(r.path,i),i}#$(e,t,n,r){return{ancestorPaths:r.ancestorPaths,depth:e.depth,flattenedSegments:e.flattenedSegments?.map(e=>({isTerminal:e.isTerminal,name:e.name,path:e.path})),hasChildren:e.hasChildren,index:t,isExpanded:e.isExpanded,isFlattened:e.isFlattened,isFocused:r.path===this.#c,isSelected:this.#B.has(r.path),kind:e.kind,level:e.depth,name:e.name,path:r.path,posInSet:r.posInSet??this.#x[n]??0,setSize:r.setSize??this.#S[n]??0}}#ee(e){return this.#$(e.row,e.index,e.index,{ancestorPaths:e.ancestorPaths,path:e.row.path,posInSet:e.posInSet,setSize:e.setSize})}#te(e,t){let n=this.#H.getVisibleRowContext(e);return n==null?void 0:n.ancestorRows[t]??(t===n.ancestorRows.length&&n.row.kind===`directory`&&n.row.isExpanded?n:void 0)}#ne(e){let t=this.#a.get(e);if(t!=null)return t;let n=this.#u(e),r=n<0?[]:[...this.#ne(n),n];return this.#a.set(e,r),r}#re(e){let t=this.#o.get(e);if(t!=null)return t;let n=this.#ne(e).map(e=>this.#b[e]??``).filter(e=>e!==``);return this.#o.set(e,n),n}#ie(e){this.#H.collapse(e)}#ae(e,t=this.#z,n=!0){let r=[...new Set(e)],i=!yT(this.#B,r),a=this.#z!==t;!i&&!a||(this.#B=new Set(r),this.#z=t,i&&(this.#V+=1),n&&this.#De())}#oe(e){return{collapse:()=>{this.#ie(e)},deselect:()=>{this.deselectPath(e)},expand:()=>{this.#ke(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!0,isExpanded:()=>this.#H.isExpanded(e),isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)},toggle:()=>{this.#ze(e)}}}#se(e){return{deselect:()=>{this.deselectPath(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!1,isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)}}}#ce(e){let t=this.#H.list();this.#le(t).batch(e)}#le(e,t,n){return new Jw({...this.#e,paths:e,preparedInput:t??void 0,...n===void 0?{}:{initialExpandedPaths:n}})}#ue(){return this.#h??=this.#H.list(),this.#h}#de(){if(this.#m!=null)return this.#m;let e=new Set;for(let t of this.#ue()){e.add(t);for(let n of bT(t))e.add(n)}return this.#m=[...e].sort(),this.#m}#fe(){return this.#g??=this.#ue().map(wT),this.#g}#pe(){return this.#f??=this.#de().filter(e=>e.endsWith(`/`)),this.#f}#me(){return this.#p??=this.#pe().map(wT),this.#p}#he(){this.#f=null,this.#p=null,this.#m=null,this.#h=null,this.#g=null}#ge(){return this.#pe().filter(e=>this.#H.isExpanded(e))}#_e(e){let t=new Set(this.#j??[]);if(e)for(let e of this.#B)for(let n of bT(e))t.add(n);this.#ve(t)}#ve(e){this.#W=!0;try{for(let t of this.#pe()){let n=e.has(t),r=this.#H.isExpanded(t);n&&!r?this.#H.expand(t):!n&&r&&this.#H.collapse(t)}}finally{this.#W=!1}}#ye(){if(this.#M==null||this.#M.length===0){this.#k=[],this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let e=this.#b;if(this.#k=e.filter(e=>this.#O.has(e)),this.#A!==`hide-non-matches`||this.#O.size===0){this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let t=[],n=[],r=new Map;for(let[i,a]of e.entries())this.#N?.has(a)===!0&&(r.set(a,n.length),t.push(i),n.push(a));this.#F=t,this.#I=n,this.#P=r,this.#G=n.length}#be(){return this.#I??this.#b}#xe(e){return this.#I==null?this.#H.getVisibleIndex(e)??-1:this.#P?.get(e)??-1}#Se(e){return this.#F?.[e]??e}#Ce(e){return this.#P?.get(e)??this.#H.getVisibleIndex(e)??-1}#we(e){let t=this.#k;if(t.length===0)return;let n=this.#c,r=n==null?-1:t.indexOf(n),i=t[r<0?e>0?0:t.length-1:Math.min(t.length-1,Math.max(0,r+e))];i!=null&&this.focusPath(i)}#Te(e,t){let n=e==null?null:OT(e),r=this.#M;if(r!==n){if(r==null&&n!=null&&(this.#j=this.#ge()),this.#M=n,n==null)this.#_e(!0),this.#j=null,this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else if(n.length===0)this.#_e(!1),this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else{let e=this.#Ee();this.#je(e,!0)}t&&(this.#y?.(this.#M),this.#De())}}#Ee(){if(this.#M==null||this.#M.length===0)return this.#O.clear(),this.#c;let e=this.#M,t=this.#ue(),n=this.#fe(),r=[],i=new Set,a=null;for(let o=0;o<t.length;o+=1){if(!n[o].includes(e))continue;let s=t[o];r.push(s),i.add(s),a??=s}let o=this.#pe(),s=this.#me();for(let t=0;t<o.length;t+=1){if(!s[t].includes(e))continue;let n=o[t];i.has(n)||(r.push(n),i.add(n),a??=n)}this.#O=i;let c=this.#A===`hide-non-matches`&&r.length>0?new Set:null;this.#N=c;let l=this.#A===`expand-matches`?new Set(this.#j??[]):new Set;for(let e of r){c?.add(e),e.endsWith(`/`)&&l.add(e);for(let t of bT(e))l.add(t),c?.add(t)}return this.#ve(l),a??this.#c}#De(){for(let e of this.#t)e()}#Oe(e){this.#n.get(e.operation)?.forEach(t=>{t(e)}),this.#n.get(`*`)?.forEach(t=>{t(e)})}#ke(e){for(let t of bT(e))this.#H.isExpanded(t)||this.#H.expand(t);this.#H.isExpanded(e)||this.#H.expand(e)}#Ae(e){let t=this.#G;if(t===0)return;let n=this.#s===-1?0:this.#s,r=Math.min(t-1,Math.max(0,n+e));(r!==n||this.#s===-1)&&(!this.#l&&this.#F==null&&r>=this.#b.length&&this.#Ie(),this.#Fe(r))}#je(e,t=!0){let n=this.#H.getVisibleCount();this.#U=n;let r=PT(this.#H.getVisibleTreeProjectionData(t?void 0:Math.min(n,AT)),e,t?e=>this.#H.getVisibleIndex(e):void 0);this.#a.clear(),this.#o.clear(),this.#l=r.paths.length>=n,this.#u=r.getParentIndex,this.#b=r.paths,this.#x=r.posInSetByIndex,this.#S=r.setSizeByIndex,this.#ye(),this.#s=e==null?this.#be().length>0?0:-1:this.#Z(e),this.#c=this.#s<0?null:this.#Me(this.#s)}#Me(e){return this.#be()[e]??(this.#F==null?this.#H.getVisibleRowContext(e)?.row.path??null:null)}#Ne(e){return this.#H.getPathInfo(e)?.path??null}#Pe(e){if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t,!1)}#Fe(e,t=!0){let n=this.#Me(e);n!=null&&(this.#s!==e||this.#c!==n)&&(this.#s=e,this.#c=n,t&&this.#De())}#Ie(){this.#l||this.#je(this.#c,!0)}#Le(e){let t=mT(this.#T,e);t==null&&this.#T!=null&&(this.#E=``),this.#T=t;let n=mT(this.#c,e,!0),r=[...this.#B].map(t=>mT(t,e)).filter(e=>e!=null).map(e=>this.#H.getPathInfo(e)?.path??null).filter(e=>e!=null),i=mT(this.#z,e),a=i==null?null:this.#H.getPathInfo(i)?.path??null,o=[...new Set(r)];return yT(this.#B,o)||(this.#B=new Set(o),this.#V+=1),this.#z=a,n}#Re(){return this.#H.on(`*`,e=>{if(this.#W)return;e.canonicalChanged&&(this.#d.clear(),this.#he()),this.#i!=null&&dT(e)&&(this.#i=null);let t=dT(e)?this.#Le(e):this.#c,n=this.#M!=null&&this.#M.length>0?this.#Ee():this.#M===``?this.#c:t,r=this.#M!=null||e.operation!==`expand`&&e.operation!==`collapse`;this.#je(n,r),this.#De();let i=vT(e);i!=null&&this.#Oe(i)})}#ze(e){if(this.#H.isExpanded(e)){this.#ie(e);return}this.#ke(e)}},IT=e=>{if(e==null||e.length===0)return`0`;let t=`${e.length}`;for(let n of e)t+=`\0${n.path}\0${n.status}`;return t};function LT(e){let t=e.endsWith(`/`),n=``,r=-1;for(let t=0;t<=e.length;t+=1){if(e[t]!==`/`&&t!==e.length){r===-1&&(r=t);continue}r!==-1&&(n!==``&&(n+=`/`),n+=e.slice(r,t),r=-1)}return n===``?null:{isDirectory:t,path:n}}function RT(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=[],r=0;for(;;){let e=t.indexOf(`/`,r);if(e===-1)break;n.push(t.slice(0,e+1)),r=e+1}return n}function zT(e,t){return t?`${e}/`:e}function BT(e,t=null){let n=IT(e==null?void 0:[...e]);if(n===`0`)return null;if(t?.signature===n)return t;let r=new Map,i=new Set,a=new Set,o=new Map;for(let t of e??[]){let e=HT(t);e!=null&&GT({canonicalPath:e.canonicalPath,changeCountByDirectoryPath:o,directoriesWithChanges:i,ignoredDirectoryPaths:a,isDirectory:e.isDirectory,status:t.status,statusByPath:r})}return r.size===0?null:{changeCountByDirectoryPath:o,directoriesWithChanges:i,ignoredDirectoryPaths:a,signature:n,statusByPath:r}}function VT(e,t){let n=t?.remove??[],r=t?.set??[];if(n.length===0&&r.length===0)return e;let i=new Map(e?.statusByPath),a=new Set(e?.directoriesWithChanges),o=new Set(e?.ignoredDirectoryPaths),s=new Map(e?.changeCountByDirectoryPath),c=!1;for(let e of n){let t=UT(e);t!=null&&(c=WT({canonicalPath:t.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,statusByPath:i})||c)}for(let e of r){let t=HT(e);t!=null&&(c=GT({canonicalPath:t.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,isDirectory:t.isDirectory,status:e.status,statusByPath:i})||c)}return c?i.size===0?null:{changeCountByDirectoryPath:s,directoriesWithChanges:a,ignoredDirectoryPaths:o,signature:JT(i),statusByPath:i}:e}function HT(e){return UT(e.path)}function UT(e){let t=LT(e);if(t!=null)return{canonicalPath:zT(t.path,t.isDirectory),isDirectory:t.isDirectory}}function WT({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,statusByPath:i}){let a=i.get(e);return a!=null&&(i.delete(e),a===`ignored`&&e.endsWith(`/`)&&r.delete(e),qT(t,n,e),!0)}function GT({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,isDirectory:i,status:a,statusByPath:o}){let s=o.get(e);return s!==a&&(s??KT(t,n,e),o.set(e,a),a===`ignored`&&i?r.add(e):i&&r.delete(e),!0)}function KT(e,t,n){for(let r of RT(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function qT(e,t,n){for(let r of RT(n)){let n=(e.get(r)??0)-1;n>0?e.set(r,n):(e.delete(r),t.delete(r))}}function JT(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\0${n}\0${r}`;return t}var YT=e=>e.trim().toLowerCase(),XT=e=>e.split(`/`).at(-1)??e,ZT=e=>{let t=e.toLowerCase().split(`.`),n=[];for(let e=1;e<t.length;e+=1)n.push(t.slice(e).join(`.`));return n};function QT(e,t){return typeof e==`string`?{name:e,remappedFrom:t}:{...e,remappedFrom:t}}function $T(e){let t=tx(e),n=t.remap,r=new Map;for(let[e,n]of Object.entries(t.byFileName??{}))r.set(e.toLowerCase(),n);let i=new Map;for(let[e,n]of Object.entries(t.byFileExtension??{}))i.set(YT(e),n);let a=Object.entries(t.byFileNameContains??{}).map(([e,t])=>[e.toLowerCase(),t]);return{resolveIcon:(e,o)=>{if(e===`file-tree-icon-file`&&o!=null){let s=XT(o),c=s.toLowerCase(),l=r.get(c);if(l!=null)return QT(l,e);for(let[t,n]of a)if(c.includes(t))return QT(n,e);let u=ZT(s);for(let t of u){let n=i.get(t);if(n!=null)return QT(n,e)}let d=$b(t.set,s,u);if(d!=null&&t.set!==`none`){if(d==="default"){let t=n?.[e];if(t!=null)return QT(t,e)}return{name:Zb(d),remappedFrom:e,token:d}}}let s=n?.[e];return s==null?{name:e}:QT(s,e)}}}var eE,tE,nE,rE,iE,aE,oE,sE,cE,lE,uE={},dE=[],fE=Array.isArray,pE=dE.slice,mE=Object.assign;function hE(e){e&&e.parentNode&&e.remove()}function gE(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return arguments.length>2&&(o.children=arguments.length>3?pE.call(arguments,2):n),_E(e,o,r,i,null)}function _E(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++tE,__i:-1,__u:0};return i==null&&eE.vnode!=null&&eE.vnode(a),a}function vE(e){return e.children}function yE(e,t){this.props=e,this.context=t,this.__g=0}function bE(e,t){if(t==null)return e.__?bE(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?bE(e):null}function xE(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=n.__e;break}return xE(e)}}function SE(e){(8&e.__g||!(e.__g|=8)||!nE.push(e)||iE++)&&rE==eE.debounceRendering||((rE=eE.debounceRendering)||queueMicrotask)(CE)}function CE(){for(var e,t,n,r,i,a,o,s,c=1;nE.length;)nE.length>c&&nE.sort(aE),e=nE.shift(),c=nE.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,a=[],o=[],(s=t.__P)&&((n=mE({},r)).__v=r.__v+1,eE.vnode&&eE.vnode(n),jE(s,n,r,t.__n,s.namespaceURI,32&r.__u?[i]:null,a,i??bE(r),!!(32&r.__u),o,s.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,NE(a,n,o),n.__e!=i&&xE(n)));iE=0}function wE(e,t,n,r,i,a,o,s,c,l,u,d){var f,p,m,h,g,_,v,y=r&&r.__k||dE,b=t.length;for(c=TE(n,t,y,c,b),f=0;f<b;f++)(m=n.__k[f])!=null&&(p=m.__i==-1?uE:y[m.__i]||uE,m.__i=f,_=jE(e,m,p,i,a,o,s,c,l,u,d),h=m.__e,m.ref&&p.ref!=m.ref&&(p.ref&&IE(p.ref,null,m),u.push(m.ref,m.__c||h,m)),g==null&&h!=null&&(g=h),(v=!!(4&m.__u))||p.__k===m.__k?c=EE(m,c,e,v):typeof m.type==`function`&&_!==void 0?c=_:h&&(c=h.nextSibling),m.__u&=-7);return n.__e=g,c}function TE(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(c=a+f,(o=e.__k[a]=typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?_E(null,o,null,null,null):fE(o)?_E(vE,{children:o},null,null,null):o.constructor==null&&o.__b>0?_E(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=e,o.__b=e.__b+1,s=null,(l=o.__i=DE(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=bE(s)),LE(s,s));return r}function EE(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=EE(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=bE(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function DE(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&e.key==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function OE(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n??``}function kE(e,t,n,r,i){var a;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||OE(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||OE(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(oE,`$1`)),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||={},e.__l[t+a]=n,n?r?n.l=r.l:(n.l=sE,e.addEventListener(t,a?lE:cE,a)):e.removeEventListener(t,a?lE:cE,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function AE(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=sE++;else if(t.u<n.l)return;return n(eE.event?eE.event(t):t)}}}function jE(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M=t.type;if(t.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),n.__c.__z&&(s=t.__e=n.__e=(a=n.__c.__z)[0],n.__c.__z=null)),(d=eE.__b)&&d(t);n:if(typeof M==`function`)try{if(v=t.props,y=`prototype`in M&&M.prototype.render,b=(d=M.contextType)&&r[d.__c],x=d?b?b.props.value:d.__:r,n.__c?2&(f=t.__c=n.__c).__g&&(f.__g|=1,_=!0):(y?t.__c=f=new M(v,x):(t.__c=f=new yE(v,x),f.constructor=M,f.render=RE),b&&b.sub(f),f.props=v,f.state||(f.state={}),f.context=x,f.__n=r,p=!0,f.__g|=8,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&M.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=mE({},f.__s)),mE(f.__s,M.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&M.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&M.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),!(4&f.__g)&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)||t.__v==n.__v){for(t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),S=0;S<f._sb.length;S++)f.__h.push(f._sb[S]);f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__g&=-5,C=eE.__r,w=0,y){for(f.state=f.__s,f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),T=0;T<f._sb.length;T++)f.__h.push(f._sb[T]);f._sb=[]}else do f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(8&f.__g&&++w<25);f.state=f.__s,f.getChildContext!=null&&(r=mE({},r,f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),E=d,d!=null&&d.type===vE&&d.key==null&&(E=PE(d.props.children)),s=wE(e,fE(E)?E:[E],t,n,r,i,a,o,s,c,l,u),t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__g&=-4)}catch(e){if(t.__v=null,c||a!=null){if(e.then){for(D=0,O=!1,t.__u|=c?160:128,t.__c.__z=[],k=0;k<a.length;k++)(A=a[k])==null||O||(A.nodeType==8&&A.data==`$s`?(D>0&&t.__c.__z.push(A),D++,a[k]=null):A.nodeType==8&&A.data==`/$s`?(--D>0&&t.__c.__z.push(A),O=D===0,s=a[k],a[k]=null):D>0&&(t.__c.__z.push(A),a[k]=null));if(!O){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__c.__z=[s]}t.__e=s}else{for(j=a.length;j--;)hE(a[j]);ME(t)}}else t.__e=n.__e,t.__k=n.__k,e.then||ME(t);eE.__e(e,t,n)}else s=t.__e=FE(n.__e,t,n,r,i,a,o,c,l,u);return(d=eE.diffed)&&d(t),128&t.__u?void 0:s}function ME(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(ME)}function NE(e,t,n){for(var r=0;r<n.length;r++)IE(n[r],n[++r],n[++r]);eE.__c&&eE.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){eE.__e(e,t.__v)}})}function PE(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:fE(e)?e.map(PE):mE({},e)}function FE(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v=n.props,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(u=0;u<a.length;u++)if((m=a[u])&&`setAttribute`in m==!!b&&(b?m.localName==b:m.nodeType==3)){e=m,a[u]=null;break}}if(e==null){if(b==null)return l.createTextNode(y);e=l.createElementNS(i,b,y.is&&y),s&&=(eE.__m&&eE.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=pE.call(e.childNodes),v=n.props||uE,!s&&a!=null)for(v={},u=0;u<e.attributes.length;u++)v[(m=e.attributes[u]).name]=m.value;for(u in v)if(m=v[u],u!=`children`){if(u==`dangerouslySetInnerHTML`)f=m;else if(!(u in y)){if(u==`value`&&`defaultValue`in y||u==`checked`&&`defaultChecked`in y)continue;kE(e,u,null,m,i)}}for(u in _=1&n.__u,y)m=y[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||v[u]===m&&!_||kE(e,u,m,v[u],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=``),wE(b==`template`?e.content:e,fE(p)?p:[p],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&bE(n,0),s,c,l),a!=null)for(u=a.length;u--;)hE(a[u]);s||(u=`value`,b==`progress`&&h==null?e.removeAttribute(`value`):h==null||h===e[u]&&(b!==`progress`||h)||kE(e,u,h,v[u],i),u=`checked`,g!=null&&g!=e[u]&&kE(e,u,g,v[u],i))}return e}function IE(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){eE.__e(e,n)}}function LE(e,t,n){var r,i;if(eE.unmount&&eE.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||IE(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){eE.__e(e,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&LE(r[i],t,n||typeof e.type!=`function`);n||hE(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function RE(e,t,n){return this.constructor(e,n)}function zE(e,t){var n,r,i,a;t==document&&(t=document.documentElement),eE.__&&eE.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=gE(vE,null,[e]),i=[],a=[],jE(t,e,r||uE,uE,t.namespaceURI,r?null:t.firstChild?pE.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a,t.ownerDocument),NE(i,e,a)}function BE(e,t){e.__u|=32,zE(e,t)}eE={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=8&i.__g),o)return void(i.__g|=2)}catch(t){e=t}}throw iE=0,e}},tE=0,yE.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=mE({},this.state);typeof e==`function`&&(e=e(mE({},n),this.props)),e&&mE(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),SE(this))},yE.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),SE(this))},yE.prototype.render=vE,nE=[],iE=0,aE=function(e,t){return e.__v.__b-t.__v.__b},oE=/(PointerCapture)$|Capture$/i,sE=0,cE=AE(!1),lE=AE(!0);var VE=0;Array.isArray;function Q(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--VE,__i:-1,__u:0,__source:i,__self:a};return eE.vnode&&eE.vnode(l),l}var HE=16,UE=16,WE={};function GE({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:a,label:o,alignCapitals:s=!1}){"use no memo";let c=`#${e.replace(/^#/,``)}`,{width:l,height:u,viewBox:d}=WE[e]??{width:HE,height:UE},f=r??l,p=i??u,m=a??d??`0 0 ${l} ${u}`;return Q(`svg`,{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":s,...o==null?{"aria-hidden":!0}:{"aria-label":o,role:`img`},viewBox:m,width:f,height:p,children:Q(`use`,{href:c})})}var KE=e=>e!==void 0&&/\s/.test(e),qE=(e,t)=>{let n=t=>KE(e[t-1])||KE(e[t]);if(!n(t))return t;for(let r=1;r<e.length;r++){let i=t-r;if(i>0&&!n(i))return i;let a=t+r;if(a<e.length&&!n(a))return a}return t},JE=e=>qE(e,Math.ceil(e.length/2)),YE=e=>{if(e.length<2)return[e,``];let t=JE(e);return[e.slice(0,t),e.slice(t)]},XE=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`.`)+1,n=e.length-t>10,r=t>=1&&!n?t:JE(e);return[e.slice(0,r),e.slice(r)]},ZE=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`/`)+1,n=e.length-t>25,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},QE=(e,{splitIndex:t}={})=>{if(typeof t!=`number`){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}return[e.slice(0,t),e.slice(t)]},$E=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},eD=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=t;return[e.slice(0,n),e.slice(n)]};function tD({children:e,marker:t,variant:n=`default`}){"use no memo";return Q(`div`,{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:Q(`div`,{"data-truncate-marker":!0,children:typeof t==`function`?t({children:e}):n===`fade`?Q(`span`,{"data-truncate-fade":!0}):t})})}function nD(e){"use no memo";let{mode:t,children:n}=e;return Q(`div`,{children:[Q(`div`,{"data-truncate-content":`visible`,children:t===`fruncate`?Q(`span`,{children:n}):n}),Q(`div`,{"data-truncate-content":`overflow`,"aria-hidden":!0,children:t===`fruncate`?Q(`span`,{children:n}):n})]})}function rD({children:e,mode:t=`truncate`,marker:n=`…`,variant:r=`default`,...i}){"use no memo";let a=Q(nD,{mode:t,children:e},`content`),o=Q(tD,{marker:n,mode:t,variant:r},`marker`),s=Q(`div`,{"data-truncate-fill":!0},`fill`);return Q(`div`,{"data-truncate-container":t,"data-truncate-variant":r,...i,children:Q(`div`,{"data-truncate-grid":!0,children:t===`truncate`?[a,o]:[o,a,s]})})}function iD({children:e,...t}){"use no memo";return Q(rD,{mode:`truncate`,...t,children:e})}function aD({children:e,...t}){"use no memo";return Q(rD,{mode:`fruncate`,...t,children:e})}function oD({children:e,contents:t,priority:n=`end`,split:r=`center`,minimumLength:i=12,className:a,style:o,...s}){"use no memo";let c=null,l=null;if(Array.isArray(t)){if(t.length!==2)return console.error(`MiddleTruncate: contents must be an array of two items`),null;c=Q(iD,{...s,children:t[0]}),l=Q(aD,{...s,children:t[1]})}else{if(typeof e!=`string`)return console.error(`MiddleTruncate: children must be a string`),null;if(e.length===0)return Q(`div`,{className:a,style:o});if(e.length<i)return Q(n===`end`?aD:iD,{...s,className:a,style:o,children:e});let t=null,u=null,d=null;if(typeof r==`string`)r===`center`?t=YE:r===`extension`?t=XE:r===`leaf-path`&&(t=ZE);else if(typeof r==`number`)t=QE,u=r;else if(Array.isArray(r)){let[e,n]=r;d=n,e===`last`?t=$E:e===`first`&&(t=eD)}else typeof r==`function`&&(t=r);t??=YE;let[f,p]=t(e,{priority:n,variant:s.variant,splitIndex:typeof u==`number`?u:void 0,splitOffset:typeof d==`number`?d:void 0}),m=f.length>=p.length,h=n===`equal`&&!m,g=n===`equal`&&m,_={},v={};h&&(_.marker=``),g&&(v.marker=``),c=Q(iD,{...s,..._,children:f}),l=Q(aD,{...s,...v,children:p})}return Q(`div`,{"data-truncate-group-container":`middle`,className:a,style:o,children:[Q(`div`,{"data-truncate-segment-priority":n===`start`||n===`equal`?`1`:`2`,children:c}),Q(`div`,{"data-truncate-segment-priority":n===`end`||n===`equal`?`1`:`2`,children:l})]})}var sD={endIndex:-1,startIndex:-1};function cD(e,t,n){return Math.min(Math.max(e,t),n)}function lD(e,t){return e<0||t<e?sD:{endIndex:t,startIndex:e}}function uD(e){return e.startIndex<0||e.endIndex<e.startIndex}function dD(e,t){return uD(e)?0:(e.endIndex-e.startIndex+1)*t}function fD(e,t,n){if(t<=0)return-1;let r=t*n;return e<=0?0:e>=r?t:Math.floor(e/n)}function pD(e,t,n){return t<=0||e<=0?-1:e>=t*n?t-1:Math.ceil(e/n)-1}function mD(e){let t=new Map;return e.forEach((e,n)=>{if(e.kind!==`directory`||!e.isExpanded)return;let r=e.ancestorPaths.length,i=t.get(r);if(i==null){t.set(r,[n]);return}i.push(n)}),t}function hD(e,t){let n=0,r=e.length-1,i=-1;for(;n<=r;){let a=Math.floor((n+r)/2),o=e[a];if(o==null)break;if(o<=t){i=a,n=a+1;continue}r=a-1}return i}function gD(e){let t=new Map,n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=i.kind===`directory`&&i.isExpanded?[...i.ancestorPaths,i.path]:i.ancestorPaths,o=0;for(;o<n.length&&o<a.length&&n[o]===a[o];)o+=1;for(let e=n.length-1;e>=o;--e){let i=n[e];i!=null&&t.set(i,r-1)}n.length=o;for(let e=o;e<a.length;e+=1){let t=a[e];t!=null&&n.push(t)}}let r=e.length-1;for(let e of n)t.set(e,r);return t}function _D(e,t,n){if(e.length===0||t<=0)return[];let r=gD(e),i=mD(e),a=[];for(let r=0;r<e.length;r+=1){let o=i.get(r);if(o==null||o.length===0)break;let s=t+r*n,c=hD(o,Math.min(e.length-1,Math.floor(s/n))),l=null;for(;c>=0;){let t=o[c],n=t==null?null:e[t]??null;if(n!=null&&(r===0||n.ancestorPaths[r-1]===a[r-1]?.path)){l=n;break}--c}if(l==null)break;a.push(l)}return a.map((i,a)=>{let o=a*n,s=(r.get(i.path)??e.length-1)+1;if(s>=e.length)return{row:i,top:o};let c=s*n-t;return{row:i,top:Math.min(o,c-n)}}).filter(e=>e.top+n>0)}function vD(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),a=Math.max(0,Math.floor(t.overscan)),o=Math.max(0,r-i),s=cD(t.scrollTop,0,o),c=t.stickyRows??_D(e,s,t.itemHeight),l=c.reduce((e,n)=>Math.max(e,n.top+t.itemHeight),0),u=Math.min(r,s+l),d=Math.max(0,i-l),f=Math.max(0,r-u),p=fD(s,n,t.itemHeight),m=fD(u,n,t.itemHeight),h=l<=0||p<0||p>=n?-1:p,g=h===-1?-1:Math.min(n-1,m-1),_=h===-1||g<h?0:g-h+1,v=d<=0||m>=n?sD:lD(m,pD(u+d,n,t.itemHeight)),y=g+1,b=uD(v)?sD:lD(Math.max(y,v.startIndex-a),Math.min(n-1,v.endIndex+a)),x=dD(b,t.itemHeight);return{occlusion:{firstOccludedIndex:h,lastOccludedIndex:g,occludedCount:_},physical:{itemHeight:t.itemHeight,maxScrollTop:o,overscan:a,scrollTop:s,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:f,paneHeight:d,paneTop:u},sticky:{height:l,rows:c},visible:v,window:{endIndex:b.endIndex,height:x,offsetTop:uD(b)?0:b.startIndex*t.itemHeight,startIndex:b.startIndex}}}var yD={added:`A`,deleted:`D`,ignored:null,modified:`M`,renamed:`R`,untracked:`U`},bD={added:`Git status: added`,deleted:`Git status: deleted`,ignored:`Git status: ignored`,modified:`Git status: modified`,renamed:`Git status: renamed`,untracked:`Git status: untracked`},xD=`Contains git status items`;function SD(e){return e.current?!0:(e.current=!0,!1)}function CD(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:a}=e;if(n<0)return null;let o=Math.max(0,i),s=n*r,c=s+r;if(s<t+o){let e=Math.max(0,s-o);return e===t?null:e}if(c>t+a){let e=c-a;return e===t?null:e}return null}function wD(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:a=0,totalHeight:o,viewportHeight:s}=e;if(i===`nearest`)return CD({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:a,viewportHeight:s});if(n<0)return null;let c=Math.max(0,a),l=n*r,u=Math.max(0,s-c),d=i===`center`?c+Math.max(0,(u-r)/2):c,f=Math.max(0,o-s),p=Math.max(0,Math.min(l-d,f));return p===t?null:p}function TD(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:a,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),c=n*r,l=c+r,u=t+s,d=t+o;if(c>=u&&l<=d)return null;let f=Math.max(0,a-o),p=Math.max(0,Math.min(c-s,f));return p===t?null:p}function ED(e){if(e==null||!e.isConnected||e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();return t instanceof ShadowRoot?t.activeElement===e:document.activeElement===e}function DD(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let e=t.activeElement;return e instanceof HTMLElement?e:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function OD(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;return n>0?n:e.clientHeight>0?e.clientHeight:t}function kD(e,t){return e!=null&&e>0?e:t}function AD(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;return n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0?n.blockSize:e.contentRect.height>0?e.contentRect.height:null}function jD(e,t,n,r,i=0){let a=CD({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});return a!=null&&(e.scrollTop=a,!0)}function MD(e,t,n,r,i,a,o=0){let s=wD({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:a,topInset:o,totalHeight:i,viewportHeight:r});return s!=null&&(e.scrollTop=s,!0)}function ND(e,t,n,r,i,a){let o=TD({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:a,totalHeight:i,viewportHeight:r});return o!=null&&(e.scrollTop=o,!0)}function PD(e,t,n,r){return n.end<n.start?null:e<n.start?-t:e>n.end?r:null}function FD(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;return t==null?`reset`:r?n===t?`ignore`:`focus-input`:`reveal-canonical`}function ID({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:a}){return Q(`input`,{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:a,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})}function LD(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:a,isParked:o,itemHeight:s,features:c,state:l,extraStyle:u}=e,d=n===`sticky`,f=t.ancestorPaths.at(-1)??``,p={};return l.isFocusRinged&&(p[`data-item-focused`]=!0),t.isSelected&&(p[`data-item-selected`]=!0),l.isContextHovered&&(p[`data-item-context-hover`]=`true`),l.isDragTarget&&(p[`data-item-drag-target`]=!0),l.isDragging&&(p[`data-item-dragging`]=!0),l.effectiveGitStatus!=null&&(p[`data-item-git-status`]=l.effectiveGitStatus),l.containsGitChange&&(p[`data-item-contains-git-change`]=`true`),{"aria-expanded":!d&&t.kind===`directory`?t.isExpanded:void 0,"aria-haspopup":c.contextMenuEnabled?`menu`:void 0,"aria-label":i,"aria-level":d?void 0:t.level+1,"aria-posinset":d?void 0:t.posInSet+1,"aria-selected":d?void 0:t.isSelected?`true`:`false`,"aria-setsize":d?void 0:t.setSize,"data-file-tree-sticky-path":d?r:void 0,"data-file-tree-sticky-row":d?`true`:void 0,"data-item-context-menu-button-visibility":c.actionLaneEnabled?c.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":c.contextMenuEnabled?c.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":c.actionLaneEnabled?`true`:void 0,"data-item-has-git-lane":c.gitLaneActive?`true`:void 0,"data-item-parent-path":f.length>0?f:void 0,"data-item-parked":o?`true`:void 0,"data-item-path":r,"data-item-type":t.kind===`directory`?`folder`:`file`,"data-type":`item`,id:d?void 0:a,role:d?void 0:`treeitem`,style:{minHeight:`${s}px`,...u},tabIndex:!d&&t.isFocused?0:-1,...p}}function RD(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,a=t.ctrlKey||t.metaKey,o=t.shiftKey||a,s=t.shiftKey?{additive:a,kind:`range`}:a?{kind:`toggle`}:{kind:`single`};return{closeSearch:r,revealCanonical:n===`sticky`,selection:s,toggleDirectory:!o&&i}}var zD,BD,VD,HD,UD=Object.is,WD=0,GD=[],KD=eE,qD=KD.__b,JD=KD.__r,YD=KD.diffed,XD=KD.__c,ZD=KD.unmount,QD=KD.__;function $D(e,t){KD.__h&&KD.__h(BD,e,WD||t),WD=0;var n=BD.__H||(BD.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function eO(e){return WD=1,tO(fO,e)}function tO(e,t,n){var r=$D(zD++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):fO(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);UD(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=BD,!BD.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,UD(t,e.__[0])||(o=!0)}}),a&&a.call(this,e,t,n)||o};BD.__f=!0;var a=BD.shouldComponentUpdate,o=BD.componentWillUpdate;BD.componentWillUpdate=function(e,t,n){if(4&this.__g){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},BD.shouldComponentUpdate=i}return r.__N||r.__}function nO(e,t){var n=$D(zD++,3);!KD.__s&&dO(n.__H,t)&&(n.__=e,n.u=t,BD.__H.__h.push(n))}function rO(e,t){var n=$D(zD++,4);!KD.__s&&dO(n.__H,t)&&(n.__=e,n.u=t,BD.__h.push(n))}function $(e){return WD=5,iO(function(){return{current:e}},[])}function iO(e,t){var n=$D(zD++,7);return dO(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function aO(e,t){return WD=8,iO(function(){return e},t)}function oO(){for(var e;e=GD.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(lO),e.__H.__h.forEach(uO),e.__H.__h=[]}catch(t){e.__H.__h=[],KD.__e(t,e.__v)}}KD.__b=function(e){BD=null,qD&&qD(e)},KD.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),QD&&QD(e,t)},KD.__r=function(e){JD&&JD(e),zD=0;var t=(BD=e.__c).__H;t&&(VD===BD?(t.__h=[],BD.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(lO),t.__h.forEach(uO),t.__h=[],zD=0)),VD=BD},KD.diffed=function(e){YD&&YD(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(GD.push(t)!==1&&HD===KD.requestAnimationFrame||((HD=KD.requestAnimationFrame)||cO)(oO)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),VD=BD=null},KD.__c=function(e,t){t.some(function(e){try{e.__h.forEach(lO),e.__h=e.__h.filter(function(e){return!e.__||uO(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],KD.__e(n,e.__v)}}),XD&&XD(e,t)},KD.unmount=function(e){ZD&&ZD(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{lO(e)}catch(e){t=e}}),n.__H=void 0,t&&KD.__e(t,n.__v))};var sO=typeof requestAnimationFrame==`function`;function cO(e){var t,n=function(){clearTimeout(r),sO&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);sO&&(t=requestAnimationFrame(n))}function lO(e){var t=BD,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),BD=t}function uO(e){var t=BD;e.__c=e.__(),BD=t}function dO(e,t){return!e||e.length!==t.length||t.some(function(t,n){return!UD(t,e[n])})}function fO(e,t){return typeof t==`function`?t(e):t}function pO(e,t=null,n=null){"use no memo";let r=e.flattenedSegments;return r==null||r.length===0?t??e.name:Q(`span`,{"data-item-flattened-subitems":!0,children:r.map((e,i)=>{let a=i===r.length-1;return Q(vE,{children:[Q(`span`,{"data-item-flattened-subitem":e.path,"data-item-flattened-subitem-drag-target":n===e.path?`true`:void 0,children:a&&t!=null?t:Q(iD,{children:e.name})}),i<r.length-1?` / `:``]},e.path)})})}function mO(e){return e.isFlattened?e.flattenedSegments?.findLast(e=>e.isTerminal)?.path??e.path:e.path}function hO(e){let t=e.flattenedSegments;return t==null||t.length===0?e.name:t.map(e=>e.name).join(` / `)}function gO(e,t,n,r){return e.map((e,i)=>{let a=i*n,o=e.subtreeEndIndex+1;if(o>=r)return{row:e.row,top:a};let s=o*n-t;return{row:e.row,top:Math.min(a,s-n)}}).filter(e=>e.top+n>0)}function _O({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:a}){let o=e.getVisibleCount(),s=i&&o>0?e.getStickyRowCandidates(r,t):[],c=s==null&&i&&o>0?e.getVisibleRows(0,o-1):[],l=vD(c,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:s==null?void 0:gO(s,r,t,o),totalRowCount:o,viewportHeight:a}),u=i&&r<=0&&o>0?e.getStickyRowCandidates(1,t):[],d=u!=null&&r<=0?gO(u,1,t,o):i&&r<=0&&c.length>0?_D(c,1,t):l.sticky.rows;return{overlayHeight:d.reduce((e,n)=>Math.max(e,n.top+t),0),overlayRows:d,snapshot:l,visibleRows:c}}var vO=400,yO=40,bO=18;function xO(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,a=r.elementFromPoint?.(t,n)??i?.(t,n)??null;return e instanceof ShadowRoot&&(a==null||!e.contains(a))?SO(e,t,n):a instanceof HTMLElement?a:null}function SO(e,t,n){let r=Array.from(e.querySelectorAll(`[data-type="item"], [data-item-flattened-subitem]`));for(let e=r.length-1;e>=0;e--){let i=r[e],a=i.getBoundingClientRect();if(t>=a.left&&t<=a.right&&n>=a.top&&n<=a.bottom)return i}return null}function CO(e){let t=e?.closest?.(`[data-type="item"]`);if(!(t instanceof HTMLElement))return null;let n=t.dataset.itemPath??null;if(n==null)return null;let r=e?.closest?.(`[data-item-flattened-subitem]`),i=r instanceof HTMLElement?r.getAttribute(`data-item-flattened-subitem`)??null:null;if(i!=null&&i.endsWith(`/`))return{directoryPath:i,flattenedSegmentPath:i,hoveredPath:n,kind:`directory`};if(t.dataset.itemType===`folder`)return{directoryPath:n,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`};let a=t.dataset.itemParentPath??null;return a==null||a.length===0?{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:`root`}:{directoryPath:a,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`}}function wO(e){let t=e.cloneNode(!0);return t.removeAttribute(`id`),t.dataset.fileTreeDragPreview=`true`,t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,Object.assign(t.style,{boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`,left:`0px`,margin:`0`,pointerEvents:`none`,position:`fixed`,top:`0px`,willChange:`transform`,zIndex:`10000`}),t}function TO(){return navigator.vendor!==`Apple Computer, Inc.`}function EO(e,t){let n=e-t.top;if(n<yO)return-Math.ceil((yO-Math.max(0,n))/yO*bO);let r=t.bottom-e;return r<yO?Math.ceil((yO-Math.max(0,r))/yO*bO):0}function DO(e,t){if(e!=null){let t=yD[e];return t==null?null:{text:t,title:bD[e]}}return t?{icon:{name:`file-tree-icon-dot`,width:6,height:6},title:xD}:null}function OO(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;--i){let a=e[i],o=n.get(a);if(o!=null){for(let e of r)n.set(e,o);return o?`ignored`:null}if(t.has(a)){n.set(a,!0);for(let e of r)n.set(e,!0);return`ignored`}r.push(a)}for(let e of r)n.set(e,!1);return null}function kO(e){return e!=null&&`toggle`in e}function AO(e){return e.code===`Space`||e.key===` `||e.key===`Spacebar`}function jO(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function MO(e){return e==null?``:`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}"] { opacity: 1; }`}function NO(e){return e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`}function PO(e,t){return t&&NO(e)||(e.ctrlKey||e.metaKey)&&AO(e)?!0:e.key===`ArrowDown`||e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`}var FO=new Set([`ArrowDown`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`]);function IO(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&(t.dataset.fileTreeContextMenuRoot===`true`||t.dataset.type===`context-menu-anchor`||t.dataset.type===`context-menu-trigger`||t.getAttribute(`slot`)===`context-menu`))return!0;return!1}function LO(e){return{bottom:e.bottom,height:e.height,left:e.left,right:e.right,top:e.top,width:e.width,x:e.x,y:e.y}}function RO(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function zO(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function BO(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function VO(e,t,n){if(e==null)return null;let r=t.get(e)??null;if(r!=null)return r;let i=n.get(e)??null;return i?.dataset.itemParked===`true`?null:i}function HO(e){if(e==null)return[];let t=[];for(let n of e.querySelectorAll(`button[data-file-tree-sticky-row="true"]`)){if(!(n instanceof HTMLElement))continue;let e=n.dataset.fileTreeStickyPath;e!=null&&t.push(e)}return t}function UO(e,t){if(e==null||t==null)return null;for(let n of e.querySelectorAll(`button[data-item-focused="true"][data-item-parked="true"]`))if(n instanceof HTMLElement&&n.dataset.itemPath===t)return n;return null}function WO(e,t,n,r,i,a,o){let s=Math.max(0,a-i),c=t?.getBoundingClientRect()??null,l=c==null||n==null?null:n.getBoundingClientRect().top-c.top,u=UO(e,r),d=c==null||u==null?null:u.getBoundingClientRect().top-c.top;return Math.max(0,Math.min(d??Math.max(l??0,s),Math.max(0,o-i)))}function GO(e,t){return{kind:e.kind,name:hO(e),path:t}}function KO(e){return e==null?void 0:`${e}__tree`}function qO(e,t,n){if(e!=null)return`${e}__focused-item-${encodeURIComponent(t)}${n?`__parked`:``}`}function JO(e){return e===`file-tree-icon-chevron`||e===`file-tree-icon-dot`||e===`file-tree-icon-file`||e===`file-tree-icon-lock`}function YO(e,t){if(e==null)return null;if(`text`in e)return e.parts==null?Q(`span`,{title:e.title,children:e.text}):Q(`span`,{title:e.title,children:e.parts.map((e,t)=>Q(`span`,{style:{color:e.color},children:e.text},t))});let n=typeof e.icon==`string`?JO(e.icon)?t(e.icon):{name:e.icon}:JO(e.icon.name)?(()=>{let n=t(e.icon.name),{name:r,...i}=e.icon;return{...n,...i}})():e.icon;return Q(`span`,{title:e.title,children:Q(GE,{...n})})}function XO(e){e!=null&&ED(e.querySelector([`button:not([disabled])`,`[href]`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`, `))??e)}function ZO(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:a=null,gitDecoration:o=null,gitLaneActive:s=!1,renameInput:c=null,showDecorativeActionAffordance:l=!1}={}){let u=mO(e);return Q(vE,{children:[e.depth>0?Q(`div`,{"data-item-section":`spacing`,children:Array.from({length:e.depth}).map((t,n)=>Q(`div`,{"data-item-section":`spacing-item`,"data-ancestor-path":e.ancestorPaths[n]},n))}):null,Q(`div`,{"data-item-section":`icon`,children:e.kind===`directory`?Q(GE,{...t(`file-tree-icon-chevron`)}):Q(GE,{...t(`file-tree-icon-file`,u)})}),Q(`div`,{"data-item-section":`content`,children:e.isFlattened?pO(e,c,a):c??Q(oD,{minimumLength:5,split:`extension`,children:e.name})}),i?Q(`div`,{"data-item-section":`decoration`,children:r==null?null:YO(r,t)}):null,s?Q(`div`,{"data-item-section":`git`,children:YO(o,t)}):null,n?Q(`div`,{"data-item-section":`action`,children:l?Q(`span`,{"aria-hidden":`true`,"data-item-action-affordance":`decorative`,children:Q(GE,{...t(`file-tree-icon-ellipsis`)})}):null}):null]})}function QO(e,t,n,r={}){let{controller:i,renameView:a,visualFocusPath:o,contextHoverPath:s,draggedPathSet:c,dragTarget:l,dragAndDropEnabled:u,shouldSuppressContextMenu:d,handleRowDragStart:f,handleRowDragEnd:p,handleRowTouchStart:m,instanceId:h,itemHeight:g,gitStatusByPath:_,ignoredGitDirectories:v,ignoredInheritanceCache:y,directoriesWithGitChanges:b,gitLaneActive:x,contextMenuEnabled:S,contextMenuTriggerMode:C,contextMenuButtonTriggerEnabled:w,contextMenuButtonVisibility:T,contextMenuRightClickEnabled:E,registerRenameInput:D,registerButton:O,resolveIcon:k,renderDecorationForRow:A,openContextMenuForRow:j,onRowClick:M,onKeyDown:ee}=e,N=mO(t),{isParked:P=!1,mode:te=`flow`,style:ne}=r,F=te===`sticky`,re=_?.get(N)??null??OO(t.ancestorPaths,v,y),ie=t.kind===`directory`&&(b?.has(N)??!1),I=A(t,N),L=DO(re,ie),ae=S&&w,oe=I!=null||x||ae,se=ae&&T===`always`,ce=a.getPath()===N,le=ce?a.getValue():``,R=F||!ce?null:Q(ID,{ref:D,ariaLabel:`Rename ${hO(t)}`,isFlattened:t.isFlattened,value:le,onBlur:()=>{a.commit()},onInput:e=>{a.setValue(e.currentTarget.value)}}),ue=ZO(t,k,{actionLaneEnabled:ae,customDecoration:I,decorationLaneEnabled:oe,dragTargetFlattenedSegmentPath:l?.flattenedSegmentPath??null,gitDecoration:L,gitLaneActive:x,renameInput:R,showDecorativeActionAffordance:se}),de={...LD({ariaLabel:hO(t),domId:t.isFocused?qO(h,N,P):void 0,extraStyle:ne,features:{actionLaneEnabled:ae,contextMenuButtonVisibility:ae?T:null,contextMenuEnabled:S,contextMenuTriggerMode:S?C:null,gitLaneActive:x},isParked:P,itemHeight:g,mode:te,row:t,state:{containsGitChange:ie,effectiveGitStatus:re,isContextHovered:s===N,isDragTarget:l?.kind===`directory`&&l.directoryPath===N,isDragging:c?.has(N)===!0,isFocusRinged:t.isFocused&&o===N},targetPath:N}),key:n,onContextMenu:S||u?e=>{if(d()){e.preventDefault();return}S&&(e.preventDefault(),E&&(i.focusMountedPathFromInput(N),j(t,N,{anchorRect:RO(e.clientX,e.clientY),source:`right-click`})))}:void 0,onFocus:F?void 0:()=>{i.focusMountedPathFromInput(N)},onKeyDown:F?void 0:ee,ref:e=>{O(N,e)}};return!F&&ce?Q(`div`,{...de,children:ue}):Q(`button`,{...de,type:`button`,draggable:u&&!P,onDragEnd:u&&!P?p:void 0,onDragStart:u&&!P?e=>{f(e,t,N)}:void 0,onMouseDown:e=>{if(F){e.preventDefault();return}i.isSearchOpen()&&e.preventDefault()},onTouchStart:u&&!P?e=>{m(e,t,N)}:void 0,onClick:e=>{M(e,t,N,te)},children:ue})}function $O(e,t,n){return t.end<t.start?[]:e.controller.getVisibleRows(t.start,t.end).filter(e=>!n.has(mO(e))).map((n,r)=>QO(e,n,t.start+r))}function ek({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:a,instanceId:o,itemHeight:s=ix,overscan:c=10,renamingEnabled:l=!1,renderRowDecoration:u,searchBlurBehavior:d=`close`,searchEnabled:f=!1,searchFakeFocus:p=!1,slotHost:m,stickyFolders:h=!1,initialViewportHeight:g=420}){"use no memo";let _=$(null),v=$(null),y=$(!1),b=$(null),x=$(null),S=$(null),C=$(null),w=$(null),T=$(new Map),E=$(new Map),D=$(()=>{}),O=$(null),k=$(0),A=$(!1),j=$(null);j.current!==t&&(A.current=!1,j.current=t);let M=$(!1),ee=$(null),N=$(null),P=$(!1),te=$(null),ne=$(null),F=$(null),re=$(null),ie=$(null),I=$(null),L=$(null),ae=$(null),oe=$(!1),se=$(null),ce=$(null),le=$(null),R=$(null),ue=iO(()=>new Map,[]),[,de]=eO(0),fe=$(!1),[pe,z]=eO(null),[B,V]=eO(null),[me,he]=eO(null),[ge,_e]=eO(null),[ve,ye]=eO(0),[H,be]=eO(null),xe=$(H);xe.current=H;let Se=$(null),Ce=$(null),we=$(null),Te=$(null),Ee=$(null),De=$(!1),Oe=()=>{Ce.current=null,we.current=null,Te.current=null},ke=(e,t)=>{Ce.current=e,we.current=null,Te.current=t==null?null:{path:e,scrollTop:t}},Ae=(e,t)=>{Ce.current=null,we.current={path:e,viewportOffset:t},Te.current=null},je=$(d===`retain`&&t.isSearchOpen()),[Me,Ne]=eO(p);nO(()=>{p||Ne(!1)},[p]);let Pe=$(!1),Fe=aO(()=>{Pe.current=!0,Ne(e=>e&&!1)},[]),[Ie,Le]=eO(()=>_O({controller:t,itemHeight:s,overscan:c,scrollTop:0,stickyFolders:h,viewportHeight:g})),[Re,ze]=eO(!1);nO(()=>{ze(!0)},[]);let Be=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,Ve=e?.contextMenu?.triggerMode??(Be?`right-click`:`both`),U=Ve===`both`||Ve===`button`,W=e?.contextMenu?.buttonVisibility??`when-needed`,He=Ve===`both`||Ve===`right-click`;rO(()=>{let e=S.current;if(e==null)return;let t=e=>{if(!(e instanceof CustomEvent))return;let t=e.detail?.path??null;Ee.current=t,V(t),_e(t==null?null:`pointer`)},n=e=>{e instanceof CustomEvent&&(De.current=e.detail?.disabled===!0)};return e.addEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.addEventListener(`file-tree-debug-set-scroll-suppression`,n),()=>{e.removeEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.removeEventListener(`file-tree-debug-set-scroll-suppression`,n)}},[]);let Ue=aO((e,t)=>{BO(T.current,e,t)},[]),We=aO((e,t)=>{BO(E.current,e,t)},[]),Ge=aO(e=>{x.current=e},[]),Ke=aO(e=>VO(e,E.current,T.current),[]),qe=n!=null||r!=null||i!=null,{resolveIcon:Je}=iO(()=>$T(a),[a]),Ye=t[kT](),Xe=Ye.getPath(),Ze=Xe!=null,Qe=t.isSearchOpen(),$e=t.getSearchValue(),et=t.getFocusedPath(),tt=t.getFocusedIndex(),nt=t.getScrollRequest(),rt=t.isDragAndDropEnabled(),it=t.getDragSession(),at=iO(()=>it==null?null:new Set(it.draggedPaths),[it]),ot=it?.target??null,st=it?.primaryPath??null,ct=KO(o),{overlayHeight:lt,overlayRows:ut,snapshot:dt,visibleRows:ft}=Ie,pt=dt.physical.viewportHeight,G=iO(()=>({end:dt.window.endIndex,start:dt.window.startIndex}),[dt.window.endIndex,dt.window.startIndex]),mt=ut,ht=dt.sticky.rows,gt=dt.physical.totalHeight,_t=dt.sticky.height,vt=iO(()=>new Set(ht.map(e=>mO(e.row))),[ht]),yt=tt>=0&&tt>=G.start&&tt<=G.end,bt=aO((e,t)=>u?.({item:GO(e,t),row:e})??null,[u]),xt=aO(e=>ED(e==null?null:T.current.get(e)??null)?!0:ED(S.current),[]),St=aO(e=>{xt(t.focusNearestPath(e))},[t,xt]),Ct=$(St);Ct.current=St;let wt=$(!0),Tt=$(()=>{}),Et=aO((t=!0)=>{let n=xe.current;n!=null&&(wt.current=wt.current&&t,be(null),e?.contextMenu?.onClose?.(),wt.current&&St(n.path))},[e?.contextMenu,St]);Tt.current=Et;let Dt=aO(e=>{let t=e==null?null:zO(S.current,e);he(e=>e===t?e:t)},[]),Ot=aO((e,n,r)=>{let i=t.getItem(n);if(i==null)return;let a=Ke(n);if(a?.dataset.fileTreeStickyRow===`true`){let e=C.current;ke(n,e?.scrollTop??null),M.current=!0,z(e=>e===n?e:n)}i.focus(),Dt(a),wt.current=!0,be({anchorRect:r?.anchorRect??null,item:GO(e,n),path:n,source:r?.source??`keyboard`})},[t,Ke,Dt]),kt=aO(e=>{if(l){if(t.isSearchOpen()){let e=C.current,t=OD(e,pt);te.current=tt<0||e==null?null:Math.max(0,Math.min(tt*s-e.scrollTop,Math.max(0,t-s))),P.current=!0}t.startRenaming(e)!==!1&&(_e(`focus`),de(e=>e+1))}},[t,tt,s,l,pt]),At=aO((e,{restoreTreeFocus:n=!0,targetOffset:r=`live-overlay`}={})=>{let i=C.current;if(i==null)return!1;t.focusPath(e);let a=t.getFocusedIndex();if(a<0)return!1;let o=t.getVisibleRows(a,a)[0]??null;if(o==null)return!1;let l=OD(i,pt),u=t.getVisibleCount()*s,d=r===`sticky-parents`?o.ancestorPaths.length*s:_O({controller:t,itemHeight:s,overscan:c,scrollTop:i.scrollTop,stickyFolders:h,viewportHeight:l}).snapshot.sticky.height;return M.current=!0,ND(i,a,s,l,u,d),D.current(),Se.current=n?e:null,!0},[t,s,c,pt,h]),jt=()=>y.current===!0||R.current!=null||oe.current===!0,Mt=e=>typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame(()=>{e()}):window.setTimeout(e,16),Nt=e=>{if(e!=null){if(typeof window.cancelAnimationFrame==`function`){window.cancelAnimationFrame(e);return}window.clearTimeout(e)}},Pt=()=>{re.current!=null&&(clearTimeout(re.current),re.current=null),F.current=null},Ft=()=>{I.current?.remove(),I.current=null},It=()=>{Nt(ne.current),ne.current=null,ie.current=null},Lt=e=>{let t=S.current?.getRootNode();if(t instanceof ShadowRoot){t.append(e);return}document.body.append(e)},Rt=()=>{ae.current?.(),ae.current=null,R.current!=null&&(clearTimeout(R.current),R.current=null),oe.current=!1,se.current=null,le.current=null,ce.current!=null&&(ce.current.setAttribute(`draggable`,`true`),ce.current.style.removeProperty(`touch-action`),ce.current=null),Ft(),Pt(),It(),L.current=null},zt=(e,n)=>{let r=S.current?.getRootNode(),i=CO(xO(r instanceof ShadowRoot?r:document,e,n));return t.setDragTarget(i),t.getDragSession()?.target??null},Bt=e=>{let n=t.getDragAndDropConfig()?.openOnDropDelay??800;if(e==null||e.kind!==`directory`||e.directoryPath==null||n<=0){Pt();return}let r=t.getItem(e.directoryPath),i=kO(r)?r:null;if(i==null||i.isExpanded()){Pt();return}let a=`${e.directoryPath}::${e.flattenedSegmentPath??``}`;F.current!==a&&(Pt(),F.current=a,re.current=setTimeout(()=>{let n=t.getDragSession()?.target;n?.kind===`directory`&&n.directoryPath===e.directoryPath&&n.flattenedSegmentPath===e.flattenedSegmentPath&&i.expand()},n))},Vt=()=>{ne.current=null;let e=ie.current,n=C.current;if(e==null||n==null||t.getDragSession()==null)return;let r=n.getBoundingClientRect(),i=EO(e.clientY,r);if(i===0)return;let a=Math.max(0,n.scrollHeight-n.clientHeight),o=Math.max(0,Math.min(a,n.scrollTop+i));o!==n.scrollTop&&(n.scrollTop=o,D.current()),Bt(zt(e.clientX,e.clientY)),ne.current=Mt(Vt)},Ht=(e,t)=>{ie.current={clientX:e,clientY:t},ne.current??=Mt(Vt)},Ut=(e,n,r)=>{let i=e.currentTarget;if(i!=null){if(Rt(),Ft(),Pt(),It(),t.startDrag(r)===!1){e.preventDefault();return}if(L.current=n,e.dataTransfer!=null&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`,e.dataTransfer.setData(`text/plain`,r),TO())){let t=wO(i),n=i.getBoundingClientRect();Object.assign(t.style,{height:`${n.height}px`,opacity:`0.85`,transform:`translate3d(-9999px, 0px, 0)`,width:`${n.width}px`}),Lt(t),I.current=t,e.dataTransfer.setDragImage(t,Math.max(0,e.clientX-n.left),Math.max(0,e.clientY-n.top))}}},Wt=()=>{Ft(),Pt(),It(),L.current=null,t.cancelDrag()},Gt=(e,n,r)=>{if(R.current!=null||oe.current)return;let i=e.touches[0],a=e.currentTarget;if(i==null||a==null)return;le.current={clientX:i.clientX,clientY:i.clientY},ce.current=a,a.setAttribute(`draggable`,`false`);let o=(e={})=>{let t=e.restoreNativeDraggable??!oe.current;R.current!=null&&(clearTimeout(R.current),R.current=null),document.removeEventListener(`touchmove`,s),document.removeEventListener(`touchend`,c),document.removeEventListener(`touchcancel`,c),ae.current===o&&(ae.current=null),t&&(a.setAttribute(`draggable`,`true`),ce.current===a&&(ce.current=null),le.current=null)},s=e=>{let t=e.touches[0],n=le.current;if(t==null||n==null)return;let r=t.clientX-n.clientX,i=t.clientY-n.clientY;r*r+i*i<=100||o()},c=()=>{o()};document.addEventListener(`touchmove`,s,{passive:!0}),document.addEventListener(`touchend`,c),document.addEventListener(`touchcancel`,c),ae.current=o,R.current=setTimeout(()=>{if(o({restoreNativeDraggable:!1}),t.startDrag(r)===!1){a.setAttribute(`draggable`,`true`),ce.current===a&&(ce.current=null),le.current=null;return}oe.current=!0,ce.current=a,a.setAttribute(`draggable`,`false`),a.style.setProperty(`touch-action`,`none`),L.current=n;let e=a.getBoundingClientRect(),s=wO(a);Object.assign(s.style,{height:`${e.height}px`,opacity:`0.85`,transform:`translate3d(${e.left}px, ${e.top}px, 0)`,width:`${e.width}px`}),Lt(s),I.current=s,se.current={x:i.clientX-e.left,y:i.clientY-e.top};let c=e=>{let t=e.touches[0];if(t==null)return;e.preventDefault();let n=se.current;n!=null&&I.current!=null&&(I.current.style.transform=`translate3d(${t.clientX-n.x}px, ${t.clientY-n.y}px, 0)`),Bt(zt(t.clientX,t.clientY)),Ht(t.clientX,t.clientY)},l=e=>{let n=e.changedTouches[0];n!=null&&zt(n.clientX,n.clientY),t.completeDrag(),Rt()},u=()=>{t.cancelDrag(),Rt()};ae.current=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),document.removeEventListener(`touchcancel`,u)},document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),document.addEventListener(`touchcancel`,u)},vO)},Kt=e=>{if(H!=null){if(e.key===`Escape`){Et(),e.preventDefault(),e.stopPropagation();return}FO.has(e.key)&&(e.preventDefault(),e.stopPropagation());return}if(Ye.isActive()){if(e.isComposing||e.keyCode===229)return;if(e.key===`Escape`)Ye.cancel();else if(e.key===`Enter`)Ye.commit();else return;_e(`focus`),de(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(l&&e.key===`F2`){kt(et??void 0),e.preventDefault(),e.stopPropagation();return}if(Qe){if(e.key===`Escape`)P.current=!1,te.current=null,t.closeSearch();else if(e.key===`Enter`){let e=t.getFocusedPath();e!=null&&t.selectOnlyPath(e);let n=C.current,r=OD(n,pt);te.current=tt<0||n==null?null:Math.max(0,Math.min(tt*s-n.scrollTop,Math.max(0,r-s))),P.current=!0,t.closeSearch()}else if(e.key===`ArrowDown`)t.focusNextSearchMatch();else if(e.key===`ArrowUp`)t.focusPreviousSearchMatch();else return;_e(`focus`),de(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(f&&jO(e)){t.openSearch(e.key),de(e=>e+1),e.preventDefault(),e.stopPropagation();return}let n=Be&&NO(e),r=PO(e,Be),i=r&&S.current!=null?DD(S.current):null,a=r?new Set(HO(S.current)):new Set,o=i?.dataset.fileTreeStickyPath??null,c=i?.dataset.fileTreeStickyRow===`true`&&o!=null;if(c&&o!==et&&a.has(o)){let e=C.current;ke(o,e?.scrollTop??null),t.focusPath(o)}let u=t.getFocusedPath(),d=t.getFocusedIndex(),p=t.getFocusedItem();if(p==null)return;let m=kO(p)?p:null,h=u!=null&&(vt.has(u)||c&&o===u&&a.has(u)),g=e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowRight`&&m!=null&&m.isExpanded(),_=e.key===`ArrowLeft`&&h&&m!=null&&m.isExpanded(),v=C.current,y=!0;if(e.shiftKey&&e.key===`ArrowDown`)t.extendSelectionFromFocused(1);else if(e.shiftKey&&e.key===`ArrowUp`)t.extendSelectionFromFocused(-1);else if(n&&u!=null&&d>=0){let e=t.getVisibleRows(d,d)[0]??null,n=VO(u,E.current,T.current);e==null||n==null?y=!1:Ot(e,u)}else if((e.ctrlKey||e.metaKey)&&AO(e))t.toggleFocusedSelection();else if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`)t.selectAllVisiblePaths();else switch(e.key){case`ArrowDown`:t.focusNextItem();break;case`ArrowUp`:t.focusPreviousItem();break;case`ArrowRight`:m==null||m.isExpanded()?t.focusNextItem():m.expand();break;case`ArrowLeft`:m!=null&&m.isExpanded()?m.collapse():t.focusParentItem();break;case`Home`:t.focusFirstItem();break;case`End`:t.focusLastItem();break;default:y=!1}if(!y)return;_e(`focus`);let b=t.getFocusedPath(),x=b!=null&&(vt.has(b)||a.has(b)),w=g&&b!==u,D=n&&c&&o===u&&b===u;if((h||D)&&b!=null&&(w&&x||D))ke(b,v?.scrollTop??null),M.current=!0,z(e=>e===b?e:b);else{let t=e.key===`ArrowUp`&&h&&b!==u;b!=null&&(t||_&&b===u)?(Ae(b,WO(S.current,v,i,u,s,_t,pt)),M.current=!0,z(e=>e===b?e:b)):Oe()}de(e=>e+1),e.preventDefault(),e.stopPropagation()};rO(()=>{if(!(!f||!Qe)){if(je.current){je.current=!1;return}ED(w.current)}},[Qe,f]),rO(()=>{let e=x.current;switch(FD({hasRenderedInput:e!=null,previousRenamingPath:N.current,renamingPath:Xe})){case`reset`:N.current=null;return;case`reveal-canonical`:Xe!=null&&At(Xe,{restoreTreeFocus:!1,targetOffset:`live-overlay`});return;case`ignore`:return;case`focus-input`:e!=null&&(Se.current=null,N.current=Xe,ED(e),e.select());return}},[G.end,G.start,Xe,At,vt]),rO(()=>{let e=S.current;if(e==null)return;let t=null,n=()=>{t!=null&&(clearTimeout(t),t=null)},r=()=>{let t=DD(e)?.dataset.itemPath??null;z(e=>e===t?e:t)},i=()=>{n(),M.current=!0,r()},a=i=>{let a=i.relatedTarget;if(a==null){n(),t=setTimeout(()=>{if(t=null,DD(e)!=null){r();return}M.current=!1,z(null)},0);return}if(!(a instanceof Node)||!e.contains(a)){n(),M.current=!1,z(null);return}let o=a instanceof HTMLElement?a.dataset.itemPath??null:null;z(e=>e===o?e:o)};return e.addEventListener(`focusin`,i),e.addEventListener(`focusout`,a),()=>{n(),e.removeEventListener(`focusin`,i),e.removeEventListener(`focusout`,a)}},[]),rO(()=>{let e=S.current;e!=null&&(dt.physical.scrollTop<=0?e.dataset.scrollAtTop=`true`:delete e.dataset.scrollAtTop)},[dt.physical.scrollTop]),rO(()=>{let e=null,n=C.current,r=b.current,i=S.current;if(n==null)return;O.current=OD(n,g);let a=()=>{let e=t.getVisibleCount(),r=kD(O.current,g),i=Math.max(0,e*s-r);n.scrollTop>i&&(n.scrollTop=i),Le(_O({controller:t,itemHeight:s,overscan:c,scrollTop:Math.min(n.scrollTop,i),stickyFolders:h,viewportHeight:r}))};if(!A.current){A.current=!0;let e=t.getFocusedIndex();if(e>=0){let r=kD(O.current,g),i=t.getVisibleRows(e,e)[0]??null;jD(n,e,s,r,h&&i!=null?Math.max(0,Math.min(i.ancestorPaths.length*s,Math.max(0,r-s))):0)}}D.current=a;let o=t.subscribe(()=>{SD(fe)&&de(e=>e+1),a()}),l=()=>{De.current!==!0&&(r!=null&&(r.dataset.isScrolling??=``),i!=null&&(i.dataset.isScrolling??=``),y.current=!0,e!=null&&clearTimeout(e),e=setTimeout(()=>{r!=null&&delete r.dataset.isScrolling,i!=null&&delete i.dataset.isScrolling,y.current=!1,ye(e=>e+1),e=null},50))},u=null,d=()=>{i!=null&&delete i.dataset.overlayReveal,u!=null&&(clearTimeout(u),u=null)},f=()=>{i!=null&&De.current!==!0&&(n.scrollTop>0||(i.dataset.overlayReveal=`true`,u!=null&&clearTimeout(u),u=setTimeout(()=>{d()},200)))},p=()=>{if(a(),n.scrollTop>0&&d(),xe.current!=null&&y.current&&Tt.current(),De.current===!0){y.current=!1;return}V(e=>e==null?e:null),l()},m=()=>{l(),f()},_=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),v=e=>{_.has(e.key)&&m()};n.addEventListener(`scroll`,p,{passive:!0}),n.addEventListener(`wheel`,m,{passive:!0}),n.addEventListener(`touchmove`,m,{passive:!0}),n.addEventListener(`keydown`,v);let x=typeof ResizeObserver<`u`?new ResizeObserver(e=>{O.current=(e[0]==null?null:AD(e[0]))??OD(n,g),a()}):null;return x?.observe(n),()=>{D.current=()=>{},o(),n.removeEventListener(`scroll`,p),n.removeEventListener(`wheel`,m),n.removeEventListener(`touchmove`,m),n.removeEventListener(`keydown`,v),e!=null&&clearTimeout(e),u!=null&&clearTimeout(u),r!=null&&delete r.dataset.isScrolling,i!=null&&(delete i.dataset.isScrolling,delete i.dataset.overlayReveal),y.current=!1,O.current=null,x?.disconnect()}},[t,g,s,c,h]),rO(()=>{Be||H==null||Et(!1)},[Et,Be,H]);let qt=iO(()=>H==null?null:`${H.path}::${H.source}`,[H]);rO(()=>{if(qt==null){m?.clearSlotContent(Ny);return}let t=xe.current;if(t==null)return;let n=v.current??_.current;if(n==null)return;let r={anchorElement:n,anchorRect:t.anchorRect??LO(n.getBoundingClientRect()),close:e=>{Tt.current(e?.restoreFocus??!0)},restoreFocus:()=>{wt.current&&Ct.current(xe.current?.path??null)}},i=e?.contextMenu?.render?.(t.item,r)??null;return m?.setSlotContent(Ny,i),e?.contextMenu?.onOpen?.(t.item,r),XO(i),queueMicrotask(()=>{i==null||!i.isConnected||document.activeElement===i&&XO(i)}),()=>{m?.clearSlotContent(Ny)}},[qt,e?.contextMenu,m]),rO(()=>{H!=null&&t.getItem(H.path)==null&&Et()},[Et,H,t]),rO(()=>{if(H==null)return;let e=S.current?.getRootNode(),t=e instanceof ShadowRoot?e.host:S.current,n=e=>{let n=e.target;n instanceof Node&&(IO(e)||_.current?.contains(n)!==!0&&t?.contains(n)!==!0&&Et())},r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Et())};return document.addEventListener(`mousedown`,n,!0),document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`mousedown`,n,!0),document.removeEventListener(`keydown`,r,!0)}},[Et,H]),rO(()=>{let e=C.current,n=S.current;if(e==null||n==null){ee.current=et;return}let r=et==null?null:T.current.get(et)??null,i=DD(n),a=i?.dataset.itemPath??null,o=Ze&&x.current===i,c=f&&w.current===i,l=P.current&&!Qe,u=te.current??0,d=Se.current,p=Ce.current,m=we.current,g=Te.current,_=i!=null,v=M.current||_,y=ee.current!==et,b=p!=null&&p===et&&et!=null,E=!1,O=!1;if(nt!=null&&nt.id!==k.current){k.current=nt.id;let n=nt.visibleIndex,r=t.getVisibleRows(n,n)[0]??null;if(r!=null){let t=h?Math.max(0,Math.min(r.ancestorPaths.length*s,Math.max(0,pt-s))):_t;E=!0,O=MD(e,n,s,pt,gt,nt.offset,t)}t.clearScrollRequest(nt.id)}let A=!E&&l&&ND(e,tt,s,pt,gt,u),j=!E&&d!=null&&d===et&&ND(e,tt,s,pt,gt,_t),N=!E&&m!=null&&m.path===et&&ND(e,tt,s,pt,gt,m.viewportOffset),ne=!E&&g!=null&&g.path===et&&e.scrollTop!==g.scrollTop;if(ne&&(e.scrollTop=g.scrollTop),(ne||O||j||N||A||v&&y&&d!==et&&!b&&jD(e,tt,s,pt,_t))&&D.current(),E){ee.current=et;return}if(!v){ee.current=et;return}if(o){ee.current=et;return}if(c&&!l){ee.current=et;return}if(r==null){l&&tt>=0&&(ND(e,tt,s,pt,gt,u),D.current()),ee.current=et;return}(y||l||d===et||p===et||m?.path===et||g?.path===et||a==null||a!==et)&&(ED(r),d===et&&(Se.current=null),p===et&&(Ce.current=null),m?.path===et&&(we.current=null),g?.path===et&&(Te.current=null),P.current=!1,te.current=null),ee.current=et},[t,tt,et,yt,s,Ze,Qe,G,pt,f,nt,h,_t,gt,ft]);let Jt=tt>=0&&tt>=dt.visible.startIndex&&tt<=dt.visible.endIndex,Yt=et!=null&&mt.some(e=>mO(e.row)===et),Xt=Jt||Yt,Zt=U&&M.current===!0&&Xt?et:null,Qt=ge===`pointer`?B:null,$t=H?.path??Ee.current??Qt??Zt??B,en=H?.source===`right-click`;rO(()=>{y.current&&H==null||Dt(Ke($t))},[H,Ke,G,pt,ve,mt,$t,Dt,ft]);let tn=aO(e=>{if(y.current||IO(e))return;let t=e.target;if(!(t instanceof HTMLElement)||t.closest?.(`[data-type="context-menu-trigger"]`)!=null)return;let n=t.closest?.(`[data-file-tree-sticky-row="true"]`),r=t.closest?.(`[data-type="item"]`),i=n instanceof HTMLElement?n.dataset.fileTreeStickyPath??null:r instanceof HTMLElement?r.dataset.itemPath??null:null;i!=null&&_e(e=>e===`pointer`?e:`pointer`),V(e=>e===i?e:i)},[]),nn=aO(()=>{V(null)},[]);rO(()=>{if(!rt)return;let e=()=>{Rt(),t.cancelDrag()};return window.addEventListener(`dragend`,e),()=>{window.removeEventListener(`dragend`,e),Rt(),t.cancelDrag()}},[t,rt]);let rn=e=>{if(!rt||t.getDragSession()==null||oe.current)return;let n=CO(e.target instanceof HTMLElement?e.target:null);t.setDragTarget(n),Bt(t.getDragSession()?.target??null),Ht(e.clientX,e.clientY),e.dataTransfer!=null&&(e.dataTransfer.dropEffect=`move`),e.preventDefault()},an=e=>{if(!rt||t.getDragSession()==null||oe.current)return;let n=e.relatedTarget;n instanceof Node&&S.current?.contains(n)===!0||(Pt(),It(),t.setDragTarget(null))},on=e=>{!rt||t.getDragSession()==null||oe.current||(e.preventDefault(),zt(e.clientX,e.clientY),t.completeDrag(),Ft(),Pt(),It(),L.current=null)},sn=dt.window.height,cn=dt.window.offsetTop,ln=Math.min(0,pt-sn),un=Math.min(0,pt-sn-_t),dn=pe===et||P.current,K=et!=null&&dn&&!yt&&tt>=0?ft[tt]??t.getVisibleRows(tt,tt)[0]??null:null,fn=K==null?null:PD(tt,s,G,sn),pn=L.current,mn=st!=null&&pn!=null&&pn.path===st&&pn.index>=G.start&&pn.index<=G.end,hn=st!=null&&pn!=null&&pn.path===st&&!mn&&pn.path!==K?.path?pn:null,gn=hn==null?null:PD(hn.index,s,G,sn),_n=MO((tt>=0?ft[tt]??t.getVisibleRows(tt,tt)[0]??null:null)?.ancestorPaths.at(-1)??null),vn=Qe&&et!=null?qO(o,et,!yt):void 0,yn=H?.path??(Qe?et:pe),bn=H?.path??B,xn=Ke($t),Sn=Be&&U&&!en&&!Ze&&xn!=null&&me!=null&&$t!=null,Cn=Be&&(Sn||H!=null),wn=H?.anchorRect,Tn=wn==null&&xn!=null&&me!=null&&(H!=null||Sn)?me:null,En=wn==null?Tn==null?void 0:{top:`${Tn}px`}:{left:`${wn.left}px`,position:`fixed`,right:`auto`,top:`${wn.top}px`},Dn=en?{opacity:`0`}:void 0,On=aO((e,n,r,i)=>{let a=RD({event:{ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey},isDirectory:n.kind===`directory`,isSearchOpen:Qe,mode:i}),o=a.toggleDirectory&&n.kind===`directory`,s=o?t.resolveMountedDirectoryPathFromInput(r):null;if(o&&s==null)return;let c=s??r;switch(a.selection.kind){case`range`:t.selectPathRange(c,a.selection.additive);break;case`toggle`:t.togglePathSelectionFromInput(c);break;case`single`:t.selectOnlyMountedPathFromInput(c)}let l=e.currentTarget instanceof HTMLElement?e.currentTarget:null,u=n.index>=dt.visible.startIndex&&n.index<=dt.visible.endIndex,d=i===`flow`&&u&&l!=null&&l.dataset.itemParked!==`true`;t.focusMountedPathFromInput(c),d&&(M.current=!0,z(e=>e===c?e:c),_e(`focus`)),o&&t.toggleMountedDirectoryFromInput(c),a.closeSearch&&t.closeSearch(),a.revealCanonical&&At(c,{targetOffset:`sticky-parents`})},[t,Qe,dt.visible.endIndex,dt.visible.startIndex,At]),kn=()=>{if(y.current||!U||$t==null||xn==null)return;let e=t.getItem($t);e!=null&&(Dt(xn),wt.current=!0,be({anchorRect:null,item:{kind:e.isDirectory()?`directory`:`file`,name:xn.getAttribute(`aria-label`)??$t,path:e.getPath()},path:e.getPath(),source:`button`}))},An={contextHoverPath:bn,contextMenuButtonTriggerEnabled:U,contextMenuButtonVisibility:W,contextMenuEnabled:Be,contextMenuRightClickEnabled:He,contextMenuTriggerMode:Ve,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:rt,draggedPathSet:at,dragTarget:ot,gitLaneActive:qe,gitStatusByPath:n,handleRowDragEnd:Wt,handleRowDragStart:Ut,handleRowTouchStart:Gt,ignoredGitDirectories:r,ignoredInheritanceCache:ue,instanceId:o,itemHeight:s,onKeyDown:Kt,onRowClick:On,openContextMenuForRow:Ot,registerButton:Ue,registerRenameInput:Ge,renameView:Ye,renderDecorationForRow:bt,resolveIcon:Je,shouldSuppressContextMenu:jt,visualFocusPath:yn},jn={...An,registerButton:We};return Q(`div`,{ref:S,id:ct,"data-file-tree-context-menu-button-visibility":Be&&U?W:void 0,"data-file-tree-context-menu-trigger-mode":Be?Ve:void 0,"data-file-tree-has-context-menu-action-lane":Be&&U?`true`:void 0,"data-file-tree-has-git-lane":qe?`true`:void 0,"data-file-tree-virtualized-root":`true`,onDragLeave:rt?an:void 0,onDragOver:rt?rn:void 0,onDrop:rt?on:void 0,onKeyDown:Kt,onPointerLeave:Be?nn:void 0,onPointerOver:Be?tn:void 0,role:`tree`,tabIndex:-1,style:{outline:`none`,position:`relative`},children:[Q(`style`,{"data-file-tree-guide-style":`true`,dangerouslySetInnerHTML:{__html:_n}}),Q(`slot`,{name:My,"data-type":`header-slot`}),f?Q(`div`,{"data-file-tree-search-container":!0,"data-open":Qe?`true`:`false`,children:Q(`input`,{ref:w,"aria-activedescendant":vn,"aria-controls":ct,placeholder:`Search…`,"data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Me?`true`:void 0,value:$e,onBlur:()=>{d===`retain`&&!Pe.current||t.closeSearch()},onFocus:Fe,onPointerDown:Fe,onInput:e=>{Fe();let n=e.currentTarget;t.setSearch(n.value)}})}):null,Q(`div`,{ref:C,"data-file-tree-virtualized-scroll":`true`,children:[h&&Re&&mt.length>0?Q(`div`,{"aria-hidden":`true`,"data-file-tree-sticky-overlay":`true`,children:Q(`div`,{"data-file-tree-sticky-overlay-content":`true`,style:{height:`${lt}px`},children:mt.map((e,t)=>QO(jn,e.row,`sticky:${mO(e.row)}`,{mode:`sticky`,style:{left:`0`,position:`absolute`,right:`0`,top:`${e.top}px`,zIndex:`${mt.length-t}`}}))})}):null,Q(`div`,{ref:b,"data-file-tree-virtualized-list":`true`,style:{height:`${gt}px`},children:[Q(`div`,{"data-file-tree-virtualized-sticky-offset":`true`,"aria-hidden":`true`,style:{height:`${cn}px`}}),Q(`div`,{"data-file-tree-virtualized-sticky":`true`,style:{height:`${sn}px`,top:`${ln}px`,bottom:`${un}px`},children:[$O(An,G,vt),K!=null&&fn!=null?QO(An,K,`parked:${K.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:st===K.path?`none`:void 0,position:`absolute`,right:`0`,top:`${fn}px`}}):null,hn!=null&&gn!=null?QO(An,hn,`parked-drag:${hn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:`none`,position:`absolute`,right:`0`,top:`${gn}px`}}):null]})]})]}),Be?Q(`div`,{ref:_,"data-type":`context-menu-anchor`,"data-visible":Cn?`true`:`false`,style:En,children:[Q(`button`,{ref:v,type:`button`,"data-type":Py,"aria-label":`Options`,"aria-haspopup":`menu`,"aria-expanded":H==null?`false`:`true`,"data-visible":Sn?`true`:`false`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),H!=null){Et();return}kn()},tabIndex:-1,style:Dn,children:Q(GE,{...Je(`file-tree-icon-ellipsis`)})}),H==null?null:Q(`slot`,{name:Ny})]}):null,H==null?null:Q(`div`,{"data-type":`context-menu-wash`,"aria-hidden":`true`,onMouseDownCapture:e=>{e.preventDefault(),Et()},onTouchStartCapture:e=>{e.preventDefault(),e.stopPropagation(),Et()},onTouchMoveCapture:e=>{e.preventDefault(),e.stopPropagation()},onWheelCapture:e=>{e.preventDefault(),e.stopPropagation()}})]})}var tk={hydrateRoot:(e,t)=>{BE(gE(ek,t),e)},renderRoot:(e,t)=>{zE(gE(ek,t),e)},unmountRoot:e=>{zE(null,e)}};function nk(e,t){tk.renderRoot(e,t)}function rk(e,t){tk.hydrateRoot(e,t)}function ik(e){tk.unmountRoot(e)}var ak=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#n(e);t!=null&&(t.remove(),this.#e.delete(e))}setHost(e){if(this.#t=e,e!=null){this.#i(e);for(let[e,t]of this.#e)this.#r(e,t)}}setSlotContent(e,t){let n=this.#n(e);if(n===t){t!=null&&(this.#e.set(e,t),this.#r(e,t));return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#r(e,t)}setSlotHtml(e,t){let n=t?.trim()??``;if(n.length===0){this.setSlotContent(e,null);return}let r=this.#n(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#r(e,r);return}let i=document.createElement(`div`);i.innerHTML=n,this.setSlotContent(e,i)}#n(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let t of Array.from(n.children))if(t instanceof HTMLElement&&t.dataset.fileTreeManagedSlot===e)return t;return null}#r(e,t){t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t&&this.#t.appendChild(t)}#i(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let e=t.dataset.fileTreeManagedSlot;e==null||this.#e.has(e)||this.#e.set(e,t)}}};Array.isArray;var ok=0;function sk(e){return e!=null&&e.length>0?e:(ok+=1,`pst_ft_${ok}`)}function ck({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??ix)}function lk(e){if(typeof document>`u`)return;let t=document.createElement(`div`);t.innerHTML=e;let n=t.querySelector(`svg`);return n instanceof SVGElement?n:void 0}function uk(e){return e.querySelector(`#file-tree-icon-chevron`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-file`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-dot`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-lock`)instanceof SVGElement}function dk(e){return Array.from(e.children).filter(e=>e instanceof SVGElement)}var fk=class{static LoadedCustomComponent=!0;#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=new ak;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y=null;#b;#x=!1;#S=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:a,initialSearchQuery:o,icons:s,itemHeight:c,onSearchChange:l,onSelectionChange:u,overscan:d,renderRowDecoration:f,renaming:p,search:m,searchBlurBehavior:h,searchFakeFocus:g,stickyFolders:_,unsafeCSS:v,initialVisibleRowCount:y,...b}=e;this.#e=t,this.#n=sk(a),this.#p=BT(i),this.#m=s,this.#h=v,this.#r=u,this.#i=f,this.#a=p!=null&&p!==!1,this.#o=h,this.#s=m===!0,this.#c=g===!0,this.#u=rx(n,c),this.#d={itemHeight:this.#u.itemHeight,overscan:d,stickyFolders:_,initialVisibleRowCount:y},this.#t=new FT({...b,fileTreeSearchMode:r,initialSearchQuery:o,onSearchChange:l,renaming:p}),this.#v=this.#t.getSelectionVersion(),this.#y=this.#r==null?null:this.subscribe(()=>{this.#D()})}unmount(){this.#b!=null&&(ik(this.#b),delete this.#b.dataset.fileTreeVirtualizedWrapper,this.#b=void 0),this.#l.clearAll(),this.#l.setHost(null),this.#f!=null&&(delete this.#f.dataset.fileTreeVirtualized,this.#I(this.#f),this.#f=void 0)}cleanUp(){this.unmount(),this.#y?.(),this.#y=null,this.#t.destroy()}getFileTreeContainer(){return this.#f}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getFocusedIndex(){return this.#t.getFocusedIndex()}getVisibleCount(){return this.#t.getVisibleCount()}getVisibleRows(e,t){return this.#t.getVisibleRows(e,t)}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#u.itemHeight}getDensityFactor(){return this.#u.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}focusFirstItem(){this.#t.focusFirstItem()}focusLastItem(){this.#t.focusLastItem()}focusNextItem(){this.#t.focusNextItem()}focusPreviousItem(){this.#t.focusPreviousItem()}focusParentItem(){this.#t.focusParentItem()}scrollToPath(e,t){this.#t.scrollToPath(e,t)}focusNearestPath(e){return this.#t.focusNearestPath(e)}add(e){this.#t.add(e)}batch(e){this.#t.batch(e)}applyGitStatusPatch(e){let t=VT(this.#p,e);if(t===this.#p)return;this.#p=t;let n=this.#T();n!=null&&nk(n.wrapper,this.#w())}move(e,t,n){this.#t.move(e,t,n)}onMutation(e,t){return this.#t.onMutation(e,t)}setSearch(e){this.#t.setSearch(e)}openSearch(e){this.#t.openSearch(e)}closeSearch(){this.#t.closeSearch()}isSearchOpen(){return this.#t.isSearchOpen()}getSearchValue(){return this.#t.getSearchValue()}getSearchMatchingPaths(){return this.#t.getSearchMatchingPaths()}focusNextSearchMatch(){this.#t.focusNextSearchMatch()}focusPreviousSearchMatch(){this.#t.focusPreviousSearchMatch()}startRenaming(e,t){return this.#t.startRenaming(e,t)}remove(e,t){this.#t.remove(e,t)}resetPaths(e,t){Array.isArray(e)?this.#t.resetPaths(e,t):this.#t.resetPaths(e)}setComposition(e){this.#e=e;let t=this.#T();t!=null&&(this.#O(),nk(t.wrapper,this.#w()))}setGitStatus(e){let t=BT(e,this.#p);if(t===this.#p)return;this.#p=t;let n=this.#T();n!=null&&nk(n.wrapper,this.#w())}setIcons(e){this.#m=e;let t=this.#T();t!=null&&(this.#E(t.host,t.wrapper),nk(t.wrapper,this.#w()))}hydrate({fileTreeContainer:e}){let t=this.#P(e),n=this.#N(t);this.#O(),rk(n,this.#w())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#P(t??this.#f,e),r=this.#N(n);this.#O(),nk(r,this.#w())}#C(){return{initialViewportHeight:ck({initialVisibleRowCount:this.#d.initialVisibleRowCount,itemHeight:this.#d.itemHeight}),itemHeight:this.#d.itemHeight,overscan:this.#d.overscan,stickyFolders:this.#d.stickyFolders}}#w(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#p?.statusByPath,ignoredGitDirectories:this.#p?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#p?.directoriesWithChanges,icons:this.#m,instanceId:this.#n,renamingEnabled:this.#a,renderRowDecoration:this.#i,searchBlurBehavior:this.#o,searchEnabled:this.#s,searchFakeFocus:this.#c,slotHost:this.#l,...this.#C()}}#T(){let e=this.#f,t=this.#b;return e==null||t==null?null:{host:e,wrapper:t}}#E(e,t){let n=e.shadowRoot;n!=null&&(this.#k(n),this.#A(n)),this.#j(t)}#D(){let e=this.#r;if(e==null)return;let t=this.#t.getSelectionVersion();t!==this.#v&&(this.#v=t,e(this.#t.getSelectedPaths()))}#O(){let e=this.#e?.header?.render;if(e!=null){this.#l.setSlotContent(My,e());return}this.#l.setSlotHtml(My,this.#e?.header?.html??null)}#k(e){let t=dk(e).find(e=>uk(e)),n=lk(Xb(tx(this.#m).set));n!=null&&(t==null||t.outerHTML!==n.outerHTML)&&(t==null?e.prepend(n):t.replaceWith(n))}#A(e){let t=dk(e),n=t.find(e=>uk(e)),r=t.filter(e=>e!==n),i=tx(this.#m).spriteSheet?.trim()??``;if(i.length===0){for(let e of r)e.remove();return}let a=lk(i);if(a==null){for(let e of r)e.remove();return}if(r.length!==1||r[0].outerHTML!==a.outerHTML){for(let e of r)e.remove();e.appendChild(a)}}#j(e){let t=tx(this.#m);t.colored&&Qb(t.set)?e.dataset.fileTreeColoredIcons=`true`:delete e.dataset.fileTreeColoredIcons}#M(e){let t=e.querySelector(`style[${Oy}]`);if(this.#g==null&&t instanceof HTMLStyleElement&&(this.#g=t),this.#h==null||this.#h===``){this.#g?.remove(),this.#g=void 0,this.#_=void 0;return}(this.#g?.parentNode!==e||this.#_!==this.#h)&&(this.#g??=document.createElement(`style`),this.#g.setAttribute(Oy,``),this.#g.parentNode!==e&&e.appendChild(this.#g),this.#g.textContent=cx(this.#h),this.#_=this.#h)}#N(e){if(this.#b!=null)return this.#b;let t=e.shadowRoot;if(t==null)throw Error(`FileTree requires a shadow root`);let n=Array.from(t.children).filter(e=>e instanceof HTMLDivElement&&typeof e.dataset.fileTreeId==`string`&&e.dataset.fileTreeId.length>0),r=n.find(e=>e.dataset.fileTreeId===this.#n)??n[0];return r!=null&&(this.#n=r.dataset.fileTreeId??this.#n),this.#b=r??document.createElement(`div`),this.#b.dataset.fileTreeId=this.#n,this.#b.dataset.fileTreeVirtualizedWrapper=`true`,this.#E(e,this.#b),this.#b.parentNode!==t&&t.appendChild(this.#b),this.#b}#P(e,t){let n=e??this.#f??document.createElement(`file-tree-container`);t!=null&&n.parentNode!==t&&t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:`open`});return mx(n,r),this.#M(r),n.dataset.fileTreeVirtualized=`true`,n.style.display=`flex`,this.#F(n),this.#l.setHost(n),this.#f=n,n}#F(e){e.style.getPropertyValue(`--trees-item-height`)===``&&(e.style.setProperty(`--trees-item-height`,`${String(this.#u.itemHeight)}px`),this.#x=!0),e.style.getPropertyValue(`--trees-density-override`)===``&&(e.style.setProperty(`--trees-density-override`,String(this.#u.factor)),this.#S=!0)}#I(e){this.#x&&=(e.style.removeProperty(`--trees-item-height`),!1),this.#S&&=(e.style.removeProperty(`--trees-density-override`),!1)}};function pk(e){let[t]=(0,q.useState)(()=>new fk(e)),n=(0,q.useRef)({timeout:null,model:t});return(0,q.useEffect)(()=>{let{current:e}=n;return e.timeout!=null&&(clearTimeout(e.timeout),e.timeout=null),()=>{e.timeout=setTimeout(()=>e.model.cleanUp(),1)}},[]),{model:t}}function mk(e){return e.name.startsWith(`.`)}function hk(e,t,n=0){return rr(e,Xa,Mi.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=>!mk(e))}})}function gk(){return{known:new Set,projected:new Map}}function _k(e,t){t.known.clear(),t.projected.clear(),e.resetPaths([])}function vk(e,t,n){t.length===0&&_k(e,n);for(let{request:r,listing:i}of t){let t=`${r?.path??i.path}:${String(r?.offset??0)}`,a=i.entries.filter(e=>e.type!==`symlink`).map(e=>yk(i.path,e.name,e.type)),o=n.projected.get(t)??[];n.projected.set(t,a);let s=new Set([...n.projected.values()].flat());for(let t of o)if(!s.has(t)){e.getItem(t)&&e.remove(t,{recursive:!0});for(let e of n.known)(e===t||t.endsWith(`/`)&&e.startsWith(t))&&n.known.delete(e)}bk(e,i,n.known)}}function yk(e,t,n){return`${e.endsWith(`/`)?e:`${e}/`}${t}${n===`directory`?`/`:``}`}function bk(e,t,n){let r=t.entries.filter(e=>e.type!==`symlink`).map(e=>yk(t.path,e.name,e.type)),i=r.filter(t=>!n.has(t)&&!e.getItem(t));i.length>0&&e.batch(i.map(e=>({type:`add`,path:e}))),n.add(t.path);for(let e of r)n.add(e);return i}function xk(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 Sk({app:e,rootPath:t,activePath:n}){let r=gn(),i=yf(e),a=(0,q.useCallback)(t=>e.capabilities.subscribe(t),[e]),o=(0,q.useCallback)(()=>e.capabilities.version,[e]),s=(0,q.useSyncExternalStore)(a,o,o),c=(0,q.useMemo)(()=>({app:e,rootPath:t,computerId:i,version:s}),[e,t,i,s]),[l,u]=(0,q.useState)(null),d=l?.scope===c?l:null,f=n?xk(n,t):[],p=d?.activePath===n?d.path:f.at(-1)??t,m=new Map;for(let e of[t,...f])m.set(`${e}:0`,{path:e,offset:0});for(let e of d?.pages??[])m.set(`${e.path}:${String(e.offset)}`,e);let h=[...m.values()],g=(t,n)=>Mi.of(e,`tree`,s,t,n);return{scope:c,snapshot:Ss({queries:h.map(({path:t,offset:n})=>hk(e,t,n)),combine:e=>({listings:e.flatMap((e,t)=>e.data?[{request:h[t],listing:e.data}]:[]),busy:e.some(e=>e.isFetching),failure:e.find(e=>e.error)?.error??null})}),focusedPath:p,requestPage:(e,t)=>{let i=e.replace(/\/+$/,``)||`/`,a=g(i,t);r.getQueryState(a)?.status===`error`&&r.invalidateQueries({queryKey:a,exact:!0}),u(e=>({scope:c,activePath:n,path:i,pages:[...e?.scope===c?e.pages.filter(e=>e.path!==i||e.offset!==t):[],{path:i,offset:t}]}))},reload:()=>{r.invalidateQueries({queryKey:Mi.of(e,`tree`,s)})}}}var Ck=32,wk=()=>`Library`,Tk=(e,t)=>`${wk()}${t.slice(e.length)}`,Ek=(e,t)=>`${e}${t.replace(/\/$/,``).slice(wk().length)}`,Dk=e=>e===void 0?`${wk()}/`:`${wk()}/${e}/`;function Ok(e){if(!e.endsWith(`/`))return null;let t=e.slice(0,-1);return t===wk()?{folder:void 0}:t.startsWith(`${wk()}/`)?{folder:t.slice(wk().length+1)}:null}var kk=e=>e.replace(/\/$/,``)===wk(),Ak={flex:1,minHeight:0,"--trees-item-height":`${String(Ck)}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":`transparent`,"--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":`13px`,"--trees-search-bg-override":`var(--color-base-200)`,"--trees-search-fg-override":`var(--color-base-content)`};function jk({app:e,root:t,activeFolder:n,active:r=!0,mode:i,onSelectFolder:a,onDrop:o,onRename:s,onNewFolder:c,onMoveRows:l,canWrite:u,version:d}){let f=Dk(n),{scope:p,snapshot:m,requestPage:h,reload:g}=Sk({app:e,rootPath:t,activePath:`${qh(t,n)}/.`}),_=(0,q.useRef)(!1),v=(0,q.useRef)({quiet:!1,root:t,mode:i,onSelectFolder:a,onDrop:o,onRename:s,onNewFolder:c,onMoveRows:l,requestPage:h});v.current={quiet:v.current.quiet,root:t,mode:i,onSelectFolder:a,onDrop:o,onRename:s,onNewFolder:c,onMoveRows:l,requestPage:h};let y=i===`browse`&&u,{model:b}=pk({paths:[],itemHeight:Ck,initialExpansion:1,flattenEmptyDirectories:!1,search:i===`browse`,composition:{contextMenu:{enabled:i===`browse`}},onSelectionChange(e){if(v.current.quiet||_.current)return;let t=e.at(-1);if(t===void 0||e.length!==1)return;let n=Ok(t);n!==null&&(v.current.requestPage(Ek(v.current.root,t),0),v.current.onSelectFolder(n.folder))},dragAndDrop:y?{canDrag:e=>e.every(e=>!kk(e)),canDrop:({target:e})=>e.kind===`directory`&&e.directoryPath!==null&&Ok(e.directoryPath)!==null,onDropComplete:({draggedPaths:e,target:t})=>{let n=t.directoryPath===null?null:Ok(t.directoryPath);n!==null&&v.current.onDrop?.(e.map(e=>Ek(v.current.root,e)),n.folder)}}:void 0,renaming:y?{canRename:e=>!kk(e.path),onRename:({sourcePath:e,destinationPath:t})=>{let n=t.replace(/\/$/,``).split(`/`).at(-1);n!==void 0&&v.current.onRename?.(Ek(v.current.root,e),n)}}:void 0}),x=(0,q.useRef)(gk());(0,q.useLayoutEffect)(()=>{_k(b,x.current)},[b,p,d]);let S=(0,q.useRef)(d);(0,q.useEffect)(()=>{S.current!==d&&(S.current=d,g())},[g,d]),(0,q.useLayoutEffect)(()=>{let e=m.listings.map(({request:e,listing:n})=>({request:e,listing:{...n,path:Tk(t,n.path),entries:n.entries.filter(e=>e.type===`directory`)}}));vk(b,e,x.current)},[b,t,m.listings]);let C=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{v.current.quiet=!0;try{if(!r){C.current=null;for(let e of b.getSelectedPaths())b.getItem(e)?.deselect();return}e()}finally{v.current.quiet=!1}function e(){if(C.current===f)return;let e=b.getItem(f);if(!e)return;C.current=f;for(let e of b.getSelectedPaths())e!==f&&b.getItem(e)?.deselect();e.isSelected()||e.select();let t=f.slice(0,-1).split(`/`);for(let e=1;e<t.length;e+=1){let n=b.getItem(`${t.slice(0,e).join(`/`)}/`);n&&`expand`in n&&!n.isExpanded()&&n.expand()}}},[r,f,b,m.listings]),(0,q.useEffect)(()=>{m.failure&&Zt.error(Ht(m.failure).message,{id:`prints-tree-error`,toasterId:`prints-generation-notices`,action:{label:`Retry`,onClick:g}})},[g,m.failure]),(0,J.jsx)(`div`,{className:`prints-tree`,"data-library-tree":i,onDragStartCapture:()=>{_.current=!0},onDragEnd:()=>{_.current=!1},onDrop:()=>{_.current=!1},children:(0,J.jsx)(By,{model:b,className:`prints-tree-view`,style:Ak,renderContextMenu:i===`browse`?(e,n)=>{let r=Ok(e.path);return(0,J.jsxs)(`div`,{className:`flex min-w-40 flex-col gap-xs p-xs`,role:`menu`,children:[r===null?null:(0,J.jsxs)(W,{className:`w-full justify-start`,disabled:!u,role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1}),v.current.onNewFolder?.(r.folder)},children:[(0,J.jsx)(ch,{"aria-hidden":`true`}),` New folder`]}),(0,J.jsxs)(W,{className:`w-full justify-start`,disabled:!u||kk(e.path),role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1}),b.startRenaming(e.path)},children:[(0,J.jsx)(vh,{"aria-hidden":`true`}),` Rename`]}),(0,J.jsxs)(W,{className:`w-full justify-start`,disabled:!u||kk(e.path),role:`menuitem`,size:`sm`,variant:`ghost`,onClick:()=>{n.close({restoreFocus:!1});let r=b.getSelectedPaths(),i=r.includes(e.path)?r:[e.path];v.current.onMoveRows?.(i.map(e=>Ek(t,e)))},children:[(0,J.jsx)(Ei,{"aria-hidden":`true`}),` Move to…`]})]})}:void 0})})}function Mk({view:e,onView:t,onNewFolder:n,canWrite:r,...i}){return(0,J.jsxs)(`nav`,{className:`prints-rail`,"aria-label":`Library`,children:[(0,J.jsxs)(`div`,{className:`prints-rail-views`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`prints-rail-view`,"aria-current":e.kind===`all`?`page`:void 0,onClick:()=>{t({kind:`all`})},children:[(0,J.jsx)(Cr,{"aria-hidden":!0,size:16}),` All prints`]}),(0,J.jsxs)(`button`,{type:`button`,className:`prints-rail-view`,"aria-current":e.kind===`favorites`?`page`:void 0,onClick:()=>{t({kind:`favorites`})},children:[(0,J.jsx)(Kn,{"aria-hidden":!0,size:16}),` Favorites`]})]}),(0,J.jsxs)(`div`,{className:`prints-rail-head`,children:[(0,J.jsx)(`span`,{children:`Folders`}),(0,J.jsx)(W,{size:`sm`,variant:`ghost`,"aria-label":`New folder`,title:`New folder`,disabled:!r,onClick:()=>{n(e.kind===`folder`?e.folder:void 0)},children:(0,J.jsx)(ch,{"aria-hidden":!0,size:16})})]}),(0,J.jsx)(jk,{...i,mode:`browse`,canWrite:r,activeFolder:e.kind===`folder`?e.folder:void 0,active:e.kind===`folder`,onNewFolder:n,onSelectFolder:e=>{t({kind:`folder`,folder:e})}})]})}var Nk=`prints-generation-notices`;function Pk({count:e,total:t,canWrite:n,onToggleAll:r,onMove:i,onFavorite:a,onDone:o}){let s=t>0&&e===t;return(0,J.jsxs)(`div`,{className:`prints-select-bar`,role:`toolbar`,"aria-label":`Selection`,children:[(0,J.jsx)(`span`,{className:`prints-select-count`,"aria-live":`polite`,children:e===0?`Choose prints`:`${String(e)} selected`}),(0,J.jsxs)(W,{size:`sm`,variant:`ghost`,className:`prints-select-all`,disabled:t===0,onClick:r,children:[(0,J.jsx)(`span`,{className:`prints-select-wide`,children:s?`Clear selection`:`Select all in view`}),(0,J.jsx)(`span`,{className:`prints-select-narrow`,children:s?`None`:`All`})]}),(0,J.jsx)(`span`,{className:`prints-select-spacer`}),(0,J.jsxs)(W,{size:`sm`,variant:`ghost`,"aria-label":`Favorite`,disabled:e===0||!n,onClick:a,children:[(0,J.jsx)(Kn,{"aria-hidden":!0,size:16}),(0,J.jsx)(`span`,{className:`prints-select-wide`,children:`Favorite`})]}),(0,J.jsxs)(W,{size:`sm`,disabled:e===0||!n,onClick:i,children:[(0,J.jsx)(Ei,{"aria-hidden":!0,size:16}),(0,J.jsxs)(`span`,{className:`prints-select-wide`,children:[`Move to… (`,e,`)`]}),(0,J.jsxs)(`span`,{className:`prints-select-narrow`,children:[`Move (`,e,`)`]})]}),(0,J.jsx)(ht,{"aria-label":`Done selecting`,title:`Done selecting`,icon:(0,J.jsx)(Hr,{}),size:`sm`,onClick:o})]})}function Fk({view:e,title:t,onUp:n,lastFolder:r,onOpen:i,onFolders:a,selecting:o,onToggleSelect:s}){return(0,J.jsxs)(`div`,{className:`prints-library-bar`,children:[(0,J.jsxs)(W,{className:`prints-folders-button`,size:`sm`,variant:`ghost`,onClick:a,children:[(0,J.jsx)(lh,{"aria-hidden":!0,size:16}),` Folders`]}),(0,J.jsxs)(`div`,{className:`prints-library-title`,children:[n?(0,J.jsx)(ht,{"aria-label":`Up one folder`,title:`Up one folder`,icon:(0,J.jsx)(ih,{}),onClick:n}):null,(0,J.jsx)(`h2`,{title:t,children:t})]}),(0,J.jsx)(kg,{className:`prints-view-switch`,value:e.kind,onValueChange:e=>{i(e===`all`||e===`favorites`?{kind:e}:{kind:`folder`,folder:r})},children:(0,J.jsxs)(jg,{variant:`segmented`,"aria-label":`View`,children:[(0,J.jsx)(Mg,{value:`folder`,children:`Folder`}),(0,J.jsx)(Mg,{value:`all`,children:`All`}),(0,J.jsx)(Mg,{value:`favorites`,children:`Favorites`})]})}),(0,J.jsxs)(W,{size:`sm`,variant:o?`outline`:`ghost`,"aria-label":`Select`,"aria-pressed":o,onClick:s,children:[(0,J.jsx)(ph,{"aria-hidden":!0,size:16}),(0,J.jsx)(`span`,{className:`prints-select-label`,children:`Select`})]})]})}function Ik({app:e,root:t,canWrite:n,count:r,open:i,version:a,onClose:o,onMove:s}){let[c,l]=(0,q.useState)(),[u,d]=(0,q.useState)(``),f=u.trim(),p=f===``||Kh(f)&&!f.includes(`/`),m=f===``?c:c===void 0?f:`${c}/${f}`;return(0,J.jsx)(Fp,{open:i,onOpenChange:e=>{e||(d(``),o())},children:(0,J.jsxs)(Bp,{className:`prints-move-dialog`,children:[(0,J.jsx)(Hp,{children:(0,J.jsxs)(Up,{children:[`Move `,String(r),` `,r===1?`item`:`items`,` to…`]})}),(0,J.jsx)(`div`,{className:`prints-move-tree`,children:(0,J.jsx)(jk,{app:e,root:t,activeFolder:c,mode:`pick`,canWrite:n,version:a,onSelectFolder:l})}),(0,J.jsxs)(`label`,{className:`prints-move-new`,htmlFor:`prints-move-new-folder`,children:[(0,J.jsxs)(`span`,{children:[`New folder inside `,c??`the library`]}),(0,J.jsx)(ey,{id:`prints-move-new-folder`,value:u,placeholder:`Folder name`,"aria-invalid":!p,onChange:e=>{d(e.target.value)}})]}),(0,J.jsxs)(Vp,{children:[(0,J.jsx)(Wp,{render:(0,J.jsx)(W,{variant:`outline`,size:`sm`}),children:`Cancel`}),(0,J.jsxs)(W,{size:`sm`,disabled:!p||!n,onClick:()=>{d(``),s(m,f!==``)},children:[`Move to`,` `,m===void 0?`Library`:m.split(`/`).at(-1)]})]})]})})}var Lk={conflict:`a file or folder with that name is already there`,not_found:`it is no longer in the library`,invalid:`a folder can't move into itself`,not_granted:`Prints isn't allowed to change this Computer`,unavailable:`the Computer didn't answer`};function Rk(e,t,n,r){let{moved:i,failed:a}=n;if(a.length>0){let e=a[0];Zt.error(`Couldn't move ${String(a.length)} ${a.length===1?`item`:`items`}: ${Lk[e.error]}.`,{toasterId:Nk,id:`prints-move-error`})}i.length!==0&&Zt(`Moved ${String(i.length)} ${i.length===1?`item`:`items`}`,{toasterId:Nk,duration:8e3,action:{label:`Undo`,onClick:()=>{let n=new Map;for(let{from:e,to:r}of i){let i=Jh(t,e)??``;n.set(i,[...n.get(i)??[],r])}Promise.all([...n].map(([t,n])=>rg(e,{paths:n,folder:t===``?void 0:t}))).then(()=>{r()},e=>{dn(`prints-undo-move`,e),Zt.error(`Couldn't undo that move.`,{toasterId:Nk}),r()})}}})}function zk({parent:e,open:t,onClose:n,onCreate:r}){let[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(!1),u=()=>{a(``),s(null),n()},d=async()=>{l(!0);let e=await r(i);l(!1),e===null?u():(s(e),Zt.error(e,{toasterId:Nk,id:`prints-new-folder`}))};return(0,J.jsx)(Fp,{open:t,onOpenChange:e=>{e||u()},children:(0,J.jsxs)(Bp,{className:`prints-new-folder-dialog`,children:[(0,J.jsx)(Hp,{children:(0,J.jsxs)(Up,{children:[`New folder in `,e??`the library`]})}),(0,J.jsxs)(`form`,{id:`prints-new-folder-form`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,J.jsx)(`label`,{htmlFor:`prints-new-folder-name`,children:`Name`}),(0,J.jsx)(ey,{id:`prints-new-folder-name`,autoFocus:!0,value:i,placeholder:`Characters`,"aria-invalid":o!==null,onChange:e=>{a(e.target.value),s(null)}})]}),(0,J.jsxs)(Vp,{children:[(0,J.jsx)(Wp,{render:(0,J.jsx)(W,{variant:`outline`,size:`sm`}),children:`Cancel`}),(0,J.jsx)(W,{size:`sm`,type:`submit`,form:`prints-new-folder-form`,disabled:c||i.trim()===``,children:`Create`})]})]})})}var Bk=24,Vk=`prints-generation-notices`;function Hk(e,t){let[n,r]=(0,q.useState)({entries:[],index:-1}),i=(e,t)=>e.kind===t.kind&&(e.kind!==`folder`||t.kind===`folder`&&e.folder===t.folder),a=n=>{r(t=>{let r=t.entries[t.index]??e;if(i(r,n))return t;let a=t.entries.slice(0,t.index+1),o=a.length===0?[e]:a;return{entries:[...o,n],index:o.length}}),t(n)},o=e=>{let i=n.index+e;if(i<0||i>=n.entries.length)return!1;let a=n.entries[i];return r({...n,index:i}),t(a),!0};return{open:a,canGoBack:n.index>0,canGoForward:n.index>=0&&n.index<n.entries.length-1,back:()=>o(-1),forward:()=>o(1)}}function Uk({app:e,destination:t,view:n,setView:r,entries:i,canWrite:a}){let o=gn(),s=Hk(n,r),[c,l]=(0,q.useState)(0),[u,d]=(0,q.useState)(),f=n.kind===`folder`?n.folder:void 0,p=n.kind===`folder`;(0,q.useEffect)(()=>{p&&d(f)},[p,f]);let[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(new Set),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(new Map),w=e?.capabilities.has(Qn)===!0,T=Ss({queries:(0,q.useMemo)(()=>{let e=i.map(e=>e.path),t=[];for(let n=0;n<e.length;n+=Bk)t.push(e.slice(n,n+Bk));return t},[i]).map(n=>({...rr(e,Qn,lg.described(e,n),async(t,r)=>{if(!e)return[];let i=await ig(e,n);return r.throwIfAborted(),i}),enabled:w&&t!==null,retry:!1})),combine:e=>{let t=new Map;for(let n of e)for(let e of n.data??[])t.set(e.path,e);return t}}),E=(0,q.useCallback)(()=>{l(e=>e+1),_(new Set),o.invalidateQueries({queryKey:lg.listings(e)}),o.invalidateQueries({queryKey:lg.describedAll(e)})},[e,o]),D=(0,q.useCallback)(async(n,r,i={})=>{if(!(!e||t===null)){try{Rk(e,t,await rg(e,{paths:n,folder:r,createFolder:i.create??!1,name:i.name}),E)}catch(e){dn(`prints-move-files`,e),Zt.error(`Couldn't move those. Check the Computer and try again.`,{toasterId:Vk,id:`prints-move-error`})}E()}},[e,t,E]),O=(0,q.useCallback)((t,r)=>{e&&(C(e=>{let n=new Map(e);for(let e of t)n.set(e,r);return n}),ag(e,t,r).then(()=>{o.invalidateQueries({queryKey:lg.describedAll(e)}),n.kind===`favorites`&&o.invalidateQueries({queryKey:lg.listings(e)})},e=>{dn(`prints-set-favorite`,e),Zt.error(`Couldn't change that favorite.`,{toasterId:Vk,id:`prints-favorite-error`}),C(e=>{let n=new Map(e);for(let e of t)n.delete(e);return n})}))},[e,o,n.kind]),k=(0,q.useCallback)(async(n,r)=>{if(!e||t===null)return`Choose a library folder first.`;let i=r.trim();if(!Kh(i)||i.includes(`/`))return`Use a single name, without slashes.`;let a=n===void 0?i:`${n}/${i}`;if(!Kh(a))return`That folder name is too long.`;try{await e.capabilities.require(ya).mkdir({path:qh(t,a)})}catch(e){return dn(`prints-new-folder`,e),`Couldn't create the folder. Check Computer write access.`}return E(),s.open({kind:`folder`,folder:a}),null},[e,t,s,E]),A=(0,q.useMemo)(()=>n.kind===`folder`?[{id:``,label:t?.split(`/`).at(-1)??`Library`},...Yh(n.folder).map(({name:e,folder:t})=>({id:t,label:e}))].slice(-8):[{id:n.kind,label:n.kind===`all`?`All prints`:`Favorites`}],[t,n]),j=e=>S.get(e)??T.get(e)?.favorite??!1,M=e=>{if(t===null||!e.path.startsWith(`${t}/`))return e;let r=T.get(e.path),o=S.get(e.path)??r?.favorite??!1,s=i.find(t=>t.path===e.path),c={...e,badge:void 0,folderCaption:n.kind===`folder`?void 0:s?.folder,favorite:o,select:{active:m,checked:g.has(e.path),onToggle:()=>{_(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n})}}};return!e.pending&&r!==void 0&&(c.badge=r.kind===null?{label:null,seconds:null}:{label:r.modelLabel??r.model,seconds:r.durationSeconds}),w&&(c.onToggleFavorite=()=>{O([e.path],!o)}),w&&a&&(c.onMove=()=>{y([e.path])}),c},ee=n.kind===`all`?`All prints`:n.kind===`favorites`?`Favorites`:n.folder?.split(`/`).at(-1)??`Library`,N=n.kind===`folder`&&n.folder!==void 0?n.folder.split(`/`).slice(0,-1).join(`/`):null;return{title:ee,up:N===null?void 0:()=>{s.open({kind:`folder`,folder:N===``?void 0:N})},lastFolder:u,history:s,version:c,refresh:E,crumbs:A,selecting:m,setSelecting:e=>{h(e),e||_(new Set)},selected:g,selectAll:e=>{_(new Set(e))},moving:v,setMoving:y,newFolder:b,setNewFolder:x,move:D,toggleFavorite:O,createFolder:k,enrich:M,isFavorite:j,folderOf:Jh}}function Wk(e,t){return{kind:`button`,id:`folder`,text:t.checking?`Checking…`:`prints`,icon:`folder`,title:e===null?`Choose where Prints saves images`:v(`Save prints to ${e}`,1024),opens:`dialog`,expanded:t.editing}}function Gk(e,t=/Mac|iPhone|iPad/u.test(globalThis.navigator.userAgent)){if(e.startsWith(`<leader>`)){let t=e.replaceAll(`<leader>`,`Ctrl K `).trimEnd();return e.endsWith(` `)?`${t} Space`:t}return e.split(` `).map(e=>e.split(`+`).map(e=>e===`mod`?t?`⌘`:`Ctrl`:e===`escape`?`Esc`:e.length===1?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)).join(e===`ctrl+k`||e===`mod+k`?` `:`+`)).join(` `)}function Kk(e){let t=new Map;for(let n of e.bindings)t.set(n.commandId,[...t.get(n.commandId)??[],Gk(n.binding)]);return e.slash.map(e=>({alias:e.alias,commandId:e.commandId,command:e.command,title:e.title,description:e.description,category:e.category,order:e.order,grammar:e.arguments,consumesDraft:e.consumesDraft,keys:t.get(e.commandId)??[],availability:e.availability}))}function qk(e,t){let n=e.toLocaleLowerCase(),r=t.toLocaleLowerCase();if(r.length===0)return{tier:0,spread:0,indices:[]};let i=e=>Array.from({length:r.length},(t,n)=>e+n);if(n.startsWith(r))return{tier:0,spread:n.length-r.length,indices:i(0)};let a=n.search(RegExp(`[-_\\s]${r.replaceAll(/[.*+?^${}()|[\]\\]/gu,`\\$&`)}`,`u`));if(a>=0)return{tier:1,spread:a,indices:i(a+1)};let o=n.indexOf(r);if(o>=0)return{tier:2,spread:o,indices:i(o)};let s=[],c=0;for(let e of r){let t=n.indexOf(e,c);if(t<0)return;s.push(t),c=t+1}let l=s[0]??0;return{tier:3,spread:(s.at(-1)??0)-l-r.length+1,indices:s}}function Jk(e,t,n,r){return e.map(e=>({entry:e,match:qk(t(e),n)})).filter(e=>e.match!==void 0).sort((e,n)=>e.match.tier-n.match.tier||e.match.spread-n.match.spread||r(e.entry)-r(n.entry)||t(e.entry).localeCompare(t(n.entry))).map(({entry:e,match:t})=>({entry:e,indices:t.indices}))}var Yk=[`help`,`login`,`model`];function Xk(e,t,n={}){if(!t.startsWith(`/`)||t.includes(`
1268
- `))return{kind:`none`};let r=t.search(/\s/u);if(r<0){let r=t.slice(1);return{kind:`commands`,query:r,items:Jk(e.filter(e=>e.availability.status===`available`&&(r.length===0?e.category===(n.idleCategory??`Conversation`)||Yk.includes(e.alias):e.category!==`Advanced`||e.alias.toLocaleLowerCase().startsWith(r.toLocaleLowerCase()))),e=>e.alias,r,e=>{let t=Yk.indexOf(e.alias);return r.length===0&&t>=0?t-Yk.length:e.order}).map(({entry:e,indices:t})=>({command:e,label:`/${e.alias}`,matches:t.map(e=>e+1),insert:e.grammar===void 0?`/${e.alias}`:`/${e.alias} `}))}}let i=t.slice(1,r),a=e.find(e=>e.alias===i);if(a?.grammar===void 0||a.availability.status!==`available`)return{kind:`none`};let o=t.slice(r).trimStart(),s=(o.includes(` `)?[]:a.grammar.words??[]).filter(e=>e.word.toLocaleLowerCase().startsWith(o.toLocaleLowerCase())).map(e=>({word:e,label:e.word,matches:Array.from({length:o.length},(e,t)=>t),insert:`/${i} ${e.word}`}));return{kind:`arguments`,command:a,query:o,hint:`/${i} ${a.grammar.hint}`,items:s}}var Zk=Ef({keyCode:Of(229)});function Qk(e){return e.nativeEvent.isComposing||at(Zk,e.nativeEvent).success}function $k(e,t){return e.animate(t.reduced?[{opacity:1},{opacity:0}]:[{opacity:1,transform:`none`},{opacity:0,transform:`translateY(-120%)`}],{duration:t.reduced?t.fast:t.normal,easing:de(t,t.easeExit),fill:`backwards`})}function eA(e,t){let n=-12*Math.min(1.5,t.bounce/.3);return e.animate(t.reduced?[{opacity:0},{opacity:1}]:[{opacity:0,transform:`translateY(70%)`},{opacity:1,transform:`translateY(${String(n)}%)`,offset:.6},{opacity:1,transform:`none`}],{duration:t.reduced?t.fast:t.springDuration,easing:de(t,t.ease),fill:`backwards`})}function tA(e,t,n){return e.animate([{opacity:1-n},{opacity:n}],{duration:t.reduced?t.fast:t.normal,delay:n===1&&!t.reduced?t.fast/2:0,easing:de(t,t.ease),fill:`backwards`})}function nA(e,t){let n=1+.05*Math.min(1.5,.4+t.bounce/.3);return e.animate([{transform:`scale(1)`},{transform:`scale(${String(n)})`,offset:.4},{transform:`scale(1)`}],{duration:t.springDuration,easing:de(t,`ease-out`)})}var rA=(0,q.forwardRef)(function({state:e,onStop:t,stopLabel:n=`Stop`,iconSize:r=20,onClick:i,disabled:a,className:o,tone:s=`primary`,"aria-label":c,...l},u){let d=(0,q.useRef)(null);(0,q.useImperativeHandle)(u,()=>d.current);let f=(0,q.useRef)(e);(0,q.useLayoutEffect)(()=>{let t=d.current,n=f.current;if(f.current=e,!t||n===e||!y(t))return;let r=t.querySelector(`[data-glyph="arrow"]`),i=t.querySelector(`[data-glyph="busy"]`);if(!r||!i)return;let a=kt(t),o=[];return e===`busy`?o.push($k(r,a),tA(i,a,1)):n===`busy`&&o.push(tA(i,a,0),eA(r,a)),n===`empty`&&e===`ready`&&!a.reduced&&o.push(nA(t,a)),()=>{for(let e of o)e.cancel()}},[e]);let p=e===`busy`,m=p&&t!==void 0;return(0,J.jsx)(bt,{...l,ref:d,className:B(`caps-send-action`,o),tone:s,"aria-busy":p?!0:void 0,"aria-label":m?n:c,"data-send-state":e,disabled:a===!0||e===`empty`||p&&!m,onClick:m?t:i,label:null,icon:(0,J.jsxs)(`span`,{className:`caps-send-glyph`,"data-state":e,children:[(0,J.jsx)(`span`,{"data-glyph":`arrow`,children:(0,J.jsx)(nh,{"aria-hidden":`true`,size:r})}),(0,J.jsx)(`span`,{"data-glyph":`busy`,children:t===void 0?(0,J.jsx)(yn,{decorative:!0,size:`sm`}):(0,J.jsx)(Sh,{"aria-hidden":`true`,fill:`currentColor`,size:Math.round(r*.7)})})]})})}),iA=(0,q.forwardRef)(function({className:e,label:t,...n},r){return(0,J.jsx)(bt,{...n,ref:r,className:B(`parakeet-composer-model-key`,e),label:t,readout:(0,J.jsx)(Jn,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)] shrink-0`})})}),aA=(0,q.forwardRef)(function({className:e,...t},n){return(0,J.jsx)(`div`,{...t,ref:n,className:B(`caps-popover-anchor`,e)})}),oA=(0,q.forwardRef)(function({className:e,open:t,side:n=`top`,...r},i){return t?(0,J.jsx)(`div`,{...r,ref:i,className:B(`caps-popover`,e),"data-side":n}):null}),sA=(0,q.forwardRef)(function({active:e,className:t,onMouseDown:n,...r},i){return(0,J.jsx)(`div`,{role:`option`,"aria-selected":e,...r,ref:i,className:B(`caps-popover-option`,t),"data-active":e,onMouseDown:e=>{e.preventDefault(),n?.(e)}})});function cA({items:e,openId:t,onOpenChange:n,leading:r,trailing:i,renderTrigger:a,placement:o=`housing`,align:s=`end`,hostInset:c,className:l,...u}){let d=(0,q.useId)(),f=(0,q.useRef)(null),p=(0,q.useRef)(null),m=(0,q.useRef)(new Map),h=e.find(e=>e.id===t&&!e.disabled),g=h?.id,_=()=>{g&&m.current.get(g)?.focus(),n(null)};return(0,q.useEffect)(()=>{g&&p.current?.focus()},[g]),(0,q.useEffect)(()=>{c===void 0?f.current?.style.removeProperty(`--caps-status-tray-host-inset`):f.current?.style.setProperty(`--caps-status-tray-host-inset`,`${String(Math.max(0,c))}px`)},[c]),(0,q.useEffect)(()=>{if(!g)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),m.current.get(g)?.focus(),n(null))},t=e=>{e.target instanceof Node&&!f.current?.contains(e.target)&&n(null)};return document.addEventListener(`keydown`,e),document.addEventListener(`pointerdown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`pointerdown`,t)}},[g,n]),(0,J.jsxs)(aA,{...u,ref:f,className:B(`caps-status-tray`,l),"data-placement":o,"data-align":s,children:[h?(0,J.jsxs)(oA,{open:!0,ref:p,tabIndex:-1,side:`top`,id:`${d}-${h.id}`,role:`dialog`,"aria-labelledby":`${d}-title`,className:`caps-status-tray-panel`,"data-status-tray-panel":h.id,children:[(0,J.jsxs)(`div`,{className:`caps-status-tray-head`,children:[h.tone?(0,J.jsx)(em,{size:`compact`,tone:h.tone,glyph:h.glyph??`dot`}):null,(0,J.jsx)(`span`,{id:`${d}-title`,className:`caps-status-tray-title`,children:h.title??h.label}),h.actions,(0,J.jsx)(ht,{"aria-label":`Close tray`,icon:(0,J.jsx)(Hr,{"aria-hidden":`true`}),onClick:_})]}),(0,J.jsx)(`div`,{className:`caps-status-tray-body`,children:h.content})]}):null,o===`host`?null:(0,J.jsxs)(`div`,{className:`caps-status-tray-row`,children:[r,(0,J.jsx)(`div`,{className:`caps-status-tray-chips`,children:e.map(e=>{let r={ref:t=>{t?m.current.set(e.id,t):m.current.delete(e.id)},type:`button`,className:a?void 0:`caps-status-tray-chip`,"aria-expanded":g===e.id,"aria-controls":g===e.id?`${d}-${e.id}`:void 0,"aria-label":e.accessibleLabel,disabled:e.disabled,title:e.disabled?e.accessibleLabel:void 0,"aria-haspopup":`dialog`,"data-status-tray-chip":e.id,onClick:()=>{n(t===e.id?null:e.id)},children:(0,J.jsxs)(J.Fragment,{children:[e.tone?(0,J.jsx)(em,{size:`compact`,glyph:e.glyph??`dot`,motion:e.motion??`none`,tone:e.tone}):null,(0,J.jsx)(`span`,{className:`caps-status-tray-label`,children:e.label}),e.count!==void 0&&e.count>0?(0,J.jsx)(`span`,{className:`caps-status-tray-count`,children:e.count}):null]})};return(0,J.jsxs)(q.Fragment,{children:[a?a(r):(0,J.jsx)(`button`,{...r}),e.after]},e.id)})}),i]})]})}function lA({children:e,className:t,...n}){return(0,J.jsx)(`div`,{...n,className:B(`caps-status-tray-list`,t),children:e})}function uA({icon:e,primary:t,secondary:n,actions:r,className:i,...a}){return(0,J.jsxs)(`div`,{...a,className:B(`caps-status-tray-item`,i),children:[e?(0,J.jsx)(`span`,{className:`caps-status-tray-icon`,children:e}):null,(0,J.jsxs)(`span`,{className:`caps-status-tray-text`,children:[(0,J.jsx)(`span`,{className:`caps-status-tray-primary`,children:t}),n?(0,J.jsx)(`span`,{className:`caps-status-tray-secondary`,children:n}):null]}),r?(0,J.jsx)(`span`,{className:`caps-status-tray-actions`,children:r}):null]})}function dA({children:e=`All caught up.`,title:t}){return(0,J.jsxs)(`div`,{className:`caps-status-tray-note`,children:[t?(0,J.jsx)(`strong`,{className:`caps-status-tray-note-title`,children:t}):null,(0,J.jsx)(`p`,{children:e})]})}var fA=(0,q.forwardRef)(function({className:e,invalid:t,...n},r){return(0,J.jsx)(`textarea`,{...n,"aria-invalid":t?!0:n[`aria-invalid`]===!1?void 0:n[`aria-invalid`],className:B(`textarea textarea-bordered w-full`,t&&`textarea-error`,e),ref:r})});function pA(e,t){return`${e}-${String(t)}`}function mA(e){switch(e.key){case`ArrowDown`:return`next`;case`ArrowUp`:return`previous`;case`Enter`:return e.shiftKey?null:`accept`;case`Tab`:return`accept`;case`Escape`:return`dismiss`;default:return null}}function hA(e){return{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":e.open,"aria-controls":e.open?e.listId:void 0,"aria-activedescendant":e.open?pA(e.listId,e.selected):void 0}}function gA({open:e,rows:t,selected:n,listId:r,label:i,kind:a,hint:o,empty:s,onHighlight:c,onChoose:l}){return(0,J.jsx)(oA,{open:e,side:`top`,"data-parakeet-slash":``,children:(0,J.jsxs)(`div`,{className:`parakeet-slash-menu`,"data-kind":a,children:[o===void 0?null:(0,J.jsx)(`p`,{className:`parakeet-slash-hint`,children:o}),t.length===0?s===void 0?null:(0,J.jsx)(`p`,{className:`parakeet-slash-hint`,children:s}):(0,J.jsx)(`div`,{id:r,role:`listbox`,"aria-label":i,children:t.map((e,t)=>(0,J.jsxs)(sA,{id:pA(r,t),active:t===n,"aria-disabled":e.disabled===!0||void 0,"data-disabled":e.disabled===!0,onMouseEnter:()=>{c(t)},onClick:()=>{l(t)},children:[e.media===void 0?null:(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`parakeet-slash-media`,children:e.media}),(0,J.jsx)(`span`,{className:`parakeet-slash-label`,children:e.label}),(0,J.jsx)(`span`,{className:`parakeet-slash-detail`,children:e.detail}),e.keys===void 0||e.keys.length===0?null:(0,J.jsx)(`kbd`,{className:`parakeet-slash-keys`,children:e.keys})]},e.key))})]})})}var _A={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`},vA={blurStdDeviation:.22,alphaSlope:18,alphaIntercept:-8};function yA({state:e}){let t=`caps-checkbox-${(0,q.useId)().replaceAll(`:`,``)}`,n=(0,q.useRef)(null),r=(0,q.useRef)(e).current,i=(0,q.useRef)(e),a=le();return(0,q.useLayoutEffect)(()=>{if(!n.current)return;let t=e!==`unchecked`,r=i.current!==`unchecked`,s=a||i.current===e;i.current=e;let c=kt(n.current),l=Hn(c,{ease:`inCubic`,duration:160}),u=mo(n.current,{d:{to:_A[e],...s?ii:Hn(c,{ease:`outCubic`,duration:200})},"stroke-dashoffset":{to:+!t,...s?ii:t?Hn(c,{ease:`inOutSine`,duration:260}):l},"stroke-width":s?{to:t?2.4:0,duration:0}:t&&!r?[{to:2.2,...Hn(c,{ease:`outCubic`,duration:65})},{to:2.4,delay:o(c,120),...ni(c,{bounce:.35,duration:220})}]:{to:t?2.4:0,...l}});return()=>{u.cancel()}},[e,a]),(0,J.jsxs)(`svg`,{className:`caps-checkbox-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsx)(f,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,J.jsx)(H,{id:`${t}-shadow`}),(0,J.jsx)(Dn,{id:`${t}-inset`}),(0,J.jsx)(Xe,{id:`${t}-goo`,values:vA}),(0,J.jsxs)(`filter`,{id:`${t}-relief`,x:`-25%`,y:`-25%`,width:`150%`,height:`150%`,colorInterpolationFilters:`sRGB`,children:[(0,J.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`0.28`,result:`relief`}),(0,J.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,J.jsx)(`feDistantLight`,{azimuth:`225`,elevation:`55`})}),(0,J.jsx)(`feComposite`,{in:`light`,in2:`SourceAlpha`,operator:`in`,result:`clipped-light`}),(0,J.jsx)(`feBlend`,{in:`SourceGraphic`,in2:`clipped-light`,mode:`screen`})]}),(0,J.jsx)(`mask`,{id:`${t}-contour`,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`12`,height:`12`,style:{maskType:`alpha`},children:(0,J.jsx)(`path`,{ref:n,d:_A[r],fill:`none`,stroke:`var(--color-white)`,strokeWidth:r===`unchecked`?0:2.4,pathLength:`1`,strokeDasharray:`1`,strokeDashoffset:+(r===`unchecked`),strokeLinecap:`round`,strokeLinejoin:`round`,filter:e===`mixed`?void 0:`url(#${t}-goo)`})}),(0,J.jsx)(`clipPath`,{id:`${t}-well`,children:(0,J.jsx)(`rect`,{x:`1`,y:`1`,width:`10`,height:`10`,rx:`2.5`})})]}),(0,J.jsx)(`rect`,{className:`caps-checkbox-track`,x:`0.5`,y:`0.5`,width:`11`,height:`11`,rx:`3`,filter:`url(#${t}-inset)`}),(0,J.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,J.jsx)(`g`,{filter:`url(#${t}-shadow)`,children:(0,J.jsx)(`g`,{filter:`url(#${t}-relief)`,children:(0,J.jsx)(`g`,{mask:`url(#${t}-contour)`,children:(0,J.jsx)(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`url(#${t}-surface)`})})})})})]})}var bA=(0,q.forwardRef)(function({className:e,appearance:t,indicator:n,invalid:r,indeterminate:i=!1,checked:a,defaultChecked:o=!1,onChange:s,...c},l){let u=(0,q.useRef)(null),[d,f]=(0,q.useState)(o),p=a??d,m=i?`mixed`:p?`checked`:`unchecked`;return(0,q.useImperativeHandle)(l,()=>{if(!u.current)throw Error(`Checkbox input is not mounted`);return u.current},[]),(0,q.useLayoutEffect)(()=>{u.current&&(u.current.indeterminate=i)},[i]),(0,q.useEffect)(()=>{let e=u.current?.form;if(!e||a!==void 0)return;let t=e=>{queueMicrotask(()=>{!e.defaultPrevented&&u.current&&f(o)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[a,o,c.form]),(0,J.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,J.jsx)(`input`,{...c,checked:p,"aria-checked":i?`mixed`:p,"aria-invalid":r?!0:c[`aria-invalid`]===!1?void 0:c[`aria-invalid`],className:B(`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,J.jsx)(yA,{state:m}):n]})});function xA({getKey:e,isDisabled:t=()=>!1,items:n}){let r=(0,q.useMemo)(()=>{let r=n.map(e);if(r.some(e=>!e))throw Error(`Selectable items require non-empty keys`);if(new Set(r).size!==r.length)throw Error(`Selectable items require unique keys`);return n.filter(e=>!t(e))},[e,t,n]),[i,a]=(0,q.useState)(null);(0,q.useEffect)(()=>{i!==null&&!r.some(t=>e(t)===i)&&a(null)},[i,r,e]);let o=r.find(t=>e(t)===i),s=o?r.findIndex(t=>e(t)===i):-1;return{activeIndex:s,activeItem:o,activeKey:i,enabledItems:r,move:(t,n)=>{if(r.length===0)return;let i=n?n===`start`?0:r.length-1:s<0?t>0?0:r.length-1:(s+t+r.length)%r.length,o=r[i];o&&a(e(o))},setActiveKey:a}}var SA=M(`card caps-card`,{variants:{variant:{surface:`caps-card-surface`,outline:`caps-card-outline`,interactive:`caps-card-interactive`,game:`caps-card-game caps-card-interactive`,fit:`caps-card-fit`},density:{regular:``,compact:`caps-card-compact`}},defaultVariants:{variant:`surface`,density:`regular`}}),CA=(0,q.forwardRef)(function({className:e,density:t,featured:n=!1,state:r,variant:i,...a},o){return(0,J.jsx)(`div`,{...a,className:B(SA({density:t,variant:i}),n&&`caps-card-featured`,e),"data-state":r,ref:o})});(0,q.forwardRef)(function({className:e,density:t,variant:n,width:r=`default`,...i},a){return(0,J.jsx)(`main`,{className:`caps-centered-card-stage`,children:(0,J.jsx)(CA,{...i,className:B(`caps-centered-card`,r===`wide`&&`caps-centered-card-wide`,e),ref:a,variant:n??`surface`,...t?{density:t}:{}})})}),(0,q.forwardRef)(function({alignment:e=`start`,className:t,...n},r){return(0,J.jsx)(`div`,{...n,className:B(`caps-card-header`,e===`center`&&`caps-card-header-centered`,t),ref:r})}),(0,q.forwardRef)(function({className:e,level:t=3,...n},r){return(0,J.jsx)(t===2?`h2`:`h3`,{...n,className:B(`caps-card-title`,e),ref:r})}),(0,q.forwardRef)(function({className:e,...t},n){return(0,J.jsx)(`p`,{...t,className:B(`caps-card-description`,e),ref:n})}),(0,q.forwardRef)(function({className:e,...t},n){return(0,J.jsx)(`div`,{...t,className:B(`caps-card-content`,e),ref:n})}),(0,q.forwardRef)(function({className:e,...t},n){return(0,J.jsx)(`div`,{...t,className:B(`caps-card-footer`,e),ref:n})});var wA=(0,q.forwardRef)(function({action:e,attachments:t,className:n,input:r,toolbar:i,...a},o){return(0,J.jsxs)(`div`,{...a,ref:o,className:B(`caps-composer`,n),children:[t===void 0?null:(0,J.jsx)(`div`,{className:`caps-composer-attachments`,children:t}),(0,J.jsx)(`div`,{className:`caps-composer-input`,children:r}),i===void 0&&e===void 0?null:(0,J.jsxs)(`div`,{className:`caps-composer-bar`,children:[(0,J.jsx)(`div`,{className:`caps-composer-toolbar`,children:i}),e]})]})});function TA({draft:e,hasAttachments:t=!1,busy:n,queueWhileBusy:r=!1,blocked:i=!1}){let a=!i&&(e.trim().length>0||t);return n&&(!r||!a)?`busy`:a?`ready`:`empty`}function EA({attachments:e,action:t,children:n,className:r,input:i,menu:a,row:o,...s}){return(0,J.jsxs)(aA,{className:`parakeet-composer-anchor`,children:[a,(0,J.jsxs)(CA,{...s,className:B(`parakeet-composer-shell`,r),children:[(0,J.jsx)(wA,{action:t,attachments:e,input:i,toolbar:o===void 0?void 0:(0,J.jsx)(cA,{className:`parakeet-composer-row`,align:`start`,items:o.items,openId:o.openId,onOpenChange:o.onOpenChange,renderTrigger:({children:e,...t})=>(0,J.jsx)(bt,{...t,label:e,expanded:t[`aria-expanded`]===!0}),leading:o.controls,trailing:(0,J.jsxs)(`span`,{className:`parakeet-composer-trailing`,children:[o.status,o.readout==null?null:(0,J.jsx)(`span`,{className:`parakeet-composer-readout`,children:o.readout}),(0,J.jsx)(`span`,{className:`parakeet-composer-action`,children:o.action})]})})}),n]})]})}function DA(e,t){(0,q.useLayoutEffect)(()=>{let t=e.current;t&&(t.style.height=`auto`,t.style.height=`${String(t.scrollHeight)}px`)},[e,t])}function OA({disabled:e,emptyLabel:t,models:n,onChange:r,value:i}){let a=n.find(e=>e.id===i),[o,s]=(0,q.useState)(null);return(0,J.jsx)(`span`,{className:`contents`,ref:s,children:(0,J.jsxs)(no,{children:[(0,J.jsx)(Va,{"aria-label":`Generation model`,"data-generation-model":i,disabled:e||n.length===0,render:(e,n)=>(0,J.jsx)(iA,{...e,expanded:n.open,label:a===void 0?t:ui(a)})}),(0,J.jsx)(Da,{"data-generation-model-menu":!0,container:Ng(o),side:`top`,align:`start`,"aria-label":`Generation models`,children:n.map(e=>(0,J.jsx)(wa,{"data-generation-model-option":e.id,checked:e.id===i,closeOnClick:!0,onSelect:()=>{r(e.id)},children:ui(e)},e.id))})]})})}var kA={kind:`folder`,folder:void 0};function AA(e){let t=yf(e),n=(0,q.useRef)(e);n.current=e;let r=gn(),i=Or(li(e)),a=Es(dg(e,i.data?.configured?{kind:`folder`,path:i.data.path}:null)),o=`${t??``}:${i.data?.path??``}`,[s,c]=(0,q.useState)({scope:o,view:kA}),l=s.scope===o?s.view:kA,d=e=>{c({scope:o,view:e})},[f,p]=(0,q.useState)(null),m=n=>n?.app===e&&n.computerId===t,h=ce({mutationKey:xi.folder(e),mutationFn:async({owner:e,id:t,path:r,create:i})=>{let a=()=>{if(n.current!==e||e.context.get().computerId!==t)throw new G(`Computer selection changed`,{code:`SELECTION_CHANGED`,retryable:!1})};return a(),i&&await e.capabilities.require(ya).mkdir({path:r}),a(),await Ga(e.capabilities,{path:r,limit:1,offset:0}),a(),br(e.capabilities,{operation:`select-folder`,computerId:t,path:r})},onSuccess:(e,t)=>{t.owner===n.current&&t.owner.context.get().computerId===t.id&&p(null)},onSettled:(e,t,n)=>Promise.all([r.invalidateQueries({queryKey:n.queryKey,exact:!0}),r.invalidateQueries({queryKey:lg.listing(n.owner,n.path),exact:!0})])}),g=h.variables?.owner===e&&h.variables.id===t,_=i.isFetching||g&&h.isPending,v=async(n,r)=>{if(!e||!t||_)return`Computer selection changed. Try again.`;let i=n.trim();if(!u(Ai)(i))return`Enter an absolute Computer folder, such as /media.`;try{return await h.mutateAsync({owner:e,id:t,path:i,create:r,queryKey:xi.folder(e)}),null}catch{return`Could not use this folder. Check its location and your Computer permissions.`}},y=i.isError||a.isError,b=y||!i.data?.configured?null:i.data.path,x=b===null?null:l.kind===`folder`?qh(b,l.folder):b,S=b===null?null:l.kind===`folder`?{kind:`folder`,path:x??b}:{kind:l.kind,path:b};return{view:l,setView:d,destination:b,landingPath:x??(y?null:i.data?.path??null),source:S,path:y?null:i.data?.path??null,computerId:t,available:e?.capabilities.has(_r)===!0,writable:e?.capabilities.has(ya)===!0,busy:_,error:y?`Your media folder is unavailable. Choose or create a folder.`:null,editing:m(f),setEditing:n=>{p(n?{app:e,computerId:t}:null)},choose:v,ensureCreated:async()=>i.data?i.data.configured?null:v(i.data.path,!0):`Your Prints library is still loading.`,recheck:()=>{r.invalidateQueries({queryKey:lg.listing(e,i.data?.path??null),exact:!0}),r.invalidateQueries({queryKey:xi.folder(e),exact:!0})}}}var jA=w(b),MA=w(g({message:b}));function NA(e){for(let t of e.errors){let e=xn(xe(Qe(MA(t),e=>e.message),()=>jA(t)));if(e!==void 0&&e.length>0)return e}}var PA={neutral:`progress-neutral`,primary:`progress-primary`,secondary:`progress-secondary`,accent:`progress-accent`,success:`progress-success`,info:`progress-info`,warning:`progress-warning`,error:`progress-error`},FA=(0,q.forwardRef)(function({className:e,tone:t=`primary`,...n},r){return(0,J.jsx)(`progress`,{...n,"data-complete":n.value!==void 0&&Number(n.value)>=Number(n.max??1)?`true`:void 0,className:B(`progress caps-gooey-motion caps-gooey-progress w-full`,PA[t],e),ref:r})});(0,q.forwardRef)(function({label:e,value:t,max:n,tone:r=`info`,className:i,...a},o){return(0,J.jsxs)(`div`,{...a,ref:o,className:B(`caps-game-meter`,i),children:[(0,J.jsxs)(`div`,{className:`caps-game-meter-readout`,children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsxs)(`span`,{className:`caps-game-meter-value`,children:[t,` / `,n]})]}),(0,J.jsx)(FA,{"aria-label":e,value:t,max:n,tone:r})]})});function IA({className:e,items:t,onCancel:n,onRemove:r,onRetry:i,rowClassName:a}){return t.length?(0,J.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,J.jsx)(zA,{item:e,onCancel:n,onRemove:r,onRetry:i,...a===void 0?{}:{rowClassName:a}},e.id))}):null}function LA({action:e,id:t,onAction:n,retry:r=!1}){return e?(0,J.jsx)(ht,{"aria-label":e.accessibleLabel,title:e.label,variant:`ghost`,size:`xs`,className:`motion-reduce:transition-none`,icon:r?(0,J.jsx)(Oi,{}):(0,J.jsx)(Hr,{}),onClick:()=>void n(t),type:`button`}):null}function RA({item:e}){return(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block min-w-0 truncate`,title:e.name,children:e.name}),(0,J.jsx)(`div`,{className:`caps-upload-details`,children:(0,J.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 zA({item:e,onCancel:t,onRemove:n,onRetry:r,rowClassName:i}){return(0,J.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,J.jsx)(`img`,{alt:``,className:`caps-upload-preview mask mask-squircle size-8 shrink-0 object-cover`,src:e.preview.url}):(0,J.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,J.jsx)(Tr,{className:`size-4`})}),(0,J.jsx)(RA,{item:e}),(0,J.jsx)(BA,{actions:e.actions,id:e.id,onCancel:t,onRemove:n,onRetry:r}),(0,J.jsx)(FA,{"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 BA({actions:e,id:t,onCancel:n,onRemove:r,onRetry:i}){return(0,J.jsxs)(`div`,{className:`caps-upload-actions flex min-w-0 flex-wrap justify-end gap-xs`,children:[(0,J.jsx)(LA,{action:e.retry,id:t,onAction:i,retry:!0}),(0,J.jsx)(LA,{action:e.cancel,id:t,onAction:n}),(0,J.jsx)(LA,{action:e.remove,id:t,onAction:r})]})}var VA=q.createContext(void 0);function HA(e){let t=q.useContext(VA);if(t===void 0&&!e)throw Error(Li(47));return t}var UA={...Ki,disabled:e=>e.disabled,instantType:e=>e.instantType===`trigger-change`&&!Ki.open(e)?void 0:e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,isPressOpenedByTrigger:(e,t)=>e.openChangeReason===`trigger-press`&&Ki.isOpenedByTrigger(e,t),isTouchPressOpen:(e,t)=>t&&e.openMethod===`touch`&&e.openChangeReason===`trigger-press`,hasTriggerFocusGuards:(e,t)=>Ki.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},WA=class extends Yi{constructor(e,t,n){let r=new da;super(GA(e,r,t,n),KA(r),UA)}setOpen=(e,t)=>{let n=t.reason===sa,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=pa(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=Ji(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}),Bh.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function GA(e,t,n,r=!1){let i={...Ui(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 KA(e){return{popupRef:q.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:q.createRef(),beforeTriggerFocusGuardRef:q.createRef(),beforeContentFocusGuardRef:q.createRef(),stickIfOpenTimeout:new Ma,stickIfOpen:!0,triggerElements:e}}var qA=ia(function({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=YA(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),ga(u,d),Ya(u);let{forceUnmount:m}=qi(d,u,()=>{u.context.stickIfOpen=!0,u.set(`openChangeReason`,null)});u.useSyncedValues({modal:o}),q.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),q.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,so(lo))}),[m,u]);let h=d||f||s!=null;return(0,J.jsxs)(VA.Provider,{value:u,children:[s&&(0,J.jsx)(ua,{handle:s,store:u}),h&&(0,J.jsx)(XA,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})});function JA(e){return HA(!0)?(0,J.jsx)(qA,{props:e}):(0,J.jsx)(ba,{children:(0,J.jsx)(qA,{props:e})})}function YA(e,t){let n=ma((e,n)=>new WA(t,e,n));return q.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function XA({store:e,modal:t}){let n=e.useState(`floatingRootContext`),r=to(n,{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),i=r.reference,a=r.floating;return ha(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:a}),null}var ZA=fo(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=HA(!0),h=na(s)??m;if(!h)throw Error(Li(74));let g=va(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=q.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=ra(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`isPressOpenedByTrigger`,g),T=h.useState(`isTouchPressOpen`,l),E=h.useState(`hasTriggerFocusGuards`,g),D=Zi(v,{enabled:!a&&l&&!T,mouseOnly:!0,move:!1,handleClose:Fa(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),O=Bi(()=>h.context.stickIfOpen),k=Wa(v,{stickIfOpen:O}),A=Vi(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:ee}=la({disabled:a,native:o}),N={open(e){return w?Ia.open(e):Qi.open(e)}},{handlePreFocusGuardFocus:P,handleFocusTargetFocus:te}=ka(h,x),ne=aa(`button`,e,{state:{disabled:a,open:y},ref:[ee,t,S,x],props:[k.reference,D,j,A,{[Ca]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,M],stateAttributesMapping:N}),F=(0,J.jsx)(q.Fragment,{children:ne},g);return E?(0,J.jsxs)(q.Fragment,{children:[(0,J.jsx)(ro,{ref:h.context.beforeTriggerFocusGuardRef,onFocus:P}),F,(0,J.jsx)(ro,{ref:h.context.triggerFocusTargetRef,onFocus:te})]}):F}),QA=q.createContext(void 0);function $A(){let e=q.useContext(QA);if(e===void 0)throw Error(Li(45));return e}var ej=q.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return HA().useState(`mounted`)||n?(0,J.jsx)(QA.Provider,{value:n,children:(0,J.jsx)($a,{ref:t,...r})}):null}),tj=q.createContext(void 0);function nj(){let e=q.useContext(tj);if(!e)throw Error(Li(46));return e}var rj=q.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=Ba,..._}=e,v=HA(),y=$A(),b=Ka(),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=xa({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}),ee=x.useState(`domReferenceElement`);uo({store:v,domReference:ee,positionerElement:O,open:C});let N=E===!0&&w!==`trigger-hover`;_a(C&&N,D===`touch`,O,T);let P=v.useStateSetter(`positionerElement`),te={open:C,side:M.side,align:M.align,anchorHidden:M.anchorHidden,instant:k},ne=io(e,te,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,P],hidden:!S,inert:!C});return(0,J.jsxs)(tj.Provider,{value:M,children:[S&&N&&(0,J.jsx)(ea,{inert:La(!C),cutout:T}),(0,J.jsx)(Pa,{id:b,children:ne})]})}),ij=q.createContext(void 0);function aj(){let[e,t]=q.useState(0),n=Bi(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:q.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var oj=q.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=HA(),l=nj(),u=Ri(!0)!=null,{context:d,hasClosePart:f}=aj(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);Ni({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),$i(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Wi(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M={open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ee=aa(`div`,e,{state:M,ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...Gi,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&Pi.has(e.key)&&e.stopPropagation()}},oa(g),s],stateAttributesMapping:Fi});return(0,J.jsx)(Za,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,getInsideElements:()=>[c.context.beforeTriggerFocusGuardRef.current],previousFocusableElement:ta(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,J.jsx)(ij.Provider,{value:d,children:ee})})}),sj=(0,q.forwardRef)(function({children:e,className:t,type:n=`button`,...r},i){return(0,J.jsxs)(`button`,{...r,ref:i,type:n,className:B(`select caps-select caps-combobox-trigger w-full`,t),children:[(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(Jn,{className:`caps-select-chevron`,"aria-hidden":`true`})]})});function cj({defaultOpen:e,defaultValue:t,getKey:n,getSearchText:r,groupBy:i,id:a,isDisabled:o,items:s,onOpenChange:c,onCommit:l,multiple:u,controlledOpen:d,controlledKeys:f,trigger:p}){let m=`${a}-listbox`,[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(t),[x,S]=(0,q.useState)(e),C=f??(y===null?[]:[y]),w=p?d??x:!0,T=(0,q.useMemo)(()=>{let e=h.trim().toLowerCase();return e?s.filter(t=>r(t).toLowerCase().includes(e)):s},[r,s,h]),E=xA({getKey:n,isDisabled:o,items:T});(0,q.useEffect)(()=>{if(E.activeKey!==null)return;let e=E.enabledItems.find(e=>C.includes(n(e)))??E.enabledItems[0];e&&E.setActiveKey(n(e))},[E.activeKey,E.enabledItems,E.setActiveKey,n,C]);let D=e=>{v(!1),e||g(``),d===void 0&&S(e),c?.(e)},O=e=>`${m}-option-${encodeURIComponent(e)}`,k=e=>{let t=n(e);f===void 0&&b(t),l(e),p&&!u&&D(!1)},A=e=>{v(!0),g(e.target.value),E.setActiveKey(null)},j=e=>{if(Qk(e))return;let t;switch(e.key){case`ArrowDown`:t=[1,void 0];break;case`ArrowUp`:t=[-1,void 0];break;case`End`:t=[1,`end`];break;case`Home`:t=[-1,`start`]}t?(v(!0),e.preventDefault(),E.move(t[0],t[1])):e.key===`Enter`&&E.activeItem&&(e.preventDefault(),k(E.activeItem))},M=(0,q.useMemo)(()=>{if(!i)return[{label:``,items:T}];let e=new Map;for(let t of T){let n=i(t),r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e].map(([e,t])=>({label:e,items:t}))},[T,i]);return{keyboardNavigation:_,onPointerMove:()=>{v(!1)},activeKey:E.activeKey,activeItem:E.activeItem,groups:M,inputValue:h,listboxId:m,onInputChange:A,onInputKeyDown:j,optionId:O,open:w,commit:k,selectedKeys:C,setOpen:D}}function lj(e){let{"aria-describedby":t,"aria-invalid":n,"aria-label":r,"aria-labelledby":i,"aria-required":a,activeTone:o=`neutral`,container:s,contentClassName:c,defaultOpen:l=!1,defaultValue:u=null,emptyMessage:d=`No matches`,getKey:f,getLabel:p,getSearchText:m=p,groupBy:h,id:g,inputProps:_,inputRef:v,isDisabled:y=()=>!1,items:b,onOpenChange:x,onValueChange:S,multiple:C,open:w,placeholder:T=`Search…`,renderItem:E,rootRef:D,trigger:O,triggerRef:k,value:A,...j}=e,M=e=>{let t=f(e);if(C){let e=A.includes(t)?A.filter(e=>e!==t):[...A,t];S?.(e,b.filter(t=>e.includes(f(t))))}else S?.(t,e)},ee;C?ee=A:A!==void 0&&(ee=A===null?[]:[A]);let N=(0,q.useId)(),P=O?.props??_,te=g??P?.id??N,ne={id:te,"aria-describedby":[t,P?.[`aria-describedby`]].filter(Boolean).join(` `)||void 0,"aria-invalid":n??P?.[`aria-invalid`],"aria-label":P?.[`aria-label`]??r,"aria-labelledby":P?.[`aria-labelledby`]??i,"aria-required":a??P?.[`aria-required`]},{keyboardNavigation:F,onPointerMove:re,activeItem:ie,activeKey:I,commit:L,groups:ae,inputValue:oe,listboxId:se,onInputChange:ce,onInputKeyDown:le,open:R,optionId:ue,selectedKeys:de,setOpen:fe}=cj({defaultOpen:l,defaultValue:u,getKey:f,getSearchText:m,groupBy:h,id:te,isDisabled:y,items:b,onOpenChange:x,onCommit:M,multiple:C??!1,controlledOpen:w,controlledKeys:ee,trigger:O});oo(()=>{O&&fe(!1)});let pe=ca(`popover`),z=s===void 0?pe:s,V=ja(`.caps-combobox-option[data-active="true"]:not(:disabled), [data-navigation="pointer"] .caps-combobox-option:hover:not(:disabled)`),me=(0,J.jsx)(ey,{..._,...O?{}:ne,"aria-activedescendant":ie?ue(f(ie)):void 0,"aria-autocomplete":`list`,"aria-controls":se,"aria-expanded":!0,className:B(`input-sm`,_?.className),id:O?_?.id??`${te}-input`:te,onChange:e=>{_?.onChange?.(e),ce(e)},onKeyDown:e=>{_?.onKeyDown?.(e),e.defaultPrevented||le(e)},placeholder:_?.placeholder??T,ref:v,role:`combobox`,value:oe}),he=(0,J.jsx)(`div`,{id:se,ref:V,className:`caps-combobox-list`,"data-navigation":F?`keyboard`:`pointer`,onPointerMove:re,role:`listbox`,"aria-multiselectable":C??void 0,children:ae.every(e=>e.items.length===0)?(0,J.jsx)(`div`,{className:`px-md py-md text-sm text-base-content`,children:d}):ae.map(e=>(0,J.jsxs)(`div`,{"aria-label":e.label||void 0,role:e.label?`group`:void 0,children:[e.label?(0,J.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=I===t,i={active:r,disabled:n,selected:de.includes(t)};return(0,J.jsxs)(`button`,{"aria-disabled":n||void 0,"aria-selected":i.selected,className:`caps-combobox-option`,"data-active":r&&F,disabled:n,id:ue(t),onClick:()=>{L(e)},onMouseDown:e=>{e.preventDefault()},role:`option`,tabIndex:-1,type:`button`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`caps-combobox-check`,children:i.selected?(0,J.jsx)(hr,{}):null}),E?.(e,r,i)??p(e)]},t)})]},e.label))});return O?(0,J.jsx)(`div`,{...j,className:B(j.className),ref:D,children:(0,J.jsxs)(JA,{modal:!0,onOpenChange:fe,open:R,children:[(0,J.jsx)(ZA,{...ne,"aria-haspopup":`dialog`,className:`btn`,ref:k,render:O}),z===null?null:(0,J.jsx)(ej,{container:z,children:(0,J.jsx)(rj,{align:`start`,side:`bottom`,sideOffset:4,children:(0,J.jsxs)(oj,{"data-active-tone":o,className:B(`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,J.jsx)(`div`,{className:`caps-combobox-search`,children:me}),he]})})})]})}):(0,J.jsx)(`div`,{...j,className:B(j.className),ref:D,children:(0,J.jsxs)(`div`,{className:B(`caps-combobox-panel`,c),"data-active-tone":o,children:[(0,J.jsx)(`div`,{className:`caps-combobox-search`,children:me}),he]})})}function uj({icon:e,caption:t}){return(0,J.jsxs)(`span`,{className:`caps-icon-choice-mark`,"aria-hidden":`true`,children:[(0,J.jsx)(`span`,{className:`caps-icon-choice-art`,children:e}),t?(0,J.jsx)(`span`,{className:`caps-icon-choice-caption`,children:t}):null,(0,J.jsx)(`span`,{className:`caps-icon-choice-lamp`})]})}var dj=(0,q.forwardRef)(function({label:e,icon:t,caption:n,appearance:r,className:i,...a},o){return(0,J.jsx)(`label`,{className:`caps-icon-choice`,"data-appearance":r===`compact`?r:void 0,children:(0,J.jsx)(bA,{...a,appearance:r??`default`,"aria-label":e,className:B(`caps-icon-choice-input`,i),indicator:(0,J.jsx)(uj,{icon:t,caption:n}),ref:o})})}),fj=(0,q.forwardRef)(function({label:e,icon:t,hint:n,className:r,...i},a){let o=(0,q.useId)(),s=[i[`aria-describedby`],n?o:null].filter(Boolean).join(` `)||void 0;return(0,J.jsx)(`label`,{className:`caps-check-key`,children:(0,J.jsx)(bA,{...i,"aria-label":e,"aria-describedby":s,className:B(`caps-check-key-input`,r),indicator:(0,J.jsxs)(`span`,{className:`caps-check-key-face`,"aria-hidden":`true`,children:[t?(0,J.jsx)(`span`,{className:`caps-check-key-icon`,children:t}):null,(0,J.jsxs)(`span`,{className:`caps-check-key-copy`,children:[(0,J.jsx)(`span`,{className:`caps-check-key-label`,children:e}),n?(0,J.jsx)(`span`,{className:`caps-check-key-hint`,id:o,children:n}):null]}),(0,J.jsx)(`span`,{className:`caps-check-key-lamp`})]}),ref:a})})});function pj({className:e,...t}){return(0,J.jsx)(`div`,{...t,className:B(`caps-check-keys`,e)})}function mj({checked:e}){let t=`caps-radio-${(0,q.useId)().replaceAll(`:`,``)}`,n=(0,q.useRef)(null),r=(0,q.useRef)(e).current,i=(0,q.useRef)(e),a=(0,q.useRef)(null),o=ae(a),{reduced:s}=o;return(0,q.useLayoutEffect)(()=>{if(!n.current)return;let t=s||i.current===e;i.current=e;let r=e?4:0,a=Hn(o,{ease:`outCubic`,duration:75}),c=e?ni(o,{bounce:.65,duration:300}):Hn(o,{ease:`inCubic`,duration:100}),l=mo(n.current,t?{rx:r,ry:r,cy:6,duration:0}:{rx:[{to:e?3.5:4.15,...a},{to:r,...c}],ry:[{to:e?4.5:3.85,...a},{to:r,...c}],cy:[{to:e?5.85:6.1,...a},{to:6,...c}]});return()=>{l.cancel()}},[e,s,o]),(0,J.jsxs)(`svg`,{ref:a,className:`caps-radio-visual`,width:`24`,height:`24`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsx)(f,{id:`${t}-surface`,transform:`matrix(1 0 0 1 6 6)`}),(0,J.jsx)(H,{id:`${t}-shadow`}),(0,J.jsx)(Dn,{id:`${t}-inset`}),(0,J.jsx)(`clipPath`,{id:`${t}-well`,children:(0,J.jsx)(`circle`,{cx:`6`,cy:`6`,r:`5`})})]}),(0,J.jsx)(`circle`,{className:`caps-radio-track`,cx:`6`,cy:`6`,r:`5.5`,filter:`url(#${t}-inset)`}),(0,J.jsx)(`g`,{clipPath:`url(#${t}-well)`,children:(0,J.jsx)(`ellipse`,{ref:n,cx:`6`,cy:`6`,rx:r?4:0,ry:r?4:0,fill:`url(#${t}-surface)`,filter:`url(#${t}-shadow)`})})]})}var hj=(0,q.createContext)(null),gj=(0,q.forwardRef)(function({children:e,className:t,defaultValue:n,disabled:r=!1,name:i,onValueChange:a,orientation:o=`vertical`,value:s,...c},l){let u=(0,q.useId)(),d=(0,q.useRef)(null);(0,q.useImperativeHandle)(l,()=>{if(!d.current)throw Error(`RadioGroup is not mounted`);return d.current},[]);let f=i??`radio-group-${u}`,[p,m]=(0,q.useState)(n),h=s??p;return(0,q.useEffect)(()=>{let e=d.current?.form;if(!e||s!==void 0)return;let t=e=>{queueMicrotask(()=>{e.defaultPrevented||m(n)})};return e.addEventListener(`reset`,t),()=>{e.removeEventListener(`reset`,t)}},[s,n,c.form]),(0,J.jsx)(hj.Provider,{value:{disabled:r,name:f,onValueChange:e=>{s===void 0&&m(e),a?.(e)},value:h},children:(0,J.jsx)(`fieldset`,{...c,className:B(`flex gap-md`,o===`horizontal`?`flex-row flex-wrap`:`flex-col`,t),disabled:r,role:c.role??`radiogroup`,ref:d,children:e})})}),_j=(0,q.forwardRef)(function({className:e,indicator:t,onChange:n,onClick:r,value:i,...a},o){let s=(0,q.useContext)(hj);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,J.jsxs)(`span`,{className:`caps-radio`,"data-checked":c,"data-custom-indicator":t!==void 0||void 0,children:[(0,J.jsx)(`input`,{...a,"aria-checked":c,checked:c,className:B(`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,J.jsx)(mj,{checked:c}):t]})}),vj=(0,q.forwardRef)(function({description:e,id:t,meta:n,title:r,...i},a){let o=(0,q.useContext)(hj),s=(0,q.useId)(),c=t??s,l=o?.value===i.value,u=o?.disabled===!0||i.disabled===!0;return(0,J.jsxs)(`label`,{className:`caps-choice-card`,"data-checked":l,"data-disabled":u||void 0,htmlFor:c,children:[(0,J.jsx)(_j,{...i,"aria-describedby":e?`${c}-description`:void 0,"aria-labelledby":`${c}-title`,id:c,ref:a}),(0,J.jsxs)(`span`,{className:`caps-choice-card-copy`,children:[(0,J.jsx)(`span`,{className:`caps-choice-card-title`,id:`${c}-title`,children:r}),e?(0,J.jsx)(`span`,{className:`caps-choice-card-description`,id:`${c}-description`,children:e}):null]}),n?(0,J.jsx)(`span`,{className:`caps-choice-card-meta`,children:n}):null]})}),yj=(0,q.forwardRef)(function({label:e,icon:t,caption:n,art:r=`dim`,className:i,...a},o){return(0,J.jsx)(`label`,{className:`caps-icon-choice`,"data-art":r===`color`?r:void 0,children:(0,J.jsx)(_j,{...a,"aria-label":e,className:B(`caps-icon-choice-input`,i),indicator:(0,J.jsx)(uj,{icon:t,caption:n}),ref:o})})});(0,q.forwardRef)(function({label:e,color:t,className:n,...r},i){return(0,J.jsx)(`label`,{className:`caps-icon-choice`,"data-art":`color`,"data-swatch":``,title:e,children:(0,J.jsx)(_j,{...r,"aria-label":e,className:B(`caps-icon-choice-input`,n),indicator:(0,J.jsx)(uj,{icon:(0,J.jsx)(`span`,{className:`caps-swatch-dot`,style:{backgroundColor:t}})}),ref:i})})});var bj=w(b),xj=w(_t),Sj=w(p(Ue)),Cj=w(St(b)),wj=St(In(File)),Tj=w(wj),Ej=At([b,Ue,_t,be,Nt,St(b),wj]),Dj=w(Ej),Oj=e=>vt(bj(e.state.value),()=>``),kj=e=>vt(xj(e.state.value),()=>!1),Aj=e=>vt(Sj(e.state.value),()=>null),jj=e=>vt(Cj(e.state.value),()=>[]),Mj=e=>vt(Tj(e.state.value),()=>[]),Nj=e=>vt(Dj(e.state.value),()=>null);function Pj({field:e,spec:t,locked:n,...r}){let[i,a]=(0,q.useState)(!1);return(0,J.jsxs)(ny,{children:[(0,J.jsx)(ey,{...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:Oj(e),onBlur:e.handleBlur,onChange:t=>{e.handleChange(t.currentTarget.value)}}),(0,J.jsx)(W,{type:`button`,variant:`outline`,size:`icon`,"aria-label":i?`Hide`:`Show`,"aria-pressed":i,disabled:n,onClick:()=>{a(e=>!e)},children:i?(0,J.jsx)(oh,{"aria-hidden":`true`}):(0,J.jsx)(sh,{"aria-hidden":`true`})})]})}var Fj={text:`text`,email:`email`,url:`url`,tel:`tel`};function Ij({spec:e,field:t,locked:n,...r}){let i=Mj(t),a=n||e.readOnly===!0,o=(0,q.useRef)(null);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,J.jsx)(Ce,{asChild:!0,children:(0,J.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,J.jsx)(W,{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,J.jsx)(IA,{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 Lj({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,J.jsx)(ey,{...a,type:Fj[e.kind],inputMode:e.kind===`text`?void 0:e.kind,autoComplete:e.autoComplete,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:Oj(t),onChange:e=>{i(e.currentTarget.value)}});case`textarea`:return(0,J.jsx)(fA,{...a,rows:e.rows??3,placeholder:e.placeholder,maxLength:e.maxLength,readOnly:e.readOnly,value:Oj(t),onChange:e=>{i(e.currentTarget.value)}});case`secret`:return(0,J.jsx)(Pj,{...r,field:t,spec:e,locked:n});case`money`:return(0,J.jsxs)(ny,{children:[(0,J.jsx)(ry,{className:`caps-field-currency`,children:e.currency??`USD`}),(0,J.jsx)(ey,{...a,inputMode:`decimal`,autoComplete:`off`,className:`caps-field-amount`,placeholder:e.placeholder??`0.00`,readOnly:e.readOnly,value:Oj(t),onChange:e=>{i(e.currentTarget.value)}})]});case`date`:return(0,J.jsx)(ey,{...a,type:`date`,readOnly:e.readOnly,value:Oj(t),onChange:e=>{i(e.currentTarget.value)}});case`number`:return(0,J.jsx)(vy,{...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:Aj(t),onValueChange:e=>{t.handleChange(e)}});case`select`:return(0,J.jsxs)(yy,{...a,value:Oj(t),onChange:e=>{i(e.currentTarget.value)},children:[e.placeholder===void 0?null:(0,J.jsx)(`option`,{value:``,disabled:!0,children:e.placeholder}),e.options.map(e=>(0,J.jsx)(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]});case`combobox`:return(0,J.jsx)(lj,{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:Oj(t),...e.placeholder===void 0?{}:{placeholder:e.placeholder},trigger:(0,J.jsx)(sj,{name:e.name,disabled:n||e.readOnly===!0,onBlur:t.handleBlur,children:e.options.find(e=>e.value===Oj(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,J.jsx)(Ij,{...r,spec:e,field:t,locked:n});case`checkbox`:return(0,J.jsx)(bA,{...a,disabled:n||e.readOnly===!0,checked:kj(t),onChange:e=>{t.handleChange(e.currentTarget.checked)}});case`switch`:return(0,J.jsx)(zr,{...a,disabled:n||e.readOnly===!0,checked:kj(t),onCheckedChange:e=>{t.handleChange(e)}});case`radio`:case`icon-radio`:case`checkboxes`:case`icon-checkboxes`:return null}}var Rj=new Set([`radio`,`icon-radio`,`checkboxes`,`icon-checkboxes`]);function zj({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=jj(t),s=(e,r)=>{t.handleChange(r?[...n,e]:n.filter(t=>t!==e))};return(0,J.jsx)(dy,{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,J.jsx)(`div`,{className:`caps-field-icon-choices`,children:e.options.map(r=>(0,J.jsx)(dj,{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,J.jsx)(pj,{children:e.options.map(r=>(0,J.jsx)(fj,{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,J.jsx)(dy,{legend:o,icon:e.icon,layout:i,...i===`columns`?{legendTitle:o}:{},description:e.help,disabled:a,error:r??null,children:(0,J.jsx)(gj,{name:e.name,"aria-label":o,value:Oj(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,J.jsx)(yj,{value:t.value,label:t.label,...t.caption===void 0?{}:{caption:t.caption},icon:t.icon,disabled:t.disabled},t.value):s?(0,J.jsx)(vj,{value:t.value,title:t.label,description:t.description,meta:t.meta,disabled:t.disabled},t.value):(0,J.jsx)(py,{label:t.label,orientation:`inline`,children:(0,J.jsx)(_j,{value:t.value,disabled:t.disabled})},t.value))})})}function Bj({spec:e,field:t,locked:n,error:r,render:i,...a}){return i({name:e.name,label:e.label,help:e.help,value:Nj(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 Vj({form:e,spec:t,locked:n,layout:r}){let i=Gv({form:e,name:t.name}),a=Uv(e.store,e=>e.submissionAttempts>0),o=i.state.meta.isBlurred||a?NA(i.state.meta):void 0;if(t.render===void 0&&Rj.has(t.kind))return(0,J.jsx)(zj,{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,J.jsx)(py,{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,J.jsx)(Lj,{spec:t,field:i,locked:n}):(0,J.jsx)(Bj,{spec:t,field:i,locked:n,error:o,render:t.render})})}var Hj=w(we(b,Ej));function Uj({form:e,spec:t,locked:n,layout:r}){let i=t.when;return Uv(e.store,e=>i===void 0||i(vt(Hj(e.values),()=>({}))))?(0,J.jsx)(Vj,{form:e,spec:t,locked:n,layout:r}):null}function Wj({form:e,section:t,locked:n,layout:r}){let i=t.fields.map(t=>(0,J.jsx)(Uj,{form:e,spec:t,locked:n,layout:r},t.name));return t.title===void 0?i:(0,J.jsx)(uy,{title:t.title,description:t.description,layout:r,children:i})}function Gj({model:e,names:t,disabled:n=!1,layout:r}){let i=e.form;return t===void 0?e.description.sections.map(e=>(0,J.jsx)(Wj,{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,J.jsx)(Uj,{form:i,spec:a,locked:n,layout:r},t)})}var Kj=class{annotation;constructor(e){this.annotation=e}},qj=class{sections;constructor(e){this.sections=e}},Jj=`caps/form`,Yj=0;function Xj(e){Yj+=1;let t={[`${Jj}:${String(Yj)}`]:new Kj(e)};return e.label!==void 0&&(t.title=e.label),e.help!==void 0&&(t.description=e.help),t}b.annotate(Xj({kind:`secret`})).pipe(oe(`Secret`));var Zj=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 Qj(e){return Object.values(e??{}).reduce((e,t)=>t instanceof Kj?{...e,...t.annotation}:e,{})}function $j(e){return e.reduce((e,t)=>({...e,...Qj(t)}),{})}function eM(e){let t=e?.[Jj];return t instanceof qj?t.sections:{}}var tM=w(b);function nM(e){if(fn(e))return kn(tM(e.literal),{onNone:()=>null,onSome:e=>[e]});if(!ln(e))return null;let t=[];for(let n of e.types){if(Yt(n))continue;let e=nM(n);if(e===null)return null;t.push(...e)}return t}function rM(e){if(Je(e))return{type:`string`,literals:[]};if(on(e))return{type:`number`,nullable:!1};if(ut(e))return{type:`boolean`};let t=nM(e);if(t!==null)return{type:`string`,literals:t};if(r(e)){let[t]=e.rest;if(t===void 0)return null;if(Je(t))return{type:`strings`,literals:[]};let n=nM(t);return n===null?null:{type:`strings`,literals:n}}if(ln(e)){let t=e.types.filter(e=>!Yt(e)&&!Kt(e)),n=e.types.some(e=>Kt(e)),[r]=t;if(t.length!==1||r===void 0)return null;let i=rM(r);return i?.type===`number`?{type:`number`,nullable:n}:n?null:i}return null}function iM(e){let t=e.ast;if(!Dt(t))throw Error(`A schema form needs a Schema.Struct.`);return{fields:t.propertySignatures.map(e=>{let t=String(e.name),n=st(e.type),r=$j([e.type.annotations,...(e.type.checks??[]).map(e=>e.annotations)]),i=r.kind===`file`?{type:`files`}:rM(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:_n(e.type),description:Rt(e.type)}}),sections:eM(nt(t))}}function aM(e){let t=e,n=!1,r=!1;for(;;)if(t instanceof L)n=!0,t=t.unwrap();else if(t instanceof me)r=!0,t=t.unwrap();else if(t instanceof jt)t=t.unwrap();else if(t instanceof ye)t=t.in;else return{node:t,optional:n,nullable:r}}function oM(e){if(e instanceof Ae){let t=e.options.map(e=>oM(e));return t.some(e=>e===null)?null:t.flatMap(e=>e??[])}let t=e instanceof se?e.options:e instanceof ue?[...e.values]:null;if(t===null)return null;let n=t.map(e=>tM(e));return n.every(Nn)?n.map(e=>e.value):null}function sM(e){let{node:t,nullable:n}=aM(e);if(t instanceof Ln)return{type:`string`,literals:[]};if(t instanceof T)return{type:`number`,nullable:n};if(t instanceof s)return{type:`boolean`};let r=oM(t);if(r!==null)return{type:`string`,literals:r};if(t instanceof Pt){let e=aM(t.element).node;if(e instanceof Ln)return{type:`strings`,literals:[]};let n=oM(e);return n===null?null:{type:`strings`,literals:n}}return null}function cM(e){let t=[e];for(;;){let e=t[t.length-1];if(e===void 0)break;let n=e instanceof L||e instanceof me||e instanceof jt?e.unwrap():e instanceof ye?e.in:e;if(n===e)break;t.push(n)}return t.reverse().map(e=>qe.get(e))}function lM(e){return cM(e).reduce((e,t)=>({...e,...t}),{})}function uM(e){return Object.entries(e.shape)}function dM(e){let t=aM(e).node;if(!(t instanceof ee))throw Error(`A schema form needs a z.object.`);return{fields:uM(t).map(([e,t])=>{let n=$j(cM(t)),r=n.kind===`file`?{type:`files`}:sM(t);if(r===null)throw Error(`Schema field "${e}" has no form control. Annotate it with field({ render }) or a kind.`);let i=lM(t);return{name:e,valueType:r,optional:aM(t).optional,annotation:n,title:i.title,description:i.description}}),sections:eM(lM(e))}}function fM(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??Zj(e),description:r.description,meta:r.meta,icon:r.icon,caption:r.caption,disabled:r.disabled===!0}})}function pM(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 mM(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 hM(e){let t=e instanceof d?dM(e):iM(e),n=t.fields.map((e,t)=>{let{kind:n,...r}=e.annotation,i=fM(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??Zj(e.name),help:a,kind:n??pM(e.valueType,i),options:i,optionalInSchema:e.optional,index:t}}),r={};t.fields.forEach((e,t)=>{let i=n[t];i&&(r[e.name]=mM(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 gM(e){let t=e instanceof d?e:ge(e);return{"~standard":{...t[`~standard`],validate:e=>{let n=t[`~standard`].validate(e);return n instanceof Promise?n.then(e=>_M(e)):_M(n)}}}}function _M(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 vM=`onServer`;function yM(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 bM(e){if(yM(e))return()=>void 0;let t=new MutationObserver(()=>{yM(e)&&t.disconnect()});return t.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`aria-invalid`]}),()=>{t.disconnect()}}function xM(e){return e.state.meta.errorMap.onServer!==void 0}function SM(e){e.setMeta(e=>({...e,errorMap:{...e.errorMap,[vM]:void 0}}))}function CM(e,t,n){e.setFieldMeta(t,e=>({...e,isBlurred:!0,errorMap:{...e.errorMap,[vM]:n}}))}function wM(e){let[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(e.defaultValues),[s,c]=(0,q.useState)(null);cv(a,e.defaultValues)||(o(e.defaultValues),c(null));let{schema:l}=e,u=(0,q.useMemo)(()=>hM(l),[l]),d=(0,q.useMemo)(()=>gM(l),[l]),f=$v({defaultValues:s??a,validators:{onChange:d,onSubmit:d},listeners:{onChange:({fieldApi:e})=>{n(null),i(null),xM(e)&&SM(e)}},onSubmit:async({value:t,formApi:r})=>{n(null),i(null);let a=await gM(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&&CM(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 TM(e){return{dirty:Uv(e.form.store,e=>!e.isDefaultValue),submitting:Uv(e.form.store,e=>e.isSubmitting),canSubmit:Uv(e.form.store,e=>e.canSubmit)}}function EM({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}=TM(e),f=(0,q.useRef)(null),p=(0,q.useRef)(()=>void 0);return(0,q.useEffect)(()=>()=>{p.current()},[]),(0,J.jsxs)(cy,{...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=bM(t))})},children:[c??(0,J.jsx)(Gj,{model:e,disabled:l,layout:o}),s===void 0?(0,J.jsx)(kM,{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 DM({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i,...a}){let o=wM({schema:e,defaultValues:t,onSubmit:n,onSaved:r,failure:i});return(0,J.jsx)(EM,{...a,model:o})}function OM(e){return`model`in e?(0,J.jsx)(EM,{...e}):(0,J.jsx)(DM,{...e})}function kM({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}=TM(e),d=u?null:e.saved&&!l?(0,J.jsx)(em,{tone:`success`,size:`compact`,label:e.saved}):l?(0,J.jsx)(em,{tone:`neutral`,size:`compact`,label:o}):null;return(0,J.jsxs)(sy,{...c,error:e.error,status:d,children:[r?(0,J.jsx)(W,{type:`button`,variant:`ghost`,disabled:u,onClick:r,children:i}):n&&l?(0,J.jsx)(W,{type:`button`,variant:`ghost`,disabled:u,onClick:e.discard,children:n}):null,(0,J.jsx)(W,{...s,type:`submit`,loading:u,disabled:u||!l&&!a,title:!l&&!a?`No changes to save`:void 0,children:t})]})}var AM={error:0,warning:1,info:2};function jM(e,t){let n=t.generating+t.uploading>0;if(n)return{busy:n,tone:void 0,label:[t.generating?`Creating ${String(t.generating)}`:``,t.uploading?`Uploading ${String(t.uploading)}`:``].filter(Boolean).join(` · `)};let r=[...e].sort((e,t)=>Number(t.blocking??!1)-Number(e.blocking??!1)||AM[e.tone]-AM[t.tone]).at(0);return r?{busy:n,tone:r.tone===`info`?`neutral`:r.tone,label:r.short+(e.length>1?` +${String(e.length-1)}`:``)}:null}function MM(e,t,n){let r=jM(e,t);if(!r)return null;let i={kind:`button`,id:`activity`,text:`Activity`,count:e.length+t.generating+t.uploading,busy:r.busy,title:v(`Activity: ${r.label}`,1024),opens:`dialog`,expanded:n};return r.tone===void 0?i:{...i,tone:r.tone}}var NM={Setup:(0,J.jsx)(xh,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Images:(0,J.jsx)(dh,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),Uploads:(0,J.jsx)(Ch,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`})};function PM({notices:e,uploads:t,open:n,inset:r,onOpenChange:i,onDismiss:a,onDismissAll:o,onLoadMore:s}){return(0,J.jsx)(cA,{className:`prints-activity-tray`,placement:`host`,align:`start`,...r===void 0?{}:{hostInset:r},items:[{id:`activity`,label:`Activity`,title:`Activity`,content:(0,J.jsx)(FM,{notices:e,uploads:t,onDismiss:a,onDismissAll:o,onLoadMore:s})}],openId:n?`activity`:null,onOpenChange:e=>{i(e===`activity`)}})}function FM({notices:e,uploads:t,onDismiss:n,onDismissAll:r,onLoadMore:i}){let a=[`Setup`,`Images`,`Uploads`].map(t=>({group:t,items:e.filter(e=>e.group===t)})).filter(e=>e.items.length);return(0,J.jsxs)(`div`,{className:`prints-instrument`,children:[a.map(({group:e,items:t})=>(0,J.jsxs)(`section`,{"aria-label":e,className:`prints-notice-group`,children:[(0,J.jsx)(hi,{level:3,children:e}),(0,J.jsx)(lA,{children:t.map(e=>(0,J.jsx)(uA,{icon:NM[e.group],primary:(0,J.jsxs)(`span`,{className:`prints-notice-copy`,children:[(0,J.jsx)(`span`,{children:e.title}),e.detail?(0,J.jsx)(`span`,{className:`prints-notice-detail`,children:e.detail}):null]}),actions:(0,J.jsxs)(`div`,{className:`prints-notice-actions`,"aria-label":`Actions for ${e.title}`,children:[e.actions?.map((e,t)=>(0,J.jsx)(W,{variant:t===0?`outline`:`ghost`,size:t===0?`sm`:`xs`,onClick:e.run,children:e.label},e.label)),e.blocking?null:(0,J.jsx)(ht,{"aria-label":`Dismiss ${e.title}`,icon:(0,J.jsx)(Hr,{"aria-hidden":`true`}),onClick:()=>{n(e.key)}})]})},e.key))})]},e)),e.length?null:(0,J.jsx)(dA,{children:`All caught up.`}),t&&t.items.length>0?(0,J.jsxs)(`section`,{"aria-label":`Upload queue`,className:`prints-upload-bank`,children:[(0,J.jsx)(hi,{level:3,children:`Uploading`}),(0,J.jsx)(IA,{...t})]}):null,(0,J.jsxs)(`div`,{className:`prints-panel-footer`,children:[(0,J.jsx)(`span`,{className:`prints-footer-note`,children:`Clear dismisses finished items`}),(0,J.jsx)(W,{variant:`ghost`,size:`xs`,disabled:!e.some(e=>!e.blocking),onClick:r,children:`Clear`}),i?(0,J.jsx)(W,{variant:`ghost`,size:`xs`,onClick:i,children:`Load more activity`}):null]})]})}function IM({folder:e}){return(0,J.jsx)(Fp,{open:e.editing,onOpenChange:e.setEditing,children:(0,J.jsxs)(Bp,{children:[(0,J.jsx)(Hp,{children:(0,J.jsx)(Up,{children:`Save prints to`})}),(0,J.jsx)(RM,{folder:e},e.computerId),(0,J.jsx)(Vp,{children:(0,J.jsx)(Wp,{render:(0,J.jsx)(W,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var LM=g({path:fe.check(P(u(Ai),{message:`Enter an absolute Computer folder, such as /media.`})).annotate(Xj({label:`Folder`,placeholder:`/media`}))});function RM({folder:e}){let t=(0,q.useRef)(!1),n=wM({schema:LM,defaultValues:{path:e.path??`/media`},onSubmit:async({path:n})=>{let r=await e.choose(n,t.current);return r?{kind:`refused`,fields:{path:r}}:{kind:`saved`}}}),r=e=>{t.current=e,n.form.setFieldMeta(`path`,e=>({...e,errorMap:{...e.errorMap,onServer:void 0}}))},i=e.busy||!e.writable;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(OM,{model:n,disabled:i,footer:(0,J.jsxs)(sy,{divider:!1,children:[(0,J.jsx)(bt,{className:`[--caps-keycap-width:auto]`,label:`Use`,type:`submit`,disabled:i,onClick:()=>{r(!1)}}),(0,J.jsx)(bt,{className:`[--caps-keycap-width:auto]`,label:`Create`,type:`submit`,disabled:i,onClick:()=>{r(!0)}})]})}),e.error?(0,J.jsx)(uA,{role:`alert`,icon:(0,J.jsx)(uh,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),primary:e.error}):(0,J.jsx)(dA,{children:e.writable?`Prints saves new images and uploads here and shows this folder as your gallery.`:`This Computer is read-only for Prints, so the folder can’t change.`})]})}var zM={image:`Image`,video:`Video`,audio:`Audio`,media:`Media`};function BM({connected:e,mediaCapability:t,modelsError:n,retryModels:r,modelsLoading:i,models:a,canGenerate:o,mediaSetupMissing:s,canWrite:c,generationError:l,recoveryError:u,pendingGenerations:d,activeGenerations:f,gallerySlots:p,computerId:m,failed:h,uploadError:g,uploads:_,permissions:v,resume:y,discard:b,retryUpload:x}){let S=[];if(e)m===null?S.push({key:`no-computer`,group:`Setup`,tone:`info`,blocking:!0,short:`Choose a Computer`,title:`No Computer selected`,detail:`Choose a Computer for this window, or create one in Grove.`}):t?n===null?!i&&!o&&!s&&S.push({key:`approval`,group:`Setup`,tone:`warning`,blocking:!0,short:`Generation not enabled`,title:`Media generation isn’t enabled`,detail:`Turn it on in this App’s Team permissions. Images already generated can still be saved.`,actions:[{label:`Permissions`,run:()=>{v()}}]}):S.push({key:`models:${n}`,group:`Setup`,tone:`warning`,blocking:!0,short:`Models unavailable`,title:`Couldn’t load image models`,detail:n,actions:[{label:`Retry`,run:r}]}):S.push({key:`no-media`,group:`Setup`,tone:`info`,blocking:!0,short:`Image creation off`,title:`Image creation is off for this Computer`,detail:`You can still browse and upload images.`});else{let e=Ht(new G(`Prints disconnected`,{code:`DISCONNECTED`,retryable:!0}));S.push({key:`disconnected`,group:`Setup`,tone:`warning`,blocking:!0,short:e.title,title:e.title,detail:e.message})}if(e&&m!==null&&!c&&S.push({key:`read-only`,group:`Setup`,tone:`info`,blocking:!0,short:`Read-only`,title:`Read-only Computer`,detail:`Uploads and new prints are off.`}),l!==null){let e=`${zM[l.mediaKind??`media`]} failed`;S.push({key:l.key,group:`Images`,tone:`error`,short:e,title:`${e}: ${l.message}`,detail:l.prompt,blocking:l.dismiss!==void 0,actions:[...l.billing?[{label:`Open Billing`,run:l.billing}]:l.retry?[{label:`Retry`,run:l.retry}]:[],...l.dismiss?[{label:`Dismiss`,run:l.dismiss}]:[]]})}u!==null&&S.push({key:`recovery:${u}`,group:`Images`,tone:`error`,short:`Retry blocked`,title:u});for(let e of d){if(f.has(e.reference.requestId)||p.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path))continue;let t=`${zM[Br(a,e.input.settings.model)?.kind??`media`]} failed`;S.push({key:`unfinished:${e.reference.requestId}`,group:`Images`,tone:`error`,blocking:!0,short:t,title:`${t}: ${e.failure?.message??`Stopped when Prints closed. Retry to run it again.`}`,detail:e.reference.computerId===m?e.typed.prompt:`${e.typed.prompt} · select the original Computer to retry`,actions:[...e.reference.computerId===m?[{label:`Retry`,run:()=>{y(e)}}]:[],{label:`Dismiss`,run:()=>{b(e)}}]})}h.length>0&&S.push({key:`files:${h.join(`|`)}`,group:`Images`,tone:`error`,short:`Couldn’t open images`,title:`Couldn’t open some images`,detail:h.join(`, `)}),g!==null&&S.push({key:`uploads:${g}`,group:`Uploads`,tone:`error`,short:`Upload failed`,title:`Couldn’t add images`,detail:g});for(let e of _)(e.status===`error`||e.status===`cancelled`)&&S.push({key:`upload:${e.id}:${e.status}`,group:`Uploads`,tone:e.status===`error`?`error`:`info`,short:`Upload failed`,title:`${e.file.name} wasn’t saved`,detail:e.message,actions:[{label:`Retry`,run:()=>{x(e.id)}}]});return S}function VM(e,t){let n=Or(Ur(e)),r=ce(xr({queryKey:xi.dismissals(e),mutationFn:({owner:e,id:t,keys:n})=>cr(e.capabilities,{operation:`dismiss-notices`,computerId:t,keys:n}),apply:(e,t)=>({keys:[...new Set([...e.keys,...t.keys])].slice(-200)})})),i=n=>{e&&t&&n.length>0&&r.mutate({owner:e,id:t,keys:n})};return{error:r.variables?.owner===e&&r.variables.id===t&&r.isError?`Could not dismiss activity. Please try again.`:n.isError?`Could not load dismissed activity. Notices may reappear.`:null,visible:e=>e.filter(e=>(e.blocking??!1)||!n.data?.keys.includes(e.key)),dismiss:e=>{i([e])},dismissAll:e=>{i(e.filter(e=>!e.blocking).map(e=>e.key).slice(-200))}}}var HM=0,UM=1,WM=2,GM=0,KM=1;function qM(e,t,n){let r=e.list,i;for(;r;){if(r.index===n)return!1;if(t>r.high)break;i=r,r=r.next}return i||(e.list={index:n,high:t,next:r}),i&&(i.next={index:n,high:t,next:i.next}),!0}function JM(e,t){let n=e.list;if(n.index===t)return n.next===null?GM:(e.list=n.next,KM);let r=n;for(n=n.next;n!==null;){if(n.index===t)return r.next=n.next,KM;r=n,n=n.next}}var YM={low:0,max:0,high:0,C:WM,P:void 0,R:void 0,L:void 0,list:void 0};YM.P=YM,YM.L=YM,YM.R=YM;function XM(e){let t=e.high;e.max=e.L===YM&&e.R===YM?t:e.L===YM?Math.max(e.R.max,t):e.R===YM?Math.max(e.L.max,t):Math.max(Math.max(e.L.max,e.R.max),t)}function ZM(e){let t=e;for(;t.P!==YM;)XM(t.P),t=t.P}function QM(e,t){if(t.R===YM)return;let n=t.R;t.R=n.L,n.L!==YM&&(n.L.P=t),n.P=t.P,t.P===YM?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.L=t,t.P=n,XM(t),XM(n)}function $M(e,t){if(t.L===YM)return;let n=t.L;t.L=n.R,n.R!==YM&&(n.R.P=t),n.P=t.P,t.P===YM?e.root=n:t===t.P.R?t.P.R=n:t.P.L=n,n.R=t,t.P=n,XM(t),XM(n)}function eN(e,t,n){t.P===YM?e.root=n:t===t.P.L?t.P.L=n:t.P.R=n,n.P=t.P}function tN(e,t){let n;for(;t!==YM&&t.C===UM;)t===t.P.L?(n=t.P.R,n.C===HM&&(n.C=UM,t.P.C=HM,QM(e,t.P),n=t.P.R),n.L.C===UM&&n.R.C===UM?(n.C=HM,t=t.P):(n.R.C===UM&&(n.L.C=UM,n.C=HM,$M(e,n),n=t.P.R),n.C=t.P.C,t.P.C=UM,n.R.C=UM,QM(e,t.P),t=e.root)):(n=t.P.L,n.C===HM&&(n.C=UM,t.P.C=HM,$M(e,t.P),n=t.P.L),n.R.C===UM&&n.L.C===UM?(n.C=HM,t=t.P):(n.L.C===UM&&(n.R.C=UM,n.C=HM,QM(e,n),n=t.P.L),n.C=t.P.C,t.P.C=UM,n.L.C=UM,$M(e,t.P),t=e.root));t.C=UM}function nN(e){for(;e.L!==YM;)e=e.L;return e}function rN(e,t){let n;for(;t.P.C===HM;)t.P===t.P.P.L?(n=t.P.P.R,n.C===HM?(t.P.C=UM,n.C=UM,t.P.P.C=HM,t=t.P.P):(t===t.P.R&&(t=t.P,QM(e,t)),t.P.C=UM,t.P.P.C=HM,$M(e,t.P.P))):(n=t.P.P.L,n.C===HM?(t.P.C=UM,n.C=UM,t.P.P.C=HM,t=t.P.P):(t===t.P.L&&(t=t.P,$M(e,t)),t.P.C=UM,t.P.P.C=HM,QM(e,t.P.P)));e.root.C=UM}function iN(){let e={root:YM,size:0},t={};return{insert(n,r,i){let a=e.root,o=YM;for(;a!==YM&&(o=a,n!==o.low);)a=n<a.low?a.L:a.R;if(n===o.low&&o!==YM){if(!qM(o,r,i))return;o.high=Math.max(o.high,r),XM(o),ZM(o),t[i]=o,e.size++;return}let s={low:n,high:r,max:r,C:HM,P:o,L:YM,R:YM,list:{index:i,high:r,next:null}};o===YM?e.root=s:(s.low<o.low?o.L=s:o.R=s,ZM(s)),rN(e,s),t[i]=s,e.size++},remove(n){let r=t[n];if(r===void 0)return;delete t[n];let i=JM(r,n);if(i===void 0)return;if(i===KM){r.high=r.list.high,XM(r),ZM(r),e.size--;return}let a=r,o=a.C,s;r.L===YM?(s=r.R,eN(e,r,r.R)):r.R===YM?(s=r.L,eN(e,r,r.L)):(a=nN(r.R),o=a.C,s=a.R,a.P===r?s.P=a:(eN(e,a,a.R),a.R=r.R,a.R.P=a),eN(e,r,a),a.L=r.L,a.L.P=a,a.C=r.C),XM(s),ZM(s),o===UM&&tN(e,s),e.size--},search(t,n,r){let i=[e.root];for(;i.length!==0;){let e=i.pop();if(!(e===YM||t>e.max)&&(e.L!==YM&&i.push(e.L),e.R!==YM&&i.push(e.R),e.low<=n&&e.high>=t)){let n=e.list;for(;n!==null;)n.high>=t&&r(n.index,e.low),n=n.next}}},get size(){return e.size}}}var aN=e=>{let t=q.useRef(e);return q.useEffect(()=>{t.current=e}),t},oN=(e,t)=>{let n=t||sN,r,i;return function(){return r&&n(arguments,r)?i:i=e.apply(null,r=arguments)}},sN=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3],cN=class{constructor(){this.set=void 0,this.get=void 0;let e,t;this.get=n=>n===e?t:void 0,this.set=(n,r)=>{e=n,t=r}}},lN=e=>{try{return new e}catch{let e={};return{set(t,n){e[t]=n},get(t){return e[t]}}}},uN=e=>{let t=e.length,n=lN(e[0]),r,i,a,o,s=t===1;return t<3?{g:e=>(r=n.get(e[0]))===void 0||s?r:r.get(e[1]),s:(t,a)=>(s?n.set(t[0],a):(r=n.get(t[0]))===void 0?(i=lN(e[1]),i.set(t[1],a),n.set(t[0],i)):r.set(t[1],a),a)}:{g:e=>{for(o=n,a=0;a<t;a++)if((o=o.get(e[a]))===void 0)return;return o},s:(r,s)=>{for(o=n,a=0;a<t-1;a++)(i=o.get(r[a]))===void 0?(i=lN(e[a+1]),o.set(r[a],i),o=i):o=i;return o.set(r[t-1],s),s}}},dN=(e,t)=>{let n,{g:r,s:i}=uN(e);return function(){return(n=r(arguments))===void 0?i(arguments,t.apply(null,arguments)):n}},fN=new WeakMap;function pN(){let e=q.useState(mN)[1];return q.useRef(()=>e({})).current}var mN={},hN=q.createElement;function gN(e){let{positioner:t,resizeObserver:n,items:r,as:i=`div`,id:a,className:o,style:s,role:c=`grid`,tabIndex:l=0,containerRef:u,itemAs:d=`div`,itemStyle:f,itemHeightEstimate:p=300,itemKey:m=SN,overscanBy:h=2,scrollTop:g,isScrolling:_,height:v,render:y,onRender:b}=e,x=0,S,C=pN(),w=wN(t,n),T=r.length,{columnWidth:E,columnCount:D,range:O,estimateHeight:k,size:A,shortestColumn:j}=t,M=A(),ee=j(),N=[],P=c===`list`?`listitem`:c===`grid`?`gridcell`:void 0,te=aN(b);h=v*h;let ne=g+h,F=ee<ne&&M<T;if(O(Math.max(0,g-h/2),ne,(e,t,n)=>{let i=r[e],a=m(i,e),o={top:n,left:t,width:E,writingMode:`horizontal-tb`,position:`absolute`};N.push(hN(d,{key:a,ref:w(e),role:P,style:typeof f==`object`&&f?Object.assign({},o,f):o},vN(y,e,i,E))),S===void 0?(x=e,S=e):(x=Math.min(x,e),S=Math.max(S,e))}),F){let e=Math.min(T-M,Math.ceil((g+h-ee)/p*D)),t=M,n=CN(E);for(;t<M+e;t++){let e=r[t],i=m(e,t);N.push(hN(d,{key:i,ref:w(t),role:P,style:typeof f==`object`?Object.assign({},n,f):n},vN(y,t,e,E)))}}q.useEffect(()=>{typeof te.current==`function`&&S!==void 0&&te.current(x,S,r),_N=`1`},[x,S,r,te]),q.useEffect(()=>{F&&C()},[F,t]);let re=yN(_,k(T,p));return hN(i,{ref:u,key:_N,id:a,role:c,className:o,tabIndex:l,style:typeof s==`object`?xN(re,s):re,children:N})}var _N=`0`,vN=dN([cN,{},WeakMap,cN],(e,t,n,r)=>hN(e,{index:t,data:n,width:r})),yN=oN((e,t)=>({position:`relative`,width:`100%`,maxWidth:`100%`,height:Math.ceil(t),maxHeight:Math.ceil(t),willChange:e?`contents`:void 0,pointerEvents:e?`none`:void 0})),bN=(e,t)=>e[0]===t[0]&&e[1]===t[1],xN=oN((e,t)=>Object.assign({},e,t),bN);function SN(e,t){return t}var CN=oN(e=>({width:e,zIndex:-1e3,visibility:`hidden`,position:`absolute`,writingMode:`horizontal-tb`}),(e,t)=>e[0]===t[0]),wN=oN((e,t)=>n=>r=>{r!==null&&(t&&(t.observe(r),fN.set(r,n)),e.get(n)===void 0&&e.set(n,r.offsetHeight))},bN),TN=function(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=n);let i=iN(),a=Array(e),o=[],s=Array(e);for(let t=0;t<e;t++)a[t]=0,s[t]=[];return{columnCount:e,columnWidth:t,set:function(e,c){c===void 0&&(c=0);let l=0;for(let e=1;e<a.length;e++)a[e]<a[l]&&(l=e);let u=a[l]||0;a[l]=u+c+r,s[l].push(e),o[e]={left:l*(t+n),top:u,height:c,column:l},i.insert(u,u+c,e)},get:e=>o[e],update:t=>{let n=Array(e),c=0,l=0;for(;c<t.length-1;c++){let e=t[c],r=o[e];r.height=t[++c],i.remove(e),i.insert(r.top,r.top+r.height,e),n[r.column]=n[r.column]===void 0?e:Math.min(e,n[r.column])}for(c=0;c<n.length;c++){if(n[c]===void 0)continue;let e=s[c],t=EN(e,n[c]),u=s[c][t],d=o[u];for(a[c]=d.top+d.height+r,l=t+1;l<e.length;l++){let t=e[l],n=o[t];n.top=a[c],a[c]=n.top+n.height+r,i.remove(t),i.insert(n.top,n.top+n.height,t)}}},range:(e,t,n)=>i.search(e,t,(e,t)=>n(e,o[e].left,t)),estimateHeight:(t,n)=>{let r=Math.max(0,Math.max.apply(null,a));return t===i.size?r:r+Math.ceil((t-i.size)/e)*n},shortestColumn:()=>a.length>1?Math.min.apply(null,a):a[0]||0,size(){return i.size},all(){return o}}},EN=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1,a=e[i];if(a===t)return i;a<=t?n=i+1:r=i-1}return-1},DN=(0,q.createContext)(null);function ON(){let e=(0,q.useContext)(DN);if(e===null)throw Error(`An audio tile part must sit inside an AudioTileScope`);return e}function kN({url:e,children:t}){let n=Jg(e,it);return(0,J.jsx)(DN.Provider,{value:n,children:t})}function AN({url:e}){let{progress:t}=ON();return(0,J.jsx)(`span`,{className:`prints-audio-tile`,children:(0,J.jsx)(Yg,{progress:t,url:e})})}function jN({title:e}){let t=ON();return(0,J.jsx)(ht,{"aria-label":`${t.playing?`Pause`:`Play`} ${e}`,className:`prints-audio-tile-play`,icon:t.playing?(0,J.jsx)(_h,{}):(0,J.jsx)(yh,{}),iconSize:`sm`,size:`sm`,variant:`accent`,onClick:t.toggle})}var MN=8,NN=320,PN=4,FN=640,IN=656;function LN(e,t){return e<=0||!Number.isFinite(t)||t<=0?0:e===1?1:e<=PN?t<FN?1:e===2||t<IN?2:3:t>=1280?4:t>=IN?3:2}function RN({item:e}){return mn(e.path)?(0,J.jsx)(AN,{url:e.url}):Ua(e.path)?(0,J.jsx)(`video`,{"aria-label":e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,loop:!0,muted:!0,playsInline:!0,src:e.url}):(0,J.jsx)(`img`,{alt:e.path,className:`block h-full w-full object-cover`,"data-media-thumb":!0,src:e.url})}var zN=(0,q.memo)(function({item:e}){let t=(0,q.useRef)(null);(0,q.useEffect)(()=>{e.onVisible?.()},[e.onVisible]);let[n,r]=(0,q.useState)(e.pending===!0&&!e.onVisible);return e.pending&&!e.onVisible&&!n&&r(!0),(0,q.useLayoutEffect)(()=>{let r=t.current;if(!r||e.pending||n)return;let i=window.matchMedia(`(prefers-reduced-motion: reduce)`);if(i.matches)return;let a=!0,o,s,c=()=>o?.();return ji(async()=>{let{animate:e,spring:t}=await import(`./modules-C4mfDnjH.js`).then(e=>e.t);return{animate:e,spring:t}},__vite__mapDeps([3,1]),import.meta.url).then(({animate:e,spring:t})=>{if(!a)return;let n=e(r,{opacity:{from:0,to:1,duration:160,ease:`outQuad`},translateY:{from:6,to:0,ease:t({bounce:.16,duration:320})},scale:{from:.985,to:1,ease:t({bounce:.16,duration:320})}});o=()=>{n.complete()},s=()=>{n.revert()}}),i.addEventListener(`change`,c),()=>{a=!1,i.removeEventListener(`change`,c),s?.()}},[e.key,e.pending,n]),(0,J.jsxs)(`div`,{ref:t,className:`prints-gallery-tile`,"data-referenced":e.referenced?!0:void 0,children:[e.error?(0,J.jsx)(`div`,{className:`block h-full w-full overflow-hidden bg-base-200`,"data-media-failed":!0,title:e.path,children:(0,J.jsx)(rm,{status:`failed`,failure:(0,J.jsxs)(`div`,{className:`flex max-w-full flex-col items-center gap-xs`,children:[e.prompt?(0,J.jsx)(`p`,{className:`m-0 max-w-full truncate px-md text-xs text-(--stipe-fg-muted)`,children:e.prompt}):null,(0,J.jsx)(tm,{density:`tile`,message:e.error,onRetry:e.onRetry,onDismiss:e.onDismiss})]})})}):(0,J.jsx)(`button`,{className:`block h-full w-full overflow-hidden bg-base-200 p-0 text-left`,"data-media-thumb-wrap":!0,type:`button`,disabled:e.pending,"aria-pressed":e.select?.active?e.select.checked:void 0,onClick:()=>{e.select?.active?e.select.onToggle():e.onOpen(e.path)},onKeyDown:t=>{t.key.toLowerCase()===`i`&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&e.onInfo&&(t.preventDefault(),e.onInfo())},title:e.path,children:(0,J.jsx)(`div`,{className:`caps-item block! h-full w-full overflow-hidden rounded-none! border-0! bg-transparent! shadow-none! z-auto! -outline-offset-2!`,"data-selected":e.selected??!1,children:e.pending||n?(0,J.jsx)(rm,{"data-media-pending":e.pending?`true`:void 0,indicator:(0,J.jsx)(yn,{decorative:!0,size:`fill`,tone:`accent`,variant:`bloom`}),label:e.pendingLabel??`Preparing image…`,status:e.pending?`generating`:`done`,children:e.pending?null:(0,J.jsx)(RN,{item:e})}):(0,J.jsx)(RN,{item:e})})}),!e.pending&&!e.error?(0,J.jsx)(HN,{item:e}):null,(0,J.jsxs)(`div`,{className:`prints-gallery-tools`,children:[!e.pending&&!e.error?(0,J.jsx)(UN,{item:e}):null,!e.pending&&e.onInfo?(0,J.jsx)(ht,{"aria-label":`Image info: ${e.path}`,title:`Image info (I)`,"aria-keyshortcuts":`I`,onClick:e.onInfo,icon:(0,J.jsx)(fh,{})}):null,!e.pending&&e.onToggleReference?(0,J.jsx)(ht,{className:`prints-gallery-reference`,"aria-label":`${e.referenced?`Remove reference`:`Add reference`}: ${e.path}`,title:e.referenced?`Remove reference`:`Add reference`,"aria-pressed":e.referenced??!1,disabled:e.referenceDisabled,onClick:e.onToggleReference,icon:e.referenced?(0,J.jsx)(hr,{}):(0,J.jsx)(dh,{})}):null]})]})}),BN=(0,q.memo)(function({item:e}){return mn(e.path)?(0,J.jsx)(kN,{url:e.url,children:(0,J.jsx)(zN,{item:e})}):(0,J.jsx)(zN,{item:e})}),VN=e=>`${String(e)}s`;function HN({item:e}){let{select:t}=e;return(0,J.jsxs)(J.Fragment,{children:[mn(e.path)&&e.url!==``?(0,J.jsx)(jN,{title:e.path}):null,(0,J.jsx)(`div`,{className:`prints-tile-mark`,"data-checked":t?.active?t.checked:void 0,"data-favorite":e.favorite?!0:void 0,children:t?.active?(0,J.jsx)(bA,{appearance:`compact`,"aria-label":`Select ${e.path}`,checked:t.checked,onChange:t.onToggle}):e.onToggleFavorite?(0,J.jsx)(ht,{"aria-label":`${e.favorite?`Unfavorite`:`Favorite`}: ${e.path}`,"aria-pressed":e.favorite??!1,className:`prints-tile-heart`,icon:(0,J.jsx)(Kn,{fill:e.favorite?`currentColor`:`none`}),onClick:e.onToggleFavorite,title:e.favorite?`Remove from favorites`:`Favorite`}):null}),e.badge?(0,J.jsx)(`div`,{className:`prints-tile-badge`,"data-media-badge":!0,children:e.badge.label===null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ch,{"aria-hidden":!0,size:12}),(0,J.jsx)(`span`,{children:`Upload`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`prints-tile-badge-model`,children:e.badge.label}),e.badge.seconds===null?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Xn,{"aria-hidden":!0,size:12}),(0,J.jsx)(`span`,{children:VN(e.badge.seconds)})]})]})}):null,e.folderCaption?(0,J.jsx)(`div`,{className:`prints-tile-folder`,title:e.folderCaption,children:e.folderCaption}):null]})}function UN({item:e}){return!e.onMove||e.select?.active?null:(0,J.jsxs)(no,{children:[(0,J.jsx)(Va,{render:(0,J.jsx)(ht,{"aria-label":`More actions: ${e.path}`,title:`More actions`,icon:(0,J.jsx)(za,{})})}),(0,J.jsxs)(Da,{children:[(0,J.jsxs)(qa,{onSelect:e.onMove,children:[(0,J.jsx)(Ei,{"aria-hidden":!0,size:16}),` Move to…`]}),e.onToggleFavorite?(0,J.jsxs)(qa,{onSelect:e.onToggleFavorite,children:[(0,J.jsx)(Kn,{"aria-hidden":!0,size:16}),` `,e.favorite?`Remove from favorites`:`Favorite`]}):null,e.onInfo?(0,J.jsxs)(qa,{onSelect:e.onInfo,children:[(0,J.jsx)(fh,{"aria-hidden":!0,size:16}),` Image info`]}):null]})]})}var WN=(0,q.memo)(function({children:e,style:t,...n}){return(0,J.jsx)(`div`,{"data-media-grid":!0,...n,style:t,children:e})});function GN(e,t){let[n,r]=(0,q.useState)({height:0,width:0});return(0,q.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{r(e=>{let n={height:t.clientHeight,width:t.clientWidth};return n.width===e.width&&n.height===e.height?e:n})};n();let i=new ResizeObserver(n);return i.observe(t),window.addEventListener(`resize`,n),()=>{i.disconnect(),window.removeEventListener(`resize`,n)}},[e,t]),n}function KN(e){let[t,n]=(0,q.useState)(0),[r,i]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{let t=e.current;if(!t)return;let r=null,a=()=>{n(t.scrollTop),i(!0),r!==null&&clearTimeout(r),r=setTimeout(()=>{i(!1)},150)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{t.removeEventListener(`scroll`,a),r!==null&&clearTimeout(r)}},[e]),{isScrolling:r,scrollTop:t}}function qN(e,t){let n=t.height>0?t.width/t.height:1;return Math.round(e/n)}function JN(e,t,n,r){let i=Math.floor((t-(n-1)*MN)/n),a=e.length===1?e[0]:void 0;if(!a||r<=0)return i;let o=a.height>0?a.width/a.height:1;return Math.max(1,Math.min(i,Math.floor(r*o)))}function YN(e,t,n){let r=e.some(e=>e.select!==void 0),i=Math.max(1,LN(e.length,t),r&&e.length>=2?2:1),a=t-16,o=n-16;return(0,q.useMemo)(()=>{let t=JN(e,a,i,o),n=TN(i,t,MN);return t>0&&e.forEach((e,r)=>{n.set(r,qN(t,e))}),n},[e,a,i,o])}var XN=(0,q.memo)(function({data:e,width:t}){return(0,J.jsx)(`div`,{"data-media-tile":e.key,style:{height:qN(t,e),width:t},children:(0,J.jsx)(BN,{item:e})})});function ZN(e,t){let n=Array.from(e.querySelectorAll(`[data-media-tile]`)).find(e=>e.dataset.mediaTile===t)?.querySelector(`[data-media-thumb-wrap]`);return!n||n.disabled?!1:(n.focus({preventScroll:!0}),!0)}function QN(e,t,n){let r=e.ownerDocument;(r.activeElement!==r.body||ZN(e,t))&&n()}function $N(e,t,n){let r=n.top+t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;return(r<e.scrollTop||r+n.height>e.scrollTop+e.clientHeight)&&e.scrollTo({top:r,behavior:`instant`}),r}var eP=(0,q.memo)(function({items:e,scrollRef:t,focus:n}){let r=GN(t,e.length),i=r.width||NN,a=e.length===1&&r.height>0,o=i-16,s=r.height-16,c=YN(e,i,r.height),{isScrolling:l,scrollTop:u}=KN(t),d=(0,q.useRef)(new Set),f=(0,q.useRef)(null),p=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!n)return;let a=f.current===n.requestId;if(a&&p.current===i)return;let o=t.current,s=e.findIndex(e=>e.key===n.key),l=c.get(s);if(!o||!l||r.height===0)return;let u=o.querySelector(`[data-media-grid]`);if(!u)return;let d=$N(o,u,l);if(a){QN(o,n.key,()=>{p.current=i});return}ZN(o,n.key)?(f.current=n.requestId,p.current=i,n.onFocus()):o.scrollTo({top:d,behavior:`instant`})},[n,e,r.height,t,u,c,i]),(0,q.useEffect)(()=>{let n=t.current;if(!n||r.width===0||r.height===0)return;let i=e.findIndex(e=>e.pending&&!e.onVisible&&!d.current.has(e.key));if(d.current=new Set(e.map(e=>e.key)),i<0)return;let a=c.get(i),o=n.querySelector(`[data-media-grid]`);if(!a||!o)return;let s=o.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop+a.top,l=s+a.height;s>=n.scrollTop&&l<=n.scrollTop+n.clientHeight||n.scrollTo({top:Math.max(0,s-MN),behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`})},[e,r.width,r.height,t,c]);let m=(0,q.useCallback)(({data:e,width:t})=>(0,J.jsx)(XN,{data:e,width:t}),[]),h=gN({as:WN,height:r.height,isScrolling:l,itemKey:e=>e.key,items:e,overscanBy:2,positioner:c,render:m,scrollTop:u});return(0,J.jsx)(`div`,{"data-media-sole":a?``:void 0,style:{boxSizing:`border-box`,padding:MN,...a?{display:`flex`,alignItems:`center`,justifyContent:`center`,minHeight:r.height}:void 0},children:(0,J.jsx)(`div`,{style:{width:a?JN(e,o,1,s):`100%`},children:h})})});function tP({items:e,scrollRef:t,focus:n}){return(0,J.jsx)(`section`,{"data-media-mosaic":!0,children:(0,J.jsx)(eP,{items:e,scrollRef:t,focus:n})})}function nP(e,t,n){let r=new Map(e.map(e=>[e.key,e])),i=new Set(t.map(e=>e.key));return[...[...t].reverse().filter(e=>!e.resolved||r.has(e.key)).map(e=>{let t=r.get(e.key);return t&&e.resolved?t:n(e)}),...e.filter(e=>!i.has(e.key))]}var rP=`prints-prompt-counter`;function iP({busy:e,disabled:t,disabledReason:n,draft:r,label:i,onGenerate:a,promptOver:o}){return(0,J.jsx)(rA,{"aria-describedby":o?rP:void 0,"aria-label":i,className:`prints-generate`,"data-generation-submit":!0,disabled:t||o,onClick:a,state:TA({draft:r,busy:e}),title:t&&n?n:i})}function aP({caretRequest:e,disabled:t,maxLength:n,addedLength:r=0,menu:i,mentionCount:a,onCaret:o,onChange:s,onMentionDismiss:c,onMentionMove:l,onMentionPick:u,onSend:d,onSlashMove:f,onSlashPick:p,placeholder:m,slashCount:h,value:g}){let _=(0,q.useRef)(null),v=(0,q.useRef)(g),[y,b]=(0,q.useState)([]),[x,S]=(0,q.useState)(-1),[C,w]=(0,q.useState)(!1),T=(0,q.useRef)(!1),E=(0,q.useRef)(!1);v.current=g,(0,q.useLayoutEffect)(()=>{if(C||t||!E.current)return;E.current=!1;let e=_.current;e&&e.ownerDocument.activeElement===e.ownerDocument.body&&e.focus({preventScroll:!0})},[t,C]),(0,q.useLayoutEffect)(()=>{let t=_.current;!t||e?.value!==g||(t.setSelectionRange(e.caret,e.caret),t.focus({preventScroll:!0}))},[e,g]),DA(_,g);let D=(0,q.useCallback)(async()=>{let e=v.current.trim();if(!(!e||t||T.current)&&!(n!==void 0&&e.length+r>n)){E.current=_.current===_.current?.ownerDocument.activeElement,T.current=!0,w(!0);try{if(!await d())return;b(t=>t.at(-1)===e?t:[...t,e].slice(-20)),S(-1)}finally{T.current=!1,w(!1)}}},[t,n,d,r]),O=g.trim().length,k=O>0?O+r:0,A=n!==void 0&&k>n;return(0,J.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,J.jsx)(fA,{"aria-invalid":A?!0:void 0,"aria-label":`Prompt`,className:`w-full`,"data-generation-prompt":!0,...hA(i),disabled:t===!0||C,onChange:e=>{s(e.currentTarget.value),o(e.currentTarget.selectionStart),S(-1)},onSelect:e=>{o(e.currentTarget.selectionStart)},onKeyDown:e=>{if(Qk(e))return;let t=mA(e);if(a>0&&t!==null){e.preventDefault(),t===`next`?l(1):t===`previous`?l(-1):t===`accept`?u():c();return}if(g.startsWith(`/`)&&t!==null&&(h>0||t===`dismiss`||e.key===`Enter`)){if(e.preventDefault(),t===`dismiss`)s(g.slice(1));else if(h)t===`next`?f(1):t===`previous`?f(-1):p();else return;return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),D();return}if(e.key===`ArrowUp`&&_.current?.selectionStart===0&&y.length&&(x===-1||x>0)){e.preventDefault();let t=x===-1?y.length-1:x-1;S(t),s(y[t]);return}if(e.key===`ArrowDown`&&x!==-1){e.preventDefault();let t=x+1;t>=y.length?(S(-1),s(``)):(S(t),s(y[t]))}},placeholder:m,ref:_,rows:1,value:g}),n!==void 0&&k>0?(0,J.jsx)(`p`,{className:`px-3 pb-1 text-xs tabular-nums ${A?`text-error`:`text-dim`}`,"data-prompt-counter":!0,id:rP,role:A?`alert`:`status`,children:A?`${String(k)} / ${String(n)} characters. This model accepts up to ${String(n)}; shorten the prompt${r>0?` or its style and characters`:``} by ${String(k-n)} or pick another model.`:`${String(k)} / ${String(n)}`}):null]})}function oP({index:e,listId:t,matches:n,onHighlight:r,onPick:i}){return(0,J.jsx)(gA,{open:!0,rows:n.map(e=>({key:e.id,label:`/${e.slash}`,detail:e.description??e.title})),selected:e,listId:t,label:`Commands`,kind:`commands`,empty:`No matching commands`,onHighlight:r,onChoose:i})}function sP(e,t){let[n,r]=(0,q.useState)(0),i=t.startsWith(`/`),a=(0,q.useMemo)(()=>{if(!i)return[];let n=Xk(e.map((e,t)=>({alias:e.slash,commandId:e.id,command:e.command,title:e.title,description:e.description,category:`Prompt`,order:t,keys:[],availability:{status:`available`}})),t,{idleCategory:`Prompt`});return n.kind===`commands`?n.items.flatMap(({command:t})=>e.find(e=>e.id===t.commandId)??[]):[]},[t,e,i]);return(0,q.useEffect)(()=>{r(0)},[t]),{moveSlash:e=>{r(t=>a.length?(t+e+a.length)%a.length:0)},highlightSlash:r,resetSlash:()=>{r(0)},slashIndex:n,slashMatches:a,slashOpen:i}}function cP({images:e,index:t,listId:n,matches:r,onHighlight:i,onPick:a}){return(0,J.jsx)(gA,{open:!0,rows:r.map(t=>{if(t.kind===`reference`)return{key:qn(t.reference.number),label:`@${qn(t.reference.number)}`,detail:t.reference.name,media:(0,J.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,children:t.reference.url?(0,J.jsx)(`img`,{src:t.reference.url,alt:``}):null})};let{character:n}=t,r=n.references.at(0)?.path,i=e.find(e=>e.path===r);return{key:String(n.id),label:`@${n.name}`,detail:n.description||void 0,media:(0,J.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,children:i?(0,J.jsx)(`img`,{src:i.url,alt:``}):null})}}),selected:t,listId:n,label:`References and characters`,kind:`characters`,onHighlight:i,onChoose:a})}var lP=e=>e.kind===`reference`?qn(e.reference.number):e.character.name;function uP(e,t,n,r){return Ci(e).flatMap(e=>{let i=/^image(\d+)$/i.exec(e);if(i!==null){let t=n.find(e=>e.number===Number(i.at(1)));return[{key:e.toLowerCase(),label:`@${e.toLowerCase()}`,url:t?.url,valid:t!==void 0}]}let a=t.find(t=>t.name.toLowerCase()===e.toLowerCase());if(a===void 0)return[];let o=a.references.at(0)?.path;return[{key:`character:${String(a.id)}`,label:`@${a.name}`,url:r.find(e=>e.path===o)?.url,valid:!0}]})}function dP({tokens:e}){return e.length===0?null:(0,J.jsx)(`ul`,{className:`prints-mention-tokens`,"aria-label":`Mentioned in the prompt`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`prints-mention-token`,"data-mention-token":e.label,"data-invalid":e.valid?void 0:``,title:e.valid?void 0:`No longer attached`,children:[(0,J.jsx)(`span`,{className:`prints-mention-thumb mask mask-squircle`,children:e.url?(0,J.jsx)(`img`,{src:e.url,alt:``}):null}),(0,J.jsx)(`span`,{children:e.label}),e.valid?null:(0,J.jsx)(`span`,{children:` · not attached`})]},e.key))})}function fP(e,t,n){let[r,i]=(0,q.useState)(0),[a,o]=(0,q.useState)(0),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(null),d=s===n?null:Lr(n,r),f=d?Sr(e,t,d.query):[];return(0,q.useEffect)(()=>{o(0)},[n]),{caretRequest:l,matches:f,index:a,setCaret:i,highlight:o,dismiss:()=>{c(n)},move:e=>{o(t=>f.length?(t+e+f.length)%f.length:0)},complete:e=>{let t=f.at(e);if(!d||!t)return null;let a=lP(t),o=`${n.slice(0,d.start)}@${a} ${n.slice(r)}`,s=d.start+a.length+2;return u({value:o,caret:s}),i(s),o}}}function pP(e,t,n){let[r,i]=(0,q.useState)(Ti),a=e.map(e=>Yn(e,n)),o=Gn(r,a,t);return o!==r&&i(o),mr(o,a)}var mP=400;function hP(e){let{draft:t,model:n}=e;if(n===void 0||t.prompt.trim()===``)return null;let r=wr(t.prompt).length>0,i=n.kind===`audio`?ki(t.prompt):Vr({prompt:t.prompt,saved:e.characters,references:t.references,labels:e.labels,wording:e=>ri(Yr(e,n,r),n),computerId:e.computerId,model:{label:n.label,maxReferences:n.input.maxReferences}});if(i.kind===`refused`)return null;let a=Yr(i.references,n,r),o={...t,prompt:ti(n.kind===`audio`?void 0:e.styleText,i.prompt),references:a};return Rr(o,n)!==void 0||n.video!==null&&!n.video.formats.some(e=>e.width===o.width&&e.height===o.height)?null:bi(o,n).settings}function gP(e,t){let n=e===null?null:JSON.stringify(e),r=(0,q.useRef)(e);r.current=e;let[i,a]=(0,q.useState)({key:n,settings:e});return(0,q.useEffect)(()=>{let e=setTimeout(()=>{a({key:n,settings:r.current})},t);return()=>{clearTimeout(e)}},[n,t]),i}function _P(e,t){return Wn({queryKey:[`prints`,`quote`,e?.computerId??null,t.key],enabled:e!==void 0&&t.settings!==null,queryFn:()=>e===void 0||t.settings===null?null:e.quote(t.settings),staleTime:6e4,retry:!1})}function vP(e,t){let n=t===null?null:JSON.stringify(t),r=gP(t,mP),i=Or(_P(e,r));return r.key!==n||i.data==null?null:yi(i.data.costMilliunits)}function yP(e){let t=gn(),n=Or(Gr(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(xi.characters(e),n)}}),i=ce(r((e,t,n)=>Di(e.capabilities,t,n))),a=ce(r((e,t,n)=>Qr(e.capabilities,t,n))),o=i.error??a.error??n.error;return{characters:n.data?.characters??[],error:o?Ht(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:t})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}var bP=u(oi),xP=e=>e.split(`/`).at(-1)??e;function SP({paths:e,images:t}){return(0,J.jsx)(`span`,{className:`flex gap-xs`,children:e.map(e=>{let n=t.find(t=>t.path===e);return(0,J.jsx)(`span`,{className:`prints-character-thumb mask mask-squircle`,title:e,children:n?(0,J.jsx)(`img`,{src:n.url,alt:xP(e)}):null},e)})})}function CP({characters:e,images:t,open:n,onOpenChange:r,busy:i,error:a,canUpload:o,onUpload:s,onSave:c,onDelete:l}){let[u,d]=(0,q.useState)(null),f=(0,q.useId)(),p=u?.name.trim()??``,m=p.startsWith(`@`)?p.slice(1):p,h=[];m===``?h.push(`Enter a character name.`):m.length>32?h.push(`Use 32 characters or fewer for the name.`):/^image\d+$/i.test(m)?h.push(`image1, image2 and so on name attached references; pick another name.`):bP(m)||h.push(`Use only letters, numbers, hyphens (-) and underscores (_).`),u?.references.length===0&&h.push(`Select at least one reference image.`),i&&h.push(`Wait for the current character change to finish, then save.`);let g=h.length>0,_=g?f:void 0;return(0,J.jsx)(Fp,{open:n,onOpenChange:e=>{e||d(null),r(e)},children:(0,J.jsxs)(Bp,{children:[(0,J.jsx)(Hp,{children:(0,J.jsx)(Up,{children:`Characters`})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[e.length===0&&u===null?(0,J.jsx)(`p`,{className:`text-sm`,children:`No characters yet. Save one, then type @name in a prompt to keep it the same in every image.`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-sm`,"aria-label":`Saved characters`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-center gap-sm`,children:[(0,J.jsx)(SP,{paths:e.references.map(e=>e.path),images:t}),(0,J.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`@`,e.name]})]}),(0,J.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,J.jsx)(W,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(e)},children:`Edit`}),(0,J.jsx)(W,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{l(e,()=>{u?.id===e.id&&d(null)})},children:`Delete`})]})]},e.id))}),u===null?(0,J.jsx)(W,{size:`xs`,type:`button`,onClick:()=>{d({name:``,description:``,references:[]})},children:`New character`}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-sm`,children:[(0,J.jsx)(ey,{"aria-label":`Character name`,"aria-invalid":!bP(m),"aria-describedby":_,maxLength:33,placeholder:`Name, typed as @name`,value:u.name,onChange:e=>{d({...u,name:e.currentTarget.value})}}),(0,J.jsx)(fA,{"aria-label":`Character description`,maxLength:500,rows:4,placeholder:`Short description added to the prompt, e.g. a tall girl with silver hair and a red scarf`,value:u.description,onChange:e=>{d({...u,description:e.currentTarget.value})}}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-sm`,children:[(0,J.jsxs)(`span`,{className:`text-xs`,children:[`Reference images · `,u.references.length,` selected, up to`,` `,8]}),(0,J.jsxs)(W,{size:`xs`,variant:`ghost`,type:`button`,disabled:!o,onClick:s,children:[(0,J.jsx)(Ch,{"aria-hidden":`true`,size:14}),`Upload`]})]}),t.length===0?(0,J.jsx)(`p`,{className:`text-xs`,children:`No images in the Prints folder yet. Upload one to use it as a reference.`}):(0,J.jsx)(`ul`,{className:`prints-character-picker`,"aria-label":`Reference images`,children:t.map(e=>{let t=u.references.some(t=>t.path===e.path);return(0,J.jsx)(`li`,{title:e.path,children:(0,J.jsxs)(`label`,{className:`prints-character-pick`,children:[(0,J.jsx)(`img`,{src:e.url,alt:``}),(0,J.jsx)(`span`,{className:`prints-character-check`,children:(0,J.jsx)(bA,{"aria-label":`Use ${xP(e.path)}`,checked:t,disabled:!t&&u.references.length>=8,onChange:()=>{d({...u,references:t?u.references.filter(t=>t.path!==e.path):[...u.references,{path:e.path}]})}})})]})},e.path)})}),g?(0,J.jsx)(`p`,{id:f,role:`status`,className:`text-xs`,children:h.join(` `)}):null,(0,J.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,J.jsx)(W,{size:`xs`,variant:`primary`,type:`button`,disabled:g,"aria-describedby":_,onClick:()=>{c({id:u.id,name:m,description:u.description.trim(),references:u.references},()=>{d(null)})},children:`Save character`}),(0,J.jsx)(W,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{d(null)},children:`Cancel`})]})]}),a?(0,J.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null]}),(0,J.jsx)(Vp,{children:(0,J.jsx)(Wp,{render:(0,J.jsx)(W,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var wP=g({destination:Ie(p(b)),height:Ie(bn),model:Ie(b),prompt:Ie(b),references:Ie(St(g({computerId:Ie(b),path:b,role:Ie(Ze([`first-frame`,`last-frame`,`reference`]))}))),generateAudio:Ie(p(_t)),steps:Ie(p(bn)),style:Ie(p(b)),width:Ie(bn)}),TP=i(K(),nn()).parse(structuredClone(Ve(wP,{onExcessProperty:`error`}).schema)),EP=(e,t,n,r)=>({id:e,title:t,category:`Image generation`,description:n,projections:{agent:{}},action:r===void 0?{presentation:{type:`action`}}:{inputSchema:r,presentation:{type:`action`}}}),DP=EP(`inspect-generation-draft`,`Inspect image draft`,`Read the current Prints image form and available models`),OP=EP(`set-generation-draft`,`Edit image draft`,`Set selected Prints image form fields; this does not generate an image`,TP),kP=EP(`submit-generation-draft`,`Generate image`,`Submit the current Prints image form using the same action as the Send button`);function AP(e,t){let n=!1,r=new Set,i=(t,i)=>{e.commands.register(t,i).then(e=>{n?e():r.add(e)},()=>void 0)};return i(DP,()=>{if(n)return;let e=t.readDraft();return{draft:{destination:e.destination??null,height:e.height,model:e.model,prompt:e.prompt,generateAudio:e.generateAudio??null,references:e.references.map(e=>{let t={path:e.path,role:e.role??null};return e.computerId===void 0?t:{...t,computerId:e.computerId}}),steps:e.steps??null,style:e.style??null,width:e.width},models:t.readModels().map(e=>({id:e.id,label:e.label,defaultHeight:e.input.defaultHeight,defaultWidth:e.input.defaultWidth,maxReferences:e.input.maxReferences}))}}),i(OP,({arguments:e})=>{if(n)return;let r=I(wP,{onExcessProperty:`error`})(e);t.setDraft(r)}),i(kP,async()=>{if(!n)return{accepted:await t.submit()}}),()=>{if(!n){n=!0;for(let e of r)e();r.clear()}}}function jP(e){return[{id:`clear-prompt`,title:`Clear prompt`,category:`Prompt`,description:`Remove the current prompt`,projections:{slash:{aliases:[`clear`],order:0},palette:{}},handler:()=>{e().clear()}},...$n.map((t,n)=>({id:`size-${t}`,title:`Use ${t} size`,category:`Prompt`,description:`Use ${String(or[t].width)} × ${String(or[t].height)}`,projections:{slash:{aliases:[t],order:n+1},palette:{}},handler:()=>{e().useSize(t)}})),{id:`choose-style`,title:`Choose style`,category:`Prompt`,description:`Pick, create or edit a saved style`,projections:{slash:{aliases:[`style`],order:4},palette:{}},handler:()=>{e().openStyles()}},{id:`no-style`,title:`Use no style`,category:`Prompt`,description:`Send the prompt without a style`,projections:{slash:{aliases:[`nostyle`],order:5},palette:{}},handler:()=>{e().clearStyle()}}]}function MP(e,t){let n=(0,q.useRef)(e);n.current=e;let r=xf(t,{sourceId:`media-prompt`,namespace:`media`},(0,q.useCallback)(()=>jP(()=>n.current),[])),i=(0,q.useSyncExternalStore)(r.subscribe,r.snapshot,r.snapshot);return{items:(0,q.useMemo)(()=>Kk(i).map(e=>({id:e.commandId,command:e.command,slash:e.alias,title:e.title,description:e.description})),[i]),run:e=>{r.execute(e,{origin:`slash`})}}}function NP(e){let t=gn(),n=Or(Jr(e)),r=n=>({mutationFn:t=>{let r=e?.context.get().computerId;if(!e||!r)throw Error(`No Computer selected`);return n(e,r,t)},onSuccess:n=>{t.setQueryData(xi.styles(e),n)}}),i=ce(r((e,t,n)=>Zn(e.capabilities,t,n))),a=ce(r((e,t,n)=>ur(e.capabilities,t,n))),o=i.error??a.error??n.error;return{styles:n.data?.styles??[],error:o?Ht(o).message:null,busy:i.isPending||a.isPending,save:(e,t)=>{i.mutate(e,{onSuccess:n=>{t(n.styles.find(t=>t.name===e.name))}})},remove:(e,t)=>{a.mutate(e,{onSuccess:t})}}}function PP(e){let t=e.filter(e=>e.kind===`video`&&e.video!==null&&e.video.prices.length>0&&e.input.maxReferences>=1&&e.video.referenceRoles.includes(`first-frame`));return t.find(e=>e.video?.provider===`seedance`)??t.at(0)}function FP(e,t,n){let r=e.video;if(r===null)return;let i=Math.log(t/n),a=e=>Math.abs(Math.log(e.width/e.height)-i);return r.formats.filter(e=>e.resolution===r.defaultResolution).reduce((e,t)=>e===void 0||a(t)<a(e)?t:e,void 0)}function IP(e,t){let{lineage:n,printPath:r,models:i,current:a}=t,o=e===`animate`?PP(i):void 0;if(e===`animate`&&o===void 0)return{kind:`refused`,message:`No video model on this Computer takes a first frame.`};let s=Br(i,n.model),c=o??s??Br(i,a.model);if(c===void 0)return{kind:`refused`,message:`Choose a model from the granted registry.`};let l=o===void 0&&s===void 0?`This print was made with ${n.model}, which is no longer available. Loaded it with ${ui(c)} instead.`:null,u=n.references.slice(0,n.typed.references),d=e===`animate`?{path:r,role:`first-frame`}:{path:r},f=[d,...u.filter(e=>!gi(e,t.printComputerId)||e.path!==r)];if(e!==`reuse`&&c.input.maxReferences===0)return{kind:`refused`,message:`${c.label} does not take reference images.`};let p=e===`reuse`?u:e===`remix`?f:[d],m=jr(a,c),h={width:n.width??m.width,height:n.height??m.height},g=o===void 0?$r(h,c,void 0):FP(c,h.width,h.height)??m,_=o===void 0&&c.input.steps!==`fixed`&&n.steps!==null&&c.id===n.model?n.steps:m.steps,v=n.style!==null&&t.styles.includes(n.style)?n.style:void 0;return{kind:`draft`,notice:l,draft:{...m,destination:void 0,prompt:Vn(n.typed.prompt,e=>{let t=u.at(e-1),n=t===void 0?-1:p.findIndex(e=>e.path===t.path&&e.computerId===t.computerId);return n<0?void 0:n+1}),references:p,steps:_,style:v,width:g.width,height:g.height}}}function LP({id:e,styles:t,selected:n,disabled:r,onSelect:i}){let a=n===void 0||t.some(e=>e.name===n);return(0,J.jsxs)(yy,{id:e,"aria-label":`Prompt style`,"data-generation-style":!0,className:`select-sm`,disabled:r,onChange:e=>{i(e.currentTarget.value||void 0)},value:n??``,children:[(0,J.jsx)(`option`,{value:``,children:`No style`}),a?null:(0,J.jsx)(`option`,{value:n,children:n}),t.map(e=>(0,J.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}function RP({styles:e,selected:t,open:n,onOpenChange:r,busy:i,error:a,onSelect:o,onSave:s,onDelete:c}){let[l,u]=(0,q.useState)(null);return(0,J.jsx)(Fp,{open:n,onOpenChange:r,children:(0,J.jsxs)(Bp,{children:[(0,J.jsx)(Hp,{children:(0,J.jsx)(Up,{children:`Styles`})}),(0,J.jsx)(`ul`,{className:`space-y-1`,"aria-label":`Saved styles`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center justify-between gap-sm`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,J.jsxs)(`span`,{className:`flex gap-xs`,children:[(0,J.jsx)(W,{size:`xs`,variant:t===e.name?`primary`:`ghost`,type:`button`,"aria-pressed":t===e.name,onClick:()=>{o(e.name),r(!1)},children:`Use`}),e.builtIn?null:(0,J.jsx)(W,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(e)},children:`Edit`}),(0,J.jsx)(W,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u({name:`${e.name} copy`.slice(0,64),text:e.text})},children:`Duplicate`}),e.builtIn?null:(0,J.jsx)(W,{size:`xs`,variant:`ghost`,type:`button`,disabled:i,onClick:()=>{c(e,()=>{t===e.name&&o(void 0),l?.id===e.id&&u(null)})},children:`Delete`})]})]},e.id))}),l===null?(0,J.jsx)(W,{size:`xs`,type:`button`,onClick:()=>{u({name:``,text:``})},children:`New style`}):(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(ey,{"aria-label":`Style name`,maxLength:64,value:l.name,onChange:e=>{u({...l,name:e.currentTarget.value})}}),(0,J.jsx)(fA,{"aria-label":`Style text`,maxLength:8e3,rows:6,value:l.text,onChange:e=>{u({...l,text:e.currentTarget.value})}}),(0,J.jsxs)(`div`,{className:`flex gap-xs`,children:[(0,J.jsx)(W,{size:`xs`,variant:`primary`,type:`button`,disabled:i||l.name.trim()===``||l.text.trim()===``,onClick:()=>{let n=e.find(e=>e.id===l.id);s({id:l.id,name:l.name.trim(),text:l.text},e=>{n&&t===n.name&&e&&o(e.name),u(null)})},children:`Save style`}),(0,J.jsx)(W,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{u(null)},children:`Cancel`})]})]}),a?(0,J.jsx)(`p`,{role:`alert`,className:`text-xs`,children:a}):null,(0,J.jsx)(Vp,{children:(0,J.jsx)(Wp,{render:(0,J.jsx)(W,{variant:`outline`,size:`sm`}),children:`Close`})})]})})}var zP=(0,q.lazy)(async()=>({default:(await ji(()=>import(`./print-info-drawer-Ci9I_Ml8.js`),__vite__mapDeps([5,1,2,3,6]),import.meta.url)).PrintInfoDrawer})),BP=[`a mushroom knight`,`moss on a keyboard`,`a tiny house made of mushrooms`];function VP(e){Zt.error(e,{id:`prints-generation-error`,toasterId:`prints-generation-notices`})}function HP(e){let t=(0,q.useRef)(!1),n=$v({defaultValues:ir(),onSubmit:async({value:n})=>{t.current=await e.current(n)}}),r=(0,q.useCallback)(async()=>(t.current=!1,await n.handleSubmit(),t.current),[n]);return Object.assign(n,{submitCurrent:r})}function UP(e){let t=[...new Set(e.map(e=>e.group))];return t.length<2?[{group:void 0,choices:e}]:t.map(t=>({group:t,choices:e.filter(e=>e.group===t)}))}function WP({form:e,selected:t,stylePicker:n,sizeChoices:r,sizeMode:i,onCustomSize:a,match:o,onEditStyles:s,onEditCharacters:c}){let l=t?.input.dimensions===`none`,u=t!==void 0&&t.sizes!==null,d=t?.video??null;return(0,J.jsxs)(`div`,{className:`prints-settings`,children:[(0,J.jsx)(py,{label:`Style`,orientation:`horizontal`,children:n}),(0,J.jsx)(py,{label:`Size`,orientation:`horizontal`,children:(0,J.jsx)(yy,{"aria-label":`Generation size`,"data-generation-size":!0,className:`select-sm`,disabled:l,title:l?`This model chooses the output size.`:void 0,onChange:t=>{let n=t.currentTarget.value;o.onChange(n===`match`),a(n===`custom`);let i=r.find(e=>e.value===n);i&&(e.setFieldValue(`width`,i.width),e.setFieldValue(`height`,i.height))},value:l?`provider`:i,children:l?(0,J.jsx)(`option`,{value:`provider`,children:`Model default`}):(0,J.jsxs)(J.Fragment,{children:[o.offered?(0,J.jsx)(`option`,{value:`match`,disabled:o.size===void 0,children:o.size===void 0?`Match first reference: attach an image first`:`Match first reference · ${Zr(o.size.width,o.size.height)}`}):null,u&&i!==`match`&&!r.some(e=>e.value===i)?(0,J.jsx)(`option`,{value:i,disabled:!0,children:`Choose a supported resolution`}):null,UP(r).map(({group:e,choices:t})=>e===void 0?t.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value)):(0,J.jsx)(`optgroup`,{label:e,children:t.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))},e)),u?null:(0,J.jsx)(`option`,{value:`custom`,children:`Custom size`})]})})}),!l&&!u&&i===`custom`?(0,J.jsxs)(`div`,{className:`prints-custom-size`,children:[(0,J.jsx)(e.Field,{name:`width`,children:e=>(0,J.jsx)(py,{label:`Width`,children:(0,J.jsx)(ey,{"aria-label":`Generation width`,"data-generation-width":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})}),(0,J.jsx)(e.Field,{name:`height`,children:e=>(0,J.jsx)(py,{label:`Height`,children:(0,J.jsx)(ey,{"aria-label":`Generation height`,"data-generation-height":!0,max:4096,min:1,onChange:t=>{e.handleChange(Number(t.currentTarget.value)||1)},type:`number`,value:e.state.value})})})]}):null,d?(0,J.jsx)(e.Field,{name:`durationSeconds`,children:e=>(0,J.jsx)(py,{label:`Length`,orientation:`horizontal`,children:(0,J.jsx)(yy,{"aria-label":`Video length in seconds`,className:`select-sm`,"data-generation-duration":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(d.durations.find(e=>String(e)===n))},value:e.state.value===void 0?``:String(e.state.value),children:d.durations.map(e=>(0,J.jsxs)(`option`,{value:String(e),children:[e,` seconds`]},e))})})}):null,d?.supportsAudio?(0,J.jsx)(e.Field,{name:`generateAudio`,children:e=>d.defaultGenerateAudio===null?(0,J.jsx)(py,{label:`Sound`,orientation:`horizontal`,children:(0,J.jsxs)(yy,{"aria-label":`Video sound`,className:`select-sm`,"data-generation-audio":!0,onChange:t=>{let n=t.currentTarget.value;e.handleChange(n===``?void 0:n===`on`)},value:e.state.value===void 0?``:e.state.value?`on`:`off`,children:[(0,J.jsx)(`option`,{value:``,children:`Model default`}),(0,J.jsx)(`option`,{value:`on`,children:`On`}),(0,J.jsx)(`option`,{value:`off`,children:`Off`})]})}):(0,J.jsx)(py,{label:`Sound`,orientation:`horizontal`,children:(0,J.jsx)(zr,{"aria-label":`Video sound`,checked:e.state.value??!0,"data-generation-audio":!0,onCheckedChange:e.handleChange})})}):null,t&&t.input.steps!==`fixed`?(0,J.jsx)(e.Field,{name:`steps`,children:e=>(0,J.jsx)(py,{label:`Steps`,optional:!0,orientation:`horizontal`,children:(0,J.jsx)(ey,{"aria-label":`Generation steps`,className:`input-sm`,"data-generation-steps":!0,max:t.input.maxSteps??void 0,min:1,onChange:t=>{e.handleChange(t.currentTarget.value===``?void 0:Number(t.currentTarget.value))},type:`number`,value:e.state.value??``})})}):null,(0,J.jsxs)(`div`,{className:`prints-settings-library`,children:[(0,J.jsx)(W,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{s()},children:`Edit styles…`}),(0,J.jsx)(W,{size:`xs`,variant:`ghost`,type:`button`,onClick:()=>{c()},children:`Characters…`})]})]})}function GP({actions:e,guidance:t,commandApp:n,form:r,models:i,modelsLoading:a,mediaCapability:o,submitting:s,values:c,computerId:l,mediaDirectory:u,referenceImages:d,referenceLabels:f,price:p,characters:m,characterDialog:h,onSubmit:g,styleControls:_,addedLength:v}){let y=Br(i,c.model),b=c.prompt.trim().length,x=y!==void 0&&b>0&&b+v>y.maxPromptLength,S=Kr(y),C=y?.video??null,w=wr(c.prompt).length>0,T=Yr(c.references,y,w),E=y===void 0?void 0:Si(T,y,C?.formats.find(e=>e.width===c.width&&e.height===c.height)?.resolution),D=y?.input.maxReferences??0,O=c.references.length>D,[k,A]=(0,q.useState)(!1),[j,M]=(0,q.useState)(!1),ee=c.references.find(e=>l!==null&&gi(e,l)),N=d.find(e=>e.path===ee?.path),P=N===void 0?void 0:ei(y,N.width,N.height),te=r.setFieldValue,ne=(0,q.useRef)({width:c.width,height:c.height});ne.current={width:c.width,height:c.height},(0,q.useEffect)(()=>{if(j){if(P===void 0){M(!1),Zt(`Size kept at ${String(ne.current.width)} × ${String(ne.current.height)}; Match first reference turned off`,{toasterId:`prints-generation-notices`});return}te(`width`,P.width),te(`height`,P.height)}},[j,P?.width,P?.height,te]);let[F,re]=(0,q.useState)(!1),ie=y!==void 0&&y.sizes!==null,I=si(y),L=j?`match`:ie?`${String(c.width)}x${String(c.height)}`:k?`custom`:I.find(e=>e.width===c.width&&e.height===c.height)?.value??`custom`,[ae,oe]=(0,q.useState)(!1),se=MP({clear:()=>{r.setFieldValue(`prompt`,``)},useSize:e=>{A(!1),M(!1),r.setFieldValue(`width`,or[e].width),r.setFieldValue(`height`,or[e].height),r.setFieldValue(`prompt`,``)},openStyles:()=>{r.setFieldValue(`prompt`,``),oe(!0)},clearStyle:()=>{r.setFieldValue(`style`,void 0),r.setFieldValue(`prompt`,``)}},n),[ce,le]=(0,q.useState)(!1),R=c.references.map((e,t)=>({number:f[t]??t+1,name:e.path.split(`/`).at(-1)??e.path,url:l!==null&&gi(e,l)?d.find(t=>t.path===e.path)?.url:void 0})),ue=fP(m,R,c.prompt),de=uP(c.prompt,m,R,d),fe=sP(se.items,c.prompt),pe=(0,q.useId)(),z=`${pe}-commands`,B=`${pe}-characters`,V=Vr({computerId:l,prompt:c.prompt,saved:m,references:c.references,labels:f,wording:e=>ri(Yr(e,y,w),y),model:y===void 0?void 0:{label:y.label,maxReferences:y.input.maxReferences}}),me=Xr(c.prompt,m).characters,he=e=>{let t=fe.slashMatches.at(e);t&&(fe.resetSlash(),se.run(t.command))},ge=_({open:ae,onOpenChange:oe}),_e=[c.style,j?`Match · ${ai(c.width,c.height)}`:fi(y,c.width,c.height),C&&c.durationSeconds!==void 0?`${String(c.durationSeconds)}s`:void 0,C?.supportsAudio&&c.generateAudio===!1?`silent`:void 0].filter(e=>e!=null),ve=(0,J.jsx)(WP,{form:r,selected:y,stylePicker:ge.picker,sizeChoices:I,sizeMode:L,onCustomSize:A,match:{offered:y?.kind===`image`&&y.input.dimensions===`own`,size:P,onChange:M},onEditStyles:()=>{re(!1),oe(!0)},onEditCharacters:()=>{re(!1),le(!0)}}),ye=e=>{let t=r.store.state.fieldMeta,n=jr(c,e),i=$r(c,e,y);r.setFieldValue(`model`,e.id),(e.input.dimensions===`none`||e.sizes!==null)&&A(!1),r.setFieldValue(`width`,i.width),r.setFieldValue(`height`,i.height),r.setFieldValue(`durationSeconds`,n.durationSeconds),r.setFieldValue(`voiceId`,n.voiceId),r.setFieldValue(`generateAudio`,n.generateAudio),e.kind===`audio`&&r.setFieldValue(`references`,[]),(e.input.steps===`fixed`||!t.steps?.isTouched)&&r.setFieldValue(`steps`,n.steps)},H=y?.kind===`audio`,be=Ig(pi(i)),xe=(0,q.useRef)(null);y!==void 0&&y.kind!==`audio`&&(xe.current=y.id);let Se=()=>{let e=H?Br(i,xe.current??``)??Br(i,`@cf/black-forest-labs/flux-2-klein-4b`)??Wr(i).at(0):Br(i,be.at(0)?.id??``);e&&ye(e)},Ce=y===void 0?null:Lg(y),we=Ce===null?[]:zg(be,Ce),Te=y?.audio==null||Ce===null?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Bg,{disabled:s,modes:Rg(be),value:Ce,onChange:e=>{let t=Br(i,zg(be,e).at(0)?.id??``);t&&ye(t)}}),we.length>1?(0,J.jsx)(Hg,{disabled:s,models:we,value:y.id,onChange:e=>{let t=Br(i,e);t&&ye(t)}}):null,y.audio.mode===`speech`?(0,J.jsx)(Ug,{disabled:s,voices:y.audio.voices,value:c.voiceId??y.audio.defaultVoiceId??``,onChange:e=>{r.setFieldValue(`voiceId`,e)}}):null,y.audio.seconds===null?null:(0,J.jsx)(Kg,{disabled:s,seconds:y.audio.seconds,value:c.durationSeconds??y.audio.seconds.default,onChange:e=>{r.setFieldValue(`durationSeconds`,e)}})]});return(0,J.jsxs)(EA,{"aria-label":H?`Audio generation`:`Image generation`,"data-generation-form":!0,attachments:!H&&c.references.length>0?(0,J.jsx)(`div`,{className:`prints-reference-tray`,"aria-label":`Image references`,children:c.references.map((e,t)=>{let n=l!==null&&gi(e,l)?d.find(t=>t.path===e.path):void 0,i=T[t]?.role,a=vi(S,T,t);return(0,J.jsxs)(`div`,{className:`prints-reference-tile`,title:e.computerId===void 0?e.path:`${e.computerId}:${e.path}`,children:[(0,J.jsx)(`div`,{className:`prints-reference-face mask mask-squircle`,children:n?(0,J.jsx)(`img`,{src:n.url,alt:e.path.split(`/`).at(-1)}):(0,J.jsx)(`span`,{children:qn(f[t]??t+1)})}),(0,J.jsx)(`span`,{className:`prints-reference-label`,"data-reference-label":!0,children:qn(f[t]??t+1)}),i===void 0?null:a===void 0?(0,J.jsx)(`span`,{className:`prints-reference-role`,"data-reference-role":i,children:kr[i]}):(0,J.jsx)(W,{size:`xs`,variant:`ghost`,type:`button`,className:`prints-reference-role`,"data-reference-role":i,"aria-label":`Reference ${String(t+1)}: ${kr[i]}. Use as ${kr[a]}`,title:`Use as ${kr[a]}`,onClick:()=>{r.setFieldValue(`references`,T.map((e,n)=>n===t?{...e,role:a}:e))},children:kr[i]}),(0,J.jsx)(ht,{icon:(0,J.jsx)(Hr,{}),className:`prints-reference-remove`,"aria-label":`Remove reference ${String(t+1)}`,onClick:()=>{r.setFieldValue(`references`,c.references.filter((e,n)=>n!==t))}})]},JSON.stringify([e.computerId??l,e.path]))})}):void 0,input:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`form`,{"aria-busy":s,onSubmit:e=>{e.preventDefault(),g()},children:(0,J.jsx)(r.Field,{name:`prompt`,children:e=>(0,J.jsxs)(`div`,{className:`prints-prompt`,children:[fe.slashOpen?(0,J.jsx)(oP,{index:fe.slashIndex,listId:z,matches:fe.slashMatches,onHighlight:fe.highlightSlash,onPick:he}):null,!fe.slashOpen&&ue.matches.length>0?(0,J.jsx)(cP,{images:d,index:ue.index,listId:B,matches:ue.matches,onHighlight:ue.highlight,onPick:t=>{let n=ue.complete(t);n!==null&&e.handleChange(n)}}):null,(0,J.jsx)(aP,{caretRequest:ue.caretRequest,menu:fe.slashOpen?{open:fe.slashMatches.length>0,listId:z,selected:fe.slashIndex}:{open:ue.matches.length>0,listId:B,selected:ue.index},mentionCount:fe.slashOpen?0:ue.matches.length,onCaret:ue.setCaret,onMentionDismiss:ue.dismiss,onMentionMove:ue.move,onMentionPick:()=>{let t=ue.complete(ue.index);t!==null&&e.handleChange(t)},disabled:!o||a||i.length===0||s,maxLength:y?.maxPromptLength,addedLength:v,onChange:t=>{e.handleChange(t)},onSend:g,onSlashMove:fe.moveSlash,onSlashPick:()=>{he(fe.slashIndex)},placeholder:y?.audio?.mode===`speech`?`What should it say?`:y?.audio?.mode===`music`?`Describe the music`:`What are we making?`,slashCount:fe.slashMatches.length,value:e.state.value}),c.references.length>0||E!==void 0||me.length>0||de.length>0?(0,J.jsxs)(`div`,{className:`prints-composer-notes`,children:[(0,J.jsx)(dP,{tokens:de}),c.references.length>0?(0,J.jsxs)(`span`,{className:`prints-reference-count`,"data-generation-references":!0,"data-over-limit":O?``:void 0,role:O?`alert`:void 0,children:[c.references.length,` / `,D,` `,`references`,O?D===0?` — this model takes none; remove them or pick another model`:` — over this model's limit; remove some to generate`:null]}):null,E===void 0?null:(0,J.jsx)(`span`,{className:`prints-reference-count`,"data-generation-reference-roles":!0,"data-over-limit":``,role:`alert`,children:E}),V.kind===`refused`&&me.length===0?(0,J.jsx)(`span`,{className:`prints-reference-count`,"data-generation-mentions":!0,"data-over-limit":``,role:`alert`,children:V.message}):null,me.length>0?(0,J.jsx)(`span`,{className:`prints-reference-count`,"data-generation-characters":!0,"data-over-limit":V.kind===`refused`?``:void 0,role:V.kind===`refused`?`alert`:void 0,children:V.kind===`refused`?V.message:`Characters: ${me.map(e=>e.name).join(`, `)}`}):null]}):null]})})}),t?(0,J.jsxs)(`div`,{className:`prints-composer-guidance`,role:`status`,"data-composer-guidance":!0,children:[(0,J.jsx)(`span`,{children:t.group===`Images`&&t.detail?t.detail:(0,J.jsxs)(J.Fragment,{children:[t.title,`. `,t.detail]})}),t.actions?.map(e=>(0,J.jsx)(W,{variant:`ghost`,size:`xs`,onClick:e.run,children:e.label},e.label))]}):null]}),row:{controls:(0,J.jsxs)(J.Fragment,{children:[H?null:e,be.length>0?(0,J.jsx)(bt,{"aria-label":`Audio`,"data-generation-audio-key":!0,icon:(0,J.jsx)(rh,{}),label:null,pressed:H,tone:H?`accent`:`neutral`,title:H?`Back to pictures`:`Make audio`,disabled:a||!o,onClick:Se}):null,H?Te:(0,J.jsx)(r.Field,{name:`model`,children:e=>(0,J.jsx)(OA,{models:Wr(i),emptyLabel:l===null?`Choose a Computer`:a?`Loading models…`:`Models unavailable`,disabled:a||!o,onChange:e=>{let t=Br(i,e);t&&ye(t)},value:e.state.value})}),l&&u?(0,J.jsx)(`span`,{className:`sr-only`,"data-generation-computer":!0,title:`Where new prints are saved`,children:`Saved in your Prints folder`}):null]}),action:(0,J.jsxs)(`span`,{className:`prints-generate-action`,children:[p===null?null:(0,J.jsx)(`span`,{className:`prints-generate-price`,"data-generation-price":!0,title:`Estimated price`,children:p.startsWith(`<`)?p:`≈ ${p}`}),(0,J.jsx)(iP,{busy:s,draft:c.prompt,disabled:!o||a||i.length===0||s,label:vr(y),onGenerate:()=>{g()},promptOver:x})]}),items:H?[]:[{id:`settings`,accessibleLabel:`Generation settings`,title:`Settings`,label:(0,J.jsxs)(`span`,{className:`prints-settings-chip`,children:[(0,J.jsx)(xh,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),(0,J.jsx)(`span`,{className:`prints-settings-chip-text`,children:_e.length>0?_e.join(` · `):`Settings`})]}),content:ve}],openId:F?`settings`:null,onOpenChange:e=>{re(e===`settings`)}},children:[ge.dialog,h({open:ce,onOpenChange:le})]})}function KP({connection:e}){let t=(0,q.useRef)(null),n=(0,q.useRef)(e);n.current=e;let r=AA(e?.app??null),i=vf(e?.app??null)?.setup?.media===`missing`,[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),l=()=>{let t=e?.app;t&&(o(!0),c(!1),t.ui.openSetup(`media`).then(e=>{o(!1),c(e===`unavailable`)},e=>{o(!1),c(!0),dn(`open-media-setup`,e)}))},u=s?(0,J.jsxs)(J.Fragment,{children:[`Image setup couldn’t open.`,` `,(0,J.jsx)(`a`,{href:`https://github.com/fungi-computer/oyster#deploy-to-cloudflare`,target:`_blank`,rel:`noreferrer`,children:`Open the image setup guide`}),`.`]}):`Image generation isn’t set up yet.`,[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(),h=VM(e?.app??null,r.computerId),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(),S=(0,q.useRef)(0);(0,q.useEffect)(()=>{_(null),y(null),x(void 0)},[e,r.computerId,r.path]);let C=r.path,w=Sg(e,r),{gallery:T,images:E,failed:D,loading:O,gallerySlots:k,canBrowse:A,canRead:j,canWrite:M,reserveSlot:ee,failSlot:N,clearSlotError:P,removeSlot:te,addComputerFile:ne,retryFile:F,uploads:re,uploadFiles:ie}=w,I=e!==null&&r.destination!==null&&A&&j,L=Uk({app:e?.app??null,destination:r.destination,view:r.view,setView:r.setView,entries:T.entries,canWrite:M}),[ae,oe]=(0,q.useState)(!1);Sf(I?e.app.window.navigation:null,{canGoBack:L.history.canGoBack,canGoForward:L.history.canGoForward,crumbs:L.crumbs,onBack:L.history.back,onForward:L.history.forward,onCrumb:e=>{L.history.open(e===`all`||e===`favorites`?{kind:e}:{kind:`folder`,folder:e===``?void 0:e})}});let[se,ce]=(0,q.useState)(Date.now),le=k.some(e=>e.startedAt!==void 0&&!e.resolved&&!e.error);(0,q.useEffect)(()=>{if(!le)return;let e=setInterval(()=>{ce(Date.now())},1e3);return()=>{clearInterval(e)}},[le]);let R=fp(e,(e,t,n)=>(T.refresh(),ne(e,t,n)));(0,q.useLayoutEffect)(()=>{x(void 0),R.target&&(_(null),y(null))},[R.target]);let ue=T.entries.some(e=>e.path===R.target?.path);(0,q.useEffect)(()=>{R.target&&!ue&&T.nextPageReady&&T.loadMore()},[R.target,ue,T.nextPageReady,T.loadMore]);let de=E.find(e=>e.source.kind===`computer`&&e.source.computerId===R.target?.computerId&&e.source.path===R.target.path),fe=NP(e?.app??null),pe=yP(e?.app??null),z=S_({connection:e,folder:r,styles:fe.styles,characters:pe.characters,effects:{reserve:ee,failed:N,notifyFailure:VP,saved:({result:e},t)=>{j?ne(e.destination.path,t,e.destination.computerId):N(`${e.destination.computerId}:${e.destination.path}`,`Image saved, but this App cannot read its preview.`)}}}),{state:B,models:V,modelsLoading:me,modelsError:he,canGenerate:ge,mediaCapability:_e,pendingGenerations:ve,activeGenerations:ye,recoveryError:H}=z,be=(0,q.useRef)(V),xe=(0,q.useRef)(z);xe.current=z;let Se=(0,q.useRef)(null),Ce=(0,q.useRef)(null),we=(0,q.useRef)(0),[Te,Ee]=(0,q.useState)(null),De=(0,q.useRef)([]),Oe=(0,q.useRef)(e=>z.submit(e,De.current));Oe.current=async e=>{let t=await z.submit(e,De.current);return t&&Ee(null),t};let ke=HP(Oe),Ae=e=>{ke.setFieldValue(`model`,e.model),ke.setFieldValue(`width`,e.width),ke.setFieldValue(`height`,e.height),ke.setFieldValue(`steps`,e.steps),ke.setFieldValue(`durationSeconds`,e.durationSeconds),ke.setFieldValue(`generateAudio`,e.generateAudio),ke.setFieldValue(`prompt`,e.prompt),ke.setFieldValue(`references`,e.references),ke.setFieldValue(`style`,e.style),ke.setFieldValue(`destination`,void 0)},je=(0,q.useRef)(ke);je.current=ke;let Me=Uv(ke.store,e=>e.values),Ne=pP(Me.references,Me.prompt,r.computerId);De.current=Ne;let Pe=vP(z.session,hP({draft:Me,model:Br(z.models,Me.model),styleText:fe.styles.find(e=>e.name===Me.style)?.text,characters:pe.characters,labels:Ne,computerId:r.computerId})),Fe=Uv(ke.store,e=>e.isSubmitting),Ie=e?.app;(0,q.useEffect)(()=>{if(Ie)return AP(Ie,{readDraft:()=>je.current.store.state.values,readModels:()=>be.current,setDraft:e=>{let t=je.current;if(e.model!==void 0){let n=Br(be.current,e.model);if(!n)throw Error(`Choose a model from the granted registry.`);let r=jr(t.store.state.values,n),i=Br(be.current,t.store.state.values.model),a=$r(t.store.state.values,n,i);t.setFieldValue(`model`,r.model),t.setFieldValue(`width`,a.width),t.setFieldValue(`height`,a.height),t.setFieldValue(`steps`,r.steps),t.setFieldValue(`durationSeconds`,r.durationSeconds),t.setFieldValue(`generateAudio`,r.generateAudio)}e.generateAudio!==void 0&&t.setFieldValue(`generateAudio`,e.generateAudio??void 0),e.destination!==void 0&&t.setFieldValue(`destination`,e.destination??void 0),e.height!==void 0&&t.setFieldValue(`height`,e.height),e.prompt!==void 0&&t.setFieldValue(`prompt`,e.prompt),e.references!==void 0&&t.setFieldValue(`references`,e.references),e.steps!==void 0&&t.setFieldValue(`steps`,e.steps??void 0),e.style!==void 0&&t.setFieldValue(`style`,e.style??void 0),e.width!==void 0&&t.setFieldValue(`width`,e.width)},submit:()=>je.current.store.state.isSubmitting||xe.current.isRunning()?Promise.resolve(!1):je.current.submitCurrent()})},[Ie]),(0,q.useEffect)(()=>{be.current=V},[V]),(0,q.useEffect)(()=>{if(V.length===0||he)return;let e=V.find(e=>e.id===`@cf/black-forest-labs/flux-2-klein-4b`)??Wr(V).at(0)??V[0];if(!ke.store.state.fieldMeta.model?.isTouched){let t=jr(ke.store.state.values,e);ke.setFieldValue(`model`,t.model),ke.store.state.fieldMeta.width?.isTouched||ke.setFieldValue(`width`,t.width),ke.store.state.fieldMeta.height?.isTouched||ke.setFieldValue(`height`,t.height),ke.store.state.fieldMeta.steps?.isTouched||ke.setFieldValue(`steps`,t.steps)}},[ke,he,V]);let Le=Br(V,Me.model),Re=Me.references,ze=Le?.input.maxReferences??0,Be=(0,q.useRef)({addComputerFile:ne,retryPath:z.retryPath,uploads:re});Be.current={addComputerFile:ne,retryPath:z.retryPath,uploads:re};let Ve=de?yg(de):null,U=(0,q.useMemo)(()=>E.map(e=>({key:yg(e),selected:yg(e)===Ve,path:e.source.kind===`computer`?e.source.path:e.file.name,referenced:Re.some(t=>e.source.kind===`computer`&&gi(t,e.source.computerId)&&t.path===e.source.path),referenceDisabled:Re.length>=ze&&!Re.some(t=>e.source.kind===`computer`&&gi(t,e.source.computerId)&&t.path===e.source.path),onToggleReference:e.source.kind===`computer`&&ze>0&&!mn(e.source.path)?()=>{if(e.source.kind!==`computer`)return;let t=e.source.path,n=e.source.computerId,r=Re.some(e=>gi(e,n)&&e.path===t);ke.setFieldValue(`references`,r?Re.filter(e=>!gi(e,n)||e.path!==t):[...Re,{path:t}])}:void 0,onInfo:()=>{_(e)},url:e.url,width:e.width,height:e.height,onOpen:()=>{_(null),y(yg(e))}})),[E,Re,ze,ke,Ve]),He=(0,q.useMemo)(()=>{let e=r.computerId;if(!e)return U;let t=new Map(U.map(e=>[e.key,e])),n=[...T.entries].sort((e,t)=>t.modifiedAt-e.modifiedAt||e.name.localeCompare(t.name)).map(n=>{let r=`${e}:${n.path}`;return{...t.get(r)??{key:r,path:n.path,width:1,height:1,url:``,pending:!0,pendingLabel:`Loading print…`,onOpen:()=>void 0,onVisible:()=>{T.loadFile(n.path)},error:D.includes(n.name)?`Could not load this print.`:void 0},onRetry:()=>{F(n.path)}}}),i=new Set(n.map(e=>e.key));return[...n,...U.filter(e=>!i.has(e.key)&&e.key!==Ve)]},[U,T.entries,T.loadFile,F,D,r.computerId,Ve]),Ue=I&&!(r.view.kind===`folder`&&!L.up)?r.view.kind===`all`?{title:`No prints yet`,description:`Prints in any folder of the library appear here.`}:r.view.kind===`favorites`?{title:`No favorites yet`,description:`Tap the heart on a print to keep it here for your whole Team.`}:{title:`Nothing in ${L.title} yet`,description:`New prints you make here land in it. You can also drop in images or move prints from another folder.`}:null,We=B.kind===`pending`,Ge=[...ye].sort().join(`|`),Ke=k.filter(e=>e.error!==void 0).length,qe=(0,q.useMemo)(()=>ve.filter(e=>e.reference.computerId===r.computerId&&!Ge.split(`|`).includes(e.reference.requestId)&&!k.some(t=>t.computerId===e.reference.computerId&&t.path===e.input.destination.path)).map(e=>({key:`${e.reference.computerId}:${e.input.destination.path}`,path:e.input.destination.path,width:1024,height:1280,url:``,pending:!0,error:e.failure?.message??`Stopped when Prints closed. Retry to run it again.`,prompt:e.typed.prompt,onOpen:()=>void 0,onRetry:()=>{xe.current.resume(e)},onDismiss:()=>{xe.current.discard(e)}})),[ve,r.computerId,Ge,k]),Je=(0,q.useMemo)(()=>[...qe,...nP(He,k,e=>{let t=re.items.find(t=>t.id===e.uploadId),r=e.error??(t?.status===`error`||t?.status===`cancelled`?t.message:void 0);return{key:e.key,path:e.path,width:e.width,height:r===void 0?e.height:Math.max(e.height,e.width*1.25),url:``,pending:!0,error:r,prompt:r===void 0?void 0:ve.find(t=>t.reference.computerId===e.computerId&&t.input.destination.path===e.path)?.typed.prompt??(Ke===1?z.failedPrompt:void 0),pendingLabel:t?.status===`complete`||B.kind===`completed`?`Loading preview…`:e.uploadId?`Uploading image…`:e.startedAt===void 0?e.pendingLabel:ci(V.find(e=>e.kind===`video`),se-e.startedAt,e.resumed),onOpen:()=>void 0,onRetry:r&&(j||t&&t.status!==`complete`)?()=>{if(P(e.key),t&&t.status!==`complete`){Be.current.uploads.retry(t.id);return}!e.uploadId&&Be.current.retryPath(e.path)||n.current&&Be.current.addComputerFile(e.path,n.current,e.computerId)}:void 0,onDismiss:r?()=>{te(e.key),e.uploadId&&Be.current.uploads.remove(e.uploadId)}:void 0}})],[qe,ve,Ke,z.failedPrompt,He,k,re.items,B.kind,j,V,se]),Ye=Fe||We,Xe=!i&&_e&&ge&&M&&C!==null&&B.kind===`ready`&&!me&&V.length>0,Ze=k.some(e=>e.error!==void 0),Qe=re.items.filter(e=>e.computerId===r.computerId),$e=B.kind===`error`&&he===null?{key:z.errorKey,mediaKind:B.mediaKind,message:B.message,billing:B.action===`billing`&&e?()=>{e.app.ui.openTeamBilling().catch(t=>{dn(`open-team-billing`,t),n.current===e&&z.reportRecoveryError(t)})}:void 0,prompt:z.failedPrompt,retry:Ze?z.retry:void 0,dismiss:Ze?()=>{for(let e of k)e.error!==void 0&&te(e.key);z.dismissFailed()}:void 0}:null,et=BM({connected:e!==null,mediaCapability:_e,modelsError:he,retryModels:z.retryModels,modelsLoading:me,models:V,canGenerate:ge,mediaSetupMissing:i,canWrite:M,generationError:$e,recoveryError:H,pendingGenerations:ve,activeGenerations:ye,gallerySlots:k,computerId:r.computerId,failed:D,uploadError:re.error,uploads:Qe,permissions:()=>{e?.app.ui.requestAppPermissions({}).catch(e=>{z.reportRecoveryError(e)})},resume:e=>{z.resume(e)},discard:e=>{z.discard(e)},retryUpload:e=>{re.retry(e)}});h.error&&et.push({key:`dismissal-storage`,group:`Setup`,tone:`warning`,blocking:!0,short:`Activity not saved`,title:`Activity not saved`,detail:h.error});let tt=h.visible(et),nt={generating:ye.size,uploading:Qe.filter(e=>e.status===`sending`||e.status===`queued`).length},rt={items:Qe.filter(e=>e.status===`sending`||e.status===`queued`).map(e=>({id:e.id,name:e.file.name,preview:{kind:`image`,url:e.previewUrl},progress:null,progressLabel:``,statusLabel:e.message,actions:{cancel:{label:`Cancel`,accessibleLabel:`Cancel ${e.file.name}`}}})),onCancel:e=>{re.cancel(e)},onRetry:e=>{re.retry(e)},onRemove:e=>{re.remove(e)}},it=new Set([...T.entries.map(e=>`${r.computerId??``}:${e.path}`),...E.map(e=>e.source.kind===`computer`?`${e.source.computerId}:${e.source.path}`:e.file.name)]).size,at=MM(tt,nt,d);bf(e?.app,[...r.available?[Wk(r.landingPath??r.path,{checking:r.busy&&r.path===null,editing:r.editing})]:[],...at===null?[]:[at],...A?[{kind:`text`,id:`prints`,text:`${String(it)} ${it===1?`print`:`prints`}`}]:[]],e=>e.itemId===`activity`?(m(e.anchor?.start),f(e=>!e),!0):e.itemId!==`folder`||!r.available?!1:(r.setEditing(!0),!0),t=>{dn(`prints.status.report`,t),e?.app.ui.showToast({message:`Prints couldn't update its status bar.`,tone:`error`}).catch(e=>{dn(`prints.status.toast`,e)})});let ot=E.flatMap(e=>e.source.kind===`computer`?[{path:e.source.path,url:e.url,width:e.width,height:e.height}]:[]),st=e=>{y(null),S.current+=1,x({key:e,requestId:`viewer-close-${String(S.current)}`,onFocus:()=>void 0})},ct=(t,n,i)=>(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(zP,{image:t,app:e?.app??null,referenceImages:ot,models:V,canAnimate:PP(V)!==void 0,download:i,library:I&&t.source.kind===`computer`&&r.destination!==null&&t.source.path.startsWith(`${r.destination}/`)?(()=>{let e=t.source.path,n=L.isFavorite(e);return{favorite:n,onToggleFavorite:()=>{L.toggleFavorite([e],!n)},onMove:M?()=>{L.setMoving([e])}:void 0}})():void 0,onIterate:(e,n)=>{if(t.source.kind!==`computer`)return null;let r=IP(e,{lineage:n,printComputerId:t.source.computerId,printPath:t.source.path,models:V,styles:fe.styles.map(e=>e.name),current:ke.store.state.values});return r.kind===`refused`?r.message:(Ae(r.draft),Ee(r.notice===null?null:{model:r.draft.model,message:r.notice}),_(null),v!==null&&st(yg(t)),null)},onClose:n},t.url)}),lt={label:`Upload images`,onSelect:()=>Ce.current?.click(),disabled:!M||C===null,disabledReason:`Choose a writable Computer and folder to upload images.`},ut=(0,J.jsx)(W,{variant:`ghost`,loading:a,onClick:l,children:`Set up image generation`});return(0,J.jsxs)(`main`,{ref:t,className:`h-full w-full flex flex-col overflow-hidden`,"data-app-pane":`media`,"data-generation-state":B.kind,"data-computer-capability":A?`connected`:`absent`,onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length&&M&&(e.preventDefault(),ie(t.map(e=>(we.current+=1,new File([e],`paste-${String(we.current)}-${hg(e.name)}`,{type:e.type,lastModified:e.lastModified})))))},children:[(0,J.jsx)(Vh,{id:`prints-generation-notices`}),(0,J.jsxs)(`div`,{className:`prints-library`,"data-library":I||void 0,children:[I&&r.destination?(0,J.jsx)(Mk,{app:e.app,root:r.destination,view:r.view,onView:L.history.open,canWrite:M,version:L.version,onNewFolder:e=>{L.setNewFolder({parent:e})},onDrop:(e,t)=>{L.move(e,t)},onRename:(e,t)=>{L.move([e],L.folderOf(r.destination??``,e),{name:t})},onMoveRows:L.setMoving}):null,(0,J.jsxs)(`div`,{className:`prints-library-main`,"data-selecting":L.selecting||void 0,children:[I?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Fk,{view:r.view,title:L.title,onUp:L.up,lastFolder:L.lastFolder,onOpen:L.history.open,onFolders:()=>{oe(!0)},selecting:L.selecting,onToggleSelect:()=>{L.setSelecting(!L.selecting)}}),L.selecting?(0,J.jsx)(Pk,{count:L.selected.size,total:T.entries.length,canWrite:M,onToggleAll:()=>{L.selectAll(L.selected.size===T.entries.length?[]:T.entries.map(e=>e.path))},onMove:()=>{L.setMoving([...L.selected])},onFavorite:()=>{L.toggleFavorite([...L.selected],!0)},onDone:()=>{L.setSelecting(!1)}}):null]}):null,I&&r.view.kind===`folder`&&w.gallery.folders.length>0?(0,J.jsx)(`div`,{className:`prints-folder-tiles`,role:`list`,"aria-label":`Folders`,children:w.gallery.folders.map(e=>(0,J.jsxs)(`button`,{type:`button`,role:`listitem`,className:`prints-folder-tile`,onClick:()=>{L.history.open({kind:`folder`,folder:r.view.kind===`folder`&&r.view.folder?`${r.view.folder}/${e}`:e})},children:[(0,J.jsx)(uh,{"aria-hidden":!0,size:18}),(0,J.jsx)(`span`,{children:e})]},e))}):null,(0,J.jsxs)(`div`,{className:`prints-gallery-region`,children:[(0,J.jsx)($m,{screen:!0,ref:Se,className:`prints-gallery-scroll flex-1 min-h-0`,"data-media-scroll":!0,"aria-busy":O||T.loading,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault();let t=Array.from(e.dataTransfer.files);t.length&&M&&ie(t)},children:(0,J.jsxs)(`div`,{className:`prints-gallery-content`,children:[Je.length>0?(0,J.jsx)(tP,{items:I?Je.map(L.enrich):Je,scrollRef:Se,focus:v===null?b??(de&&R.target?{key:`${R.target.computerId}:${R.target.path}`,requestId:R.target.requestId,onFocus:()=>{_(null),y(yg(de))}}:void 0):void 0}):O||T.loading?(0,J.jsx)(Ty,{"data-media-loading":!0,framed:!1,message:`Loading prints…`,detail:`Your library is on its way.`,variant:`wander`}):(0,J.jsx)(Cy,{"aria-live":`polite`,"data-absence":!0,"data-media-empty":!0,role:`status`,variant:`speech`,className:`prints-invitation`,visual:`blobs`,title:i?`Make and collect images`:Ue?.title??`Make your first print`,description:i?`Upload images to start your collection. Open any image to view or download it.`:Ue===null?r.computerId===null?`Your images will appear here.`:r.available&&C===null?`Pick a folder in the composer below, then describe something or drop in images.`:`Describe something and it lands here, or drop in images from your Computer.`:Ue.description,primaryAction:i?lt:void 0,actions:i?(0,J.jsxs)(`div`,{className:`prints-image-setup`,children:[(0,J.jsx)(`span`,{children:u}),ut]}):(0,J.jsx)(W,{variant:`ghost`,size:`sm`,disabled:!M||C===null,onClick:()=>Ce.current?.click(),children:`Upload images`}),suggestions:i?void 0:BP.map(e=>({label:e,disabled:!Xe,onSelect:()=>{ke.setFieldValue(`prompt`,e),t.current?.querySelector(`[data-generation-prompt]`)?.focus()}}))}),T.hasNextPage&&(0,J.jsx)(W,{variant:`ghost`,disabled:T.loading,onClick:T.loadMore,children:T.loading?`Loading images…`:`Load more images`})]})}),R.error?(0,J.jsx)(`p`,{role:`alert`,children:`Could not open this print. It may no longer be available on this Computer.`}):null,g&&(g.source.kind===`local`||g.source.connection===e&&g.source.computerId===r.computerId)?ct(g,()=>{_(null)}):null]})]})]}),I&&r.destination?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ik,{app:e.app,root:r.destination,canWrite:M,count:L.moving?.length??0,open:L.moving!==null,version:L.version,onClose:()=>{L.setMoving(null)},onMove:(e,t)=>{let n=L.moving??[];L.setMoving(null),L.setSelecting(!1),L.move(n,e,{create:t})}}),(0,J.jsx)(zk,{parent:L.newFolder?.parent,open:L.newFolder!==null,onClose:()=>{L.setNewFolder(null)},onCreate:e=>L.createFolder(L.newFolder?.parent,e)}),(0,J.jsx)(Fp,{open:ae,onOpenChange:oe,children:(0,J.jsxs)(Bp,{className:`prints-folders-dialog`,children:[(0,J.jsx)(Hp,{children:(0,J.jsx)(Up,{children:`Folders`})}),(0,J.jsx)(Mk,{app:e.app,root:r.destination,view:r.view,onView:e=>{L.history.open(e),oe(!1)},canWrite:M,version:L.version,onNewFolder:e=>{oe(!1),L.setNewFolder({parent:e})},onMoveRows:L.setMoving})]})})]}):null,(0,J.jsx)(a_,{items:Je,images:E,viewerKey:v,app:e?.app??null,onNavigate:y,onClose:st,renderInfo:(e,t)=>ct(e,t,null)}),i&&Je.length>0?(0,J.jsxs)(`div`,{className:`prints-library-actions`,children:[(0,J.jsx)(W,{size:`sm`,onClick:lt.onSelect,disabled:lt.disabled,children:`Upload images`}),ut,s?(0,J.jsx)(`div`,{className:`prints-image-setup`,children:u}):null]}):null,(0,J.jsxs)(`div`,{className:`prints-composer-dock`,children:[(0,J.jsx)(`section`,{"aria-label":`Computer uploads`,className:`prints-uploads`,children:(0,J.jsx)(`input`,{ref:Ce,type:`file`,disabled:!M||C===null,accept:`image/*`,multiple:!0,hidden:!0,"aria-label":`Choose images to upload`,onChange:e=>{ie(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}})}),i?null:(0,J.jsx)(GP,{addedLength:Le?.kind===`audio`?0:di(Me.prompt,fe.styles.find(e=>e.name===Me.style)?.text,pe.characters),styleControls:e=>({picker:(0,J.jsx)(LP,{styles:fe.styles,selected:Me.style,disabled:!_e||me||Ye,onSelect:e=>{ke.setFieldValue(`style`,e)}}),dialog:(0,J.jsx)(RP,{open:e.open,onOpenChange:e.onOpenChange,styles:fe.styles,selected:Me.style,busy:fe.busy,error:fe.error,onSelect:e=>{ke.setFieldValue(`style`,e)},onSave:fe.save,onDelete:(e,t)=>{fe.remove(e.id,t)}})}),characters:pe.characters,characterDialog:e=>(0,J.jsx)(CP,{open:e.open,onOpenChange:e.onOpenChange,characters:pe.characters,images:ot,busy:pe.busy,error:pe.error,canUpload:M&&C!==null,onUpload:()=>Ce.current?.click(),onSave:pe.save,onDelete:(e,t)=>{pe.remove(e.id,t)}}),guidance:tt.find(e=>e.blocking&&e.group===`Setup`)??(Te!==null&&Te.model===Me.model?{key:`iteration-model`,group:`Images`,tone:`warning`,short:`Model changed`,title:`Model changed`,detail:Te.message,actions:[{label:`Dismiss`,run:()=>{Ee(null)}}]}:void 0),commandApp:Ie,actions:(0,J.jsx)(bt,{"aria-label":`Upload images`,title:M?`Upload images to Computer`:`Connect a writable Computer to upload`,icon:(0,J.jsx)(Ch,{}),label:null,className:`prints-upload-key`,disabled:!M||C===null,onClick:()=>Ce.current?.click()}),form:ke,mediaCapability:_e&&ge&&M&&C!==null,models:V,modelsLoading:me,onSubmit:ke.submitCurrent,submitting:Ye,values:Me,computerId:r.computerId,mediaDirectory:C,referenceImages:ot,referenceLabels:Ne,price:Pe}),at===null?null:(0,J.jsx)(PM,{notices:tt,uploads:rt,open:d,inset:p,onOpenChange:f,onDismiss:h.dismiss,onDismissAll:()=>{h.dismissAll(et)},onLoadMore:z.hasMore?z.loadMore:void 0})]}),(0,J.jsx)(IM,{folder:r})]})}var qP=document.getElementById(`media-root`);if(!qP)throw Error(`Media root is missing`);hf(qP,{name:`Prints`,queryClient:lr()},({app:e})=>(0,q.createElement)(KP,{connection:e?{app:e}:null}));