offsite 0.0.91 → 0.0.92
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.
|
@@ -11,9 +11,9 @@ Error generating stack: `+e.message+`
|
|
|
11
11
|
`)[0];return(0,G.jsxs)(Mr,{className:`items-start`,onSelect:()=>Kf(l,e.id),onKeyDown:t=>{(t.key===`Delete`||t.key===`Backspace`)&&(t.preventDefault(),b(e.id))},children:[(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate`,children:n===``?`Attachments`:n}),(0,G.jsxs)(`span`,{className:`text-muted-foreground block text-xs`,children:[yn(e.createdAt),t>0&&` · ${t} attachment${t===1?``:`s`}`]})]}),(0,G.jsx)(U,{variant:`ghost-muted`,size:`icon-micro`,"aria-label":`Delete stashed prompt`,title:`Delete`,onClick:t=>{t.preventDefault(),t.stopPropagation(),b(e.id)},children:(0,G.jsx)(H,{icon:Go})})]},e.id)})})})]}),e.delivery!==null&&(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(Mr,{disabled:e.empty,onSelect:e.onSubmit,children:[(0,G.jsx)(H,{icon:e.delivery===`steer`?Rs:Vs}),(0,G.jsxs)(`span`,{className:`flex-1`,children:[e.delivery===`steer`&&`Queue`,e.delivery===`queue`&&`Send now`]}),(0,G.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[z,`+Enter`]})]})})]})}function $f(e){let t=e.item;switch(t.kind){case`file_change`:return(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.diffs.map((e,t)=>(0,G.jsx)(ap,{before:e.before,after:e.after},t))});case`todo_list`:return(0,G.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:t.steps.map((e,t)=>(0,G.jsxs)(`li`,{className:B(`text-secondary-label`,e.status===`completed`&&`text-muted-foreground line-through`,e.status===`running`&&`text-foreground`),children:[e.status===`completed`?`☑`:`☐`,` `,e.text]},t))});case`plan`:return(0,G.jsx)(ir,{text:t.plan});case`tool`:return tp(t.name)===`other`?(0,G.jsx)(ip,{text:JSON.stringify(t.input,null,2)}):null;default:return null}}function ep(e,t){switch(e.kind){case`command`:return e.command;case`file_change`:return sp(e.path,t);case`web_search`:return e.url??e.query??``;case`subagent`:return e.description;case`skill`:return e.skill;case`tool`:{let n=tp(e.name);return n===`read`?sp(np(e.input),t):n===`search`?op(e.input.pattern):``}default:return``}}function tp(e){switch(e.toLowerCase()){case`read`:return`read`;case`grep`:case`glob`:return`search`;default:return`other`}}function np(e){return[e.file_path,e.filePath,e.path].map(op).find(e=>e!==``)??``}function rp(e){let t=0,n=0;for(let r of e.diffs)for(let e of Hr(r.before,r.after))e.added&&(t+=e.count),e.removed&&(n+=e.count);return{added:t,removed:n}}function ip(e){return(0,G.jsx)(`pre`,{className:`text-foreground/80 text-2xs max-h-64 overflow-auto font-mono leading-relaxed whitespace-pre-wrap`,children:e.text})}function ap(e){return(0,G.jsx)(`pre`,{className:`border-border/60 text-2xs max-h-80 overflow-auto rounded-md border font-mono leading-relaxed`,children:Hr(e.before,e.after).flatMap((e,t)=>e.value.replace(/\n$/,``).split(`
|
|
12
12
|
`).map((n,r)=>(0,G.jsxs)(`div`,{className:B(`px-2 whitespace-pre-wrap`,e.added&&`bg-diff-addition/10 text-diff-addition`,e.removed&&`bg-diff-deletion/10 text-diff-deletion`,!e.added&&!e.removed&&`text-muted-foreground`),children:[e.added?`+`:e.removed?`-`:` `,` `,n]},`${t}:${r}`)))})}function op(e){return typeof e==`string`?e:``}function sp(e,t){return e.startsWith(t+`/`)||e.startsWith(t+`\\`)?e.slice(t.length+1):e}var cp=`(Recommended)`;function lp(e){let t=e.options.map(e=>e.label).filter(e=>e.endsWith(cp));return e.multiSelect?t:t.slice(0,1)}function up(e){return(0,G.jsxs)(`span`,{className:B(`mt-0.5 grid size-4 shrink-0 place-items-center border transition-colors`,e.multi?`rounded`:`rounded-full`,e.selected&&`border-primary bg-primary text-primary-foreground`,e.suggested&&`border-primary border-dashed`,!e.selected&&!e.suggested&&`border-muted-foreground/40`),children:[e.selected&&e.multi&&(0,G.jsx)(H,{icon:Un,strokeWidth:3,className:`size-3`}),e.selected&&!e.multi&&(0,G.jsx)(`span`,{className:`bg-primary-foreground size-1.5 rounded-full`})]})}function dp(e){let[t,n]=(0,W.useState)(Date.now);(0,W.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.ceil((e.at-t)/1e3));return(0,G.jsxs)(`span`,{className:`text-muted-foreground text-2xs mr-1 tabular-nums`,children:[e.label,` in`,` `,r<60?`${r}s`:`${Math.ceil(r/60)}m`]})}var fp=`composer-glass relative mx-auto -mb-[calc(1rem+1px)] w-[calc(100%-2.75rem)] rounded-t-2xl border border-b-0 px-1 pt-1 pb-[calc(1rem+1px+0.25rem)] text-xs/4`;function pp(e){let t=e.request;if(t.kind===`question`)return(0,G.jsx)(mp,{machine:e.machine,request:t,draft:e.draft});let n=t.kind===`plan`,r=n?``:ep(t.item,e.cwd);return(0,G.jsx)(`div`,{className:B(fp,`border-warning/28 bg-linear-to-b from-warning/8 to-warning/8`),children:(0,G.jsxs)(`div`,{className:`grid grid-cols-[1.5rem_minmax(0,1fr)_auto] items-start gap-x-2 gap-y-3 px-1 py-1`,children:[(0,G.jsx)(`span`,{className:`text-warning flex justify-center pt-0.5`,children:(0,G.jsx)(H,{icon:Ws,className:`size-4`})}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground text-2xs flex w-full min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-warning shrink-0 font-medium`,children:n?`Ready to code?`:t.title}),e.count>1&&(0,G.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:[`1/`,e.count]})]}),r!==``&&(0,G.jsx)(`span`,{className:`text-foreground block max-h-20 w-full min-w-0 overflow-auto font-mono text-xs whitespace-pre`,children:r})]}),(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[t.autoResolve!==void 0&&(0,G.jsx)(dp,{label:t.autoResolve.decision===`allow`?`Approve`:`Decline`,at:t.autoResolve.at}),(0,G.jsx)(U,{size:`xs`,variant:`outline`,onClick:()=>Ke(t.id,`deny`,null),children:n?`Keep planning`:`Decline`}),t.kind===`approval`&&t.canAlwaysAllow&&(0,G.jsx)(U,{size:`xs`,variant:`outline`,onClick:()=>Ke(t.id,`always`,null),children:`Always`}),(0,G.jsx)(U,{size:`xs`,onClick:()=>Ke(t.id,`allow`,null),children:n?`Approve plan`:`Approve`})]}),n&&(0,G.jsx)(`div`,{className:`col-span-3 max-h-60 overflow-auto px-1 empty:hidden`,children:(0,G.jsx)(ir,{text:t.plan})}),t.kind===`approval`&&t.item.kind!==`command`&&(0,G.jsx)(`div`,{className:`col-span-3 max-h-60 overflow-auto px-1 empty:hidden`,children:(0,G.jsx)($f,{item:t.item})})]})})}function mp(e){let t=e.request.questions,[n,r]=(0,W.useState)(0),[i,a]=(0,W.useState)({}),[o,s]=(0,W.useState)({}),l=Object.fromEntries(t.map(e=>[e.question,[...i[e.question]??[],o[e.question]?.trim()??``].filter(e=>e!==``)])),u=Object.fromEntries(t.map(e=>[e.question,(l[e.question].length>0?l[e.question]:lp(e)).join(`, `)])),d=t[n],f=t.flatMap((e,t)=>l[e.question].length===0?[t]:[]),p=f.find(e=>e>n)??f[0];function m(e,c){let l=i[e.question]??[];e.multiSelect?a({...i,[e.question]:l.includes(c)?l.filter(e=>e!==c):[...l,c]}):(a({...i,[e.question]:[c]}),s({...o,[e.question]:``}),n<t.length-1&&r(n+1))}function h(e,t){s({...o,[e.question]:t}),!e.multiSelect&&t.trim()!==``&&a({...i,[e.question]:[]})}async function g(t,n){let r=Nf(R().items,[e.draft,...Object.values(o)]);for(let i of n)try{let n=await kf(e.machine,i),o=n;i.type.startsWith(`image/`)&&(r+=1,o=`[Image #${r}] (saved at ${n})`),s(e=>{let n=e[t.question]??``;return{...e,[t.question]:`${n}${/(^|\s)$/.test(n)?``:` `}${o}`}}),t.multiSelect||a(e=>({...e,[t.question]:[]}))}catch(e){c(e)}}return(0,G.jsx)(`div`,{className:`composer-glass shadow-composer relative z-10 rounded-3xl border border-(--composer-outline)`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 p-2.5`,children:[(0,G.jsxs)(`div`,{role:`tabpanel`,className:`flex min-w-0 flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-start gap-1.5 pt-1 pr-1 pl-1.5`,children:[(0,G.jsx)(`span`,{className:`bg-primary/18 text-primary grid size-6 shrink-0 place-items-center rounded-md`,children:(0,G.jsx)(H,{icon:Es,className:`size-4`})}),(0,G.jsx)(`p`,{className:`text-foreground min-w-0 flex-1 pt-0.5 text-[15px] leading-5 font-medium`,children:d.question}),(0,G.jsx)(U,{size:`icon-micro`,variant:`ghost`,"aria-label":`Skip questions`,title:`Skip questions`,onClick:()=>Ke(e.request.id,`deny`,null),children:(0,G.jsx)(H,{icon:_t,className:`size-4`})})]}),(0,G.jsxs)(`div`,{role:d.multiSelect?`group`:`radiogroup`,"aria-label":d.question,className:`flex max-h-[min(18rem,32dvh)] flex-col gap-0.5 overflow-y-auto`,children:[d.options.map(e=>{let t=i[d.question]?.includes(e.label)===!0,n=l[d.question].length===0&&lp(d).includes(e.label),r=e.label.endsWith(cp);return(0,G.jsxs)(`button`,{role:d.multiSelect?`checkbox`:`radio`,"aria-checked":t,className:B(`flex cursor-pointer items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors`,t?`bg-muted/70`:`hover:bg-muted/40`),onClick:()=>m(d,e.label),children:[(0,G.jsx)(up,{multi:d.multiSelect,selected:t,suggested:n}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-foreground text-sm`,children:r?e.label.slice(0,-13).trim():e.label}),r&&(0,G.jsx)(`span`,{className:`text-muted-foreground/70 text-[11px]`,children:`Recommended`})]}),e.description!==``&&(0,G.jsx)(`span`,{className:`text-secondary-label mt-0.5 block text-xs leading-4`,children:e.description})]})]},e.label)}),(0,G.jsxs)(`label`,{className:B(`flex cursor-text items-start gap-2.5 rounded-lg px-2.5 py-2 transition-colors`,(o[d.question]??``).trim()===``?`focus-within:bg-muted/40 hover:bg-muted/40`:`bg-muted/70`),children:[(0,G.jsx)(up,{multi:d.multiSelect,selected:(o[d.question]??``).trim()!==``,suggested:!1}),(0,G.jsx)(`textarea`,{value:o[d.question]??``,rows:1,onChange:e=>h(d,e.target.value),onPaste:e=>{let t=e.clipboardData.getData(`text/plain`);if(t!==``){e.preventDefault(),document.execCommand(`insertText`,!1,t);return}let n=[...e.clipboardData.files];n.length!==0&&(e.preventDefault(),g(d,n))},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),g(d,[...e.dataTransfer.files])},placeholder:`Something else…`,className:`placeholder:text-placeholder/75 [field-sizing:content] max-h-40 min-w-0 flex-1 resize-none bg-transparent text-sm leading-5 outline-none`})]})]})]},d.question),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t.length>1&&(0,G.jsx)(`div`,{role:`tablist`,className:`flex min-w-0 [scrollbar-width:none] gap-1 overflow-x-auto`,children:t.map((e,t)=>(0,G.jsxs)(`button`,{role:`tab`,"aria-selected":t===n,className:B(`flex h-6 shrink-0 cursor-pointer items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,t===n?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`),onClick:()=>r(t),children:[l[e.question].length>0&&(0,G.jsx)(H,{icon:Jo,"aria-label":`Answered`,className:`text-success size-3.5`}),l[e.question].length===0&&u[e.question]!==``&&(0,G.jsx)(H,{icon:jr,"aria-label":`Using the recommended answer`,className:`text-primary size-3.5`}),u[e.question]===``&&(0,G.jsx)(H,{icon:ms,"aria-label":`Not answered`,className:`text-muted-foreground size-3.5`}),e.header]},e.question))}),(0,G.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1.5 pr-1`,children:[e.request.autoResolve!==void 0&&(0,G.jsx)(dp,{label:`Skip`,at:e.request.autoResolve.at}),(0,G.jsx)(U,{size:`xs`,variant:`outline`,onClick:()=>Ke(e.request.id,`allow`,{}),children:`Skip`}),(0,G.jsx)(U,{size:`xs`,variant:p===void 0?`default`:`outline`,onClick:()=>Ke(e.request.id,`allow`,Object.fromEntries(t.flatMap(e=>l[e.question].length===0?[]:[[e.question,l[e.question].join(`, `)]]))),children:`Submit`}),p!==void 0&&(0,G.jsx)(U,{size:`xs`,onClick:()=>{l[d.question].length===0&&a({...i,[d.question]:lp(d)}),r(p)},children:`Next`})]})]})]})})}function hp(e,t,n,r){if(e.key!==t&&e.key!==n)return;e.preventDefault();let i=[...e.currentTarget.querySelectorAll(r)];if(i.length===0)return;let a=i.findIndex(e=>e===document.activeElement),o=e.key===n?a+1:a-1;i[Math.min(Math.max(o,0),i.length-1)].focus()}function gp(e,t,n,r,i){let a=_p(e,n,r+Math.asin(.5/n)),o=_p(e,n,i-Math.asin(.5/n)),s=_p(e,t,i-Math.asin(.5/t)),c=_p(e,t,r+Math.asin(.5/t)),l=[a,o,s,c,...r<Math.PI/2&&i>Math.PI/2?[_p(e,n,Math.PI/2)]:[]],u=Math.min(...l.map(e=>e.x)),d=Math.min(...l.map(e=>e.y)),f=_p(e,(t+n)/2,(r+i)/2);return{style:{left:u,top:d,width:Math.max(...l.map(e=>e.x))-u,height:Math.max(...l.map(e=>e.y))-d,clipPath:`path('M${a.x-u} ${a.y-d} A${n} ${n} 0 0 0 ${o.x-u} ${o.y-d} L${s.x-u} ${s.y-d} A${t} ${t} 0 0 1 ${c.x-u} ${c.y-d}Z')`},center:{left:f.x-u,top:f.y-d}}}function _p(e,t,n){return{x:e+t*Math.cos(n),y:e-t*Math.sin(n)}}var vp=`relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-(--control-radius) border border-transparent outline-none hover:bg-accent data-[state=open]:bg-accent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-64 [&_svg]:pointer-events-none [&_svg]:shrink-0`,yp=`h-7 gap-1.5 px-1.5 text-sm font-medium text-secondary-label hover:text-foreground [&_svg:not([class*=text-])]:text-muted-foreground [&_svg:not([class*=size-])]:size-4`;function bp(e){let t=Math.min(190,(window.innerWidth-16)/2),[n,r]=(0,W.useState)(!1);return vr(e.shortcut,()=>r(!n),{enableOnFormTags:!0,preventDefault:!0}),(0,G.jsxs)(mn,{modal:e.options.length>5,open:n,onOpenChange:r,children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(`button`,{className:B(vp,yp),title:e.title,children:e.trigger})}),e.options.length>5&&(0,G.jsx)(Dn,{className:`w-72`,side:`top`,align:`start`,onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:(0,G.jsx)(xp,{value:e.value,options:e.options,radius:t,onChange:e.onChange})}),e.options.length<=5&&(0,G.jsx)(En,{children:(0,G.jsx)(Ln,{"data-slot":`dropdown-menu-content`,side:`top`,sideOffset:-28,className:`data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 pointer-events-none relative z-50 origin-(--radix-dropdown-menu-content-transform-origin) drop-shadow-[0_12px_28px_rgb(0_0_0/45%)] duration-100 outline-none`,style:{width:t*2,height:t},onOpenAutoFocus:In,onKeyDown:e=>hp(e,`ArrowLeft`,`ArrowRight`,`[role=menuitemradio]`),onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:(0,G.jsx)(xp,{value:e.value,options:e.options,radius:t,onChange:e.onChange})})})]})}function xp(e){return e.options.length>5?(0,G.jsx)(pn,{value:e.value,onValueChange:e.onChange,children:e.options.map(e=>(0,G.jsx)(Mn,{value:e.value,children:e.label},e.value))}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`bg-background pointer-events-auto absolute`,style:gp(e.radius,e.radius*.35,e.radius,0,Math.PI).style}),(0,G.jsx)(tn,{value:e.value,onValueChange:e.onChange,children:e.options.map((t,n)=>{let r=gp(e.radius,e.radius*.35,e.radius,Math.PI-(n+1)*Math.PI/e.options.length,Math.PI-n*Math.PI/e.options.length);return(0,G.jsx)(Jn,{value:t.value,className:B(`pointer-events-auto absolute cursor-pointer transition-colors outline-none`,t.value===e.value&&`text-foreground bg-[color-mix(in_srgb,var(--primary)_30%,var(--popover))]`,t.value!==e.value&&`bg-popover text-secondary-label data-highlighted:bg-accent data-highlighted:text-accent-foreground`),style:r.style,children:(0,G.jsx)(`span`,{className:`absolute -translate-x-1/2 -translate-y-1/2 text-sm font-medium whitespace-nowrap`,style:r.center,children:t.label})},t.value)})})]})}function Sp(){let e=k(e=>e.settings),t=k(e=>e.capabilities)?.models.find(t=>t.value===e.model);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Cp,{}),(0,G.jsx)(`span`,{className:`bg-border mx-0.5 hidden h-4 w-px shrink-0 sm:block`}),t!==void 0&&t.efforts.length>0&&(0,G.jsx)(bp,{title:`Effort`,shortcut:[`mod+shift+e`,`mod+slash`],trigger:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(H,{icon:Ho}),(0,G.jsx)(`span`,{className:`capitalize`,children:e.effort??`Default`})]}),value:e.effort??`default`,options:[...e.provider===`opencode`?[{value:`default`,label:`Default`}]:[],...t.efforts.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))],onChange:e=>rt({effort:e==="default"?null:e})})]})}function Cp(){let e=k(e=>e.settings),t=k(e=>e.selection),n=k(e=>e.machines.find(t=>t.id===e.selection?.machine)),r=[...[...n?.claudeAccounts??[],...n?.codexAccounts??[]].filter(e=>e.valid).map(e=>({key:e.id,provider:e.provider,accountId:e.id,name:e.name,color:e.color,plan:e.plan,error:e.error})),...n?.openCode.available===!0?[{key:`opencode`,provider:`opencode`,accountId:null,name:`OpenCode`,color:null,plan:null,error:null}]:[]].filter(n=>t?.sessionId===null||n.provider===e.provider),i=e.provider===`opencode`?`opencode`:e.accountId,a=k(e=>e.capabilities),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)({}),u=a?.models.find(t=>t.value===e.model)?.name??e.model??`Choose a model`,d=r.find(e=>e.key===i);return vr([`mod+shift+m`,`mod+period`],()=>s(!o),{enableOnFormTags:!0,preventDefault:!0}),(0,G.jsxs)(ln,{open:o,onOpenChange:s,children:[(0,G.jsx)(Sn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:B(vp,yp),title:d===void 0?`Model`:`${d.name} · ${u}`,children:[(0,G.jsxs)(`span`,{className:`relative`,children:[(0,G.jsx)(gc,{provider:e.provider,className:`size-4`}),r.filter(t=>t.provider===e.provider).length>1&&d!==void 0&&(0,G.jsx)(`span`,{className:B(`pointer-events-none absolute -right-1 -bottom-1 flex h-3 min-w-3 items-center justify-center rounded-full border px-0.5 text-[8px] leading-none font-semibold shadow-sm`,d.color===null?`bg-card text-muted-foreground`:`border-card text-white`),style:d.color===null?void 0:{backgroundColor:d.color},children:d.name.charAt(0).toUpperCase()})]}),(0,G.jsx)(`span`,{className:`max-w-40 truncate`,children:u})]})}),(0,G.jsx)(sn,{side:`top`,className:`w-screen max-w-90`,onOpenAutoFocus:e=>{if(e.preventDefault(),!(e.currentTarget instanceof HTMLElement))throw Error(`model picker is not an element`);let t=e.currentTarget;(t.querySelector(`input`)??t.querySelector(`[data-selected=true]`)??t.querySelector(`[data-model]`))?.focus()},onCloseAutoFocus:e=>{e.preventDefault(),document.querySelector(`[data-composer]`)?.focus()},children:(0,G.jsx)(wp,{choices:r,fetched:c,onFetched:l,onClose:()=>s(!1)})})]})}function wp(e){let t=k(e=>e.settings),n=k(e=>e.selection),r=k(e=>e.capabilities),i=t.provider===`opencode`?`opencode`:t.accountId,[a,o]=(0,W.useState)(i),[s,l]=(0,W.useState)(``),u=(0,W.useRef)(null),f=a===null?[]:a===i?r?.models??null:e.fetched[a]??null,p=e.choices.find(e=>e.key===a)?.provider,m=(f??[]).filter(e=>!e.hidden),h=m.length>=5,g=h?s.trim().toLowerCase():``,_=m.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(g)),v=(0,W.useEffectEvent)(()=>{if(n!==null)for(let t of e.choices)t.key!==i&&t.error===null&&L(n.machine,`capabilities`,{provider:t.provider,accountId:t.accountId,projectId:n.projectId}).then(n=>e.onFetched(e=>({...e,[t.key]:n.models})),c)});(0,W.useEffect)(()=>{v()},[]);function y(n){let a=e.fetched[n]?.find(e=>e.value===t.model);n!==i&&i!==null&&r!==null&&a!==void 0&&(e.onFetched(e=>({...e,[i]:r.models})),b(n,a)),o(n)}function b(r,i){let a=e.choices.find(e=>e.key===r);if(a===void 0||n===null)return;let o=a.provider,s={accountId:a.accountId,model:i.value,...i.effort===null?{}:{effort:i.effort}};mt(n.machine,o,a.accountId,i.value),o===t.provider?rt(s):rt({...ft(Ge(R(),n.machine).lastUsed,o),...s})}return(0,G.jsxs)(`div`,{tabIndex:-1,className:`flex max-h-86.5 flex-row outline-none`,onKeyDown:t=>{let n=document.activeElement===u.current&&s!==``;if(t.key!==`ArrowLeft`&&t.key!==`ArrowRight`||n){hp(t,`ArrowUp`,`ArrowDown`,`input, [data-model]`);return}t.preventDefault();let r=e.choices.filter(e=>e.error===null),i=r.findIndex(e=>e.key===a),o=t.key===`ArrowRight`?1:-1,c=r.at(Math.min(Math.max(i+o,0),r.length-1));c!==void 0&&c.key!==a&&(t.currentTarget.focus(),y(c.key))},children:[e.choices.length>1&&(0,G.jsxs)(`div`,{className:`bg-muted/30 flex w-11 shrink-0 [scrollbar-width:none] flex-col gap-1 overflow-y-auto p-1`,children:[e.choices.map(t=>(0,G.jsxs)(`div`,{className:`relative w-full`,children:[t.key===a&&(0,G.jsx)(`div`,{className:`bg-primary pointer-events-none absolute top-1/2 -right-1 z-10 h-5 w-0.75 -translate-y-1/2 rounded-l-full`}),(0,G.jsx)(Xr,{side:`left`,label:t.error===null?[t.name,t.plan].filter(e=>e!==null).join(` · `):`${t.name} — ${t.error}`,children:(0,G.jsxs)(`button`,{className:B(`hover:bg-foreground/10 focus-visible:bg-foreground/10 relative flex aspect-square w-full cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-none`,t.error!==null&&`cursor-not-allowed opacity-50 hover:bg-transparent`),"aria-label":t.name,"aria-pressed":t.key===a,"aria-disabled":t.error!==null,onClick:()=>{t.error===null&&y(t.key)},children:[(0,G.jsx)(gc,{provider:t.provider,className:`size-5`}),e.choices.filter(e=>e.provider===t.provider).length>1&&(0,G.jsx)(`span`,{className:B(`text-3xs pointer-events-none absolute right-0.5 bottom-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full border px-0.5 leading-none font-semibold shadow-sm`,t.color===null?`bg-card text-muted-foreground`:`border-card text-white`),style:t.color===null?void 0:{backgroundColor:t.color},children:t.name.charAt(0).toUpperCase()})]})})]},t.key)),(0,G.jsx)(Xr,{side:`left`,label:`Manage accounts`,children:(0,G.jsx)(`button`,{className:`text-muted-foreground hover:bg-foreground/10 hover:text-foreground focus-visible:bg-foreground/10 mt-auto flex aspect-square w-full shrink-0 cursor-pointer items-center justify-center rounded-md transition-colors focus-visible:outline-none`,"aria-label":`Manage accounts`,onClick:()=>{e.onClose(),d(Se[t.provider])},children:(0,G.jsx)(H,{icon:ac,className:`size-4.5`})})})]}),(0,G.jsxs)(`div`,{className:B(`bg-muted/40 flex min-h-0 min-w-0 flex-1 flex-col`,e.choices.length>1&&`border-border/70 border-l`),children:[h&&(0,G.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5`,children:(0,G.jsxs)(`div`,{className:`border-border/70 focus-within:border-ring relative border-b pb-1.5 transition-colors`,children:[(0,G.jsx)(H,{icon:br,className:`text-muted-foreground/55 pointer-events-none absolute top-1.5 left-0 size-4`}),(0,G.jsx)(`input`,{ref:u,value:s,placeholder:`Search models...`,className:`placeholder:text-muted-foreground/70 h-6.5 w-full bg-transparent ps-5 text-sm outline-none`,onChange:e=>l(e.target.value),onKeyDown:t=>{if(t.key!==`Enter`||a===null)return;let n=_.at(0);n!==void 0&&(t.preventDefault(),b(a,n),e.onClose())}})]})}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 py-1.5`,children:_.length===0?(0,G.jsx)(`p`,{className:`text-muted-foreground p-2 text-center text-sm`,children:f===null?`Loading models…`:`No models found`}):_.map(n=>(0,G.jsx)(`button`,{"data-model":!0,"data-selected":a===i&&n.value===t.model,className:B(`hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground mb-0.5 outline-none flex min-h-8 w-full cursor-pointer flex-col justify-center rounded-sm px-2 py-1.5 text-left`,a===i&&n.value===t.model&&`text-foreground bg-foreground/[0.08]`),onClick:()=>{a!==null&&(b(a,n),e.onClose())},children:(0,G.jsxs)(`span`,{className:`truncate text-sm leading-snug font-medium`,children:[n.name,p===`opencode`&&(0,G.jsx)(`span`,{className:`text-muted-foreground ml-2 text-xs font-normal`,children:n.description})]})},n.value))})]})]})}function Tp({className:e,type:t,...n}){return(0,G.jsx)(`input`,{type:t,"data-slot":`input`,className:B(`h-9 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-[color,background-color,border-color,box-shadow] duration-200 ease-out outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/33 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...n})}function Ep({className:e,...t}){return(0,G.jsx)(bc,{"data-slot":`label`,className:B(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var Dp={216:`O`,223:`s`,248:`o`,273:`d`,295:`h`,305:`i`,320:`l`,322:`l`,359:`t`,383:`s`,384:`b`,385:`B`,387:`b`,390:`O`,392:`c`,393:`D`,394:`D`,396:`d`,398:`E`,400:`E`,402:`f`,403:`G`,407:`I`,409:`k`,410:`l`,412:`M`,413:`N`,414:`n`,415:`O`,421:`p`,427:`t`,429:`t`,430:`T`,434:`V`,436:`y`,438:`z`,477:`e`,485:`g`,544:`N`,545:`d`,549:`z`,564:`l`,565:`n`,566:`t`,567:`j`,570:`A`,571:`C`,572:`c`,573:`L`,574:`T`,575:`s`,576:`z`,579:`B`,580:`U`,581:`V`,582:`E`,583:`e`,584:`J`,585:`j`,586:`Q`,587:`q`,588:`R`,589:`r`,590:`Y`,591:`y`,592:`a`,593:`a`,595:`b`,596:`o`,597:`c`,598:`d`,599:`d`,600:`e`,603:`e`,604:`e`,605:`e`,606:`e`,607:`j`,608:`g`,609:`g`,610:`G`,613:`h`,614:`h`,616:`i`,618:`I`,619:`l`,620:`l`,621:`l`,623:`m`,624:`m`,625:`m`,626:`n`,627:`n`,628:`N`,629:`o`,633:`r`,634:`r`,635:`r`,636:`r`,637:`r`,638:`r`,639:`r`,640:`R`,641:`R`,642:`s`,647:`t`,648:`t`,649:`u`,651:`v`,652:`v`,653:`w`,654:`y`,655:`Y`,656:`z`,657:`z`,663:`c`,665:`B`,666:`e`,667:`G`,668:`H`,669:`j`,670:`k`,671:`L`,672:`q`,686:`h`,867:`a`,868:`e`,869:`i`,870:`o`,871:`u`,872:`c`,873:`d`,874:`h`,875:`m`,876:`r`,877:`t`,878:`v`,879:`x`,7424:`A`,7427:`B`,7428:`C`,7429:`D`,7431:`E`,7432:`e`,7433:`i`,7434:`J`,7435:`K`,7436:`L`,7437:`M`,7438:`N`,7439:`O`,7440:`O`,7441:`o`,7442:`o`,7443:`o`,7446:`o`,7447:`o`,7448:`P`,7449:`R`,7450:`R`,7451:`T`,7452:`U`,7453:`u`,7454:`u`,7455:`m`,7456:`V`,7457:`W`,7458:`Z`,7522:`i`,7523:`r`,7524:`u`,7525:`v`,7834:`a`,7835:`s`,8305:`i`,8341:`h`,8342:`k`,8343:`l`,8344:`m`,8345:`n`,8346:`p`,8347:`s`,8348:`t`,8580:`c`};for(let e=`̀`.codePointAt(0);e<=`ͯ`.codePointAt(0);++e){let t=String.fromCodePoint(e);for(let e of`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`){let n=(e+t).normalize().codePointAt(0);n>126&&(Dp[n]=e)}}var Op={a:[7844,7863],e:[7870,7879],o:[7888,7907],u:[7912,7921]};for(let e of Object.keys(Op)){let t=e.toUpperCase();for(let n=Op[e][0];n<=Op[e][1];++n)Dp[n]=n%2==0?t:e}function kp(e){if(e<192||e>8580)return e;let t=Dp[e];return t===void 0?e:t.codePointAt(0)}function Ap(e){return e}function jp(e){return e}function Mp(e,t){return e>t?e:t}var Np=e=>e.split(``).map(e=>e.codePointAt(0)),Pp=new Set(` \f
|
|
13
13
|
\r \v\xA0 \u2028\u2029 `.split(``).map(e=>e.codePointAt(0)));for(let e=` `.codePointAt(0);e<=` `.codePointAt(0);e++)Pp.add(e);var Fp=``.codePointAt(0),Ip=`A`.codePointAt(0),Lp=`Z`.codePointAt(0),Rp=`a`.codePointAt(0),zp=`z`.codePointAt(0),Bp=`0`.codePointAt(0),Vp=`9`.codePointAt(0);function Hp(e,t,n){return n?e:t-e-1}var Up=16,Wp=-3,Gp=-1,Kp=Up/2,qp=Up/2,Jp=7,Yp=4,Xp=2;function Zp(e){return e?new Set:null}function Qp(e,t,n){if(t!==null&&t.i16.length>e+n){let r=t.i16.subarray(e,e+n);return[e+n,r]}return[e,new Int16Array(n)]}function $p(e,t,n){if(t!==null&&t.i32.length>e+n){let r=t.i32.subarray(e,e+n);return[e+n,r]}return[e,new Int32Array(n)]}function em(e){return e>=Rp&&e<=zp?1:e>=Ip&&e<=Lp?2:e>=Bp&&e<=Vp?4:0}function tm(e){let t=String.fromCodePoint(e);return t===t.toUpperCase()?t===t.toLowerCase()?t.match(/\p{Number}/gu)===null?t.match(/\p{Letter}/gu)===null?0:3:4:2:1}function nm(e){return e<=Fp?em(e):tm(e)}function rm(e,t){return e===0&&t!==0?Kp:e===1&&t===2||e!==4&&t===4?Jp:t===0?qp:0}function im(e,t){return t===0?Kp:rm(nm(e[t-1]),nm(e[t]))}function am(e,t,n,r){let i=e.slice(r),a=i.indexOf(n);if(a===0)return r;if(!t&&n>=Rp&&n<=zp){a>0&&(i=i.slice(0,a));let e=i.indexOf(n-32);e>=0&&(a=e)}return a<0?-1:r+a}function om(e){for(let t of e)if(t>=128)return!1;return!0}function sm(e,t,n){if(!om(e))return 0;if(!om(t))return-1;let r=0,i=0;for(let a=0;a<t.length;a++){if(i=am(e,n,t[a],i),i<0)return-1;a===0&&i>0&&(r=i-1),i++}return r}var cm=(e,t,n,r,i,a,o)=>{let s=i.length;if(s===0)return[{start:0,end:0,score:0},Zp(a)];let c=r.length;if(o!==null&&c*s>o.i16.length)return um(e,t,n,r,i,a);let l=sm(r,i,e);if(l<0)return[{start:-1,end:-1,score:0},null];let u=0,d=0,f=null,p=null,m=null,h=null;[u,f]=Qp(u,o,c),[u,p]=Qp(u,o,c),[u,m]=Qp(u,o,c),[d,h]=$p(d,o,s);let[,g]=$p(d,o,c);for(let e=0;e<g.length;e++)g[e]=r[e];let _=Ap(0),v=0,y=0,b=0,x=i[0],S=i[0],C=Ap(0),w=0,T=!1,E=g.subarray(l),D=f.subarray(l).subarray(0,E.length),O=p.subarray(l).subarray(0,E.length),k=m.subarray(l).subarray(0,E.length);for(let[r,a]of E.entries()){let o=null;a<=Fp?(o=em(a),!e&&o===2&&(a+=32)):(o=tm(a),!e&&o===2&&(a=String.fromCodePoint(a).toLowerCase().codePointAt(0)),t&&(a=kp(a))),E[r]=a;let c=rm(w,o);if(k[r]=c,w=o,a===S&&(y<s&&(h[y]=jp(l+r),y++,S=i[Math.min(y,s-1)]),b=l+r),a===x){let e=Up+c*Xp;if(D[r]=e,O[r]=1,s===1&&(n&&e>_||!n&&e>=_)&&(_=e,v=l+r,n&&c===Kp))break;T=!1}else D[r]=Mp(T?C+Gp:C+Wp,0),O[r]=0,T=!0;C=D[r]}if(y!==s)return[{start:-1,end:-1,score:0},null];if(s===1){let e={start:v,end:v+1,score:_};if(!a)return[e,null];let t=new Set;return t.add(v),[e,t]}let A=h[0],j=b-A+1,M=null;[u,M]=Qp(u,o,j*s);{let e=f.subarray(A,b+1);for(let[t,n]of e.entries())M[t]=n}let[,N]=Qp(u,o,j*s);{let e=p.subarray(A,b+1);for(let[t,n]of e.entries())N[t]=n}let ee=h.subarray(1),te=i.slice(1).slice(0,ee.length);for(let[e,t]of ee.entries()){let r=!1,i=te[e],a=e+1,o=a*j,c=g.subarray(t,b+1),l=m.subarray(t).subarray(0,c.length),u=N.subarray(o+t-A).subarray(0,c.length),d=N.subarray(o+t-A-1-j).subarray(0,c.length),f=M.subarray(o+t-A).subarray(0,c.length),p=M.subarray(o+t-A-1-j).subarray(0,c.length),h=M.subarray(o+t-A-1).subarray(0,c.length);h[0]=0;for(let[e,o]of c.entries()){let c=e+t,g=0,y=0,b=0;if(y=r?h[e]+Gp:h[e]+Wp,i===o){g=p[e]+Up;let t=l[e];b=d[e]+1,t===Kp?b=1:b>1&&(t=Mp(t,Mp(Yp,m[c-b+1]))),g+t<y?(g+=l[e],b=0):g+=t}u[e]=b,r=g<y;let x=Mp(Mp(g,y),0);a===s-1&&(n&&x>_||!n&&x>=_)&&(_=x,v=c),f[e]=x}}let ne=Zp(a),re=A;if(a&&ne!==null){let e=s-1;re=v;let t=!0;for(;;){let n=e*j,r=re-A,i=M[n+r],a=0,o=0;if(e>0&&re>=h[e]&&(a=M[n-j+r-1]),re>h[e]&&(o=M[n+r-1]),i>a&&(i>o||i===o&&t)){if(ne.add(re),e===0)break;e--}t=N[n+r]>1||n+j+r+1<N.length&&N[n+j+r+1]>0,re--}}return[{start:re,end:v+1,score:_},ne]};function lm(e,t,n,r,i,a,o){let s=0,c=0,l=!1,u=0,d=Ap(0),f=Zp(o),p=0;i>0&&(p=nm(n[i-1]));for(let m=i;m<a;m++){let i=n[m],a=nm(i);if(e||(i>=Ip&&i<=Lp?i+=32:i>Fp&&(i=String.fromCodePoint(i).toLowerCase().codePointAt(0))),t&&(i=kp(i)),i===r[s]){o&&f!==null&&f.add(m),c+=Up;let e=rm(p,a);u===0?d=e:(e===Kp&&(d=e),e=Mp(Mp(e,d),Yp)),c+=s===0?e*Xp:e,l=!1,u++,s++}else c+=l?Gp:Wp,l=!0,u=0,d=0;p=a}return[c,f]}var um=(e,t,n,r,i,a,o)=>{if(i.length===0)return[{start:0,end:0,score:0},null];if(sm(r,i,e)<0)return[{start:-1,end:-1,score:0},null];let s=0,c=-1,l=-1,u=r.length,d=i.length;for(let a=0;a<u;a++){let o=r[Hp(a,u,n)];e||(o>=Ip&&o<=Lp?o+=32:o>Fp&&(o=String.fromCodePoint(o).toLowerCase().codePointAt(0))),t&&(o=kp(o));let f=i[Hp(s,d,n)];if(o===f&&(c<0&&(c=a),s++,s===d)){l=a+1;break}}if(c>=0&&l>=0){s--;for(let t=l-1;t>=c;t--){let a=r[Hp(t,u,n)];e||(a>=Ip&&a<=Lp?a+=32:a>Fp&&(a=String.fromCodePoint(a).toLowerCase().codePointAt(0)));let o=i[Hp(s,d,n)];if(a===o&&(s--,s<0)){c=t;break}}if(!n){let e=c;c=u-l,l=u-e}let[o,f]=lm(e,t,r,i,c,l,a);return[{start:c,end:l,score:o},f]}return[{start:-1,end:-1,score:0},null]},dm=(e,t,n,r,i,a,o)=>{if(i.length===0)return[{start:0,end:0,score:0},null];let s=r.length,c=i.length;if(s<c||sm(r,i,e)<0)return[{start:-1,end:-1,score:0},null];let l=0,u=-1,d=Ap(0),f=Ap(-1);for(let a=0;a<s;a++){let o=Hp(a,s,n),p=r[o];e||(p>=Ip&&p<=Lp?p+=32:p>Fp&&(p=String.fromCodePoint(p).toLowerCase().codePointAt(0))),t&&(p=kp(p));let m=Hp(l,c,n);if(i[m]===p){if(m===0&&(d=im(r,o)),l++,l===c){if(d>f&&(u=a,f=d),d===Kp)break;a-=l-1,l=0,d=0}}else a-=l,l=0,d=0}if(u>=0){let a=0,o=0;n?(a=u-c+1,o=u+1):(a=s-(u+1),o=s-(u-c+1));let[l]=lm(e,t,r,i,a,o,!1);return[{start:a,end:o,score:l},null]}return[{start:-1,end:-1,score:0},null]},fm=102400,pm=2048;function mm(e,t){return{i16:new Int16Array(e),i32:new Int32Array(t)}}var hm=mm(fm,pm),gm=(e,t,n)=>{let r=!1;switch(t){case`smart-case`:e.toLowerCase()!==e&&(r=!0);break;case`case-sensitive`:r=!0;break;case`case-insensitive`:e=e.toLowerCase(),r=!1}let i=Np(e);return n&&(i=i.map(kp)),{queryRunes:i,caseSensitive:r}};function _m(e,t){let n=Object.keys(e).map(e=>parseInt(e,10)).sort((e,t)=>t-e),r=[];for(let i of n)if(r=r.concat(e[i]),r.length>=t)break;return r}function vm(e,t,n){return r=>{let i=this.runesList[r];if(t.length>i.length)return;let[a,o]=this.algoFn(n,this.opts.normalize,this.opts.forward,i,t,!0,hm);if(a.start===-1)return;if(this.opts.fuzzy===!1){o=new Set;for(let e=a.start;e<a.end;++e)o.add(e)}let s=this.opts.sort?a.score:0;e[s]===void 0&&(e[s]=[]),e[s].push({item:this.items[r],...a,positions:o??new Set})}}function ym(e){let{queryRunes:t,caseSensitive:n}=gm(e,this.opts.casing,this.opts.normalize),r={},i=vm.bind(this)(r,t,n);for(let e=0,t=this.runesList.length;e<t;++e)i(e);return _m(r,this.opts.limit)}var bm={limit:1/0,selector:e=>e,casing:`smart-case`,normalize:!0,fuzzy:`v2`,tiebreakers:[],sort:!0,forward:!0},xm=class{constructor(e,...t){switch(this.opts={...bm,...t[0]},this.items=e,this.runesList=e.map(e=>Np(this.opts.selector(e).normalize())),this.algoFn=dm,this.opts.fuzzy){case`v2`:this.algoFn=cm;break;case`v1`:this.algoFn=um}}},Sm={...bm,match:ym},Cm=class extends xm{constructor(e,...t){super(e,...t),this.opts={...Sm,...t[0]}}find(e){return e.length===0||this.items.length===0?this.items.slice(0,this.opts.limit).map(wm):(e=e.normalize(),Tm(this.opts.match.bind(this)(e),this.opts))}};({...bm});var wm=e=>({item:e,start:-1,end:-1,score:0,positions:new Set});function Tm(e,t){if(t.sort){let{selector:n}=t;e.sort((e,r)=>{if(e.score===r.score)for(let i of t.tiebreakers){let t=i(e,r,n);if(t!==0)return t}return 0})}return Number.isFinite(t.limit)&&e.splice(t.limit),e}function Em(e,t,n){return n(e.item).length-n(t.item).length}var Dm=class{constructor(e,...t){this.finder=new Cm(e,...t),this.find=this.finder.find.bind(this.finder)}};function Om(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(``),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(null),l=a===``?``:`${a}/`,u=(t??[]).filter(e=>e.startsWith(l)).map(e=>e.slice(l.length)),d=[...new Set(u.filter(e=>e.includes(`/`)).map(e=>e.split(`/`)[0]))].sort((e,t)=>e.localeCompare(t)),f=r===``?u.filter(e=>!e.includes(`/`)).sort((e,t)=>e.localeCompare(t)).map(e=>`${l}${e}`):new Dm(t??[],{limit:50,casing:`case-insensitive`,tiebreakers:[(e,t)=>km(t)-km(e),Em]}).find(r).map(e=>e.item);return(0,W.useEffect)(()=>{let t=!1;return(async()=>{try{let r=await L(e.machine,`projects.logoFiles`,{id:e.projectId});t||n(r)}catch(e){t||c(Ht(e))}})(),()=>{t=!0}},[e.machine,e.projectId]),(0,G.jsx)(oi,{open:!0,onOpenChange:()=>e.onClose(),children:(0,G.jsxs)($r,{className:`gap-0 overflow-hidden p-0 sm:max-w-lg`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,G.jsx)(ri,{className:`sr-only`,children:`Pick icon`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 border-b p-1`,children:[(0,G.jsxs)(`label`,{className:`flex h-7 min-w-0 flex-1 items-center gap-2.5 px-2`,children:[(0,G.jsx)(H,{icon:br,className:`text-muted-foreground size-4 flex-none`}),(0,G.jsx)(`input`,{className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none`,placeholder:`Search images in this project`,value:r,onChange:e=>i(e.target.value)})]}),(0,G.jsx)(ni,{asChild:!0,children:(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,children:(0,G.jsx)(H,{icon:Go})})})]}),r===``&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1 border-b p-1`,children:[(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Parent folder`,disabled:a===``,onClick:()=>o(a.split(`/`).slice(0,-1).join(`/`)),children:(0,G.jsx)(H,{icon:kr})}),(0,G.jsxs)(`span`,{className:`truncate px-1.5 font-mono text-xs`,children:[`/`,a]})]}),(0,G.jsxs)(`div`,{className:`h-72 overflow-y-auto p-1`,children:[r===``&&d.map(e=>(0,G.jsxs)(`button`,{className:`hover:bg-muted flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm transition-colors`,onClick:()=>o(`${l}${e}`),children:[(0,G.jsx)(H,{icon:lr,className:`text-muted-foreground size-4 flex-none`}),(0,G.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e})]},e)),f.map(t=>(0,G.jsxs)(`button`,{className:`hover:bg-muted flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm transition-colors`,onClick:async()=>{try{let n=await L(e.machine,`files.read`,{projectId:e.projectId,path:t});n.kind===`image`?e.onPick(`data:${n.mediaType};base64,${n.data}`):n.kind===`large`?c(`${t} is too large`):c(`${t} is not an image`)}catch(e){c(Ht(e))}},children:[(0,G.jsx)(H,{icon:qn,className:`text-muted-foreground size-4 flex-none`}),(0,G.jsx)(`span`,{className:`truncate font-mono text-xs`,children:r===``?t.slice(l.length):t})]},t)),t?.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground grid h-full place-items-center text-sm`,children:`No images in this project`}),t!==null&&t.length>0&&r!==``&&f.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground grid h-full place-items-center text-sm`,children:`No matching images`})]}),s!==null&&(0,G.jsx)(`p`,{className:`text-destructive border-t px-3 py-2 text-sm break-all`,children:s})]})})}function km(e){let t=e.item.lastIndexOf(`/`)+1;return[...e.positions].filter(e=>e>=t).length}function Am(e){let t=k(e=>e.machines),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(()=>jm(t.find(t=>t.id===e.machine))),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(!1),f=o.trim()===``?void 0:n?.listing,p=f?.directories.filter(e=>e.name.toLowerCase().includes(c.toLowerCase()));function m(e){s(e),l(``)}return(0,W.useEffect)(()=>{if(o.trim()===``)return;let t=!1,n=setTimeout(async()=>{try{let n=await L(e.machine,`directories.list`,{path:o});if(t)return;r({path:o,listing:n}),a(null)}catch(e){if(t)return;r(null),a(Ht(e))}},150);return()=>{t=!0,clearTimeout(n)}},[e.machine,o]),(0,G.jsx)(oi,{open:!0,onOpenChange:()=>e.onClose(),children:(0,G.jsxs)($r,{className:`gap-0 overflow-hidden p-0 sm:max-w-lg`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,G.jsx)(ri,{className:`sr-only`,children:`Add project`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 border-b p-1`,children:[(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Home folder`,onClick:()=>m(`~`),children:(0,G.jsx)(H,{icon:gs})}),(0,G.jsx)(`div`,{className:`bg-border mx-0.5 h-4 w-px`}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Parent folder`,disabled:f?.parent===void 0||f.parent===null,onClick:()=>{f?.parent!==void 0&&f.parent!==null&&m(f.parent)},children:(0,G.jsx)(H,{icon:kr})}),(0,G.jsx)(`input`,{"aria-label":`Folder path`,className:`hover:bg-muted focus:bg-muted h-7 min-w-0 flex-1 rounded-md bg-transparent px-1.5 font-mono text-xs outline-none`,spellCheck:!1,value:o,onChange:e=>m(e.target.value)}),(0,G.jsx)(ni,{asChild:!0,children:(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,children:(0,G.jsx)(H,{icon:Go})})})]}),(0,G.jsxs)(`label`,{className:`flex h-9 items-center gap-2.5 border-b px-3`,children:[(0,G.jsx)(H,{icon:br,className:`text-muted-foreground size-4 flex-none`}),(0,G.jsx)(`input`,{className:`placeholder:text-muted-foreground min-w-0 flex-1 bg-transparent text-sm outline-none`,placeholder:`Search this folder`,value:c,onChange:e=>l(e.target.value)})]}),(0,G.jsxs)(`div`,{className:`h-72 overflow-y-auto p-1`,children:[p?.map(e=>(0,G.jsxs)(`button`,{className:`hover:bg-muted flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm transition-colors`,onClick:()=>m(e.path),children:[(0,G.jsx)(H,{icon:lr,className:`text-muted-foreground size-4 flex-none`}),(0,G.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),p?.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground grid h-full place-items-center text-sm`,children:c===``?`No folders here`:`No matching folders`})]}),i!==null&&o.trim()!==``&&(0,G.jsx)(`p`,{className:`text-destructive border-t px-3 py-2 text-sm break-all`,children:i}),(0,G.jsx)(si,{className:`border-t p-3`,children:(0,G.jsx)(U,{disabled:n?.path!==o||u,onClick:async()=>{if(n!==null&&n.path===o){d(!0);try{e.onAdd({...await lc(e.machine,n.listing.path),machine:e.machine})}catch(e){a(Ht(e)),d(!1)}}},children:`Add project`})})]})})}function jm(e){return e===void 0||e.config===null||e.system===null?`~`:e.config.workingDir[e.system.platform]??`~`}function Mm(e){let t=e.project.path,[n,r]=(0,W.useState)(e.project.name),[i,a]=(0,W.useState)(e.project.logo),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1),m=(0,W.useRef)(null);return(0,G.jsx)(oi,{open:!0,onOpenChange:()=>e.onClose(),children:(0,G.jsxs)($r,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,children:[(0,G.jsxs)(`form`,{className:`grid`,onSubmit:async t=>{t.preventDefault(),l(!0);try{await uc(e.project.machine,e.project.id,{name:n,logo:i===e.project.logo?void 0:i}),e.onClose()}catch(e){s(Ht(e)),l(!1)}},children:[(0,G.jsxs)(ei,{className:`gap-1 px-6 pt-4 pr-12`,children:[(0,G.jsx)(ri,{className:`text-base`,children:`Edit project`}),(0,G.jsx)(ii,{className:`truncate font-mono text-xs`,title:t,children:t})]}),(0,G.jsxs)(`div`,{className:`grid gap-6 p-6`,children:[(0,G.jsxs)(`div`,{className:`grid gap-2.5`,children:[(0,G.jsx)(Ep,{children:`Icon`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsxs)(`div`,{className:`relative flex-none`,children:[(0,G.jsx)(hc,{name:n.trim()===``?rn(t):n,logo:i,className:`ring-foreground/10 size-16 rounded-2xl ring-1 [&>img]:rounded-2xl [&>svg]:rounded-2xl`}),i!==null&&(0,G.jsx)(`button`,{type:`button`,className:`bg-popover text-muted-foreground hover:text-foreground absolute -top-1.5 -right-1.5 grid size-5 cursor-pointer place-items-center rounded-full border shadow-xs`,title:`Remove icon`,onClick:()=>a(null),children:(0,G.jsx)(H,{icon:Go,className:`size-3`})})]}),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,title:`Upload an image from this device`,onClick:()=>m.current?.click(),children:[(0,G.jsx)(H,{icon:ic}),`Upload`]}),(0,G.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,title:`Choose an image from the project on the server`,onClick:()=>p(!0),children:[(0,G.jsx)(H,{icon:lr}),`Choose from project`]})]}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`PNG, JPG, WebP, SVG or ICO. SVG and ICO up to 384 KB`})]})]}),(0,G.jsx)(`input`,{ref:m,type:`file`,accept:`image/png,image/jpeg,image/webp,image/svg+xml,image/x-icon`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&a(`data:${t.type};base64,${await Af(t)}`)}})]}),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(Ep,{htmlFor:`project-name`,children:`Name`}),(0,G.jsx)(Tp,{id:`project-name`,placeholder:rn(t),value:n,onChange:e=>r(e.target.value)})]}),o!==null&&(0,G.jsx)(`p`,{className:`text-destructive text-sm break-all`,children:o})]}),(0,G.jsxs)(si,{className:`bg-muted/40 border-t px-6 py-4`,children:[(0,G.jsxs)(U,{type:`button`,variant:u?`destructive`:`ghost`,className:B(`sm:mr-auto`,!u&&`text-destructive hover:bg-destructive/10 hover:text-destructive`),title:`Its threads stay in their provider`,onClick:async()=>{if(!u)d(!0);else try{await dc(e.project.machine,e.project.id),e.onRemoved()}catch(e){s(Ht(e))}},children:[(0,G.jsx)(H,{icon:is,className:`text-current`}),u?`Click again to remove`:`Remove project`]}),(0,G.jsx)(U,{type:`button`,variant:`outline`,onClick:e.onClose,children:`Cancel`}),(0,G.jsx)(U,{type:`submit`,disabled:n.trim()===``||c,children:`Save`})]})]}),f&&(0,G.jsx)(Om,{machine:e.project.machine,projectId:e.project.id,onClose:()=>p(!1),onPick:e=>{a(e),p(!1)}})]})})}function Nm(e){let t=e.scope,n=k(e=>t===null?void 0:e.projects.find(e=>e.machine===t.machine&&e.id===t.projectId)),[r,i]=(0,W.useState)(!1);return vr(`mod+p`,()=>i(!r),{enableOnFormTags:!0,preventDefault:!0}),(0,G.jsxs)(mn,{open:r,onOpenChange:i,children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:`hover:bg-sidebar-row-hover data-[state=open]:bg-sidebar-row-hover -ml-1.5 flex h-7 min-w-0 cursor-pointer items-center gap-1.5 rounded-[var(--control-radius)] px-1.5 text-sm font-medium`,title:e.scope===null?`Inbox`:n?.path,children:[e.scope!==null&&(0,G.jsx)(mc,{machine:e.scope.machine,projectId:e.scope.projectId,className:`size-4 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,G.jsx)(`span`,{className:`truncate`,children:e.scope===null?`Inbox`:e.scope.projectId===`no-project`?`Chat`:n?.name}),(0,G.jsx)(H,{icon:Rr,className:`text-sidebar-muted-foreground size-3.5 shrink-0`})]})}),(0,G.jsx)(Dn,{className:`w-64`,children:(0,G.jsx)(Pm,{inbox:!0,scope:e.scope,onScope:e.onScope,onEdit:e.onEdit,onAddProject:e.onAddProject,onClose:()=>i(!1)})})]})}function Pm(e){let t=k(e=>e.machines),n=k(e=>e.projects),r=k(e=>e.sessions),a=k(e=>e.unseen),o=t.map(e=>({machine:e,projects:n.filter(t=>t.machine===e.id&&!t.hidden&&!t.scratch)})).filter(e=>t.length>1||e.projects.length>0),s=r.filter(e=>{let n=$e(t,e.machine,e.id);return n?.running===!0||n?.waiting===!0||Object.values(n?.tasks??{}).includes(`running`)||a.includes(P(e.machine,e.id))});function c(e,t){return n.find(n=>n.machine===e&&n.id===t)}function l(e){return s.filter(t=>t.machine===e&&c(e,t.projectId)?.scratch===!0).length}function u(e){return(0,G.jsx)(Mr,{className:`text-muted-foreground grid size-7 min-h-0 shrink-0 place-items-center rounded-sm p-0`,title:`Manage projects on ${e.name}`,"aria-label":`Manage projects on ${e.name}`,disabled:e.status!==`online`,onSelect:()=>{d(`Projects`),i({settingsMachine:e.id})},children:(0,G.jsx)(H,{icon:Js,className:`size-3.5`})})}function f(t){return(0,G.jsxs)(Mn,{value:P(t.id,S),className:`text-muted-foreground data-[state=checked]:bg-foreground/10 data-[state=checked]:text-foreground h-7 min-h-0 shrink-0 gap-1 px-2 py-0 text-xs *:data-[slot=dropdown-menu-radio-item-indicator]:hidden`,title:`Threads on ${t.name} without a project`,onSelect:()=>e.onScope({machine:t.id,projectId:S}),children:[(0,G.jsx)(mc,{machine:t.id,projectId:S,className:`size-3.5 shrink-0`}),`Chat`,l(t.id)>0&&(0,G.jsx)(`span`,{className:`text-foreground grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,children:l(t.id)})]})}function p(e){return e.status===`online`?e.name:e.status===`unpaired`?`${e.name} · needs pairing`:`${e.name} · offline`}return(0,G.jsxs)(pn,{value:e.scope===null?``:P(e.scope.machine,e.scope.projectId),children:[e.inbox&&(0,G.jsxs)(Mn,{value:``,onSelect:()=>e.onScope(null),children:[(0,G.jsx)(H,{icon:fi,className:`text-muted-foreground size-5 shrink-0`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Inbox`}),s.length>0&&(0,G.jsx)(`span`,{className:`text-foreground grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,children:s.length})]}),e.inbox&&o.length>0&&(0,G.jsx)(Pn,{}),o.map((n,r)=>(0,G.jsxs)(W.Fragment,{children:[r>0&&(0,G.jsx)(Pn,{}),t.length>1&&(0,G.jsxs)(`div`,{className:`flex items-center`,children:[(0,G.jsxs)(an,{className:`flex min-w-0 flex-1 items-center gap-2 pl-[0.52rem]!`,children:[(0,G.jsx)(Of,{icon:n.machine.icon,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`truncate`,children:p(n.machine)})]}),n.machine.system?.scratchAvailable===!0&&f(n.machine),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[u(n.machine),(0,G.jsx)(Mr,{className:`text-muted-foreground grid size-7 min-h-0 shrink-0 place-items-center rounded-sm p-0`,title:`Add project to ${n.machine.name}`,"aria-label":`Add project to ${n.machine.name}`,disabled:n.machine.status!==`online`,onSelect:()=>e.onAddProject(n.machine.id),children:(0,G.jsx)(H,{icon:Oo,className:`size-3.5`})})]})]}),n.projects.map(t=>{let n=s.filter(e=>e.machine===t.machine&&e.projectId===t.id).length;return(0,G.jsxs)(Mn,{value:P(t.machine,t.id),title:t.path,className:`group/project`,onSelect:()=>e.onScope({machine:t.machine,projectId:t.id}),onContextMenu:n=>{n.preventDefault(),e.onClose(),e.onEdit(t)},children:[(0,G.jsx)(mc,{machine:t.machine,projectId:t.id,className:`size-5 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.name}),n>0&&(0,G.jsx)(`span`,{className:`text-foreground grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,children:n}),(0,G.jsx)(`div`,{className:`-my-0.5 flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-data-highlighted/project:opacity-100 pointer-coarse:hidden`,children:(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground hover:bg-foreground/10 grid size-5 cursor-pointer place-items-center rounded-sm [&_svg]:size-3.5`,title:`Configure project`,"aria-label":`Configure ${t.name}`,onClick:n=>{n.stopPropagation(),e.onClose(),e.onEdit(t)},children:(0,G.jsx)(H,{icon:Us})})})]},P(t.machine,t.id))})]},n.machine.id)),t.length===1&&(0,G.jsxs)(G.Fragment,{children:[(e.inbox||o.length>0)&&(0,G.jsx)(Pn,{}),(0,G.jsxs)(`div`,{className:`flex items-center`,children:[(0,G.jsxs)(Mr,{className:`flex-1`,onSelect:()=>e.onAddProject(t[0].id),children:[(0,G.jsx)(H,{icon:Oo}),`Add project`]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[t[0].system?.scratchAvailable===!0&&f(t[0]),u(t[0])]})]})]})]})}function Fm(e){let t=k(e=>e.selection?.sessionId),n=k(t=>He(t,e.machine,e.projectId)),r=e.projectId===`no-project`||n?.scratch===!0,[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null);return vr([`mod+p`,`mod+semicolon`],e=>{e.stopPropagation(),a(!i)},{enabled:t===null,enableOnFormTags:!0,preventDefault:!0,eventListenerOptions:{capture:!0}}),(0,G.jsxs)(`div`,{className:`absolute inset-x-0 bottom-full pb-4`,children:[(0,G.jsxs)(`h1`,{className:`text-foreground w-full text-center text-2xl font-normal tracking-tight sm:text-3xl`,children:[`What should we build `,!r&&`in `,t===null?(0,G.jsxs)(mn,{open:i,onOpenChange:a,children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:B(`border-muted-foreground/35 hover:border-foreground/60 inline-flex max-w-64 cursor-pointer border-b border-dotted align-bottom outline-none`,r&&`max-w-none`),title:n?.path,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:r?`without a project`:n?.name}),`?`]})}),(0,G.jsx)(Dn,{className:`max-h-80 w-64`,onCloseAutoFocus:t=>{t.preventDefault(),e.onCloseMenu()},children:(0,G.jsx)(Pm,{inbox:!1,scope:{machine:e.machine,projectId:e.projectId},onScope:e=>{if(e===null)throw Error(`the new thread menu has no inbox`);Ie({...e,sessionId:null})},onEdit:l,onAddProject:s,onClose:()=>a(!1)})})]}):(0,G.jsx)(`span`,{className:B(`border-muted-foreground/35 inline-block max-w-64 truncate border-b border-dotted align-bottom`,r&&`max-w-none`),title:n?.path,children:r?`without a project`:n?.name}),t!==null&&`?`]}),o!==null&&(0,G.jsx)(Am,{machine:o,onClose:()=>s(null),onAdd:e=>{s(null),Ie({machine:e.machine,projectId:e.id,sessionId:null})}}),c!==null&&(0,G.jsx)(Mm,{project:c,onClose:()=>l(null),onRemoved:()=>l(null)})]})}function Im(){let e=k(e=>e.queue);return(0,G.jsx)(`div`,{className:`composer-glass relative mx-auto -mb-[calc(1rem+1px)] w-[calc(100%-2.75rem)] rounded-t-2xl border border-b-0 border-(--composer-outline) px-1 pt-1 pb-[calc(1rem+1px+0.25rem)] text-xs/4`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`grid min-h-6 grid-cols-[1.5rem_minmax(0,1fr)_auto_auto] items-center gap-x-1`,children:[(0,G.jsx)(H,{icon:Ss,className:`text-muted-foreground mx-auto size-3`}),(0,G.jsx)(`span`,{className:`text-secondary-label truncate`,children:e.prompt.text===``?`${e.prompt.images.length} image(s)`:e.prompt.text}),(0,G.jsx)(U,{variant:`ghost-muted`,size:`icon-micro`,title:`Send now`,onClick:()=>Tt(e.id),children:(0,G.jsx)(H,{icon:kr,className:`size-4`})}),(0,G.jsx)(U,{variant:`ghost-muted`,size:`icon-micro`,title:`Remove from queue`,onClick:()=>Ae(e.id),children:(0,G.jsx)(H,{icon:_t,className:`size-4`})})]},e.id))})}function Lm(){let e=k(Mt),t=io(),n=e?t?.limits.find(e=>e.rejected):void 0,[r,i]=(0,W.useState)(Date.now());return(0,W.useEffect)(()=>{if(n===void 0)return;i(Date.now());let e=setInterval(()=>i(Date.now()),3e4);return()=>clearInterval(e)},[n]),n===void 0?null:(0,G.jsxs)(`div`,{className:`composer-glass relative mx-auto -mb-[calc(1rem+1px)] flex w-[calc(100%-2.75rem)] items-center gap-2 rounded-t-2xl border border-b-0 border-(--composer-outline) px-3 pt-2 pb-[calc(1rem+1px+0.5rem)] text-xs/4`,children:[(0,G.jsx)(H,{icon:rc,className:`text-warning-foreground size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`text-secondary-label truncate`,children:n.resetsAt===null?`Usage limit reached`:`Usage limit reached · Resets in ${xn(n.resetsAt*1e3-r)}`})]})}var Rm=9,zm=40;function Bm(e){let t=e.state;return(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-hidden":e.closing,"aria-label":t.kind===`recording`?`Recording`:t.kind===`transcribing`?`Transcribing`:t.title,className:B(`absolute inset-y-0 right-0 left-0 z-10 flex items-center gap-0.5 rounded-full ps-1 shadow-xs motion-safe:starting:[clip-path:inset(0_0_0_calc(100%-2.25rem)_round_9999px)]`,e.closing?`pointer-events-none [clip-path:inset(0_0_0_calc(100%-2.25rem)_round_9999px)] opacity-0 [transition:clip-path_250ms_cubic-bezier(0.4,0,0.2,1),opacity_120ms_linear_150ms]`:`[clip-path:inset(0_0_0_0_round_9999px)] transition-[clip-path,background-color] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)]`,t.kind===`failed`?`bg-[color-mix(in_srgb,var(--composer-surface)_86%,var(--destructive))]`:`bg-[color-mix(in_srgb,var(--composer-surface)_90%,var(--text))]`),children:[(0,G.jsx)(`button`,{className:`text-muted-foreground hover:bg-foreground/10 hover:text-foreground flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full transition-[opacity,background-color,color] delay-100 duration-200 motion-safe:starting:opacity-0`,title:t.kind===`recording`?`Cancel`:t.kind===`transcribing`?`Cancel transcription`:`Dismiss (Esc)`,"aria-label":t.kind===`recording`?`Cancel dictation`:t.kind===`transcribing`?`Cancel transcription`:`Dismiss`,onClick:e.dictation.cancel,children:(0,G.jsx)(H,{icon:_t,className:`size-4`})}),t.kind===`recording`&&(0,G.jsx)(Vm,{started:t.started,analyser:t.analyser}),t.kind===`transcribing`&&(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`flex h-4 min-w-0 flex-1 items-center justify-center gap-0.5`,children:Array.from({length:Rm},(e,t)=>(0,G.jsx)(`span`,{className:`bg-foreground/50 h-[35%] w-0.5 shrink-0 rounded-full motion-safe:animate-pulse`,style:{animationDelay:`${t*110}ms`}},t))}),t.kind===`failed`&&(0,G.jsx)(`span`,{className:`text-destructive line-clamp-2 min-w-0 flex-1 cursor-default text-center text-[11px]/[1.15] font-medium transition-opacity duration-200 motion-safe:starting:opacity-0`,title:`${t.title}${t.detail===null?``:`\n${t.detail}`}`,children:t.label}),t.kind===`recording`&&(0,G.jsx)(`button`,{className:`bg-message-action text-message-action-foreground shadow-message-action/24 hover:bg-message-action-hover flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full shadow-xs transition-colors`,title:`Done, transcribe (Esc)`,"aria-label":`Finish dictation`,onClick:()=>void e.dictation.toggle(),children:(0,G.jsx)(H,{icon:nr,className:`size-4`,strokeWidth:2})}),t.kind===`transcribing`&&(0,G.jsx)(`span`,{className:`bg-foreground/12 text-muted-foreground flex size-9 shrink-0 items-center justify-center rounded-full`,children:(0,G.jsx)(H,{icon:ws,className:`size-4 animate-spin`})}),t.kind===`failed`&&t.action!==null&&(0,G.jsx)(`button`,{className:`bg-message-action text-message-action-foreground shadow-message-action/24 hover:bg-message-action-hover flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full shadow-xs transition-colors`,title:t.action===`retry`?`Retry with the same recording`:`Try again`,"aria-label":t.action===`retry`?`Retry`:`Try again`,onClick:t.action===`retry`?e.dictation.retry:()=>void e.dictation.toggle(),children:(0,G.jsx)(H,{icon:Gn,className:`size-4`})})]})}function Vm(e){let[t,n]=(0,W.useState)([]),[r,i]=(0,W.useState)(Date.now());(0,W.useEffect)(()=>{let t=new Float32Array(e.analyser.fftSize),r=[],a=0,o=requestAnimationFrame(s);function s(c){if(o=requestAnimationFrame(s),c-a<60)return;a=c,e.analyser.getFloatTimeDomainData(t);let l=0;for(let e of t)l+=e*e;let u=Math.min(1,Math.sqrt(Math.sqrt(l/t.length))*1.6);r=[...r,u].slice(-40),n(r),i(Date.now())}return()=>cancelAnimationFrame(o)},[e.analyser]);let a=r-e.started>3e3&&t.length===zm&&t.every(e=>e<.08),o=t.slice(-9);return(0,G.jsx)(`div`,{className:`flex h-4 min-w-0 flex-1 items-center justify-center gap-0.5 transition-opacity delay-100 duration-200 motion-safe:starting:opacity-0`,children:a?(0,G.jsx)(`span`,{title:`No sound from the microphone. Check that it is not muted`,children:(0,G.jsx)(H,{icon:jo,className:`text-warning-foreground size-3.5`})}):[...Array(Rm-o.length).fill(0),...o].map((e,t)=>(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`bg-destructive/80 w-0.5 shrink-0 rounded-full`,style:{height:`${Math.max(15,e*100)}%`}},t))})}var Hm=window.matchMedia(`(min-width: 768px)`);function Um(e){let t=k(e=>Hm.matches?e.prefs.dictateButton.desktop:e.prefs.dictateButton.mobile),n=e.dictation.state,[r,i]=(0,W.useState)(n),[a,o]=(0,W.useState)(null);r!==n&&(i(n),o(n.kind===`idle`&&r.kind!==`idle`?r:null));let s=n.kind===`idle`?a:n;return(0,W.useEffect)(()=>{if(a===null)return;let e=setTimeout(()=>o(null),300);return()=>clearTimeout(e)},[a]),(0,G.jsxs)(G.Fragment,{children:[s!==null&&(0,G.jsx)(Bm,{state:s,dictation:e.dictation,closing:n.kind===`idle`}),n.kind===`idle`?e.running&&e.empty?(0,G.jsx)(`button`,{className:`bg-destructive/90 shadow-destructive/24 hover:bg-destructive flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full text-white shadow-xs transition-colors`,title:`Stop (Esc)`,"aria-label":`Stop generation`,onClick:e.onStop,children:(0,G.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,G.jsx)(`rect`,{x:`2`,y:`2`,width:`8`,height:`8`,rx:`1.5`})})}):e.blank&&t?(0,G.jsx)(`button`,{className:`bg-message-action text-message-action-foreground shadow-message-action/24 hover:bg-message-action-hover flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full shadow-xs transition-all duration-150 hover:scale-105`,title:`Dictate (${z}+Shift+D)`,"aria-label":`Dictate`,onClick:()=>void e.dictation.toggle(),children:(0,G.jsx)(H,{icon:Ao,className:`size-4`})}):(0,G.jsx)(`button`,{className:`bg-message-action text-message-action-foreground shadow-message-action/24 hover:bg-message-action-hover disabled:bg-foreground/12 disabled:text-muted-foreground relative flex size-9 items-center justify-center overflow-hidden rounded-full shadow-xs transition-all duration-150 hover:scale-105 enabled:cursor-pointer disabled:pointer-events-none disabled:shadow-none`,title:e.running&&e.delivery===`steer`?`Send now (Enter) · Queue (${z}+Enter)`:e.running?`Queue (Enter) · Send now (${z}+Enter)`:`Send (Enter)`,"aria-label":`Send message`,disabled:e.empty,onClick:t=>e.onSubmit(t.metaKey||t.ctrlKey),children:(0,G.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:`M7 11.5V2.5M7 2.5L3 6.5M7 2.5L11 6.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})}):(0,G.jsx)(`div`,{className:`size-9 shrink-0`})]})}var Wm=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],Gm=5242880,Km=window.matchMedia(`(pointer: coarse)`);function qm(){let e=k(e=>e.selection),t=k(e=>e.loaded),n=k(e=>e.items.length===0&&e.partial===``),r=k(e=>e.requests),i=k(e=>e.queue),a=k(e=>e.draft),o=k(e=>e.capabilities),s=k(e=>e.settings.provider===`opencode`?e.machines.find(t=>t.id===e.selection?.machine)?.openCode.available!==!0:e.settings.accountId===null),[l,u]=(0,W.useState)(!1),[d,f]=(0,W.useState)(0),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)([]),_=(0,W.useRef)(null),v=(0,W.useRef)(null),y=(0,W.useRef)(!1),b=e?.machine??``,x=e?.projectId??``,S=k(e=>He(e,b,x)),C=k(e=>Ge(e,b).status),T=k(e=>Ge(e,b).config?.delivery??null),E=e===null?``:ct(e),D=Le(E),O=D.text,A=D.images,j=D.files,[M,N]=(0,W.useState)(O.length),ee=k(Mt),te=t&&n&&!ee,ne=r.at(0),re=Z();(0,W.useEffect)(()=>{let e=_.current;e===null||Km.matches||(e.focus(),e.setSelectionRange(e.value.length,e.value.length))},[e]),(0,W.useEffect)(()=>{if(a===null)return;let e=Pf(a);F(E,t=>({...t,...e})),N(e.text.length),Oe(null),_.current?.focus()},[a,E]),(0,W.useEffect)(()=>{C===`online`&&L(b,`files.list`,{projectId:x}).then(g,c)},[b,x,C]);let ie=O.slice(0,M),ae=/^\/\S*$/.exec(ie)?.[0]??/(?:^|\s)(@\S*)$/.exec(ie)?.[1]??null,oe=ae?.slice(1).toLowerCase()??``,se=ae===null||p?[]:ae.startsWith(`/`)?(o?.commands??[]).filter(e=>e.name.toLowerCase().includes(oe)).sort((e,t)=>Number(!e.name.toLowerCase().startsWith(oe))-Number(!t.name.toLowerCase().startsWith(oe))).map(e=>({key:e.name,label:`/${e.name}${e.hint===``?``:` ${e.hint}`}`,description:e.description,insert:`/${e.name}`})):h.filter(e=>e.toLowerCase().includes(oe)).slice(0,50).map(e=>({key:e,label:e,description:``,insert:`@${e}`})),ce=Math.min(d,se.length-1),le=O.trim()===``&&A.length===0||l||s;function ue(e,t){F(E,t=>({...t,text:e,images:t.images.filter(t=>e.includes(`[Image #${t.number}]`)),files:t.files.filter(t=>e.includes(Jm(t)))})),N(t),f(0),m(!1)}function de(e){if(ae===null)return;let t=M-ae.length,n=t+e.insert.length+1;ue(`${O.slice(0,t)}${e.insert} ${O.slice(M)}`,n),requestAnimationFrame(()=>_.current?.setSelectionRange(n,n))}async function fe(t){if(!le){u(!0);try{if(T===null)throw Error(`This machine is not connected`);let n=R().settings,r=O.trim();for(let e of j){let t=await w(e.id);if(t===void 0)throw Error(`${e.name} is no longer saved, attach it again`);let n=await kf(b,t);r=r.replace(Jm(e),()=>`@${n}`)}await We({text:r,images:A.map(e=>({mediaType:e.mediaType,data:e.data}))},t?T===`queue`?`steer`:`queue`:T,e,n),F(E,e=>({...e,text:``,images:[],files:[]})),N(0)}catch(e){c(e)}finally{u(!1)}}}async function P(e){let t=M,n=/(^|\s)$/.test(O.slice(0,M))?``:` `;for(let r of e){if(Wm.includes(r.type)&&r.size<=Gm){let e=await Af(r),i=Nf(R().items,[he(E).text])+1,a={number:i,mediaType:r.type,data:e},o=t,s=`${n}[Image #${i}] `;n=``,F(E,e=>({...e,text:`${e.text.slice(0,o)}${s}${e.text.slice(o)}`,images:[...e.images,a]})),t+=s.length,N(t),requestAnimationFrame(()=>_.current?.setSelectionRange(t,t));continue}if(r.size>52428800){c(Error(`${r.name} is larger than 50 MB`));continue}let e=await xe(r),i={number:Math.max(0,...he(E).files.map(e=>e.number))+1,id:e,name:r.name},a=t,o=`${n}${Jm(i)} `;n=``,F(E,e=>({...e,text:`${e.text.slice(0,a)}${o}${e.text.slice(a)}`,files:[...e.files,i]})),t+=o.length,N(t),requestAnimationFrame(()=>_.current?.setSelectionRange(t,t))}}return(0,G.jsx)(`div`,{className:B(`pointer-events-none z-20`,te?`absolute inset-0 flex items-center pb-3 sm:pb-4`:`relative flex min-h-0 flex-col before:absolute before:right-(--app-scrollbar-width) before:bottom-full before:left-0 before:h-8 before:bg-linear-to-t before:from-background before:to-transparent`),children:(0,G.jsxs)(jf,{width:`composer`,className:`pointer-events-auto relative z-10`,children:[te&&(0,G.jsx)(Fm,{machine:b,projectId:x,onCloseMenu:()=>_.current?.focus()}),se.length===0&&(0,G.jsx)(Lm,{}),i.length>0&&se.length===0&&(0,G.jsx)(Im,{}),ne!==void 0&&se.length===0&&(0,G.jsx)(pp,{request:ne,machine:b,cwd:S?.path??``,count:r.length,draft:O},ne.id),se.length>0&&(0,G.jsx)(Rf,{items:se,active:ce,onHover:f,onPick:de}),(0,G.jsxs)(`div`,{className:B(`composer-glass shadow-composer relative z-10 border border-(--composer-outline) transition-[border-color,box-shadow] duration-150 ease-out focus-within:border-[color-mix(in_srgb,var(--text)_16%,transparent)] focus-within:ring-4 focus-within:ring-[color-mix(in_srgb,var(--text)_4%,transparent)] dark:shadow-none`,te?`rounded-3xl`:`rounded-t-3xl border-b-0`,ne?.kind===`question`&&`hidden`),onMouseDown:e=>{e.target instanceof Element&&e.currentTarget.contains(e.target)&&(e.target.closest(`button, a, input, textarea`)||(e.preventDefault(),_.current?.focus()))},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),P([...e.dataTransfer.files])},children:[(0,G.jsxs)(`div`,{className:B(`pb-2`,A.length>0&&`pt-3.5 sm:pt-4`),children:[A.length>0&&(0,G.jsx)(Mf,{draftKey:E}),(0,G.jsx)(`textarea`,{ref:_,"data-composer":!0,rows:1,spellCheck:!1,autoCorrect:`off`,"data-gramm":`false`,"data-gramm_editor":`false`,"data-enable-grammarly":`false`,"data-lt-active":`false`,value:O,onChange:e=>ue(e.target.value,e.target.selectionStart),onSelect:e=>N(e.currentTarget.selectionStart),onPaste:e=>{let t=e.clipboardData.getData(`text/plain`),n=y.current;if(y.current=!1,t!==``){e.preventDefault();let r=n?null:Ff(t,j);if(r!==null){P([r]);return}document.execCommand(`insertText`,!1,t);return}let r=[...e.clipboardData.files];r.length!==0&&(e.preventDefault(),P(r))},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(y.current=If(e.nativeEvent),Jf(e.nativeEvent))e.preventDefault(),qf(E);else{if(se.length>0){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;f((ce+t+se.length)%se.length);return}if(e.key===`Enter`&&!e.shiftKey||e.key===`Tab`){e.preventDefault(),de(se[ce]);return}if(e.key===`Escape`){e.preventDefault(),m(!0);return}}if(e.key===`Enter`&&!e.shiftKey&&!Km.matches)e.preventDefault(),fe(e.metaKey||e.ctrlKey);else if(e.key===`ArrowUp`&&O===``){let t=Lf(R().items);if(t===null)return;e.preventDefault(),ue(t,t.length)}else e.key===`Escape`&&ee&&st()}}},placeholder:s?`Add an account in Settings to start`:ee&&T===`steer`?`Steer the agent… (${z}+Enter to queue)`:ee?`Queue a follow-up… (${z}+Enter to send now)`:`Ask anything, @tag files/folders, or / for commands`,className:B(`placeholder:text-placeholder/75 block [field-sizing:content] w-full resize-none bg-transparent px-3 text-sm leading-relaxed outline-none sm:px-4`,A.length>0?`max-h-52 min-h-19.5`:`max-h-55.5 min-h-20 pt-3.5 sm:max-h-56 sm:pt-4 [@media(min-height:840px)]:min-h-23 sm:[@media(min-height:840px)]:min-h-23.5`)})]}),(0,G.jsxs)(`div`,{className:B(`flex min-w-0 items-center justify-between gap-2 px-3 sm:px-3.5`,te?`pb-2.5 sm:pb-3.5`:`pb-2 sm:pb-3`),children:[(0,G.jsx)(`div`,{className:`-m-1 -ms-3.5 flex min-w-0 flex-1 [scrollbar-width:none] items-center gap-1 overflow-x-auto p-1 ps-3 sm:ps-4`,children:(0,G.jsx)(Sp,{})}),(0,G.jsxs)(`div`,{className:`relative flex shrink-0 items-center justify-end gap-2`,children:[(0,G.jsx)(`input`,{ref:v,type:`file`,multiple:!0,hidden:!0,onChange:e=>{P([...e.target.files??[]]),e.target.value=``}}),l&&j.length>0&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Uploading…`}),(0,G.jsx)(Zf,{dictation:re,empty:le,delivery:T,onSubmit:()=>void fe(!0)}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,title:`Attach files`,"aria-label":`Attach files`,onClick:()=>v.current?.click(),children:(0,G.jsx)(H,{icon:Ns})}),(0,G.jsx)(Um,{dictation:re,running:ee,empty:le,blank:O.trim()===``&&A.length===0,delivery:T,onSubmit:e=>void fe(e),onStop:st})]})]})]})]})})}function Jm(e){return`[File #${e.number}: ${e.name}]`}var Ym={five_hour:`session`,seven_day:`weekly`,seven_day_opus:`opus`,seven_day_sonnet:`sonnet`};function Xm(e){return Ym[e.window]??e.window.toLowerCase()}function Zm(){let e=io()?.limits.filter(e=>!e.rejected&&e.utilization!==null&&e.utilization>=.9).sort((e,t)=>(t.utilization??0)-(e.utilization??0))[0];if(e===void 0)return null;let t=`${Math.round((e.utilization??0)*100)}%`,n=`${Xm(e)} limit ${t} used`;return(0,G.jsxs)(`span`,{className:`bg-warning/15 text-warning-foreground flex h-5 shrink-0 items-center gap-0.75 rounded-[6px] px-1.25 text-[11px] font-medium tabular-nums`,title:n,"aria-label":n,children:[(0,G.jsx)(H,{icon:ys,className:`size-3 shrink-0`}),t]})}var Qm={working:jr,done:Zo,failed:un},$m=new Set,eh=null,th=0,nh={open:!1,label:``,error:``};function rh(e){eh!==null&&eh.id!==e.id&&ca.dismiss(eh.id),eh=e,ca.custom(()=>(0,G.jsx)(uh,{toast:e}),{id:e.id,duration:e.state===`done`?5e3:1/0,onDismiss:()=>{eh?.id===e.id&&(eh=null)}})}function ih(e){nh=e;for(let e of $m)e()}function ah(e){return $m.add(e),()=>{$m.delete(e)}}function oh(e,t){th+=1;let n=`git-${th}`;rh(`url`in t?{id:n,state:`done`,label:e,error:``,url:t.url}:{id:n,state:`failed`,label:e,error:t.error,url:null})}async function sh(e){th+=1;let t=`git-${th}`;rh({id:t,state:`working`,label:e.labels.working,error:``,url:null});try{let n=await e.task();eh?.id===t&&rh({id:t,state:`done`,label:e.labels.done,error:``,url:n})}catch(n){eh?.id===t&&rh({id:t,state:`failed`,label:e.labels.failed,error:Ht(n),url:null})}finally{e.onRefresh()}}function ch(e,t,n,r){sh({labels:r?{working:`Committing and pushing…`,done:`Committed and pushed`,failed:`Commit and push failed`}:{working:`Committing…`,done:`Committed`,failed:`Commit failed`},task:async()=>(await L(e.machine,`git.commit`,{projectId:e.projectId,repo:t,message:n,push:r}),null),onRefresh:e.onRefresh})}function lh(e,t,n){sh({labels:{working:`Creating pull request…`,done:`Pull request created`,failed:`Couldn't create pull request`},task:async()=>(await L(e.machine,`git.createPullRequest`,{projectId:e.projectId,repo:t,base:n.base,head:n.head,title:n.title,body:n.body})).url,onRefresh:e.onRefresh})}function uh(e){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,G.jsx)(H,{icon:Qm[e.toast.state],className:B(`size-4 shrink-0`,e.toast.state===`working`&&`animate-spin`,e.toast.state===`done`&&`text-success`,e.toast.state===`failed`&&`text-destructive`)}),(0,G.jsx)(`span`,{className:`truncate`,children:e.toast.label})]}),e.toast.url!==null&&(0,G.jsx)(U,{asChild:!0,size:`xs`,variant:`outline`,children:(0,G.jsx)(`a`,{href:e.toast.url,target:`_blank`,rel:`noopener noreferrer`,children:`Open`})}),e.toast.state===`failed`&&(0,G.jsx)(U,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>ih({open:!0,label:e.toast.label,error:e.toast.error}),children:`View`}),(0,G.jsx)(U,{type:`button`,size:`icon-micro`,variant:`ghost-muted`,"aria-label":`Dismiss`,onClick:()=>ca.dismiss(e.toast.id),children:(0,G.jsx)(H,{icon:_t,className:`size-4`})})]})}function dh(){let e=(0,W.useSyncExternalStore)(ah,()=>nh);return(0,G.jsx)(oi,{open:e.open,onOpenChange:t=>ih({...e,open:t}),children:(0,G.jsxs)($r,{className:`sm:max-w-lg`,children:[(0,G.jsx)(ei,{children:(0,G.jsx)(ri,{children:e.label})}),(0,G.jsx)(`pre`,{className:`bg-muted/50 max-h-[60vh] overflow-y-auto rounded-lg border p-3 font-mono text-xs break-words whitespace-pre-wrap`,children:e.error})]})})}function fh({...e}){return(0,G.jsx)(ll,{"data-slot":`select`,...e})}function ph({...e}){return(0,G.jsx)(pl,{"data-slot":`select-value`,...e})}function mh({className:e,size:t=`default`,children:n,...r}){return(0,G.jsxs)(dl,{"data-slot":`select-trigger`,"data-size":t,className:B(`flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-[color,background-color,border-color,box-shadow] duration-200 ease-out outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/33 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,G.jsx)(ml,{asChild:!0,children:(0,G.jsx)(H,{icon:Fr,className:`text-muted-foreground pointer-events-none size-4`})})]})}function hh({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,G.jsx)(_l,{children:(0,G.jsxs)(yl,{"data-slot":`select-content`,"data-align-trigger":n===`item-aligned`,className:B(`relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,G.jsx)(_h,{}),(0,G.jsx)(jl,{"data-position":n,className:B(`data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)`,n===`popper`&&``),children:t}),(0,G.jsx)(vh,{})]})})}function gh({className:e,children:t,...n}){return(0,G.jsxs)(Ll,{"data-slot":`select-item`,className:B(`relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,G.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`,children:(0,G.jsx)(Vl,{children:(0,G.jsx)(H,{icon:Un,className:`pointer-events-none`})})}),(0,G.jsx)(zl,{children:t})]})}function _h({className:e,...t}){return(0,G.jsx)(Ul,{"data-slot":`select-scroll-up-button`,className:B(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,G.jsx)(H,{icon:Xo})})}function vh({className:e,...t}){return(0,G.jsx)(Gl,{"data-slot":`select-scroll-down-button`,className:B(`z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4`,e),...t,children:(0,G.jsx)(H,{icon:Rr})})}function yh(e){return e.target?.kind===`failed`?(0,G.jsx)(`span`,{className:`text-destructive truncate text-xs`,children:e.target.text}):(0,G.jsxs)(`span`,{className:`text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs`,children:[(0,G.jsxs)(`span`,{className:`truncate`,children:[e.head,` →`]}),(0,G.jsxs)(fh,{value:e.target?.base??``,disabled:e.target===void 0,onValueChange:e.onBase,children:[(0,G.jsx)(mh,{size:`sm`,className:`max-w-48`,children:(0,G.jsx)(ph,{placeholder:`Loading branches…`})}),(0,G.jsx)(hh,{children:(e.target?.branches??[]).map(e=>(0,G.jsx)(gh,{value:e,children:e},e))})]})]})}function bh(e){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 ps-6`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground truncate text-xs`,children:[e.draft.head,` → `,e.draft.base]}),(0,G.jsx)(Tp,{value:e.draft.title,onChange:t=>e.onChange({...e.draft,title:t.target.value})}),(0,G.jsx)(`textarea`,{value:e.draft.body,onChange:t=>e.onChange({...e.draft,body:t.target.value}),rows:8,className:`bg-background focus-visible:border-ring focus-visible:ring-ring/33 w-full resize-y rounded-lg border px-3 py-2 font-mono text-xs transition-[border-color,box-shadow] duration-200 ease-out outline-none focus-visible:ring-3`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[e.onSkip!==null&&(0,G.jsx)(U,{variant:`ghost`,size:`sm`,onClick:e.onSkip,children:`Skip`}),(0,G.jsx)(U,{variant:`outline`,size:`sm`,onClick:e.onRegenerate,children:`Regenerate`}),(0,G.jsx)(U,{size:`sm`,disabled:e.draft.title.trim()===``,onClick:e.onCreate,children:`Create PR`})]})]})}var xh={working:jr,review:$o,done:Zo,failed:un,skipped:js};function Sh(e){let t=k(t=>He(t,e.machine,e.projectId)?.name)??``,[n]=(0,W.useState)(()=>Ch(e.repos,e.action)),[r,i]=(0,W.useState)(()=>n.map(e=>e.path)),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)({}),[l,u]=(0,W.useState)(null),d=n.filter(e=>r.includes(e.path)&&s[e.path]?.kind!==`failed`),f=e.action===`pullRequest`&&d.some(e=>s[e.path]===void 0),p=d.filter(e=>e.changed>0);(0,W.useEffect)(()=>{if(e.action===`pullRequest`)for(let t of n)L(e.machine,`git.branches`,{projectId:e.projectId,repo:t.path}).then(e=>c(n=>({...n,[t.path]:{kind:`ready`,...e}})),e=>c(n=>({...n,[t.path]:{kind:`failed`,text:Ht(e)}})))},[e.machine,e.projectId,e.action,n]);function m(e,t){u(n=>n?.map(n=>n.path===e?{...n,...t}:n)??null)}async function h(t,r){try{await r()}catch(r){if(n.length===1){e.onClose(),oh(`Pull request failed`,{error:Ht(r)});return}m(t,{state:`failed`,text:Ht(r),draft:null})}finally{e.onRefresh()}}function g(e,t){c(n=>{let r=n[e];return r?.kind===`ready`?{...n,[e]:{...r,base:t}}:n})}function _(e,t){u(d.map(t=>({path:t.path,state:`working`,text:e,url:null,draft:null})));for(let e of d)h(e.path,()=>t(e.path))}function v(t){if(n.length===1){e.onClose(),ch(e,n[0].path,a,t);return}let r=t?`Committed and pushed`:`Committed`;_(t?`Committing and pushing…`:`Committing…`,async n=>{await L(e.machine,`git.commit`,{projectId:e.projectId,repo:n,message:a,push:t}),m(n,{state:`done`,text:r})})}function y(){_(`Pushing…`,async t=>{await L(e.machine,`git.push`,{projectId:e.projectId,repo:t}),m(t,{state:`done`,text:`Pushed`})})}async function b(t,r,i){m(t,{state:`working`,text:r?`Committing local changes and writing pull request…`:`Writing pull request…`,draft:null});let a=await L(e.machine,`git.pullRequest`,{projectId:e.projectId,repo:t,base:i,commit:r});if(a.kind===`open`){if(n.length===1){e.onClose(),oh(`Pull request already open`,{url:a.url});return}m(t,{state:`done`,text:`A pull request is already open`,url:a.url})}else m(t,{state:`review`,text:`Review and create`,draft:{base:a.base,head:a.head,title:a.title,body:a.body}})}function x(e){_(`Starting…`,async t=>{let n=s[t];if(n?.kind!==`ready`)throw Error(`The branches are not loaded`);await b(t,e&&p.some(e=>e.path===t),n.base)})}function S(t,r){n.length===1?(e.onClose(),lh(e,t,r)):h(t,async()=>{m(t,{state:`working`,text:`Creating pull request…`,draft:null}),m(t,{state:`done`,text:`Created pull request`,url:(await L(e.machine,`git.createPullRequest`,{projectId:e.projectId,repo:t,base:r.base,head:r.head,title:r.title,body:r.body})).url})})}return(0,G.jsx)(oi,{open:!0,onOpenChange:()=>e.onClose(),children:(0,G.jsxs)($r,{className:`top-[12vh] translate-y-0 sm:max-w-lg`,children:[(0,G.jsxs)(ei,{children:[(0,G.jsxs)(ri,{children:[e.action===`commit`&&`Commit changes`,e.action===`push`&&`Push`,e.action===`pullRequest`&&`Create pull request`]}),(0,G.jsxs)(ii,{children:[e.action===`commit`&&(n.length===1?`Stages every change and commits it.`:`Stages every change in the selected repositories and commits it.`),e.action===`push`&&`Pushes the selected repositories to their remote.`,e.action===`pullRequest`&&`AI writes the title and description. You review them before the pull request is created.`]})]}),l===null&&(0,G.jsxs)(G.Fragment,{children:[n.length===1&&(0,G.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-1.5 text-xs`,children:[e.action===`pullRequest`?(0,G.jsx)(yh,{head:n[0].branch??`detached`,target:s[n[0].path],onBase:e=>g(n[0].path,e)}):n[0].branch??`detached`,(0,G.jsxs)(`span`,{className:`shrink-0`,children:[`· `,n[0].changed,` `,n[0].changed===1?`change`:`changes`]})]}),n.length>1&&(0,G.jsx)(`div`,{className:`flex max-h-60 flex-col gap-0.5 overflow-y-auto`,children:n.map(n=>(0,G.jsxs)(`label`,{className:`hover:bg-accent flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5`,children:[(0,G.jsx)(`input`,{type:`checkbox`,disabled:s[n.path]?.kind===`failed`,checked:r.includes(n.path)&&s[n.path]?.kind!==`failed`,onChange:e=>i(e.target.checked?[...r,n.path]:r.filter(e=>e!==n.path))}),(0,G.jsx)(`span`,{className:`truncate font-medium`,children:wh(n.path,t)}),e.action===`pullRequest`?(0,G.jsx)(yh,{head:n.branch??`detached`,target:s[n.path],onBase:e=>g(n.path,e)}):(0,G.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,children:n.branch??`detached`}),(0,G.jsx)(`span`,{className:`text-muted-foreground ml-auto shrink-0 text-xs tabular-nums`,children:e.action===`push`?n.upstream===null?`not pushed yet`:`↑${n.ahead}`:n.changed>0&&`${n.changed} ${n.changed===1?`change`:`changes`}`})]},n.path))}),e.action===`commit`&&(0,G.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),placeholder:`Leave empty to write the message with AI`,rows:5,className:`bg-background focus-visible:border-ring focus-visible:ring-ring/33 w-full resize-none rounded-lg border px-3 py-2 font-mono text-xs transition-[border-color,box-shadow] duration-200 ease-out outline-none focus-visible:ring-3`}),e.action===`pullRequest`&&p.length>0&&(0,G.jsxs)(`p`,{children:[`You have local changes`,n.length>1&&` in ${p.map(e=>wh(e.path,t)).join(`, `)}`,`. Do you want to commit and push them before creating the pull request?`]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[e.action===`commit`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(U,{variant:`outline`,size:`sm`,disabled:d.length===0,onClick:()=>v(!1),children:`Commit`}),(0,G.jsx)(U,{size:`sm`,disabled:d.length===0,onClick:()=>v(!0),children:`Commit and Push`})]}),e.action===`push`&&(0,G.jsx)(U,{size:`sm`,disabled:d.length===0,onClick:y,children:`Push`}),e.action===`pullRequest`&&p.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(U,{variant:`outline`,size:`sm`,disabled:f,onClick:()=>x(!1),children:`Continue without them`}),(0,G.jsx)(U,{size:`sm`,disabled:f,onClick:()=>x(!0),children:`Commit and continue`})]}),e.action===`pullRequest`&&p.length===0&&(0,G.jsx)(U,{size:`sm`,disabled:f||d.length===0,onClick:()=>x(!1),children:`Create pull request`})]})]}),l!==null&&(0,G.jsx)(`div`,{className:`flex max-h-[60vh] flex-col gap-2 overflow-y-auto`,children:l.map(e=>{let r=e.draft;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`span`,{className:`mt-0.5 flex size-4 shrink-0 overflow-hidden`,children:(0,G.jsx)(H,{icon:xh[e.state],className:B(`size-4`,e.state===`working`&&`animate-spin`,e.state===`review`&&`text-info`,e.state===`done`&&`text-success`,e.state===`failed`&&`text-destructive`,e.state===`skipped`&&`text-muted-foreground`)})}),(0,G.jsx)(`span`,{className:`shrink-0 font-medium`,children:wh(e.path,t)}),(0,G.jsxs)(`span`,{className:B(`min-w-0 text-xs leading-5 break-words whitespace-pre-wrap`,e.state===`failed`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.url!==null&&(0,G.jsxs)(G.Fragment,{children:[` `,(0,G.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline hover:underline-offset-2`,children:e.url})]})]})]}),e.state===`review`&&r!==null&&(0,G.jsx)(bh,{draft:r,onChange:t=>m(e.path,{draft:t}),onSkip:n.length===1?null:()=>m(e.path,{state:`skipped`,text:`Skipped`,draft:null}),onRegenerate:()=>void h(e.path,()=>b(e.path,!1,r.base)),onCreate:()=>S(e.path,r)})]},e.path)})})]})})}function Ch(e,t){if(t===`commit`)return e.filter(e=>e.changed>0);if(t===`push`)return e.filter(e=>e.branch!==null&&(e.upstream===null||e.ahead>0));if(t===`pullRequest`)return e.filter(e=>e.branch!==null);throw Error(`Unknown git action ${String(t)}`)}function wh(e,t){return e===``?t:e}var Th=3e3,Eh=18e4;function Dh(e,t,n){let[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(0);(0,W.useEffect)(()=>{if(t===null)return;let n=P(e,t),r={projectId:t},a=!0,o=!1,s=!1;async function l(){if(!o){o=!0;try{let t=await L(e,`git.status`,r);if(!a)return;s=!1,i(e=>e!==null&&e.key===n&&Tn(e.repos,t)?e:{key:n,repos:t})}catch(e){a&&!s&&(s=!0,c(e))}finally{o=!1}}}function u(){document.hidden||l()}l();let d=window.setInterval(u,Th);return window.addEventListener(`focus`,u),()=>{a=!1,window.clearInterval(d),window.removeEventListener(`focus`,u)}},[e,t,n,a]),(0,W.useEffect)(()=>{if(t===null)return;let n={projectId:t},r=!0,i=!1;async function a(){if(!document.hidden)try{await L(e,`git.fetch`,n),r&&(i=!1,o(e=>e+1))}catch(e){r&&!i&&(i=!0,c(e))}}a();let s=window.setInterval(a,Eh);return()=>{r=!1,window.clearInterval(s)}},[e,t]);let s=(0,W.useCallback)(()=>o(e=>e+1),[]);return{repos:r!==null&&t!==null&&r.key===P(e,t)?r.repos:[],refresh:s}}function Oh(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(null),[s,l]=(0,W.useState)(!1),u=Ch(e.repos,`commit`);async function d(){if(u.length===1)i(!1),ch(e,u[0].path,``,!1);else{l(!0);try{for(let t of u)await L(e.machine,`git.commit`,{projectId:e.projectId,repo:t.path,message:``,push:!1});i(!1)}catch(e){c(e)}finally{l(!1),e.onRefresh()}}}return{target:e,action:t,setAction:n,menuOpen:r,setMenuOpen:i,branchRepo:a,setBranchRepo:o,committing:s,committable:u,yoloCommit:d}}function kh(e){let t=e.git,n=t.target.repos,r=n.reduce((e,t)=>e+t.ahead,0),i=Ch(n,`push`);function a(e){sh({labels:{working:`Pushing…`,done:`Pushed`,failed:`Push failed`},task:async()=>(await L(t.target.machine,`git.push`,{projectId:t.target.projectId,repo:e}),null),onRefresh:t.target.onRefresh})}return(0,G.jsxs)(G.Fragment,{children:[e.collapsed&&n.map(e=>(0,G.jsxs)(Mr,{onSelect:()=>t.setBranchRepo(e.path),children:[(0,G.jsx)(H,{icon:Xn}),(0,G.jsx)(`span`,{className:`flex min-w-0 flex-1`,children:(0,G.jsx)(`span`,{className:`text-muted-foreground truncate rounded-md border px-1.5 py-0.5 font-mono text-xs`,children:e.path===``?e.branch??`detached`:`${e.path}: ${e.branch??`detached`}`})}),(0,G.jsx)(`span`,{className:`text-muted-foreground flex gap-1 text-xs`,children:(0,G.jsx)(Er,{behind:e.behind,ahead:e.ahead})})]},e.path)),e.collapsed&&(0,G.jsxs)(Mr,{disabled:t.committable.length===0,onSelect:()=>t.setAction(`commit`),children:[(0,G.jsx)(H,{icon:ls}),`Commit`]}),(0,G.jsxs)(Mr,{disabled:i.length===0||t.committing,onSelect:()=>{i.length===1?a(i[0].path):t.setAction(`push`)},children:[(0,G.jsx)(H,{icon:zn}),`Just Push`,r>0&&(0,G.jsxs)(`span`,{className:`text-muted-foreground ml-auto text-xs tabular-nums`,children:[`↑`,r]})]}),(0,G.jsxs)(Mr,{disabled:t.committable.length===0||t.committing,onSelect:e=>{e.preventDefault(),t.yoloCommit()},children:[(0,G.jsx)(H,{icon:t.committing?jr:ls,className:B(t.committing&&`animate-spin`)}),t.committing?`Committing…`:`Yolo Commit`]}),(0,G.jsxs)(Mr,{disabled:Ch(n,`pullRequest`).length===0,onSelect:()=>t.setAction(`pullRequest`),children:[(0,G.jsx)(H,{icon:fs}),`Create pull request`]})]})}function Ah(e){let t=e.git,n=t.target.repos.find(e=>e.path===t.branchRepo);return(0,G.jsxs)(G.Fragment,{children:[t.action!==null&&(0,G.jsx)(Sh,{machine:t.target.machine,projectId:t.target.projectId,action:t.action,repos:t.target.repos,onClose:()=>t.setAction(null),onRefresh:t.target.onRefresh}),t.branchRepo!==null&&n!==void 0&&(0,G.jsx)(On,{machine:t.target.machine,projectId:t.target.projectId,repo:n,onRefresh:t.target.onRefresh,onClose:()=>t.setBranchRepo(null)})]})}function jh(e){let t=Oh(e),[n,r]=(0,W.useState)(!1),i=[...new Set(e.repos.map(e=>e.branch??`detached`))],a=e.repos.flatMap(e=>{let t=An(e);return t===null?[]:[{repo:e,next:t}]}),o=e.repos.map(e=>e.path===``?e.branch??`detached`:`${e.path}: ${e.branch??`detached`}`).join(`
|
|
14
|
-
`),s=i.length===1?i[0]:`${i.length} branches`;async function l(t){r(!0);try{await L(e.machine,`git.sync`,{projectId:e.projectId,repo:t})}catch(e){c(e)}finally{r(!1),e.onRefresh()}}return(0,G.jsxs)(G.Fragment,{children:[e.repos.length===1&&(0,G.jsx)(on,{machine:e.machine,projectId:e.projectId,repo:e.repos[0],onRefresh:e.onRefresh}),e.repos.length>1&&a.length===0&&(0,G.jsxs)(`span`,{className:`text-muted-foreground hidden max-w-48 items-center gap-1 text-xs sm:flex`,title:o,children:[(0,G.jsx)(H,{icon:Xn,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`truncate`,children:s})]}),e.repos.length>1&&a.length>0&&(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground hidden max-w-48 cursor-pointer items-center gap-1 text-xs sm:flex`,title:o,children:[(0,G.jsx)(H,{icon:n?jr:a.length===1?a[0].next.icon:jn,className:B(`size-3.5 shrink-0`,n&&`animate-spin`)}),(0,G.jsx)(`span`,{className:`truncate`,children:s})]})}),(0,G.jsx)(Dn,{align:`end`,className:`w-64`,children:a.map(e=>(0,G.jsxs)(Mr,{disabled:n,onSelect:()=>void l(e.repo.path),children:[(0,G.jsx)(H,{icon:e.next.icon}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.next.label,` ·`,` `,e.repo.path===``?e.repo.branch:e.repo.path]}),(0,G.jsx)(`span`,{className:`text-muted-foreground flex gap-1 text-xs`,children:(0,G.jsx)(Er,{behind:e.repo.behind,ahead:e.repo.ahead})})]},e.repo.path))})]}),(0,G.jsxs)(`div`,{className:`ml-2.5 flex w-fit`,children:[(0,G.jsxs)(U,{variant:`outline`,size:`xs`,className:`rounded-e-none border-e-0`,disabled:t.committable.length===0,onClick:()=>t.setAction(`commit`),children:[(0,G.jsx)(H,{icon:ls}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:`Commit`})]}),(0,G.jsxs)(mn,{open:t.menuOpen,onOpenChange:t.setMenuOpen,children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(U,{variant:`outline`,size:`icon-xs`,className:`rounded-s-none`,"aria-label":`Git actions`,children:(0,G.jsx)(H,{icon:t.committing?jr:Rr,className:B(`size-4`,t.committing&&`animate-spin`)})})}),(0,G.jsx)(Dn,{align:`end`,className:`w-56`,children:(0,G.jsx)(kh,{git:t,collapsed:!1})})]})]}),(0,G.jsx)(Ah,{git:t})]})}function Mh({className:e,size:t=`default`,...n}){return(0,G.jsx)(ed,{"data-slot":`switch`,"data-size":t,className:B(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,G.jsx)(nd,{"data-slot":`switch-thumb`,className:`bg-background dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0`})})}function Nh(e){return(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`h2`,{className:`text-muted-foreground mb-2 px-1 text-xs font-medium`,children:[e.title,e.note&&(0,G.jsxs)(`span`,{className:`font-normal`,children:[` · `,e.note]})]}),(0,G.jsx)(`div`,{className:`@container divide-y overflow-hidden rounded-xl border`,children:e.children})]})}function Q(e){return(0,G.jsxs)(`label`,{className:`flex min-h-13 flex-wrap items-center gap-x-4 gap-y-2 px-4 py-2.5`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 text-sm font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`max-w-full shrink-0 @max-lg:has-[[data-slot=select-trigger],input:not([type=number])]:w-full @max-lg:has-[[data-slot=select-trigger],input:not([type=number])]:*:w-full @max-lg:**:data-[slot=select-trigger]:w-full`,children:e.children})]})}function Ph(e){let[t,n]=(0,W.useState)(e.value);function r(){t!==e.value&&(e.valid&&!e.valid(t)?n(e.value):e.onCommit(t))}return(0,G.jsx)(Tp,{className:B(`w-56`,e.className),type:e.type,min:e.type===`number`?0:void 0,step:e.step,placeholder:e.placeholder,disabled:e.disabled,value:t,onChange:e=>n(e.target.value),onBlur:r,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}function Fh(e){return(0,G.jsx)(Ph,{type:`number`,className:`w-24`,step:e.step??1,value:String(e.value),valid:e=>e!==``&&Number(e)>=0,onCommit:t=>e.onCommit(Number(t))},e.value)}function Ih(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null);return(0,W.useEffect)(()=>{let t=!0;return n(null),i(null),L(e.machine,`dictation.workflows`,void 0).then(e=>{t&&n(e)},e=>{t&&i(Ht(e))}),()=>{t=!1}},[e.machine]),(0,G.jsx)(Nh,{title:`Dictation`,note:`This machine transcribes your recordings with the OiPer app`,children:(0,G.jsx)(Q,{label:`OiPer workflow`,children:r===null?t===null?(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Checking…`}):(0,G.jsxs)(fh,{value:e.config.dictation.workflowId??``,onValueChange:t=>void po(e.machine,{...e.config,dictation:{...e.config.dictation,workflowId:t}}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{placeholder:`Choose a workflow`})}),(0,G.jsx)(hh,{children:t.map(e=>(0,G.jsx)(gh,{value:e.id,children:e.name},e.id))})]}):(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:r})})})}var Lh=`3.6.8`,Rh=`1.3.1`,zh=[{family:`FiraCode Nerd Font`,label:`Fira Code`},{family:`JetBrainsMono Nerd Font`,label:`JetBrains Mono`},{family:`CaskaydiaCove Nerd Font`,label:`Cascadia Code`},{family:`Hack Nerd Font`,label:`Hack`}],Bh=[{value:`macos`,label:`macOS`},{value:`linux`,label:`Linux`},{value:`windows`,label:`Windows`}];async function Vh(e){let t=`${e.font.size}px ${e.font.family}`;await Promise.all([document.fonts.load(t),document.fonts.load(`bold ${t}`)]);let n=document.documentElement.style;n.setProperty(`--pad-top`,`${e.padding.top}px`),n.setProperty(`--pad-right`,`${e.padding.right}px`),n.setProperty(`--pad-bottom`,`${e.padding.bottom}px`),n.setProperty(`--pad-left`,`${e.padding.left}px`)}function Hh(e,t){let n=te();return{fontFamily:e.font.family,fontSize:e.font.size,lineHeight:e.font.lineHeight,ligatures:e.font.ligatures,cursorStyle:e.cursor.style,cursorBlink:e.cursor.blink,scrollback:e.scrollback,boldIsBright:e.boldIsBright,colors:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorText:n.background,selectionBackground:n.selectionBackground,selectionForeground:n.foreground,palette:n.palette},version:Uh(t),clickToMoveCursor:e.behavior.clickToMoveCursor,optionAsMeta:e.behavior.optionAsMeta,windowsCopyPaste:e.behavior.windowsCopyPaste}}function Uh(e){if(e===`offsite`)return`offsite 0.0.0`;if(e===`ghostty`)return`ghostty ${Rh}`;if(e===`iterm2`)return`iTerm2 ${Lh}`;throw Error(`unknown terminal identity ${e}`)}function Wh(e){let t=e.prefs.editor,[n,r]=(0,W.useState)(!zh.some(e=>e.family===t.font.family));function i(t){Ye({...e.prefs,editor:t})}function a(e,n){i({...t,[e]:{...t[e],...n}})}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Nh,{title:`Font`,children:[(0,G.jsx)(Q,{label:`Family`,children:(0,G.jsxs)(fh,{value:n?`custom`:t.font.family,onValueChange:e=>{r(e===`custom`),e!==`custom`&&a(`font`,{family:e})},children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[zh.map(e=>(0,G.jsx)(gh,{value:e.family,children:e.label},e.family)),(0,G.jsx)(gh,{value:`custom`,children:`Custom`})]})]})}),n&&(0,G.jsx)(Q,{label:`Custom family`,children:(0,G.jsx)(Ph,{placeholder:`Installed font name`,value:t.font.family,onCommit:e=>a(`font`,{family:e})})}),(0,G.jsx)(Q,{label:`Size`,children:(0,G.jsx)(Fh,{value:t.font.size,step:.5,onCommit:e=>a(`font`,{size:e})})}),(0,G.jsx)(Q,{label:`Line height`,children:(0,G.jsx)(Fh,{value:t.font.lineHeight,step:.05,onCommit:e=>a(`font`,{lineHeight:e})})}),(0,G.jsx)(Q,{label:`Ligatures`,children:(0,G.jsx)(Mh,{checked:t.font.ligatures,onCheckedChange:e=>a(`font`,{ligatures:e})})}),(0,G.jsx)(Q,{label:`Font features`,children:(0,G.jsx)(Ph,{placeholder:`'ss01', 'zero'`,value:t.font.features,onCommit:e=>a(`font`,{features:e})})})]}),(0,G.jsxs)(Nh,{title:`Cursor`,children:[(0,G.jsx)(Q,{label:`Style`,children:(0,G.jsxs)(fh,{value:t.cursor.style,onValueChange:e=>a(`cursor`,{style:e}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`block`,children:`Block`}),(0,G.jsx)(gh,{value:`bar`,children:`Bar`}),(0,G.jsx)(gh,{value:`underline`,children:`Underline`})]})]})}),(0,G.jsx)(Q,{label:`Blink`,children:(0,G.jsx)(Mh,{checked:t.cursor.blink,onCheckedChange:e=>a(`cursor`,{blink:e})})})]}),(0,G.jsxs)(Nh,{title:`Text`,children:[(0,G.jsx)(Q,{label:`Tab size`,children:(0,G.jsx)(Fh,{value:t.tabSize,onCommit:e=>i({...t,tabSize:e})})}),(0,G.jsx)(Q,{label:`Word wrap`,children:(0,G.jsx)(Mh,{checked:t.wordWrap,onCheckedChange:e=>i({...t,wordWrap:e})})})]})]})}var Gh=[{id:`original`,name:`Original`,scale:1,tile:null},{id:`small`,name:`Small`,scale:.7,tile:null},{id:`dark`,name:`Dark`,scale:.7,tile:{color:`#0a0a0a`,shape:`rounded`}},{id:`light`,name:`Light`,scale:.7,tile:{color:`#ffffff`,shape:`rounded`}},{id:`dark-circle`,name:`Dark circle`,scale:.62,tile:{color:`#0a0a0a`,shape:`circle`}},{id:`light-circle`,name:`Light circle`,scale:.62,tile:{color:`#ffffff`,shape:`circle`}},{id:`dark-square`,name:`Dark square`,scale:.7,tile:{color:`#0a0a0a`,shape:`square`}},{id:`light-square`,name:`Light square`,scale:.7,tile:{color:`#ffffff`,shape:`square`}}],Kh=Fe.withTag(`settings`);function qh(e){let t=e.prefs;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Nh,{title:`Appearance`,children:(0,G.jsx)(Q,{label:`Theme`,children:(0,G.jsxs)(fh,{value:t.theme,onValueChange:e=>Ye({...t,theme:e}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsx)(hh,{children:ae.map(e=>(0,G.jsx)(gh,{value:e.id,children:e.name},e.id))})]})})}),(0,G.jsx)(Nh,{title:`Sidebar`,children:(0,G.jsx)(Q,{label:`Group active sessions by project in Inbox`,children:(0,G.jsx)(Mh,{checked:t.groupActiveByProject,onCheckedChange:e=>Ye({...t,groupActiveByProject:e})})})}),(0,G.jsxs)(Nh,{title:`Dictate button`,note:`Takes the place of Send while the message is empty`,children:[(0,G.jsx)(Q,{label:`On desktop`,children:(0,G.jsx)(Mh,{checked:t.dictateButton.desktop,onCheckedChange:e=>Ye({...t,dictateButton:{...t.dictateButton,desktop:e}})})}),(0,G.jsx)(Q,{label:`On mobile`,children:(0,G.jsx)(Mh,{checked:t.dictateButton.mobile,onCheckedChange:e=>Ye({...t,dictateButton:{...t.dictateButton,mobile:e}})})})]}),(0,G.jsx)(Xh,{}),(0,G.jsx)(Jh,{}),(0,G.jsx)(U,{variant:`outline`,onClick:e.onRestore,children:`Restore browser defaults`})]})}function Jh(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(null);async function i(){t(!0),r(null);try{let e=`serviceWorker`in navigator?await navigator.serviceWorker.getRegistration():void 0;if(e===void 0){let e=await fetch(`/?update=${Date.now()}`,{cache:`no-store`});if(!e.ok)throw Error(`the server answered ${e.status}`)}else{await e.update();let t=e.installing??e.waiting;t!==null&&await Yh(t)}location.reload()}catch(e){Kh.error(`could not update`,e),r(Ht(e)),t(!1)}}return(0,G.jsx)(Nh,{title:`App`,children:(0,G.jsx)(Q,{label:`Load the newest version of OffSite in this browser`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[n!==null&&(0,G.jsxs)(`span`,{className:`text-destructive text-xs`,children:[`Could not update: `,n]}),(0,G.jsxs)(U,{size:`sm`,variant:`outline`,disabled:e,onClick:()=>void i(),children:[e&&(0,G.jsx)(H,{icon:Gn,className:`animate-spin`}),e?`Updating…`:`Update`]})]})})})}async function Yh(e){await new Promise((t,n)=>{function r(){e.state===`activated`&&t(),e.state===`redundant`&&n(Error(`the new version failed to install`))}e.addEventListener(`statechange`,r),r()})}function Xh(){let e=k(e=>e.machines.find(e=>e.addresses.some(e=>(o??[location.origin]).includes(e))));if(e===void 0||e.appIcon===null)return null;let t=e.appIcon;return(0,G.jsx)(Nh,{title:`App icon`,children:(0,G.jsx)(`div`,{className:`grid grid-cols-4 gap-2 p-3 @max-lg:grid-cols-2`,children:Gh.map(n=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":t===n.id,className:B(`hover:bg-accent flex flex-col items-center gap-2 rounded-lg border p-3 text-xs`,t===n.id&&`border-primary bg-accent`),onClick:()=>L(e.id,`appIcon.save`,n.id).catch(c),children:[(0,G.jsx)(`span`,{className:B(`flex size-12 items-center justify-center`,n.tile?.shape===`rounded`&&`rounded-[22%]`,n.tile?.shape===`circle`&&`rounded-full`,n.tile!==null&&`ring-border ring-1`),style:{background:n.tile?.color},children:(0,G.jsx)(`img`,{src:`/icon.svg`,alt:``,style:{width:`${n.scale*100}%`}})}),n.name]},n.id))})})}function Zh(e){for(let t=0;t<e.length;t++){let n=e[t];if(!n.startsWith(`-`)&&!n.startsWith(`+`))return!1;let r=n.startsWith(`-`),i=n.slice(1);if(i===``||i===`-`)return!1;if(i.startsWith(`-`)){if(!Qh(i.slice(1),r))return!1}else for(let n=0;n<i.length;n++){let a=i[n];if(a===`o`){let a=i.slice(n+1);if(a===``){if(t++,t===e.length)return!1;a=e[t]}if(!Qh(a,r))return!1;break}if(a===`b`||a===`c`||r&&`dfnprvx`.includes(a)||!r&&a===`i`)return!1}}return!0}function Qh(e,t){let n=e.toLowerCase().replace(/[-_]/g,``),r=t;return n.startsWith(`no`)&&(n=n.slice(2),r=!t),[`rcs`,`globalrcs`,`interactive`,`exec`].includes(n)?r:![`privileged`,`restricted`,`sourcetrace`,`verbose`,`xtrace`].includes(n)||!r}function $h(e,t,n){if(t===`windows`)return`Not available on Windows`;if(e!==null&&/[\n"'\\$`;&|<>()*?[\]{}#!]/.test(e))return`Not available for commands with shell syntax`;let r=e===null?[n]:e.split(/[ \t]/).filter(e=>e!==``);if(r.length===0)return`Available for bash, zsh and fish`;let i=r[0],a=i.split(`/`).pop(),o=r.slice(1);return a===`bash`?t===`macos`&&(i===`/bin/bash`||!i.includes(`/`))?`Needs a newer bash than the one macOS includes`:o.every(e=>[`-l`,`--login`,`-i`].includes(e))?null:`Not available with these bash options`:a===`zsh`?Zh(o)?null:`Not available with these zsh options`:a===`fish`?o.every(e=>{if(e.startsWith(`--`)){let t=e.slice(2).split(`=`)[0];return t===``||![`command`,`no-config`,`no-execute`].some(e=>e.startsWith(t))}return!(e.startsWith(`-`)&&/[cNn]/.test(e))})?null:`Not available with these fish options`:`Available for bash, zsh and fish`}var eg=[10,15,30,45,60,120,180,300,600,900,1800,3600];function tg(e){let t=e.config;function n(n){po(e.machine,{...t,...n})}return(0,G.jsxs)(Nh,{title:`Agents`,children:[(0,G.jsx)(Q,{label:`Send while working`,children:(0,G.jsxs)(fh,{value:t.delivery,onValueChange:n=>{if(n!==`queue`&&n!==`steer`)throw Error(`Unknown delivery ${n}`);po(e.machine,{...t,delivery:n})},children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`queue`,children:`Queue messages`}),(0,G.jsx)(gh,{value:`steer`,children:`Steer the agent`})]})]})}),(0,G.jsx)(Q,{label:`Auto-skip questions`,children:(0,G.jsx)(ng,{value:t.autoSkipQuestionTimeout,onChange:e=>n({autoSkipQuestionTimeout:e})})}),(0,G.jsx)(Q,{label:`Auto-resolve permissions`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(fh,{value:t.autoPermissionMode,onValueChange:e=>{if(e!==`bypass`&&e!==`allow`&&e!==`deny`)throw Error(`Unknown decision ${e}`);n({autoPermissionMode:e})},children:[(0,G.jsx)(mh,{className:`w-24`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`bypass`,children:`Bypass`}),(0,G.jsx)(gh,{value:`allow`,children:`Allow`}),(0,G.jsx)(gh,{value:`deny`,children:`Deny`})]})]}),(0,G.jsx)(ng,{value:t.autoPermissionTimeout,onChange:e=>n({autoPermissionTimeout:e})})]})})]})}function ng(e){let t=e.value===null||eg.includes(e.value)?eg:[...eg,e.value].sort((e,t)=>e-t);return(0,G.jsxs)(fh,{value:e.value===null?`off`:String(e.value),onValueChange:t=>e.onChange(t===`off`?null:Number(t)),children:[(0,G.jsx)(mh,{className:`w-40`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`off`,children:`Off`}),t.map(e=>(0,G.jsx)(gh,{value:String(e),children:e===3600?`After 1 hour`:e===60?`After 1 minute`:e%60==0?`After ${e/60} minutes`:`After ${e} seconds`},e))]})]})}function rg(e){let t=e.config[e.setting],[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(t.provider===null)return;let n=!0;return r(null),a(null),L(e.machine,`capabilities`,{provider:t.provider,accountId:t.accountId,projectId:null}).then(e=>{n&&r(e.models)},e=>{n&&a(Ht(e))}),()=>{n=!1}},[e.machine,t.provider,t.accountId]);function o(t){po(e.machine,{...e.config,[e.setting]:t})}function s(t){if(t===`off`){o({provider:null,accountId:null,model:null});return}if(t===`opencode`){o({provider:`opencode`,accountId:null,model:null});return}let n=[...e.claudeAccounts,...e.codexAccounts].find(e=>e.id===t);if(n===void 0)throw Error(`That account was removed`);o({provider:n.provider,accountId:n.id,model:null})}return(0,G.jsxs)(Nh,{title:e.title,children:[(0,G.jsx)(Q,{label:`Account`,children:(0,G.jsxs)(fh,{value:t.provider===null?`off`:t.provider===`opencode`?`opencode`:t.accountId??`off`,onValueChange:s,children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`off`,children:`Off`}),[...e.claudeAccounts,...e.codexAccounts].map(e=>(0,G.jsxs)(gh,{value:e.id,disabled:!e.valid,children:[(0,G.jsx)(gc,{provider:e.provider,className:`size-4`}),`${rr[e.provider]} · ${e.name}`]},e.id)),e.openCode.available&&(0,G.jsxs)(gh,{value:`opencode`,children:[(0,G.jsx)(gc,{provider:`opencode`,className:`size-4`}),rr.opencode]})]})]})}),t.provider!==null&&(0,G.jsx)(Q,{label:`Model`,children:(0,G.jsxs)(fh,{value:t.model??void 0,disabled:n===null,onValueChange:e=>o({...t,model:e}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{placeholder:i===null?n===null?`Loading…`:`Choose a model`:`Unavailable`})}),(0,G.jsx)(hh,{children:(n??[]).map(e=>(0,G.jsx)(gh,{value:e.value,children:e.name},e.value))})]})}),i!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:i})]})}var ig={zsh:`M11.415 5.038a.58.58 0 0 0-.543.197L.135 18.021a.58.58 0 0 0 .071.814.58.58 0 0 0 .815-.07L11.757 5.979a.58.58 0 0 0-.07-.815.6.6 0 0 0-.272-.126m-8.113.317a3.133 3.133 0 0 0-3.12 3.12 3.13 3.13 0 0 0 3.12 3.119A3.133 3.133 0 0 0 6.42 8.475a3.13 3.13 0 0 0-3.119-3.119m0 1.806a1.3 1.3 0 0 1 1.314 1.313 1.3 1.3 0 0 1-1.314 1.312A1.3 1.3 0 0 1 1.99 8.475a1.3 1.3 0 0 1 1.312-1.314m5.253 5.253a3.13 3.13 0 0 0-3.119 3.119 3.13 3.13 0 0 0 3.12 3.118 3.133 3.133 0 0 0 3.118-3.12 3.133 3.133 0 0 0-3.119-3.118m0 1.805a1.3 1.3 0 0 1 1.313 1.314c0 .735-.577 1.312-1.312 1.312a1.3 1.3 0 0 1-1.314-1.312 1.3 1.3 0 0 1 1.313-1.314m7.201 3.276a.58.58 0 0 0-.578.578.58.58 0 0 0 .578.578h7.666a.58.58 0 0 0 .579-.578.58.58 0 0 0-.579-.578Z`,bash:`M21.038,4.9l-7.577-4.498C13.009,0.134,12.505,0,12,0c-0.505,0-1.009,0.134-1.462,0.403L2.961,4.9 C2.057,5.437,1.5,6.429,1.5,7.503v8.995c0,1.073,0.557,2.066,1.462,2.603l7.577,4.497C10.991,23.866,11.495,24,12,24 c0.505,0,1.009-0.134,1.461-0.402l7.577-4.497c0.904-0.537,1.462-1.529,1.462-2.603V7.503C22.5,6.429,21.943,5.437,21.038,4.9z M15.17,18.946l0.013,0.646c0.001,0.078-0.05,0.167-0.111,0.198l-0.383,0.22c-0.061,0.031-0.111-0.007-0.112-0.085L14.57,19.29 c-0.328,0.136-0.66,0.169-0.872,0.084c-0.04-0.016-0.057-0.075-0.041-0.142l0.139-0.584c0.011-0.046,0.036-0.092,0.069-0.121 c0.012-0.011,0.024-0.02,0.036-0.026c0.022-0.011,0.043-0.014,0.062-0.006c0.229,0.077,0.521,0.041,0.802-0.101 c0.357-0.181,0.596-0.545,0.592-0.907c-0.003-0.328-0.181-0.465-0.613-0.468c-0.55,0.001-1.064-0.107-1.072-0.917 c-0.007-0.667,0.34-1.361,0.889-1.8l-0.007-0.652c-0.001-0.08,0.048-0.168,0.111-0.2l0.37-0.236 c0.061-0.031,0.111,0.007,0.112,0.087l0.006,0.653c0.273-0.109,0.511-0.138,0.726-0.088c0.047,0.012,0.067,0.076,0.048,0.151 l-0.144,0.578c-0.011,0.044-0.036,0.088-0.065,0.116c-0.012,0.012-0.025,0.021-0.038,0.028c-0.019,0.01-0.038,0.013-0.057,0.009 c-0.098-0.022-0.332-0.073-0.699,0.113c-0.385,0.195-0.52,0.53-0.517,0.778c0.003,0.297,0.155,0.387,0.681,0.396 c0.7,0.012,1.003,0.318,1.01,1.023C16.105,17.747,15.736,18.491,15.17,18.946z M19.143,17.859c0,0.06-0.008,0.116-0.058,0.145 l-1.916,1.164c-0.05,0.029-0.09,0.004-0.09-0.056v-0.494c0-0.06,0.037-0.093,0.087-0.122l1.887-1.129 c0.05-0.029,0.09-0.004,0.09,0.056V17.859z M20.459,6.797l-7.168,4.427c-0.894,0.523-1.553,1.109-1.553,2.187v8.833 c0,0.645,0.26,1.063,0.66,1.184c-0.131,0.023-0.264,0.039-0.398,0.039c-0.42,0-0.833-0.114-1.197-0.33L3.226,18.64 c-0.741-0.44-1.201-1.261-1.201-2.142V7.503c0-0.881,0.46-1.702,1.201-2.142l7.577-4.498c0.363-0.216,0.777-0.33,1.197-0.33 c0.419,0,0.833,0.114,1.197,0.33l7.577,4.498c0.624,0.371,1.046,1.013,1.164,1.732C21.686,6.557,21.12,6.411,20.459,6.797z`,fish:`m19.164 9.228-3.016 2.688v.527l3.016 2.688v-1.228l-1.936-1.723 1.936-1.724V9.228m-6.658.046v1.208l1.905 1.696-1.905 1.695v1.209l2.968-2.645v-.518l-2.968-2.645M9.781 7.847a6.519 6.519 0 0 0-2.038-.335c-.672 0-1.349.112-2.03.335a9.23 9.23 0 0 0-2.088 1.017v.723c.69-.4 1.377-.7 2.06-.897a7.388 7.388 0 0 1 2.058-.296c.684 0 1.368.098 2.052.296a9.452 9.452 0 0 1 2.075.897v-.723a9.229 9.229 0 0 0-2.09-1.017m.014 7.78a7.371 7.371 0 0 1-2.052.296 7.388 7.388 0 0 1-2.057-.296 9.18 9.18 0 0 1-2.061-.897v.723a9.228 9.228 0 0 0 2.088 1.017 6.492 6.492 0 0 0 2.03.335c.678 0 1.357-.112 2.038-.335a9.227 9.227 0 0 0 2.089-1.017v-.723c-.7.4-1.391.7-2.075.897m.602-11.23h-.51L7.28 6.92h1.19l1.672-1.62 1.671 1.62h1.191l-2.607-2.525m-2.965 13.68v-.824H6.427v.825l.786 1.527h.614l-.395-1.527M4.127 10.95v1.216H5.13V10.95H4.127m-1.16-1.695L0 11.901v.518l2.967 2.645v-1.208L1.063 12.16l1.904-1.695V9.256m20.68 3.28c-.235-.3-.574-.509-1.017-.626.395-.103.696-.278.902-.525.206-.247.31-.556.31-.926 0-.546-.197-.984-.59-1.314-.393-.33-.919-.495-1.575-.495-.22 0-.473.025-.758.073-.284.048-.61.12-.974.217v.84c.314-.12.613-.21.9-.27a4.05 4.05 0 0 1 .832-.091c.403 0 .714.093.933.278.218.185.328.451.328.798 0 .328-.118.584-.353.768-.235.184-.562.276-.98.276h-.697v.75h.696c.458 0 .821.116 1.09.346.268.23.402.542.402.934 0 .425-.134.75-.402.976-.269.226-.653.339-1.153.339a3.55 3.55 0 0 1-.89-.117 4.395 4.395 0 0 1-.91-.358v.909a6.1 6.1 0 0 0 .95.249c.323.057.639.085.95.085.738 0 1.315-.177 1.733-.53.417-.355.626-.842.626-1.463 0-.449-.118-.823-.353-1.123`,powershell:`M23.181 2.974c.568 0 .923.463.792 1.035l-3.659 15.982c-.13.572-.697 1.035-1.265 1.035H.819c-.568 0-.923-.463-.792-1.035L3.686 4.009c.13-.572.697-1.035 1.265-1.035zm-8.375 9.346c.251-.394.227-.905-.09-1.243L9.122 5.125c-.38-.404-1.037-.407-1.466-.003-.429.402-.468 1.056-.088 1.46l4.662 4.96v.11l-7.42 5.374c-.45.327-.533.977-.187 1.453.346.476.991.597 1.44.27l8.229-5.91c.28-.196.438-.365.514-.52zm-2.796 4.399a.928.928 0 00-.934.923c0 .51.418.923.934.923h4.433a.928.928 0 00.934-.923.928.928 0 00-.934-.923z`,cmd:`M8.165 6V3h7.665v3H8.165zm-.5-3H1c-.55 0-1 .45-1 1v2h7.665V3zM23 3h-6.67v3H24V4c0-.55-.45-1-1-1zM0 6.5h24V20c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V6.5zM11.5 18c0 .3.2.5.5.5h8c.3 0 .5-.2.5-.5v-1.5c0-.3-.2-.5-.5-.5h-8c-.3 0-.5.2-.5.5V18zm-5.2-4.55l-3.1 3.1c-.25.25-.25.6 0 .8l.9.9c.25.25.6.25.8 0l4.4-4.4a.52.52 0 0 0 0-.8l-4.4-4.4c-.2-.2-.6-.2-.8 0l-.9.9c-.25.2-.25.55 0 .8l3.1 3.1z`},ag={zsh:`zsh`,bash:`bash`,fish:`fish`,pwsh:`powershell`,powershell:`powershell`,cmd:`cmd`},og={macos:[`zsh`,`bash`,`fish`,`pwsh`],linux:[`bash`,`zsh`,`fish`,`pwsh`],windows:[`pwsh`,`powershell`,`cmd`]};function sg(e){let t=e.trim().split(/[\\/]/).pop()?.toLowerCase().replace(/\.exe$/,``);return t===void 0?void 0:ag[t]}function cg(e){return e.replace(/[\\/][^\\/]*$/,``)}function lg(e){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-4 flex-none`,fill:`currentColor`,children:(0,G.jsx)(`path`,{d:ig[e.logo]})})}function ug(e){let[t,n]=(0,W.useState)(e.value??``),r=sg(t);function i(t){n(t),t!==(e.value??``)&&e.onCommit(t===``?null:t)}return(0,G.jsxs)(`div`,{className:`relative w-56`,children:[r&&(0,G.jsx)(`span`,{className:`text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2`,children:(0,G.jsx)(lg,{logo:r})}),(0,G.jsx)(Tp,{className:r?`pr-9 pl-8`:`pr-9`,placeholder:`System default`,value:t,onChange:e=>n(e.target.value),onBlur:()=>i(t),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}}),(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(U,{variant:`ghost`,size:`icon-xs`,"aria-label":`Known shells`,className:`text-muted-foreground absolute top-1/2 right-1.5 -translate-y-1/2`,children:(0,G.jsx)(H,{icon:Dr})})}),(0,G.jsx)(Dn,{align:`end`,className:`w-72`,children:(0,G.jsx)(dg,{machine:e.machine,platform:e.platform,device:e.device,onCommit:i})})]})]})}function dg(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null),a=e.platform===e.device,o=a?t:og[e.platform].map(e=>({name:e,path:null}));return(0,W.useEffect)(()=>{a&&L(e.machine,`terminal.shells`,void 0).then(n,e=>i(Ht(e)))},[e.machine,a]),(0,G.jsxs)(G.Fragment,{children:[r&&(0,G.jsx)(`p`,{className:`text-destructive px-2 py-1.5 text-xs`,children:r}),o?.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground px-2 py-1.5 text-xs`,children:`No known shells found`}),o?.map(t=>(0,G.jsxs)(Mr,{onSelect:()=>e.onCommit(t.path??t.name),children:[(0,G.jsx)(lg,{logo:ag[t.name]}),t.name,t.path!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground ml-auto min-w-0 truncate pl-3 text-xs [direction:rtl]`,title:t.path,children:(0,G.jsx)(`bdi`,{children:cg(t.path)})})]},t.path??t.name)),(0,G.jsx)(Pn,{}),(0,G.jsx)(Mr,{onSelect:()=>e.onCommit(``),children:`System default`})]})}function fg(e){let t=e.config.workingDir[e.platform]??``;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Nh,{title:`Projects`,children:(0,G.jsx)(Q,{label:`Working directory`,children:(0,G.jsx)(Ph,{className:`w-72 font-mono`,value:t,placeholder:`Home folder`,onCommit:t=>po(e.machine,{...e.config,workingDir:{...e.config.workingDir,[e.platform]:t.trim()===``?null:t.trim()}})},`${e.machine}-${t}`)})}),(0,G.jsx)(pg,{machine:e.machine,config:e.config,platform:e.platform,defaultShell:e.defaultShell},e.machine),(0,G.jsx)(tg,{machine:e.machine,config:e.config}),(0,G.jsx)(rg,{title:`Commit messages and pull requests`,setting:`commitMessage`,machine:e.machine,config:e.config,claudeAccounts:e.claudeAccounts,codexAccounts:e.codexAccounts,openCode:e.openCode},`git-${e.machine}`),(0,G.jsx)(rg,{title:`Session titles`,setting:`titleGeneration`,machine:e.machine,config:e.config,claudeAccounts:e.claudeAccounts,codexAccounts:e.codexAccounts,openCode:e.openCode},`titles-${e.machine}`),(0,G.jsx)(U,{variant:`outline`,onClick:e.onRestore,children:`Restore machine defaults`})]})}function pg(e){let t=e.config.terminal,[n,r]=(0,W.useState)(e.platform),i=$h(t.shell[e.platform],e.platform,e.defaultShell);function a(t){po(e.machine,{...e.config,terminal:t})}return(0,G.jsxs)(Nh,{title:`Shell`,note:`Applies to new terminals`,children:[(0,G.jsx)(Q,{label:`Platform`,children:(0,G.jsxs)(fh,{value:n,onValueChange:e=>r(e),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsx)(hh,{children:Bh.map(t=>(0,G.jsxs)(gh,{value:t.value,children:[t.label,t.value===e.platform&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`(this machine)`})]},t.value))})]})}),(0,G.jsx)(Q,{label:`Command`,children:(0,G.jsx)(ug,{machine:e.machine,platform:n,device:e.platform,value:t.shell[n],onCommit:e=>a({...t,shell:{...t.shell,[n]:e}})},`${e.machine}-${n}-command`)}),(0,G.jsx)(Q,{label:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Shell integration`,(0,G.jsx)(Xr,{label:(0,G.jsxs)(`div`,{children:[`Tells the terminal where prompts and commands start and end.`,(0,G.jsxs)(`ul`,{className:`mt-1 list-disc pl-4`,children:[(0,G.jsx)(`li`,{children:`Click in the command line to move the cursor`}),(0,G.jsx)(`li`,{children:`Ignore clipboard reads once the command that asked has finished`})]})]}),children:(0,G.jsx)(`span`,{onClick:e=>e.preventDefault(),children:(0,G.jsx)(H,{icon:_s,"aria-label":`About shell integration`,className:`text-muted-foreground size-3.5`})})})]}),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground max-w-32 text-right text-xs sm:max-w-none`,children:i}),(0,G.jsx)(Mh,{checked:i===null&&t.behavior.shellIntegration,disabled:i!==null,onCheckedChange:e=>a({...t,behavior:{...t.behavior,shellIntegration:e}})})]})}),(0,G.jsx)(mg,{identity:t.behavior.terminalIdentity,onChange:e=>a({...t,behavior:{...t.behavior,terminalIdentity:e}})})]})}function mg(e){return(0,G.jsx)(Q,{label:`Report the terminal as`,children:(0,G.jsxs)(fh,{value:e.identity,onValueChange:e.onChange,children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`offsite`,children:`OffSite`}),(0,G.jsx)(gh,{value:`ghostty`,children:`Ghostty`}),(0,G.jsx)(gh,{value:`iterm2`,children:`iTerm2`})]})]})})}var hg=(0,W.createContext)({});function gg(e){let t=(0,W.useRef)(null);return t.current===null&&(t.current=e()),t.current}var _g=typeof window<`u`?W.useLayoutEffect:W.useEffect,vg=(0,W.createContext)(null);function yg(e,t){e.indexOf(t)===-1&&e.push(t)}function bg(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}function xg([...e],t,n){let r=t<0?e.length+t:t;if(r>=0&&r<e.length){let r=n<0?e.length+n:n,[i]=e.splice(t,1);e.splice(r,0,i)}return e}var Sg=(e,t,n)=>n>t?t:n<e?e:n,Cg={},wg=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Tg=e=>typeof e==`object`&&!!e,Eg=e=>/^0[^.\s]+$/u.test(e);function Dg(e){let t;return()=>(t===void 0&&(t=e()),t)}var Og=e=>e,kg=(...e)=>e.reduce((e,t)=>n=>t(e(n))),Ag=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},jg=class{constructor(){this.subscriptions=[]}add(e){return yg(this.subscriptions,e),()=>this.remove(e)}remove(e){bg(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r){if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},Mg=e=>e*1e3,Ng=e=>e/1e3,Pg=(e,t)=>t?1e3/t*e:0,Fg=(e,t,n)=>e*(3*(1-e)*((1-e)*t+e*n)+e*e);function Ig(e,t,n,r){return e===t&&n===r?Og:i=>{let a=0,o=1,s=i;for(let t=0;;t++){s>=a&&s<=o||(s=(a+o)/2);let r=Fg(s,e,n)-i;if(r*r<1e-28||t===40)break;r>0?o=s:a=s,s-=r*1e-7/(Fg(s+1e-7,e,n)-i-r)}return Fg(s,t,r)}}var Lg=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Rg=e=>t=>1-e(1-t),zg=Ig(.33,1.53,.69,.99),Bg=Rg(zg),Vg=Lg(Bg),Hg=e=>e>=1?1:(e*=2)<1?.5*Bg(e):.5*(2-2**(-10*(e-1))),Ug=e=>1-Math.sin(Math.acos(e)),Wg=Rg(Ug),Gg=Lg(Ug),Kg=Ig(.42,0,1,1),qg=Ig(0,0,.58,1),Jg=Ig(.42,0,.58,1),Yg=e=>Array.isArray(e)&&typeof e[0]!=`number`,Xg=e=>Array.isArray(e)&&typeof e[0]==`number`,Zg={linear:Og,easeIn:Kg,easeInOut:Jg,easeOut:qg,circIn:Ug,circInOut:Gg,circOut:Wg,backIn:Bg,backInOut:Vg,backOut:zg,anticipate:Hg},Qg=e=>typeof e==`string`,$g=e=>{if(Xg(e)){let[t,n,r,i]=e;return Ig(t,n,r,i)}return Qg(e)?Zg[e]:e},e_={delta:0,timestamp:0,isProcessing:!1},t_;function n_(){t_=void 0}var r_={now:()=>(t_===void 0&&r_.set(e_.isProcessing||Cg.useManualTiming?e_.timestamp:performance.now()),t_),set:e=>{t_=e,queueMicrotask(n_)}},i_=e=>Math.round(e*1e5)/1e5,a_=e=>t=>typeof t==`string`&&t.startsWith(e),o_=a_(`--`),s_=a_(`var(--`),c_=e=>s_(e)?l_.test(e.split(`/*`)[0].trim()):!1,l_=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function u_(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var d_={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},f_={...d_,transform:e=>Sg(0,1,e)},p_={...d_,default:1},m_=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function h_(e){return e==null}var g_=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,__=(e,t)=>n=>!!(typeof n==`string`&&g_.test(n)&&n.startsWith(e)||t&&!h_(n)&&Object.prototype.hasOwnProperty.call(n,t)),v_=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(m_);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},y_=e=>Sg(0,255,e),b_={...d_,transform:e=>Math.round(y_(e))},x_={test:__(`rgb`,`red`),parse:v_(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+b_.transform(e)+`, `+b_.transform(t)+`, `+b_.transform(n)+`, `+i_(f_.transform(r))+`)`},S_=(e,t,n)=>{let r=e.substring(1+t*n,1+(t+1)*n);return n>1?r:r+r};function C_(e){let t=e.length>5?2:1,n=S_(e,3,t);return{red:parseInt(S_(e,0,t),16),green:parseInt(S_(e,1,t),16),blue:parseInt(S_(e,2,t),16),alpha:n?parseInt(n,16)/255:1}}var w_={test:__(`#`),parse:C_,transform:x_.transform},T_=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),E_=T_(`deg`),D_=T_(`%`),$=T_(`px`),O_=T_(`vh`),k_=T_(`vw`),A_={...D_,parse:e=>D_.parse(e)/100,transform:e=>D_.transform(e*100)},j_={test:__(`hsl`,`hue`),parse:v_(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+D_.transform(i_(t))+`, `+D_.transform(i_(n))+`, `+i_(f_.transform(r))+`)`},M_={test:e=>x_.test(e)||w_.test(e)||j_.test(e),parse:e=>x_.test(e)?x_.parse(e):j_.test(e)?j_.parse(e):w_.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?x_.transform(e):j_.transform(e),getAnimatableNone:e=>{let t=M_.parse(e);return t.alpha=0,M_.transform(t)}},N_=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,P_=new RegExp(m_.source),F_=new RegExp(N_.source,`i`);function I_(e){return isNaN(e)&&typeof e==`string`&&(P_.test(e)||F_.test(e))}var L_=`number`,R_=`color`,z_=`var`,B_=`var(`,V_="${}",H_=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)(?![a-z]*\()/giu;function U_(e){let t=e.toString();return P_.test(t)||F_.test(t)}function W_(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(H_,e=>(M_.test(e)?(r.color.push(a),i.push(R_),n.push(M_.parse(e))):e.startsWith(B_)?(r.var.push(a),i.push(z_),n.push(e)):(r.number.push(a),i.push(L_),n.push(parseFloat(e))),++a,V_)).split(V_),indexes:r,types:i}}function G_(e){return W_(e).values}function K_({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];i+=e===L_?i_(r[a]):e===R_?M_.transform(r[a]):r[a]}return i}}function q_(e){return K_(W_(e))}var J_=e=>typeof e==`number`?0:M_.test(e)?M_.getAnimatableNone(e):e,Y_=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:J_(e);function X_(e){let t=W_(e);return K_(t)(t.values.map((e,n)=>Y_(e,t.split[n])))}var Z_={test:I_,parse:G_,createTransformer:q_,getAnimatableNone:X_};function Q_(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function $_({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Q_(s,r,e+1/3),a=Q_(s,r,e),o=Q_(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function ev(e,t){return n=>n>0?t:e}var tv=(e,t,n)=>e+(t-e)*n,nv=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},rv=[w_,x_,j_],iv=e=>rv.find(t=>t.test(e));function av(e){let t=iv(e);if(!t)return!1;let n=t.parse(e);return t===j_&&(n=$_(n)),n}var ov=(e,t)=>{let n=av(e),r=av(t);if(!n||!r)return ev(e,t);let i={...n};return e=>(i.red=nv(n.red,r.red,e),i.green=nv(n.green,r.green,e),i.blue=nv(n.blue,r.blue,e),i.alpha=tv(n.alpha,r.alpha,e),x_.transform(i))},sv=new Set([`none`,`hidden`]);function cv(e,t){return sv.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function lv(e,t){return n=>tv(e,t,n)}function uv(e){return typeof e==`number`?lv:typeof e==`string`?c_(e)?ev:M_.test(e)?ov:mv:Array.isArray(e)?dv:typeof e==`object`?M_.test(e)?ov:fv:ev}function dv(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>uv(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function fv(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=uv(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function pv(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]],s=e.values[o]??0;n[i]=s,r[a]++}return n}var mv=(e,t)=>{let n=W_(e),r=W_(t);return n.indexes.var.length===r.indexes.var.length&&n.indexes.color.length===r.indexes.color.length&&n.indexes.number.length>=r.indexes.number.length?sv.has(e)&&!r.values.length||sv.has(t)&&!n.values.length?cv(e,t):kg(dv(pv(n,r),r.values),K_(r)):ev(e,t)},hv=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function gv(e,t){let n=hv.exec(e);if(!n)return;let r=hv.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>i_(tv(a,o,e))+i}function _v(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return tv(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=gv(e,t);if(n)return n}return uv(e)(e,t)}var vv=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function yv(e){let t=new Set,n=new Set,r=!1,i=!1,a,o=new Set,s={delta:0,timestamp:0,isProcessing:!1};function c(t){o.has(t)&&(n.add(t),e()),(a=t)(s)}let l={schedule:(e,i=!1,s=!1)=>{let c=s&&r,l=c?t:n;return i&&o.add(e),c&&e!==a&&l.delete(e),l.add(e),e},cancel:e=>{n.delete(e),o.delete(e)},process:e=>{if(s=e,r){i=!0;return}r=!0;let o=t;t=n,n=o,t.forEach(c),t.clear(),a=void 0,r=!1,i&&(i=!1,l.process(e))}};return l}var bv=40;function xv(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=vv.reduce((e,t)=>(e[t]=yv(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Cg.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,bv),1)),n.timestamp=o,n.isProcessing=!0,s.process(n),c.process(n),l.process(n),u.process(n),d.process(n),f.process(n),p.process(n),m.process(n),n.isProcessing=!1,r&&t&&(i=!1,e(h))},g=()=>{r=!0,i=!0,n.isProcessing||e(h)};return{schedule:vv.reduce((e,t)=>{let n=o[t];return e[t]=(e,t=!1,i=!1)=>(r||g(),n.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<vv.length;t++)o[vv[t]].cancel(e)},state:n,steps:o}}var{schedule:Sv,cancel:Cv,steps:wv}=xv(typeof requestAnimationFrame<`u`?requestAnimationFrame:Og,!0,e_),Tv=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>Sv.update(t,e),stop:()=>Cv(t),now:()=>e_.isProcessing?e_.timestamp:r_.now()}},Ev=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Dv=2e4;function Ov(e,t=50,n=Dv,r){let i=0,a=e.next(i);for(r?.push(a.value);!a.done&&i<n;)i+=t,a=e.next(i),r?.push(a.value);return i>=n?1/0:i}function kv(e,t=100,n){let{keyframes:r,velocity:i}=e,a=r&&r[r.length-1]-r[0],o=n({...e,velocity:i&&a?i*t/a:i,keyframes:[0,t]}),s=Math.min(Ov(o),Dv);return{type:`keyframes`,ease:e=>o.next(s*e).value/t,duration:Ng(s)}}var Av=100,jv=10,Mv=1,Nv=800,Pv=.3,Fv=.3,Iv=.01,Lv=2,Rv=.005,zv=.5,Bv=.01,Vv=10,Hv=.05,Uv=e=>e<0?1/Math.max(1+e,Hv):Math.max(1-e,Hv);function Wv(e,t){if(!(e>1))return 1;let n=Math.sqrt(e*e-1),r=e-n,i=e+n,a=2*n*Math.exp(-t)*(1+t);return qv(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function Gv(e,t){return e*Math.sqrt(1-t*t)}var Kv=12;function qv(e,t,n){let r=n;for(let n=1;n<Kv;n++)r-=e(r)/t(r);return r}var Jv=.001;function Yv({duration:e=Nv,bounce:t=Pv}){let n,r,i=Uv(t);e=Sg(Bv,Vv,Ng(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=Gv(t,i),o=Math.exp(-r);return Jv-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=Gv(t*t,i);return(-n(t)+Jv>0?-1:1)*-a*o/s}):(n=t=>-.001+Math.exp(-t*e)*(t*e+1),r=t=>Math.exp(-t*e)*(-t*(e*e)));let a=5/e,o=qv(n,r,a),s=o*Wv(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:Mg(e)}}var Xv=(e,t)=>(t?e>=0:e>0)&&e<1/0;function Zv(e,t){if(Xv(e,t))return e}function Qv(e){let t=Zv(e.stiffness),n=Zv(e.damping,!0),r=Zv(e.mass),i={...e,stiffness:t??Av,damping:n??jv,mass:r??Mv,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){let t=Uv(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*Wv(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,Yv(i)),i.isResolvedFromDuration=!0;Xv(i.stiffness)&&Xv(i.damping,!0)||(i.stiffness=Av,i.damping=jv)}return i}function $v(e=Fv,t=Pv){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:o,damping:s,mass:c,duration:l,isResolvedFromDuration:u,isTimeDefined:d}=Qv({...n}),f=e=>d?0:-Ng(e),p=s/(2*Math.sqrt(o*c)),m=Ng(Math.sqrt(o/c)),h=p*m,g={target:i,delta:i-r,velocity:f(n.velocity||0)||0,restSpeed:0,restDelta:0},_=()=>{let e=Math.abs(g.delta)<5;g.restSpeed=n.restSpeed||(e?Iv:Lv),g.restDelta=n.restDelta||(e?Rv:zv)};_();let v,y,b;if(p<1){let e=Gv(m,p),t={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};b=()=>{t.A=(g.velocity+h*g.delta)/e,t.sinC=h*t.A+g.delta*e,t.cosC=h*g.delta-t.A*e};let n=n=>{n!==t.t&&(t.t=n,t.env=Math.exp(-h*n),t.sin=Math.sin(e*n),t.cos=Math.cos(e*n))};v=e=>(n(e),g.target-t.env*(t.A*t.sin+g.delta*t.cos)),y=e=>(n(e),t.env*(t.sinC*t.sin+t.cosC*t.cos))}else if(p===1){v=e=>g.target-Math.exp(-m*e)*(g.delta+(g.velocity+m*g.delta)*e);let e={C:0};b=()=>{e.C=g.velocity+m*g.delta},y=t=>Math.exp(-m*t)*(m*e.C*t-g.velocity)}else{let e=m*Math.sqrt(p*p-1),t=h-e,n=h+e,r=e<1||d?1/0:300/e,i=(e,t)=>Math.exp(t>r?(h-e)*r-h*t:-e*t),a={S:0,F:0};b=()=>{let t=(g.velocity+h*g.delta)/e;a.S=(g.delta+t)/2,a.F=(g.delta-t)/2},v=e=>g.target-a.S*i(t,e)-a.F*i(n,e),y=e=>t*a.S*i(t,e)+n*a.F*i(n,e)}b();let x=u&&l||null,S={calculatedDuration:x,retarget:(e,t)=>{g.target=e[e.length-1],g.delta=g.target-e[0],g.velocity=f(t),n.restSpeed&&n.restDelta||_(),S.calculatedDuration=x,a.done=!1,b()},velocity:e=>Mg(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=Mg(y(e));a.done=Math.abs(n)<=g.restSpeed&&Math.abs(g.target-t)<=g.restDelta}return a.value=a.done?g.target:t,a},toString:()=>{let e=Math.min(Ov(S),Dv),t=Ev(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}var ey=Object.assign($v,{applyToOptions:e=>{let t=kv(e,100,$v);return e.ease=t.ease,e.duration=Mg(t.duration),e.type=`keyframes`,e}});function ty({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>e<s||e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o?o(g):g;_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>{let t=v(e);f.done=Math.abs(t)<=l,f.value=f.done?_:e?_+t:d},b,x,S=e=>{p(f.value)&&(b=e,x=ey({keyframes:[f.value,m(f.value)],velocity:-v(e)/r*1e3,damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return!x&&b===void 0&&(t=!0,y(e),S(e)),b!==void 0&&e>=b?x.next(e-b):(!t&&y(e),f)}}}function ny(e,t,n){let r=[],i=Cg.mix||_v,a=e.length-1;for(let o=0;o<a;o++){let a=n?.(e[o],e[o+1])||i(e[o],e[o+1]);t&&(a=kg(Array.isArray(t)?t[o]||Og:t,a)),r.push(a)}return r}function ry(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=ny(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=Ag(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Sg(e[0],e[a-1],t)):l}function iy(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=Ag(0,t,r);e.push(tv(n,1,i))}}function ay(e){let t=[0];return iy(t,e.length-1),t}function oy(e,t){return e.map(e=>e*t)}function sy(e,t){return e.map(()=>t||Jg).splice(0,e.length-1)}function cy({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`,mixer:i}){let a=typeof t[0]==`number`?void 0:i,o=Yg(r)?r.map($g):$g(r)||Jg,s={done:!1,value:t[0]};if(!a&&t.length===2&&!Array.isArray(o)&&(!n||n.length!==2||n[0]===0&&n[1]===1)){let[n,r]=t,i=n===r?void 0:(Cg.mix||_v)(n,r);return{calculatedDuration:e,next:t=>(s.value=i?i(o(e>0?Sg(0,1,t/e):1)):r,s.done=t>=e,s)}}let c=ry(oy(n&&n.length===t.length?n:ay(t),e),t,{ease:Array.isArray(o)?o:sy(t,o),mixer:a});return{calculatedDuration:e,next:t=>(s.value=c(t),s.done=t>=e,s)}}var ly=5;function uy(e,t,n){let r=Math.max(t-ly,0);return Pg(n-e(r),t-r)}function dy(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):uy(t=>e.next(t).value,t,e.next(t).value)}var fy=e=>e!==null;function py(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(fy),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var my={decay:ty,inertia:ty,tween:cy,keyframes:cy,spring:ey};function hy(e){typeof e.type==`string`&&(e.type=my[e.type])}var gy=40,_y=(e,t)=>t-e>gy&&!Cg.useManualTiming?t:e;function vy(e,t){return{kind:e,animation:t,timestamp:r_.now(),frameTimestamp:e_.timestamp,frameIsProcessing:e_.isProcessing}}function yy(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...vy(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function by(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...vy(`layout-animation-start`,e),node:t})}catch{}}var xy=class{constructor(){this.isResolved=!1}get finished(){return this._finished||=this.isResolved?Promise.resolve():new Promise(e=>{this._resolve=e}),this._finished}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(e,t){return this.finished.then(e,t)}},Sy=e=>e/100,Cy=e=>Math.round(e*1e4)/1e4,wy=class extends xy{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==r_.now()&&this.tick(r_.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),yy(this,this.options)}initAnimation(){let{options:e}=this;hy(e);let{type:t=cy,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||cy;this.mixKeyframes=void 0,s!==cy&&typeof o[0]!=`number`&&(this.mixKeyframes=kg(Sy,e.mixer?.(o[0],o[1])||_v(o[0],o[1])),o=[0,100]);let c=s(o===e.keyframes?e:{...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=Ov(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){this.currentTime=this.holdTime??Math.round(e-this.startTime)*this.playbackSpeed}tick(e,t=!1){let{generator:n,totalDuration:r,calculatedDuration:i}=this;if(this.startTime===null)return n.next(0);let{delay:a=0,keyframes:o,type:s,onUpdate:c,finalKeyframe:l}=this.options;this.startTime===this.pendingStartTime&&(this.startTime=_y(this.startTime,e)),this.pendingStartTime=void 0,this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let u=this.currentTime-a*(this.playbackSpeed>=0?1:-1),d=this.playbackSpeed>=0?u<0:u>r;this.currentTime=Math.max(u,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let f=this.generate(this.currentTime,d),{done:p}=f;d||(p=this.playbackSpeed>=0?i<1/0?this.currentTime>=r:p:this.currentTime<=0);let m=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&p);return m&&s!==ty&&(f.value=py(o,this.options,l,this.speed)),c&&c(f.value),m&&this.finish(),f}at(e){return this.holdTime??Cy((e-this.startTime)*this.playbackSpeed)}sampleAt(e,t){let{options:n,totalDuration:r}=this,i=this.at(e)-(n.delay||0);return i>=r&&n.type!==ty?py(n.keyframes,n,t?void 0:n.finalKeyframe):this.generate(Math.max(i,0),i<0).value}generate(e,t){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o}=this,{keyframes:s,repeat:c,repeatType:l,repeatDelay:u}=this.options,d=e,f=n;if(c){let t=Math.min(e,r)/o,n=Math.floor(t),i=t%1;!i&&t>=1&&(i=1),i===1&&n--,n=Math.min(n,c+1),n%2&&(l===`reverse`?(i=1-i,u&&(i-=u/o)):l===`mirror`&&(f=a)),d=Sg(0,1,i)*o}let p;return t?(this.delayState.value=s[0],p=this.delayState):p=f.next(d),i&&!t&&(p.value=i(p.value)),p}get duration(){return Ng(this.calculatedDuration)}get iterationDuration(){return this.duration+Ng(this.options.delay??0)}get time(){return Ng(this.currentTime)}set time(e){e=Mg(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){return dy(this.generator,this.currentTime,this.options.velocity)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(r_.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Ng(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Tv,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??(this.pendingStartTime=n):this.startTime=n-this.holdTime/(this.playbackSpeed||1),this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(r_.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.driver?.stop(),this.driver=void 0,this.startTime=this.holdTime=null}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}},Ty=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function Ey(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(m_)||[];if(!r)return e;let i=n.replace(r,``),a=+!!Ty.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var Dy=/\b([a-z-]*)\(.*?\)/gu,Oy={...Z_,getAnimatableNone:e=>{let t=e.match(Dy);return t?t.map(Ey).join(` `):e}},ky={...Z_,getAnimatableNone:e=>{let t=Z_.parse(e);return Z_.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},Ay={...d_,transform:Math.round},jy={rotate:E_,pathRotation:E_,rotateX:E_,rotateY:E_,rotateZ:E_,scale:p_,scaleX:p_,scaleY:p_,scaleZ:p_,skew:E_,skewX:E_,skewY:E_,distance:$,translateX:$,translateY:$,translateZ:$,x:$,y:$,z:$,perspective:$,transformPerspective:$,opacity:f_,originX:A_,originY:A_,originZ:$},My={borderWidth:$,borderTopWidth:$,borderRightWidth:$,borderBottomWidth:$,borderLeftWidth:$,borderRadius:$,borderTopLeftRadius:$,borderTopRightRadius:$,borderBottomRightRadius:$,borderBottomLeftRadius:$,width:$,maxWidth:$,height:$,maxHeight:$,top:$,right:$,bottom:$,left:$,inset:$,insetBlock:$,insetBlockStart:$,insetBlockEnd:$,insetInline:$,insetInlineStart:$,insetInlineEnd:$,padding:$,paddingTop:$,paddingRight:$,paddingBottom:$,paddingLeft:$,paddingBlock:$,paddingBlockStart:$,paddingBlockEnd:$,paddingInline:$,paddingInlineStart:$,paddingInlineEnd:$,margin:$,marginTop:$,marginRight:$,marginBottom:$,marginLeft:$,marginBlock:$,marginBlockStart:$,marginBlockEnd:$,marginInline:$,marginInlineStart:$,marginInlineEnd:$,fontSize:$,backgroundPositionX:$,backgroundPositionY:$,...jy,zIndex:Ay,fillOpacity:f_,strokeOpacity:f_,numOctaves:Ay},Ny={...My,color:M_,backgroundColor:M_,outlineColor:M_,fill:M_,stroke:M_,borderColor:M_,borderTopColor:M_,borderRightColor:M_,borderBottomColor:M_,borderLeftColor:M_,filter:Oy,WebkitFilter:Oy,mask:ky,WebkitMask:ky},Py=e=>Ny[e],Fy=new Set([Oy,ky]);function Iy(e,t){let n=Py(e);return Fy.has(n)||(n=Z_),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function Ly(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var Ry=e=>e*180/Math.PI,zy=e=>Vy(Ry(Math.atan2(e[1],e[0]))),By={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scaleZ:()=>1,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:zy,rotateZ:zy,skewX:e=>Ry(Math.atan(e[1])),skewY:e=>Ry(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Vy=e=>(e%=360,e<0&&(e+=360),e),Hy=zy,Uy=e=>Math.hypot(e[0],e[1]),Wy=e=>Math.hypot(e[4],e[5]),Gy={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Uy,scaleY:Wy,scaleZ:e=>Math.hypot(e[8],e[9],e[10]),scale:e=>(Uy(e)+Wy(e))/2,rotateX:e=>Vy(Ry(Math.atan2(e[6],e[5]))),rotateY:e=>Vy(Ry(Math.atan2(-e[2],e[0]))),rotateZ:Hy,rotate:Hy,skewX:e=>Ry(Math.atan(e[4])),skewY:e=>Ry(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Ky(e){return+!!e.includes(`scale`)}function qy(e,t){if(!e||e===`none`)return Ky(t);let n=e.match(/^matrix(3d)?\(([-\d.e\s,]+)\)$/u);if(!n)return Ky(t);let r=(n[1]?Gy:By)[t],i=n[2].split(`,`).map(e=>parseFloat(e));return typeof r==`function`?r(i):i[r]}var Jy=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return qy(n,t)},Yy=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Xy=new Set([...Yy,`pathRotation`]),Zy=e=>e===d_||e===$,Qy=new Set([`x`,`y`,`z`]),$y=Yy.filter(e=>!Qy.has(e));function eb(e){let t=[];return $y.forEach(n=>{let r=e.getValue(n);if(r!==void 0){let e=r.get(),i=+!!n.startsWith(`scale`);if(e===i)return;t.push([n,e]),r.set(i)}}),t}var tb=new Set([`bottom`,`right`]);function nb(e,t,n,r,i,a){let o=parseFloat(e);if(!isNaN(o))return o;let{min:s,max:c}=t()[n],l=c-s;return a===`border-box`?l:l-parseFloat(r)-parseFloat(i)}var rb=({transform:e})=>qy(e,`x`),ib=({transform:e})=>qy(e,`y`),ab={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>nb(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>nb(e,i,`y`,t,n,r),top:({top:e})=>parseFloat(e),left:({left:e})=>parseFloat(e),bottom:({top:e},t)=>{let{y:n}=t();return parseFloat(e)+(n.max-n.min)},right:({left:e},t)=>{let{x:n}=t();return parseFloat(e)+(n.max-n.min)},x:rb,y:ib,translateX:rb,translateY:ib},ob=new Set,sb=!1,cb=!1,lb=!1;function ub(){if(cb){let e=[],t=new Set,n=new Set;ob.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),tb.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=eb(e);t.length&&(r.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}cb=!1,sb=!1,ob.forEach(e=>e.complete(lb)),ob.clear()}function db(){ob.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(cb=!0)})}function fb(){lb=!0,db(),ub(),lb=!1}function pb(e,t,n){if(typeof e==`string`){if(wg(e)||Eg(e))return parseFloat(e);if(!Z_.test(e)&&Z_.test(n))return Iy(t,n)}return e??void 0}var mb=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(ob.add(this),sb||(sb=!0,Sv.read(db),Sv.resolveKeyframes(ub))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=pb(n.readValue(t,a),t,a);r!==void 0&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}Ly(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ob.delete(this)}cancel(){this.state===`scheduled`&&(ob.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},hb=e=>e.startsWith(`--`);function gb(e,t,n){hb(t)?e.style.setProperty(t,n):e.style[t]=n}var _b={};function vb(e,t){let n=Dg(e);return()=>_b[t]??n()}var yb=vb(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),bb=vb(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),xb=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Sb={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:xb([0,.65,.55,1]),circOut:xb([.55,0,1,.45]),backIn:xb([.31,.01,.66,-.59]),backOut:xb([.33,1.53,.69,.99])};function Cb(e,t){if(e)return typeof e==`function`?bb()?Ev(e,t):`ease-out`:Xg(e)?xb(e):Array.isArray(e)?e.map(e=>Cb(e,t)||Sb.easeOut):Sb[e]}function wb(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=Cb(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function Tb(e){return typeof e==`function`&&`applyToOptions`in e}function Eb({type:e,...t}){return Tb(e)&&bb()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Db=class extends xy{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e;let c=Eb(e);this.animation=wb(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=py(r,this.options,o,this.speed);this.updateMotionValue?.(e),gb(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},yy(this,e,c)}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){this.isStopped||(this.isStopped=!0,this.state!==`idle`&&this.finishedTime===null&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||(this.animation.onfinish=null,this.cancel())))}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return Ng(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Ng(e)}get time(){return Ng(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Mg(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,onAttach:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&yb()?(this.animation.timeline=e,t?.(this.animation),Og):n(this)}},Ob={anticipate:Hg,backInOut:Vg,circInOut:Gg};function kb(e){return e in Ob}function Ab(e){typeof e.ease==`string`&&kb(e.ease)&&(e.ease=Ob[e.ease])}var jb=class extends Db{constructor(e){Ab(e),hy(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}elapsed(){return this.state===`running`?(r_.now()-this.startTime)*this.speed:this.time*1e3}sample(e){if(!this.sampler){let{motionValue:e,onUpdate:t,onComplete:n,onPlay:r,onStop:i,element:a,...o}=this.options;this.sampler=new wy({...o,autoplay:!1}),this.sampler.stop()}return this.sampler.sample(Math.max(0,e)).value}liveValue(){let{state:e}=this;if(e===`running`||e===`paused`)return this.sample(this.elapsed())}updateMotionValue(e){let{motionValue:t,element:n,name:r}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let{speed:i}=this,a=this.elapsed(),o=this.state===`running`&&i?Sg(0,10,a):0,s=this.sample(a);n&&r&&gb(n,r,s),t.setWithVelocity(this.sample(a-o*Math.sign(i)),s,o/Math.abs(i||1))}},Mb=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Z_.test(e)||e===`0`)&&!e.startsWith(`url(`));function Nb(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function Pb(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=Mb(i,t),s=Mb(a,t);return!o||!s?!1:Nb(e)||(n===`spring`||Tb(n))&&r}function Fb(e){e.duration=0,e.type=`keyframes`}var Ib=new Set([`opacity`,`clipPath`,`filter`,`transform`]),Lb=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function Rb(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&Lb.test(e[t]))return!0;return!1}var zb=({mixer:e,keyframes:t})=>e&&typeof t[0]!=`number`&&t.some((n,r)=>r&&e(t[r-1],n)),Bb=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Vb=()=>!Cg.useManualTiming&&Object.hasOwnProperty.call(Element.prototype,`animate`);function Hb(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(Ib.has(n)||Bb.has(n)))return!1;let c=t?.owner?.current;if(!(c instanceof HTMLElement)&&!(c instanceof SVGElement))return!1;let{onUpdate:l,transformTemplate:u}=t.owner.getProps();return Vb()&&(Ib.has(n)||Bb.has(n)&&Rb(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`&&!zb(e)}var Ub=(e,t)=>t&&typeof e==`number`?t.transform(e):e,Wb={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},Gb=Yy.length,Kb={},qb=(e,t,n=Ub(t,jy[e]))=>(Kb[e]||(Kb[e]=(Wb[e]||e)+`(`))+n+`)`,Jb=(e,t)=>(typeof t==`number`?t:parseFloat(t))===+!!e.startsWith(`scale`);function Yb(e,t,n){let r=``;for(let i=0;i<Gb;i++){let a=Yy[i],o=e[a];if(o===void 0)continue;let s=n&&(t[a]=Ub(o,My[a]));Jb(a,o)||(r+=qb(a,o,s||void 0)+` `)}let i=e.pathRotation;return i&&(r+=qb(`rotate`,i)),r=r.trim(),n?n(t,r):r||`none`}var Xb=new WeakMap,Zb=200,Qb=.001,$b=.1,ex=.001,tx=100,nx=e=>/^(linear|ease(In|Out|InOut))$/.test(e),rx=(e,t)=>Math.abs(e-t)<=Qb,ix=(e,t)=>e-t,ax=(e,t,n)=>ay(Array(n+1)).map(n=>tv(e,t,n)),ox=e=>e.motionValue.owner,sx=e=>Xb.get(e),cx=({state:e})=>e===`idle`||e===`finished`,lx=(e,t)=>e.latestValues?e.latestValues[t]:e.getValue(t)?.get(),ux=({name:e,motionValue:t})=>e&&Yy.includes(e)&&t?.owner?.current instanceof HTMLElement&&Vb()&&bb();function dx(e){let t=ox(e),{onUpdate:n,transformTemplate:r}=t.getProps();return!e.isHandoff&&!n&&!e.hasOnUpdate&&!r&&e.type!==`inertia`&&(lx(t,`transform`)||`none`)===`none`&&!lx(t,`pathRotation`)&&!t.projection?.isProjecting()&&!zb(e)}var fx=class extends wy{constructor(e){let t=ox(e).current,{driver:n=Tv}=e,r,i=dx(e);e.driver=e=>{let i=n(e);return{js:i,now:i.now,start:(e=!0)=>{let n=sx(t);!n||n.isJS?i.start(e):n.schedule(!1,!e)},stop:()=>{i.stop();let e=sx(t);e&&!e.isFinishing&&e.release(r)}}},super(e),r=this,this.canAccelerate=i;let{stop:a}=this;this.stop=()=>{this.isAccelerated()&&this.sync(),a()}}get group(){return sx(ox(this.options).current)}get js(){return this.driver?.js}get name(){return this.options.name}timing(){let{startTime:e,speed:t,totalDuration:n}=this,{delay:r=0,repeatType:i}=this.options;return this.holdTime===null?n===1/0?[e+r/t,this.resolvedDuration*(i===`loop`?1:2)/t||1]:[e+(r+n)/t,0]:[1/0,0]}isAccelerated(){let{group:e,state:t}=this;return e?.tracks.has(this)&&!e.isJS&&this.canAccelerate&&(t===`running`||t===`paused`)}liveValue(){return this.isAccelerated()?this.sampleAt(r_.now()):void 0}tween(){let{keyframes:e,type:t,ease:n,times:r,repeat:i,delay:a=0}=this.options,o=Xg(n)?xb(n):nx(n)&&Sb[n];if(o&&!i&&!r&&e.length===2&&t===cy&&this.holdTime===null){let e=this.startTime+a/this.speed;return[e,e+this.resolvedDuration/this.speed,o]}}boundaries(e,t){let{startTime:n,speed:r,resolvedDuration:i,options:a}=this,{delay:o=0,repeat:s=0,repeatDelay:c=0,repeatType:l,times:u,keyframes:d,type:f}=a,p=(f||cy)===cy?u||ay(d):[0,1],m=n+o/r,h=[];if(this.holdTime!==null||!(i>0))return h;for(let n=Math.max(0,Math.floor((e-m)*r/i));n<=s;n++){let a=m+n*i/r;if(a>t)break;for(let o of p){let s=a+(n%2&&l&&l!==`loop`?1-o:o)*(i-c)/r;s>e&&s<t&&h.push(s)}}return h}numberAt(e){return parseFloat(this.sampleAt(e,!0))}sync(){let e=r_.now();this.options.motionValue.setWithVelocity(this.sampleAt(e-10,!0),this.sampleAt(e,!0),10)}play(){this.isStopped||((this.group||px(ox(this.options))).tracks.add(this),super.play())}pause(){super.pause(),this.isAccelerated()&&(this.sync(),this.group.schedule(!1))}complete(){super.complete();let{group:e}=this;e&&!e.isJS&&this.canAccelerate&&this.tick(r_.now())}get time(){return this.isAccelerated()?Ng(Sg(0,this.totalDuration,this.at(r_.now())-(this.options.delay||0))):super.time}set time(e){super.time=e,this.isAccelerated()&&this.sync()}attachTimeline(e){return this.canAccelerate=!1,this.group?.demote(!0),super.attachTimeline(e)}};function px(e){let t=e.current,n=new Set,r=new Map,i={},a=[],o=new Map,s=[],c=!1,l=!1,u=!1,d=!1,f=-1/0,p=e=>{for(let t of n)if(t.name===e)return!0},m=(t,n)=>{let o={};for(let s of t===void 0?Yy:a){let a=r.get(s),c=t===void 0?lx(e,s):a?a.sampleAt(n>t&&!a.timing()[1]?n:t):i[s];c!==void 0&&(o[s]=c)}return o},h=(e,t)=>{let n=``;for(let r in e){let i=e[r];t&&Jb(r,i)||(n+=qb(r,i)+` `)}return(t?n.trim():n)||`none`},g=(e,t)=>h(m(e,t)),_=(e=m())=>{t.style.transform=h(e,!0)},v=(e=!0)=>{e&&_(),s.forEach(({animation:e})=>e.cancel()),s=[]},y=(e,n)=>new Animation(new KeyframeEffect(t,e,n)),b=(e,t,n=1/0)=>{let r={animation:e,offset:t,end:n};e.startTime=r_.now()+t,n<1/0&&(e.onfinish=()=>{r.isDone=!0,s.some(e=>e.end===1/0)&&(e.cancel(),s=s.filter(e=>e!==r)),A.schedule(!1)}),e.oncancel=()=>s.includes(r)&&A.demote(),s.push(r)},x=(e,t,n)=>{let r=(t,n)=>Math.abs(e(n)-e(t)),i=r(t,n);for(;n-t>.01;){let e=(t+n)/2;r(t,e)>r(e,n)?n=e:t=e}return r(t,n)>i/2?[t,n]:[]},S=(e,t,n,r)=>{let i=Math.min(Zb,Math.max(2,Math.ceil((n-t)/10)));if(r.length*4>i)return;let a=ax(t,n,i).concat(r).sort(ix),o=e=>Ag(t,n,e),s,c;for(let n of e){let e=n.numberAt(t),r=a.map(t=>n.numberAt(t)-e),i=r[r.length-1],o=r.some(e=>Math.abs(e)*Qb>Math.abs(i))?0:i,l=r.map(e=>o?e/o:e);if(o&&!s)s=l,c=t=>(n.numberAt(t)-e)/o;else if(l.some((e,t)=>!rx(e,o&&s[t])))return}if(!s||s.every((e,t)=>rx(e,o(a[t]))))return`linear`;let l=[],u=(e,t=c(e))=>l.push(Cy(t)+` `+Cy(o(e)*100)+`%`);return s.forEach((e,t)=>{t&&Math.abs(e-s[t-1])>.2&&x(c,a[t-1],a[t]).forEach(e=>u(e)),u(a[t],e)}),`linear(`+l+`)`},C=(e,t,n,r)=>{let i=[t],a=(t,n)=>e.every(e=>!(Math.abs(e.numberAt((t+n)/2)-(e.numberAt(t)+e.numberAt(n))/2)>(e.name.startsWith(`scale`)?ex:$b))),o=(t,n,r)=>{if(n-t<1||a(t,n))i.push(n);else if(r<4)o(t,(t+n)/2,r+1),o((t+n)/2,n,r+1);else{for(let r of e)i.push(...x(e=>r.numberAt(e),t,n));i.push(n)}},s=ax(t,n,Math.ceil((n-t)/100));for(let e of r)s.push(e,Math.min(e+.01,n));let c=t;for(let e of s.sort(ix))e>c&&o(c,e,0),c=e;return i.sort(ix)},w=e=>{let t;for(let n of e){let e=n.tween();if(!e||t?.some((t,n)=>n<2?Math.abs(e[n]-t)>1:e[n]!==t))return;t=e}return t},T=(e,t,n,r,i={fill:`both`},a)=>{let o=e.flatMap(e=>e.boundaries(t,n)),s=r||S(e,t,n,o),c=s?[t,n]:C(e,t,n,o),l=c.map(e=>g(e,a)),u={transform:l};return s||(u.offset=c.map(e=>Ag(t,n,e))),l.every(e=>e===l[0])&&(_(m(t,a)),u=null),y(u,{...i,duration:n-t,easing:s||`linear`})},E=t=>{let c=t,l=0,u=0,d=[],f=[],p=new Set;r.clear(),o=new Map;for(let e of n){r.set(e.name,e);let[n,i]=e.timing(),a=n===1/0;if(o.set(e,[e.at(t),e.speed,a]),a)e.sync();else{if(e.speed<0)return;if(i){if(l){let e=(n-u)/i;if(Math.abs(i-l)>1||Math.abs(e-Math.round(e))*l>1)return}else l=i,u=n;f.push(e)}else p.add(n);d.push(e),c=Math.max(c,n)}}i={},a=Yy.filter(t=>{if(r.has(t))return!0;let n=i[t]=lx(e,t);return n!==void 0&&!Jb(t,n)}),v(!1);let m=!l&&w(d);try{if(m&&m[1]>t){let[e,n,r]=m;b(T(d,e,n,r),e-t,n-e)}else c>t&&(b(T(d,t,c),0,c-t),p.forEach(e=>e<c-1&&b(y(null,{duration:e-t}),0,e-t)));if(l){let e=u+Math.floor((c-u)/l)*l;b(T(f,e,e+l,void 0,{iterations:1/0,iterationStart:(c-e)/l,fill:`forwards`},c),c-t)}}catch{return}return s.length||v(),!0},D=e=>{let t,r=0;for(let i of n){let n=o.get(i);if(!n)return!1;let[a,s,c]=n,l=i.at(e),u=i.timing()[0]===1/0;if(c){if(u&&l===a)continue;return!1}let d=(l-a)/s,f=u?0:i.speed/s;if(t===void 0)t=d,r=f;else if(Math.abs(d-t)>1||f!==r)return!1}if(t===void 0)return!0;if(!s.length)return!1;for(let{offset:e,end:n,isDone:r}of s){let i=t-e;if(n<1/0&&(r?i<n-1:i<0||i>=n))return!1}for(let{animation:n,offset:i,isDone:a}of s){if(a)continue;let o=t-i;r&&n.updatePlaybackRate&&n.playState===`running`&&Math.abs(Number(n.currentTime)-o)<20?n.playbackRate!==r&&n.updatePlaybackRate(r):r?(n.playbackRate=r,n.startTime=e-o/r):(n.startTime=null,n.currentTime=o)}return!0},O=()=>!n.size&&(u=!0,sx(t)===A&&Xb.delete(t),A.isJS||v(),!0),k=()=>{let t=r_.now();if(A.isJS||(A.isFinishing=!0,n.forEach(n=>{let[r,a]=n.timing();n.state===`running`&&n.speed>0&&!a&&r<=t+1&&(n.complete(),i[n.name]=lx(e,n.name),o.has(n)||(c=!0))}),A.isFinishing=!1),l=!1,u||(n.forEach(e=>cx(e)&&n.delete(e)),O()))return;for(let e of n)if(!e.canAccelerate)return A.demote(!0);A.isJS&&(A.isJS=!1,c=!0,n.forEach(e=>e.js?.stop()));let r=c,a=d;if(c=d=!1,r||!D(t)){if(a){if(t-f<tx)return A.demote();f=t}if(!E(t))return A.demote()}},A={tracks:n,isJS:!1,isFinishing:!1,schedule(e,t){u||(c||=e,d||=!!t,l||(l=!0,e_.isProcessing?Sv.render(k,!1,!0):queueMicrotask(k)))},release(e){cx(e)&&n.delete(e),O()||A.schedule(!0)},check(){if(!A.isJS){for(let t in i)if(lx(e,t)!==i[t]&&!p(t))return A.schedule(!0,!0)}},demote(e){if(!(A.isJS||u))return n.forEach(t=>{t.isAccelerated()&&t.sync(),e||(t.canAccelerate=!1)}),A.isJS=!0,o=new Map,v(),n.forEach(e=>e.state===`running`&&e.js?.start()),!0}};return Xb.set(t,A),A}var mx=class extends xy{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=r_.now();let{keyframes:t,name:n,motionValue:r,element:i}=e,a=e;a.autoplay??=!0,a.delay??=0,a.type??=`keyframes`,a.repeat??=0,a.repeatDelay??=0,a.repeatType??=`loop`;let o=i?.KeyframeResolver||mb;this.keyframeResolver=new o(t,(e,t,n)=>this.onKeyframesResolved(e,t,a,!n),n,r,i),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=r_.now();let u=Pb(e,i,a,o);u||((Cg.instantAnimations||!s)&&l?.(py(e,n,t)),e[0]=e[e.length-1],Fb(n),n.repeat=0);let{onComplete:d}=n;n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{d?.(),this.notifyFinished()};let f=u&&!c&&Hb(n),p=!f&&ux(n);r&&(f||p||this.resolvedAt!==this.createdAt)&&(n.startTime??=_y(this.createdAt,this.resolvedAt));let m;if(f){n.element=n.motionValue?.owner?.current;try{m=new jb(n)}catch{m=new wy(n)}}else m=p?new fx(n):new wy(n);this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this._animation.finished:super.finished}then(e,t){return this.finished.finally(e).then(()=>{})}liveValue(){return this._animation?.liveValue?.()}get animation(){return this._animation||(this.keyframeResolver?.resume(),fb()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation?.cancel(),this.keyframeResolver?.cancel()}};function hx(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var gx=30,_x=e=>!isNaN(parseFloat(e)),vx={current:void 0},yx=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=r_.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.dirty(),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=r_.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=_x(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){var n;return e===`change`?this.onChangeSubscribe(t):((n=this.events)[e]||(n[e]=new jg)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new jg,t.change.add(this.changeSubscriber),this.changeSubscriber=void 0),t.change.add(e)),()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:t.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){Sv.read(()=>{!this.changeSubscriber&&!this.events.change?.getSize()&&this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){t&&(this.updatedAt=r_.now(),this.stop()),this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,this.stopPassiveEffect?.()}dirty(){let{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){(this.dependents||=new Set).add(e)}removeDependent(e){this.dependents?.delete(e)}get(){vx.current?.push(this);let e=this.animation?.liveValue?.();return e===void 0?this.current:e}getCurrent(){return this.current}getPrevious(){return this.prev}getVelocity(){let e=r_.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>gx)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,gx);return Pg(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0;let n=!1,r;r=e(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===r&&(this.animation=void 0),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel?.notify()),this.animation=void 0}isAnimating(){return!!this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect?.()}};function bx(e,t){return new yx(e,t)}function xx(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Sx(e,t){let n=e?.[t]??e?.default??e;return n===e?n:xx(n,e)}var Cx={type:`spring`,stiffness:500,damping:25,restSpeed:10},wx=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Tx={type:`keyframes`,duration:.8},Ex={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Dx=(e,{keyframes:t})=>t.length>2?Tx:Xy.has(e)?e.startsWith(`scale`)?wx(t[1]):Cx:Ex,Ox=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`,`out`,`mixer`]);function kx(e){for(let t in e)if(!Ox.has(t))return!0;return!1}var Ax=(e,t,n,r={},i,a)=>o=>{let s=Sx(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=Mg(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i,hasOnUpdate:!!s.onUpdate};kx(s)||Object.assign(u,Dx(e,u)),u.duration&&=Mg(u.duration),u.repeatDelay&&=Mg(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Fb(u),u.delay===0&&(d=!0)),(Cg.instantAnimations||Cg.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,Fb(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=py(u.keyframes,s);if(e!==void 0){Sv.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new wy(u):new mx(u)},jx=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Mx(e){let t=jx.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Nx(e,t,n=1){let[r,i]=Mx(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return wg(e)?parseFloat(e):e}return c_(i)?Nx(i,t,n+1):i}function Px(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Fx(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...Px(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function Ix(e,t,n){return Fx(e.getProps(),t,n,e)}var Lx=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,Rx=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Yy]),zx=e=>Array.isArray(e);function Bx(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,bx(n))}function Vx(e){return zx(e)?e[e.length-1]||0:e}function Hx(e,t){let{transitionEnd:n={},transition:r={},...i}=Ix(e,t)||{};i={...i,...n};for(let t in i)Bx(e,t,Vx(i[t]))}var Ux=e=>!!(e&&e.getVelocity);function Wx(e){return!!(Ux(e)&&e.add)}function Gx(e,t){let n=e.getValue(`willChange`);if(Wx(n))return n.add(t);if(!n&&Cg.WillChange){let n=new Cg.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}var Kx=`data-framer-appear-id`;function qx(e){return e.props[Kx]}var Jx=typeof window<`u`;function Yx({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function Xx(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?xx(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState?.getState()[i],p=a?.path;p&&(p.animateValues?p.animateValues(t=>e.getValue(t,e.latestValues[t]??0),s,a,n,d):p.animateVisualElement?.(e,s,a,n,d));for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&Yx(f,t))continue;let o={delay:n,...Sx(f?.out[t]||a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){Sv.update(()=>r.set(i));continue}let p=!1;if(Jx&&window.MotionHandoffAnimation){let n=qx(e);if(n){let e=window.MotionHandoffAnimation(n,t,Sv);e!==null&&(o.startTime=e,p=!0)}}Gx(e,t);let m=l??e.shouldReduceMotion;r.start(Ax(t,r,i,m&&Rx.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>Sv.update(()=>{o&&Hx(e,o)});d.length?Promise.all(d).then(t):t()}return d}function Zx(e,t,n={}){let r=Ix(e,t,Lx(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?Xx(e,r,n):[]),o=(r=0)=>{let{variantChildren:a}=e,{delayChildren:o=0,staggerChildren:s,staggerDirection:c}=i,l=[];return a?.forEach(e=>{e.notify(`AnimationStart`,t),l.push(Zx(e,t,{...n,delay:r+(typeof o==`function`?0:o)+hx(a,e,o,s,c)}).then(()=>e.notify(`AnimationComplete`,t)))}),Promise.all(l)},{when:s}=i;return s?s===`beforeChildren`?a().then(()=>o()):o().then(a):Promise.all([a(),o(n.delay)])}function Qx(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>Zx(e,t,n))):typeof t==`string`?Zx(e,t,n):Promise.all(Xx(e,Ix(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var $x={test:e=>e===`auto`,parse:e=>e},eS=e=>t=>t.test(e),tS=[d_,$,D_,E_,k_,O_,$x],nS=e=>tS.find(eS(e));function rS(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||Eg(e)}var iS=new Set([`auto`,`none`,`0`]);function aS(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!iS.has(t)&&U_(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=Iy(n,i))}var oS=class extends mb{constructor(){super(...arguments),this.isAsync=!0}scheduleResolve(){if(this.canReadNow()&&(this.readKeyframes(),!this.needsMeasurement))return this.complete();super.scheduleResolve()}canReadNow(){let{unresolvedKeyframes:e,element:t,motionValue:n}=this,r=e[0]??n?.get();if(!t?.current||r===void 0)return!1;for(let t=0;t<e.length;t++)if(u_(t?e[t]:r))return!1;return!0}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t?.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),c_(r))){let i=Nx(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Rx.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=nS(r),o=nS(i);if(u_(r)!==u_(i)&&ab[n])this.needsMeasurement=!0;else if(a!==o){if(Zy(a)&&Zy(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else ab[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||rS(e[t]))&&n.push(t);n.length&&aS(e,n,t)}measure(){let{element:e,name:t}=this;return ab[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e?.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&this.motionValue?.jump(r,!1)}measureEndState(){let{element:e,unresolvedKeyframes:t}=this;if(!e?.current)return;this.motionValue?.jump(this.measuredOrigin,!1);let n=t.length-1,r=t[n];t[n]=this.measure(),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.resolveNoneKeyframes()}},sS=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function cS(e){return Tg(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function lS(e){return Tg(e)&&`ownerSVGElement`in e}var uS={};function dS(e){return uS.current?.add(e),e}var fS=e=>uS.current?uS.current.bind(e):e;function pS(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=t?t.current:uS.current?.root||document,i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}function mS(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}function hS(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(Xy.has(e))o=!0;else if(o_(e))i[e]=n;else{let t=Ub(n,My[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=Yb(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}var gS={offset:`stroke-dashoffset`,array:`stroke-dasharray`},_S={offset:`strokeDashoffset`,array:`strokeDasharray`};function vS(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?gS:_S;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var yS=[`transform`,`opacity`,`clipPath`,`filter`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function bS(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(hS(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;for(let e of yS)d[e]!==void 0&&(f[e]=d[e],delete d[e]);(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&vS(d,i,a,o,!1)}function xS({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function SS({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function CS(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function wS(e){return e===void 0||e===1}function TS({scale:e,scaleX:t,scaleY:n}){return!wS(e)||!wS(t)||!wS(n)}var ES=[`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skewX`,`skewY`];function DS(e){return TS(e)||kS(e)||OS(e)}function OS(e){return e.z||e.rotate||e.rotateX||e.rotateY||e.rotateZ||e.skewX||e.skewY}function kS(e){return AS(e.x)||AS(e.y)}function AS(e){return e&&e!==`0%`}function jS(e,t,n){return n+t*(e-n)}function MS(e,t,n,r,i){return i!==void 0&&(e=jS(e,i,r)),jS(e,n,r)+t}function NS(e,t=0,n=1,r,i){e.min=MS(e.min,t,n,r,i),e.max=MS(e.max,t,n,r,i)}function PS(e,{x:t,y:n}){NS(e.x,t.translate,t.scale,t.originPoint),NS(e.y,n.translate,n.scale,n.originPoint)}var FS=.999999999999,IS=1.0000000000001;function LS(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++)a=n[s],o=a.projectionDelta,a.options.visualElement?.props.style?.display!==`contents`&&(r===!0&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(RS(e.x,-a.scroll.offset.x),RS(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,PS(e,o)),r&&(r.path?.[s]||r)!==a&&DS(a.latestValues)&&VS(e,a.latestValues,a.layout?.layoutBox));t.x<IS&&t.x>FS&&(t.x=1),t.y<IS&&t.y>FS&&(t.y=1)}function RS(e,t){e.min+=t,e.max+=t}function zS(e,t,n,r,i=.5){NS(e,t,n,tv(e.min,e.max,i),r)}function BS(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function VS(e,t,n){let r=n??e;zS(e.x,BS(t.x,r.x),t.scaleX,t.scale,t.originX),zS(e.y,BS(t.y,r.y),t.scaleY,t.scale,t.originY)}function HS(e,t){return xS(CS(e.getBoundingClientRect(),t))}function US(e,t,n){let r=HS(e,n),{scroll:i}=t;return i&&(RS(r.x,i.offset.x),RS(r.y,i.offset.y)),r}var WS=()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),{schedule:GS,cancel:KS}=xv(queueMicrotask,!1);function qS(e,t,n){let r=Ux(e)?e:bx(e);return r.start(Ax(``,r,t,n)),r.animation}var JS={},YS={value:null,addProjectionMetrics:null,countProjection:void 0};function XS(e,t){let n=r_.now();e=fS(e);let r=({timestamp:i})=>{let a=i-n;a>=t&&(Cv(r),e(a-t))};return Sv.setup(r,!0),dS(()=>Cv(r))}function ZS(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function QS(e){return lS(e)&&e.tagName===`svg`}function $S(e){return Ux(e)?e.get():e}var eC=e=>typeof e==`number`?e:parseFloat(e),tC=sS.length,nC=e=>typeof e==`number`||$.test(e);function rC(e,t,n,r,i,a){i?(e.opacity=tv(0,n.opacity??1,aC(r)),e.opacityExit=tv(t.opacity??1,0,oC(r))):a&&(e.opacity=tv(t.opacity??1,n.opacity??1,r));for(let i=0;i<tC;i++){let a=sS[i],o=iC(t,a),s=iC(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||nC(o)===nC(s)?(e[a]=Math.max(tv(eC(o),eC(s),r),0),(D_.test(s)||D_.test(o))&&(e[a]+=`%`)):e[a]=s)}for(let i=0;i<ES.length;i++){let a=ES[i];(t[a]||n[a])&&(e[a]=tv(t[a]||0,n[a]||0,r))}}function iC(e,t){return e[t]===void 0?e.borderRadius:e[t]}var aC=sC(0,.5,Wg),oC=sC(.5,.95,Og);function sC(e,t,n){return r=>r<e?0:r>t?1:n(Ag(e,t,r))}function cC(e,t){e.min=t.min,e.max=t.max}function lC(e,t){cC(e.x,t.x),cC(e.y,t.y)}function uC(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var dC=.9999,fC=1.0001,pC=-.01,mC=.01;function hC(e){return e.max-e.min}function gC(e,t,n){return Math.abs(e-t)<=n}function _C(e,t,n,r=.5){e.origin=r,e.originPoint=tv(t.min,t.max,e.origin),e.scale=hC(n)/hC(t),e.translate=tv(n.min,n.max,e.origin)-e.originPoint,(e.scale>=dC&&e.scale<=fC||isNaN(e.scale))&&(e.scale=1),(e.translate>=pC&&e.translate<=mC||isNaN(e.translate))&&(e.translate=0)}function vC(e,t,n,r){_C(e.x,t.x,n.x,r?.originX),_C(e.y,t.y,n.y,r?.originY)}function yC(e,t,n,r=0){e.min=(r?tv(n.min,n.max,r):n.min)+t.min,e.max=e.min+hC(t)}function bC(e,t,n,r){yC(e.x,t.x,n.x,r?.x),yC(e.y,t.y,n.y,r?.y)}function xC(e,t,n,r=0){let i=r?tv(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+hC(t)}function SC(e,t,n,r){xC(e.x,t.x,n.x,r?.x),xC(e.y,t.y,n.y,r?.y)}function CC(e,t,n,r,i){return e-=t,e=jS(e,1/n,r),i!==void 0&&(e=jS(e,1/i,r)),e}function wC(e,t=0,n=1,r=.5,i,a=e,o=e){if(D_.test(t)&&(t=parseFloat(t),t=tv(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=tv(a.min,a.max,r);e===a&&(s-=t),e.min=CC(e.min,t,n,s,i),e.max=CC(e.max,t,n,s,i)}function TC(e,t,[n,r,i],a,o){wC(e,t[n],t[r],t[i],t.scale,a,o)}var EC=[`x`,`scaleX`,`originX`],DC=[`y`,`scaleY`,`originY`];function OC(e,t,n,r){TC(e.x,t,EC,n?.x,r?.x),TC(e.y,t,DC,n?.y,r?.y)}var kC=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),AC=kC(`applewebkit/`)&&!kC(`chrome/`)?Math.round:Og;function jC(e){e.min=AC(e.min),e.max=AC(e.max)}function MC(e){jC(e.x),jC(e.y)}var NC=()=>({translate:0,scale:1,origin:0,originPoint:0}),PC=()=>({x:NC(),y:NC()}),FC=()=>({min:0,max:0}),IC=()=>({x:FC(),y:FC()});function LC(e){return e.translate===0&&e.scale===1}function RC(e){return LC(e.x)&&LC(e.y)}function zC(e,t){return e.min===t.min&&e.max===t.max}function BC(e,t){return zC(e.x,t.x)&&zC(e.y,t.y)}function VC(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function HC(e,t){return VC(e.x,t.x)&&VC(e.y,t.y)}function UC(e){return hC(e.x)/hC(e.y)}function WC(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}var GC=class{constructor(){this.members=[]}add(e){yg(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;r&&r.isConnected!==!1||n.snapshot||(bg(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(bg(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}};function KC(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var qC={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if($.test(e))e=parseFloat(e);else return e}return`${KC(e,t.target.x)}% ${KC(e,t.target.y)}%`}},JC={borderRadius:Object.assign({},qC,{applyTo:sS.slice()}),borderTopLeftRadius:qC,borderTopRightRadius:qC,borderBottomLeftRadius:qC,borderBottomRightRadius:qC,boxShadow:{correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Z_.parse(e);if(i.length>5)return r;let a=Z_.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=tv(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}}};function YC(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e}=n;e&&(r=`perspective(${e}px) ${r}`);for(let e=0;e<ES.length;e++){let t=ES[e],i=n[t];i&&(r+=`${t}(${i}deg) `),!e&&n.pathRotation&&(r+=`rotate(${n.pathRotation}deg) `)}}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}function XC(e){return[e(`x`),e(`y`)]}var ZC=(e,t)=>e.depth-t.depth,QC=class{constructor(){this.children=[],this.isDirty=!1}add(e){yg(this.children,e),this.isDirty=!0}remove(e){bg(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(ZC),this.isDirty=!1,this.children.forEach(e)}},$C={hasAnimatedSinceResize:!0,hasEverUpdated:!1},ew=[`z`,`skew`,`skewZ`],tw=1e3,nw=0;function rw(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}var iw=e=>e.instance&&Xb.get(e.instance)?.demote()&&e.resetSkewAndRotation();function aw(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=qx(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Sv,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&aw(r)}function ow(e){if(e)return e.options.allowProjection===!1?ow(e.parent):e.projection}function sw({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return Object.assign(JS,{...JC,...JS}),class{static create(e,t,n){let{layoutId:r,layout:i,drag:a,dragConstraints:o,layoutScroll:s,layoutRoot:c,layoutAnchor:l,layoutCrossfade:u}=t,d=e.projection=new this(e.latestValues,t[`data-framer-portal-id`]?void 0:ow(e.parent));d.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!a||o&&ZS(o),visualElement:e,animationType:typeof i==`string`?i:`both`,initialPromotionConfig:n,crossfade:u,layoutScroll:s,layoutRoot:c,layoutAnchor:l});let f=d.getStack()?.lead;f&&!d.root.isUpdateBlocked()&&(f.willUpdate(),f.scheduleCheckAfterUnmount())}constructor(e={},n=t?.()){this.id=nw++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(uw),this.nodes.forEach(xw),this.nodes.forEach(Sw),this.nodes.forEach(dw),YS.countProjection?.()},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new QC)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new jg),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){this.eventHandlers.get(e)?.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=lS(t)&&!QS(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent?.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;Sv.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n?.(),n=XS(i,250),$C.hasAnimatedSinceResize&&($C.hasAnimatedSinceResize=!1,this.nodes.forEach(bw)))})}n&&this.root.registerSharedNode(n,this),this.addLayoutListener()}addLayoutListener(){let{layoutId:e,layout:t,visualElement:n,animate:r}=this.options;this.instance&&!this.hasLayoutListener&&r!==!1&&n&&(e||t)&&(this.hasLayoutListener=!0,this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:r,layout:i})=>{if(this.isAnimationBlocked){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||n.getDefaultTransition()||Ow,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=n.getProps(),c=!this.targetLayout||!HC(this.targetLayout,i),l=!t&&r;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...Sx(a,`layout`),onPlay:o,onComplete:s};(n.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||bw(this),this.isLead()&&this.options.onExitComplete?.();this.targetLayout=i}))}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this),this.getStack()?.remove(this),this.parent?.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),this.hasLayoutListener=!1,Cv(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes?.forEach(Cw),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete?.();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&aw(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;iw(this),this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,iw(t),(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1),t.isAnimationBlocked&&(t.dragSnapshot||=t.measure(),this.dragAncestor=t)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(mw),this.nodes.forEach(pw);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(hw);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(_w),this.nodes.forEach(vw),this.nodes.forEach(yw),this.nodes.forEach(cw),this.nodes.forEach(lw)):this.nodes.forEach(hw),this.clearAllSnapshots();let e=r_.now();e_.delta=Sg(0,1e3/60,e-e_.timestamp),e_.timestamp=e,e_.isProcessing=!0,wv.update.process(e_),wv.preRender.process(e_),wv.render.process(e_),e_.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,GS.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(fw),this.sharedNodes.forEach((e,t)=>e.members.length?e.removeLeadSnapshot():this.sharedNodes.delete(t))}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Sv.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Sv.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!hC(this.snapshot.measuredBox.x)&&!hC(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutCorrected||=IC(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t?.notify(`LayoutMeasure`,this.layout.layoutBox,e?.layoutBox)}updateScroll(e=`measure`){let{scroll:t,instance:i}=this,{animationId:a}=this.root;if(this.options.layoutScroll&&i&&!(t&&t.animationId===a&&t.phase===e)){let o=r(i);this.scroll={animationId:a,phase:e,isRoot:o,offset:n(i),wasRoot:t?t.isRoot:o}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout;e&&iw(this);let t=this.projectionDelta&&!RC(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||DS(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),MC(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return IC();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(jw))){let{scroll:e}=this.root;e&&(RS(t.x,e.offset.x),RS(t.y,e.offset.y))}return t}removeElementScroll(e){let t=IC();if(lC(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&lC(t,e),RS(t.x,i.offset.x),RS(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n,r,i=0){let a=n||IC();lC(a,e);for(let e=i;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(RS(a.x,-n.scroll.offset.x),RS(a.y,-n.scroll.offset.y)),DS(n.latestValues)&&VS(a,n.latestValues,n.layout?.layoutBox)}return!r&&DS(this.latestValues)&&VS(a,this.latestValues,this.layout?.layoutBox),a}removeTransform(e){let t=IC();lC(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!DS(n.latestValues))continue;let r;n.instance&&(TS(n.latestValues)&&n.updateSnapshot(),r=IC(),lC(r,n.measurePageBox())),OC(t,n.latestValues,n.snapshot?.layoutBox,r)}return DS(this.latestValues)&&OC(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade},this.addLayoutListener()}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==e_.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=e_.timestamp;let a=this.getClosestProjectingParent();!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),(this.relativeTarget||this.targetDelta)&&(this.target||(this.target=IC(),this.targetWithTransforms=IC()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),bC(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target,!0):lC(this.target,this.layout.layoutBox),PS(this.target,this.targetDelta)):lC(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&(!a.resumingFrom==!this.resumingFrom||a.options.layoutRoot&&!a.resumingFrom)&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),YS.countProjection?.(1))}getClosestProjectingParent(){if(!(!this.parent||TS(this.parent.latestValues)||kS(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=IC(),this.relativeTargetOrigin=IC(),SC(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),lC(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===e_.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent?.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;lC(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;LS(this.layoutCorrected,this.treeScale,this.path,t&&(e.relativeTarget&&!e.relativeParent.resumingFrom?e.relativeParent:!0)),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=IC());let{target:s}=e;s?(!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(uC(this.prevProjectionDelta.x,this.projectionDelta.x),uC(this.prevProjectionDelta.y,this.projectionDelta.y)),vC(this.projectionDelta,this.layoutCorrected,s,this.latestValues),this.treeScale.x===a&&this.treeScale.y===o&&WC(this.projectionDelta.x,this.prevProjectionDelta.x)&&WC(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),YS.countProjection?.(2)):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){this.options.visualElement?.scheduleRender(),e&&this.getStack()?.scheduleRender(),this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=PC(),this.projectionDelta=PC(),this.projectionDeltaWithTransform=PC()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=PC();this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=IC(),c=r?.source!==this.layout?.source,l=this.getStack(),u=!l||l.members.length<=1,d=!(!c||u||this.options.crossfade!==!0||this.path.some(Dw));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);ww(o.x,e.x,n),ww(o.y,e.y,n),r&&(o.x.translate=r.x,o.y.translate=r.y),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(SC(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Ew(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&BC(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=IC(),lC(f,this.relativeTarget)),c&&(this.animationValues=a,rC(a,i,this.latestValues,n,d,u)),r?.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Cv(this.pendingAnimation),void 0),this.pendingAnimation=Sv.update(()=>{$C.hasAnimatedSinceResize=!0,this.motionValue||=bx(0),this.motionValue.jump(0,!1),this.currentAnimation=qS(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),by(this.currentAnimation,this),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta?.(tw),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,layout:n,latestValues:r}=e,{target:i}=e;if(t&&i&&n){if(this!==e&&this.layout&&n&&Aw(this.options.animationType,this.layout.layoutBox,n.layoutBox)){let{layoutBox:e}=this.layout,t=i;i=this.target||IC(),kw(i.x,t.x,e.x),kw(i.y,t.y,e.y)}lC(t,i),VS(t,r),vC(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new GC),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?.transition,preserveFollowOpacity:n?.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){this.getStack()?.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){return this.getStack()?.relegate(this)||!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let{latestValues:t}=e;if(!OS(t))return;let n={};for(let t=0;t<ew.length;t++)rw(ew[t],e,n,this.animationValues);for(let t=0;t<ES.length;t++)rw(ES[t],e,n,this.animationValues);e.render();for(let t in n)e.setStaticValue(t,n[t]),this.animationValues&&(this.animationValues[t]=n[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;let n=this.getLead();if(!this.isVisible&&n!==this){e.visibility=`hidden`;return}let r=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=$S(t?.pointerEvents)||``,e.transform=r?r(this.latestValues,``):`none`;return}if(!this.projectionDelta||!this.layout||!n.target){(this.options.layoutId||this.needsShow)&&(this.needsShow=!1,e.visibility=``,e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=$S(t?.pointerEvents)||``),this.hasProjected&&!DS(this.latestValues)&&(e.transform=r?r({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=n.animationValues||n.latestValues;this.applyTransformsToTarget();let a=YC(this.projectionDeltaWithTransform,this.treeScale,i);r&&(a=r(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,e.opacity=n.animationValues?n===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:n===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in JS){if(i[t]===void 0)continue;let{correct:r,applyTo:o,isCSSVariable:s}=JS[t],c=a===`none`?i[t]:r(i[t],n);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=n===this?$S(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=this.dragSnapshot=this.dragAncestor=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(pw),this.root.sharedNodes.clear()}}}function cw(e){e.updateLayout(),gw(e)}function lw(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source,o=(r,a)=>{if(i===`size`)XC(e=>{let t=hC(r[e]);r[e].min=a[e].min,r[e].max=r[e].min+t});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;cC(r[e],a[e])}else Aw(i,t.layoutBox,n)&&XC(t=>{let n=hC(a[t]);r[t].max=r[t].min+n,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[t].max=e.relativeTarget[t].min+n)})},s=a?t.measuredBox:t.layoutBox;o(s,n);let c=PC();vC(c,n,t.layoutBox);let l=PC();vC(l,a?e.applyTransform(r,!0):n,s);let u=!RC(c),d=!1,f=e.getClosestProjectingParent();if((!e.resumeFrom||f?.options.layoutRoot&&e.resumeFrom.path.includes(f))&&f&&!f.resumeFrom){let{snapshot:r,layout:i}=f;if(r&&i){let s=e.options.layoutAnchor||void 0,c=IC();SC(c,a?e.resumeFrom.applyTransform(t.layoutBox,!0,void 0,!0,f.depth+1):t.layoutBox,r.layoutBox,s);let l=IC();SC(l,n,i.layoutBox,s),a&&o(c,l),HC(c,l)||(d=!0),f.options.layoutRoot&&(e.relativeTarget=l,e.relativeTargetOrigin=c,e.relativeParent=f)}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:l,layoutDelta:c,hasLayoutChanged:u,hasRelativeLayoutChanged:d})}else e.isLead()&&e.options.onExitComplete?.();e.options.transition=void 0}function uw(e){YS.countProjection?.(0),e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function dw(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function fw(e){e.clearSnapshot()}function pw(e){e.clearMeasurements()}function mw(e){e.isLayoutDirty=!0,e.updateLayout()}function hw(e){e.isLayoutDirty=!1}function gw(e){let{snapshot:t,dragAncestor:n}=e,r=n?.isAnimationBlocked&&n.layout;if(!t||!r||e.resumeFrom||e.isAnimationBlocked)return;let i=n.dragSnapshot;XC(e=>RS(t.layoutBox[e],r.layoutBox[e].min-i.layoutBox[e].min))}function _w(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.dragSnapshot||e.layout,e.isLayoutDirty=!0)}function vw(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function yw(e){let{visualElement:t}=e.options;t?.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function bw(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function xw(e){e.resolveTargetDelta()}function Sw(e){e.calcProjection()}function Cw(e){e.resetSkewAndRotation()}function ww(e,t,n){e.translate=tv(t.translate,0,n),e.scale=tv(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Tw(e,t,n,r){e.min=tv(t.min,n.min,r),e.max=tv(t.max,n.max,r)}function Ew(e,t,n,r){Tw(e.x,t.x,n.x,r),Tw(e.y,t.y,n.y,r)}function Dw(e){return e.animationValues?.opacityExit!==void 0}var Ow={duration:.45,ease:[.4,0,.1,1]};function kw(e,t,n){e.max=hC(n)+(e.min=t.min)}function Aw(e,t,n){return e===`position`||e===`preserve-aspect`&&!gC(UC(t),UC(n),.2)}function jw(e){return e!==e.root&&e.scroll?.wasRoot}function Mw(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var Nw=sw({attachResizeListener:(e,t)=>Mw(e,`resize`,t),measureScroll:WS,checkIsScrollRoot:()=>!0}),Pw={current:void 0},Fw=sw({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Pw.current){let e=new Nw({});e.mount(window),e.setOptions({layoutScroll:!0}),Pw.current=e}return Pw.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Iw=new WeakMap;function Lw(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function Rw(e){return typeof e==`string`||Array.isArray(e)}var zw=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Bw=[`initial`].concat(zw);function Vw(e){if(Lw(e.animate))return!0;for(let t=0;t<Bw.length;t++)if(Rw(e[Bw[t]]))return!0;return!1}function Hw(e){return!!(Vw(e)||e.variants)}function Uw(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Ux(i))e.addValue(r,i);else if(Ux(a))e.addValue(r,bx(i,{owner:e}));else if(a!==i){if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,bx(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var Ww={current:null},Gw={current:!1},Kw=typeof window<`u`;function qw(){if(Gw.current=!0,Kw){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>Ww.current=e.matches;e.addEventListener(`change`,t),t()}else Ww.current=!1}}var Jw=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Yw={};function Xw(e){Yw=e}function Zw(){return Yw}var Qw=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=mb,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=r_.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Sv.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=Vw(t),this.isVariantNode=Hw(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&Ux(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];if(this.current=e,Iw.set(e,this),this.projection?.instance||this.projection?.mount(e),this.isVariantNode&&!this.isControllingVariants){let e=this;do e=e.props.inherit!==!1&&e.parent;while(e&&!e.isVariantNode);if(e){let{variantChildren:t}=e;t.add(this),this.removeFromVariantTree=()=>t.delete(this)}}this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(Gw.current||qw(),this.shouldReduceMotion=Ww.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection?.unmount(),Cv(this.notifyUpdate),Cv(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree?.(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),(this.enteringChildren||=new Set).add(e)}removeChild(e){this.children.delete(e),this.enteringChildren?.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.get(e)?.(),t.accelerate&&Ib.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Db({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:Mg(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Xy.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Sv.preRender(this.notifyUpdate),n&&(this.projection&&(this.projection.isTransformDirty=!0),Xb.get(this.current)?.check()),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i?.()})}sortNodePosition(e){return!this.current||!e.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Yw){let t=Yw[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):IC()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){let{transformTemplate:n,onUpdate:r}=this.props;(e.transformTemplate||n)&&this.scheduleRender(),(e.transformTemplate&&!n||e.onUpdate&&!r)&&Xb.get(this.current)?.demote(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<Jw.length;t++){let n=Jw[t];this.propEventSubscriptions[n]?.(),delete this.propEventSubscriptions[n];let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=Uw(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue?.()}getProps(){return this.props}getVariant(e){return this.props.variants?.[e]}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}addValue(e,t){let n=this.values.get(e);if(t!==n){n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t);let r=t.get();r!==void 0&&(this.latestValues[e]=r)}}removeValue(e){this.values.delete(e),this.valueSubscriptions.get(e)?.(),this.valueSubscriptions.delete(e),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){let n=this.props.values?.[e];return n||(n=this.values.get(e),n===void 0&&t!==void 0&&(n=bx(t??this.getDefaultValue?.(e),{owner:this}),this.addValue(e,n)),n)}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(wg(n)||Eg(n))?n=parseFloat(n):typeof n!=`number`&&!Z_.test(n)&&Z_.test(t)&&(n=Iy(e,t)),this.setBaseTarget(e,Ux(n)?n.get():n)),Ux(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return(this.events[e]||(this.events[e]=new jg)).add(t)}notify(e,...t){this.events[e]?.notify(...t)}scheduleRenderMicrotask(){GS.render(this.render)}},$w=class extends Qw{constructor(){super(...arguments),this.KeyframeResolver=oS}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;Ux(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}};function eT(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function tT(e,{layout:t,layoutId:n}){return Xy.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!JS[e]||e===`opacity`)}function nT(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Ux(r[t])||i&&Ux(i[t])||tT(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function rT(e){return window.getComputedStyle(e)}var iT=class extends $w{constructor(){super(...arguments),this.type=`html`,this.renderInstance=eT}mount(e){super.mount(e)}readValueFromInstance(e,t){if(Xy.has(t))return this.projection?.isProjecting?Ky(t):Jy(e,t);{let n=rT(e),r=(o_(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return HS(e,t)}build(e,t,n){hS(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return nT(e,t,n)}},aT=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1;function oT(e){return{point:{x:e.pageX,y:e.pageY}}}var sT=e=>t=>aT(t)&&e(t,oT(t));function cT(e,t,n,r){return Mw(e,t,sT(n),r)}var lT=new WeakMap,uT,dT=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:lS(r)&&`getBBox`in r?r.getBBox()[t]:r[n],fT=dT(`inline`,`width`,`offsetWidth`),pT=dT(`block`,`height`,`offsetHeight`);function mT({target:e,borderBoxSize:t}){lT.get(e)?.forEach(n=>{n(e,{get width(){return fT(e,t)},get height(){return pT(e,t)}})})}function hT(e){e.forEach(mT)}function gT(){typeof ResizeObserver<`u`&&(uT=new ResizeObserver(hT))}function _T(e,t){uT||gT();let n=pS(e);return n.forEach(e=>{let n=lT.get(e);n||(n=new Set,lT.set(e,n)),n.add(t),uT?.observe(e)}),()=>{n.forEach(e=>{let n=lT.get(e);n?.delete(t),n?.size||uT?.unobserve(e)})}}var vT=new Set,yT;function bT(){yT=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};vT.forEach(t=>t(e))},window.addEventListener(`resize`,yT)}function xT(e){return vT.add(e),yT||bT(),()=>{vT.delete(e),!vT.size&&typeof yT==`function`&&(window.removeEventListener(`resize`,yT),yT=void 0)}}function ST(e,t){return dS(typeof e==`function`?xT(e):_T(e,t))}var CT=(e,t)=>Math.abs(e-t);function wT(e,t){let n=CT(e.x,t.x),r=CT(e.y,t.y);return Math.sqrt(n**2+r**2)}var TT=new Set([`auto`,`scroll`]),ET=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=OT(this.lastRawMoveEventInfo,this.transformPagePoint));let e=AT(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=wT(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e;this.history.push({...r,timestamp:r_.now()});let{onStart:i,onMove:a}=this.handlers;t||(i?.(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),a?.(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.handleScroll(window),this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=OT(t,this.transformPagePoint),this.hasPendingMove=!0,Sv.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.hasPendingMove&&this.updatePoint(),this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i?.(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=AT(e.type===`pointercancel`?this.lastMoveEventInfo:OT(t,this.transformPagePoint),this.history);this.startEvent&&n?.(e,a),r?.(e,a)},!aT(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=OT(oT(e),this.transformPagePoint),{point:c}=s;this.history=[{...c,timestamp:r_.now()}];let{onSessionStart:l}=t;l&&l(e,AT(s,this.history));let u={passive:!0,capture:!0};this.removeListeners=kg(cT(this.contextWindow,`pointermove`,this.handlePointerMove,u),cT(this.contextWindow,`pointerup`,this.handlePointerUp,u),cT(this.contextWindow,`pointercancel`,this.handlePointerUp,u)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(TT.has(e.overflowX)||TT.has(e.overflowY))&&this.scrollPositions.set(t,DT(t)),t=t.parentElement}this.scrollPositions.set(window,DT(window)),this.removeScrollListeners=kg(Mw(window,`scroll`,this.onElementScroll,{capture:!0}),Mw(window,`scroll`,this.onWindowScroll,{}))}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=DT(e),i={x:r.x-t.x,y:r.y-t.y};(i.x!==0||i.y!==0)&&(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Sv.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners?.(),this.removeScrollListeners?.(),this.scrollPositions.clear(),Cv(this.updatePoint)}},DT=e=>e===window?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop};function OT(e,t){return t?{point:t(e.point)}:e}function kT(e,t){return{x:e.x-t.x,y:e.y-t.y}}function AT({point:e},t){return{point:e,delta:kT(e,MT(t)),offset:kT(e,jT(t)),velocity:NT(t,.1)}}function jT(e){return e[0]}function MT(e){return e[e.length-1]}function NT(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=MT(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Mg(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Mg(t)*2&&(r=e[1]);let a=Ng(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}var PT=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function FT(e){return PT.has(e.tagName)||e.isContentEditable===!0}var IT=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function LT(e){return IT.has(e.tagName)||e.isContentEditable===!0}var RT={x:!1,y:!1};function zT(){return RT.x||RT.y}function BT(e){return e===`x`||e===`y`?RT[e]?null:(RT[e]=!0,()=>{RT[e]=!1}):RT.x||RT.y?null:(RT.x=RT.y=!0,()=>{RT.x=RT.y=!1})}function VT(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?tv(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?tv(n,e,r.max):Math.min(e,n)),e}function HT(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function UT(e,{top:t,left:n,bottom:r,right:i}){return{x:HT(e.x,n,i),y:HT(e.y,t,r)}}function WT(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function GT(e,t){return{x:WT(e.x,t.x),y:WT(e.y,t.y)}}function KT(e,t){let n=.5,r=hC(e),i=hC(t);return i>r?n=Ag(t.min,t.max-r,e.min):r>i&&(n=Ag(e.min,e.max-i,t.min)),Sg(0,1,n)}function qT(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var JT=.35;function YT(e=JT){return e===!1?e=0:e===!0&&(e=JT),{x:XT(e,`left`,`right`),y:XT(e,`top`,`bottom`)}}function XT(e,t,n){return{min:ZT(e,t),max:ZT(e,n)}}function ZT(e,t){return typeof e==`number`?e:e[t]||0}function QT(e){let t=``;for(let n of e.path){n.scroll=void 0,n.updateScroll();let{scroll:r}=n;n!==e.root&&r&&(t+=r.offset.x+`,`+r.offset.y+`,`)}return t}var $T=new WeakMap,eE=class{constructor(e,t=()=>e.getProps()){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=IC(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e,this.readProps=t}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){if(this.visualElement.presenceContext?.isPresent===!1)return;let r=e=>{t&&this.snapToCursor(e),this.stopAnimation()},i=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock?.(),this.openDragLock=BT(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints();let{projection:a}=this.visualElement;a&&(a.isAnimationBlocked=!0,a.target=void 0),XC(e=>{let t=this.getAxisMotionValue(e).get()||0;if(c_(t)&&(t=Nx(t,this.visualElement.current)||0),$.test(t))t=parseFloat(t);else if(D_.test(t)){let n=a?.layout?.layoutBox[e];n&&(t=hC(n)*(parseFloat(t)/100))}this.originPoint[e]=t}),i&&Sv.update(()=>i(e,t),!1,!0),Gx(this.visualElement,`transform`),this.visualElement.animationState?.setActive(`whileDrag`,!0)},a=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){if(this.currentDirection=oE(o),this.currentDirection===null)return;i&&i(this.currentDirection)}this.updateAxis(`x`,o),this.updateAxis(`y`,o),this.visualElement.render(),a&&Sv.update(()=>a(e,t),!1,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},s=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:c}=this.getProps();this.panSession=new ET(e,{onSessionStart:r,onStart:i,onMove:a,onSessionEnd:o,resumeAnimation:s},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:n,contextWindow:this.visualElement.current?.ownerDocument.defaultView,element:this.visualElement.current})}stop(e,t,n){let r=e||this.latestPointerEvent,i=t||this.latestPanInfo,a=this.isDragging;if(this.cancel(),!a||!i||!r)return;let{velocity:o}=i;this.startAnimation(o,n);let{onDragEnd:s}=this.getProps();s&&Sv.postRender(()=>s(r,i))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession(),!this.getProps().dragPropagation&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t?.setActive(`whileDrag`,!1)}endPanSession(){this.panSession?.end(),this.panSession=void 0}updateAxis(e,t){let{drag:n}=this.readProps();if(!t||!aE(e,n,this.currentDirection))return;let r=this.getAxisMotionValue(e),i=this.originPoint[e]+t[e],a=this.constraints&&this.constraints[e];a&&(i=VT(i,a,this.elastic[e])),r.set(i)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),{projection:n}=this.visualElement,r=n&&(n.layout||n.measure(!1)),i=this.constraints;tE(e)?this.constraints&&this.scroll===QT(n)||(this.constraints=this.resolveRefConstraints()):this.constraints=e&&r?UT(r.layoutBox,e):!1,this.elastic=YT(t),i!==this.constraints&&!tE(e)&&r&&this.constraints&&!this.hasMutatedConstraints&&XC(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=qT(r.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!tE(e))return!1;let n=nE(e),{projection:r}=this.visualElement;if(!r||!r.layout)return!1;this.scroll=QT(r);let i=US(n,r.root,this.visualElement.getTransformPagePoint()),a=GT(r.layout.layoutBox,r.removeElementScroll(i));if(t){let e=t(SS(a));this.hasMutatedConstraints=!!e,e&&(a=xS(e))}return a}startAnimation(e,t){let{drag:n,dragMomentum:r,dragElastic:i,dragTransition:a,dragSnapToOrigin:o,onDragTransitionEnd:s}=this.getProps(),c=this.constraints||{},l=XC(s=>{if(!aE(s,t||n,this.currentDirection))return;let l=c[s]||{};(o===!0||o===s)&&(l={min:0,max:0});let u=i?200:1e6,d=i?40:1e7,f={type:`inertia`,velocity:r?e[s]:0,bounceStiffness:u,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...a,...l};return this.startAxisValueAnimation(s,f)});return Promise.all(l).then(s)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return Gx(this.visualElement,e),n.start(Ax(e,n,0,t,this.visualElement,!1))}stopAnimation(){XC(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.readProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor({clientX:e,clientY:t}){let{drag:n}=this.getProps(),r={x:e,y:t},i=this.visualElement.getTransformPagePoint()?.(r)||r,a=this.visualElement.measureViewportBox();XC(e=>{if(!aE(e,n,this.currentDirection))return;let t=this.getAxisMotionValue(e),{min:r,max:o}=a[e];t.set((t.get()||0)+i[e]-tv(r,o,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!tE(t)||!n||!this.constraints)return;this.stopAnimation();let r=this.constraints,i={x:0,y:0};XC(e=>{let t=this.getAxisMotionValue(e).get();i[e]=KT({min:t,max:t},r[e])});let{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},``):`none`,n.root?.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),XC(t=>{let n=this.getAxisMotionValue(t);if(!aE(t,e,null)||!n.get())return;let{min:r,max:a}=this.constraints[t];n.set(tv(r,a,i[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;$T.set(this.visualElement,this);let e=this.visualElement.current,t=cT(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&<(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps(),r=tE(t)&&nE(t);r&&(this.constraints=this.resolveRefConstraints(),n||=iE(e,r,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i.layout||(i.root?.updateScroll(),i.updateLayout()),Sv.read(r);let o=Mw(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(XC(t=>{if(!aE(t,this.getProps().drag,this.currentDirection))return;let n=this.getAxisMotionValue(t);this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate)}),this.visualElement.render())}));return()=>{o(),t(),a(),s(),n?.()}}getProps(){let e=this.readProps(),{dragElastic:t=JT,dragMomentum:n=!0}=e;return{...e,dragElastic:t,dragMomentum:n}}};function tE(e){return!!e&&typeof e==`object`&&(`current`in e||`nodeType`in e)}var nE=e=>`current`in e?e.current:e;function rE(e){let t=!0;return()=>{t?t=!1:e()}}function iE(e,t,n){let r=ST(e,rE(n)),i=ST(t,rE(n));return()=>{r(),i()}}function aE(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function oE(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}function sE(e,t){let n=pS(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},dS(()=>r.abort())]}function cE(e){return!(e.pointerType===`touch`||zT())}function lE(e,t,n={}){t=fS(t);let[r,i,a]=sE(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{e.pointerType!==`touch`&&(n?r=!0:s(e))};e.addEventListener(`pointerenter`,n=>{if(!cE(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var uE=(e,t)=>t?e===t||uE(e,t.parentElement):!1,dE=new WeakSet;function fE(e){return t=>{t.key===`Enter`&&e(t)}}function pE(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var mE=(e,t)=>{let n=!1,r=fE(()=>{dE.has(e)||(n=!0,pE(e,`down`))}),i=fE(()=>{n&&(n=!1,pE(e,`up`))});e.addEventListener(`keydown`,r,t),e.addEventListener(`keyup`,i,t),e.addEventListener(`blur`,()=>{e.removeEventListener(`keydown`,r),e.removeEventListener(`keyup`,i),n&&pE(e,`cancel`)},{...t,once:!0})};function hE(e){return aT(e)&&!zT()}var gE=new WeakSet;function _E(e,t,n={}){t=fS(t);let[r,i,a]=sE(e,n),o=e=>{let r=e.currentTarget;if(!hE(e)||gE.has(e))return;dE.add(r),n.stopPropagation&&gE.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),dE.has(r)&&dE.delete(r),hE(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||uE(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),cS(e)&&(e.addEventListener(`focus`,()=>mE(e,i),i),!FT(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function vE(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],i=e[1+n],a=e[2+n],o=e[3+n],s=ry(i,a,o);return t?s(r):s}var yE=class{constructor(e){this.isMounted=!1,this.node=e}update(){}},bE=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),xE=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function SE(e,t,n,r){eT(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(bE.has(n)?n:mS(n),t.attrs[n])}function CE(e,t,n){let r=nT(e,t,n);for(let n in e)if(n!==`children`&&(Ux(e[n])||Ux(t[n]))){let t=Yy.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var wE=class extends $w{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=IC}getBaseTargetFromProps(e,t){return Xy.has(t)?super.getBaseTargetFromProps(e,t)??Ky(t):e[t]}getDefaultValue(e){return Xy.has(e)?this.latestValues[e]??Ky(e):void 0}readValueFromInstance(e,t){if(Xy.has(t)){let e=Py(t);return e&&e.default||0}if(yS.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=bE.has(t)?t:mS(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return CE(e,t,n)}build(e,t,n){bS(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){SE(e,t,n,r)}mount(e){this.isSVGTag=xE(e.tagName),super.mount(e)}};function TE(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var EE=[...zw].reverse(),DE=e=>e?.out===!0?e:e?.out;function OE(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>Qx(e,t,n))),n=AE(),r=!0,i=!1;function a(a){let{props:o,parent:s,manuallyAnimateOnMount:c}=e,{initial:l}=o,u=r||i,d=[],f=(t=l)=>typeof t!=`boolean`&&Ix(e,Array.isArray(t)?t[0]:t,e.presenceContext?.custom)||void 0,p=new Map,m={},h=1/0,g=e;do g=g.props.inherit!==!1&&g.parent;while(g&&!g.isControllingVariants);let _=u&&DE(f(l??(g&&g.props.initial))?.transition);if(EE.forEach((t,r)=>{let i=n[t],l=o[t],f=g&&g.props[t],v=l===void 0?Rw(f)||f===!1?f:void 0:l,y=Rw(v),b=t===a?i.isActive:null,x=y&&l===void 0&&!(u&&c);if(i.protectedKeys={...m},!i.isActive&&b===null||!v&&!i.prevProp||Lw(v)||typeof v==`boolean`)return;if(b===!1&&(h=r),t===`exit`&&i.isActive&&b!==!0){m={...m,...i.prevResolvedValues};return}let S=kE(i.prevProp,v),C=S||y&&(b&&!x||r>h),w=!1,T=Array.isArray(v)?v:[v],E={},D;if(b!==!1)for(let n of T){let{transition:r,transitionEnd:i,...a}=Ix(e,n,Lx(e,t))||{};E={...E,...a,...i},D=DE(r)||D}let{prevResolvedValues:O}=i;for(let t in{...O,...E}){if(t in m)continue;let n=E[t],r=O[t],a=Array.isArray(n)&&Array.isArray(r)?!TE(n,r)||S:n!==r,o;if(a&&n==null)p.has(t)||p.set(t,i.prevOut);else if(a||n!==void 0&&p.has(t)){C=!0,o=p.get(t)||_,p.delete(t)&&(w=!0),i.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)}else i.protectedKeys[t]=!0;i.out[t]=o}if(i.prevProp=v,i.prevResolvedValues=E,i.prevOut=D,i.isActive&&(m={...m,...E}),C&&(!(x&&S)||w))for(let n of T){let r={type:t};if(typeof n==`string`&&u&&c&&s?.enteringChildren){let t=Ix(s,n)?.transition?.delayChildren;r.delay=hx(s.enteringChildren,e,t)}d.push({animation:n,options:r})}}),p.size){let t={},n=f(),r=n?.transition;p.forEach((i,a)=>{i&&(r={...r||e.getDefaultTransition(),[a]:i});let s=e.getValue(a);s&&(s.liveStyle=!0);let c=n&&!Array.isArray(l)?n[a]:void 0,u=e.getBaseTargetFromProps(o,a);t[a]=(c===void 0?u!==void 0&&!Ux(u)?u:e.initialValues[a]===void 0?e.baseTarget[a]:void 0:c)??null}),r&&(t.transition=r),d.push({animation:t})}let v=u&&e.blockInitialAnimation||r&&!c&&(o.initial===!1||o.initial===o.animate);return r=i=!1,!v&&d.length?t(d):Promise.resolve()}function o(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=a(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:a,setActive:o,setAnimateFunction:n=>{t=n(e)},getState:()=>n,reset:()=>{n=AE(),i=!0}}}function kE(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!TE(t,e):!1}function AE(){let e={};for(let t of zw)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{},out:{}};return e}var jE=(0,W.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function ME(e=!0){let t=(0,W.useContext)(vg);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,W.useId)();(0,W.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,W.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var NE=(0,W.createContext)({strict:!1}),PE={animation:[`variants`,...zw],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},FE=!1;function IE(){if(FE)return;let e={};for(let t in PE)e[t]={isEnabled:e=>PE[t].some(t=>!!e[t])};Xw(e),FE=!0}function LE(){return IE(),Zw()}function RE(e){let t=LE();for(let n in e)t[n]={...t[n],...e[n]};Xw(t)}var zE=(0,W.createContext)({});function BE(e,t){if(Vw(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Rw(t)?t:void 0,animate:Rw(n)?n:void 0}}return e.inherit===!1?{}:t}function VE(e){let{initial:t,animate:n}=BE(e,(0,W.useContext)(zE));return(0,W.useMemo)(()=>({initial:t,animate:n}),[HE(t),HE(n)])}function HE(e){return Array.isArray(e)?e.join(` `):e}var UE=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function WE(e,t,n){for(let r in t)!Ux(t[r])&&!tT(r,n)&&(e[r]=t[r])}function GE({transformTemplate:e},t){return(0,W.useMemo)(()=>{let n=UE();return hS(n,t,e),Object.assign({},n.vars,n.style)},[t])}function KE(e,t){let n=e.style||{},r={};return WE(r,n,e),Object.assign(r,GE(e,t)),r}function qE(e,t){let n={},r=KE(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var JE=()=>({...UE(),attrs:{}});function YE(e,t,n,r){let i=(0,W.useMemo)(()=>{let n=JE();return bS(n,t,xE(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};return WE(t,e.style,e),{...i,style:{...t,...i.style}}}return i}var XE=new Set(`animate.exit.variants.initial.style.values.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function ZE(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||XE.has(e)}function QE(e,t){return e.startsWith(`on`)?!ZE(e):t?.(e)??!ZE(e)}function $E(e,t,n,r){let i={};for(let a in e)a===`values`&&typeof e.values==`object`||Ux(e[a])||(QE(a,r)||n===!0&&ZE(a)||!t&&!ZE(a)||e.draggable&&a.startsWith(`onDrag`))&&(i[a]=e[a]);return i}var eD=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function tD(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(eD.indexOf(e)>-1||/[A-Z]/u.test(e))}function nD(e,t,n,{latestValues:r},i,a=!1,o,s){let c=(o??tD(e)?YE:qE)(t,r,i,e),l=$E(t,typeof e==`string`,a,s),u=e===W.Fragment?{}:{...l,...c,ref:n},{children:d}=t,f=(0,W.useMemo)(()=>Ux(d)?d.get():d,[d]);return(0,W.createElement)(e,{...u,children:f})}function rD({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:iD(n,r,i,e),renderState:t()}}function iD(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=$S(a[e]);let{initial:o,animate:s}=e,c=Vw(e),l=Hw(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Lw(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Fx(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var aD=e=>(t,n)=>{let r=(0,W.useContext)(zE),i=(0,W.useContext)(vg),a=()=>rD(e,t,r,i);return n?a():gg(a)},oD=aD({scrapeMotionValuesFromProps:nT,createRenderState:UE}),sD=aD({scrapeMotionValuesFromProps:CE,createRenderState:JE}),cD=Symbol.for(`motionComponentSymbol`);function lD(e,t,n){let r=(0,W.useRef)(n);(0,W.useInsertionEffect)(()=>{r.current=n});let i=(0,W.useRef)(null);return(0,W.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`){if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n)}else a&&(a.current=n)},[t])}var uD=(0,W.createContext)({});function dD(e,t,n,r,i,a){let{visualElement:o}=(0,W.useContext)(zE),s=(0,W.useContext)(NE),c=(0,W.useContext)(vg),l=(0,W.useContext)(jE),u=l.reducedMotion,d=l.skipAnimations,f=(0,W.useRef)(null),p=(0,W.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,W.useContext)(uD);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&i.create(m,n,h),(0,W.useInsertionEffect)(()=>{m&&m.props!==n&&m.update(n,c)});let g=n[Kx],_=(0,W.useRef)(!!g&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return _g(()=>{p.current&&m&&(m.animationState?.animateChanges(),m.enteringChildren=void 0)},[]),_g(()=>{p.current=!0,m&&(window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),_.current&&m.animationState&&m.animationState.animateChanges())}),(0,W.useEffect)(()=>{m&&(!_.current&&m.animationState&&m.animationState.animateChanges(),_.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),!1),m.enteringChildren=void 0)}),m}function fD(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&RE(r);let a=n?n===`svg`:tD(e),o=a?sD:oD;function s(n,s){let c,l=pD(n);gg(()=>!!Pw.current?.sharedNodes.get(l)?.lead&&n.initial)&&(n={...n,initial:!1});let u={...(0,W.useContext)(jE),...n,layoutId:l},{isStatic:d,isValidProp:f}=u,p=VE(n),m=o(n,d);if(!d&&typeof window<`u`){mD(u,r);let t=hD(u);p.visualElement=dD(e,m,u,i,t.ProjectionNode,a),(t.isEnabled||p.visualElement?.projection?.options.layoutId)&&(c=t.MeasureLayout)}return(0,G.jsxs)(zE.Provider,{value:p,children:[c&&p.visualElement?(0,G.jsx)(c,{visualElement:p.visualElement,...u}):null,nD(e,n,lD(m,p.visualElement,s),m,d,t,a,f)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,W.forwardRef)(s);return c[cD]=e,c}function pD({layoutId:e}){let t=(0,W.useContext)(hg).id;return t&&e!==void 0?t+`-`+e:e}function mD(e,t){(0,W.useContext)(NE).strict}function hD(e){let{drag:t,layout:n}=LE();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:r.MeasureLayout,isEnabled:t?.isEnabled(e)||n?.isEnabled(e),ProjectionNode:r.ProjectionNode}}function gD(e,t){if(typeof Proxy>`u`)return fD;let n=new Map,r=(n,r)=>fD(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,fD(a,void 0,e,t)),n.get(a))})}var _D=(e,t)=>t.isSVG??tD(e)?new wE(t):new iT(t,{allowProjection:e!==W.Fragment}),vD=class extends yE{constructor(e){super(e),e.animationState||=OE(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Lw(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){this.node.getProps().animate!==this.node.prevProps?.animate&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},yD=0,bD={animation:{Feature:vD},exit:{Feature:class extends yE{constructor(){super(...arguments),this.id=yD++}update(){let{presenceContext:e,prevPresenceContext:t,animationState:n}=this.node;if(!e||!n)return;let{isPresent:r,onExitComplete:i}=e,a=t?.isPresent;if(r===a)return;if(r&&a===!1){if(this.exit===!0){let{initial:e}=this.node.getProps();if(e&&!Array.isArray(e)){let{transition:t,transitionEnd:n,...r}=Ix(this.node,e)||{};for(let e in r)this.node.getValue(e)?.jump(r[e])}this.node.blockInitialAnimation=!1,n.reset(),n.animateChanges()}else n.setActive(`exit`,!1);this.exit=void 0;return}let o=this.exit=n.setActive(`exit`,!r);i&&!r&&o.then(()=>{this.exit===o&&(this.exit=!0,i(this.id))})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id,this.node))}unmount(){}}}},xD=class extends yE{constructor(e){super(e),this.removeGroupControls=Og,this.removeListeners=Og,this.controls=new eE(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Og}update(){let{dragControls:e,drag:t}=this.node.getProps(),{dragControls:n,drag:r}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls))),r&&!t&&this.controls.stop(void 0,void 0,r)}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},SD=e=>(t,n)=>{e&&Sv.update(()=>e(t,n),!1,!0)},CD=class extends yE{constructor(){super(...arguments),this.removePointerDownListener=Og}onPointerDown(e){this.session=new ET(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:this.node.current?.ownerDocument.defaultView})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:SD(e),onStart:SD(t),onMove:SD(n),onEnd:(e,t)=>{delete this.session,r&&Sv.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=cT(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session?.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session?.end()}},wD=!1,TD=({layout:e,layoutDependency:t,layoutAnchor:n})=>({layout:e,layoutDependency:t,layoutAnchor:n,animationType:typeof e==`string`?e:`both`}),ED=(e,t)=>{let{snapshot:n}=e,r=e.getStack();r?.remove(e);let i=r?.lead;if(r?.prevLead===e&&i.resumeFrom===e&&(i.resumeFrom=i.currentAnimation=e.resumingFrom=void 0),e.options.layoutId=t,!t)e.needsShow=!0;else return e.root.registerSharedNode(t,e),()=>{let{resumeFrom:t}=e;t?.isPresent!==!1&&e.getStack().members.includes(t)&&(t.hide(),e.resumeFrom=void 0,e.snapshot=n)}},DD=class extends W.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group?.add(i),r&&n?.register?.(i),wD&&i.root.didUpdate(),i.options.layoutId!==r&&ED(i,r)?.(),i.addEventListener(`animationComplete`,()=>this.safeToRemove()),i.setOptions({...i.options,...TD(this.props),onExitComplete:()=>this.safeToRemove()})),$C.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,layoutId:n,visualElement:r,drag:i,isPresent:a}=this.props,{projection:o}=r;return o&&(o.isPresent=a,this.takeOver=e.layoutId===n?void 0:(o.willUpdate(),ED(o,n)),o.setOptions({...o.options,...TD(this.props)}),wD=!0,i||e.layoutDependency!==t||t===void 0||e.isPresent!==a?o.willUpdate():this.safeToRemove(),e.isPresent!==a&&(a?o.promote():o.relegate()||Sv.postRender(()=>{o.getStack()?.members.length||this.safeToRemove()}))),null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(this.takeOver?.(),e.root.didUpdate(),GS.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;wD=!0,r&&(r.scheduleCheckAfterUnmount(),t.group?.remove(r),n?.deregister?.(r))}safeToRemove(){this.props.safeToRemove?.()}render(){return null}};function OD(e){let[t,n]=ME(),r=(0,W.useContext)(hg);return(0,G.jsx)(DD,{...e,layoutGroup:r,switchLayoutGroup:(0,W.useContext)(uD),isPresent:t,safeToRemove:n})}var kD={pan:{Feature:CD},drag:{Feature:xD,ProjectionNode:Fw,MeasureLayout:OD}};function AD(e,t,n,r){let{props:i}=e,a=`while`+n;e.animationState&&i[a]&&e.animationState.setActive(a,r===`Start`);let o=i[`on`+n+r];o&&Sv.postRender(()=>o(t,oT(t)))}var jD=class extends yE{mount(){let{current:e}=this.node;e&&(this.unmount=lE(e,(e,t)=>(AD(this.node,t,`Hover`,`Start`),e=>AD(this.node,e,`Hover`,`End`))))}unmount(){}},MD=class extends yE{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}e&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=kg(Mw(this.node.current,`focus`,()=>this.onFocus()),Mw(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function ND(e,t,n){e.current instanceof HTMLButtonElement&&e.current.disabled||AD(e,t,`Tap`,n)}var PD=class extends yE{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=_E(e,(e,t)=>(ND(this.node,t,`Start`),(e,{success:t})=>ND(this.node,e,t?``:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},FD=new WeakMap,ID=new WeakMap,LD=e=>{let t=FD.get(e.target);t&&t(e)},RD=e=>{e.forEach(LD)};function zD({root:e,...t}){let n=e||document;ID.has(n)||ID.set(n,{});let r=ID.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(RD,{root:e,...t})),r[i]}function BD(e,t,n){let r=zD(t);return FD.set(e,n),r.observe(e),()=>{FD.delete(e),r.unobserve(e)}}var VD={some:0,all:1},HD=class extends yE{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:VD[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=BD(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(UD(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function UD({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var WD=gD(Object.assign({},bD,{inView:{Feature:HD},tap:{Feature:PD},focus:{Feature:MD},hover:{Feature:jD}},kD,{layout:{ProjectionNode:Fw,MeasureLayout:OD}}),_D);function GD(e){let t=gg(()=>bx(e)),{isStatic:n}=(0,W.useContext)(jE);if(n){let[,n]=(0,W.useState)(e);(0,W.useEffect)(()=>t.on(`change`,n),[])}return t}function KD(e,t){let n=GD(t()),r=()=>n.set(t());return r(),_g(()=>{let t=()=>Sv.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return r(),()=>{n.forEach(e=>e()),Cv(r)}}),n}function qD(e){vx.current=[],e();let t=KD(vx.current,e);return vx.current=void 0,t}function JD(e,t,n,r){if(typeof e==`function`)return qD(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return XD(e,t,n,r);let i=typeof t==`function`?t:vE(t,n,r),a=Array.isArray(e)?YD(e,i):YD([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;if(o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1&&!r?.mixer){let e=r?.ease;a.accelerate={...o,times:[0,...t,1],keyframes:[n[0],...n,n[n.length-1]],isTransformed:!0,...e?{ease:Array.isArray(e)?[e[0],...e]:e}:{}}}return a}function YD(e,t){let n=gg(()=>[]);return KD(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function XD(e,t,n,r){let i=gg(()=>Object.keys(n)),a=gg(()=>({}));for(let o of i)a[o]=JD(e,t,n[o],r);return a}var ZD=class{constructor(){this.componentControls=new Set}subscribe(e){return this.componentControls.add(e),()=>this.componentControls.delete(e)}start(e,t){this.componentControls.forEach(n=>{n.start(e.nativeEvent||e,t)})}cancel(){this.componentControls.forEach(e=>{e.cancel()})}stop(){this.componentControls.forEach(e=>{e.stop()})}},QD=()=>new ZD;function $D(){return gg(QD)}var eO=(0,W.createContext)(null);function tO(e,t,n,r,i,a=`ltr`){let o=e.findIndex(e=>e.value===t);if(o===-1)return e;if(i===`xy`){let{layout:t}=e[o],r={x:tv(t.x.min,t.x.max,.5)+n.x,y:tv(t.y.min,t.y.max,.5)+n.y},i=nO(e),s=i.find(t=>t.items.includes(e[o])),c=i.reduce((e,t)=>rO(r.y,t)<rO(r.y,e)?t:e);if(c!==s)return iO(e,o,r.x,c,a);let l=aO(r,t),u=-1,d=l;return e.forEach((e,t)=>{if(t===o)return;let n=aO(r,e.layout);n<d&&(u=t,d=n)}),u===-1?e:xg(e,o,o+Math.sign(u-o))}if(!r[i])return e;let s=r[i]>0?1:-1,c=e[o+s];if(!c)return e;let l=e[o].layout[i],u=c.layout[i],d=tv(u.min,u.max,.5);return s===1&&l.max+n[i]>d||s===-1&&l.min+n[i]<d?xg(e,o,o+s):e}function nO(e){let t=[];return e.forEach(e=>{let{min:n,max:r}=e.layout.y,i=t[t.length-1];!i||n>=i.max||r<=i.min?t.push({items:[e],min:n,max:r}):(i.items.push(e),i.min=Math.min(i.min,n),i.max=Math.max(i.max,r))}),t}function rO(e,t){return e<t.min?t.min-e:e>t.max?e-t.max:0}function iO(e,t,n,r,i){let a=e.filter((e,n)=>n!==t),o=r.items.find(e=>{let t=tv(e.layout.x.min,e.layout.x.max,.5);return i===`ltr`?n<t:n>t}),s=o?a.indexOf(o):a.indexOf(r.items[r.items.length-1])+1,c=[...a];return c.splice(s,0,e[t]),c.every((t,n)=>t===e[n])?e:c}function aO(e,t){let n=Math.max(t.x.min-e.x,0,e.x-t.x.max),r=Math.max(t.y.min-e.y,0,e.y-t.y.max);return n*n+r*r}var oO=(e,t)=>e.max<=t.min||t.max<=e.min;function sO(e){let t=!1,n=!1;for(let r=0;r<e.length;r++)for(let i=r+1;i<e.length;i++)if(t||=oO(e[r].x,e[i].x),n||=oO(e[r].y,e[i].y),t&&n)return`xy`;return t?`x`:`y`}function cO({children:e,as:t=`ul`,axis:n,onReorder:r,values:i,onPointerDownCapture:a,onClickCapture:o,...s},c,l){let u=gg(()=>l[t]),d=(0,W.useRef)(new Map),[f,p]=(0,W.useState)(`y`),m=(0,W.useRef)(!1),h=(0,W.useRef)(!1),g=(0,W.useRef)(null),_=n||f,v=new Set(i);d.current.forEach((e,t)=>{v.has(t)||d.current.delete(t)});let y=()=>i.flatMap(e=>{let t=d.current.get(e);return t?[{value:e,layout:t}]:[]}),b=()=>g.current?.ownerDocument.defaultView?.getComputedStyle(g.current).direction===`rtl`,x=(e,t)=>{let n=0,a=i.map(t=>d.current.has(t)?e[n++].value:t);a.some((e,t)=>e!==i[t])&&r(a,t)},S={axis:_,proxy:l,groupRef:g,hasReordered:h,onKeyDown:(e,t,n,r)=>{let{key:a,currentTarget:o}=e;if(e.defaultPrevented||e.target!==o||e.altKey||e.ctrlKey||e.metaKey)return;let s=y(),c=[`ArrowUp`,`ArrowLeft`,`ArrowDown`,`ArrowRight`].indexOf(a),l=c%2;if(a===` `)e.repeat||r(o,n?void 0:i);else if(!n)return;else if(a===`Escape`){let e=n.flatMap(e=>s.filter(t=>t.value===e));x(s.map(t=>n.includes(t.value)?e.shift():t),t),r(o)}else if(c<0||_!==`xy`&&_!==(l?`x`:`y`))return;else{let e=s.findIndex(({value:e})=>e===t),n=e+(c>1==!!(l&&b())?-1:1);e>-1&&s[n]&&x(xg(s,e,n),t)}e.preventDefault()},registerItem:(e,t)=>{if(d.current.set(e,t),!n){let e=sO(i.flatMap(e=>{let t=d.current.get(e);return t?[t]:[]}));e!==f&&p(e)}},updateOrder:(e,t,n)=>{if(m.current)return;let r=y(),i=tO(r,e,t,n,_,b()?`rtl`:`ltr`);r!==i&&(m.current=!0,h.current=!0,x(i,e))}};(0,W.useEffect)(()=>{m.current=!1},[i]);let C=e=>{g.current=e,typeof c==`function`?c(e):c&&(c.current=e)},w={overflowAnchor:`none`,...s.style};return(0,G.jsx)(u,{...s,style:w,ref:C,onPointerDownCapture:e=>{h.current=!1,a?.(e)},onClickCapture:e=>{h.current&&e.detail&&(h.current=!1,e.stopPropagation(),e.preventDefault()),o?.(e)},ignoreStrict:!0,children:(0,G.jsx)(eO.Provider,{value:S,children:e})})}var lO=e=>(0,W.forwardRef)((t,n)=>cO(t,n,e)),uO=50,dO=1.5,fO=new Set([`auto`,`scroll`]),pO=new WeakMap,mO=new WeakMap,hO=null;function gO(){if(hO){let e=vO(hO,`y`);e&&(mO.delete(e),pO.delete(e));let t=vO(hO,`x`);t&&t!==e&&(mO.delete(t),pO.delete(t)),hO=null}}function _O(e,t){let n=getComputedStyle(e),r=t===`x`?n.overflowX:n.overflowY,i=e===document.body||e===document.documentElement;return fO.has(r)||i}function vO(e,t){let n=e?.parentElement;for(;n;){if(_O(n,t))return n;n=n.parentElement}return null}function yO(e){let t=Math.min(1,1-e/uO);return dO*t*t*e_.delta}function bO(e,t,n){let r=t.getBoundingClientRect(),i=n===`x`?Math.max(0,r.left):Math.max(0,r.top),a=n===`x`?Math.min(window.innerWidth,r.right):Math.min(window.innerHeight,r.bottom),o=e-i,s=a-e;return o<uO?{amount:-yO(o),edge:`start`}:s<uO?{amount:yO(s),edge:`end`}:{amount:0,edge:null}}function xO(e,t,n,r){if(!e)return;hO=e;let i=vO(e,n);if(!i)return;let{amount:a,edge:o}=bO(t-(n===`x`?window.scrollX:window.scrollY),i,n);if(o===null){mO.delete(i),pO.delete(i);return}let s=mO.get(i),c=i===document.body||i===document.documentElement;if(s!==o){if(!(o===`start`&&r<0||o===`end`&&r>0))return;mO.set(i,o);let e=n===`x`?i.scrollWidth-(c?window.innerWidth:i.clientWidth):i.scrollHeight-(c?window.innerHeight:i.clientHeight);pO.set(i,e)}if(a>0){let e=pO.get(i);if((n===`x`?c?window.scrollX:i.scrollLeft:c?window.scrollY:i.scrollTop)>=e)return}n===`x`?c?window.scrollBy({left:a}):i.scrollLeft+=a:c?window.scrollBy({top:a}):i.scrollTop+=a}function SO(e,t=0){return Ux(e)?e:GD(t)}function CO({children:e,style:t={},value:n,as:r=`li`,onDrag:i,onDragEnd:a,onKeyDown:o,onBlur:s,layout:c=!0,...l},u){let d=(0,W.useContext)(eO),f=gg(()=>d.proxy[r]),[p,m]=(0,W.useState)(),h={x:SO(t.x),y:SO(t.y)},g=JD([h.x,h.y],([e,t])=>e||t?1:`unset`),{axis:_,registerItem:v,updateOrder:y,groupRef:b,hasReordered:x,onKeyDown:S}=d,C=_===`xy`||_,w=(e,t)=>{m(t),Iw.get(e)?.animationState?.setActive(`whileDrag`,!!t)};return(0,G.jsx)(f,{drag:C,tabIndex:0,...l,dragSnapToOrigin:!0,style:{...t,x:h.x,y:h.y,zIndex:g},layout:c,onDrag:(e,t)=>{let{velocity:r,point:a}=t,o={x:h.x.get(),y:h.y.get()};y(n,o,r);let s=_===`xy`?Math.abs(r.x)>Math.abs(r.y)?`x`:`y`:_;xO(b.current,a[s],s,r[s]),i&&i(e,t)},onDragEnd:(e,t)=>{x.current=!1,gO(),a&&a(e,t)},onKeyDown:e=>{o?.(e),S(e,n,p,w)},onBlur:e=>{s?.(e),p&&w(e.currentTarget)},onLayoutMeasure:e=>{v(n,e)},ref:u,ignoreStrict:!0,children:e})}var wO=(0,W.forwardRef)(CO),TO=lO(WD);function EO(e){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(``),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(null);return(0,G.jsxs)(`form`,{className:`grid`,onSubmit:async n=>{n.preventDefault(),u(null);try{if(t)await Ft([ut(a).address],s.trim()===``?null:s.trim());else{let e=ut(r);await Ft([e.address],e.code)}e.onAdded?.()}catch(e){u(Ht(e))}},children:[(0,G.jsxs)(`div`,{className:B(`grid gap-2`,e.fieldsClassName),children:[t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Tp,{"aria-label":`Server URL`,placeholder:`Server URL, e.g. http://127.0.0.1:47841`,spellCheck:!1,autoComplete:`off`,value:a,onChange:e=>o(e.target.value)}),(0,G.jsx)(Tp,{"aria-label":`Pairing code`,placeholder:`Pairing code, empty if auth is off`,spellCheck:!1,autoComplete:`off`,value:s,onChange:e=>c(e.target.value)})]}):(0,G.jsx)(Tp,{"aria-label":`Pairing link`,placeholder:`Pairing link`,spellCheck:!1,autoComplete:`off`,value:r,onChange:e=>i(e.target.value)}),l!==null&&(0,G.jsx)(`p`,{className:`text-destructive text-sm break-all`,children:l}),(0,G.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground w-fit cursor-pointer text-xs`,onClick:()=>{n(!t),u(null)},children:t?`Paste a pairing link instead`:`Enter the server URL and code separately`})]}),e.actions(t?a.trim()!==``:r.trim()!==``)]})}function DO(e){return(0,G.jsx)(oi,{open:!0,onOpenChange:()=>e.onClose(),children:(0,G.jsxs)($r,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,children:[(0,G.jsxs)(ei,{className:`gap-1 px-6 pt-4 pr-12`,children:[(0,G.jsx)(ri,{className:`text-base`,children:`Add machine`}),(0,G.jsx)(ii,{children:`Paste the pairing link that OffSite printed when it started.`})]}),(0,G.jsx)(EO,{fieldsClassName:`p-6`,onAdded:e.onClose,actions:t=>(0,G.jsxs)(si,{className:`bg-muted/40 border-t px-6 py-4`,children:[(0,G.jsx)(U,{type:`button`,variant:`outline`,onClick:e.onClose,children:`Cancel`}),(0,G.jsx)(U,{type:`submit`,disabled:!t,children:`Add machine`})]})})]})})}function OO(e){let t=e.machine,n=t.icon??`computer`,[r,i]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`flex min-h-13 items-center justify-between gap-4 px-4 py-2.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Icon`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(Df.includes(n)?Df:[n,...Df]).map(e=>(0,G.jsx)(U,{title:e,size:`icon-sm`,"aria-pressed":e===n,variant:e===n?`default`:`ghost`,onClick:()=>I(t.id,{icon:e}),children:(0,G.jsx)(Of,{icon:e})},e)),(0,G.jsxs)(ln,{open:r,onOpenChange:i,modal:!0,children:[(0,G.jsx)(Sn,{asChild:!0,children:(0,G.jsx)(U,{title:`More icons`,size:`icon-sm`,variant:`ghost`,children:(0,G.jsx)(H,{icon:wr})})}),(0,G.jsx)(sn,{align:`end`,collisionPadding:12,className:`flex max-h-96 w-80 flex-col gap-3 overflow-y-auto p-3`,children:(0,G.jsx)(kO,{machine:t.id,selected:n,onClose:()=>i(!1)})})]})]})]})}function kO(e){return(0,G.jsx)(G.Fragment,{children:[...new Set(Object.values(Ef).map(e=>e.group))].map(t=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}),(0,G.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(2rem,1fr))] gap-1`,children:Object.keys(Ef).filter(e=>Ef[e].group===t&&!Df.includes(e)).map(t=>(0,G.jsx)(U,{title:t,size:`icon-sm`,className:`aspect-square h-auto! w-full!`,"aria-pressed":t===e.selected,variant:t===e.selected?`default`:`ghost`,onClick:()=>{I(e.machine,{icon:t}),e.onClose()},children:(0,G.jsx)(Of,{icon:t,className:`block aspect-square! h-auto! w-[66%]! min-w-0! shrink-0!`})},t))})]},t))})}var AO={connecting:`Connecting…`,online:`Online`,offline:`Offline`,unpaired:`Needs pairing`};function jO(){let e=k(e=>e.machines),t=k(e=>e.machines.find(t=>t.id===e.settingsEditedMachine)),[n,r]=(0,W.useState)(!1),[a,o]=(0,W.useState)(null),s=a===null?e:[...e].sort((e,t)=>a.indexOf(e.id)-a.indexOf(t.id));return t===void 0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Nh,{title:`Machines`,note:`This browser connects to each one directly. The list stays in this browser`,children:(0,G.jsx)(TO,{as:`div`,axis:`y`,className:`divide-y`,values:s.map(e=>e.id),onReorder:o,children:s.map(e=>(0,G.jsxs)(NO,{value:e.id,disabled:!1,className:`min-h-13 gap-4`,onDragEnd:()=>{a!==null&&be(a),o(null)},children:[(0,G.jsx)(Of,{icon:e.icon,className:`text-muted-foreground size-5 shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),e.addresses.map(e=>(0,G.jsx)(`p`,{className:`text-muted-foreground truncate font-mono text-xs`,children:e},e)),e.providers.filter(e=>e.state===`error`).map(e=>(0,G.jsxs)(`p`,{className:`text-destructive truncate text-xs`,title:e.error??void 0,children:[rr[e.provider],` threads: `,e.error]},e.provider))]}),(0,G.jsxs)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:[AO[e.status],e.status===`online`&&e.via!==null&&e.via!==e.addresses[0]&&` · via ${new URL(e.via).host}`]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost`,title:`Reconnect, trying the first address first`,onClick:()=>ve(e.id),children:(0,G.jsx)(H,{icon:Bs})}),(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost-muted`,title:`Open machine`,onClick:()=>i({settingsEditedMachine:e.id}),children:(0,G.jsx)(H,{icon:kn})})]})]},e.id))})}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:(0,G.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>r(!0),children:`Add machine…`})}),n&&(0,G.jsx)(DO,{onClose:()=>r(!1)})]}):(0,G.jsx)(MO,{machine:t})}function MO(e){let t=e.machine,[n,r]=(0,W.useState)(!1),[a,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(null),f=u??t.addresses,p=t.addresses.some(e=>o!==null&&o.includes(e)),m=(0,W.useRef)(null);(0,W.useEffect)(()=>{n&&m.current?.focus()},[n]);function h(e){l(null);try{return I(t.id,{addresses:[...new Set(e.map(e=>ut(e).address))]}),!0}catch(e){return l(Ht(e)),!1}}async function g(e){l(null);let n=e.trim();if(n===``)return!0;try{let e=n.includes(`#`)?ut(n).code:n;if(e===null)throw Error(`That link has no pairing code`);return await me(t.id,e),!0}catch(e){return l(Ht(e)),!1}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Nh,{title:`Machine`,children:[(0,G.jsx)(Q,{label:`Name`,children:(0,G.jsx)(Ph,{value:t.label??``,placeholder:t.hostname,onCommit:e=>I(t.id,{label:e.trim()===``?null:e.trim()})},t.label)}),(0,G.jsx)(OO,{machine:t})]}),!p&&(0,G.jsx)(Nh,{title:`Pairing`,children:(0,G.jsxs)(`div`,{className:`flex min-h-13 items-center justify-between gap-4 px-4 py-2.5`,children:[t.pairedAt!==null&&t.status!==`unpaired`&&(0,G.jsx)(`span`,{className:`text-sm`,children:t.pairedAt===null?`Paired`:`Paired ${ar(t.pairedAt)}`}),(t.pairedAt===null||t.status===`unpaired`)&&(0,G.jsxs)(`form`,{className:`flex flex-1 items-center gap-3`,onSubmit:async e=>{e.preventDefault(),await g(a)&&s(``)},children:[(0,G.jsx)(Tp,{className:`flex-1 font-mono`,placeholder:`Pairing link or code`,spellCheck:!1,autoComplete:`off`,value:a,onChange:e=>s(e.target.value)}),(0,G.jsxs)(U,{type:`submit`,variant:`outline`,className:`px-4`,disabled:a.trim()===``,children:[(0,G.jsx)(H,{icon:bs}),`Pair`]})]})]})}),(0,G.jsxs)(Nh,{title:`Addresses`,note:`OffSite tries them in order whenever it reconnects`,children:[(0,G.jsx)(TO,{as:`div`,axis:`y`,className:`divide-y`,values:f,onReorder:d,children:f.map((e,t)=>(0,G.jsxs)(NO,{value:e,disabled:p,onDragEnd:()=>{u!==null&&h(u),d(null)},children:[(0,G.jsx)(Ph,{className:`flex-1 font-mono`,value:e,disabled:p,onCommit:e=>h(f.map((n,r)=>r===t?e:n))}),(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost`,title:`Remove address`,disabled:p||f.length===1,onClick:()=>h(f.filter((e,n)=>n!==t)),children:(0,G.jsx)(H,{icon:is})})]},e))}),n&&(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,G.jsx)(Tp,{ref:m,className:`font-mono`,placeholder:`http://192.168.1.10:47841`,spellCheck:!1,autoComplete:`off`,onBlur:e=>{let n=e.target.value.trim();(n===``||h([...t.addresses,n]))&&r(!1)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}),!n&&!p&&(0,G.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted/50 hover:text-foreground flex w-full items-center gap-2 px-4 py-3 text-sm transition-colors`,onClick:()=>r(!0),children:[(0,G.jsx)(H,{icon:Oo,className:`size-4`}),`Add address`]})]}),c!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-1 text-xs break-all`,children:c}),!p&&(0,G.jsxs)(mr,{children:[(0,G.jsx)(Or,{asChild:!0,children:(0,G.jsx)(U,{variant:`outline`,className:`text-destructive`,children:`Remove machine`})}),(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsxs)(Hn,{children:[`Remove `,t.name,`?`]}),(0,G.jsx)(Rn,{children:`This browser forgets the machine. The machine and its threads stay untouched.`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>{i({settingsEditedMachine:null}),ge(t.id)},children:`Remove machine`})]})]})]})]})}function NO(e){let t=$D();return(0,G.jsxs)(wO,{as:`div`,value:e.value,dragListener:!1,dragControls:t,onDragEnd:e.onDragEnd,className:B(`bg-background relative flex items-center gap-3 px-4 py-2.5`,e.className),children:[(0,G.jsx)(`span`,{className:B(`text-muted-foreground hover:text-foreground cursor-grab touch-none active:cursor-grabbing`,e.disabled&&`pointer-events-none opacity-50`),title:`Drag to reorder`,onPointerDown:e=>t.start(e),children:(0,G.jsx)(H,{icon:as,className:`size-4`})}),e.children]})}var PO=Fe.withTag(`notifications`),FO=new Map([[`denied`,`Blocked in the browser's site settings`],[`insecure`,`Needs https or localhost`],[`install`,`Add OffSite to the Home Screen first`],[`unsupported`,`Not supported in this browser`]]);function IO(e){let t=e.prefs.terminal,n=t.behavior;function r(r){Ye({...e.prefs,terminal:{...t,behavior:{...n,...r}}})}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Nh,{title:`Notifications`,children:[(0,G.jsx)(Q,{label:`Desktop notifications on this device`,children:(0,G.jsx)(LO,{})}),(0,G.jsx)(Q,{label:`Push terminal alerts when no OffSite page is open`,children:(0,G.jsx)(RO,{})})]}),(0,G.jsxs)(Nh,{title:`Terminal bell`,children:[(0,G.jsx)(Q,{label:`Flash the screen on bell`,children:(0,G.jsx)(Mh,{checked:n.bellFlash,onCheckedChange:e=>r({bellFlash:e})})}),(0,G.jsx)(Q,{label:`Play a sound on bell`,children:(0,G.jsx)(Mh,{checked:n.bellSound,onCheckedChange:e=>r({bellSound:e})})})]})]})}function LO(){let[e,t]=(0,W.useState)(Oa),[n,r]=(0,W.useState)(ka);(0,W.useEffect)(()=>{let e=Oa();if(e===`insecure`||e===`unsupported`)return;let n=new AbortController;return ja(n.signal,()=>t(Oa())).catch(e=>PO.error(`could not watch the notification permission`,e)),()=>n.abort()},[]);async function i(e){await Aa(e),r(e),t(Oa())}return(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[FO.has(e)&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:FO.get(e)}),(0,G.jsx)(Mh,{checked:e===`granted`&&n,disabled:e!==`granted`&&e!=="default",onCheckedChange:e=>void i(e)})]})}function RO(){let[e,t]=(0,W.useState)(za),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(()=>za()===`supported`),[o,s]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(za()!==`supported`)return;let e=!0;async function t(){try{let t=await Va();e&&r(t)}catch(e){PO.error(`could not read the push subscription`,e)}e&&a(!1)}return t(),()=>{e=!1}},[]);async function c(e){a(!0),s(null);try{e?r(await Ha()):(await Ua(),r(!1))}catch(e){PO.error(`could not change push notifications`,e),s(Ht(e))}t(za()),a(!1)}return(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o!==null&&(0,G.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Could not update: `,o]}),FO.has(e)&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:FO.get(e)}),(0,G.jsx)(Mh,{checked:e===`supported`&&n,disabled:e!==`supported`||i,onCheckedChange:e=>void c(e)})]})}function zO(e){let t=k(e=>e.projects),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[l,u]=zr(`sidebarScope`,null),d=t.filter(t=>t.machine===e.machine&&!t.scratch).sort((e,t)=>n===null?0:n.indexOf(e.id)-n.indexOf(t.id));return(0,G.jsxs)(G.Fragment,{children:[d.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground py-8 text-center text-sm`,children:`No projects yet`}),(0,G.jsx)(TO,{as:`div`,axis:`y`,values:d.map(e=>e.id),onReorder:r,children:d.map(t=>(0,G.jsxs)(NO,{value:t.id,disabled:!1,className:`min-h-13 px-1 outline-none`,onDragEnd:async()=>{if(n!==null){try{await fc(e.machine,n)}catch(e){c(e)}r(null)}},children:[(0,G.jsx)(mc,{machine:t.machine,projectId:t.id,className:`size-5 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,title:t.path,children:[(0,G.jsx)(`span`,{className:B(`block truncate text-sm`,t.hidden&&`text-muted-foreground`),children:t.name}),(0,G.jsx)(`span`,{className:`text-muted-foreground block truncate font-mono text-xs`,children:BO(t.path,e.homeDir)})]}),(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost-muted`,title:`Configure project`,"aria-label":`Configure ${t.name}`,onClick:()=>a(t),children:(0,G.jsx)(H,{icon:Us})}),(0,G.jsx)(Mh,{size:`sm`,checked:!t.hidden,onCheckedChange:e=>uc(t.machine,t.id,{hidden:!e}).catch(c),"aria-label":`Show ${t.name}`})]},t.id))}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:(0,G.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>s(!0),children:`Add project…`})}),o&&(0,G.jsx)(Am,{machine:e.machine,onClose:()=>s(!1),onAdd:()=>s(!1)}),i!==null&&(0,G.jsx)(Mm,{project:i,onClose:()=>a(null),onRemoved:()=>{l?.machine===i.machine&&l.projectId===i.id&&u(null),a(null)}})]})}function BO(e,t){return e===t?`~`:e.startsWith(`${t}/`)||e.startsWith(`${t}\\`)?`~${e.slice(t.length)}`:e}function VO(e){let t=e.account,[n,r]=(0,W.useState)(null);async function a(n){r(null);try{await L(e.machine,`accounts.update`,{id:t.id,name:t.name,color:t.color,configDir:t.configDir,enabled:t.enabled,...n})}catch(e){r(Ht(e))}}async function o(){r(null);try{await L(e.machine,`accounts.remove`,{id:t.id}),i({settingsAccount:null})}catch(e){r(Ht(e))}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Nh,{title:`Account`,children:[(0,G.jsx)(Q,{label:`Name`,children:(0,G.jsx)(Ph,{value:t.name,valid:e=>e.trim()!==``,onCommit:e=>void a({name:e})},t.name)}),(0,G.jsx)(Q,{label:`Color`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.color!==null&&(0,G.jsx)(`span`,{className:`size-5 shrink-0 rounded-full`,style:{backgroundColor:t.color}}),(0,G.jsx)(Ph,{className:`w-28 font-mono`,value:t.color??``,placeholder:`#3b82f6`,valid:e=>e===``||/^#[0-9a-f]{6}$/i.test(e),onCommit:e=>void a({color:e===``?null:e})},t.color??``)]})}),(0,G.jsx)(Q,{label:`Config directory`,children:(0,G.jsx)(Ph,{className:`w-72 font-mono`,value:t.configDir??``,placeholder:t.provider===`claude`?`~/.claude or empty for default`:`~/.codex or empty for default`,onCommit:e=>void a({configDir:e})},t.configDir??``)})]}),n!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-1 text-xs`,children:n}),(0,G.jsxs)(mr,{children:[(0,G.jsx)(Or,{asChild:!0,children:(0,G.jsx)(U,{variant:`outline`,className:`text-destructive`,children:`Remove account`})}),(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsxs)(Hn,{children:[`Remove `,t.name,`?`]}),(0,G.jsx)(Rn,{children:`OffSite stops using this account. Its config directory and sessions stay untouched.`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>void o(),children:`Remove account`})]})]})]})]})}function HO(e){let[t,n]=(0,W.useState)(``),[r,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null);async function u(){s(!0),l(null);try{await L(e.machine,`accounts.add`,{provider:e.provider,name:t,configDir:r}),i({settingsAccount:null})}catch(e){l(Ht(e)),s(!1)}}return(0,G.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault(),u()},children:[(0,G.jsxs)(Nh,{title:`Account`,children:[(0,G.jsx)(Q,{label:`Name`,children:(0,G.jsx)(Tp,{className:`w-56`,value:t,onChange:e=>n(e.target.value),placeholder:`Work`})}),(0,G.jsx)(Q,{label:`Config directory`,children:(0,G.jsx)(Tp,{className:`w-72 font-mono`,value:r,onChange:e=>a(e.target.value),placeholder:e.provider===`claude`?`~/.claude or empty for default`:`~/.codex or empty for default`})})]}),c!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-1 text-xs`,children:c}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(U,{type:`button`,variant:`ghost`,onClick:()=>i({settingsAccount:null}),children:`Cancel`}),(0,G.jsx)(U,{type:`submit`,disabled:o||t.trim()===``,children:`Add account`})]})]})}function UO(e){let t=e.config,n=t.enabledProviders[e.provider],r=e.provider===`claude`?e.claudeAccounts:e.provider===`codex`?e.codexAccounts:[],i=r.find(e=>e.valid),a=t.claudeBaseDir[e.platform]??e.defaultClaudeBaseDir;if(e.selected===`new`){if(e.provider===`opencode`)throw Error(`OpenCode accounts cannot be added`);return(0,G.jsx)(HO,{machine:e.machine,provider:e.provider})}if(e.selected!==null){let t=r.find(t=>t.id===e.selected);return t===void 0?(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This account no longer exists.`}):(0,G.jsx)(VO,{machine:e.machine,account:t})}return(0,G.jsxs)(G.Fragment,{children:[e.provider===`claude`&&(0,G.jsx)(`div`,{className:`divide-y overflow-hidden rounded-xl border`,children:(0,G.jsx)(Q,{label:`Base directory`,children:(0,G.jsx)(Ph,{className:`w-72 font-mono`,value:a,valid:e=>e.trim()!==``,onCommit:n=>po(e.machine,{...t,claudeBaseDir:{...t.claudeBaseDir,[e.platform]:n}})},a)})}),(0,G.jsxs)(`div`,{className:B(`space-y-5 transition-opacity`,!n&&`opacity-50`),children:[e.provider!==`opencode`&&(0,G.jsx)(Nh,{title:`Accounts`,children:(0,G.jsx)(GO,{machine:e.machine,accounts:r})}),n&&e.provider===`opencode`&&e.openCode.available&&(0,G.jsx)(WO,{machine:e.machine,config:t,provider:e.provider,accountId:null}),n&&e.provider!==`opencode`&&i!==void 0&&(0,G.jsx)(WO,{machine:e.machine,config:t,provider:e.provider,accountId:i.id})]})]})}function WO(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null),a=e.config.models[e.provider],o=t===null?null:t.models;(0,W.useEffect)(()=>{let t=!0;return n(null),i(null),L(e.machine,`capabilities`,{provider:e.provider,accountId:e.accountId,projectId:null}).then(e=>{t&&n(e)},e=>{t&&i(Ht(e))}),()=>{t=!1}},[e.machine,e.provider,e.accountId]);function s(t,n){po(e.machine,{...e.config,models:{...e.config.models,[e.provider]:{...a,[t]:n}}})}return(0,G.jsxs)(Nh,{title:`Models`,children:[r!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:r}),r===null&&o===null&&(0,G.jsx)(`p`,{className:`text-muted-foreground px-4 py-3 text-xs`,children:`Loading…`}),(o??[]).map(t=>{let n=a[t.value]??{hidden:t.deprecated,effort:t.effort};return(0,G.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-4 py-1.5`,children:[(0,G.jsxs)(`div`,{className:B(`min-w-0 flex-1 truncate text-sm`,n.hidden&&`text-muted-foreground`),children:[t.name,e.provider===`opencode`&&(0,G.jsx)(`span`,{className:`text-muted-foreground ml-2 text-xs`,children:t.description})]}),t.efforts.length>0&&(0,G.jsxs)(fh,{value:n.effort??t.effort??void 0,onValueChange:e=>s(t.value,{...n,effort:e}),children:[(0,G.jsx)(mh,{size:`sm`,className:`w-28`,children:(0,G.jsx)(ph,{placeholder:`Effort`})}),(0,G.jsx)(hh,{children:t.efforts.map(e=>(0,G.jsx)(gh,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,G.jsx)(Mh,{size:`sm`,checked:!n.hidden,onCheckedChange:e=>s(t.value,{...n,hidden:!e}),"aria-label":`Show ${t.name}`})]},t.value)})]})}function GO(e){let[t,n]=(0,W.useState)(!1),[r,a]=(0,W.useState)(null);async function o(e){n(!0),a(null);try{await e()}catch(e){a(Ht(e))}finally{n(!1)}}return(0,G.jsxs)(G.Fragment,{children:[e.accounts.map(n=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:B(`min-w-0 flex-1`,!n.enabled&&`opacity-50`),children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:B(`size-2 shrink-0 rounded-full`,!n.enabled&&`bg-muted-foreground/40`,n.enabled&&n.error!==null&&`bg-destructive`,n.enabled&&n.error===null&&!n.linked&&`bg-warning`,n.enabled&&n.error===null&&n.linked&&`bg-success`)}),(0,G.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n.name}),n.plan!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:n.plan})]}),n.error!==null&&(0,G.jsx)(`p`,{className:`text-destructive mt-1 truncate pl-4 text-xs`,children:n.error}),n.error===null&&!n.linked&&(0,G.jsx)(`p`,{className:`text-warning mt-1 truncate pl-4 text-xs`,children:`Not linked to shared threads · hidden in the composer`}),n.error===null&&n.linked&&(0,G.jsx)(KO,{machine:e.machine,account:n})]}),(0,G.jsx)(Mh,{size:`sm`,checked:n.enabled,disabled:t,onCheckedChange:t=>void o(()=>L(e.machine,`accounts.update`,{id:n.id,name:n.name,color:n.color,configDir:n.configDir,enabled:t})),"aria-label":`Enable ${n.name}`}),(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost-muted`,title:`Open account`,onClick:()=>i({settingsAccount:n.id}),children:(0,G.jsx)(H,{icon:kn})})]},n.id)),(0,G.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted/50 hover:text-foreground flex w-full items-center gap-2 px-4 py-3 text-sm transition-colors`,onClick:()=>i({settingsAccount:`new`}),children:[(0,G.jsx)(H,{icon:Oo,className:`size-4`}),`Add account`]}),r!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:r})]})}function KO(e){let t=ro(e.machine,e.account);return t===void 0||t.limits.length===0?null:(0,G.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-5 gap-y-1.5 pl-4`,children:t.limits.map(e=>(0,G.jsx)(qO,{limit:e},e.window))})}function qO(e){let t=e.limit,n=t.rejected?100:t.utilization===null?null:Math.min(100,Math.round(t.utilization*100));return n===null?null:(0,G.jsx)(Xr,{label:t.resetsAt===null?`Reset time unknown`:`Resets ${ar(t.resetsAt*1e3)}`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:Xm(t)}),(0,G.jsx)(`div`,{className:`bg-foreground/10 h-1 w-16 overflow-hidden rounded-full`,children:(0,G.jsx)(`div`,{className:B(`h-full rounded-full`,t.rejected&&`bg-destructive`,!t.rejected&&n>=80&&`bg-warning`,!t.rejected&&n<80&&`bg-foreground/50`),style:{width:`${n}%`}})}),(0,G.jsxs)(`span`,{className:B(`tabular-nums`,t.rejected&&`text-destructive`,!t.rejected&&`text-muted-foreground`),children:[n,`%`]})]})})}var JO=zt?`⌘`:`Ctrl+Shift`,YO=[[`Enter`,`Send, or queue or steer while the agent works`],[`${z}+Enter`,`Send the other way while the agent works`],[`Shift+Enter`,`New line`],[`↑`,`Recall your last message`],[`Esc`,`Stop the agent`],[`/`,`Slash commands`],[`@`,`Mention a file`],[`${z}+S`,`Stash the prompt, or bring back the last stash`],[`${z}+Shift+V`,`Paste long text inline instead of as a file`],[`${z}+Shift+D`,`Start or stop dictation`],[`${z}+. or ${z}+Shift+M`,`Choose the model`],[`${z}+/ or ${z}+Shift+E`,`Choose the effort`],[`${z}+P`,`Choose the project, or the sidebar scope`],[`${z}+;`,`Choose the project of a new thread`],[`${z}+F`,`Find in the thread`],[`${z}+K or ${z}+Shift+P`,`Search sessions and actions`],[`${z}+,`,`Open settings`],[`${z}+1…9`,`Open a session from the sidebar`],[`${z}+N or ${z}+T`,`New thread`],[zt?"⌘+` or Ctrl+`":"Ctrl+`",`Toggle the terminal`],[`${z}+B or ${z}+Shift+J`,`Toggle the sidebar`],[`${z}+J or ${z}+Shift+B`,`Toggle the right panel`],[`${z}+E`,`Toggle the editor`],[`${JO}+T`,`New terminal tab, in the terminal`],[`${JO}+W`,`Close the terminal tab`],[`${JO}+F`,`Find in the terminal`],[`Ctrl+Tab`,`Next terminal tab`],[`Ctrl+Shift+Tab`,`Previous terminal tab`]];function XO(){return(0,G.jsx)(Nh,{title:`Keyboard shortcuts`,children:YO.map(([e,t])=>(0,G.jsx)(Q,{label:t,children:(0,G.jsx)(`kbd`,{className:`bg-muted text-muted-foreground rounded px-1.5 py-0.5 font-sans text-xs`,children:e})},e))})}var ZO=Fe.withTag(`terminal`),QO=1048576;function $O(e){window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{ZO.warn(`could not copy to the clipboard`,e),ca(`Could not copy to the clipboard`)}):ZO.warn(`copy from the terminal needs https or localhost`)}async function ek(e){if(!window.isSecureContext){ZO.warn(`programs can read the clipboard only over https or localhost`),ca(`Programs can read the clipboard only over https or localhost`);return}let t;try{t=await navigator.clipboard.readText()}catch(e){ZO.warn(`could not read the clipboard`,e),ca(`Could not read the clipboard`);return}new TextEncoder().encode(t).length>QO?(ZO.warn(`the clipboard is over 1 MiB, not replying`),ca(`The clipboard is too large to share (over 1 MiB)`)):e(t)}var tk={macos:{label:`Ctrl+V`,ctrl:!0,alt:!1,data:``},linux:{label:`Ctrl+V`,ctrl:!0,alt:!1,data:``},windows:{label:`Alt+V`,ctrl:!1,alt:!0,data:`\x1Bv`}};function nk(e,t){let n=tk[t];return e.key.toLowerCase()===`v`&&e.ctrlKey===n.ctrl&&e.altKey===n.alt&&!e.shiftKey&&!e.metaKey}async function rk(e,t){let n=[];for(let e of await navigator.clipboard.read()){let t=e.types.find(e=>e.startsWith(`image/`));t&&n.push(await e.getType(t))}return n.length===0?(ca(`No image in the clipboard`),!1):(await ik(e,t,n),!0)}async function ik(e,t,n){let r=[];for(let t of n){let n=await L(e,`terminal.paste`,{type:t.type,data:await Af(t)});r.push(/\s/.test(n)?`"${n}"`:n)}t.paste(r.join(` `))}function ak(e){ZO.error(`could not paste image`,e),ca(`Could not paste the image`)}function ok(e){let t=e.prefs.terminal,[n,r]=(0,W.useState)(!zh.some(e=>e.family===t.font.family));function i(t){Ye({...e.prefs,terminal:t})}function a(e,n){i({...t,[e]:{...t[e],...n}})}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Nh,{title:`Font`,children:[(0,G.jsx)(Q,{label:`Family`,children:(0,G.jsxs)(fh,{value:n?`custom`:t.font.family,onValueChange:e=>{r(e===`custom`),e!==`custom`&&a(`font`,{family:e})},children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[zh.map(e=>(0,G.jsx)(gh,{value:e.family,children:e.label},e.family)),(0,G.jsx)(gh,{value:`custom`,children:`Custom`})]})]})}),n&&(0,G.jsx)(Q,{label:`Custom family`,children:(0,G.jsx)(Ph,{placeholder:`Installed font name`,value:t.font.family,onCommit:e=>a(`font`,{family:e})})}),(0,G.jsx)(Q,{label:`Size`,children:(0,G.jsx)(Fh,{value:t.font.size,step:.5,onCommit:e=>a(`font`,{size:e})})}),(0,G.jsx)(Q,{label:`Line height`,children:(0,G.jsx)(Fh,{value:t.font.lineHeight,step:.05,onCommit:e=>a(`font`,{lineHeight:e})})}),(0,G.jsx)(Q,{label:`Ligatures`,children:(0,G.jsx)(Mh,{checked:t.font.ligatures,onCheckedChange:e=>a(`font`,{ligatures:e})})}),(0,G.jsx)(Q,{label:`Bold text in bright colors`,children:(0,G.jsx)(Mh,{checked:t.boldIsBright,onCheckedChange:e=>i({...t,boldIsBright:e})})})]}),(0,G.jsxs)(Nh,{title:`Cursor`,children:[(0,G.jsx)(Q,{label:`Style`,children:(0,G.jsxs)(fh,{value:t.cursor.style,onValueChange:e=>a(`cursor`,{style:e}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`block`,children:`Block`}),(0,G.jsx)(gh,{value:`bar`,children:`Bar`}),(0,G.jsx)(gh,{value:`underline`,children:`Underline`})]})]})}),(0,G.jsx)(Q,{label:`Blink`,children:(0,G.jsx)(Mh,{checked:t.cursor.blink,onCheckedChange:e=>a(`cursor`,{blink:e})})})]}),(0,G.jsx)(sk,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,G.jsx)(ck,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,G.jsx)(lk,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,G.jsxs)(Nh,{title:`Layout`,children:[[`top`,`right`,`bottom`,`left`].map(e=>(0,G.jsx)(Q,{label:`Padding ${e}`,children:(0,G.jsx)(Fh,{value:t.padding[e],onCommit:t=>a(`padding`,{[e]:t})})},e)),(0,G.jsx)(Q,{label:`Scrollback lines`,children:(0,G.jsx)(Fh,{value:t.scrollback,step:1e3,onCommit:e=>i({...t,scrollback:e})})})]})]})}function sk(e){return(0,G.jsxs)(Nh,{title:`Behavior`,children:[(0,G.jsx)(Q,{label:`Modernize Shift+Enter`,children:(0,G.jsx)(Mh,{checked:e.behavior.modernizeShiftEnter,onCheckedChange:t=>e.onChange({modernizeShiftEnter:t})})}),(0,G.jsx)(Q,{label:`${tk.linux.label} (${tk.windows.label} on Windows machines) pastes images from the browser clipboard`,children:(0,G.jsx)(Mh,{checked:e.behavior.pasteBrowserImages,onCheckedChange:t=>e.onChange({pasteBrowserImages:t})})}),(0,G.jsx)(Q,{label:`Capture browser shortcuts`,children:(0,G.jsx)(Mh,{checked:e.behavior.captureShortcuts,onCheckedChange:t=>e.onChange({captureShortcuts:t})})}),(0,G.jsx)(Q,{label:`Click moves the cursor in the command line`,children:(0,G.jsx)(Mh,{checked:e.behavior.clickToMoveCursor,onCheckedChange:t=>e.onChange({clickToMoveCursor:t})})}),(0,G.jsx)(Q,{label:`Ask before closing a tab that is running a program`,children:(0,G.jsx)(Mh,{checked:e.behavior.confirmCloseBusyTab,onCheckedChange:t=>e.onChange({confirmCloseBusyTab:t})})})]})}function ck(e){return zt?(0,G.jsx)(Nh,{title:`Mac keys`,note:`Meta keeps that Option key from typing @, | and other symbols. Safari and Firefox use US key positions`,children:(0,G.jsx)(Q,{label:`Use Option as Meta`,children:(0,G.jsxs)(fh,{value:e.behavior.optionAsMeta,onValueChange:t=>e.onChange({optionAsMeta:t}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`off`,children:`Off`}),(0,G.jsx)(gh,{value:`left`,children:`Left Option`}),(0,G.jsx)(gh,{value:`right`,children:`Right Option`}),(0,G.jsx)(gh,{value:`both`,children:`Both Options`})]})]})})}):null}function lk(e){return Lt?(0,G.jsx)(Nh,{title:`Windows keys`,note:`Ctrl+C sends an interrupt when nothing is selected. Ctrl+Shift+C and Ctrl+Shift+V always copy and paste`,children:(0,G.jsx)(Q,{label:`Ctrl+C copies the selection and Ctrl+V pastes`,children:(0,G.jsx)(Mh,{checked:e.behavior.windowsCopyPaste,onCheckedChange:t=>e.onChange({windowsCopyPaste:t})})})}):null}var uk=[`General`,`Editor`,`Terminal`,`Notifications`,`Shortcuts`,`Machines`],dk=[`Machine`,`Projects`,`Dictation`,`Claude`,`Codex`,`OpenCode`];function fk(){let e=k(e=>e.machines),t=k(e=>e.settingsMachine===null?null:Ge(e,e.settingsMachine)),n=k(e=>e.settingsPage),r=vk(n),i=k(e=>r===null?null:e.settingsAccount),a=k(e=>n===`Machines`?e.machines.find(t=>t.id===e.settingsEditedMachine)??null:null);return{machines:e,machine:t,config:t===null?null:t.config,system:t===null?null:t.system,page:n,provider:r,account:i,editedMachine:a,subpage:i!==null||a!==null,subpageTitle:i===`new`?`New account`:i===null?a?.name:[...t?.claudeAccounts??[],...t?.codexAccounts??[]].find(e=>e.id===i)?.name}}function pk(){let e=k(e=>e.settingsOpen);return vr(`mod+comma`,()=>p(!e),{enableOnFormTags:!0,preventDefault:!0}),(0,G.jsx)(oi,{open:e,onOpenChange:p,children:(0,G.jsx)($r,{showCloseButton:!1,"aria-describedby":void 0,className:`flex h-[min(44rem,calc(100dvh-2rem))] flex-col gap-0 overflow-hidden p-0 sm:max-w-4xl sm:flex-row`,children:(0,G.jsx)(mk,{})})})}function mk(){let e=fk(),t=e.page,n=e.machine;function r(e){return(0,G.jsx)(`button`,{className:B(`text-muted-foreground hover:bg-accent hover:text-foreground flex h-9 flex-none items-center rounded-md px-2 text-sm transition-colors`,e===t&&`bg-accent text-foreground`),onClick:()=>d(e),children:(0,G.jsx)(hk,{page:e})},e)}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`nav`,{className:`flex flex-none gap-1 overflow-x-auto border-b p-3 sm:w-48 sm:flex-col sm:border-r sm:border-b-0`,children:[(0,G.jsx)(ri,{className:`hidden px-2 pt-1 pb-3 text-base font-semibold sm:block`,children:`Settings`}),uk.map(r),(0,G.jsxs)(`div`,{className:`flex flex-none items-center gap-1 sm:mt-6 sm:flex-col sm:items-stretch`,children:[n!==null&&e.machines.length>1&&(0,G.jsxs)(fh,{value:n.id,onValueChange:e=>i({settingsMachine:e,settingsAccount:null}),children:[(0,G.jsx)(mh,{className:`mb-1 w-40 sm:w-full`,children:(0,G.jsx)(ph,{})}),(0,G.jsx)(hh,{children:e.machines.map(e=>(0,G.jsxs)(gh,{value:e.id,children:[(0,G.jsx)(Of,{icon:e.icon}),e.name]},e.id))})]}),n!==null&&e.machines.length===1&&(0,G.jsxs)(`p`,{className:`text-muted-foreground flex h-9 items-center gap-1.5 px-2 text-xs font-medium [&_svg]:size-4`,children:[(0,G.jsx)(Of,{icon:n.icon}),(0,G.jsx)(`span`,{className:`truncate`,children:n.name})]}),dk.map(r)]})]}),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pt-4 pb-7`,children:[(0,G.jsxs)(`div`,{className:`mb-5 flex h-9 items-center`,children:[e.subpage&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground text-xl font-semibold tracking-tight transition-colors`,onClick:()=>i({settingsAccount:null,settingsEditedMachine:null}),children:t}),(0,G.jsx)(H,{icon:kn,className:`text-muted-foreground mx-1.5 size-5`}),(0,G.jsx)(`h2`,{className:`truncate text-xl font-semibold tracking-tight`,children:e.subpageTitle})]}),!e.subpage&&(0,G.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:t===`Machine`?`General`:t}),(0,G.jsx)(gk,{view:e,className:`ml-3`}),(0,G.jsx)(ni,{asChild:!0,children:(0,G.jsx)(U,{variant:`ghost`,size:`icon`,className:`-mr-2 ml-auto`,"aria-label":`Close settings`,children:(0,G.jsx)(H,{icon:Go})})})]}),(0,G.jsx)(_k,{view:e})]})]})}function hk(e){let t=vk(e.page);return(0,G.jsxs)(G.Fragment,{children:[t!==null&&(0,G.jsx)(`span`,{className:`mr-2.5 flex size-4 items-center justify-center`,children:(0,G.jsx)(gc,{provider:t,className:B(t===`claude`&&`size-4`,t===`codex`&&`size-[19px] shrink-0`,t===`opencode`&&`h-3.5`)})}),e.page===`Machine`?`General`:e.page]})}function gk(e){let t=e.view.machine,n=e.view.config,r=e.view.provider;return r===null||e.view.account!==null||t===null||n===null?null:(0,G.jsx)(Mh,{className:e.className,checked:n.enabledProviders[r],onCheckedChange:e=>void po(t.id,{...n,enabledProviders:{...n.enabledProviders,[r]:e}}),"aria-label":`Enable ${e.view.page}`})}function _k(e){let t=k(e=>e.prefs),n=e.view.page,r=e.view.machine,i=e.view.config,a=e.view.system,o=dk.includes(n),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(0);return(0,G.jsxs)(G.Fragment,{children:[o&&r!==null&&r.configError!==null&&(0,G.jsxs)(`p`,{className:`text-destructive mb-5 text-sm whitespace-pre-wrap`,children:[`Not saved: `,r.configError]}),(0,G.jsxs)(`div`,{className:`w-full space-y-5`,children:[n===`General`&&(0,G.jsx)(qh,{prefs:t,onRestore:()=>c(`browser`)}),n===`Machine`&&r!==null&&i!==null&&a!==null&&(0,G.jsx)(fg,{machine:r.id,config:i,platform:a.platform,defaultShell:a.defaultShell,claudeAccounts:r.claudeAccounts,codexAccounts:r.codexAccounts,openCode:r.openCode,onRestore:()=>c(`machine`)}),n===`Dictation`&&r!==null&&i!==null&&(0,G.jsx)(Ih,{machine:r.id,config:i}),n===`Projects`&&r!==null&&a!==null&&(0,G.jsx)(zO,{machine:r.id,homeDir:a.homeDir}),o&&r===null&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Add a machine to see its settings.`}),o&&r!==null&&(i===null||a===null)&&(0,G.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[r.name,` is not connected. Its settings show up once it is.`]}),n===`Editor`&&(0,G.jsx)(Wh,{prefs:t}),n===`Terminal`&&(0,G.jsx)(ok,{prefs:t}),n===`Notifications`&&(0,G.jsx)(IO,{prefs:t}),e.view.provider!==null&&r!==null&&i!==null&&a!==null&&(0,G.jsx)(UO,{machine:r.id,config:i,platform:a.platform,defaultClaudeBaseDir:a.defaultClaudeBaseDir,provider:e.view.provider,claudeAccounts:r.claudeAccounts,codexAccounts:r.codexAccounts,openCode:r.openCode,selected:e.view.account},e.view.provider),n===`Machines`&&(0,G.jsx)(jO,{}),n===`Shortcuts`&&(0,G.jsx)(XO,{})]},l),(0,G.jsx)(mr,{open:s!==null,onOpenChange:e=>{e||c(null)},children:(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:s===`browser`?`Restore browser defaults?`:`Restore machine defaults?`}),(0,G.jsx)(Rn,{children:s===`browser`?`All settings of this browser go back to their defaults.`:`All settings of ${r?.name} go back to their defaults.`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>{if(u(l+1),s===`browser`)Ye(x);else{if(r===null||i===null||a===null)throw Error(`Restoring machine defaults needs a connected machine`);po(r.id,{...a.defaults,claudeAccounts:i.claudeAccounts,codexAccounts:i.codexAccounts})}},children:`Restore defaults`})]})]})})]})}function vk(e){return e===`Claude`?`claude`:e===`Codex`?`codex`:e===`OpenCode`?`opencode`:null}function yk(){let e=k(e=>e.settingsOpen);return(0,G.jsx)(ai,{open:e,onOpenChange:p,children:(0,G.jsx)(li,{children:(0,G.jsx)(ti,{"aria-describedby":void 0,className:`bg-background text-foreground data-open:animate-in data-open:slide-in-from-right fixed inset-0 z-50 flex flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] text-sm duration-200 outline-none [--workspace-topbar-height:44px] motion-reduce:animate-none`,children:(0,G.jsx)(bk,{})})})})}function bk(){let e=k(e=>e.settingsListing),t=fk(),n=t.machine;M(!0,r);function r(){e?p(!1):t.subpage?i({settingsAccount:null,settingsEditedMachine:null}):i({settingsListing:!0})}function a(e){return(0,G.jsxs)(`button`,{className:`active:bg-accent flex min-h-12 w-full items-center px-4 text-left text-sm font-medium`,onClick:()=>d(e),children:[(0,G.jsx)(hk,{page:e}),(0,G.jsx)(H,{icon:kn,className:`text-muted-foreground ml-auto size-4`})]},e)}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`header`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-1.5 pr-3 pl-1`,children:[(0,G.jsx)(U,{variant:`ghost`,size:`icon`,"aria-label":`Back`,onClick:r,children:(0,G.jsx)(H,{icon:Br,className:`text-foreground size-5`,strokeWidth:2})}),(0,G.jsxs)(di,{className:`min-w-0 flex-1 truncate font-medium`,children:[e&&`Settings`,!e&&t.subpage&&t.subpageTitle,!e&&!t.subpage&&t.page]}),!e&&(0,G.jsx)(gk,{view:t,className:`shrink-0`})]}),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pt-2 pb-6`,children:[e&&(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsx)(Nh,{title:`This browser`,children:uk.map(a)}),(0,G.jsxs)(Nh,{title:`Machine`,children:[n!==null&&(0,G.jsxs)(Q,{label:`Machine`,children:[t.machines.length>1&&(0,G.jsxs)(fh,{value:n.id,onValueChange:e=>i({settingsMachine:e,settingsAccount:null}),children:[(0,G.jsx)(mh,{className:`w-40`,children:(0,G.jsx)(ph,{})}),(0,G.jsx)(hh,{children:t.machines.map(e=>(0,G.jsxs)(gh,{value:e.id,children:[(0,G.jsx)(Of,{icon:e.icon}),e.name]},e.id))})]}),t.machines.length===1&&(0,G.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1.5 text-sm [&_svg]:size-4`,children:[(0,G.jsx)(Of,{icon:n.icon}),n.name]})]}),dk.map(a)]})]}),!e&&(0,G.jsx)(_k,{view:t})]})]})}function xk(){return(0,G.jsx)(`div`,{className:`grid flex-1 place-items-center p-6`,children:(0,G.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,G.jsx)(`h1`,{className:`text-foreground text-center text-2xl font-normal tracking-tight sm:text-3xl`,children:`Connect a machine`}),(0,G.jsx)(`p`,{className:`text-muted-foreground mt-2 text-center text-sm`,children:`Run this on the computer you want to use, then open the pairing link it prints.`}),(0,G.jsx)(`pre`,{className:`bg-muted text-foreground mt-5 rounded-lg px-4 py-3 font-mono text-sm select-all`,children:`npx offsite serve`}),(0,G.jsx)(`p`,{className:`text-muted-foreground mt-8 mb-3 text-sm`,children:`Or connect it here.`}),(0,G.jsx)(EO,{actions:e=>(0,G.jsx)(U,{type:`submit`,className:`mt-4`,disabled:!e,children:`Connect`})})]})})}var Sk=[`messages`,`steps`,`details`,`full`],Ck={messages:`Messages`,steps:`Steps`,details:`Details`,full:`Everything`},wk=[{label:`Messages, plans and answers`,how:{messages:`Full text`,steps:`Full text`,details:`Full text`,full:`Full text`}},{label:`Commands`,how:{messages:null,steps:`One line each`,details:`Full command`,full:`Command and output`}},{label:`File edits`,how:{messages:null,steps:`File path`,details:`Path and diff`,full:`Diff and output`}},{label:`Tools, skills and web searches`,how:{messages:null,steps:`Name only`,details:`Inputs and search results`,full:`Inputs and outputs`}},{label:`Subagents and notices`,how:{messages:null,steps:`One line each`,details:`With compaction summaries`,full:`With compaction summaries`}},{label:`Thinking`,how:{messages:null,steps:null,details:`Full text`,full:`Full text`}},{label:`Todo lists`,how:{messages:null,steps:null,details:`Every step`,full:`Every step`}}];function Tk(e){let t=e.session,n=nn(),[r,i]=(0,W.useState)(`steps`),[a,o]=(0,W.useState)(null);(0,W.useEffect)(()=>{L(t.machine,`sessions.export`,{sessionId:t.id,projectId:t.projectId}).then(o).catch(e=>{c(e),Et(null)})},[t.machine,t.id,t.projectId]);function s(e){let n=t.title.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);wn(new Blob([e],{type:`text/markdown;charset=utf-8`}),`${n===``?`chat`:n}.md`),Et(null)}return(0,G.jsx)(oi,{open:!0,onOpenChange:()=>Et(null),children:(0,G.jsxs)($r,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,"aria-describedby":void 0,children:[(0,G.jsx)(ei,{className:`gap-1 px-6 pt-4 pr-12`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ri,{className:`text-base`,children:`Export to Markdown`}),a!==null&&a.context!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground rounded-full border px-2 py-0.5 text-xs tabular-nums`,children:Cn(a.context.tokens)})]})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-6 pt-5 pb-6`,children:[(0,G.jsxs)(mu,{className:`relative flex h-5 w-full touch-none items-center select-none`,min:0,max:Sk.length-1,step:1,value:[Sk.indexOf(r)],onValueChange:e=>i(Sk[e[0]]),children:[(0,G.jsx)(xu,{className:`bg-muted relative h-1.5 grow overflow-hidden rounded-full`,children:(0,G.jsx)(Cu,{className:`bg-primary absolute h-full`})}),(0,G.jsx)(Au,{"aria-label":`Detail`,className:`border-primary bg-background ring-ring/50 block size-4 rounded-full border-2 shadow-sm transition-shadow hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden`})]}),(0,G.jsx)(`div`,{className:`relative h-8 text-xs`,children:Sk.map((e,t)=>(0,G.jsxs)(`button`,{type:`button`,className:B(`text-muted-foreground hover:text-foreground absolute top-0 flex cursor-pointer flex-col`,t===0&&`left-0 items-start`,t>0&&t<Sk.length-1&&`-translate-x-1/2 items-center`,t===Sk.length-1&&`right-0 items-end`,e===r&&`text-foreground font-medium`),style:t>0&&t<Sk.length-1?{left:`calc(8px + (100% - 16px) * ${t/(Sk.length-1)})`}:void 0,onClick:()=>i(e),children:[(0,G.jsx)(`span`,{children:Ck[e]}),(0,G.jsx)(`span`,{className:`text-muted-foreground/70 font-normal tabular-nums`,children:a===null?`…`:`~${Cn(Ek(a.markdown[e]))}`})]},e))}),(0,G.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1.5`,children:wk.map(e=>(0,G.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(H,{icon:e.how[r]===null?Gr:nr,className:B(`size-4 shrink-0`,e.how[r]===null&&`text-muted-foreground/50`,e.how[r]!==null&&`text-primary`),strokeWidth:2}),(0,G.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate`,e.how[r]===null&&`text-muted-foreground/60`,e.how[r]!==null&&`text-foreground`),children:e.label}),(0,G.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e.how[r]??`Not included`})]},e.label))})]}),(0,G.jsxs)(si,{className:`bg-muted/40 border-t px-6 py-4 sm:justify-between`,children:[(0,G.jsx)(U,{type:`button`,variant:`ghost`,onClick:()=>Et(null),children:`Cancel`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(U,{type:`button`,variant:`outline`,disabled:a===null||n.copied,onClick:()=>{a!==null&&n.copy(a.markdown[r])},children:[(0,G.jsx)(H,{icon:n.copied?Un:Qn}),n.copied?`Copied`:`Copy`]}),(0,G.jsxs)(U,{type:`button`,disabled:a===null,onClick:()=>{a!==null&&s(a.markdown[r])},children:[(0,G.jsx)(H,{icon:er}),`Export`]})]})]})]})})}function Ek(e){return Math.round(e.length/4)}var Dk=.5,Ok=.8,kk=.6,Ak=.45,jk=.3,Mk=.25,Nk=.25,Pk=4,Fk=new Set([`a`,`an`,`and`,`for`,`in`,`of`,`on`,`the`,`to`,`with`]),Ik=/[\p{L}\p{N}]/u,Lk=/\p{Ll}/u,Rk=/\p{Lu}/u,zk=/\p{N}/u,Bk=/\p{L}/u;function Vk(e){return e.replace(/[\u0080-]/g,e=>{let t=e.normalize(`NFKD`).replace(/\p{M}/gu,``).toLowerCase();return t.length===1?t:e}).toLowerCase()}function Hk(e){let t=/^"([^"]+)"$/.exec(e.trim())?.[1].trim();return t===void 0||t===``?null:t}function Uk(e){let t=Hk(e);return t===null?Vk(e).replace(/^["'`]+|["'`]+$/g,``).split(/\s+/).filter(Boolean):[Vk(t)]}function Wk(e){return Uk(e).some(e=>e.length>=3)}function Gk(e,t){let n=e[t],r=e[t-1]??``,i=e[t+1]??``;return Ik.test(n)&&(r===``||!Ik.test(r)||Lk.test(r)&&Rk.test(n)||Rk.test(r)&&Rk.test(n)&&Lk.test(i)||zk.test(r)!==zk.test(n))}function Kk(e,t){return t>=e.length||!Ik.test(e[t])||Gk(e,t)}function qk(e,t){let n=t+1;for(;n<e.length&&Ik.test(e[n])&&!Gk(e,n);)n+=1;return n}function Jk(e){return Array.from({length:e.length},(e,t)=>t).filter(t=>Gk(e,t))}function Yk(e,t,n){let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];)r+=1;let i=e.slice(r),a=t.slice(r),o=i.length>1&&i[0]===a[1]&&i[1]===a[0]&&i.slice(2)===a.slice(2);return n?o:o||i===a||i.slice(1)===a.slice(1)||i.slice(1)===a||i===a.slice(1)}function Xk(e,t,n){for(let r of Jk(e)){if(t[r]!==n[0])continue;let i=[],a=r,o=n;for(;o!==``&&a<t.length;){let n=qk(e,a);if(o.length<=n-a&&t.startsWith(o,a))i.push({start:a,end:a+o.length}),o=``;else if(o.startsWith(t.slice(a,n)))for(i.push({start:a,end:n}),o=o.slice(n-a),a=n;a<t.length&&!Gk(e,a);)a+=1;else break}if(o===``&&i.length>1)return{score:kk,start:r,end:i[i.length-1].end,pieces:i}}return null}function Zk(e,t,n){if(n.length<3||!Bk.test(n))return null;let r=n.length<=Pk;for(let i of Jk(e)){if(!(t[i]===n[0]||!r&&t[i]===n[1]&&t[i+1]===n[0]))continue;let e=i+1;for(;e<t.length&&Ik.test(t[e]);)e+=1;let a=r?[n.length,n.length+1]:[n.length,n.length-1,n.length+1];for(let o of a)if(!(o>e-i)&&Yk(n,t.slice(i,i+o),r&&o===n.length)){let e={start:i,end:i+o};return{score:Ak,...e,pieces:[e]}}}return null}function Qk(e,t,n){let r=e.source,i=e.folded,a=null;for(let n=i.indexOf(t);n!==-1;n=i.indexOf(t,n+1)){let i={start:n,end:n+t.length};if(Gk(r,n)){let e=Kk(r,i.end)?1:Ok;if((a===null||e>a.score)&&(a={score:e,...i,pieces:[i]}),e===1)return a}else e.midWord&&t.length>=Pk&&a===null&&(a={score:jk,...i,pieces:[i]})}if(a!==null&&a.score>jk)return a;let o=n.primary?Xk(r,i,t):null;return o===null?n.typos?Zk(r,i,t)??a:a:o}function $k(e){let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start)){let e=t.at(-1);e!==void 0&&n.start<=e.end?e.end=Math.max(e.end,n.end):t.push({...n})}return t}function eA(e,t){let n=[];for(let r=e.indexOf(t);r!==-1;r=e.indexOf(t,r+1)){let i=r+t.length,a=Ik.test(t[0])&&Ik.test(e[r-1]??``),o=Ik.test(t[t.length-1])&&Ik.test(e[i]??``);!a&&!o&&n.push({start:r,end:i})}return $k(n)}function tA(e,t){let n=eA(e.folded,t);return n.length===0?null:{score:1,...n[0],pieces:n}}function nA(e,t,n){let r=Uk(e);if(r.length===0)return null;let i=Hk(e)!==null,a=t.filter(e=>e.value!==``).map(e=>({...e,source:e.value,folded:Vk(e.value)})),o=r.some(e=>!Fk.has(e)),s=[],c=0,l=0,u=!0;for(let e of r){let t=0,r=!1;for(let[o,c]of a.entries()){let a=i?tA(c,e):Qk(c,e,{primary:o===0,typos:n});a!==null&&(o===0&&s.push(...a.pieces),a.score>=Ok&&c.weight>Nk&&(r=!0),t=Math.max(t,a.score*c.weight))}if(t===0){if(o&&Fk.has(e))continue;return null}u&&=r,c+=t,l+=1}let d=a.at(0)?.folded??``,f=r.join(` `),p=d===f?Dk:r.length>1&&d.includes(f)?Mk:0;return{quality:c/l+p,strong:u,ranges:$k(s)}}function rA(e,t){let n=Vk(t);return Hk(e)===null?$k(Uk(e).filter(e=>e.length>=3).flatMap(e=>{let t=[];for(let r=n.indexOf(e);r!==-1;r=n.indexOf(e,r+e.length))t.push({start:r,end:r+e.length});return t})):eA(n,Uk(e)[0])}var iA=.6,aA=.25,oA=.6,sA=8,cA=3,lA=18144e5,uA=32,dA=12096e5,fA=2.5;function pA(e){return 2**(-Math.max(0,e)/dA)}function mA(e,t){let n=pA(t-e.updatedAt),r=e.opens===null?0:e.opens.score*pA(t-e.opens.openedAt);return Math.min(fA,1+n+.5*Math.log2(1+r))}function hA(e){return Uk(e).join(` `).slice(0,uA).trim()}function gA(e,t,n){let r=hA(t),i=(e.opens?.picks??[]).filter(e=>n-e.at<=lA&&(e.query===r||r.length>=cA&&e.query.startsWith(r)));return Math.max(0,...i.map(e=>e.at))}function _A(e,t,n){let r=nA(t,[{value:e.title,weight:1,midWord:!0},{value:e.branch??``,weight:oA,midWord:!1},{value:e.projectName??``,weight:aA,midWord:!1},{value:e.machineName??``,weight:aA,midWord:!1}],n);if(r!==null)return r;let i=t.trim().toLowerCase();return i.length>=sA&&e.id.toLowerCase().includes(i)?{quality:iA,strong:!0,ranges:[]}:null}function vA(e){return e>=1.5?3:e>=.7?2:+(e>=.4)}function yA(e,t,n,r){function i(i){return e.flatMap(e=>{let a=t(e),o=_A(a,n,i);return o===null?[]:[{item:e,match:o,picked:gA(a,n,r),score:o.quality*mA(a,r)}]})}let a=i(!1);return[...a.some(e=>e.match.strong)?a:i(!0)].sort((e,t)=>vA(t.match.quality)-vA(e.match.quality)||t.picked-e.picked||t.score-e.score).map(e=>({item:e.item,ranges:e.match.ranges}))}function bA(e){return Math.max(e.updatedAt,e.opens?.openedAt??0)}function xA(e,t,n){return nA(e,[{value:t,weight:1,midWord:!0},{value:n,weight:oA,midWord:!1}],!1)}function SA(e,t,n,r){return e.flatMap(e=>{let n=t(e);return n===void 0?[]:[{match:e,subject:n}]}).sort((e,t)=>CA(e.match,t.match)||gA(t.subject,n,r)-gA(e.subject,n,r)||mA(t.subject,r)-mA(e.subject,r)).map(e=>e.match)}function CA(e,t){return t.quality-e.quality||Number(t.author===`user`)-Number(e.author===`user`)}function wA(e){let t=k(e=>e.machines);return(0,G.jsxs)(pn,{value:e.scope,onValueChange:e.onScope,children:[(0,G.jsx)(Mn,{value:`all`,children:`All machines`}),t.map(e=>(0,G.jsxs)(Mn,{value:e.id,disabled:e.status!==`online`,children:[(0,G.jsx)(Of,{icon:e.icon,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:TA(e)})]},e.id))]})}function TA(e){return e.status===`online`?e.name:e.status===`unpaired`?`${e.name} · needs pairing`:`${e.name} · offline`}function EA(e,t,n){let r=k(e=>e.machines),[i,a]=(0,W.useState)([]),[o,s]=(0,W.useState)([]),c=r.filter(e=>e.status===`online`).map(e=>e.id).join(` `),l=r.filter(e=>n===`all`||e.id===n),u=l.filter(e=>e.status===`online`).map(e=>e.id).join(` `);(0,W.useEffect)(()=>{let e=!0;for(let t of R().machines.filter(e=>e.status===`online`))L(t.id,`sessions.searchable`,void 0).then(n=>{e&&a(e=>DA(e,{machine:t.id,sessions:n.sessions.map(e=>({...e,machine:t.id})),failed:OA(n.failed)}))}).catch(()=>{e&&a(e=>DA(e,{machine:t.id,sessions:[],failed:[t.name]}))});return()=>{e=!1}},[c]),(0,W.useEffect)(()=>{if(t.startsWith(`>`)||!Wk(t))return;let e=!0;for(let n of R().machines.filter(e=>e.status===`online`))L(n.id,`sessions.searchMessages`,{query:t}).then(r=>{e&&s(e=>DA(e,{machine:n.id,query:t,matches:r.matches.map(e=>({...e,machine:n.id})),failed:OA(r.failed)}))}).catch(()=>{e&&s(e=>DA(e,{machine:n.id,query:t,matches:[],failed:[n.name]}))});return()=>{e=!1}},[t,c]);let d=o.filter(t=>u.split(` `).includes(t.machine)&&t.query===e);return{threadResults:i,reachable:u,messages:d.flatMap(e=>e.matches),searching:!e.startsWith(`>`)&&Wk(e)&&l.some(e=>e.status===`online`&&!d.some(t=>t.machine===e.id)),failures:[...new Set([...l.filter(e=>e.status!==`online`).map(e=>e.name),...i.filter(e=>u.split(` `).includes(e.machine)).flatMap(e=>e.failed),...d.flatMap(e=>e.failed)])]}}function DA(e,t){return[...e.filter(e=>e.machine!==t.machine),t]}function OA(e){return e.map(e=>rr[e])}var kA=20,AA=12,jA=10;function MA(){let e=k(e=>e.paletteOpen);return(0,G.jsx)(oi,{open:e,onOpenChange:ue,children:(0,G.jsxs)($r,{showCloseButton:!1,className:`top-[20%] translate-y-0 gap-0 overflow-hidden p-0 sm:max-w-xl`,children:[(0,G.jsx)(ri,{className:`sr-only`,children:`Search threads`}),(0,G.jsx)(NA,{})]})})}function NA(){let e=k(e=>e.selection),t=k(e=>e.machines),n=k(e=>e.projects),[r,i]=(0,W.useState)(``),[a]=Lr(r,300),[o,s]=(0,W.useState)(`all`),[c,l]=(0,W.useState)(null),[u]=(0,W.useState)(()=>Date.now()),f=(0,W.useRef)(null),m=(0,W.useRef)(null),h=r.startsWith(`>`),g=h?r.slice(1):r,_=EA(r,a,o),v=_.threadResults,y=_.reachable,b=t.find(e=>e.id===o),x=(0,W.useMemo)(()=>v.filter(e=>y.split(` `).includes(e.machine)).flatMap(e=>e.sessions).map(e=>({thread:e,subject:IA(e,t,n)})),[v,y,t,n]),S=new Map(x.map(e=>[P(e.thread.machine,e.thread.id),e.subject])),C=(0,W.useMemo)(()=>g.trim()===``?[]:yA(x,e=>e.subject,g,u).slice(0,kA).map(e=>({item:e.item.thread,ranges:e.ranges})),[x,g,u]),w=(0,W.useMemo)(()=>[...x].sort((e,t)=>bA(t.subject)-bA(e.subject)).slice(0,AA).map(e=>({item:e.thread,ranges:[]})),[x]),T=g.trim()===``?w:C,E=[...e===null?[]:[{key:`new`,label:`New thread`,place:{machine:e.machine,projectId:e.projectId},detail:RA(e.machine,e.projectId,n),run:()=>we(e.machine,e.projectId)}],{key:`accounts`,label:`Manage accounts`,detail:``,place:null,run:()=>d(Se[R().settings.provider])},{key:`settings`,label:`Settings`,detail:`Theme, notifications, keyboard shortcuts`,place:null,run:()=>p(!0)}].flatMap(e=>{let t={...e,section:`Actions`,labelRanges:[],detailRanges:[],branch:``,updatedAt:null};if(g.trim()===``)return[t];let n=xA(g,e.label,e.detail);return n===null?[]:[{...t,labelRanges:n.ranges}]}),D=new Set(C.map(e=>P(e.item.machine,e.item.id))),O=h?[]:T.map(e=>{let t=e.item,r=g.trim()!==``&&t.branch!==null?` | ${t.branch}`:``;return{key:P(t.machine,t.id),section:g.trim()===``?`Recent`:`Threads`,label:t.title,labelRanges:e.ranges,detail:LA(t,n),detailRanges:[],branch:r,updatedAt:t.updatedAt,place:{machine:t.machine,projectId:t.projectId},run:()=>Ie({machine:t.machine,projectId:t.projectId,sessionId:t.id},g.trim()===``?null:g)}}),A=h?[]:SA(_.messages.filter(e=>!D.has(P(e.machine,e.sessionId))),e=>S.get(P(e.machine,e.sessionId)),g,u).slice(0,jA).flatMap(e=>{let t=x.find(t=>t.thread.machine===e.machine&&t.thread.id===e.sessionId)?.thread;if(t===void 0)return[];let n=`${e.author===`user`?`You: `:``}${e.snippet}`;return[{key:`message:${P(e.machine,e.sessionId)}`,section:`In messages`,label:t.title,labelRanges:[],detail:n,detailRanges:rA(g,n),branch:``,updatedAt:t.updatedAt,place:{machine:t.machine,projectId:t.projectId},run:()=>Ie({machine:t.machine,projectId:t.projectId,sessionId:t.id},g)}]}),j=[...E,...O,...A],M=Math.min(Math.max(0,j.findIndex(e=>e.key===c)),j.length-1);(0,W.useLayoutEffect)(()=>{f.current?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})},[M]);function N(e){ue(!1),e.run()}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 border-b pr-2.5`,children:[(0,G.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 pl-4`,children:[(0,G.jsx)(H,{icon:br,className:`text-muted-foreground size-4 shrink-0`}),(0,G.jsx)(`input`,{ref:m,value:r,onChange:e=>{i(e.target.value),l(null)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;j.length>0&&l(j[(M+t+j.length)%j.length].key)}e.key===`Enter`&&M>=0&&(e.preventDefault(),N(j[M]))},placeholder:`Search threads and actions…`,className:`placeholder:text-placeholder/75 h-11 w-full bg-transparent text-sm outline-none`})]}),t.length>1&&(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:`text-secondary-label hover:bg-accent data-[state=open]:bg-accent flex h-7 max-w-40 shrink-0 cursor-pointer items-center gap-1.5 rounded-[var(--control-radius)] px-1.5 text-xs`,children:[b!==void 0&&(0,G.jsx)(Of,{icon:b.icon,className:`size-3 shrink-0`}),(0,G.jsx)(`span`,{className:`truncate`,children:b?.name??`All machines`}),(0,G.jsx)(H,{icon:Rr,className:`size-3 shrink-0`})]})}),(0,G.jsx)(Dn,{align:`end`,className:`w-56`,onCloseAutoFocus:e=>{e.preventDefault(),m.current?.focus()},children:(0,G.jsx)(wA,{scope:o,onScope:e=>{s(e),l(null)}})})]})]}),(0,G.jsxs)(`div`,{ref:f,className:`max-h-96 overflow-y-auto p-1`,children:[j.length===0&&!_.searching&&(0,G.jsx)(`p`,{className:`text-muted-foreground px-3 py-6 text-center text-xs`,children:`Nothing matches.`}),j.map((e,n)=>(0,G.jsxs)(`div`,{children:[e.section!==j[n-1]?.section&&(0,G.jsx)(`p`,{className:`text-secondary-label px-2.5 pt-2 pb-1 text-xs`,children:e.section}),(0,G.jsxs)(`button`,{"data-active":n===M,className:B(`flex w-full cursor-pointer flex-col rounded-lg px-2.5 py-1.5 text-left`,n===M&&`bg-accent`),onMouseMove:()=>l(e.key),onClick:()=>N(e),children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[e.place!==null&&(0,G.jsx)(mc,{machine:e.place.machine,projectId:e.place.projectId,className:`size-3.5 shrink-0 grayscale`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,G.jsx)(FA,{text:e.label,ranges:e.labelRanges})})]}),e.detail!==``&&(0,G.jsxs)(`span`,{className:`text-secondary-label flex min-w-0 items-center gap-1.5 text-xs`,children:[e.place!==null&&t.length>1&&(0,G.jsx)(PA,{id:e.place.machine,machines:t}),(0,G.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,G.jsx)(FA,{text:e.detail,ranges:e.detailRanges}),(0,G.jsx)(`span`,{className:`text-muted-foreground/40`,children:e.branch})]}),e.updatedAt!==null&&(0,G.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 tabular-nums`,children:yn(e.updatedAt)})]})]})]},e.key)),_.searching&&(0,G.jsx)(`p`,{className:`text-muted-foreground px-2.5 py-2 text-xs`,children:`Searching messages…`})]}),_.failures.length>0&&(0,G.jsxs)(`p`,{className:`text-muted-foreground border-t px-4 py-2 text-xs`,children:[`Couldn't search `,_.failures.join(`, `)]})]})}function PA(e){let t=e.machines.find(t=>t.id===e.id);return(0,G.jsx)(Of,{icon:t?.icon??null,className:`size-3 shrink-0`})}function FA(e){return(0,G.jsxs)(G.Fragment,{children:[e.ranges.map((t,n)=>(0,G.jsxs)(W.Fragment,{children:[e.text.slice(e.ranges[n-1]?.end??0,t.start),(0,G.jsx)(`mark`,{className:`text-foreground bg-transparent font-medium`,children:e.text.slice(t.start,t.end)})]},t.start)),e.text.slice(e.ranges.at(-1)?.end??0)]})}function IA(e,t,n){return{id:e.id,title:e.title,branch:e.branch,projectName:n.find(t=>t.machine===e.machine&&t.id===e.projectId)?.name??null,machineName:t.length>1?t.find(t=>t.id===e.machine)?.name??null:null,updatedAt:e.updatedAt,opens:e.opens}}function LA(e,t){return`${e.status===`minimized`?`Minimized · `:``}${RA(e.machine,e.projectId,t)}`}function RA(e,t,n){return t===`no-project`?`Chat`:n.find(n=>n.machine===e&&n.id===t)?.name??``}function zA(e){let t=e.session,[n,r]=(0,W.useState)(!1),i=k(e=>e.generatingTitles.includes(P(t.machine,t.id))),a=k(e=>He(e,t.machine,t.projectId)?.scratch===!0),o=e.context?Bn:Mr,s=e.context?Wn:Pn;return(0,G.jsxs)(G.Fragment,{children:[t.status!==`active`&&(0,G.jsxs)(o,{onSelect:()=>void Je(t.machine,t.id,{status:`active`}),children:[(0,G.jsx)(H,{icon:t.status===`pinned`?Fs:Ls}),t.status===`pinned`?`Unpin`:`Activate`]}),t.status!==`inactive`&&(0,G.jsxs)(o,{onSelect:e.onDeactivate,children:[(0,G.jsx)(H,{icon:nc}),`Done`]}),t.status!==`snoozed`&&(0,G.jsxs)(o,{onSelect:()=>void Je(t.machine,t.id,{status:`snoozed`}),children:[(0,G.jsx)(H,{icon:sc}),`Snooze`]}),t.status!==`minimized`&&(0,G.jsxs)(o,{onSelect:()=>void Je(t.machine,t.id,{status:`minimized`}),children:[(0,G.jsx)(H,{icon:As}),`Minimize`]}),t.status!==`pinned`&&(0,G.jsxs)(o,{onSelect:()=>void Je(t.machine,t.id,{status:`pinned`}),children:[(0,G.jsx)(H,{icon:Is}),`Pin`]}),(0,G.jsx)(s,{}),(0,G.jsxs)(o,{disabled:i,onSelect:()=>void lt(t),children:[(0,G.jsx)(H,{icon:ko}),`Refresh title`]}),(0,G.jsxs)(o,{onSelect:e.onRename,children:[(0,G.jsx)(H,{icon:Ps}),`Rename`]}),(0,G.jsxs)(o,{onSelect:()=>Et(t),children:[(0,G.jsx)(H,{icon:er}),`Export`]}),a&&(0,G.jsxs)(o,{onSelect:()=>uc(t.machine,t.projectId,{scratch:!1,name:t.title}).catch(c),children:[(0,G.jsx)(H,{icon:hr}),`Turn into project`]}),(0,G.jsxs)(o,{variant:`destructive`,title:`Also removes it from ${rr[t.provider]}`,onSelect:e=>{n?nt(t.machine,t.id,t.projectId):(e.preventDefault(),r(!0))},children:[(0,G.jsx)(H,{icon:is}),n?e.mobile?`Tap again to delete`:`Click again to delete`:`Delete`]})]})}function BA(e){return e.activity?.approval===!0&&e.activity?.question===!0?(0,G.jsx)(`span`,{title:`Waiting for approval and an answer`,className:`text-question flex`,children:(0,G.jsx)(H,{icon:qs,className:`size-4 shrink-0`})}):e.activity?.approval===!0?(0,G.jsx)(`span`,{title:`Waiting for approval`,className:`text-question flex`,children:(0,G.jsx)(H,{icon:Ws,className:`size-4 shrink-0`})}):e.activity?.question===!0?(0,G.jsx)(`span`,{title:`Waiting for an answer`,className:`text-question flex`,children:(0,G.jsx)(H,{icon:Vo,className:`size-4 shrink-0`})}):e.activity?.running===!0?(0,G.jsx)(`span`,{title:`Working`,className:`text-info flex`,children:(0,G.jsx)(H,{icon:Qo,className:`size-4 shrink-0 animate-spin`})}):e.backgroundRunning?e.activity?.backgroundAgent===!0?(0,G.jsx)(`span`,{title:`Agent running in background`,className:`text-info flex`,children:(0,G.jsx)(H,{icon:jr,className:`size-4 shrink-0 animate-spin`})}):(0,G.jsx)(`span`,{title:`Task running in background`,className:`text-muted-foreground flex`,children:(0,G.jsx)(H,{icon:jr,className:`size-4 shrink-0 animate-spin`})}):e.done?(0,G.jsx)(`span`,{title:`Done`,className:`text-success flex`,children:(0,G.jsx)(H,{icon:Yo,className:`size-4 shrink-0`})}):null}function VA(e){let t=k(t=>t.generatingTitles.includes(P(e.session.machine,e.session.id)));return(0,G.jsx)(`span`,{className:B((t||e.awaitingTitle)&&`text-shimmer`),children:e.session.title})}var HA=`group/sidebar-row relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,UA=(0,W.memo)(WA);function WA(e){let t=e.session,n=cc(t.machine,t.projectId),r=k(e=>Ge(e,t.machine).icon),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),c=(0,W.useRef)(null),l=e.activity?.waiting===!0,u=Object.values(e.activity?.tasks??{}).includes(`running`),d=!l&&(e.activity?.running===!0||u),f=e.activity?.running===!0||u,p=!l&&!d&&e.unseen,m=!e.selected&&!l&&!p;function h(){pt(t.machine,t.id,e.scope)}function g(){f?s(!0):h()}let _=(0,G.jsx)(mr,{open:o,onOpenChange:s,children:(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:`Stop running work?`}),(0,G.jsx)(Rn,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:h,children:`Stop and Mark Done`})]})]})}),v=e.saved&&(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Thread actions`,onClick:e=>e.stopPropagation(),children:(0,G.jsx)(H,{icon:os,className:`size-3.5`})})}),(0,G.jsx)(Dn,{align:`end`,className:`w-44`,onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>{c.current!==null&&(e.preventDefault(),c.current.focus(),c.current.select())},children:(0,G.jsx)(zA,{session:t,context:!1,mobile:!1,onDeactivate:g,onRename:()=>a(t.title)})})]}),y=(0,G.jsx)(tr,{className:`w-44`,onCloseAutoFocus:e=>{c.current!==null&&(e.preventDefault(),c.current.focus(),c.current.select())},children:(0,G.jsx)(zA,{session:t,context:!0,mobile:!1,onDeactivate:g,onRename:()=>a(t.title)})}),b=i===null?(0,G.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate text-sm`,m?`text-secondary-label font-normal`:`font-medium`,!m&&(e.unseen||l)&&`text-foreground`,!m&&!e.unseen&&!l&&`text-foreground/90`),children:(0,G.jsx)(VA,{session:t,awaitingTitle:!e.saved})}):(0,G.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&Je(t.machine,t.id,{title:n})},children:(0,G.jsx)(`input`,{ref:c,value:i,onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>a(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&a(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),x=B(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,m&&`text-sidebar-muted-foreground/75 hover:bg-sidebar-row-hover hover:text-sidebar-foreground has-[[data-state=open]]:bg-sidebar-row-hover has-[[data-state=open]]:text-sidebar-foreground`,!e.selected&&!m&&`text-sidebar-foreground hover:bg-sidebar-row-hover has-[[data-state=open]]:bg-sidebar-row-hover bg-transparent`);return e.slim?(0,G.jsxs)(`li`,{className:`list-none`,children:[(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(HA,x,`flex h-9 items-center gap-2.5 px-2.5`),onClick:()=>e.onSelect(t.machine,t.projectId,t.id),onKeyDown:n=>{n.key===`Enter`&&e.onSelect(t.machine,t.projectId,t.id)},children:[(0,G.jsx)(`span`,{className:`flex shrink-0 items-center opacity-40 grayscale transition-opacity group-hover/sidebar-row:opacity-100 group-hover/sidebar-row:grayscale-0 group-has-[[data-state=open]]/sidebar-row:opacity-100 group-has-[[data-state=open]]/sidebar-row:grayscale-0`,children:(0,G.jsx)(mc,{machine:t.machine,projectId:t.projectId})}),(0,G.jsx)(`span`,{className:`group-any-hover/sidebar-row:mask-r-from-[calc(100%-2rem)] group-any-hover/sidebar-row:mask-r-to-[calc(100%-0.5rem)] flex min-w-0 flex-1 group-has-[[data-state=open]]/sidebar-row:mask-r-from-[calc(100%-2rem)] group-has-[[data-state=open]]/sidebar-row:mask-r-to-[calc(100%-0.5rem)]`,children:b}),(0,G.jsxs)(`span`,{className:`relative ml-auto flex h-6 min-w-8 shrink-0 items-center justify-end`,children:[(0,G.jsx)(`span`,{className:`text-secondary-label group-any-hover/sidebar-row:opacity-0 inline-flex justify-end text-xs tabular-nums transition-opacity group-has-[[data-state=open]]/sidebar-row:opacity-0`,children:yn(t.updatedAt)}),(0,G.jsxs)(`span`,{className:`group-any-hover/sidebar-row:opacity-100 absolute inset-y-0 right-0 -mr-1 flex items-center opacity-0 transition-opacity has-[[data-state=open]]:opacity-100`,children:[v,e.saved&&(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Activate`,"aria-label":`Activate`,onClick:e=>{e.stopPropagation(),Je(t.machine,t.id,{status:`active`})},children:(0,G.jsx)(H,{icon:Ls,className:`size-3.5`})})]})]})]})}),y]}),_]}):(0,G.jsxs)(`li`,{className:`list-none py-0.5`,children:[(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(HA,x,d&&!e.selected&&`opacity-70 transition-opacity focus-within:opacity-100 hover:opacity-100`),onClick:()=>e.onSelect(t.machine,t.projectId,t.id),onKeyDown:n=>{n.key===`Enter`&&e.onSelect(t.machine,t.projectId,t.id)},children:[(0,G.jsxs)(`div`,{className:`group-any-hover/sidebar-row:mask-r-from-[calc(100%-4.5rem)] group-any-hover/sidebar-row:mask-r-to-[calc(100%-2.5rem)] px-(--sidebar-row-content-inset) py-(--sidebar-content-inset) group-has-[[data-state=open]]/sidebar-row:mask-r-from-[calc(100%-4.5rem)] group-has-[[data-state=open]]/sidebar-row:mask-r-to-[calc(100%-2.5rem)]`,children:[(0,G.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,G.jsx)(mc,{machine:t.machine,projectId:t.projectId,className:`size-5`}),b,(0,G.jsx)(BA,{activity:e.activity,backgroundRunning:u,done:p})]}),(0,G.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,G.jsx)(Of,{icon:r,className:`size-3 shrink-0`}),(0,G.jsxs)(`span`,{className:B(`min-w-0 flex-1 truncate`,m?`font-normal`:`font-medium`),children:[n,t.branch!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | ${t.branch}`})]}),t.status===`pinned`&&(0,G.jsx)(H,{icon:Is,className:`size-3 shrink-0`}),t.status===`snoozed`&&(0,G.jsx)(H,{icon:sc,className:`size-3 shrink-0`}),(0,G.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:yn(t.updatedAt)})]})]}),e.saved&&(0,G.jsxs)(`div`,{className:`group-any-hover/sidebar-row:pointer-events-auto group-any-hover/sidebar-row:opacity-100 pointer-events-none absolute inset-y-0 right-0 flex flex-col items-end py-(--sidebar-content-inset) pr-1.5 opacity-0 transition-opacity has-[[data-state=open]]:pointer-events-auto has-[[data-state=open]]:opacity-100`,children:[(0,G.jsx)(`div`,{className:`flex h-6 items-center`,children:(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground me-0.75 inline-flex size-5 cursor-pointer items-center justify-center transition-colors`,title:`Done`,"aria-label":`Done`,onClick:e=>{e.stopPropagation(),g()},children:(0,G.jsx)(H,{icon:nc,strokeWidth:1.25,className:`size-5 scale-110`})})}),(0,G.jsx)(`div`,{className:`mt-1 flex h-5 items-center`,children:v})]})]})}),y]}),_]})}function GA(e){let t=cc(e.machine,e.projectId),n=k(t=>Ge(t,e.machine).icon);return(0,G.jsx)(`li`,{className:`list-none py-0.5`,children:(0,G.jsx)(`div`,{role:`button`,tabIndex:0,className:B(HA,`bg-sidebar-row-active text-sidebar-foreground`),onClick:e.onSelect,children:(0,G.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,G.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,G.jsx)(mc,{machine:e.machine,projectId:e.projectId,className:`size-5`}),(0,G.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,G.jsx)(H,{icon:Ys,className:`text-warning-foreground size-4 shrink-0`})]}),(0,G.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,G.jsx)(Of,{icon:n,className:`size-3 shrink-0`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:[t,(0,G.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | Draft`})]}),(0,G.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`now`})]})]})})})}var KA=`/assets/ghostty-vt-CQAu1Gs5.wasm`,qA=Uint8Array,JA=Uint16Array,YA=Int32Array,XA=new qA([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ZA=new qA([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),QA=new qA([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$A=function(e,t){for(var n=new JA(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new YA(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},ej=$A(XA,2),tj=ej.b,nj=ej.r;tj[28]=258,nj[258]=28;var rj=$A(ZA,0),ij=rj.b;rj.r;for(var aj=new JA(32768),oj=0;oj<32768;++oj){var sj=(oj&43690)>>1|(oj&21845)<<1;sj=(sj&52428)>>2|(sj&13107)<<2,sj=(sj&61680)>>4|(sj&3855)<<4,aj[oj]=((sj&65280)>>8|(sj&255)<<8)>>1}for(var cj=(function(e,t,n){for(var r=e.length,i=0,a=new JA(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new JA(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new JA(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[aj[d]>>c]=l}else for(s=new JA(r),i=0;i<r;++i)e[i]&&(s[i]=aj[o[e[i]-1]++]>>15-e[i]);return s}),lj=new qA(288),oj=0;oj<144;++oj)lj[oj]=8;for(var oj=144;oj<256;++oj)lj[oj]=9;for(var oj=256;oj<280;++oj)lj[oj]=7;for(var oj=280;oj<288;++oj)lj[oj]=8;for(var uj=new qA(32),oj=0;oj<32;++oj)uj[oj]=5;var dj=cj(lj,9,1),fj=cj(uj,5,1),pj=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},mj=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},hj=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},gj=function(e){return(e+7)/8|0},_j=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new qA(e.subarray(t,n))},vj=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],yj=function(e,t,n){var r=Error(t||vj[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,yj),!n)throw r;return r},bj=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new qA(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new qA(i*3));var l=function(e){var t=n.length;if(e>t){var r=new qA(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=mj(e,d,1);var v=mj(e,d+1,3);if(d+=3,!v){var y=gj(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&yj(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=dj,m=fj,h=9,g=5;else if(v==2){var S=mj(e,d,31)+257,C=mj(e,d+10,15)+4,w=S+mj(e,d+5,31)+1;d+=14;for(var T=new qA(w),E=new qA(19),D=0;D<C;++D)E[QA[D]]=mj(e,d+D*3,7);d+=C*3;for(var O=pj(E),k=(1<<O)-1,A=cj(E,O,1),D=0;D<w;){var j=A[mj(e,d,k)];d+=j&15;var y=j>>4;if(y<16)T[D++]=y;else{var M=0,N=0;for(y==16?(N=3+mj(e,d,3),d+=2,M=T[D-1]):y==17?(N=3+mj(e,d,7),d+=3):y==18&&(N=11+mj(e,d,127),d+=7);N--;)T[D++]=M}}var ee=T.subarray(0,S),te=T.subarray(S);h=pj(ee),g=pj(te),p=cj(ee,h,1),m=cj(te,g,1)}else yj(1);if(d>_){c&&yj(0);break}}s&&l(f+131072);for(var ne=(1<<h)-1,re=(1<<g)-1,ie=d;;ie=d){var M=p[hj(e,d)&ne],ae=M>>4;if(d+=M&15,d>_){c&&yj(0);break}if(M||yj(2),ae<256)n[f++]=ae;else if(ae==256){ie=d,p=null;break}else{var oe=ae-254;if(ae>264){var D=ae-257,se=XA[D];oe=mj(e,d,(1<<se)-1)+tj[D],d+=se}var ce=m[hj(e,d)&re],le=ce>>4;ce||yj(3),d+=ce&15;var te=ij[le];if(le>3){var se=ZA[le];te+=hj(e,d)&(1<<se)-1,d+=se}if(d>_){c&&yj(0);break}s&&l(f+131072);var ue=f+oe;if(f<te){var de=a-te,fe=Math.min(te,ue);for(de+f<0&&yj(3);f<fe;++f)n[f]=r[de+f]}for(;f<ue;++f)n[f]=n[f-te]}}t.l=p,t.p=ie,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?_j(n,0,f):n.subarray(0,f)},xj=new qA(0),Sj=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&yj(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&yj(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2},Cj=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new qA(32768),this.p=new qA(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||yj(5),this.d&&yj(4),!this.p.length)this.p=e;else if(e.length){var t=new qA(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=bj(this.p,this.s,this.o);this.ondata(_j(n,t,this.s.b),this.d),this.o=_j(n,this.s.b-32768),this.s.b=this.o.length,this.p=_j(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),wj=function(){function e(e,t){Cj.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(Cj.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(Sj(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&yj(6,`invalid zlib data`),this.p=this.p.subarray(0,-4)),Cj.prototype.c.call(this,t)},e}();function Tj(e,t){return bj(e.subarray(Sj(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var Ej=typeof TextDecoder<`u`&&new TextDecoder;try{Ej.decode(xj,{stream:!0})}catch{}function Dj(e,t=`utf8`){return new TextDecoder(t).decode(e)}var Oj=new TextEncoder;function kj(e){return Oj.encode(e)}var Aj=8192,jj=(()=>{let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),Mj={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array},Nj=class e{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=Aj,n={}){let r=!1;typeof t==`number`?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);let i=n.offset?n.offset>>>0:0,a=t.byteLength-i,o=i;(ArrayBuffer.isView(t)||t instanceof e)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+i),t=t.buffer),this.lastWrittenByte=r?a:0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw Error(`Mark stack empty`);return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let t=(this.offset+e)*2,n=new Uint8Array(t);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=t,this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,`uint8`)}readArray(e,t){let n=Mj[t].BYTES_PER_ELEMENT*e,r=this.byteOffset+this.offset,i=this.buffer.slice(r,r+n);if(this.littleEndian===jj&&t!==`uint8`&&t!==`int8`){let e=new Uint8Array(this.buffer.slice(r,r+n));e.reverse();let i=new Mj[t](e.buffer);return this.offset+=n,i.reverse(),i}let a=new Mj[t](i);return this.offset+=n,a}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){let e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){let e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t=``;for(let n=0;n<e;n++)t+=this.readChar();return t}readUtf8(e=1){return Dj(this.readBytes(e))}decodeText(e=1,t=`utf8`){return Dj(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(kj(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}},Pj=[];for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;Pj[e]=t}var Fj=4294967295;function Ij(e,t,n){let r=e;for(let e=0;e<n;e++)r=Pj[(r^t[e])&255]^r>>>8;return r}function Lj(e,t){return(Ij(Fj,e,t)^Fj)>>>0}function Rj(e,t,n){let r=e.readUint32(),i=Lj(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(i!==r)throw Error(`CRC mismatch for chunk ${n}. Expected ${r}, found ${i}`)}function zj(e,t,n){for(let r=0;r<n;r++)t[r]=e[r]}function Bj(e,t,n,r){let i=0;for(;i<r;i++)t[i]=e[i];for(;i<n;i++)t[i]=e[i]+t[i-r]&255}function Vj(e,t,n,r){let i=0;if(n.length===0)for(;i<r;i++)t[i]=e[i];else for(;i<r;i++)t[i]=e[i]+n[i]&255}function Hj(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+(t[a-i]>>1)&255}else{for(;a<i;a++)t[a]=e[a]+(n[a]>>1)&255;for(;a<r;a++)t[a]=e[a]+(t[a-i]+n[a]>>1)&255}}function Uj(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+t[a-i]&255}else{for(;a<i;a++)t[a]=e[a]+n[a]&255;for(;a<r;a++)t[a]=e[a]+Wj(t[a-i],n[a],n[a-i])&255}}function Wj(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function Gj(e,t,n,r,i,a){switch(e){case 0:zj(t,n,i);break;case 1:Bj(t,n,i,a);break;case 2:Vj(t,n,r,i);break;case 3:Hj(t,n,r,i,a);break;case 4:Uj(t,n,r,i,a);break;default:throw Error(`Unsupported filter: ${e}`)}}var Kj=new Uint16Array([255]),qj=new Uint8Array(Kj.buffer)[0]===255;function Jj(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],s=Math.ceil(a/8)*i,c=new Uint8Array(r*n*s),l=0;for(let e=0;e<7;e++){let i=o[e],a=Math.ceil((n-i.x)/i.xStep),u=Math.ceil((r-i.y)/i.yStep);if(a<=0||u<=0)continue;let d=a*s,f=new Uint8Array(d);for(let e=0;e<u;e++){let o=t[l++],u=t.subarray(l,l+d);l+=d;let p=new Uint8Array(d);Gj(o,u,p,f,d,s),f.set(p);for(let t=0;t<a;t++){let a=i.x+t*i.xStep,o=i.y+e*i.yStep;if(!(a>=n||o>=r))for(let e=0;e<s;e++)c[(o*n+a)*s+e]=p[t*s+e]}}}if(a===16){let e=new Uint16Array(c.buffer);if(qj)for(let t=0;t<e.length;t++)e[t]=Yj(e[t]);return e}return c}function Yj(e){return(e&255)<<8|e>>8&255}var Xj=new Uint16Array([255]),Zj=new Uint8Array(Xj.buffer)[0]===255,Qj=new Uint8Array;function $j(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=Math.ceil(a/8)*i,s=Math.ceil(a/8*i*n),c=new Uint8Array(r*s),l=Qj,u=0,d,f;for(let e=0;e<r;e++){switch(d=t.subarray(u+1,u+1+s),f=c.subarray(e*s,(e+1)*s),t[u]){case 0:zj(d,f,s);break;case 1:Bj(d,f,s,o);break;case 2:Vj(d,f,l,s);break;case 3:Hj(d,f,l,s,o);break;case 4:Uj(d,f,l,s,o);break;default:throw Error(`Unsupported filter: ${t[u]}`)}l=f,u+=s+1}if(a===16){let e=new Uint16Array(c.buffer);if(Zj)for(let t=0;t<e.length;t++)e[t]=eM(e[t]);return e}return c}function eM(e){return(e&255)<<8|e>>8&255}var tM=Uint8Array.of(137,80,78,71,13,10,26,10);function nM(e){if(!rM(e.readBytes(tM.length)))throw Error(`wrong PNG signature`)}function rM(e){if(e.length<tM.length)return!1;for(let t=0;t<tM.length;t++)if(e[t]!==tM[t])return!1;return!0}var iM=`tEXt`,aM=0,oM=new TextDecoder(`latin1`);function sM(e){if(lM(e),e.length===0||e.length>79)throw Error(`keyword length must be between 1 and 79`)}var cM=/^[\u0000-\u00FF]*$/;function lM(e){if(!cM.test(e))throw Error(`invalid latin1 text`)}function uM(e,t,n){let r=dM(t);e[r]=fM(t,n-r.length-1)}function dM(e){for(e.mark();e.readByte()!==aM;);let t=e.offset;e.reset();let n=oM.decode(e.readBytes(t-e.offset-1));return e.skip(1),sM(n),n}function fM(e,t){return oM.decode(e.readBytes(t))}var pM={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},mM={UNKNOWN:-1,DEFLATE:0},hM={UNKNOWN:-1,ADAPTIVE:0},gM={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},_M={NONE:0,BACKGROUND:1,PREVIOUS:2},vM={SOURCE:0,OVER:1},yM=class extends Nj{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;_chunks;_inflatorResult;constructor(e,t={}){super(e);let{checkCrc:n=!1}=t;this._checkCrc=n,this._inflator=new wj((e,t)=>{if(this._chunks.push(e),t){let e=this._chunks.reduce((e,t)=>e+t.length,0);this._inflatorResult=new Uint8Array(e);let t=0;for(let e of this._chunks)this._inflatorResult.set(e,t),t+=e.length;this._chunks=[]}}),this._chunks=[],this._png={width:-1,height:-1,channels:-1,data:new Uint8Array,depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array,this._compressionMethod=mM.UNKNOWN,this._filterMethod=hM.UNKNOWN,this._interlaceMethod=gM.UNKNOWN,this._colorType=pM.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this._inflatorResult=new Uint8Array,this.setBigEndian()}decode(){for(nM(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this._inflator.push(new Uint8Array,!0),this.decodeImage(),this._png}decodeApng(){for(nM(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){let n=this.offset;switch(t){case`IHDR`:this.decodeIHDR();break;case`PLTE`:this.decodePLTE(e);break;case`IDAT`:this.decodeIDAT(e);break;case`IEND`:this._end=!0;break;case`tRNS`:this.decodetRNS(e);break;case`iCCP`:this.decodeiCCP(e);break;case iM:uM(this._png.text,this,e);break;case`pHYs`:this.decodepHYs();break;default:this.skip(e)}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?Rj(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){let n=this.offset;switch(t!==`fdAT`&&t!==`IDAT`&&this._writingDataChunks&&this.pushDataToFrame(),t){case`acTL`:this.decodeACTL();break;case`fcTL`:this.decodeFCTL();break;case`fdAT`:this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=n+e}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?Rj(this,e+4,t):this.skip(4)}decodeIHDR(){let e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=bM(this.readUint8());let t=this.readUint8();this._colorType=t;let n;switch(t){case pM.GREYSCALE:n=1;break;case pM.TRUECOLOUR:n=3;break;case pM.INDEXED_COLOUR:n=1;break;case pM.GREYSCALE_ALPHA:n=2;break;case pM.TRUECOLOUR_ALPHA:n=4;break;case pM.UNKNOWN:default:throw Error(`Unknown color type: ${t}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==mM.DEFLATE)throw Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){let e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array};this._frames.push(e)}decodePLTE(e){if(e%3!=0)throw RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);let t=e/3;this._hasPalette=!0;let n=[];this._palette=n;for(let e=0;e<t;e++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;try{this._inflator.push(new Uint8Array(this.buffer,n,t),!1)}catch(e){throw Error(`Error while decompressing the data:`,{cause:e})}this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;n+=4,t-=4;try{this._inflator.push(new Uint8Array(this.buffer,n,t),!1)}catch(e){throw Error(`Error while decompressing the data:`,{cause:e})}this.skip(e)}decodetRNS(e){switch(this._colorType){case pM.GREYSCALE:case pM.TRUECOLOUR:if(e%2!=0)throw RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break;case pM.INDEXED_COLOUR:{if(e>this._palette.length)throw Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){let e=this.readByte();this._palette[t].push(e)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case pM.UNKNOWN:case pM.GREYSCALE_ALPHA:case pM.TRUECOLOUR_ALPHA:default:throw Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){let t=dM(this),n=this.readUint8();if(n!==mM.DEFLATE)throw Error(`Unsupported iCCP compression method: ${n}`);let r=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:Tj(r)}}decodepHYs(){let e=this.readUint32(),t=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:t,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){let t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(e);if(n){if(n.data=$j({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)t.data=n.data;else{let r=this._apng.frames.at(e-1);this.disposeFrame(n,r,t),this.addFrameDataToCanvas(t,n)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,n){switch(e.disposeOp){case _M.NONE:break;case _M.BACKGROUND:for(let t=0;t<this._png.height;t++)for(let r=0;r<this._png.width;r++){let i=(t*e.width+r)*this._png.channels;for(let e=0;e<this._png.channels;e++)n.data[i+e]=0}break;case _M.PREVIOUS:n.data.set(t.data);break;default:throw Error(`Unknown disposeOp`)}}addFrameDataToCanvas(e,t){let n=1<<this._png.depth,r=(e,n)=>({index:((e+t.yOffset)*this._png.width+t.xOffset+n)*this._png.channels,frameIndex:(e*t.width+n)*this._png.channels});switch(t.blendOp){case vM.SOURCE:for(let n=0;n<t.height;n++)for(let i=0;i<t.width;i++){let{index:a,frameIndex:o}=r(n,i);for(let n=0;n<this._png.channels;n++)e.data[a+n]=t.data[o+n]}break;case vM.OVER:for(let i=0;i<t.height;i++)for(let a=0;a<t.width;a++){let{index:o,frameIndex:s}=r(i,a);for(let r=0;r<this._png.channels;r++){let i=t.data[s+this._png.channels-1]/n,a=r%(this._png.channels-1)==0?1:t.data[s+r],c=Math.floor(i*a+(1-i)*e.data[o+r]);e.data[o+r]+=c}}break;default:throw Error(`Unknown blendOp`)}}decodeImage(){let e=this._inflatorResult;if(this._filterMethod!==hM.ADAPTIVE)throw Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===gM.NO_INTERLACE)this._png.data=$j({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===gM.ADAM7)this._png.data=Jj({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){this._inflator.push(new Uint8Array,!0);let e=this._inflatorResult,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:_M.NONE,blendOp:vM.SOURCE,data:e}),this._inflator=new wj((e,t)=>{if(this._chunks.push(e),t){let e=this._chunks.reduce((e,t)=>e+t.length,0);this._inflatorResult=new Uint8Array(e);let t=0;for(let e of this._chunks)this._inflatorResult.set(e,t),t+=e.length;this._chunks=[]}}),this._chunks=[],this._writingDataChunks=!1}};function bM(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw Error(`invalid bit depth: ${e}`);return e}function xM(e){let t=e.palette,n=e.depth;if(!t)throw Error(`Color palette is undefined.`);SM(e);let r=e.width*e.height,i=r*t[0].length,a=new Uint8Array(i),o=0,s=0,c=new Uint8Array(r),l=255;switch(n){case 1:l=128;break;case 2:l=192;break;case 4:l=240;break;case 8:l=255;break;default:throw Error(`Incorrect depth value`)}for(let t of e.data){let r=l,i=8;for(;r&&(i-=n,c[o++]=(t&r)>>i,r>>=n,o%e.width!==0););}if(e.palette)for(let t of c){let n=e.palette.at(t);if(!n)throw Error(`Incorrect index of palette color`);a.set(n,s),s+=n.length}return a}function SM(e){let t=e.depth<8?Math.ceil(e.width*e.depth/8)*e.height*e.channels:e.width*e.height*e.channels;if(e.data.length!==t)throw RangeError(`wrong data size. Found ${e.data.length}, expected ${t}`)}function CM(e,t){return new yM(e,t).decode()}var wM=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_FOREGROUND=e.DEFAULT_BACKGROUND=e.PALETTE_ANSI_256=e.PALETTE_VT340_GREY=e.PALETTE_VT340_COLOR=e.normalizeHLS=e.normalizeRGB=e.nearestColorIndex=e.fromRGBA8888=e.toRGBA8888=e.alpha=e.blue=e.green=e.red=e.BIG_ENDIAN=void 0,e.BIG_ENDIAN=new Uint8Array(new Uint32Array([4278190080]).buffer)[0]===255,e.BIG_ENDIAN&&console.warn(`BE platform detected. This version of node-sixel works only on LE properly.`);function t(e){return e&255}e.red=t;function n(e){return e>>>8&255}e.green=n;function r(e){return e>>>16&255}e.blue=r;function i(e){return e>>>24&255}e.alpha=i;function a(e,t,n,r=255){return((r&255)<<24|(n&255)<<16|(t&255)<<8|e&255)>>>0}e.toRGBA8888=a;function o(e){return[e&255,e>>8&255,e>>16&255,e>>>24]}e.fromRGBA8888=o;function s(e,i){let a=t(e),o=n(e),s=r(e),c=2**53-1,l=-1;for(let e=0;e<i.length;++e){let t=a-i[e][0],n=o-i[e][1],r=s-i[e][2],u=t*t+n*n+r*r;if(!u)return e;u<c&&(c=u,l=e)}return l}e.nearestColorIndex=s;function c(e,t,n){return Math.max(e,Math.min(n,t))}function l(e,t,n){return n<0&&(n+=1),n>1&&--n,n*6<1?t+(e-t)*6*n:n*2<1?e:n*3<2?t+(e-t)*(4-n*6):t}function u(e,t,n){if(!n){let e=Math.round(t*255);return a(e,e,e)}let r=t<.5?t*(1+n):t+n-t*n,i=2*t-r;return a(c(0,255,Math.round(l(r,i,e+1/3)*255)),c(0,255,Math.round(l(r,i,e)*255)),c(0,255,Math.round(l(r,i,e-1/3)*255)))}function d(e,t,n){return(4278190080|Math.round(n/100*255)<<16|Math.round(t/100*255)<<8|Math.round(e/100*255))>>>0}e.normalizeRGB=d;function f(e,t,n){return u((e+240)/360,t/100,n/100)}e.normalizeHLS=f,e.PALETTE_VT340_COLOR=new Uint32Array([d(0,0,0),d(20,20,80),d(80,13,13),d(20,80,20),d(80,20,80),d(20,80,80),d(80,80,20),d(53,53,53),d(26,26,26),d(33,33,60),d(60,26,26),d(33,60,33),d(60,33,60),d(33,60,60),d(60,60,33),d(80,80,80)]),e.PALETTE_VT340_GREY=new Uint32Array([d(0,0,0),d(13,13,13),d(26,26,26),d(40,40,40),d(6,6,6),d(20,20,20),d(33,33,33),d(46,46,46),d(0,0,0),d(13,13,13),d(26,26,26),d(40,40,40),d(6,6,6),d(20,20,20),d(33,33,33),d(46,46,46)]),e.PALETTE_ANSI_256=(()=>{let e=[a(0,0,0),a(205,0,0),a(0,205,0),a(205,205,0),a(0,0,238),a(205,0,205),a(0,250,205),a(229,229,229),a(127,127,127),a(255,0,0),a(0,255,0),a(255,255,0),a(92,92,255),a(255,0,255),a(0,255,255),a(255,255,255)],t=[0,95,135,175,215,255];for(let n=0;n<6;++n)for(let r=0;r<6;++r)for(let i=0;i<6;++i)e.push(a(t[n],t[r],t[i]));for(let t=8;t<=238;t+=10)e.push(a(t,t,t));return new Uint32Array(e)})(),e.DEFAULT_BACKGROUND=a(0,0,0,255),e.DEFAULT_FOREGROUND=a(255,255,255,255)})),TM=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LIMITS=void 0,e.LIMITS={CHUNK_SIZE:16384,PALETTE_SIZE:4096,MAX_WIDTH:16384,BYTES:`AGFzbQEAAAABJAdgAAF/YAJ/fwBgA39/fwF/YAF/AX9gAABgBH9/f38AYAF/AAIlAgNlbnYLaGFuZGxlX2JhbmQAAwNlbnYLbW9kZV9wYXJzZWQAAwMTEgQAAAAAAQQBAQUBAAACAgAGAwQFAXABBwcFBAEBBwcGCAF/AUGAihoLB9wBDgZtZW1vcnkCABFnZXRfc3RhdGVfYWRkcmVzcwADEWdldF9jaHVua19hZGRyZXNzAAQOZ2V0X3AwX2FkZHJlc3MABRNnZXRfcGFsZXR0ZV9hZGRyZXNzAAYEaW5pdAALBmRlY29kZQAMDWN1cnJlbnRfd2lkdGgADQ5jdXJyZW50X2hlaWdodAAOGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtfaW5pdGlhbGl6ZQACCXN0YWNrU2F2ZQARDHN0YWNrUmVzdG9yZQASCnN0YWNrQWxsb2MAEwkMAQBBAQsGCgcJDxACDAEBCq5UEgMAAQsFAEGgCAsGAEGQiQELBgBBsIkCCwUAQZAJC+okAQh/QeQIKAIAIQVB4AgoAgAhA0HoCCgCACEIIAFBkIkBaiIJQf8BOgAAIAAgAUgEQCAAQZCJAWohBgNAIAMhBCAGQQFqIQECQCAGLQAAQf8AcSIDQTBrQQlLBEAgASEGDAELQewIKAIAQQJ0QewIaiICKAIAIQADQCACIAMgAEEKbGpBMGsiADYCACABLQAAIQMgAUEBaiIGIQEgA0H/AHEiA0Ewa0EKSQ0ACwsCQAJAAkACQAJAAkACQAJ/AkACQCADQT9rIgBBP00EQCAERQ0BIARBIUYEQAJAQfAIKAIAIgFBASABGyIHIAhqIgFB1AgoAgAiA0gNACADQf//AEoNAANAIANBAnQiAkGgiQJqIgRBoAgpAwA3AwAgAkGoiQJqQaAIKQMANwMAIAJBsIkCakGgCCkDADcDACACQbiJAmpBoAgpAwA3AwAgAkHAiQJqQaAIKQMANwMAIAJByIkCakGgCCkDADcDACACQdCJAmpBoAgpAwA3AwAgAkHYiQJqQaAIKQMANwMAIAJB4IkCakGgCCkDADcDACACQeiJAmpBoAgpAwA3AwAgAkHwiQJqQaAIKQMANwMAIAJB+IkCakGgCCkDADcDACACQYCKAmpBoAgpAwA3AwAgAkGIigJqQaAIKQMANwMAIAJBkIoCakGgCCkDADcDACACQZiKAmpBoAgpAwA3AwAgAkGgigJqQaAIKQMANwMAIAJBqIoCakGgCCkDADcDACACQbCKAmpBoAgpAwA3AwAgAkG4igJqQaAIKQMANwMAIAJBwIoCakGgCCkDADcDACACQciKAmpBoAgpAwA3AwAgAkHQigJqQaAIKQMANwMAIAJB2IoCakGgCCkDADcDACACQeCKAmpBoAgpAwA3AwAgAkHoigJqQaAIKQMANwMAIAJB8IoCakGgCCkDADcDACACQfiKAmpBoAgpAwA3AwAgAkGAiwJqQaAIKQMANwMAIAJBiIsCakGgCCkDADcDACACQZCLAmpBoAgpAwA3AwAgAkGYiwJqQaAIKQMANwMAIAJBoIsCakGgCCkDADcDACACQaiLAmpBoAgpAwA3AwAgAkGwiwJqQaAIKQMANwMAIAJBuIsCakGgCCkDADcDACACQcCLAmpBoAgpAwA3AwAgAkHIiwJqQaAIKQMANwMAIAJB0IsCakGgCCkDADcDACACQdiLAmpBoAgpAwA3AwAgAkHgiwJqQaAIKQMANwMAIAJB6IsCakGgCCkDADcDACACQfCLAmpBoAgpAwA3AwAgAkH4iwJqQaAIKQMANwMAIAJBgIwCakGgCCkDADcDACACQYiMAmpBoAgpAwA3AwAgAkGQjAJqQaAIKQMANwMAIAJBmIwCakGgCCkDADcDACACQaCMAmpBoAgpAwA3AwAgAkGojAJqQaAIKQMANwMAIAJBsIwCakGgCCkDADcDACACQbiMAmpBoAgpAwA3AwAgAkHAjAJqQaAIKQMANwMAIAJByIwCakGgCCkDADcDACACQdCMAmpBoAgpAwA3AwAgAkHYjAJqQaAIKQMANwMAIAJB4IwCakGgCCkDADcDACACQeiMAmpBoAgpAwA3AwAgAkHwjAJqQaAIKQMANwMAIAJB+IwCakGgCCkDADcDACACQYCNAmpBoAgpAwA3AwAgAkGIjQJqQaAIKQMANwMAIAJBkI0CakGgCCkDADcDACACQZiNAmpBoAgpAwA3AwAgAkGwiQZqIARBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBEGABPwKAABB1AgoAgBBAnRB0IkOaiAEQYAE/AoAAEHUCCgCAEECdEHgiRJqIARBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBEGABPwKAABB1AhB1AgoAgAiAkGAAWoiAzYCACABIANIDQEgAkGA/wBIDQALCwJAIABFDQAgCEH//wBLDQBBgIABIAhrIAcgAUH//wBLGyECAkAgAEEBcUUNACACRQ0AIAhBAnRBoIkCaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBAnFFDQAgAkUNACAIQQJ0QbCJBmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsCQCAAQQRxRQ0AIAJFDQAgCEECdEHAiQpqIQMgAiEEIAJBB3EiBwRAA0AgAyAFNgIAIANBBGohAyAEQQFrIQQgB0EBayIHDQALCyACQQFrQQdJDQADQCADIAU2AhwgAyAFNgIYIAMgBTYCFCADIAU2AhAgAyAFNgIMIAMgBTYCCCADIAU2AgQgAyAFNgIAIANBIGohAyAEQQhrIgQNAAsLAkAgAEEIcUUNACACRQ0AIAhBAnRB0IkOaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBEHFFDQAgAkUNACAIQQJ0QeCJEmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsgAEEgcUUNACACRQ0AIAJBAWshByAIQQJ0QfCJFmohAyACQQdxIgQEQANAIAMgBTYCACADQQRqIQMgAkEBayECIARBAWsiBA0ACwsgB0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgAkEIayICDQALC0HcCEHcCCgCACAAcjYCACAGQQFqIgIgBi0AAEH/AHEiA0E/ayIAQT9LDQQaDAMLAkBB7AgoAgAiBEEBRgRAQfAIKAIAIgNBzAgoAgAiAUkNASADIAFwIQMMAQtB+AgoAgAhAkH0CCgCACEBAkACQCAEQQVHDQAgAUEBRw0AIAJB6QJODQQMAQsgAkHkAEoNA0H8CCgCAEHkAEoNA0GACSgCAEHkAEoNAwsCQCABRQ0AIAFBAkoNACACQfwIKAIAQYAJKAIAIAFBAnRBiAhqKAIAEQIAIQFB8AgoAgAiA0HMCCgCACICTwR/IAMgAnAFIAMLQQJ0QZAJaiABNgIAC0HwCCgCACIDQcwIKAIAIgFJDQAgAyABcCEDCyADQQJ0QZAJaigCACEFDAELIANB/QBxQSFHBEAgCCEBIAYhAgwECyAEQSNHDQQCQEHsCCgCACICQQFGBEBB8AgoAgAiAUHMCCgCACIASQ0BIAEgAHAhAQwBC0H4CCgCACEBQfQIKAIAIQACQAJAIAJBBUcNACAAQQFHDQAgAUHpAkgNAQwHCyABQeQASg0GQfwIKAIAQeQASg0GQYAJKAIAQeQASg0GCwJAIABFDQAgAEECSg0AIAFB/AgoAgBBgAkoAgAgAEECdEGICGooAgARAgAhAEHwCCgCACIBQcwIKAIAIgJPBH8gASACcAUgAQtBAnRBkAlqIAA2AgALQfAIKAIAIgFBzAgoAgAiAEkNACABIABwIQELIAFBAnRBkAlqKAIAIQUMBAsgCCEBIAYhAgtB1AgoAgAhBgNAAkAgASAGSA0AIAZB//8ASg0AIAZBAnQiBEGgiQJqIgZBoAgpAwA3AwAgBEGoiQJqQaAIKQMANwMAIARBsIkCakGgCCkDADcDACAEQbiJAmpBoAgpAwA3AwAgBEHAiQJqQaAIKQMANwMAIARByIkCakGgCCkDADcDACAEQdCJAmpBoAgpAwA3AwAgBEHYiQJqQaAIKQMANwMAIARB4IkCakGgCCkDADcDACAEQeiJAmpBoAgpAwA3AwAgBEHwiQJqQaAIKQMANwMAIARB+IkCakGgCCkDADcDACAEQYCKAmpBoAgpAwA3AwAgBEGIigJqQaAIKQMANwMAIARBkIoCakGgCCkDADcDACAEQZiKAmpBoAgpAwA3AwAgBEGgigJqQaAIKQMANwMAIARBqIoCakGgCCkDADcDACAEQbCKAmpBoAgpAwA3AwAgBEG4igJqQaAIKQMANwMAIARBwIoCakGgCCkDADcDACAEQciKAmpBoAgpAwA3AwAgBEHQigJqQaAIKQMANwMAIARB2IoCakGgCCkDADcDACAEQeCKAmpBoAgpAwA3AwAgBEHoigJqQaAIKQMANwMAIARB8IoCakGgCCkDADcDACAEQfiKAmpBoAgpAwA3AwAgBEGAiwJqQaAIKQMANwMAIARBiIsCakGgCCkDADcDACAEQZCLAmpBoAgpAwA3AwAgBEGYiwJqQaAIKQMANwMAIARBoIsCakGgCCkDADcDACAEQaiLAmpBoAgpAwA3AwAgBEGwiwJqQaAIKQMANwMAIARBuIsCakGgCCkDADcDACAEQcCLAmpBoAgpAwA3AwAgBEHIiwJqQaAIKQMANwMAIARB0IsCakGgCCkDADcDACAEQdiLAmpBoAgpAwA3AwAgBEHgiwJqQaAIKQMANwMAIARB6IsCakGgCCkDADcDACAEQfCLAmpBoAgpAwA3AwAgBEH4iwJqQaAIKQMANwMAIARBgIwCakGgCCkDADcDACAEQYiMAmpBoAgpAwA3AwAgBEGQjAJqQaAIKQMANwMAIARBmIwCakGgCCkDADcDACAEQaCMAmpBoAgpAwA3AwAgBEGojAJqQaAIKQMANwMAIARBsIwCakGgCCkDADcDACAEQbiMAmpBoAgpAwA3AwAgBEHAjAJqQaAIKQMANwMAIARByIwCakGgCCkDADcDACAEQdCMAmpBoAgpAwA3AwAgBEHYjAJqQaAIKQMANwMAIARB4IwCakGgCCkDADcDACAEQeiMAmpBoAgpAwA3AwAgBEHwjAJqQaAIKQMANwMAIARB+IwCakGgCCkDADcDACAEQYCNAmpBoAgpAwA3AwAgBEGIjQJqQaAIKQMANwMAIARBkI0CakGgCCkDADcDACAEQZiNAmpBoAgpAwA3AwAgBEGwiQZqIAZBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBkGABPwKAABB1AgoAgBBAnRB0IkOaiAGQYAE/AoAAEHUCCgCAEECdEHgiRJqIAZBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBkGABPwKAABB1AhB1AgoAgBBgAFqIgY2AgALIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiAFNgIAIABBAXZBAXEgAWxBAnRBsIkGaiAFNgIAIABBAnZBAXEgAWxBAnRBwIkKaiAFNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiAFNgIAIABBBHZBAXEgAWxBAnRB4IkSaiAFNgIAIABBBXYgAWxBAnRB8IkWaiAFNgIAQdQIKAIAIQYLIAFBAWohAUHcCEHcCCgCACAAcjYCACACLQAAIQAgAkEBaiIEIQIgAEH/AHEiA0E/ayIAQcAASQ0ACyAECyECQQAhBCACIQYgASEIIANB/QBxQSFGDQELIANBJGsOCgEDAwMDAwMDAwIDC0HsCEIBNwIADAQLQdgIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbNgIADAILQegIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbIgA2AgBB2AggADYCACAAQQRrEAAEQEHoCEEENgIAQdgIQQQ2AgBB0AhBATYCAA8LEAgMAQsCQCADQTtHDQBB7AgoAgAiAEEHSg0AQewIIABBAWo2AgAgAEECdEHwCGpBADYCAAsgAiEGIAQhAyABIQgMAQtBBCEIIAIhBiAEIQMLIAYgCUkNAAsLQeQIIAU2AgBB4AggAzYCAEHoCCAINgIAC9ELAgF+CH9B2AhCBDcDAEGojQJBoAgpAwAiADcDAEGgjQIgADcDAEGYjQIgADcDAEGQjQIgADcDAEGIjQIgADcDAEGAjQIgADcDAEH4jAIgADcDAEHwjAIgADcDAEHojAIgADcDAEHgjAIgADcDAEHYjAIgADcDAEHQjAIgADcDAEHIjAIgADcDAEHAjAIgADcDAEG4jAIgADcDAEGwjAIgADcDAEGojAIgADcDAEGgjAIgADcDAEGYjAIgADcDAEGQjAIgADcDAEGIjAIgADcDAEGAjAIgADcDAEH4iwIgADcDAEHwiwIgADcDAEHoiwIgADcDAEHgiwIgADcDAEHYiwIgADcDAEHQiwIgADcDAEHIiwIgADcDAEHAiwIgADcDAEG4iwIgADcDAEGwiwIgADcDAEGoiwIgADcDAEGgiwIgADcDAEGYiwIgADcDAEGQiwIgADcDAEGIiwIgADcDAEGAiwIgADcDAEH4igIgADcDAEHwigIgADcDAEHoigIgADcDAEHgigIgADcDAEHYigIgADcDAEHQigIgADcDAEHIigIgADcDAEHAigIgADcDAEG4igIgADcDAEGwigIgADcDAEGoigIgADcDAEGgigIgADcDAEGYigIgADcDAEGQigIgADcDAEGIigIgADcDAEGAigIgADcDAEH4iQIgADcDAEHwiQIgADcDAEHoiQIgADcDAEHgiQIgADcDAEHYiQIgADcDAEHQiQIgADcDAEHIiQIgADcDAEHAiQIgADcDAEG4iQIgADcDAEGwiQIgADcDAEGoCCgCACIEQf8AakGAAW0hCAJAIARBgQFIDQBBASEBIAhBAiAIQQJKG0EBayICQQFxIQMgBEGBAk4EQCACQX5xIQIDQCABQQl0IgdBEHJBoIkCakGwiQJBgAT8CgAAIAdBsI0CakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsLIANFDQAgAUEJdEEQckGgiQJqQbCJAkGABPwKAAALAkAgBEEBSA0AIAhBASAIQQFKGyIDQQFxIQUCQCADQQFrIgdFBEBBACEBDAELIANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQbCJBmpBsIkCQYAE/AoAACAGQZAEckGwiQZqQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACwsgBQRAIAFBCXRBEHJBsIkGakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEFIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiBkEQckHAiQpqQbCJAkGABPwKAAAgBkGQBHJBwIkKakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAFBEAgAUECdEHAiQpqQbCJAkGABPwKAAALIARBAUgNACADQQFxIQUgBwR/IANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQdCJDmpBsIkCQYAE/AoAACAGQZAEckHQiQ5qQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACyABQQd0QQRyBUEECyEBIAUEQCABQQJ0QdCJDmpBsIkCQYAE/AoAAAsgBEEBSA0AIANBAXEhBSAHBH8gA0H+////B3EhAkEAIQEDQCABQQl0IgZBEHJB4IkSakGwiQJBgAT8CgAAIAZBkARyQeCJEmpBsIkCQYAE/AoAACABQQJqIQEgAkECayICDQALIAFBB3RBBHIFQQQLIQEgBQRAIAFBAnRB4IkSakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEEIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiA0EQckHwiRZqQbCJAkGABPwKAAAgA0GQBHJB8IkWakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAERQ0AIAFBAnRB8IkWakGwiQJBgAT8CgAAC0HUCCAIQQd0QQRyNgIAC58TAgh/AX5B5AgoAgAhA0HgCCgCACECQegIKAIAIQcgAUGQiQFqIglB/wE6AAAgACABSARAIABBkIkBaiEIA0AgAiEEIAhBAWohAQJAIAgtAABB/wBxIgJBMGtBCUsEQCABIQgMAQtB7AgoAgBBAnRB7AhqIgUoAgAhAANAIAUgAiAAQQpsakEwayIANgIAIAEtAAAhAiABQQFqIgghASACQf8AcSICQTBrQQpJDQALCwJAAkACQAJAAkACQAJ/AkAgAkE/ayIAQT9NBEAgBEUNASAEQSFGBEBB8AgoAgAiAUEBIAEbIgQgB2ohAQJAIABFDQAgB0H//wBLDQBBgIABIAdrIAQgAUH//wBLGyEFAkAgAEEBcUUNACAHQQJ0QaCJAmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEECcUUNACAHQQJ0QbCJBmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEEcUUNACAHQQJ0QcCJCmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEIcUUNACAHQQJ0QdCJDmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEQcUUNACAHQQJ0QeCJEmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLIABBIHFFDQAgBUEBayEEIAdBAnRB8IkWaiEAIAVBB3EiAgRAA0AgACADNgIAIABBBGohACAFQQFrIQUgAkEBayICDQALCyAEQQdJDQADQCAAIAM2AhwgACADNgIYIAAgAzYCFCAAIAM2AhAgACADNgIMIAAgAzYCCCAAIAM2AgQgACADNgIAIABBIGohACAFQQhrIgUNAAsLIAhBAWoiBSAILQAAQf8AcSICQT9rIgBBP00NAxoMBAsCQEHsCCgCACIFQQFGBEBB8AgoAgAiAUHMCCgCACIESQ0BIAEgBHAhAQwBC0H4CCgCACEEQfQIKAIAIQECQAJAIAVBBUcNACABQQFHDQAgBEHpAk4NBAwBCyAEQeQASg0DQfwIKAIAQeQASg0DQYAJKAIAQeQASg0DCwJAIAFFDQAgAUECSg0AIARB/AgoAgBBgAkoAgAgAUECdEGICGooAgARAgAhBEHwCCgCACIBQcwIKAIAIgVPBH8gASAFcAUgAQtBAnRBkAlqIAQ2AgALQfAIKAIAIgFBzAgoAgAiBEkNACABIARwIQELIAFBAnRBkAlqKAIAIQMMAQsgAkH9AHFBIUcEQCAHIQEgAiEADAQLIARBI0cNBAJAQewIKAIAIgRBAUYEQEHwCCgCACIBQcwIKAIAIgBJDQEgASAAcCEBDAELQfgIKAIAIQFB9AgoAgAhAAJAAkAgBEEFRw0AIABBAUcNACABQekCSA0BDAcLIAFB5ABKDQZB/AgoAgBB5ABKDQZBgAkoAgBB5ABKDQYLAkAgAEUNACAAQQJKDQAgAUH8CCgCAEGACSgCACAAQQJ0QYgIaigCABECACEAQfAIKAIAIgFBzAgoAgAiBE8EfyABIARwBSABC0ECdEGQCWogADYCAAtB8AgoAgAiAUHMCCgCACIASQ0AIAEgAHAhAQsgAUECdEGQCWooAgAhAwwECyAHIQEgCAshBQNAIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiADNgIAIABBAXZBAXEgAWxBAnRBsIkGaiADNgIAIABBAnZBAXEgAWxBAnRBwIkKaiADNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiADNgIAIABBBHZBAXEgAWxBAnRB4IkSaiADNgIAIABBBXYgAWxBAnRB8IkWaiADNgIACyABQQFqIQEgBS0AACEAIAVBAWoiBCEFIABB/wBxIgJBP2siAEHAAEkNAAsgBCEFC0EAIQQgBSEIIAEhByACIQAgAkH9AHFBIUYNAQtBBCEHIAQhAiAAQSRrDgoDAgICAgICAgIBAgtB7AhCATcCAAwCC0GoCCgCAEEEaxAABEBB0AhBATYCAA8LAkBBqAgoAgAiBkEFSA0AQaAIKQMAIQogBkEDa0EBdiIBQQdxIQJBACEAIAFBAWtBB08EQCABQfj///8HcSEFA0AgAEEDdCIBQbCJAmogCjcDACABQQhyQbCJAmogCjcDACABQRByQbCJAmogCjcDACABQRhyQbCJAmogCjcDACABQSByQbCJAmogCjcDACABQShyQbCJAmogCjcDACABQTByQbCJAmogCjcDACABQThyQbCJAmogCjcDACAAQQhqIQAgBUEIayIFDQALCyACRQ0AA0AgAEEDdEGwiQJqIAo3AwAgAEEBaiEAIAJBAWsiAg0ACwtBwIkGQbCJAiAGQQJ0IgD8CgAAQdCJCkGwiQIgAPwKAABB4IkOQbCJAiAA/AoAAEHwiRJBsIkCIAD8CgAAQYCKFkGwiQIgAPwKAAAgBCECDAELAkAgAEE7Rw0AQewIKAIAIgBBB0oNAEHsCCAAQQFqNgIAIABBAnRB8AhqQQA2AgALIAEhBwsgCCAJSQ0ACwtB5AggAzYCAEHgCCACNgIAQegIIAc2AgAL4gcCBX8BfgJAQdAIAn8CQAJAIAAgAU4NACABQZCJAWohBiAAQZCJAWohBQNAIAUtAAAiA0H/AHEhAgJAAkACQAJAAkACQAJAQeAIKAIAIgRBIkcEQCAEDQcgAkEiRgRAQewIQgE3AgBB4AhBIjYCAAwICyACQT9rQcAASQ0GIANBIWsiAkEMTQ0BDAULAkAgAkEwayIEQQlNBEBB7AgoAgBBAnRB7AhqIgIgBCACKAIAQQpsajYCAAwBC0HsCCgCACEEIAJBO0YEQCAEQQdKDQFB7AggBEEBajYCACAEQQJ0QfAIakEANgIADAELIARBBEYEQEHECEECNgIAQbAIQfAIKQMANwMAQbgIQfgIKAIAIgI2AgBBvAhB/AgoAgAiBDYCAEHICEECQQFBwAgoAgAiAxs2AgBBrAggBEEAIAMbNgIAQagIIAJBgIABIAJBgIABSBtBBGpBACADGzYCAEHgCEEANgIADAoLIAJBP2tBwABJDQQLIANBIWsiAkEMTQ0BDAILQQEgAnRBjSBxRQ0DDAQLQQEgAnRBjSBxDQELIANBoQFrIgJBDEsNA0EBIAJ0QY0gcUUNAwtBxAhCgYCAgBA3AgBBsAhB8AgoAgBBAEHsCCgCACICQQBKGzYCAEG0CEH0CCgCAEEAIAJBAUobNgIAQbgIQfgIKAIAQQAgAkECShs2AgBB4AhBADYCAEG8CEEANgIADAQLIANBoQFrIgJBDEsNAUEBIAJ0QY0gcUUNAQtBxAhCgYCAgBA3AgBBsAhCADcDAEG4CEIANwMADAMLIAVBAWoiBSAGSQ0ACwsCQEHICCgCAA4DAwEAAQsCQEGoCCgCACIFQQVIDQBBoAgpAwAhByAFQQNrQQF2IgNBB3EhBEEAIQIgA0EBa0EHTwRAIANB+P///wdxIQYDQCACQQN0IgNBsIkCaiAHNwMAIANBCHJBsIkCaiAHNwMAIANBEHJBsIkCaiAHNwMAIANBGHJBsIkCaiAHNwMAIANBIHJBsIkCaiAHNwMAIANBKHJBsIkCaiAHNwMAIANBMHJBsIkCaiAHNwMAIANBOHJBsIkCaiAHNwMAIAJBCGohAiAGQQhrIgYNAAsLIARFDQADQCACQQN0QbCJAmogBzcDACACQQFqIQIgBEEBayIEDQALC0HAiQZBsIkCIAVBAnQiA/wKAABB0IkKQbCJAiAD/AoAAEHgiQ5BsIkCIAP8CgAAQfCJEkGwiQIgA/wKAABBgIoWQbCJAiAD/AoAAEECDAELEAhByAgoAgALEAEiAjYCACACDQAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLdABB6AhBBDYCAEHkCCAANgIAQewIQgE3AgBBxAhCADcCAEHACCADNgIAQdwIQgA3AgBBqAhCADcDAEGwCEIANwMAQbgIQgA3AwBBzAggAkGAICACQYAgSRs2AgBBoAggAa1CgYCAgBB+NwMAQdAIQQA2AgALIwBB0AgoAgBFBEAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLWgECfwJAAkACQEHICCgCAEEBaw4CAAECC0HYCEHoCCgCACIAQdgIKAIAIgEgACABShsiAEGAgAEgAEGAgAFIGyIANgIAIABBBGsPC0GoCCgCAEEEayEACyAAC0IBAX8Cf0EGQdwIKAIAIgBBIHENABpBBSAAQRBxDQAaQQQgAEEIcQ0AGkEDIABBBHENABpBAiAAQQFxIABBAnEbCwu9BQEFfQJ/IAJFBEAgAUH/AWxBMmpB5ABtIgBBCHQgAHIgAEEQdHIMAQsgArJDAADIQpUhBiAAQfABarJDAAC0Q5UhBQJ9IAGyQwAAyEKVIgNDAAAAP10EQCADIAZDAACAP5KUDAELIAYgA0MAAIA/IAaTlJILIQcgAyADkiEGAkAgBUOrqqo+kiIEQwAAAABdBEAgBEMAAIA/kiEEDAELIARDAACAP15FDQAgBEMAAIC/kiEECyAGIAeTIQMgBUMAAAAAXSEAAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQECQCAABEAgBUMAAIA/kiEEDAELIAUiBEMAAIA/XkUNACAFQwAAgL+SIQQLIAVDq6qqvpIiBUMAAAAAXSECAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQACQCACBEAgBUMAAIA/kiEFDAELIAVDAACAP15FDQAgBUMAAIC/kiEFCwJAIAVDq6oqPl0EQCADIAcgA5NDAADAQJQgBZSSIQcMAQsgBUMAAAA/XQ0AIAVDq6oqP11FBEAgAyEHDAELIAMgByADkyAFQwAAwMCUQwAAgECSlJIhBwsgAEEIdAJ/IAdDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALQRB0ciABcgtBgICAeHILNwAgAEH/AWxBMmpB5ABtIAFB/wFsQTJqQeQAbUEIdHIgAkH/AWxBMmpB5ABtQRB0ckGAgIB4cgsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwsYAQBBgAgLEQEAAAACAAAAAwAAAAQAAAAF`}})),EM=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=wM(),n=TM();function r(e){if(typeof Buffer<`u`)return Buffer.from(e,`base64`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<n.length;++e)n[e]=t.charCodeAt(e);return n}var i=r(n.LIMITS.BYTES),a,o=new Uint32Array,s=class{constructor(){this.bandHandler=e=>1,this.modeHandler=e=>1}handle_band(e){return this.bandHandler(e)}mode_parsed(e){return this.modeHandler(e)}},c={memoryLimit:134217728,sixelColor:t.DEFAULT_FOREGROUND,fillColor:t.DEFAULT_BACKGROUND,palette:t.PALETTE_VT340_COLOR,paletteLimit:n.LIMITS.PALETTE_SIZE,truncate:!0};function l(e){let t=new s,n={env:{handle_band:t.handle_band.bind(t),mode_parsed:t.mode_parsed.bind(t)}};return WebAssembly.instantiate(a||i,n).then(n=>(a||=n.module,new u(e,n.instance||n,t)))}e.DecoderAsync=l;var u=class{constructor(e,r,s){if(this._PIXEL_OFFSET=n.LIMITS.MAX_WIDTH+4,this._canvas=o,this._bandWidths=[],this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},c,e),this._opts.paletteLimit>n.LIMITS.PALETTE_SIZE)throw Error(`DecoderOptions.paletteLimit must not exceed ${n.LIMITS.PALETTE_SIZE}`);if(r)s.bandHandler=this._handle_band.bind(this),s.modeHandler=this._initCanvas.bind(this);else{let e=a||=new WebAssembly.Module(i);r=new WebAssembly.Instance(e,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=r,this._wasm=this._instance.exports,this._chunk=new Uint8Array(this._wasm.memory.buffer,this._wasm.get_chunk_address(),n.LIMITS.CHUNK_SIZE),this._states=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_state_address(),12),this._palette=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_palette_address(),n.LIMITS.PALETTE_SIZE),this._palette.set(this._opts.palette),this._pSrc=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_p0_address()),this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}get _fillColor(){return this._states[0]}get _truncate(){return this._states[8]}get _rasterWidth(){return this._states[6]}get _rasterHeight(){return this._states[7]}get _width(){return this._states[2]?this._states[2]-4:0}get _height(){return this._states[3]}get _level(){return this._states[9]}get _mode(){return this._states[10]}get _paletteLimit(){return this._states[11]}_initCanvas(e){if(e===2){let e=this.width*this.height;if(e>this._canvas.length){if(this._opts.memoryLimit&&e*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);this._canvas=new Uint32Array(e)}this._maxWidth=this._width}else if(e===1){if(this._level===2){let e=Math.min(this._rasterWidth,n.LIMITS.MAX_WIDTH)*this._rasterHeight;if(e>this._canvas.length){if(this._opts.memoryLimit&&e*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);this._canvas=new Uint32Array(e)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536))}return 0}_realloc(e,t){let n=e+t;if(n>this._canvas.length){if(this._opts.memoryLimit&&n*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);let e=new Uint32Array(Math.ceil(n/65536)*65536);e.set(this._canvas),this._canvas=e}}_handle_band(e){let t=this._PIXEL_OFFSET,n=this._lastOffset;if(this._mode===2){let r=this.height-this._currentHeight,i=0;for(;i<6&&r>0;)this._canvas.set(this._pSrc.subarray(t*i,t*i+e),n+e*i),i++,r--;this._lastOffset+=e*i,this._currentHeight+=i}else if(this._mode===1){this._realloc(n,e*6),this._maxWidth=Math.max(this._maxWidth,e),this._minWidth=Math.min(this._minWidth,e);for(let r=0;r<6;++r)this._canvas.set(this._pSrc.subarray(t*r,t*r+e),n+e*r);this._bandWidths.push(e),this._lastOffset+=e*6,this._currentHeight+=6}return 0}get width(){return this._mode===1?Math.max(this._maxWidth,this._wasm.current_width()):this._width}get height(){return this._mode===1?this._wasm.current_width()?this._bandWidths.length*6+this._wasm.current_height():this._bandWidths.length*6:this._height}get palette(){return this._palette.subarray(0,this._paletteLimit)}get memoryUsage(){return this._canvas.byteLength+this._wasm.memory.buffer.byteLength+8*this._bandWidths.length}get properties(){return{width:this.width,height:this.height,mode:this._mode,level:this._level,truncate:!!this._truncate,paletteLimit:this._paletteLimit,fillColor:this._fillColor,memUsage:this.memoryUsage,rasterAttributes:{numerator:this._states[4],denominator:this._states[5],width:this._rasterWidth,height:this._rasterHeight}}}init(e=this._opts.fillColor,t=this._opts.palette,r=this._opts.paletteLimit,i=this._opts.truncate){this._wasm.init(this._opts.sixelColor,e,r,+!!i),t&&this._palette.set(t.subarray(0,n.LIMITS.PALETTE_SIZE)),this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0}decode(e,t=0,r=e.length){let i=t;for(;i<r;){let t=Math.min(r-i,n.LIMITS.CHUNK_SIZE);this._chunk.set(e.subarray(i,i+=t)),this._wasm.decode(0,t)}}decodeString(e,t=0,r=e.length){let i=t;for(;i<r;){let t=Math.min(r-i,n.LIMITS.CHUNK_SIZE);for(let n=0,r=i;n<t;++n,++r)this._chunk[n]=e.charCodeAt(r);i+=t,this._wasm.decode(0,t)}}get data32(){if(this._mode===0||!this.width||!this.height)return o;let e=this._wasm.current_width();if(this._mode===2){let t=this.height-this._currentHeight;if(t>0){let n=this._PIXEL_OFFSET,r=this._lastOffset,i=0;for(;i<6&&t>0;)this._canvas.set(this._pSrc.subarray(n*i,n*i+e),r+e*i),i++,t--;t&&this._canvas.fill(this._fillColor,r+e*i)}return this._canvas.subarray(0,this.width*this.height)}if(this._mode===1){if(this._minWidth===this._maxWidth){let t=!1;if(e){if(e!==this._minWidth)t=!0;else{let t=this._PIXEL_OFFSET,n=this._lastOffset;this._realloc(n,e*6);for(let r=0;r<6;++r)this._canvas.set(this._pSrc.subarray(t*r,t*r+e),n+e*r)}}if(!t)return this._canvas.subarray(0,this.width*this.height)}let t=new Uint32Array(this.width*this.height);t.fill(this._fillColor);let n=0,r=0;for(let e=0;e<this._bandWidths.length;++e){let i=this._bandWidths[e];for(let e=0;e<6;++e)t.set(this._canvas.subarray(r,r+=i),n),n+=this.width}if(e){let r=this._PIXEL_OFFSET,i=this._wasm.current_height();for(let a=0;a<i;++a)t.set(this._pSrc.subarray(r*a,r*a+e),n+this.width*a)}return t}return o}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=o,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};e.Decoder=u;function d(e,t){let n=new u(t);return n.init(),typeof e==`string`?n.decodeString(e):n.decode(e),{width:n.width,height:n.height,data32:n.data32,data8:n.data8}}e.decode=d;async function f(e,t){let n=await l(t);return n.init(),typeof e==`string`?n.decodeString(e):n.decode(e),{width:n.width,height:n.height,data32:n.data32,data8:n.data8}}e.decodeAsync=f})),DM=wM(),OM=EM(),kM=DM.PALETTE_ANSI_256.slice();kM.set(DM.PALETTE_VT340_COLOR);var AM=200,jM=new TextEncoder,MM=`offsite-image:`;async function NM(e){let t=await(0,OM.decodeAsync)(e,{fillColor:0,palette:kM});return!t.width||!t.height?null:createImageBitmap(new ImageData(new Uint8ClampedArray(t.data8),t.width,t.height))}function PM(e,t,n){return e===void 0||e===`auto`?0:e.endsWith(`%`)?parseInt(e.slice(0,-1))*t/100:e.endsWith(`px`)?parseInt(e.slice(0,-2)):parseInt(e)*n}async function FM(e,t){let n=e.indexOf(`:`);if(n===-1)return null;let r=new Map(e.slice(0,n).split(`;`).map(e=>{let t=e.indexOf(`=`);return[e.slice(0,t),e.slice(t+1)]}));if(r.get(`inline`)!==`1`)return null;let i=Uint8Array.from(atob(e.slice(n+1)),e=>e.charCodeAt(0)),a=await createImageBitmap(new Blob([i])),o=PM(r.get(`width`),t.width,t.cellWidth),s=PM(r.get(`height`),t.height,t.cellHeight),c=[a.width,a.height];if(!o&&!s){let e=Math.min(t.width/a.width,(t.height-t.cellHeight)/a.height);e<1&&(c=[a.width*e,a.height*e])}else c=o?r.get(`preserveAspectRatio`)!==`0`||!s?[o,a.height*o/a.width]:[o,s]:[a.width*s/a.height,s];let[l,u]=c.map(e=>Math.max(1,Math.floor(e*t.pixelRatio))),d=await createImageBitmap(a,{resizeWidth:l,resizeHeight:u});return a.close(),d}function IM(e){let t=CM(e),{width:n,height:r,depth:i,channels:a}=t,o=n*r,s=new Uint8Array(o*4);if(t.palette){let e=xM(t),i=t.palette[0].length;for(let t=0;t<o;t+=1)s.set(e.subarray(t*i,t*i+3),t*4),s[t*4+3]=i===4?e[t*i+3]:255;return{width:n,height:r,data:s}}let c=2**i-1,l=Math.ceil(n*i/8);function u(e){if(i>=8)return t.data[e];let r=e%n*i;return t.data[Math.floor(e/n)*l+(r>>3)]>>8-i-(r&7)&c}function d(e){return i===16?e>>8:i===8?e:Math.round(e*255/c)}let f=t.transparency;for(let e=0;e<o;e+=1){let t=e*4;if(a===1||a===2){let n=u(e*a);s.fill(d(n),t,t+3),s[t+3]=a===2?d(u(e*2+1)):f?.[0]===n?0:255}else if(a===3||a===4){let n=u(e*a),r=u(e*a+1),i=u(e*a+2);s[t]=d(n),s[t+1]=d(r),s[t+2]=d(i),s[t+3]=a===4?d(u(e*4+3)):f?.[0]===n&&f[1]===r&&f[2]===i?0:255}else throw Error(`unsupported PNG with ${a} channels`)}return{width:n,height:r,data:s}}var LM=class{core;images=[];nextImage=0;constructor(e){this.core=e}place(e,t,n){let r=`${MM}${this.nextImage++}`;this.core.write(jM.encode(`\x1b]8;;${r}\x1b\\ \x1b]8;;\x1b\\\b`));let i={ref:this.core.trackCursor(),marker:r,bitmap:e,width:e.width/t,height:e.height/t,alternate:this.core.isAlternateScreen()};if(this.images.push(i),this.images.length>AM){let e=this.images.shift();e&&this.remove(e)}let a=Math.ceil(i.height/n);a>1&&this.core.write(jM.encode(`\x1BD`.repeat(a-1)))}visible(e,t,n){if(this.images.length===0)return[];let r=this.core.isAlternateScreen(),i=[],a=[];for(let o of this.images){if(o.alternate!==r){a.push(o);continue}let s=this.core.trackedPoint(o.ref);if(s===null||this.core.trackedHyperlink(o.ref)!==o.marker){this.remove(o);continue}a.push(o);let c=s.y-e;c+Math.ceil(o.height/n)<=0||c>=t||i.push({bitmap:o.bitmap,width:o.width,height:o.height,x:s.x,y:c})}return this.images=a,i}clear(){for(let e of this.images)this.remove(e);this.images=[]}remove(e){this.core.untrack(e.ref),e.bitmap.close()}},RM=Fe.withTag(`terminal`),zM=new Uint8Array([0,97,115,109,1,0,0,0,1,35,5,96,4,127,127,127,127,0,96,3,127,127,127,1,127,96,2,127,127,0,96,3,127,127,127,0,96,5,127,127,127,127,127,1,127,2,49,6,3,101,110,118,1,119,0,0,3,101,110,118,1,100,0,1,3,101,110,118,1,115,0,1,3,101,110,118,1,98,0,2,3,101,110,118,1,118,0,3,3,101,110,118,1,112,0,4,7,25,6,1,119,0,0,1,100,0,1,1,115,0,2,1,98,0,3,1,118,0,4,1,112,0,5]),BM={userdata:0,writePty:1,bell:2,xtversion:4,size:6,deviceAttributes:8},VM=1,HM=-3,UM={width:0,height:4,data:8,length:12},WM=new TextDecoder,GM=new TextEncoder,KM=class e{memory;layouts;exports;memoryView;hosts=new Map;nextHostId=1;callbacks={writePty:0,deviceAttributes:0,size:0,bell:0,xtversion:0};version={pointer:0,size:0};constructor(e){this.exports=e.exports;let t=e.exports.memory;if(!(t instanceof WebAssembly.Memory))throw Error(`libghostty-vt did not export its memory`);this.memory=t,this.memoryView=new DataView(t.buffer);let n=this.call(`ghostty_type_json`),r=new Uint8Array(t.buffer),i=n;for(;i<r.length&&r[i]!==0;)i+=1;this.layouts=JSON.parse(WM.decode(r.subarray(n,i)))}static async load(){let t=await fetch(KA);if(!t.ok)throw Error(`could not load libghostty-vt (${t.status})`);let n=null,r=await WebAssembly.instantiate(await t.arrayBuffer(),{env:{log:(e,t)=>{n&&RM.debug(`[libghostty-vt]`,WM.decode(new Uint8Array(n.buffer,e,t)))}}}),i=new e(r.instance);return n=i.memory,i.installCallbacks(),i}call(e,...t){let n=this.exports[e];if(typeof n!=`function`)throw Error(`libghostty-vt export is missing: ${e}`);return n(...t)}layout(e){let t=this.layouts[e];if(!t)throw Error(`libghostty-vt layout is missing: ${e}`);return t}field(e,t){let n=this.layout(e).fields[t];if(!n)throw Error(`libghostty-vt field is missing: ${e}.${t}`);return n}alloc(e){let t=this.call(`ghostty_wasm_alloc_u8_array`,e);if(t===0)throw Error(`libghostty-vt could not allocate ${e} bytes`);return new Uint8Array(this.memory.buffer,t,e).fill(0),t}free(e,t){e!==0&&this.call(`ghostty_wasm_free_u8_array`,e,t)}allocOpaque(){let e=this.call(`ghostty_wasm_alloc_opaque`);if(e===0)throw Error(`libghostty-vt could not allocate a pointer`);return new DataView(this.memory.buffer).setUint32(e,0,!0),e}freeOpaque(e){e!==0&&this.call(`ghostty_wasm_free_opaque`,e)}readPointer(e){return this.dataView().getUint32(e,!0)}check(e,t){if(t!==0)throw Error(`${e} failed with result ${t}`)}flag(e,t,n){let r=this.alloc(1),i=this.call(e,t,n,r),a=this.bytes(r,1)[0];return this.free(r,1),i===0&&a!==0}encodeOutput(e){let t=this.call(`ghostty_wasm_alloc_usize`),n=``,r=e(0,0,t),i=this.view(t,4).getUint32(0,!0);if(r===HM&&i>0){let r=this.alloc(i),a=e(r,i,t),o=this.view(t,4).getUint32(0,!0);a===0&&(n=WM.decode(this.bytes(r,o))),this.free(r,i)}return this.call(`ghostty_wasm_free_usize`,t),n}attachHost(e,t){let n=this.nextHostId++;this.hosts.set(n,t),this.call(`ghostty_terminal_set`,e,BM.userdata,n);for(let t of[[BM.writePty,this.callbacks.writePty],[BM.deviceAttributes,this.callbacks.deviceAttributes],[BM.size,this.callbacks.size],[BM.bell,this.callbacks.bell],[BM.xtversion,this.callbacks.xtversion]])this.call(`ghostty_terminal_set`,e,t[0],t[1]);return n}detachHost(e,t){this.call(`ghostty_terminal_set`,e,BM.xtversion,0),this.call(`ghostty_terminal_set`,e,BM.bell,0),this.call(`ghostty_terminal_set`,e,BM.size,0),this.call(`ghostty_terminal_set`,e,BM.deviceAttributes,0),this.call(`ghostty_terminal_set`,e,BM.writePty,0),this.call(`ghostty_terminal_set`,e,BM.userdata,0),this.hosts.delete(t)}view(e,t){return new DataView(this.memory.buffer,e,t)}bytes(e,t){return new Uint8Array(this.memory.buffer,e,t)}dataView(){return this.memoryView.buffer!==this.memory.buffer&&(this.memoryView=new DataView(this.memory.buffer)),this.memoryView}setField(e,t,n,r){let i=this.field(t,n),a=this.dataView(),o=e+i.offset;if(i.type===`bool`||i.type===`u8`)a.setUint8(o,r);else if(i.type===`u16`)a.setUint16(o,r,!0);else if(i.type===`i32`)a.setInt32(o,r,!0);else if(i.type===`u32`||i.type===`enum`)a.setUint32(o,r,!0);else if(i.type===`u64`)a.setBigUint64(o,BigInt(r),!0);else throw Error(`unsupported libghostty-vt field type ${i.type}`)}readField(e,t,n){let r=this.field(t,n),i=this.dataView(),a=e+r.offset;if(r.type===`bool`||r.type===`u8`)return i.getUint8(a);if(r.type===`u16`)return i.getUint16(a,!0);if(r.type===`i32`)return i.getInt32(a,!0);if(r.type===`u32`||r.type===`enum`)return i.getUint32(a,!0);if(r.type===`u64`)return Number(i.getBigUint64(a,!0));throw Error(`unsupported libghostty-vt field type ${r.type}`)}installCallbacks(){let e=new WebAssembly.Instance(new WebAssembly.Module(zM),{env:{w:(e,t,n,r)=>{let i=this.hosts.get(t);i&&r!==0&&i.write(WM.decode(new Uint8Array(this.memory.buffer,n,r)))},d:(e,t,n)=>this.hosts.has(t)?(this.writeDeviceAttributes(n),1):0,s:(e,t,n)=>{let r=this.hosts.get(t);if(!r)return 0;let i=r.size(),a=`GhosttySizeReportSize`;return this.setField(n,a,`rows`,i.rows),this.setField(n,a,`columns`,i.columns),this.setField(n,a,`cell_width`,i.cellWidth),this.setField(n,a,`cell_height`,i.cellHeight),1},b:(e,t)=>{this.hosts.get(t)?.bell()},v:(e,t,n)=>{let r=this.hosts.get(n);r&&this.writeVersion(e,r.version())},p:(e,t,n,r,i)=>this.decodePng(t,n,r,i)}}),t=this.exports.__indirect_function_table;if(!(t instanceof WebAssembly.Table))throw Error(`libghostty-vt did not expose its callback table`);let n=[`w`,`d`,`s`,`b`,`v`,`p`].map(n=>{let r=e.exports[n];if(typeof r!=`function`)throw Error(`libghostty-vt callback is missing: ${n}`);let i=t.length;return t.grow(1),t.set(i,r),i});if(this.callbacks={writePty:n[0],deviceAttributes:n[1],size:n[2],bell:n[3],xtversion:n[4]},this.call(`ghostty_sys_set`,VM,n[5])!==0)throw Error(`libghostty-vt did not accept the PNG decoder`)}decodePng(e,t,n,r){let i;try{i=IM(new Uint8Array(this.memory.buffer,t,n))}catch(e){return RM.warn(`could not decode a kitty PNG image`,e),0}let a=this.call(`ghostty_alloc`,e,i.data.length);if(a===0)return 0;this.bytes(a,i.data.length).set(i.data);let o=this.dataView();return o.setUint32(r+UM.width,i.width,!0),o.setUint32(r+UM.height,i.height,!0),o.setUint32(r+UM.data,a,!0),o.setUint32(r+UM.length,i.data.length,!0),1}writeVersion(e,t){let n=GM.encode(t);this.free(this.version.pointer,this.version.size);let r=this.alloc(n.length);this.bytes(r,n.length).set(n),this.version={pointer:r,size:n.length},this.dataView().setUint32(e+this.field(`GhosttyString`,`ptr`).offset,r,!0),this.setField(e,`GhosttyString`,`len`,n.length)}writeDeviceAttributes(e){let t=e+this.field(`GhosttyDeviceAttributes`,`primary`).offset,n=e+this.field(`GhosttyDeviceAttributes`,`secondary`).offset,r=e+this.field(`GhosttyDeviceAttributes`,`tertiary`).offset,i=`GhosttyDeviceAttributesPrimary`,a=`GhosttyDeviceAttributesSecondary`,o=t+this.field(i,`features`).offset,s=this.dataView(),c=[4,22];c.forEach((e,t)=>s.setUint16(o+t*2,e,!0)),this.setField(t,i,`conformance_level`,62),this.setField(t,i,`num_features`,c.length),this.setField(n,a,`device_type`,0),this.setField(n,a,`firmware_version`,276),this.setField(n,a,`rom_cartridge`,0),this.setField(r,`GhosttyDeviceAttributesTertiary`,`unit_id`,0)}},qM=null;async function JM(){qM=await KM.load()}function YM(){if(!qM)throw Error(`libghostty-vt is not loaded`);return qM}var XM=new Map(`Unidentified.Backquote.Backslash.BracketLeft.BracketRight.Comma.Digit0.Digit1.Digit2.Digit3.Digit4.Digit5.Digit6.Digit7.Digit8.Digit9.Equal.IntlBackslash.IntlRo.IntlYen.KeyA.KeyB.KeyC.KeyD.KeyE.KeyF.KeyG.KeyH.KeyI.KeyJ.KeyK.KeyL.KeyM.KeyN.KeyO.KeyP.KeyQ.KeyR.KeyS.KeyT.KeyU.KeyV.KeyW.KeyX.KeyY.KeyZ.Minus.Period.Quote.Semicolon.Slash.AltLeft.AltRight.Backspace.CapsLock.ContextMenu.ControlLeft.ControlRight.Enter.MetaLeft.MetaRight.ShiftLeft.ShiftRight.Space.Tab.Convert.KanaMode.NonConvert.Delete.End.Help.Home.Insert.PageDown.PageUp.ArrowDown.ArrowLeft.ArrowRight.ArrowUp.NumLock.Numpad0.Numpad1.Numpad2.Numpad3.Numpad4.Numpad5.Numpad6.Numpad7.Numpad8.Numpad9.NumpadAdd.NumpadBackspace.NumpadClear.NumpadClearEntry.NumpadComma.NumpadDecimal.NumpadDivide.NumpadEnter.NumpadEqual.NumpadMemoryAdd.NumpadMemoryClear.NumpadMemoryRecall.NumpadMemoryStore.NumpadMemorySubtract.NumpadMultiply.NumpadParenLeft.NumpadParenRight.NumpadSubtract.NumpadSeparator.NumpadArrowUp.NumpadArrowDown.NumpadArrowRight.NumpadArrowLeft.NumpadBegin.NumpadHome.NumpadEnd.NumpadInsert.NumpadDelete.NumpadPageUp.NumpadPageDown.Escape.F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12.F13.F14.F15.F16.F17.F18.F19.F20.F21.F22.F23.F24.F25.Fn.FnLock.PrintScreen.ScrollLock.Pause.BrowserBack.BrowserFavorites.BrowserForward.BrowserHome.BrowserRefresh.BrowserSearch.BrowserStop.Eject.LaunchApp1.LaunchApp2.LaunchMail.MediaPlayPause.MediaSelect.MediaStop.MediaTrackNext.MediaTrackPrevious.Power.Sleep.AudioVolumeDown.AudioVolumeMute.AudioVolumeUp.WakeUp.Copy.Cut.Paste`.split(`.`).map((e,t)=>[e,t]));function ZM(e){return XM.get(e)??0}var QM=new Map([[`!`,`1`],[`@`,`2`],[`#`,`3`],[`$`,`4`],[`%`,`5`],[`^`,`6`],[`&`,`7`],[`*`,`8`],[`(`,`9`],[`)`,`0`],[`~`,"`"],[`_`,`-`],[`+`,`=`],[`{`,`[`],[`}`,`]`],[`|`,`\\`],[`:`,`;`],[`"`,`'`],[`<`,`,`],[`>`,`.`],[`?`,`/`]]),$M;function eN(){return $M||($M=globalThis.navigator?.keyboard?.getLayoutMap().catch(()=>void 0)??Promise.resolve(void 0),$M)}function tN(){return $M=void 0,eN()}function nN(e){return!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey?0:+([...e.key].length===1)}function rN(e,t){if([...e.key].length!==1)return 0;let n=t?.get(e.code);if(n&&[...n].length===1)return n.codePointAt(0)??0;if(/^[A-Z]$/u.test(e.key))return e.key.charCodeAt(0)+32;if(e.shiftKey){let t=QM.get(e.key);if(t)return t.codePointAt(0)??0;let n=e.key.toLowerCase();return n!==e.key&&[...n].length===1?n.codePointAt(0)??0:0}return e.key.codePointAt(0)??0}var iN=new Map([[`Backquote`,"`"],[`Minus`,`-`],[`Equal`,`=`],[`BracketLeft`,`[`],[`BracketRight`,`]`],[`Backslash`,`\\`],[`Semicolon`,`;`],[`Quote`,`'`],[`Comma`,`,`],[`Period`,`.`],[`Slash`,`/`],[`Space`,` `]]),aN=[...`0123456789`].map(e=>[`Digit${e}`,e]),oN=new Map([...QM].map(e=>[e[1],e[0]]));function sN(e){return/^Key[A-Z]$/u.test(e)?e[3].toLowerCase():/^Digit[0-9]$/u.test(e)?e[5]:iN.get(e)}function cN(e){return[...iN,...aN].every(t=>t[0]===`Space`||e.get(t[0])===t[1])}function lN(e,t){let n=t?.get(e.code),r=n&&[...n].length===1?n:sN(e.code);if(r===void 0)return[...e.key].length===1?null:e.key;if(!e.shiftKey)return r;let i=r.toUpperCase();return i!==r&&[...i].length===1?i:t===void 0||!cN(t)?null:oN.get(r)??r}var uN=new TextEncoder,dN=new Map([[`[`,`\x1B`],[`m`,`\r`],[`i`,` `],[`@`,`\0`]]),fN=class{runtime=YM();terminal;keyEncoderSlot;keyEncoder;keyEventSlot;keyEvent;mouseEncoderSlot;mouseEncoder;mouseEventSlot;mouseEvent;scratch;keyboardLayoutMap;constructor(e){let t=this.runtime;this.terminal=e,this.loadKeyboardLayout(eN()),this.keyEncoderSlot=t.allocOpaque(),t.check(`ghostty_key_encoder_new`,t.call(`ghostty_key_encoder_new`,0,this.keyEncoderSlot)),this.keyEncoder=t.readPointer(this.keyEncoderSlot),this.keyEventSlot=t.allocOpaque(),t.check(`ghostty_key_event_new`,t.call(`ghostty_key_event_new`,0,this.keyEventSlot)),this.keyEvent=t.readPointer(this.keyEventSlot),this.mouseEncoderSlot=t.allocOpaque(),t.check(`ghostty_mouse_encoder_new`,t.call(`ghostty_mouse_encoder_new`,0,this.mouseEncoderSlot)),this.mouseEncoder=t.readPointer(this.mouseEncoderSlot),this.mouseEventSlot=t.allocOpaque(),t.check(`ghostty_mouse_event_new`,t.call(`ghostty_mouse_event_new`,0,this.mouseEventSlot)),this.mouseEvent=t.readPointer(this.mouseEventSlot),this.scratch=t.alloc(1)}encodeKey(e,t=`press`,n=!1){let r=this.runtime,i=e.key.toLowerCase(),a=dN.get(i);if(a!==void 0&&t===`press`&&e.ctrlKey&&!e.altKey&&!e.metaKey&&!(e.shiftKey&&/^[a-z]$/u.test(i))&&!r.flag(`ghostty_terminal_get`,this.terminal,8))return a;let o=n?this.metaText(e):null,s=o??e.key;if(o!==null&&t===`press`&&!e.ctrlKey&&[...s].length===1&&(s.codePointAt(0)??0)>127&&r.flag(`ghostty_terminal_mode_get`,this.terminal,1036)&&this.isLegacyKeyboard())return`\x1b${s}`;r.call(`ghostty_key_encoder_setopt_from_terminal`,this.keyEncoder,this.terminal),r.call(`ghostty_key_event_set_action`,this.keyEvent,t===`release`?0:e.repeat?2:1),r.call(`ghostty_key_event_set_key`,this.keyEvent,ZM(e.code));let c=+!!e.shiftKey|(e.ctrlKey?2:0)|(e.altKey?4:0)|(e.metaKey?8:0)|(e.getModifierState(`CapsLock`)?16:0)|(e.getModifierState(`NumLock`)?32:0);r.call(`ghostty_key_event_set_mods`,this.keyEvent,c),r.call(`ghostty_key_event_set_consumed_mods`,this.keyEvent,nN(e)),r.call(`ghostty_key_event_set_composing`,this.keyEvent,+!!e.isComposing),r.call(`ghostty_key_event_set_unshifted_codepoint`,this.keyEvent,rN({code:e.code,key:s,shiftKey:e.shiftKey},this.keyboardLayoutMap));let l=uN.encode(s.length===1?s:``),u=l.length===0?0:r.alloc(l.length);u!==0&&r.bytes(u,l.length).set(l),r.call(`ghostty_key_event_set_utf8`,this.keyEvent,u,l.length);let d=r.encodeOutput((e,t,n)=>r.call(`ghostty_key_encoder_encode`,this.keyEncoder,this.keyEvent,e,t,n));return u!==0&&r.free(u,l.length),d}metaText(e){return lN(e,this.keyboardLayoutMap)}refreshKeyboardLayout(){this.loadKeyboardLayout(tN())}encodePaste(e){let t=this.runtime,n=uN.encode(e);if(n.length===0)return``;let r=t.alloc(n.length);t.bytes(r,n.length).set(n);let i=+!!t.flag(`ghostty_terminal_mode_get`,this.terminal,2004),a=t.encodeOutput((e,a,o)=>t.call(`ghostty_paste_encode`,r,n.length,i,e,a,o));return t.free(r,n.length),a}encodeMouse(e){let t=this.runtime;t.call(`ghostty_mouse_encoder_setopt_from_terminal`,this.mouseEncoder,this.terminal);let n=t.layout(`GhosttyMouseEncoderSize`),r=t.alloc(n.size);for(let i of[[`size`,n.size],[`screen_width`,e.screenWidth],[`screen_height`,e.screenHeight],[`cell_width`,e.cellWidth],[`cell_height`,e.cellHeight],[`padding_top`,0],[`padding_bottom`,0],[`padding_right`,0],[`padding_left`,0]])t.setField(r,`GhosttyMouseEncoderSize`,i[0],Math.max(0,Math.round(i[1])));t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,2,r),t.free(r,n.size),t.bytes(this.scratch,1)[0]=+!!e.anyButtonPressed,t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,3,this.scratch),t.bytes(this.scratch,1)[0]=1,t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,4,this.scratch),t.call(`ghostty_mouse_event_set_action`,this.mouseEvent,{press:0,release:1,motion:2}[e.action]),e.button===null?t.call(`ghostty_mouse_event_clear_button`,this.mouseEvent):t.call(`ghostty_mouse_event_set_button`,this.mouseEvent,e.button),t.call(`ghostty_mouse_event_set_mods`,this.mouseEvent,e.mods);let i=t.layout(`GhosttyMousePosition`),a=t.alloc(i.size),o=t.view(a,i.size);return o.setFloat32(t.field(`GhosttyMousePosition`,`x`).offset,e.x,!0),o.setFloat32(t.field(`GhosttyMousePosition`,`y`).offset,e.y,!0),t.call(`ghostty_mouse_event_set_position`,this.mouseEvent,a),t.free(a,i.size),t.encodeOutput((e,n,r)=>t.call(`ghostty_mouse_encoder_encode`,this.mouseEncoder,this.mouseEvent,e,n,r))}dispose(){let e=this.runtime;e.call(`ghostty_mouse_event_free`,this.mouseEvent),e.call(`ghostty_mouse_encoder_free`,this.mouseEncoder),e.call(`ghostty_key_event_free`,this.keyEvent),e.call(`ghostty_key_encoder_free`,this.keyEncoder),e.free(this.scratch,1),e.freeOpaque(this.mouseEventSlot),e.freeOpaque(this.mouseEncoderSlot),e.freeOpaque(this.keyEventSlot),e.freeOpaque(this.keyEncoderSlot)}async loadKeyboardLayout(e){this.keyboardLayoutMap=await e}isLegacyKeyboard(){return this.encodeKey(new KeyboardEvent(`keydown`,{key:`Tab`,code:`Tab`,shiftKey:!0}))===`\x1B[Z`}},pN=26,mN=30,hN=1,gN={imageId:1,placementId:2,isVirtual:3,xOffset:4,yOffset:5,columns:10,rows:11,z:12},_N={width:3,height:4,format:5,data:7,length:8},vN={size:48,pixelWidth:4,pixelHeight:8,column:20,row:24,visible:28,sourceX:32,sourceY:36,sourceWidth:40,sourceHeight:44},yN=new Map([[0,3],[1,4],[3,2],[4,1]]),bN=new Map([773,781,782,784,786,829,830,831,838,842,843,844,848,849,850,855,859,867,868,869,870,871,872,873,874,875,876,877,878,879,1155,1156,1157,1158,1159,1426,1427,1428,1429,1431,1432,1433,1436,1437,1438,1439,1440,1441,1448,1449,1451,1452,1455,1476,1552,1553,1554,1555,1556,1557,1558,1559,1623,1624,1625,1626,1627,1629,1630,1750,1751,1752,1753,1754,1755,1756,1759,1760,1761,1762,1764,1767,1768,1771,1772,1840,1842,1843,1845,1846,1850,1853,1855,1856,1857,1859,1861,1863,1865,1866,2027,2028,2029,2030,2031,2032,2033,2035,2070,2071,2072,2073,2075,2076,2077,2078,2079,2080,2081,2082,2083,2085,2086,2087,2089,2090,2091,2092,2093,2385,2387,2388,3970,3971,3974,3975,4957,4958,4959,6109,6458,6679,6773,6774,6775,6776,6777,6778,6779,6780,7019,7021,7022,7023,7024,7025,7026,7027,7376,7377,7378,7386,7387,7392,7616,7617,7619,7620,7621,7622,7623,7624,7625,7627,7628,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643,7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7678,8400,8401,8404,8405,8406,8407,8411,8412,8417,8423,8425,8432,11503,11504,11505,11744,11745,11746,11747,11748,11749,11750,11751,11752,11753,11754,11755,11756,11757,11758,11759,11760,11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,11771,11772,11773,11774,11775,42607,42620,42621,42736,42737,43232,43233,43234,43235,43236,43237,43238,43239,43240,43241,43242,43243,43244,43245,43246,43247,43248,43249,43696,43698,43699,43703,43704,43710,43711,43713,65056,65057,65058,65059,65060,65061,65062,68111,68152,119173,119174,119175,119176,119177,119210,119211,119212,119213,119362,119363,119364].map((e,t)=>[e,t]));function xN(e,t,n){let r=Array.from(e).slice(1,4).map(e=>bN.get(e.codePointAt(0)??0)??null),i=r[2]??null;return{imageId:t,placementId:n,row:r[0]??null,column:r[1]??null,imageIdHigh:i!==null&&i<256?i:null}}function SN(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n].cells,i=null;for(let e=0;e<r.length;e+=1){let a=r[e].placeholder;i!==null&&a!==null&&a.imageId===i.imageId&&a.placementId===i.placementId&&(a.row===null||a.row===i.row)&&(a.column===null||a.column===i.column+i.width)&&(a.imageIdHigh===null||a.imageIdHigh===i.imageIdHigh)?i.width+=1:(i!==null&&t.push(CN(i)),i=a===null?null:{x:e,y:n,imageId:a.imageId,imageIdHigh:a.imageIdHigh,placementId:a.placementId,row:a.row??0,column:a.column??0,width:1})}i!==null&&t.push(CN(i))}return t}function CN(e){return{x:e.x,y:e.y,imageId:e.imageId+(e.imageIdHigh??0)*2**24,placementId:e.placementId,row:e.row,column:e.column,width:e.width}}function wN(e,t,n,r){let i=t.columns===0?Math.ceil(n.width/r.width):t.columns,a=t.rows===0?Math.ceil(n.height/r.height):t.rows,o=i*r.width,s=a*r.height,c=n.width*s>n.height*o,l=c?o/Math.max(n.width,1):s/Math.max(n.height,1),u=c?0:(o-n.width*l)/2/l,d=c?(s-n.height*l)/2/l:0,f=n.width+u*2,p=n.height+d*2,m={x:f*e.column/i,y:p*e.row/a,width:f*e.width/i,height:p/a},h=0,g=0,_=e.width*r.width,v=r.height;if(m.y<d){let e=d-m.y;m.height-=e,g=e,v-=e*l,m.y=0,m.height>n.height&&(m.height=n.height,v=n.height*l)}else m.y+m.height>p-d?(m.y-=d,m.height=p-d-m.y-d,v=m.height*l):m.y-=d;if(m.x<u){let e=u-m.x;m.width-=e,h=e,_-=e*l,m.x=0,m.width>n.width&&(m.width=n.width,_=n.width*l)}else m.x+m.width>f-u?(m.x-=u,m.width=f-u-m.x-u,_=m.width*l):m.x-=u;if(m.width<=0||m.height<=0)return null;let y={xOffset:Math.round(h*l),yOffset:Math.round(g*l),width:Math.round(_),height:Math.round(v),source:{x:Math.round(m.x),y:Math.round(m.y),width:Math.round(m.width),height:Math.round(m.height)}};return y.width===0||y.height===0?null:y}function TN(e){let t=YM(),n=t.alloc(16),r=t.call(`ghostty_terminal_get`,e,pN,n);return t.free(n,16),r===0}var EN=class{runtime=YM();terminal;iteratorSlot;info;scratch;tail=[0,0];commands=0;cachedCommands=0;bitmaps=new Map;constructor(e){let t=this.runtime;this.terminal=e,this.iteratorSlot=t.allocOpaque(),t.check(`ghostty_kitty_graphics_placement_iterator_new`,t.call(`ghostty_kitty_graphics_placement_iterator_new`,0,this.iteratorSlot)),this.info=t.alloc(vN.size),this.scratch=t.alloc(16)}note(e){let t=[...this.tail,...e.subarray(0,2)],n=t.some((e,n)=>e===27&&t[n+1]===95&&t[n+2]===71),r=e.indexOf(27);for(;!n&&r!==-1;)n=e[r+1]===95&&e[r+2]===71,r=e.indexOf(27,r+1);n&&(this.commands+=1),this.tail=[...this.tail,...e.subarray(-2)].slice(-2)}images(e,t){this.commands!==this.cachedCommands&&(this.cachedCommands=this.commands,this.bitmaps.clear());let n=new Map,r=this.placements(e,t).map(e=>{let t=n.get(e.key)??this.bitmaps.get(e.key)??kN(e.image);return n.set(e.key,t),{placement:e,bitmap:t}});return this.bitmaps=n,r}dispose(){let e=this.runtime;e.call(`ghostty_kitty_graphics_placement_iterator_free`,e.readPointer(this.iteratorSlot)),e.free(this.info,vN.size),e.free(this.scratch,16),e.freeOpaque(this.iteratorSlot),this.bitmaps.clear()}placements(e,t){let n=this.runtime;n.check(`ghostty_terminal_get`,n.call(`ghostty_terminal_get`,this.terminal,mN,this.scratch));let r=n.readPointer(this.scratch);n.check(`ghostty_kitty_graphics_get`,n.call(`ghostty_kitty_graphics_get`,r,hN,this.iteratorSlot));let i=n.readPointer(this.iteratorSlot),a=[],o=[];for(;n.call(`ghostty_kitty_graphics_placement_next`,i);){let e=this.placementU32(i,gN.imageId);if(this.placementData(i,gN.isVirtual).getUint8(0)){o.push({imageId:e,placementId:this.placementU32(i,gN.placementId),columns:this.placementU32(i,gN.columns),rows:this.placementU32(i,gN.rows)});continue}let t=n.call(`ghostty_kitty_graphics_image`,r,e);if(t===0)throw Error(`kitty placement points to missing image ${e}`);n.bytes(this.info,vN.size).fill(0);let s=n.view(this.info,vN.size);s.setUint32(0,vN.size,!0),n.check(`ghostty_kitty_graphics_placement_render_info`,n.call(`ghostty_kitty_graphics_placement_render_info`,i,t,this.terminal,this.info)),s.getUint8(vN.visible)!==0&&a.push({...this.image(t,e),z:this.placementData(i,gN.z).getInt32(0,!0),column:s.getInt32(vN.column,!0),row:s.getInt32(vN.row,!0),xOffset:this.placementU32(i,gN.xOffset),yOffset:this.placementU32(i,gN.yOffset),width:s.getUint32(vN.pixelWidth,!0),height:s.getUint32(vN.pixelHeight,!0),source:{x:s.getUint32(vN.sourceX,!0),y:s.getUint32(vN.sourceY,!0),width:s.getUint32(vN.sourceWidth,!0),height:s.getUint32(vN.sourceHeight,!0)}})}if(o.length===0)return a;for(let i of SN(e)){let e=o.find(e=>e.imageId===i.imageId&&(i.placementId===0||e.placementId===i.placementId));if(e===void 0)continue;let s=n.call(`ghostty_kitty_graphics_image`,r,i.imageId);if(s===0)continue;let c=this.image(s,i.imageId),l=wN(i,e,c.image,t);l!==null&&a.push({...c,...l,z:-1,column:i.x,row:i.y})}return a}image(e,t){let n=this.imageData(e,_N.data),r=this.imageData(e,_N.length);return{key:`${t}:${n}:${r}`,image:{width:this.imageData(e,_N.width),height:this.imageData(e,_N.height),format:this.imageData(e,_N.format),pixels:this.runtime.bytes(n,r)}}}placementData(e,t){return this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_kitty_graphics_placement_get`,this.runtime.call(`ghostty_kitty_graphics_placement_get`,e,t,this.scratch)),this.runtime.view(this.scratch,4)}placementU32(e,t){return this.placementData(e,t).getUint32(0,!0)}imageData(e,t){return this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_kitty_graphics_image_get`,this.runtime.call(`ghostty_kitty_graphics_image_get`,e,t,this.scratch)),this.runtime.view(this.scratch,4).getUint32(0,!0)}};function DN(e,t,n,r,i){let a=r.width/i.width,o=r.height/i.height;for(let i of t){let t=i.placement;ON(t.z)===n&&e.drawImage(i.bitmap,t.source.x,t.source.y,t.source.width,t.source.height,t.column*r.width+t.xOffset*a,t.row*r.height+t.yOffset*o,t.width*a,t.height*o)}}function ON(e){return e<-1073741824?`belowBackground`:e<0?`belowText`:`aboveText`}function kN(e){let t=yN.get(e.format);if(t===void 0)throw Error(`unsupported kitty image format ${e.format}`);let n=e.width*e.height,r=e.pixels,i=new Uint8ClampedArray(n*4);if(t===4)i.set(r.subarray(0,n*4));else for(let e=0;e<n;e+=1){let n=e*t,a=e*4;t===3?i.set(r.subarray(n,n+3),a):i.fill(r[n],a,a+3),i[a+3]=t===2?r[n+1]:255}let a=new OffscreenCanvas(e.width,e.height),o=a.getContext(`2d`);if(!o)throw Error(`could not create a canvas for a kitty image`);return o.putImageData(new ImageData(i,e.width,e.height),0,0),a}var AN=8,jN=16,MN=0,NN=1,PN=2,FN=8,IN={cols:1,rows:2,dirty:3,rowIterator:4,background:5,foreground:6,cursor:7,cursorHasValue:8,cursorStyle:10,cursorVisible:11,cursorBlinking:12,cursorInViewport:14,cursorX:15,cursorY:16},LN={dirty:1,raw:2,cells:3},RN={raw:1,style:2,graphemesLength:3,graphemes:4,background:5,foreground:6,selected:7},zN={keys:0,values:20,graphemesLength:40,selected:44,background:48,foreground:52,written:56,size:60},BN={narrow:0,wide:1,spacerTail:2},VN={r:229,g:231,b:235},HN={r:0,g:0,b:0};function UN(e,t){return Math.floor((e*155+t*100)/255)}function WN(e,t){return{r:UN(e.r,t.r),g:UN(e.g,t.g),b:UN(e.b,t.b)}}function GN(e,t){let n=``;for(let r=0;r<t;r+=4096){let i=Math.min(4096,t-r),a=Array(i);for(let t=0;t<i;t+=1)a[t]=e.getUint32((r+t)*4,!0);n+=String.fromCodePoint(...a)}return n}function KN(e,t){return{text:``,wide:0,foreground:e,background:t,bold:!1,italic:!1,invisible:!1,strikethrough:!1,overline:!1,underline:0,underlineColor:null,selected:!1,placeholder:null}}function qN(e,t){let n=e.dataView();return{r:n.getUint8(t),g:n.getUint8(t+1),b:n.getUint8(t+2)}}function JN(e,t){let n=e.alloc(768);e.call(`ghostty_terminal_get`,t,21,n);let r=e.bytes(n,768),i=Array.from({length:256},(e,t)=>({r:r[t*3],g:r[t*3+1],b:r[t*3+2]}));return e.free(n,768),i}function YN(e,t){let n=[],r=[];return e.cells.forEach((e,i)=>{if(e.wide!==2)for(let a of(e.text||` `).split(``))n.push(a),r.push({x:i,y:t})}),{text:n.join(``),points:r}}var XN=class{runtime=YM();stateSlot;state;rowIteratorSlot;rowCellsSlot;scratch;style;cellQuery;graphemes=0;graphemeCapacity=0;rows=[];palette=[];constructor(){let e=this.runtime;this.stateSlot=e.allocOpaque(),e.check(`ghostty_render_state_new`,e.call(`ghostty_render_state_new`,0,this.stateSlot)),this.state=e.readPointer(this.stateSlot),this.rowIteratorSlot=e.allocOpaque(),e.check(`ghostty_render_state_row_iterator_new`,e.call(`ghostty_render_state_row_iterator_new`,0,this.rowIteratorSlot)),this.rowCellsSlot=e.allocOpaque(),e.check(`ghostty_render_state_row_cells_new`,e.call(`ghostty_render_state_row_cells_new`,0,this.rowCellsSlot)),this.scratch=e.alloc(16),this.style=e.alloc(e.layout(`GhosttyStyle`).size),this.cellQuery=e.alloc(zN.size);let t=e.dataView();[[RN.style,this.style],[RN.graphemesLength,this.cellQuery+zN.graphemesLength],[RN.selected,this.cellQuery+zN.selected],[RN.background,this.cellQuery+zN.background],[RN.foreground,this.cellQuery+zN.foreground]].forEach((e,n)=>{t.setUint32(this.cellQuery+zN.keys+n*4,e[0],!0),t.setUint32(this.cellQuery+zN.values+n*4,e[1],!0)})}snapshot(e,t){let n=this.runtime;n.check(`ghostty_render_state_update`,n.call(`ghostty_render_state_update`,this.state,e));let r=this.getRender(IN.cols,2),i=this.getRender(IN.rows,2),a=this.getRender(IN.dirty,4),o=this.getColor(IN.foreground,VN),s=this.getColor(IN.background,HN),c=this.getRender(IN.cursorHasValue,1)===0?o:this.getColor(IN.cursor,o),l=this.getRender(IN.cursorInViewport,1)!==0,u=this.getRender(IN.cursorVisible,1)!==0&&l;(this.rows.length!==i||this.rows.some(e=>e.cells.length!==r))&&(this.rows=Array.from({length:i},()=>({cells:Array.from({length:r},()=>KN(o,s)),isWrapContinuation:!1,wrapsToNext:!1})));let d=new Set;if(a!==0){this.palette=JN(n,e),n.check(`ghostty_render_state_get`,n.call(`ghostty_render_state_get`,this.state,IN.rowIterator,this.rowIteratorSlot));let c=n.readPointer(this.rowIteratorSlot),l=0;for(;l<i&&n.call(`ghostty_render_state_row_iterator_next`,c)!==0;)(a===2||this.getRowFlag(c,LN.dirty))&&(this.rows[l]=this.readRow(c,r,o,s,t),d.add(l),n.bytes(this.scratch,1)[0]=0,n.call(`ghostty_render_state_row_set`,c,0,this.scratch)),l+=1;n.view(this.scratch,4).setUint32(0,0,!0),n.call(`ghostty_render_state_set`,this.state,0,this.scratch)}return{cols:r,rows:i,foreground:o,background:s,cursor:c,cursorX:l?this.getRender(IN.cursorX,2):-1,cursorY:l?this.getRender(IN.cursorY,2):-1,cursorVisible:u,cursorBlinking:this.getRender(IN.cursorBlinking,1)!==0,cursorStyle:this.getRender(IN.cursorStyle,4),dirtyRows:d,rowData:this.rows}}invalidate(){this.rows=[]}dispose(){let e=this.runtime,t=e.readPointer(this.rowCellsSlot);t&&e.call(`ghostty_render_state_row_cells_free`,t);let n=e.readPointer(this.rowIteratorSlot);n&&e.call(`ghostty_render_state_row_iterator_free`,n),e.call(`ghostty_render_state_free`,this.state),e.free(this.style,e.layout(`GhosttyStyle`).size),e.free(this.cellQuery,zN.size),e.free(this.scratch,16),e.free(this.graphemes,this.graphemeCapacity),e.freeOpaque(this.rowCellsSlot),e.freeOpaque(this.rowIteratorSlot),e.freeOpaque(this.stateSlot)}readRow(e,t,n,r,i){let a=this.runtime;a.check(`ghostty_render_state_row_get`,a.call(`ghostty_render_state_row_get`,e,LN.raw,this.scratch));let o=a.view(this.scratch,8).getBigUint64(0,!0);a.bytes(this.scratch+8,1)[0]=0,a.call(`ghostty_row_get`,o,2,this.scratch+8);let s=a.bytes(this.scratch+8,1)[0]!==0;a.bytes(this.scratch+8,1)[0]=0,a.call(`ghostty_row_get`,o,1,this.scratch+8);let c=a.bytes(this.scratch+8,1)[0]!==0;a.check(`ghostty_render_state_row_get`,a.call(`ghostty_render_state_row_get`,e,LN.cells,this.rowCellsSlot));let l=a.readPointer(this.rowCellsSlot),u=a.layout(`GhosttyStyle`),d=u.size,f=u.fields,p=[];for(;p.length<t&&a.call(`ghostty_render_state_row_cells_next`,l)!==0;){a.bytes(this.style,d).fill(0),a.setField(this.style,`GhosttyStyle`,`size`,d);let e=a.call(`ghostty_render_state_row_cells_get_multi`,l,5,this.cellQuery+zN.keys,this.cellQuery+zN.values,this.cellQuery+zN.written),t=a.dataView(),o=t.getUint32(this.cellQuery+zN.written,!0);o<3&&a.check(`ghostty_render_state_row_cells_get_multi`,e);let s=t.getUint32(this.cellQuery+zN.graphemesLength,!0),c=t.getUint8(this.cellQuery+zN.selected)!==0,u=o>=4?qN(a,this.cellQuery+zN.background):r,m=o===5?qN(a,this.cellQuery+zN.foreground):o===3?this.getCellColor(l,n):n,h=``;if(s>0){let e=s*4;if(e>this.graphemeCapacity){let t=Math.max(e,this.graphemeCapacity*2),n=a.alloc(t);a.free(this.graphemes,this.graphemeCapacity),this.graphemes=n,this.graphemeCapacity=t}a.call(`ghostty_render_state_row_cells_get`,l,RN.graphemes,this.graphemes)===0&&(h=GN(a.view(this.graphemes,e),s))}let g=0;if(h.length===0&&p.at(-1)?.text.length){a.call(`ghostty_render_state_row_cells_get`,l,RN.raw,this.scratch);let e=a.view(this.scratch,8).getBigUint64(0,!0);a.view(this.scratch+8,4).setUint32(0,0,!0),a.call(`ghostty_cell_get`,e,3,this.scratch+8),g=a.view(this.scratch+8,4).getUint32(0,!0)}let _=a.dataView(),v=e=>_.getUint8(this.style+f[e].offset)!==0,y=v(`bold`);if(i&&y&&_.getUint32(this.style+AN,!0)===NN){let e=_.getUint8(this.style+jN);e<8&&(m=this.palette[e+8]??m)}if(v(`inverse`)){let e=m;m=u,u=e}v(`faint`)&&(m=WN(m,u));let b=this.style+f.underline_color.offset,x=_.getUint32(b,!0),S=b+FN,C=null;h.codePointAt(0)===1109742&&(C=xN(h,this.colorId(this.style+AN),this.colorId(b)),h=``),p.push({text:h,wide:g,foreground:m,background:u,bold:y,italic:v(`italic`),invisible:v(`invisible`),strikethrough:v(`strikethrough`),overline:v(`overline`),underline:_.getInt32(this.style+f.underline.offset,!0),underlineColor:x===NN?this.palette[_.getUint8(S)]:x===PN?qN(a,S):null,selected:c,placeholder:C})}for(;p.length<t;)p.push(KN(n,r));return{cells:p,isWrapContinuation:s,wrapsToNext:c}}getRender(e,t){this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.state,e,this.scratch));let n=this.runtime.view(this.scratch,4);return t===1?n.getUint8(0):t===2?n.getUint16(0,!0):n.getUint32(0,!0)}getColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_get`,this.state,e,this.scratch)===0?qN(this.runtime,this.scratch):t}getRowFlag(e,t){return this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_render_state_row_get`,e,t,this.scratch)===0&&this.runtime.bytes(this.scratch,1)[0]!==0}getCellColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_row_cells_get`,e,RN.foreground,this.scratch)===0?qN(this.runtime,this.scratch):t}colorId(e){let t=this.runtime.dataView(),n=t.getUint32(e,!0);if(n===MN)return 0;if(n===NN)return t.getUint8(e+FN);if(n===PN){let t=qN(this.runtime,e+FN);return t.r<<16|t.g<<8|t.b}throw Error(`unknown style color tag ${n}`)}},ZN=16,QN=589824,$N=381888,eP=5e7,tP=new TextDecoder;function nP(e){let t=[...e],n=[0,95,135,175,215,255];for(let e=16;e<232;e+=1){let r=e-16;t.push({r:n[Math.floor(r/36)],g:n[Math.floor(r/6)%6],b:n[r%6]})}for(let e=0;e<24;e+=1){let n=8+e*10;t.push({r:n,g:n,b:n})}return t}var rP=class{encoder;kitty;runtime=YM();terminalSlot;terminal;renderState;formatterSlot;formatter;scratch;point;scrollbar;host;hostId=0;sizeReport;disposed=!1;boldIsBright=!1;version=``;constructor(e,t,n,r,i){let a=this.runtime,o=a.layout(`GhosttyTerminalOptions`).size,s=a.alloc(o);a.setField(s,`GhosttyTerminalOptions`,`cols`,e),a.setField(s,`GhosttyTerminalOptions`,`rows`,t);let c=Math.floor($N/(8*(e+1)));a.setField(s,`GhosttyTerminalOptions`,`max_scrollback`,n===0?0:Math.min((Math.ceil(n/c)+1)*QN,eP)),this.terminalSlot=a.allocOpaque();let l=a.call(`ghostty_terminal_new`,0,this.terminalSlot,s);if(a.free(s,o),a.check(`ghostty_terminal_new`,l),this.terminal=a.readPointer(this.terminalSlot),!TN(this.terminal))throw a.call(`ghostty_terminal_free`,this.terminal),a.freeOpaque(this.terminalSlot),Error(`libghostty-vt was built without kitty graphics, build it with scripts/build-ghostty-wasm.mts`);this.sizeReport={rows:t,columns:e,cellWidth:1,cellHeight:1},this.host={write:r,size:()=>this.sizeReport,bell:i,version:()=>this.version},this.hostId=a.attachHost(this.terminal,this.host),this.renderState=new XN,this.encoder=new fN(this.terminal),this.kitty=new EN(this.terminal);let u=`GhosttyFormatterTerminalOptions`,d=a.layout(u),f=a.alloc(d.size),p=a.field(u,`extra`),m=a.field(`GhosttyFormatterTerminalExtra`,`screen`);a.setField(f,u,`size`,d.size),a.setField(f,u,`trim`,1),a.setField(f+p.offset,`GhosttyFormatterTerminalExtra`,`size`,p.size),a.setField(f+p.offset+m.offset,`GhosttyFormatterScreenExtra`,`size`,m.size),this.formatterSlot=a.allocOpaque();let h=a.call(`ghostty_formatter_terminal_new`,0,this.formatterSlot,this.terminal,f);a.free(f,d.size),a.check(`ghostty_formatter_terminal_new`,h),this.formatter=a.readPointer(this.formatterSlot),this.scratch=a.alloc(16),this.point=a.alloc(a.layout(`GhosttyPoint`).size),this.scrollbar=a.alloc(a.layout(`GhosttyTerminalScrollbar`).size)}write(e){if(e.length===0)return;this.kitty.note(e);let t=this.runtime.alloc(e.length);this.runtime.bytes(t,e.length).set(e),this.runtime.call(`ghostty_terminal_vt_write`,this.terminal,t,e.length),this.runtime.free(t,e.length)}setReplies(e){e&&this.hostId===0?this.hostId=this.runtime.attachHost(this.terminal,this.host):!e&&this.hostId!==0&&(this.runtime.detachHost(this.terminal,this.hostId),this.hostId=0)}reset(){this.runtime.call(`ghostty_terminal_reset`,this.terminal),this.renderState.invalidate()}resize(e,t,n,r,i){this.sizeReport={rows:t,columns:e,cellWidth:Math.max(1,Math.round(n*i)),cellHeight:Math.max(1,Math.round(r*i))},this.runtime.check(`ghostty_terminal_resize`,this.runtime.call(`ghostty_terminal_resize`,this.terminal,Math.max(1,Math.min(65535,e)),Math.max(1,Math.min(65535,t)),this.sizeReport.cellWidth,this.sizeReport.cellHeight))}setColors(e){let t=this.runtime.alloc(3);for(let n of[[11,e.foreground],[12,e.background],[13,e.cursor]]){let e=n[1];this.runtime.bytes(t,3).set([e.r,e.g,e.b]),this.runtime.call(`ghostty_terminal_set`,this.terminal,n[0],t)}this.runtime.free(t,3);let n=nP(e.palette),r=this.runtime.alloc(n.length*3);this.runtime.bytes(r,n.length*3).set(n.flatMap(e=>[e.r,e.g,e.b])),this.runtime.call(`ghostty_terminal_set`,this.terminal,14,r),this.runtime.free(r,n.length*3),this.renderState.invalidate()}setCursor(e,t){let n={bar:0,block:1,underline:2}[e];this.runtime.view(this.scratch,4).setUint32(0,n,!0),this.runtime.call(`ghostty_terminal_set`,this.terminal,22,this.scratch),this.runtime.bytes(this.scratch,1)[0]=+!!t,this.runtime.call(`ghostty_terminal_set`,this.terminal,23,this.scratch)}title(){if(this.runtime.bytes(this.scratch,8).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,12,this.scratch)!==0)return``;let e=this.runtime.view(this.scratch,8),t=e.getUint32(0,!0),n=e.getUint32(4,!0);return n===0?``:tP.decode(this.runtime.bytes(t,n))}screenText(){let e=this.runtime.alloc(8),t=this.runtime.call(`ghostty_formatter_format_alloc`,this.formatter,0,e,e+4),n=this.runtime.view(e,8),r=n.getUint32(0,!0),i=n.getUint32(4,!0);if(this.runtime.free(e,8),t!==0)return``;let a=tP.decode(this.runtime.bytes(r,i));return this.runtime.call(`ghostty_free`,0,r,i),a}scroll(e){let t=this.runtime.layout(`GhosttyTerminalScrollViewport`),n=this.runtime.alloc(t.size);this.runtime.setField(n,`GhosttyTerminalScrollViewport`,`tag`,2);let r=this.runtime.field(`GhosttyTerminalScrollViewport`,`value`);this.runtime.view(n+r.offset,r.size).setInt32(0,e,!0),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,n),this.runtime.free(n,t.size)}scrollToBottom(){let e=this.runtime.layout(`GhosttyTerminalScrollViewport`),t=this.runtime.alloc(e.size);this.runtime.setField(t,`GhosttyTerminalScrollViewport`,`tag`,1),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,t),this.runtime.free(t,e.size)}scrollbarState(){let e=this.runtime.layout(`GhosttyTerminalScrollbar`);return this.runtime.bytes(this.scrollbar,e.size).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,9,this.scrollbar)===0?{total:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`total`),offset:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`offset`),len:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`len`)}:null}isMouseTracking(){return this.flag(`ghostty_terminal_get`,11)}isMouseAnyEventTracking(){return this.flag(`ghostty_terminal_mode_get`,1003)}isFocusReporting(){return this.flag(`ghostty_terminal_mode_get`,1004)}isSynchronizedOutput(){return this.flag(`ghostty_terminal_mode_get`,2026)}endSynchronizedOutput(){this.runtime.check(`ghostty_terminal_mode_set`,this.runtime.call(`ghostty_terminal_mode_set`,this.terminal,2026,0))}currentColors(){return{foreground:this.terminalColor(18),background:this.terminalColor(19),cursor:this.terminalColor(20),palette:JN(this.runtime,this.terminal)}}isApplicationCursorKeys(){return this.flag(`ghostty_terminal_mode_get`,1)}isKittyKeyboard(){return this.flag(`ghostty_terminal_get`,8)}isAlternateScreen(){return this.runtime.dataView().setUint32(this.scratch,0,!0),this.runtime.call(`ghostty_terminal_get`,this.terminal,6,this.scratch)===0&&this.runtime.dataView().getUint32(this.scratch,!0)===1}setSelection(e,t){let n=this.runtime.layout(`GhosttyGridRef`).size,r=this.gridRef(e.x,e.y,2);try{let e=this.gridRef(t.x,t.y,2),i=this.runtime.layout(`GhosttySelection`),a=this.runtime.alloc(i.size);this.runtime.setField(a,`GhosttySelection`,`size`,i.size);let o=this.runtime.field(`GhosttySelection`,`start`),s=this.runtime.field(`GhosttySelection`,`end`);this.runtime.bytes(a+o.offset,o.size).set(this.runtime.bytes(r,o.size)),this.runtime.bytes(a+s.offset,s.size).set(this.runtime.bytes(e,s.size)),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,a),this.runtime.free(e,n),this.runtime.free(a,i.size)}finally{this.runtime.free(r,n)}}selectWord(e){return this.selectAt(`GhosttyTerminalSelectWordOptions`,`ghostty_terminal_select_word`,e)}selectLine(e){return this.selectAt(`GhosttyTerminalSelectLineOptions`,`ghostty_terminal_select_line`,e)}clearSelection(){this.runtime.call(`ghostty_terminal_set`,this.terminal,21,0)}selectionText(){let e=this.runtime.alloc(ZN),t=this.runtime.view(e,ZN);t.setUint32(0,ZN,!0),t.setUint8(8,1),t.setUint8(9,1);let n=this.runtime.encodeOutput((t,n,r)=>this.runtime.call(`ghostty_terminal_selection_format_buf`,this.terminal,e,t,n,r));return this.runtime.free(e,ZN),n}hyperlinkAt(e,t){let n=this.gridRef(e,t,1),r=this.hyperlinkOf(n);return this.runtime.free(n,this.runtime.layout(`GhosttyGridRef`).size),r}toScreen(e){let t=this.gridRef(e.x,e.y,1),n=this.pointFromGridRef(t,2);return this.runtime.free(t,this.runtime.layout(`GhosttyGridRef`).size),n}trackCursor(){let e=this.runtime.allocOpaque(),t=this.runtime.call(`ghostty_terminal_grid_ref_track`,this.terminal,this.cursorPoint(),e),n=this.runtime.readPointer(e);return this.runtime.freeOpaque(e),this.runtime.check(`ghostty_terminal_grid_ref_track`,t),n}retrack(e){let t=this.runtime.call(`ghostty_tracked_grid_ref_set`,e,this.terminal,this.cursorPoint());this.runtime.check(`ghostty_tracked_grid_ref_set`,t)}trackedPoint(e){return this.runtime.call(`ghostty_tracked_grid_ref_point`,e,2,this.scratch)===0?{x:this.runtime.readField(this.scratch,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(this.scratch,`GhosttyPointCoordinate`,`y`)}:null}trackedHyperlink(e){let t=this.runtime.layout(`GhosttyGridRef`).size,n=this.runtime.alloc(t);this.runtime.setField(n,`GhosttyGridRef`,`size`,t);let r=this.runtime.call(`ghostty_tracked_grid_ref_snapshot`,e,n)===0?this.hyperlinkOf(n):null;return this.runtime.free(n,t),r}untrack(e){this.runtime.call(`ghostty_tracked_grid_ref_free`,e)}snapshot(){return this.renderState.snapshot(this.terminal,this.boldIsBright)}invalidate(){this.renderState.invalidate()}cellSize(){return{width:this.sizeReport.cellWidth,height:this.sizeReport.cellHeight}}dispose(){if(this.disposed)return;this.disposed=!0;let e=this.runtime;e.call(`ghostty_formatter_free`,this.formatter),this.encoder.dispose(),this.kitty.dispose(),this.renderState.dispose(),this.hostId!==0&&e.detachHost(this.terminal,this.hostId),e.call(`ghostty_terminal_free`,this.terminal),e.free(this.scrollbar,e.layout(`GhosttyTerminalScrollbar`).size),e.free(this.scratch,16),e.free(this.point,e.layout(`GhosttyPoint`).size),e.freeOpaque(this.formatterSlot),e.freeOpaque(this.terminalSlot)}hyperlinkOf(e){let t=this.runtime.encodeOutput((t,n,r)=>this.runtime.call(`ghostty_grid_ref_hyperlink_uri`,e,t,n,r));return t===``?null:t}cursorPosition(){this.runtime.dataView().setUint32(this.scratch,0,!0),this.runtime.call(`ghostty_terminal_get`,this.terminal,3,this.scratch),this.runtime.call(`ghostty_terminal_get`,this.terminal,4,this.scratch+2);let e=this.runtime.dataView();return{x:e.getUint16(this.scratch,!0),y:e.getUint16(this.scratch+2,!0)}}cursorPoint(){let e=this.cursorPosition();return this.fillPoint(this.point,e.x,e.y,0),this.point}fillPoint(e,t,n,r){this.runtime.setField(e,`GhosttyPoint`,`tag`,r);let i=this.runtime.field(`GhosttyPoint`,`value`),a=this.runtime.dataView();a.setUint16(e+i.offset,Math.max(0,t),!0),a.setUint32(e+i.offset+4,Math.max(0,n),!0)}gridRef(e,t,n){let r=this.runtime.alloc(this.runtime.layout(`GhosttyPoint`).size);this.fillPoint(r,e,t,n);let i=this.runtime.layout(`GhosttyGridRef`).size,a=this.runtime.alloc(i);this.runtime.setField(a,`GhosttyGridRef`,`size`,i);let o=this.runtime.call(`ghostty_terminal_grid_ref`,this.terminal,r,a);return this.runtime.free(r,this.runtime.layout(`GhosttyPoint`).size),o!==0&&(this.runtime.free(a,i),this.runtime.check(`ghostty_terminal_grid_ref`,o)),a}selectAt(e,t,n){let r=this.gridRef(n.x,n.y,2),i=this.runtime.layout(e),a=this.runtime.layout(`GhosttySelection`),o=this.runtime.alloc(i.size),s=this.runtime.alloc(a.size);this.runtime.setField(o,e,`size`,i.size);let c=this.runtime.field(e,`ref`);this.runtime.bytes(o+c.offset,c.size).set(this.runtime.bytes(r,c.size)),this.runtime.setField(s,`GhosttySelection`,`size`,a.size);let l=null;if(this.runtime.call(t,this.terminal,o,s)===0){let e=this.pointFromGridRef(s+this.runtime.field(`GhosttySelection`,`start`).offset,2),t=this.pointFromGridRef(s+this.runtime.field(`GhosttySelection`,`end`).offset,2);e&&t&&(l={start:e,end:t})}return this.runtime.free(s,a.size),this.runtime.free(r,this.runtime.layout(`GhosttyGridRef`).size),this.runtime.free(o,i.size),l}pointFromGridRef(e,t){let n=this.runtime.layout(`GhosttyPointCoordinate`),r=this.runtime.alloc(n.size),i=this.runtime.call(`ghostty_terminal_point_from_grid_ref`,this.terminal,e,t,r)===0?{x:this.runtime.readField(r,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(r,`GhosttyPointCoordinate`,`y`)}:null;return this.runtime.free(r,n.size),i}flag(e,t){return this.runtime.flag(e,this.terminal,t)}terminalColor(e){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.check(`ghostty_terminal_get`,this.runtime.call(`ghostty_terminal_get`,this.terminal,e,this.scratch)),qN(this.runtime,this.scratch)}};function iP(e,t){let n=[],r=e.toLowerCase(),i=t.toLowerCase(),a=r.indexOf(i);for(;a!==-1;)n.push(a),a=r.indexOf(i,a+i.length);return n}var aP=class{core;redraw;listeners=new Set;query=``;matches=[];activeMatch=-1;stale=!1;timer=null;constructor(e,t){this.core=e,this.redraw=t}find(e,t,n,r){let i=this.matches[this.activeMatch]??null;if(this.query=e,this.refresh(),this.matches.length===0)this.activeMatch=-1;else if(n||i===null){let e=i?.row??r,t=this.matches.findIndex(t=>t.row>=e);this.activeMatch=t===-1?this.matches.length-1:t}else{let e=this.matches.findIndex(e=>e.row===i.row&&e.index===i.index),n=e===-1?0:e,r=t?-1:1;this.activeMatch=(n+r+this.matches.length)%this.matches.length}return this.emit(),this.matches[this.activeMatch]??null}onResults(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}clear(){this.query=``,this.matches=[],this.activeMatch=-1}outputChanged(){this.query!==``&&(this.stale=!0,this.timer===null&&(this.timer=window.setTimeout(()=>{if(this.timer=null,!this.stale||this.query===``)return;let e=this.matches[this.activeMatch];this.refresh();let t=e?this.matches.findIndex(t=>t.row===e.row&&t.index===e.index):-1;this.activeMatch=t===-1?this.matches.length-1:t,this.emit(),this.redraw()},200)))}highlights(e,t){if(this.query===``)return[];let n=this.matches[this.activeMatch],r=[];return e.rowData.forEach((e,i)=>{let a=YN(e,i);iP(a.text,this.query).forEach((e,o)=>{let s=a.points[e],c=a.points[e+this.query.length-1];s&&c&&r.push({row:i,start:s.x,end:c.x+1,active:n?.row===t+i&&n.index===o})})}),r}dispose(){this.timer!==null&&window.clearTimeout(this.timer),this.timer=null}refresh(){this.stale=!1,this.matches=[],this.query!==``&&this.core.screenText().split(`
|
|
14
|
+
`),s=i.length===1?i[0]:`${i.length} branches`;async function l(t){r(!0);try{await L(e.machine,`git.sync`,{projectId:e.projectId,repo:t})}catch(e){c(e)}finally{r(!1),e.onRefresh()}}return(0,G.jsxs)(G.Fragment,{children:[e.repos.length===1&&(0,G.jsx)(on,{machine:e.machine,projectId:e.projectId,repo:e.repos[0],onRefresh:e.onRefresh}),e.repos.length>1&&a.length===0&&(0,G.jsxs)(`span`,{className:`text-muted-foreground hidden max-w-48 items-center gap-1 text-xs sm:flex`,title:o,children:[(0,G.jsx)(H,{icon:Xn,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`truncate`,children:s})]}),e.repos.length>1&&a.length>0&&(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground hidden max-w-48 cursor-pointer items-center gap-1 text-xs sm:flex`,title:o,children:[(0,G.jsx)(H,{icon:n?jr:a.length===1?a[0].next.icon:jn,className:B(`size-3.5 shrink-0`,n&&`animate-spin`)}),(0,G.jsx)(`span`,{className:`truncate`,children:s})]})}),(0,G.jsx)(Dn,{align:`end`,className:`w-64`,children:a.map(e=>(0,G.jsxs)(Mr,{disabled:n,onSelect:()=>void l(e.repo.path),children:[(0,G.jsx)(H,{icon:e.next.icon}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.next.label,` ·`,` `,e.repo.path===``?e.repo.branch:e.repo.path]}),(0,G.jsx)(`span`,{className:`text-muted-foreground flex gap-1 text-xs`,children:(0,G.jsx)(Er,{behind:e.repo.behind,ahead:e.repo.ahead})})]},e.repo.path))})]}),(0,G.jsxs)(`div`,{className:`ml-2.5 flex w-fit`,children:[(0,G.jsxs)(U,{variant:`outline`,size:`xs`,className:`rounded-e-none border-e-0`,disabled:t.committable.length===0,onClick:()=>t.setAction(`commit`),children:[(0,G.jsx)(H,{icon:ls}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:`Commit`})]}),(0,G.jsxs)(mn,{open:t.menuOpen,onOpenChange:t.setMenuOpen,children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(U,{variant:`outline`,size:`icon-xs`,className:`rounded-s-none`,"aria-label":`Git actions`,children:(0,G.jsx)(H,{icon:t.committing?jr:Rr,className:B(`size-4`,t.committing&&`animate-spin`)})})}),(0,G.jsx)(Dn,{align:`end`,className:`w-56`,children:(0,G.jsx)(kh,{git:t,collapsed:!1})})]})]}),(0,G.jsx)(Ah,{git:t})]})}function Mh({className:e,size:t=`default`,...n}){return(0,G.jsx)(ed,{"data-slot":`switch`,"data-size":t,className:B(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,G.jsx)(nd,{"data-slot":`switch-thumb`,className:`bg-background dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground pointer-events-none block rounded-full ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0`})})}function Nh(e){return(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`h2`,{className:`text-muted-foreground mb-2 px-1 text-xs font-medium`,children:[e.title,e.note&&(0,G.jsxs)(`span`,{className:`font-normal`,children:[` · `,e.note]})]}),(0,G.jsx)(`div`,{className:`@container divide-y overflow-hidden rounded-xl border`,children:e.children})]})}function Q(e){return(0,G.jsxs)(`label`,{className:`flex min-h-13 flex-wrap items-center gap-x-4 gap-y-2 px-4 py-2.5`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 basis-40 text-sm font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`max-w-full shrink-0 @max-lg:has-[[data-slot=select-trigger],input:not([type=number])]:w-full @max-lg:has-[[data-slot=select-trigger],input:not([type=number])]:*:w-full @max-lg:**:data-[slot=select-trigger]:w-full`,children:e.children})]})}function Ph(e){let[t,n]=(0,W.useState)(e.value);function r(){t!==e.value&&(e.valid&&!e.valid(t)?n(e.value):e.onCommit(t))}return(0,G.jsx)(Tp,{className:B(`w-56`,e.className),type:e.type,min:e.type===`number`?0:void 0,step:e.step,placeholder:e.placeholder,disabled:e.disabled,value:t,onChange:e=>n(e.target.value),onBlur:r,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}function Fh(e){return(0,G.jsx)(Ph,{type:`number`,className:`w-24`,step:e.step??1,value:String(e.value),valid:e=>e!==``&&Number(e)>=0,onCommit:t=>e.onCommit(Number(t))},e.value)}function Ih(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null);return(0,W.useEffect)(()=>{let t=!0;return n(null),i(null),L(e.machine,`dictation.workflows`,void 0).then(e=>{t&&n(e)},e=>{t&&i(Ht(e))}),()=>{t=!1}},[e.machine]),(0,G.jsx)(Nh,{title:`Dictation`,note:`This machine transcribes your recordings with the OiPer app`,children:(0,G.jsx)(Q,{label:`OiPer workflow`,children:r===null?t===null?(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Checking…`}):(0,G.jsxs)(fh,{value:e.config.dictation.workflowId??``,onValueChange:t=>void po(e.machine,{...e.config,dictation:{...e.config.dictation,workflowId:t}}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{placeholder:`Choose a workflow`})}),(0,G.jsx)(hh,{children:t.map(e=>(0,G.jsx)(gh,{value:e.id,children:e.name},e.id))})]}):(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:r})})})}var Lh=`3.6.8`,Rh=`1.3.1`,zh=[{family:`FiraCode Nerd Font`,label:`Fira Code`},{family:`JetBrainsMono Nerd Font`,label:`JetBrains Mono`},{family:`CaskaydiaCove Nerd Font`,label:`Cascadia Code`},{family:`Hack Nerd Font`,label:`Hack`}],Bh=[{value:`macos`,label:`macOS`},{value:`linux`,label:`Linux`},{value:`windows`,label:`Windows`}];async function Vh(e){let t=`${e.font.size}px ${e.font.family}`;await Promise.all([document.fonts.load(t),document.fonts.load(`bold ${t}`)]);let n=document.documentElement.style;n.setProperty(`--pad-top`,`${e.padding.top}px`),n.setProperty(`--pad-right`,`${e.padding.right}px`),n.setProperty(`--pad-bottom`,`${e.padding.bottom}px`),n.setProperty(`--pad-left`,`${e.padding.left}px`)}function Hh(e,t){let n=te();return{fontFamily:e.font.family,fontSize:e.font.size,lineHeight:e.font.lineHeight,ligatures:e.font.ligatures,cursorStyle:e.cursor.style,cursorBlink:e.cursor.blink,scrollback:e.scrollback,boldIsBright:e.boldIsBright,colors:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorText:n.background,selectionBackground:n.selectionBackground,selectionForeground:n.foreground,palette:n.palette},version:Uh(t),clickToMoveCursor:e.behavior.clickToMoveCursor,optionAsMeta:e.behavior.optionAsMeta,windowsCopyPaste:e.behavior.windowsCopyPaste}}function Uh(e){if(e===`offsite`)return`offsite 0.0.0`;if(e===`ghostty`)return`ghostty ${Rh}`;if(e===`iterm2`)return`iTerm2 ${Lh}`;throw Error(`unknown terminal identity ${e}`)}function Wh(e){let t=e.prefs.editor,[n,r]=(0,W.useState)(!zh.some(e=>e.family===t.font.family));function i(t){Ye({...e.prefs,editor:t})}function a(e,n){i({...t,[e]:{...t[e],...n}})}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Nh,{title:`Font`,children:[(0,G.jsx)(Q,{label:`Family`,children:(0,G.jsxs)(fh,{value:n?`custom`:t.font.family,onValueChange:e=>{r(e===`custom`),e!==`custom`&&a(`font`,{family:e})},children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[zh.map(e=>(0,G.jsx)(gh,{value:e.family,children:e.label},e.family)),(0,G.jsx)(gh,{value:`custom`,children:`Custom`})]})]})}),n&&(0,G.jsx)(Q,{label:`Custom family`,children:(0,G.jsx)(Ph,{placeholder:`Installed font name`,value:t.font.family,onCommit:e=>a(`font`,{family:e})})}),(0,G.jsx)(Q,{label:`Size`,children:(0,G.jsx)(Fh,{value:t.font.size,step:.5,onCommit:e=>a(`font`,{size:e})})}),(0,G.jsx)(Q,{label:`Line height`,children:(0,G.jsx)(Fh,{value:t.font.lineHeight,step:.05,onCommit:e=>a(`font`,{lineHeight:e})})}),(0,G.jsx)(Q,{label:`Ligatures`,children:(0,G.jsx)(Mh,{checked:t.font.ligatures,onCheckedChange:e=>a(`font`,{ligatures:e})})}),(0,G.jsx)(Q,{label:`Font features`,children:(0,G.jsx)(Ph,{placeholder:`'ss01', 'zero'`,value:t.font.features,onCommit:e=>a(`font`,{features:e})})})]}),(0,G.jsxs)(Nh,{title:`Cursor`,children:[(0,G.jsx)(Q,{label:`Style`,children:(0,G.jsxs)(fh,{value:t.cursor.style,onValueChange:e=>a(`cursor`,{style:e}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`block`,children:`Block`}),(0,G.jsx)(gh,{value:`bar`,children:`Bar`}),(0,G.jsx)(gh,{value:`underline`,children:`Underline`})]})]})}),(0,G.jsx)(Q,{label:`Blink`,children:(0,G.jsx)(Mh,{checked:t.cursor.blink,onCheckedChange:e=>a(`cursor`,{blink:e})})})]}),(0,G.jsxs)(Nh,{title:`Text`,children:[(0,G.jsx)(Q,{label:`Tab size`,children:(0,G.jsx)(Fh,{value:t.tabSize,onCommit:e=>i({...t,tabSize:e})})}),(0,G.jsx)(Q,{label:`Word wrap`,children:(0,G.jsx)(Mh,{checked:t.wordWrap,onCheckedChange:e=>i({...t,wordWrap:e})})})]})]})}var Gh=[{id:`original`,name:`Original`,scale:1,tile:null},{id:`small`,name:`Small`,scale:.7,tile:null},{id:`dark`,name:`Dark`,scale:.7,tile:{color:`#0a0a0a`,shape:`rounded`}},{id:`light`,name:`Light`,scale:.7,tile:{color:`#ffffff`,shape:`rounded`}},{id:`dark-circle`,name:`Dark circle`,scale:.62,tile:{color:`#0a0a0a`,shape:`circle`}},{id:`light-circle`,name:`Light circle`,scale:.62,tile:{color:`#ffffff`,shape:`circle`}},{id:`dark-square`,name:`Dark square`,scale:.7,tile:{color:`#0a0a0a`,shape:`square`}},{id:`light-square`,name:`Light square`,scale:.7,tile:{color:`#ffffff`,shape:`square`}}],Kh=Fe.withTag(`settings`);function qh(e){let t=e.prefs;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Nh,{title:`Appearance`,children:(0,G.jsx)(Q,{label:`Theme`,children:(0,G.jsxs)(fh,{value:t.theme,onValueChange:e=>Ye({...t,theme:e}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsx)(hh,{children:ae.map(e=>(0,G.jsx)(gh,{value:e.id,children:e.name},e.id))})]})})}),(0,G.jsx)(Nh,{title:`Sidebar`,children:(0,G.jsx)(Q,{label:`Group active sessions by project in Inbox`,children:(0,G.jsx)(Mh,{checked:t.groupActiveByProject,onCheckedChange:e=>Ye({...t,groupActiveByProject:e})})})}),(0,G.jsxs)(Nh,{title:`Dictate button`,note:`Takes the place of Send while the message is empty`,children:[(0,G.jsx)(Q,{label:`On desktop`,children:(0,G.jsx)(Mh,{checked:t.dictateButton.desktop,onCheckedChange:e=>Ye({...t,dictateButton:{...t.dictateButton,desktop:e}})})}),(0,G.jsx)(Q,{label:`On mobile`,children:(0,G.jsx)(Mh,{checked:t.dictateButton.mobile,onCheckedChange:e=>Ye({...t,dictateButton:{...t.dictateButton,mobile:e}})})})]}),(0,G.jsx)(Xh,{}),(0,G.jsx)(Jh,{}),(0,G.jsx)(U,{variant:`outline`,onClick:e.onRestore,children:`Restore browser defaults`})]})}function Jh(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(null);async function i(){t(!0),r(null);try{let e=`serviceWorker`in navigator?await navigator.serviceWorker.getRegistration():void 0;if(e===void 0){let e=await fetch(`/?update=${Date.now()}`,{cache:`no-store`});if(!e.ok)throw Error(`the server answered ${e.status}`)}else{await e.update();let t=e.installing??e.waiting;t!==null&&await Yh(t)}location.reload()}catch(e){Kh.error(`could not update`,e),r(Ht(e)),t(!1)}}return(0,G.jsx)(Nh,{title:`App`,children:(0,G.jsx)(Q,{label:`Load the newest version of OffSite in this browser`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[n!==null&&(0,G.jsxs)(`span`,{className:`text-destructive text-xs`,children:[`Could not update: `,n]}),(0,G.jsxs)(U,{size:`sm`,variant:`outline`,disabled:e,onClick:()=>void i(),children:[e&&(0,G.jsx)(H,{icon:Gn,className:`animate-spin`}),e?`Updating…`:`Update`]})]})})})}async function Yh(e){await new Promise((t,n)=>{function r(){e.state===`activated`&&t(),e.state===`redundant`&&n(Error(`the new version failed to install`))}e.addEventListener(`statechange`,r),r()})}function Xh(){let e=k(e=>e.machines.find(e=>e.addresses.some(e=>(o??[location.origin]).includes(e))));if(e===void 0||e.appIcon===null)return null;let t=e.appIcon;return(0,G.jsx)(Nh,{title:`App icon`,children:(0,G.jsx)(`div`,{className:`grid grid-cols-4 gap-2 p-3 @max-lg:grid-cols-2`,children:Gh.map(n=>(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":t===n.id,className:B(`hover:bg-accent flex flex-col items-center gap-2 rounded-lg border p-3 text-xs`,t===n.id&&`border-primary bg-accent`),onClick:()=>L(e.id,`appIcon.save`,n.id).catch(c),children:[(0,G.jsx)(`span`,{className:B(`flex size-12 items-center justify-center`,n.tile?.shape===`rounded`&&`rounded-[22%]`,n.tile?.shape===`circle`&&`rounded-full`,n.tile!==null&&`ring-border ring-1`),style:{background:n.tile?.color},children:(0,G.jsx)(`img`,{src:`/icon.svg`,alt:``,style:{width:`${n.scale*100}%`}})}),n.name]},n.id))})})}function Zh(e){for(let t=0;t<e.length;t++){let n=e[t];if(!n.startsWith(`-`)&&!n.startsWith(`+`))return!1;let r=n.startsWith(`-`),i=n.slice(1);if(i===``||i===`-`)return!1;if(i.startsWith(`-`)){if(!Qh(i.slice(1),r))return!1}else for(let n=0;n<i.length;n++){let a=i[n];if(a===`o`){let a=i.slice(n+1);if(a===``){if(t++,t===e.length)return!1;a=e[t]}if(!Qh(a,r))return!1;break}if(a===`b`||a===`c`||r&&`dfnprvx`.includes(a)||!r&&a===`i`)return!1}}return!0}function Qh(e,t){let n=e.toLowerCase().replace(/[-_]/g,``),r=t;return n.startsWith(`no`)&&(n=n.slice(2),r=!t),[`rcs`,`globalrcs`,`interactive`,`exec`].includes(n)?r:![`privileged`,`restricted`,`sourcetrace`,`verbose`,`xtrace`].includes(n)||!r}function $h(e,t,n){if(t===`windows`)return`Not available on Windows`;if(e!==null&&/[\n"'\\$`;&|<>()*?[\]{}#!]/.test(e))return`Not available for commands with shell syntax`;let r=e===null?[n]:e.split(/[ \t]/).filter(e=>e!==``);if(r.length===0)return`Available for bash, zsh and fish`;let i=r[0],a=i.split(`/`).pop(),o=r.slice(1);return a===`bash`?t===`macos`&&(i===`/bin/bash`||!i.includes(`/`))?`Needs a newer bash than the one macOS includes`:o.every(e=>[`-l`,`--login`,`-i`].includes(e))?null:`Not available with these bash options`:a===`zsh`?Zh(o)?null:`Not available with these zsh options`:a===`fish`?o.every(e=>{if(e.startsWith(`--`)){let t=e.slice(2).split(`=`)[0];return t===``||![`command`,`no-config`,`no-execute`].some(e=>e.startsWith(t))}return!(e.startsWith(`-`)&&/[cNn]/.test(e))})?null:`Not available with these fish options`:`Available for bash, zsh and fish`}var eg=[10,15,30,45,60,120,180,300,600,900,1800,3600];function tg(e){let t=e.config;function n(n){po(e.machine,{...t,...n})}return(0,G.jsxs)(Nh,{title:`Agents`,children:[(0,G.jsx)(Q,{label:`Send while working`,children:(0,G.jsxs)(fh,{value:t.delivery,onValueChange:n=>{if(n!==`queue`&&n!==`steer`)throw Error(`Unknown delivery ${n}`);po(e.machine,{...t,delivery:n})},children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`queue`,children:`Queue messages`}),(0,G.jsx)(gh,{value:`steer`,children:`Steer the agent`})]})]})}),(0,G.jsx)(Q,{label:`Auto-skip questions`,children:(0,G.jsx)(ng,{value:t.autoSkipQuestionTimeout,onChange:e=>n({autoSkipQuestionTimeout:e})})}),(0,G.jsx)(Q,{label:`Auto-resolve permissions`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(fh,{value:t.autoPermissionMode,onValueChange:e=>{if(e!==`bypass`&&e!==`allow`&&e!==`deny`)throw Error(`Unknown decision ${e}`);n({autoPermissionMode:e})},children:[(0,G.jsx)(mh,{className:`w-24`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`bypass`,children:`Bypass`}),(0,G.jsx)(gh,{value:`allow`,children:`Allow`}),(0,G.jsx)(gh,{value:`deny`,children:`Deny`})]})]}),(0,G.jsx)(ng,{value:t.autoPermissionTimeout,onChange:e=>n({autoPermissionTimeout:e})})]})})]})}function ng(e){let t=e.value===null||eg.includes(e.value)?eg:[...eg,e.value].sort((e,t)=>e-t);return(0,G.jsxs)(fh,{value:e.value===null?`off`:String(e.value),onValueChange:t=>e.onChange(t===`off`?null:Number(t)),children:[(0,G.jsx)(mh,{className:`w-40`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`off`,children:`Off`}),t.map(e=>(0,G.jsx)(gh,{value:String(e),children:e===3600?`After 1 hour`:e===60?`After 1 minute`:e%60==0?`After ${e/60} minutes`:`After ${e} seconds`},e))]})]})}function rg(e){let t=e.config[e.setting],[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(t.provider===null)return;let n=!0;return r(null),a(null),L(e.machine,`capabilities`,{provider:t.provider,accountId:t.accountId,projectId:null}).then(e=>{n&&r(e.models)},e=>{n&&a(Ht(e))}),()=>{n=!1}},[e.machine,t.provider,t.accountId]);function o(t){po(e.machine,{...e.config,[e.setting]:t})}function s(t){if(t===`off`){o({provider:null,accountId:null,model:null});return}if(t===`opencode`){o({provider:`opencode`,accountId:null,model:null});return}let n=[...e.claudeAccounts,...e.codexAccounts].find(e=>e.id===t);if(n===void 0)throw Error(`That account was removed`);o({provider:n.provider,accountId:n.id,model:null})}return(0,G.jsxs)(Nh,{title:e.title,children:[(0,G.jsx)(Q,{label:`Account`,children:(0,G.jsxs)(fh,{value:t.provider===null?`off`:t.provider===`opencode`?`opencode`:t.accountId??`off`,onValueChange:s,children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`off`,children:`Off`}),[...e.claudeAccounts,...e.codexAccounts].map(e=>(0,G.jsxs)(gh,{value:e.id,disabled:!e.valid,children:[(0,G.jsx)(gc,{provider:e.provider,className:`size-4`}),`${rr[e.provider]} · ${e.name}`]},e.id)),e.openCode.available&&(0,G.jsxs)(gh,{value:`opencode`,children:[(0,G.jsx)(gc,{provider:`opencode`,className:`size-4`}),rr.opencode]})]})]})}),t.provider!==null&&(0,G.jsx)(Q,{label:`Model`,children:(0,G.jsxs)(fh,{value:t.model??void 0,disabled:n===null,onValueChange:e=>o({...t,model:e}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{placeholder:i===null?n===null?`Loading…`:`Choose a model`:`Unavailable`})}),(0,G.jsx)(hh,{children:(n??[]).map(e=>(0,G.jsx)(gh,{value:e.value,children:e.name},e.value))})]})}),i!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:i})]})}var ig={zsh:`M11.415 5.038a.58.58 0 0 0-.543.197L.135 18.021a.58.58 0 0 0 .071.814.58.58 0 0 0 .815-.07L11.757 5.979a.58.58 0 0 0-.07-.815.6.6 0 0 0-.272-.126m-8.113.317a3.133 3.133 0 0 0-3.12 3.12 3.13 3.13 0 0 0 3.12 3.119A3.133 3.133 0 0 0 6.42 8.475a3.13 3.13 0 0 0-3.119-3.119m0 1.806a1.3 1.3 0 0 1 1.314 1.313 1.3 1.3 0 0 1-1.314 1.312A1.3 1.3 0 0 1 1.99 8.475a1.3 1.3 0 0 1 1.312-1.314m5.253 5.253a3.13 3.13 0 0 0-3.119 3.119 3.13 3.13 0 0 0 3.12 3.118 3.133 3.133 0 0 0 3.118-3.12 3.133 3.133 0 0 0-3.119-3.118m0 1.805a1.3 1.3 0 0 1 1.313 1.314c0 .735-.577 1.312-1.312 1.312a1.3 1.3 0 0 1-1.314-1.312 1.3 1.3 0 0 1 1.313-1.314m7.201 3.276a.58.58 0 0 0-.578.578.58.58 0 0 0 .578.578h7.666a.58.58 0 0 0 .579-.578.58.58 0 0 0-.579-.578Z`,bash:`M21.038,4.9l-7.577-4.498C13.009,0.134,12.505,0,12,0c-0.505,0-1.009,0.134-1.462,0.403L2.961,4.9 C2.057,5.437,1.5,6.429,1.5,7.503v8.995c0,1.073,0.557,2.066,1.462,2.603l7.577,4.497C10.991,23.866,11.495,24,12,24 c0.505,0,1.009-0.134,1.461-0.402l7.577-4.497c0.904-0.537,1.462-1.529,1.462-2.603V7.503C22.5,6.429,21.943,5.437,21.038,4.9z M15.17,18.946l0.013,0.646c0.001,0.078-0.05,0.167-0.111,0.198l-0.383,0.22c-0.061,0.031-0.111-0.007-0.112-0.085L14.57,19.29 c-0.328,0.136-0.66,0.169-0.872,0.084c-0.04-0.016-0.057-0.075-0.041-0.142l0.139-0.584c0.011-0.046,0.036-0.092,0.069-0.121 c0.012-0.011,0.024-0.02,0.036-0.026c0.022-0.011,0.043-0.014,0.062-0.006c0.229,0.077,0.521,0.041,0.802-0.101 c0.357-0.181,0.596-0.545,0.592-0.907c-0.003-0.328-0.181-0.465-0.613-0.468c-0.55,0.001-1.064-0.107-1.072-0.917 c-0.007-0.667,0.34-1.361,0.889-1.8l-0.007-0.652c-0.001-0.08,0.048-0.168,0.111-0.2l0.37-0.236 c0.061-0.031,0.111,0.007,0.112,0.087l0.006,0.653c0.273-0.109,0.511-0.138,0.726-0.088c0.047,0.012,0.067,0.076,0.048,0.151 l-0.144,0.578c-0.011,0.044-0.036,0.088-0.065,0.116c-0.012,0.012-0.025,0.021-0.038,0.028c-0.019,0.01-0.038,0.013-0.057,0.009 c-0.098-0.022-0.332-0.073-0.699,0.113c-0.385,0.195-0.52,0.53-0.517,0.778c0.003,0.297,0.155,0.387,0.681,0.396 c0.7,0.012,1.003,0.318,1.01,1.023C16.105,17.747,15.736,18.491,15.17,18.946z M19.143,17.859c0,0.06-0.008,0.116-0.058,0.145 l-1.916,1.164c-0.05,0.029-0.09,0.004-0.09-0.056v-0.494c0-0.06,0.037-0.093,0.087-0.122l1.887-1.129 c0.05-0.029,0.09-0.004,0.09,0.056V17.859z M20.459,6.797l-7.168,4.427c-0.894,0.523-1.553,1.109-1.553,2.187v8.833 c0,0.645,0.26,1.063,0.66,1.184c-0.131,0.023-0.264,0.039-0.398,0.039c-0.42,0-0.833-0.114-1.197-0.33L3.226,18.64 c-0.741-0.44-1.201-1.261-1.201-2.142V7.503c0-0.881,0.46-1.702,1.201-2.142l7.577-4.498c0.363-0.216,0.777-0.33,1.197-0.33 c0.419,0,0.833,0.114,1.197,0.33l7.577,4.498c0.624,0.371,1.046,1.013,1.164,1.732C21.686,6.557,21.12,6.411,20.459,6.797z`,fish:`m19.164 9.228-3.016 2.688v.527l3.016 2.688v-1.228l-1.936-1.723 1.936-1.724V9.228m-6.658.046v1.208l1.905 1.696-1.905 1.695v1.209l2.968-2.645v-.518l-2.968-2.645M9.781 7.847a6.519 6.519 0 0 0-2.038-.335c-.672 0-1.349.112-2.03.335a9.23 9.23 0 0 0-2.088 1.017v.723c.69-.4 1.377-.7 2.06-.897a7.388 7.388 0 0 1 2.058-.296c.684 0 1.368.098 2.052.296a9.452 9.452 0 0 1 2.075.897v-.723a9.229 9.229 0 0 0-2.09-1.017m.014 7.78a7.371 7.371 0 0 1-2.052.296 7.388 7.388 0 0 1-2.057-.296 9.18 9.18 0 0 1-2.061-.897v.723a9.228 9.228 0 0 0 2.088 1.017 6.492 6.492 0 0 0 2.03.335c.678 0 1.357-.112 2.038-.335a9.227 9.227 0 0 0 2.089-1.017v-.723c-.7.4-1.391.7-2.075.897m.602-11.23h-.51L7.28 6.92h1.19l1.672-1.62 1.671 1.62h1.191l-2.607-2.525m-2.965 13.68v-.824H6.427v.825l.786 1.527h.614l-.395-1.527M4.127 10.95v1.216H5.13V10.95H4.127m-1.16-1.695L0 11.901v.518l2.967 2.645v-1.208L1.063 12.16l1.904-1.695V9.256m20.68 3.28c-.235-.3-.574-.509-1.017-.626.395-.103.696-.278.902-.525.206-.247.31-.556.31-.926 0-.546-.197-.984-.59-1.314-.393-.33-.919-.495-1.575-.495-.22 0-.473.025-.758.073-.284.048-.61.12-.974.217v.84c.314-.12.613-.21.9-.27a4.05 4.05 0 0 1 .832-.091c.403 0 .714.093.933.278.218.185.328.451.328.798 0 .328-.118.584-.353.768-.235.184-.562.276-.98.276h-.697v.75h.696c.458 0 .821.116 1.09.346.268.23.402.542.402.934 0 .425-.134.75-.402.976-.269.226-.653.339-1.153.339a3.55 3.55 0 0 1-.89-.117 4.395 4.395 0 0 1-.91-.358v.909a6.1 6.1 0 0 0 .95.249c.323.057.639.085.95.085.738 0 1.315-.177 1.733-.53.417-.355.626-.842.626-1.463 0-.449-.118-.823-.353-1.123`,powershell:`M23.181 2.974c.568 0 .923.463.792 1.035l-3.659 15.982c-.13.572-.697 1.035-1.265 1.035H.819c-.568 0-.923-.463-.792-1.035L3.686 4.009c.13-.572.697-1.035 1.265-1.035zm-8.375 9.346c.251-.394.227-.905-.09-1.243L9.122 5.125c-.38-.404-1.037-.407-1.466-.003-.429.402-.468 1.056-.088 1.46l4.662 4.96v.11l-7.42 5.374c-.45.327-.533.977-.187 1.453.346.476.991.597 1.44.27l8.229-5.91c.28-.196.438-.365.514-.52zm-2.796 4.399a.928.928 0 00-.934.923c0 .51.418.923.934.923h4.433a.928.928 0 00.934-.923.928.928 0 00-.934-.923z`,cmd:`M8.165 6V3h7.665v3H8.165zm-.5-3H1c-.55 0-1 .45-1 1v2h7.665V3zM23 3h-6.67v3H24V4c0-.55-.45-1-1-1zM0 6.5h24V20c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V6.5zM11.5 18c0 .3.2.5.5.5h8c.3 0 .5-.2.5-.5v-1.5c0-.3-.2-.5-.5-.5h-8c-.3 0-.5.2-.5.5V18zm-5.2-4.55l-3.1 3.1c-.25.25-.25.6 0 .8l.9.9c.25.25.6.25.8 0l4.4-4.4a.52.52 0 0 0 0-.8l-4.4-4.4c-.2-.2-.6-.2-.8 0l-.9.9c-.25.2-.25.55 0 .8l3.1 3.1z`},ag={zsh:`zsh`,bash:`bash`,fish:`fish`,pwsh:`powershell`,powershell:`powershell`,cmd:`cmd`},og={macos:[`zsh`,`bash`,`fish`,`pwsh`],linux:[`bash`,`zsh`,`fish`,`pwsh`],windows:[`pwsh`,`powershell`,`cmd`]};function sg(e){let t=e.trim().split(/[\\/]/).pop()?.toLowerCase().replace(/\.exe$/,``);return t===void 0?void 0:ag[t]}function cg(e){return e.replace(/[\\/][^\\/]*$/,``)}function lg(e){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-4 flex-none`,fill:`currentColor`,children:(0,G.jsx)(`path`,{d:ig[e.logo]})})}function ug(e){let[t,n]=(0,W.useState)(e.value??``),r=sg(t);function i(t){n(t),t!==(e.value??``)&&e.onCommit(t===``?null:t)}return(0,G.jsxs)(`div`,{className:`relative w-56`,children:[r&&(0,G.jsx)(`span`,{className:`text-muted-foreground pointer-events-none absolute top-1/2 left-2.5 -translate-y-1/2`,children:(0,G.jsx)(lg,{logo:r})}),(0,G.jsx)(Tp,{className:r?`pr-9 pl-8`:`pr-9`,placeholder:`System default`,value:t,onChange:e=>n(e.target.value),onBlur:()=>i(t),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}}),(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(U,{variant:`ghost`,size:`icon-xs`,"aria-label":`Known shells`,className:`text-muted-foreground absolute top-1/2 right-1.5 -translate-y-1/2`,children:(0,G.jsx)(H,{icon:Dr})})}),(0,G.jsx)(Dn,{align:`end`,className:`w-72`,children:(0,G.jsx)(dg,{machine:e.machine,platform:e.platform,device:e.device,onCommit:i})})]})]})}function dg(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null),a=e.platform===e.device,o=a?t:og[e.platform].map(e=>({name:e,path:null}));return(0,W.useEffect)(()=>{a&&L(e.machine,`terminal.shells`,void 0).then(n,e=>i(Ht(e)))},[e.machine,a]),(0,G.jsxs)(G.Fragment,{children:[r&&(0,G.jsx)(`p`,{className:`text-destructive px-2 py-1.5 text-xs`,children:r}),o?.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground px-2 py-1.5 text-xs`,children:`No known shells found`}),o?.map(t=>(0,G.jsxs)(Mr,{onSelect:()=>e.onCommit(t.path??t.name),children:[(0,G.jsx)(lg,{logo:ag[t.name]}),t.name,t.path!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground ml-auto min-w-0 truncate pl-3 text-xs [direction:rtl]`,title:t.path,children:(0,G.jsx)(`bdi`,{children:cg(t.path)})})]},t.path??t.name)),(0,G.jsx)(Pn,{}),(0,G.jsx)(Mr,{onSelect:()=>e.onCommit(``),children:`System default`})]})}function fg(e){let t=e.config.workingDir[e.platform]??``;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Nh,{title:`Projects`,children:(0,G.jsx)(Q,{label:`Working directory`,children:(0,G.jsx)(Ph,{className:`w-72 font-mono`,value:t,placeholder:`Home folder`,onCommit:t=>po(e.machine,{...e.config,workingDir:{...e.config.workingDir,[e.platform]:t.trim()===``?null:t.trim()}})},`${e.machine}-${t}`)})}),(0,G.jsx)(pg,{machine:e.machine,config:e.config,platform:e.platform,defaultShell:e.defaultShell},e.machine),(0,G.jsx)(tg,{machine:e.machine,config:e.config}),(0,G.jsx)(rg,{title:`Commit messages and pull requests`,setting:`commitMessage`,machine:e.machine,config:e.config,claudeAccounts:e.claudeAccounts,codexAccounts:e.codexAccounts,openCode:e.openCode},`git-${e.machine}`),(0,G.jsx)(rg,{title:`Session titles`,setting:`titleGeneration`,machine:e.machine,config:e.config,claudeAccounts:e.claudeAccounts,codexAccounts:e.codexAccounts,openCode:e.openCode},`titles-${e.machine}`),(0,G.jsx)(U,{variant:`outline`,onClick:e.onRestore,children:`Restore machine defaults`})]})}function pg(e){let t=e.config.terminal,[n,r]=(0,W.useState)(e.platform),i=$h(t.shell[e.platform],e.platform,e.defaultShell);function a(t){po(e.machine,{...e.config,terminal:t})}return(0,G.jsxs)(Nh,{title:`Shell`,note:`Applies to new terminals`,children:[(0,G.jsx)(Q,{label:`Platform`,children:(0,G.jsxs)(fh,{value:n,onValueChange:e=>r(e),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsx)(hh,{children:Bh.map(t=>(0,G.jsxs)(gh,{value:t.value,children:[t.label,t.value===e.platform&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`(this machine)`})]},t.value))})]})}),(0,G.jsx)(Q,{label:`Command`,children:(0,G.jsx)(ug,{machine:e.machine,platform:n,device:e.platform,value:t.shell[n],onCommit:e=>a({...t,shell:{...t.shell,[n]:e}})},`${e.machine}-${n}-command`)}),(0,G.jsx)(Q,{label:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Shell integration`,(0,G.jsx)(Xr,{label:(0,G.jsxs)(`div`,{children:[`Tells the terminal where prompts and commands start and end.`,(0,G.jsxs)(`ul`,{className:`mt-1 list-disc pl-4`,children:[(0,G.jsx)(`li`,{children:`Click in the command line to move the cursor`}),(0,G.jsx)(`li`,{children:`Ignore clipboard reads once the command that asked has finished`})]})]}),children:(0,G.jsx)(`span`,{onClick:e=>e.preventDefault(),children:(0,G.jsx)(H,{icon:_s,"aria-label":`About shell integration`,className:`text-muted-foreground size-3.5`})})})]}),children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground max-w-32 text-right text-xs sm:max-w-none`,children:i}),(0,G.jsx)(Mh,{checked:i===null&&t.behavior.shellIntegration,disabled:i!==null,onCheckedChange:e=>a({...t,behavior:{...t.behavior,shellIntegration:e}})})]})}),(0,G.jsx)(mg,{identity:t.behavior.terminalIdentity,onChange:e=>a({...t,behavior:{...t.behavior,terminalIdentity:e}})})]})}function mg(e){return(0,G.jsx)(Q,{label:`Report the terminal as`,children:(0,G.jsxs)(fh,{value:e.identity,onValueChange:e.onChange,children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`offsite`,children:`OffSite`}),(0,G.jsx)(gh,{value:`ghostty`,children:`Ghostty`}),(0,G.jsx)(gh,{value:`iterm2`,children:`iTerm2`})]})]})})}var hg=(0,W.createContext)({});function gg(e){let t=(0,W.useRef)(null);return t.current===null&&(t.current=e()),t.current}var _g=typeof window<`u`?W.useLayoutEffect:W.useEffect,vg=(0,W.createContext)(null);function yg(e,t){e.indexOf(t)===-1&&e.push(t)}function bg(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}function xg([...e],t,n){let r=t<0?e.length+t:t;if(r>=0&&r<e.length){let r=n<0?e.length+n:n,[i]=e.splice(t,1);e.splice(r,0,i)}return e}var Sg=(e,t,n)=>n>t?t:n<e?e:n,Cg={},wg=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),Tg=e=>typeof e==`object`&&!!e,Eg=e=>/^0[^.\s]+$/u.test(e);function Dg(e){let t;return()=>(t===void 0&&(t=e()),t)}var Og=e=>e,kg=(...e)=>e.reduce((e,t)=>n=>t(e(n))),Ag=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},jg=class{constructor(){this.subscriptions=[]}add(e){return yg(this.subscriptions,e),()=>this.remove(e)}remove(e){bg(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r){if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},Mg=e=>e*1e3,Ng=e=>e/1e3,Pg=(e,t)=>t?1e3/t*e:0,Fg=(e,t,n)=>e*(3*(1-e)*((1-e)*t+e*n)+e*e);function Ig(e,t,n,r){return e===t&&n===r?Og:i=>{let a=0,o=1,s=i;for(let t=0;;t++){s>=a&&s<=o||(s=(a+o)/2);let r=Fg(s,e,n)-i;if(r*r<1e-28||t===40)break;r>0?o=s:a=s,s-=r*1e-7/(Fg(s+1e-7,e,n)-i-r)}return Fg(s,t,r)}}var Lg=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Rg=e=>t=>1-e(1-t),zg=Ig(.33,1.53,.69,.99),Bg=Rg(zg),Vg=Lg(Bg),Hg=e=>e>=1?1:(e*=2)<1?.5*Bg(e):.5*(2-2**(-10*(e-1))),Ug=e=>1-Math.sin(Math.acos(e)),Wg=Rg(Ug),Gg=Lg(Ug),Kg=Ig(.42,0,1,1),qg=Ig(0,0,.58,1),Jg=Ig(.42,0,.58,1),Yg=e=>Array.isArray(e)&&typeof e[0]!=`number`,Xg=e=>Array.isArray(e)&&typeof e[0]==`number`,Zg={linear:Og,easeIn:Kg,easeInOut:Jg,easeOut:qg,circIn:Ug,circInOut:Gg,circOut:Wg,backIn:Bg,backInOut:Vg,backOut:zg,anticipate:Hg},Qg=e=>typeof e==`string`,$g=e=>{if(Xg(e)){let[t,n,r,i]=e;return Ig(t,n,r,i)}return Qg(e)?Zg[e]:e},e_={delta:0,timestamp:0,isProcessing:!1},t_;function n_(){t_=void 0}var r_={now:()=>(t_===void 0&&r_.set(e_.isProcessing||Cg.useManualTiming?e_.timestamp:performance.now()),t_),set:e=>{t_=e,queueMicrotask(n_)}},i_=e=>Math.round(e*1e5)/1e5,a_=e=>t=>typeof t==`string`&&t.startsWith(e),o_=a_(`--`),s_=a_(`var(--`),c_=e=>s_(e)?l_.test(e.split(`/*`)[0].trim()):!1,l_=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function u_(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var d_={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},f_={...d_,transform:e=>Sg(0,1,e)},p_={...d_,default:1},m_=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function h_(e){return e==null}var g_=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,__=(e,t)=>n=>!!(typeof n==`string`&&g_.test(n)&&n.startsWith(e)||t&&!h_(n)&&Object.prototype.hasOwnProperty.call(n,t)),v_=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(m_);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},y_=e=>Sg(0,255,e),b_={...d_,transform:e=>Math.round(y_(e))},x_={test:__(`rgb`,`red`),parse:v_(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+b_.transform(e)+`, `+b_.transform(t)+`, `+b_.transform(n)+`, `+i_(f_.transform(r))+`)`},S_=(e,t,n)=>{let r=e.substring(1+t*n,1+(t+1)*n);return n>1?r:r+r};function C_(e){let t=e.length>5?2:1,n=S_(e,3,t);return{red:parseInt(S_(e,0,t),16),green:parseInt(S_(e,1,t),16),blue:parseInt(S_(e,2,t),16),alpha:n?parseInt(n,16)/255:1}}var w_={test:__(`#`),parse:C_,transform:x_.transform},T_=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),E_=T_(`deg`),D_=T_(`%`),$=T_(`px`),O_=T_(`vh`),k_=T_(`vw`),A_={...D_,parse:e=>D_.parse(e)/100,transform:e=>D_.transform(e*100)},j_={test:__(`hsl`,`hue`),parse:v_(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+D_.transform(i_(t))+`, `+D_.transform(i_(n))+`, `+i_(f_.transform(r))+`)`},M_={test:e=>x_.test(e)||w_.test(e)||j_.test(e),parse:e=>x_.test(e)?x_.parse(e):j_.test(e)?j_.parse(e):w_.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?x_.transform(e):j_.transform(e),getAnimatableNone:e=>{let t=M_.parse(e);return t.alpha=0,M_.transform(t)}},N_=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu,P_=new RegExp(m_.source),F_=new RegExp(N_.source,`i`);function I_(e){return isNaN(e)&&typeof e==`string`&&(P_.test(e)||F_.test(e))}var L_=`number`,R_=`color`,z_=`var`,B_=`var(`,V_="${}",H_=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)(?![a-z]*\()/giu;function U_(e){let t=e.toString();return P_.test(t)||F_.test(t)}function W_(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(H_,e=>(M_.test(e)?(r.color.push(a),i.push(R_),n.push(M_.parse(e))):e.startsWith(B_)?(r.var.push(a),i.push(z_),n.push(e)):(r.number.push(a),i.push(L_),n.push(parseFloat(e))),++a,V_)).split(V_),indexes:r,types:i}}function G_(e){return W_(e).values}function K_({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];i+=e===L_?i_(r[a]):e===R_?M_.transform(r[a]):r[a]}return i}}function q_(e){return K_(W_(e))}var J_=e=>typeof e==`number`?0:M_.test(e)?M_.getAnimatableNone(e):e,Y_=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:J_(e);function X_(e){let t=W_(e);return K_(t)(t.values.map((e,n)=>Y_(e,t.split[n])))}var Z_={test:I_,parse:G_,createTransformer:q_,getAnimatableNone:X_};function Q_(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function $_({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Q_(s,r,e+1/3),a=Q_(s,r,e),o=Q_(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function ev(e,t){return n=>n>0?t:e}var tv=(e,t,n)=>e+(t-e)*n,nv=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},rv=[w_,x_,j_],iv=e=>rv.find(t=>t.test(e));function av(e){let t=iv(e);if(!t)return!1;let n=t.parse(e);return t===j_&&(n=$_(n)),n}var ov=(e,t)=>{let n=av(e),r=av(t);if(!n||!r)return ev(e,t);let i={...n};return e=>(i.red=nv(n.red,r.red,e),i.green=nv(n.green,r.green,e),i.blue=nv(n.blue,r.blue,e),i.alpha=tv(n.alpha,r.alpha,e),x_.transform(i))},sv=new Set([`none`,`hidden`]);function cv(e,t){return sv.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function lv(e,t){return n=>tv(e,t,n)}function uv(e){return typeof e==`number`?lv:typeof e==`string`?c_(e)?ev:M_.test(e)?ov:mv:Array.isArray(e)?dv:typeof e==`object`?M_.test(e)?ov:fv:ev}function dv(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>uv(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function fv(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=uv(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function pv(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]],s=e.values[o]??0;n[i]=s,r[a]++}return n}var mv=(e,t)=>{let n=W_(e),r=W_(t);return n.indexes.var.length===r.indexes.var.length&&n.indexes.color.length===r.indexes.color.length&&n.indexes.number.length>=r.indexes.number.length?sv.has(e)&&!r.values.length||sv.has(t)&&!n.values.length?cv(e,t):kg(dv(pv(n,r),r.values),K_(r)):ev(e,t)},hv=/^(-?(?:\d+(?:\.\d*)?|\.\d+))([a-z%]*)$/iu;function gv(e,t){let n=hv.exec(e);if(!n)return;let r=hv.exec(t);if(!r||n[2]!==r[2])return;let i=n[2],a=parseFloat(n[1]),o=parseFloat(r[1]);return e=>i_(tv(a,o,e))+i}function _v(e,t,n){if(typeof e==`number`&&typeof t==`number`&&typeof n==`number`)return tv(e,t,n);if(typeof e==`string`&&typeof t==`string`){let n=gv(e,t);if(n)return n}return uv(e)(e,t)}var vv=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function yv(e){let t=new Set,n=new Set,r=!1,i=!1,a,o=new Set,s={delta:0,timestamp:0,isProcessing:!1};function c(t){o.has(t)&&(n.add(t),e()),(a=t)(s)}let l={schedule:(e,i=!1,s=!1)=>{let c=s&&r,l=c?t:n;return i&&o.add(e),c&&e!==a&&l.delete(e),l.add(e),e},cancel:e=>{n.delete(e),o.delete(e)},process:e=>{if(s=e,r){i=!0;return}r=!0;let o=t;t=n,n=o,t.forEach(c),t.clear(),a=void 0,r=!1,i&&(i=!1,l.process(e))}};return l}var bv=40;function xv(e,t,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,i=!0,a=()=>r=!0,o=vv.reduce((e,t)=>(e[t]=yv(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Cg.useManualTiming,o=a?n.timestamp:performance.now();r=!1,a||(n.delta=i?1e3/60:Math.max(Math.min(o-n.timestamp,bv),1)),n.timestamp=o,n.isProcessing=!0,s.process(n),c.process(n),l.process(n),u.process(n),d.process(n),f.process(n),p.process(n),m.process(n),n.isProcessing=!1,r&&t&&(i=!1,e(h))},g=()=>{r=!0,i=!0,n.isProcessing||e(h)};return{schedule:vv.reduce((e,t)=>{let n=o[t];return e[t]=(e,t=!1,i=!1)=>(r||g(),n.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<vv.length;t++)o[vv[t]].cancel(e)},state:n,steps:o}}var{schedule:Sv,cancel:Cv,steps:wv}=xv(typeof requestAnimationFrame<`u`?requestAnimationFrame:Og,!0,e_),Tv=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>Sv.update(t,e),stop:()=>Cv(t),now:()=>e_.isProcessing?e_.timestamp:r_.now()}},Ev=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Dv=2e4;function Ov(e,t=50,n=Dv,r){let i=0,a=e.next(i);for(r?.push(a.value);!a.done&&i<n;)i+=t,a=e.next(i),r?.push(a.value);return i>=n?1/0:i}function kv(e,t=100,n){let{keyframes:r,velocity:i}=e,a=r&&r[r.length-1]-r[0],o=n({...e,velocity:i&&a?i*t/a:i,keyframes:[0,t]}),s=Math.min(Ov(o),Dv);return{type:`keyframes`,ease:e=>o.next(s*e).value/t,duration:Ng(s)}}var Av=100,jv=10,Mv=1,Nv=800,Pv=.3,Fv=.3,Iv=.01,Lv=2,Rv=.005,zv=.5,Bv=.01,Vv=10,Hv=.05,Uv=e=>e<0?1/Math.max(1+e,Hv):Math.max(1-e,Hv);function Wv(e,t){if(!(e>1))return 1;let n=Math.sqrt(e*e-1),r=e-n,i=e+n,a=2*n*Math.exp(-t)*(1+t);return qv(e=>i*Math.exp(-r*e)-r*Math.exp(-i*e)-a,e=>Math.exp(-i*e)-Math.exp(-r*e),t)/t}function Gv(e,t){return e*Math.sqrt(1-t*t)}var Kv=12;function qv(e,t,n){let r=n;for(let n=1;n<Kv;n++)r-=e(r)/t(r);return r}var Jv=.001;function Yv({duration:e=Nv,bounce:t=Pv}){let n,r,i=Uv(t);e=Sg(Bv,Vv,Ng(e)),i<1?(n=t=>{let n=t*i,r=n*e,a=Gv(t,i),o=Math.exp(-r);return Jv-n/a*o},r=t=>{let r=t*i*e,a=i*i*t*t*e,o=Math.exp(-r),s=Gv(t*t,i);return(-n(t)+Jv>0?-1:1)*-a*o/s}):(n=t=>-.001+Math.exp(-t*e)*(t*e+1),r=t=>Math.exp(-t*e)*(-t*(e*e)));let a=5/e,o=qv(n,r,a),s=o*Wv(i,o*e),c=s*s;return{stiffness:c,damping:i*2*Math.sqrt(c),duration:Mg(e)}}var Xv=(e,t)=>(t?e>=0:e>0)&&e<1/0;function Zv(e,t){if(Xv(e,t))return e}function Qv(e){let t=Zv(e.stiffness),n=Zv(e.damping,!0),r=Zv(e.mass),i={...e,stiffness:t??Av,damping:n??jv,mass:r??Mv,isResolvedFromDuration:!1,isTimeDefined:(t??n??r)===void 0&&(e.duration!==void 0||e.bounce!==void 0)};if(i.isTimeDefined){if(e.visualDuration){let t=Uv(e.bounce||0),n=2*Math.PI/(e.visualDuration*1.2)*Wv(t,2*Math.PI/1.2);i.stiffness=n*n,i.damping=2*t*Math.sqrt(i.stiffness)}else Object.assign(i,Yv(i)),i.isResolvedFromDuration=!0;Xv(i.stiffness)&&Xv(i.damping,!0)||(i.stiffness=Av,i.damping=jv)}return i}function $v(e=Fv,t=Pv){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},r=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:o,damping:s,mass:c,duration:l,isResolvedFromDuration:u,isTimeDefined:d}=Qv({...n}),f=e=>d?0:-Ng(e),p=s/(2*Math.sqrt(o*c)),m=Ng(Math.sqrt(o/c)),h=p*m,g={target:i,delta:i-r,velocity:f(n.velocity||0)||0,restSpeed:0,restDelta:0},_=()=>{let e=Math.abs(g.delta)<5;g.restSpeed=n.restSpeed||(e?Iv:Lv),g.restDelta=n.restDelta||(e?Rv:zv)};_();let v,y,b;if(p<1){let e=Gv(m,p),t={A:0,sinC:0,cosC:0,t:-1,env:0,sin:0,cos:0};b=()=>{t.A=(g.velocity+h*g.delta)/e,t.sinC=h*t.A+g.delta*e,t.cosC=h*g.delta-t.A*e};let n=n=>{n!==t.t&&(t.t=n,t.env=Math.exp(-h*n),t.sin=Math.sin(e*n),t.cos=Math.cos(e*n))};v=e=>(n(e),g.target-t.env*(t.A*t.sin+g.delta*t.cos)),y=e=>(n(e),t.env*(t.sinC*t.sin+t.cosC*t.cos))}else if(p===1){v=e=>g.target-Math.exp(-m*e)*(g.delta+(g.velocity+m*g.delta)*e);let e={C:0};b=()=>{e.C=g.velocity+m*g.delta},y=t=>Math.exp(-m*t)*(m*e.C*t-g.velocity)}else{let e=m*Math.sqrt(p*p-1),t=h-e,n=h+e,r=e<1||d?1/0:300/e,i=(e,t)=>Math.exp(t>r?(h-e)*r-h*t:-e*t),a={S:0,F:0};b=()=>{let t=(g.velocity+h*g.delta)/e;a.S=(g.delta+t)/2,a.F=(g.delta-t)/2},v=e=>g.target-a.S*i(t,e)-a.F*i(n,e),y=e=>t*a.S*i(t,e)+n*a.F*i(n,e)}b();let x=u&&l||null,S={calculatedDuration:x,retarget:(e,t)=>{g.target=e[e.length-1],g.delta=g.target-e[0],g.velocity=f(t),n.restSpeed&&n.restDelta||_(),S.calculatedDuration=x,a.done=!1,b()},velocity:e=>Mg(y(e)),next:e=>{let t=v(e);if(u)a.done=e>=l;else{let n=Mg(y(e));a.done=Math.abs(n)<=g.restSpeed&&Math.abs(g.target-t)<=g.restDelta}return a.value=a.done?g.target:t,a},toString:()=>{let e=Math.min(Ov(S),Dv),t=Ev(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}var ey=Object.assign($v,{applyToOptions:e=>{let t=kv(e,100,$v);return e.ease=t.ease,e.duration=Mg(t.duration),e.type=`keyframes`,e}});function ty({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>e<s||e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o?o(g):g;_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>{let t=v(e);f.done=Math.abs(t)<=l,f.value=f.done?_:e?_+t:d},b,x,S=e=>{p(f.value)&&(b=e,x=ey({keyframes:[f.value,m(f.value)],velocity:-v(e)/r*1e3,damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return!x&&b===void 0&&(t=!0,y(e),S(e)),b!==void 0&&e>=b?x.next(e-b):(!t&&y(e),f)}}}function ny(e,t,n){let r=[],i=Cg.mix||_v,a=e.length-1;for(let o=0;o<a;o++){let a=n?.(e[o],e[o+1])||i(e[o],e[o+1]);t&&(a=kg(Array.isArray(t)?t[o]||Og:t,a)),r.push(a)}return r}function ry(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=ny(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=Ag(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Sg(e[0],e[a-1],t)):l}function iy(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=Ag(0,t,r);e.push(tv(n,1,i))}}function ay(e){let t=[0];return iy(t,e.length-1),t}function oy(e,t){return e.map(e=>e*t)}function sy(e,t){return e.map(()=>t||Jg).splice(0,e.length-1)}function cy({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`,mixer:i}){let a=typeof t[0]==`number`?void 0:i,o=Yg(r)?r.map($g):$g(r)||Jg,s={done:!1,value:t[0]};if(!a&&t.length===2&&!Array.isArray(o)&&(!n||n.length!==2||n[0]===0&&n[1]===1)){let[n,r]=t,i=n===r?void 0:(Cg.mix||_v)(n,r);return{calculatedDuration:e,next:t=>(s.value=i?i(o(e>0?Sg(0,1,t/e):1)):r,s.done=t>=e,s)}}let c=ry(oy(n&&n.length===t.length?n:ay(t),e),t,{ease:Array.isArray(o)?o:sy(t,o),mixer:a});return{calculatedDuration:e,next:t=>(s.value=c(t),s.done=t>=e,s)}}var ly=5;function uy(e,t,n){let r=Math.max(t-ly,0);return Pg(n-e(r),t-r)}function dy(e,t,n=0){return t<=0?n:e.velocity?e.velocity(t):uy(t=>e.next(t).value,t,e.next(t).value)}var fy=e=>e!==null;function py(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(fy),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var my={decay:ty,inertia:ty,tween:cy,keyframes:cy,spring:ey};function hy(e){typeof e.type==`string`&&(e.type=my[e.type])}var gy=40,_y=(e,t)=>t-e>gy&&!Cg.useManualTiming?t:e;function vy(e,t){return{kind:e,animation:t,timestamp:r_.now(),frameTimestamp:e_.timestamp,frameIsProcessing:e_.isProcessing}}function yy(e,t,n){let r=globalThis.__MOTION_INSPECT__;if(r)try{r({...vy(`animation-start`,e),options:n?{...t,...n}:t})}catch{}}function by(e,t){let n=globalThis.__MOTION_INSPECT__;if(n)try{n({...vy(`layout-animation-start`,e),node:t})}catch{}}var xy=class{constructor(){this.isResolved=!1}get finished(){return this._finished||=this.isResolved?Promise.resolve():new Promise(e=>{this._resolve=e}),this._finished}updateFinished(){this._finished=this._resolve=void 0,this.isResolved=!1}notifyFinished(){this.isResolved=!0,this._resolve?.()}then(e,t){return this.finished.then(e,t)}},Sy=e=>e/100,Cy=e=>Math.round(e*1e4)/1e4,wy=class extends xy{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==r_.now()&&this.tick(r_.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause(),yy(this,this.options)}initAnimation(){let{options:e}=this;hy(e);let{type:t=cy,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||cy;this.mixKeyframes=void 0,s!==cy&&typeof o[0]!=`number`&&(this.mixKeyframes=kg(Sy,e.mixer?.(o[0],o[1])||_v(o[0],o[1])),o=[0,100]);let c=s(o===e.keyframes?e:{...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=Ov(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){this.currentTime=this.holdTime??Math.round(e-this.startTime)*this.playbackSpeed}tick(e,t=!1){let{generator:n,totalDuration:r,calculatedDuration:i}=this;if(this.startTime===null)return n.next(0);let{delay:a=0,keyframes:o,type:s,onUpdate:c,finalKeyframe:l}=this.options;this.startTime===this.pendingStartTime&&(this.startTime=_y(this.startTime,e)),this.pendingStartTime=void 0,this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let u=this.currentTime-a*(this.playbackSpeed>=0?1:-1),d=this.playbackSpeed>=0?u<0:u>r;this.currentTime=Math.max(u,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let f=this.generate(this.currentTime,d),{done:p}=f;d||(p=this.playbackSpeed>=0?i<1/0?this.currentTime>=r:p:this.currentTime<=0);let m=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&p);return m&&s!==ty&&(f.value=py(o,this.options,l,this.speed)),c&&c(f.value),m&&this.finish(),f}at(e){return this.holdTime??Cy((e-this.startTime)*this.playbackSpeed)}sampleAt(e,t){let{options:n,totalDuration:r}=this,i=this.at(e)-(n.delay||0);return i>=r&&n.type!==ty?py(n.keyframes,n,t?void 0:n.finalKeyframe):this.generate(Math.max(i,0),i<0).value}generate(e,t){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o}=this,{keyframes:s,repeat:c,repeatType:l,repeatDelay:u}=this.options,d=e,f=n;if(c){let t=Math.min(e,r)/o,n=Math.floor(t),i=t%1;!i&&t>=1&&(i=1),i===1&&n--,n=Math.min(n,c+1),n%2&&(l===`reverse`?(i=1-i,u&&(i-=u/o)):l===`mirror`&&(f=a)),d=Sg(0,1,i)*o}let p;return t?(this.delayState.value=s[0],p=this.delayState):p=f.next(d),i&&!t&&(p.value=i(p.value)),p}get duration(){return Ng(this.calculatedDuration)}get iterationDuration(){return this.duration+Ng(this.options.delay??0)}get time(){return Ng(this.currentTime)}set time(e){e=Mg(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){return dy(this.generator,this.currentTime,this.options.velocity)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(r_.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Ng(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Tv,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??(this.pendingStartTime=n):this.startTime=n-this.holdTime/(this.playbackSpeed||1),this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(r_.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.driver?.stop(),this.driver=void 0,this.startTime=this.holdTime=null}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}},Ty=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function Ey(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(m_)||[];if(!r)return e;let i=n.replace(r,``),a=+!!Ty.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var Dy=/\b([a-z-]*)\(.*?\)/gu,Oy={...Z_,getAnimatableNone:e=>{let t=e.match(Dy);return t?t.map(Ey).join(` `):e}},ky={...Z_,getAnimatableNone:e=>{let t=Z_.parse(e);return Z_.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},Ay={...d_,transform:Math.round},jy={rotate:E_,pathRotation:E_,rotateX:E_,rotateY:E_,rotateZ:E_,scale:p_,scaleX:p_,scaleY:p_,scaleZ:p_,skew:E_,skewX:E_,skewY:E_,distance:$,translateX:$,translateY:$,translateZ:$,x:$,y:$,z:$,perspective:$,transformPerspective:$,opacity:f_,originX:A_,originY:A_,originZ:$},My={borderWidth:$,borderTopWidth:$,borderRightWidth:$,borderBottomWidth:$,borderLeftWidth:$,borderRadius:$,borderTopLeftRadius:$,borderTopRightRadius:$,borderBottomRightRadius:$,borderBottomLeftRadius:$,width:$,maxWidth:$,height:$,maxHeight:$,top:$,right:$,bottom:$,left:$,inset:$,insetBlock:$,insetBlockStart:$,insetBlockEnd:$,insetInline:$,insetInlineStart:$,insetInlineEnd:$,padding:$,paddingTop:$,paddingRight:$,paddingBottom:$,paddingLeft:$,paddingBlock:$,paddingBlockStart:$,paddingBlockEnd:$,paddingInline:$,paddingInlineStart:$,paddingInlineEnd:$,margin:$,marginTop:$,marginRight:$,marginBottom:$,marginLeft:$,marginBlock:$,marginBlockStart:$,marginBlockEnd:$,marginInline:$,marginInlineStart:$,marginInlineEnd:$,fontSize:$,backgroundPositionX:$,backgroundPositionY:$,...jy,zIndex:Ay,fillOpacity:f_,strokeOpacity:f_,numOctaves:Ay},Ny={...My,color:M_,backgroundColor:M_,outlineColor:M_,fill:M_,stroke:M_,borderColor:M_,borderTopColor:M_,borderRightColor:M_,borderBottomColor:M_,borderLeftColor:M_,filter:Oy,WebkitFilter:Oy,mask:ky,WebkitMask:ky},Py=e=>Ny[e],Fy=new Set([Oy,ky]);function Iy(e,t){let n=Py(e);return Fy.has(n)||(n=Z_),n.getAnimatableNone?n.getAnimatableNone(t):void 0}function Ly(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var Ry=e=>e*180/Math.PI,zy=e=>Vy(Ry(Math.atan2(e[1],e[0]))),By={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scaleZ:()=>1,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:zy,rotateZ:zy,skewX:e=>Ry(Math.atan(e[1])),skewY:e=>Ry(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Vy=e=>(e%=360,e<0&&(e+=360),e),Hy=zy,Uy=e=>Math.hypot(e[0],e[1]),Wy=e=>Math.hypot(e[4],e[5]),Gy={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Uy,scaleY:Wy,scaleZ:e=>Math.hypot(e[8],e[9],e[10]),scale:e=>(Uy(e)+Wy(e))/2,rotateX:e=>Vy(Ry(Math.atan2(e[6],e[5]))),rotateY:e=>Vy(Ry(Math.atan2(-e[2],e[0]))),rotateZ:Hy,rotate:Hy,skewX:e=>Ry(Math.atan(e[4])),skewY:e=>Ry(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Ky(e){return+!!e.includes(`scale`)}function qy(e,t){if(!e||e===`none`)return Ky(t);let n=e.match(/^matrix(3d)?\(([-\d.e\s,]+)\)$/u);if(!n)return Ky(t);let r=(n[1]?Gy:By)[t],i=n[2].split(`,`).map(e=>parseFloat(e));return typeof r==`function`?r(i):i[r]}var Jy=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return qy(n,t)},Yy=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`scaleZ`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Xy=new Set([...Yy,`pathRotation`]),Zy=e=>e===d_||e===$,Qy=new Set([`x`,`y`,`z`]),$y=Yy.filter(e=>!Qy.has(e));function eb(e){let t=[];return $y.forEach(n=>{let r=e.getValue(n);if(r!==void 0){let e=r.get(),i=+!!n.startsWith(`scale`);if(e===i)return;t.push([n,e]),r.set(i)}}),t}var tb=new Set([`bottom`,`right`]);function nb(e,t,n,r,i,a){let o=parseFloat(e);if(!isNaN(o))return o;let{min:s,max:c}=t()[n],l=c-s;return a===`border-box`?l:l-parseFloat(r)-parseFloat(i)}var rb=({transform:e})=>qy(e,`x`),ib=({transform:e})=>qy(e,`y`),ab={width:({width:e,paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r},i)=>nb(e,i,`x`,t,n,r),height:({height:e,paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r},i)=>nb(e,i,`y`,t,n,r),top:({top:e})=>parseFloat(e),left:({left:e})=>parseFloat(e),bottom:({top:e},t)=>{let{y:n}=t();return parseFloat(e)+(n.max-n.min)},right:({left:e},t)=>{let{x:n}=t();return parseFloat(e)+(n.max-n.min)},x:rb,y:ib,translateX:rb,translateY:ib},ob=new Set,sb=!1,cb=!1,lb=!1;function ub(){if(cb){let e=[],t=new Set,n=new Set;ob.forEach(r=>{r.needsMeasurement&&(e.push(r),t.add(r.element),tb.has(r.name)&&n.add(r.element))});let r=new Map;n.forEach(e=>{let t=eb(e);t.length&&(r.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=r.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}cb=!1,sb=!1,ob.forEach(e=>e.complete(lb)),ob.clear()}function db(){ob.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(cb=!0)})}function fb(){lb=!0,db(),ub(),lb=!1}function pb(e,t,n){if(typeof e==`string`){if(wg(e)||Eg(e))return parseFloat(e);if(!Z_.test(e)&&Z_.test(n))return Iy(t,n)}return e??void 0}var mb=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(ob.add(this),sb||(sb=!0,Sv.read(db),Sv.resolveKeyframes(ub))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=pb(n.readValue(t,a),t,a);r!==void 0&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}Ly(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ob.delete(this)}cancel(){this.state===`scheduled`&&(ob.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},hb=e=>e.startsWith(`--`);function gb(e,t,n){hb(t)?e.style.setProperty(t,n):e.style[t]=n}var _b={};function vb(e,t){let n=Dg(e);return()=>_b[t]??n()}var yb=vb(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),bb=vb(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),xb=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Sb={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:xb([0,.65,.55,1]),circOut:xb([.55,0,1,.45]),backIn:xb([.31,.01,.66,-.59]),backOut:xb([.33,1.53,.69,.99])};function Cb(e,t){if(e)return typeof e==`function`?bb()?Ev(e,t):`ease-out`:Xg(e)?xb(e):Array.isArray(e)?e.map(e=>Cb(e,t)||Sb.easeOut):Sb[e]}function wb(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=Cb(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function Tb(e){return typeof e==`function`&&`applyToOptions`in e}function Eb({type:e,...t}){return Tb(e)&&bb()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Db=class extends xy{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e;let c=Eb(e);this.animation=wb(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=py(r,this.options,o,this.speed);this.updateMotionValue?.(e),gb(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()},yy(this,e,c)}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){this.isStopped||(this.isStopped=!0,this.state!==`idle`&&this.finishedTime===null&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||(this.animation.onfinish=null,this.cancel())))}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return Ng(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Ng(e)}get time(){return Ng(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Mg(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,onAttach:t,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&yb()?(this.animation.timeline=e,t?.(this.animation),Og):n(this)}},Ob={anticipate:Hg,backInOut:Vg,circInOut:Gg};function kb(e){return e in Ob}function Ab(e){typeof e.ease==`string`&&kb(e.ease)&&(e.ease=Ob[e.ease])}var jb=class extends Db{constructor(e){Ab(e),hy(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}elapsed(){return this.state===`running`?(r_.now()-this.startTime)*this.speed:this.time*1e3}sample(e){if(!this.sampler){let{motionValue:e,onUpdate:t,onComplete:n,onPlay:r,onStop:i,element:a,...o}=this.options;this.sampler=new wy({...o,autoplay:!1}),this.sampler.stop()}return this.sampler.sample(Math.max(0,e)).value}liveValue(){let{state:e}=this;if(e===`running`||e===`paused`)return this.sample(this.elapsed())}updateMotionValue(e){let{motionValue:t,element:n,name:r}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let{speed:i}=this,a=this.elapsed(),o=this.state===`running`&&i?Sg(0,10,a):0,s=this.sample(a);n&&r&&gb(n,r,s),t.setWithVelocity(this.sample(a-o*Math.sign(i)),s,o/Math.abs(i||1))}},Mb=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Z_.test(e)||e===`0`)&&!e.startsWith(`url(`));function Nb(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function Pb(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=Mb(i,t),s=Mb(a,t);return!o||!s?!1:Nb(e)||(n===`spring`||Tb(n))&&r}function Fb(e){e.duration=0,e.type=`keyframes`}var Ib=new Set([`opacity`,`clipPath`,`filter`,`transform`]),Lb=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function Rb(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&Lb.test(e[t]))return!0;return!1}var zb=({mixer:e,keyframes:t})=>e&&typeof t[0]!=`number`&&t.some((n,r)=>r&&e(t[r-1],n)),Bb=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Vb=()=>!Cg.useManualTiming&&Object.hasOwnProperty.call(Element.prototype,`animate`);function Hb(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!n||!(Ib.has(n)||Bb.has(n)))return!1;let c=t?.owner?.current;if(!(c instanceof HTMLElement)&&!(c instanceof SVGElement))return!1;let{onUpdate:l,transformTemplate:u}=t.owner.getProps();return Vb()&&(Ib.has(n)||Bb.has(n)&&Rb(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`&&!zb(e)}var Ub=(e,t)=>t&&typeof e==`number`?t.transform(e):e,Wb={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},Gb=Yy.length,Kb={},qb=(e,t,n=Ub(t,jy[e]))=>(Kb[e]||(Kb[e]=(Wb[e]||e)+`(`))+n+`)`,Jb=(e,t)=>(typeof t==`number`?t:parseFloat(t))===+!!e.startsWith(`scale`);function Yb(e,t,n){let r=``;for(let i=0;i<Gb;i++){let a=Yy[i],o=e[a];if(o===void 0)continue;let s=n&&(t[a]=Ub(o,My[a]));Jb(a,o)||(r+=qb(a,o,s||void 0)+` `)}let i=e.pathRotation;return i&&(r+=qb(`rotate`,i)),r=r.trim(),n?n(t,r):r||`none`}var Xb=new WeakMap,Zb=200,Qb=.001,$b=.1,ex=.001,tx=100,nx=e=>/^(linear|ease(In|Out|InOut))$/.test(e),rx=(e,t)=>Math.abs(e-t)<=Qb,ix=(e,t)=>e-t,ax=(e,t,n)=>ay(Array(n+1)).map(n=>tv(e,t,n)),ox=e=>e.motionValue.owner,sx=e=>Xb.get(e),cx=({state:e})=>e===`idle`||e===`finished`,lx=(e,t)=>e.latestValues?e.latestValues[t]:e.getValue(t)?.get(),ux=({name:e,motionValue:t})=>e&&Yy.includes(e)&&t?.owner?.current instanceof HTMLElement&&Vb()&&bb();function dx(e){let t=ox(e),{onUpdate:n,transformTemplate:r}=t.getProps();return!e.isHandoff&&!n&&!e.hasOnUpdate&&!r&&e.type!==`inertia`&&(lx(t,`transform`)||`none`)===`none`&&!lx(t,`pathRotation`)&&!t.projection?.isProjecting()&&!zb(e)}var fx=class extends wy{constructor(e){let t=ox(e).current,{driver:n=Tv}=e,r,i=dx(e);e.driver=e=>{let i=n(e);return{js:i,now:i.now,start:(e=!0)=>{let n=sx(t);!n||n.isJS?i.start(e):n.schedule(!1,!e)},stop:()=>{i.stop();let e=sx(t);e&&!e.isFinishing&&e.release(r)}}},super(e),r=this,this.canAccelerate=i;let{stop:a}=this;this.stop=()=>{this.isAccelerated()&&this.sync(),a()}}get group(){return sx(ox(this.options).current)}get js(){return this.driver?.js}get name(){return this.options.name}timing(){let{startTime:e,speed:t,totalDuration:n}=this,{delay:r=0,repeatType:i}=this.options;return this.holdTime===null?n===1/0?[e+r/t,this.resolvedDuration*(i===`loop`?1:2)/t||1]:[e+(r+n)/t,0]:[1/0,0]}isAccelerated(){let{group:e,state:t}=this;return e?.tracks.has(this)&&!e.isJS&&this.canAccelerate&&(t===`running`||t===`paused`)}liveValue(){return this.isAccelerated()?this.sampleAt(r_.now()):void 0}tween(){let{keyframes:e,type:t,ease:n,times:r,repeat:i,delay:a=0}=this.options,o=Xg(n)?xb(n):nx(n)&&Sb[n];if(o&&!i&&!r&&e.length===2&&t===cy&&this.holdTime===null){let e=this.startTime+a/this.speed;return[e,e+this.resolvedDuration/this.speed,o]}}boundaries(e,t){let{startTime:n,speed:r,resolvedDuration:i,options:a}=this,{delay:o=0,repeat:s=0,repeatDelay:c=0,repeatType:l,times:u,keyframes:d,type:f}=a,p=(f||cy)===cy?u||ay(d):[0,1],m=n+o/r,h=[];if(this.holdTime!==null||!(i>0))return h;for(let n=Math.max(0,Math.floor((e-m)*r/i));n<=s;n++){let a=m+n*i/r;if(a>t)break;for(let o of p){let s=a+(n%2&&l&&l!==`loop`?1-o:o)*(i-c)/r;s>e&&s<t&&h.push(s)}}return h}numberAt(e){return parseFloat(this.sampleAt(e,!0))}sync(){let e=r_.now();this.options.motionValue.setWithVelocity(this.sampleAt(e-10,!0),this.sampleAt(e,!0),10)}play(){this.isStopped||((this.group||px(ox(this.options))).tracks.add(this),super.play())}pause(){super.pause(),this.isAccelerated()&&(this.sync(),this.group.schedule(!1))}complete(){super.complete();let{group:e}=this;e&&!e.isJS&&this.canAccelerate&&this.tick(r_.now())}get time(){return this.isAccelerated()?Ng(Sg(0,this.totalDuration,this.at(r_.now())-(this.options.delay||0))):super.time}set time(e){super.time=e,this.isAccelerated()&&this.sync()}attachTimeline(e){return this.canAccelerate=!1,this.group?.demote(!0),super.attachTimeline(e)}};function px(e){let t=e.current,n=new Set,r=new Map,i={},a=[],o=new Map,s=[],c=!1,l=!1,u=!1,d=!1,f=-1/0,p=e=>{for(let t of n)if(t.name===e)return!0},m=(t,n)=>{let o={};for(let s of t===void 0?Yy:a){let a=r.get(s),c=t===void 0?lx(e,s):a?a.sampleAt(n>t&&!a.timing()[1]?n:t):i[s];c!==void 0&&(o[s]=c)}return o},h=(e,t)=>{let n=``;for(let r in e){let i=e[r];t&&Jb(r,i)||(n+=qb(r,i)+` `)}return(t?n.trim():n)||`none`},g=(e,t)=>h(m(e,t)),_=(e=m())=>{t.style.transform=h(e,!0)},v=(e=!0)=>{e&&_(),s.forEach(({animation:e})=>e.cancel()),s=[]},y=(e,n)=>new Animation(new KeyframeEffect(t,e,n)),b=(e,t,n=1/0)=>{let r={animation:e,offset:t,end:n};e.startTime=r_.now()+t,n<1/0&&(e.onfinish=()=>{r.isDone=!0,s.some(e=>e.end===1/0)&&(e.cancel(),s=s.filter(e=>e!==r)),A.schedule(!1)}),e.oncancel=()=>s.includes(r)&&A.demote(),s.push(r)},x=(e,t,n)=>{let r=(t,n)=>Math.abs(e(n)-e(t)),i=r(t,n);for(;n-t>.01;){let e=(t+n)/2;r(t,e)>r(e,n)?n=e:t=e}return r(t,n)>i/2?[t,n]:[]},S=(e,t,n,r)=>{let i=Math.min(Zb,Math.max(2,Math.ceil((n-t)/10)));if(r.length*4>i)return;let a=ax(t,n,i).concat(r).sort(ix),o=e=>Ag(t,n,e),s,c;for(let n of e){let e=n.numberAt(t),r=a.map(t=>n.numberAt(t)-e),i=r[r.length-1],o=r.some(e=>Math.abs(e)*Qb>Math.abs(i))?0:i,l=r.map(e=>o?e/o:e);if(o&&!s)s=l,c=t=>(n.numberAt(t)-e)/o;else if(l.some((e,t)=>!rx(e,o&&s[t])))return}if(!s||s.every((e,t)=>rx(e,o(a[t]))))return`linear`;let l=[],u=(e,t=c(e))=>l.push(Cy(t)+` `+Cy(o(e)*100)+`%`);return s.forEach((e,t)=>{t&&Math.abs(e-s[t-1])>.2&&x(c,a[t-1],a[t]).forEach(e=>u(e)),u(a[t],e)}),`linear(`+l+`)`},C=(e,t,n,r)=>{let i=[t],a=(t,n)=>e.every(e=>!(Math.abs(e.numberAt((t+n)/2)-(e.numberAt(t)+e.numberAt(n))/2)>(e.name.startsWith(`scale`)?ex:$b))),o=(t,n,r)=>{if(n-t<1||a(t,n))i.push(n);else if(r<4)o(t,(t+n)/2,r+1),o((t+n)/2,n,r+1);else{for(let r of e)i.push(...x(e=>r.numberAt(e),t,n));i.push(n)}},s=ax(t,n,Math.ceil((n-t)/100));for(let e of r)s.push(e,Math.min(e+.01,n));let c=t;for(let e of s.sort(ix))e>c&&o(c,e,0),c=e;return i.sort(ix)},w=e=>{let t;for(let n of e){let e=n.tween();if(!e||t?.some((t,n)=>n<2?Math.abs(e[n]-t)>1:e[n]!==t))return;t=e}return t},T=(e,t,n,r,i={fill:`both`},a)=>{let o=e.flatMap(e=>e.boundaries(t,n)),s=r||S(e,t,n,o),c=s?[t,n]:C(e,t,n,o),l=c.map(e=>g(e,a)),u={transform:l};return s||(u.offset=c.map(e=>Ag(t,n,e))),l.every(e=>e===l[0])&&(_(m(t,a)),u=null),y(u,{...i,duration:n-t,easing:s||`linear`})},E=t=>{let c=t,l=0,u=0,d=[],f=[],p=new Set;r.clear(),o=new Map;for(let e of n){r.set(e.name,e);let[n,i]=e.timing(),a=n===1/0;if(o.set(e,[e.at(t),e.speed,a]),a)e.sync();else{if(e.speed<0)return;if(i){if(l){let e=(n-u)/i;if(Math.abs(i-l)>1||Math.abs(e-Math.round(e))*l>1)return}else l=i,u=n;f.push(e)}else p.add(n);d.push(e),c=Math.max(c,n)}}i={},a=Yy.filter(t=>{if(r.has(t))return!0;let n=i[t]=lx(e,t);return n!==void 0&&!Jb(t,n)}),v(!1);let m=!l&&w(d);try{if(m&&m[1]>t){let[e,n,r]=m;b(T(d,e,n,r),e-t,n-e)}else c>t&&(b(T(d,t,c),0,c-t),p.forEach(e=>e<c-1&&b(y(null,{duration:e-t}),0,e-t)));if(l){let e=u+Math.floor((c-u)/l)*l;b(T(f,e,e+l,void 0,{iterations:1/0,iterationStart:(c-e)/l,fill:`forwards`},c),c-t)}}catch{return}return s.length||v(),!0},D=e=>{let t,r=0;for(let i of n){let n=o.get(i);if(!n)return!1;let[a,s,c]=n,l=i.at(e),u=i.timing()[0]===1/0;if(c){if(u&&l===a)continue;return!1}let d=(l-a)/s,f=u?0:i.speed/s;if(t===void 0)t=d,r=f;else if(Math.abs(d-t)>1||f!==r)return!1}if(t===void 0)return!0;if(!s.length)return!1;for(let{offset:e,end:n,isDone:r}of s){let i=t-e;if(n<1/0&&(r?i<n-1:i<0||i>=n))return!1}for(let{animation:n,offset:i,isDone:a}of s){if(a)continue;let o=t-i;r&&n.updatePlaybackRate&&n.playState===`running`&&Math.abs(Number(n.currentTime)-o)<20?n.playbackRate!==r&&n.updatePlaybackRate(r):r?(n.playbackRate=r,n.startTime=e-o/r):(n.startTime=null,n.currentTime=o)}return!0},O=()=>!n.size&&(u=!0,sx(t)===A&&Xb.delete(t),A.isJS||v(),!0),k=()=>{let t=r_.now();if(A.isJS||(A.isFinishing=!0,n.forEach(n=>{let[r,a]=n.timing();n.state===`running`&&n.speed>0&&!a&&r<=t+1&&(n.complete(),i[n.name]=lx(e,n.name),o.has(n)||(c=!0))}),A.isFinishing=!1),l=!1,u||(n.forEach(e=>cx(e)&&n.delete(e)),O()))return;for(let e of n)if(!e.canAccelerate)return A.demote(!0);A.isJS&&(A.isJS=!1,c=!0,n.forEach(e=>e.js?.stop()));let r=c,a=d;if(c=d=!1,r||!D(t)){if(a){if(t-f<tx)return A.demote();f=t}if(!E(t))return A.demote()}},A={tracks:n,isJS:!1,isFinishing:!1,schedule(e,t){u||(c||=e,d||=!!t,l||(l=!0,e_.isProcessing?Sv.render(k,!1,!0):queueMicrotask(k)))},release(e){cx(e)&&n.delete(e),O()||A.schedule(!0)},check(){if(!A.isJS){for(let t in i)if(lx(e,t)!==i[t]&&!p(t))return A.schedule(!0,!0)}},demote(e){if(!(A.isJS||u))return n.forEach(t=>{t.isAccelerated()&&t.sync(),e||(t.canAccelerate=!1)}),A.isJS=!0,o=new Map,v(),n.forEach(e=>e.state===`running`&&e.js?.start()),!0}};return Xb.set(t,A),A}var mx=class extends xy{constructor(e){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=r_.now();let{keyframes:t,name:n,motionValue:r,element:i}=e,a=e;a.autoplay??=!0,a.delay??=0,a.type??=`keyframes`,a.repeat??=0,a.repeatDelay??=0,a.repeatType??=`loop`;let o=i?.KeyframeResolver||mb;this.keyframeResolver=new o(t,(e,t,n)=>this.onKeyframesResolved(e,t,a,!n),n,r,i),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=r_.now();let u=Pb(e,i,a,o);u||((Cg.instantAnimations||!s)&&l?.(py(e,n,t)),e[0]=e[e.length-1],Fb(n),n.repeat=0);let{onComplete:d}=n;n.finalKeyframe=t,n.keyframes=e,n.onComplete=()=>{d?.(),this.notifyFinished()};let f=u&&!c&&Hb(n),p=!f&&ux(n);r&&(f||p||this.resolvedAt!==this.createdAt)&&(n.startTime??=_y(this.createdAt,this.resolvedAt));let m;if(f){n.element=n.motionValue?.owner?.current;try{m=new jb(n)}catch{m=new wy(n)}}else m=p?new fx(n):new wy(n);this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this._animation.finished:super.finished}then(e,t){return this.finished.finally(e).then(()=>{})}liveValue(){return this._animation?.liveValue?.()}get animation(){return this._animation||(this.keyframeResolver?.resume(),fb()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation?.cancel(),this.keyframeResolver?.cancel()}};function hx(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var gx=30,_x=e=>!isNaN(parseFloat(e)),vx={current:void 0},yx=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=r_.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.dirty(),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=r_.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=_x(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){var n;return e===`change`?this.onChangeSubscribe(t):((n=this.events)[e]||(n[e]=new jg)).add(t)}onChangeSubscribe(e){let{events:t}=this;return!t.change&&!this.changeSubscriber?this.changeSubscriber=e:(t.change||(t.change=new jg,t.change.add(this.changeSubscriber),this.changeSubscriber=void 0),t.change.add(e)),()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:t.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){Sv.read(()=>{!this.changeSubscriber&&!this.events.change?.getSize()&&this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){t&&(this.updatedAt=r_.now(),this.stop()),this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,this.stopPassiveEffect?.()}dirty(){let{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){(this.dependents||=new Set).add(e)}removeDependent(e){this.dependents?.delete(e)}get(){vx.current?.push(this);let e=this.animation?.liveValue?.();return e===void 0?this.current:e}getCurrent(){return this.current}getPrevious(){return this.prev}getVelocity(){let e=r_.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>gx)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,gx);return Pg(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0;let n=!1,r;r=e(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===r&&(this.animation=void 0),t()}),n||(this.animation=r),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel?.notify()),this.animation=void 0}isAnimating(){return!!this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect?.()}};function bx(e,t){return new yx(e,t)}function xx(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Sx(e,t){let n=e?.[t]??e?.default??e;return n===e?n:xx(n,e)}var Cx={type:`spring`,stiffness:500,damping:25,restSpeed:10},wx=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Tx={type:`keyframes`,duration:.8},Ex={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Dx=(e,{keyframes:t})=>t.length>2?Tx:Xy.has(e)?e.startsWith(`scale`)?wx(t[1]):Cx:Ex,Ox=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`,`out`,`mixer`]);function kx(e){for(let t in e)if(!Ox.has(t))return!0;return!1}var Ax=(e,t,n,r={},i,a)=>o=>{let s=Sx(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=Mg(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i,hasOnUpdate:!!s.onUpdate};kx(s)||Object.assign(u,Dx(e,u)),u.duration&&=Mg(u.duration),u.repeatDelay&&=Mg(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Fb(u),u.delay===0&&(d=!0)),(Cg.instantAnimations||Cg.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,Fb(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=py(u.keyframes,s);if(e!==void 0){Sv.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new wy(u):new mx(u)},jx=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Mx(e){let t=jx.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Nx(e,t,n=1){let[r,i]=Mx(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return wg(e)?parseFloat(e):e}return c_(i)?Nx(i,t,n+1):i}function Px(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Fx(e,t,n,r){let i=t=>typeof t==`function`?t(n===void 0?e.custom:n,...Px(r)):t;return t=i(t),typeof t==`string`&&(t=e.variants&&e.variants[t]),i(t)}function Ix(e,t,n){return Fx(e.getProps(),t,n,e)}var Lx=(e,t)=>t===`exit`?e.presenceContext?.custom:void 0,Rx=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Yy]),zx=e=>Array.isArray(e);function Bx(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,bx(n))}function Vx(e){return zx(e)?e[e.length-1]||0:e}function Hx(e,t){let{transitionEnd:n={},transition:r={},...i}=Ix(e,t)||{};i={...i,...n};for(let t in i)Bx(e,t,Vx(i[t]))}var Ux=e=>!!(e&&e.getVelocity);function Wx(e){return!!(Ux(e)&&e.add)}function Gx(e,t){let n=e.getValue(`willChange`);if(Wx(n))return n.add(t);if(!n&&Cg.WillChange){let n=new Cg.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}var Kx=`data-framer-appear-id`;function qx(e){return e.props[Kx]}var Jx=typeof window<`u`;function Yx({protectedKeys:e,needsAnimating:t},n){let r=n in e&&!t[n];return t[n]=!1,r}function Xx(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?xx(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState?.getState()[i],p=a?.path;p&&(p.animateValues?p.animateValues(t=>e.getValue(t,e.latestValues[t]??0),s,a,n,d):p.animateVisualElement?.(e,s,a,n,d));for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&Yx(f,t))continue;let o={delay:n,...Sx(f?.out[t]||a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){Sv.update(()=>r.set(i));continue}let p=!1;if(Jx&&window.MotionHandoffAnimation){let n=qx(e);if(n){let e=window.MotionHandoffAnimation(n,t,Sv);e!==null&&(o.startTime=e,p=!0)}}Gx(e,t);let m=l??e.shouldReduceMotion;r.start(Ax(t,r,i,m&&Rx.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>Sv.update(()=>{o&&Hx(e,o)});d.length?Promise.all(d).then(t):t()}return d}function Zx(e,t,n={}){let r=Ix(e,t,Lx(e,n.type)),i=n.transitionOverride||(r?.transition??(e.getDefaultTransition()||{})),a=()=>Promise.all(r?Xx(e,r,n):[]),o=(r=0)=>{let{variantChildren:a}=e,{delayChildren:o=0,staggerChildren:s,staggerDirection:c}=i,l=[];return a?.forEach(e=>{e.notify(`AnimationStart`,t),l.push(Zx(e,t,{...n,delay:r+(typeof o==`function`?0:o)+hx(a,e,o,s,c)}).then(()=>e.notify(`AnimationComplete`,t)))}),Promise.all(l)},{when:s}=i;return s?s===`beforeChildren`?a().then(()=>o()):o().then(a):Promise.all([a(),o(n.delay)])}function Qx(e,t,n={}){return e.notify(`AnimationStart`,t),(Array.isArray(t)?Promise.all(t.map(t=>Zx(e,t,n))):typeof t==`string`?Zx(e,t,n):Promise.all(Xx(e,Ix(e,t,n.custom),n))).then(()=>{e.notify(`AnimationComplete`,t)})}var $x={test:e=>e===`auto`,parse:e=>e},eS=e=>t=>t.test(e),tS=[d_,$,D_,E_,k_,O_,$x],nS=e=>tS.find(eS(e));function rS(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||Eg(e)}var iS=new Set([`auto`,`none`,`0`]);function aS(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!iS.has(t)&&U_(t)&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]!==i&&(e[r]=Iy(n,i))}var oS=class extends mb{constructor(){super(...arguments),this.isAsync=!0}scheduleResolve(){if(this.canReadNow()&&(this.readKeyframes(),!this.needsMeasurement))return this.complete();super.scheduleResolve()}canReadNow(){let{unresolvedKeyframes:e,element:t,motionValue:n}=this,r=e[0]??n?.get();if(!t?.current||r===void 0)return!1;for(let t=0;t<e.length;t++)if(u_(t?e[t]:r))return!1;return!0}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t?.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),c_(r))){let i=Nx(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Rx.has(n)||e.length!==2)return;let[r,i]=e;if(typeof r==`number`&&typeof i==`number`)return;let a=nS(r),o=nS(i);if(u_(r)!==u_(i)&&ab[n])this.needsMeasurement=!0;else if(a!==o){if(Zy(a)&&Zy(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else ab[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||rS(e[t]))&&n.push(t);n.length&&aS(e,n,t)}measure(){let{element:e,name:t}=this;return ab[t](window.getComputedStyle(e.current),()=>e.measureViewportBox())}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e?.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=this.measure(),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&this.motionValue?.jump(r,!1)}measureEndState(){let{element:e,unresolvedKeyframes:t}=this;if(!e?.current)return;this.motionValue?.jump(this.measuredOrigin,!1);let n=t.length-1,r=t[n];t[n]=this.measure(),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.resolveNoneKeyframes()}},sS=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function cS(e){return Tg(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}function lS(e){return Tg(e)&&`ownerSVGElement`in e}var uS={};function dS(e){return uS.current?.add(e),e}var fS=e=>uS.current?uS.current.bind(e):e;function pS(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=t?t.current:uS.current?.root||document,i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}function mS(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}function hS(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(Xy.has(e))o=!0;else if(o_(e))i[e]=n;else{let t=Ub(n,My[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=Yb(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}var gS={offset:`stroke-dashoffset`,array:`stroke-dasharray`},_S={offset:`strokeDashoffset`,array:`strokeDasharray`};function vS(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?gS:_S;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var yS=[`transform`,`opacity`,`clipPath`,`filter`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function bS(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(hS(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;for(let e of yS)d[e]!==void 0&&(f[e]=d[e],delete d[e]);(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&vS(d,i,a,o,!1)}function xS({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function SS({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function CS(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function wS(e){return e===void 0||e===1}function TS({scale:e,scaleX:t,scaleY:n}){return!wS(e)||!wS(t)||!wS(n)}var ES=[`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skewX`,`skewY`];function DS(e){return TS(e)||kS(e)||OS(e)}function OS(e){return e.z||e.rotate||e.rotateX||e.rotateY||e.rotateZ||e.skewX||e.skewY}function kS(e){return AS(e.x)||AS(e.y)}function AS(e){return e&&e!==`0%`}function jS(e,t,n){return n+t*(e-n)}function MS(e,t,n,r,i){return i!==void 0&&(e=jS(e,i,r)),jS(e,n,r)+t}function NS(e,t=0,n=1,r,i){e.min=MS(e.min,t,n,r,i),e.max=MS(e.max,t,n,r,i)}function PS(e,{x:t,y:n}){NS(e.x,t.translate,t.scale,t.originPoint),NS(e.y,n.translate,n.scale,n.originPoint)}var FS=.999999999999,IS=1.0000000000001;function LS(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++)a=n[s],o=a.projectionDelta,a.options.visualElement?.props.style?.display!==`contents`&&(r===!0&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(RS(e.x,-a.scroll.offset.x),RS(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,PS(e,o)),r&&(r.path?.[s]||r)!==a&&DS(a.latestValues)&&VS(e,a.latestValues,a.layout?.layoutBox));t.x<IS&&t.x>FS&&(t.x=1),t.y<IS&&t.y>FS&&(t.y=1)}function RS(e,t){e.min+=t,e.max+=t}function zS(e,t,n,r,i=.5){NS(e,t,n,tv(e.min,e.max,i),r)}function BS(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function VS(e,t,n){let r=n??e;zS(e.x,BS(t.x,r.x),t.scaleX,t.scale,t.originX),zS(e.y,BS(t.y,r.y),t.scaleY,t.scale,t.originY)}function HS(e,t){return xS(CS(e.getBoundingClientRect(),t))}function US(e,t,n){let r=HS(e,n),{scroll:i}=t;return i&&(RS(r.x,i.offset.x),RS(r.y,i.offset.y)),r}var WS=()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),{schedule:GS,cancel:KS}=xv(queueMicrotask,!1);function qS(e,t,n){let r=Ux(e)?e:bx(e);return r.start(Ax(``,r,t,n)),r.animation}var JS={},YS={value:null,addProjectionMetrics:null,countProjection:void 0};function XS(e,t){let n=r_.now();e=fS(e);let r=({timestamp:i})=>{let a=i-n;a>=t&&(Cv(r),e(a-t))};return Sv.setup(r,!0),dS(()=>Cv(r))}function ZS(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function QS(e){return lS(e)&&e.tagName===`svg`}function $S(e){return Ux(e)?e.get():e}var eC=e=>typeof e==`number`?e:parseFloat(e),tC=sS.length,nC=e=>typeof e==`number`||$.test(e);function rC(e,t,n,r,i,a){i?(e.opacity=tv(0,n.opacity??1,aC(r)),e.opacityExit=tv(t.opacity??1,0,oC(r))):a&&(e.opacity=tv(t.opacity??1,n.opacity??1,r));for(let i=0;i<tC;i++){let a=sS[i],o=iC(t,a),s=iC(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||nC(o)===nC(s)?(e[a]=Math.max(tv(eC(o),eC(s),r),0),(D_.test(s)||D_.test(o))&&(e[a]+=`%`)):e[a]=s)}for(let i=0;i<ES.length;i++){let a=ES[i];(t[a]||n[a])&&(e[a]=tv(t[a]||0,n[a]||0,r))}}function iC(e,t){return e[t]===void 0?e.borderRadius:e[t]}var aC=sC(0,.5,Wg),oC=sC(.5,.95,Og);function sC(e,t,n){return r=>r<e?0:r>t?1:n(Ag(e,t,r))}function cC(e,t){e.min=t.min,e.max=t.max}function lC(e,t){cC(e.x,t.x),cC(e.y,t.y)}function uC(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var dC=.9999,fC=1.0001,pC=-.01,mC=.01;function hC(e){return e.max-e.min}function gC(e,t,n){return Math.abs(e-t)<=n}function _C(e,t,n,r=.5){e.origin=r,e.originPoint=tv(t.min,t.max,e.origin),e.scale=hC(n)/hC(t),e.translate=tv(n.min,n.max,e.origin)-e.originPoint,(e.scale>=dC&&e.scale<=fC||isNaN(e.scale))&&(e.scale=1),(e.translate>=pC&&e.translate<=mC||isNaN(e.translate))&&(e.translate=0)}function vC(e,t,n,r){_C(e.x,t.x,n.x,r?.originX),_C(e.y,t.y,n.y,r?.originY)}function yC(e,t,n,r=0){e.min=(r?tv(n.min,n.max,r):n.min)+t.min,e.max=e.min+hC(t)}function bC(e,t,n,r){yC(e.x,t.x,n.x,r?.x),yC(e.y,t.y,n.y,r?.y)}function xC(e,t,n,r=0){let i=r?tv(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+hC(t)}function SC(e,t,n,r){xC(e.x,t.x,n.x,r?.x),xC(e.y,t.y,n.y,r?.y)}function CC(e,t,n,r,i){return e-=t,e=jS(e,1/n,r),i!==void 0&&(e=jS(e,1/i,r)),e}function wC(e,t=0,n=1,r=.5,i,a=e,o=e){if(D_.test(t)&&(t=parseFloat(t),t=tv(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=tv(a.min,a.max,r);e===a&&(s-=t),e.min=CC(e.min,t,n,s,i),e.max=CC(e.max,t,n,s,i)}function TC(e,t,[n,r,i],a,o){wC(e,t[n],t[r],t[i],t.scale,a,o)}var EC=[`x`,`scaleX`,`originX`],DC=[`y`,`scaleY`,`originY`];function OC(e,t,n,r){TC(e.x,t,EC,n?.x,r?.x),TC(e.y,t,DC,n?.y,r?.y)}var kC=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),AC=kC(`applewebkit/`)&&!kC(`chrome/`)?Math.round:Og;function jC(e){e.min=AC(e.min),e.max=AC(e.max)}function MC(e){jC(e.x),jC(e.y)}var NC=()=>({translate:0,scale:1,origin:0,originPoint:0}),PC=()=>({x:NC(),y:NC()}),FC=()=>({min:0,max:0}),IC=()=>({x:FC(),y:FC()});function LC(e){return e.translate===0&&e.scale===1}function RC(e){return LC(e.x)&&LC(e.y)}function zC(e,t){return e.min===t.min&&e.max===t.max}function BC(e,t){return zC(e.x,t.x)&&zC(e.y,t.y)}function VC(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function HC(e,t){return VC(e.x,t.x)&&VC(e.y,t.y)}function UC(e){return hC(e.x)/hC(e.y)}function WC(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}var GC=class{constructor(){this.members=[]}add(e){yg(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;r&&r.isConnected!==!1||n.snapshot||(bg(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(bg(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}};function KC(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var qC={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if($.test(e))e=parseFloat(e);else return e}return`${KC(e,t.target.x)}% ${KC(e,t.target.y)}%`}},JC={borderRadius:Object.assign({},qC,{applyTo:sS.slice()}),borderTopLeftRadius:qC,borderTopRightRadius:qC,borderBottomLeftRadius:qC,borderBottomRightRadius:qC,boxShadow:{correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Z_.parse(e);if(i.length>5)return r;let a=Z_.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=tv(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}}};function YC(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e}=n;e&&(r=`perspective(${e}px) ${r}`);for(let e=0;e<ES.length;e++){let t=ES[e],i=n[t];i&&(r+=`${t}(${i}deg) `),!e&&n.pathRotation&&(r+=`rotate(${n.pathRotation}deg) `)}}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}function XC(e){return[e(`x`),e(`y`)]}var ZC=(e,t)=>e.depth-t.depth,QC=class{constructor(){this.children=[],this.isDirty=!1}add(e){yg(this.children,e),this.isDirty=!0}remove(e){bg(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(ZC),this.isDirty=!1,this.children.forEach(e)}},$C={hasAnimatedSinceResize:!0,hasEverUpdated:!1},ew=[`z`,`skew`,`skewZ`],tw=1e3,nw=0;function rw(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}var iw=e=>e.instance&&Xb.get(e.instance)?.demote()&&e.resetSkewAndRotation();function aw(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=qx(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Sv,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&aw(r)}function ow(e){if(e)return e.options.allowProjection===!1?ow(e.parent):e.projection}function sw({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return Object.assign(JS,{...JC,...JS}),class{static create(e,t,n){let{layoutId:r,layout:i,drag:a,dragConstraints:o,layoutScroll:s,layoutRoot:c,layoutAnchor:l,layoutCrossfade:u}=t,d=e.projection=new this(e.latestValues,t[`data-framer-portal-id`]?void 0:ow(e.parent));d.setOptions({layoutId:r,layout:i,alwaysMeasureLayout:!!a||o&&ZS(o),visualElement:e,animationType:typeof i==`string`?i:`both`,initialPromotionConfig:n,crossfade:u,layoutScroll:s,layoutRoot:c,layoutAnchor:l});let f=d.getStack()?.lead;f&&!d.root.isUpdateBlocked()&&(f.willUpdate(),f.scheduleCheckAfterUnmount())}constructor(e={},n=t?.()){this.id=nw++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(uw),this.nodes.forEach(xw),this.nodes.forEach(Sw),this.nodes.forEach(dw),YS.countProjection?.()},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new QC)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new jg),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){this.eventHandlers.get(e)?.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=lS(t)&&!QS(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent?.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;Sv.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n?.(),n=XS(i,250),$C.hasAnimatedSinceResize&&($C.hasAnimatedSinceResize=!1,this.nodes.forEach(bw)))})}n&&this.root.registerSharedNode(n,this),this.addLayoutListener()}addLayoutListener(){let{layoutId:e,layout:t,visualElement:n,animate:r}=this.options;this.instance&&!this.hasLayoutListener&&r!==!1&&n&&(e||t)&&(this.hasLayoutListener=!0,this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:r,layout:i})=>{if(this.isAnimationBlocked){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||n.getDefaultTransition()||Ow,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=n.getProps(),c=!this.targetLayout||!HC(this.targetLayout,i),l=!t&&r;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...Sx(a,`layout`),onPlay:o,onComplete:s};(n.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||bw(this),this.isLead()&&this.options.onExitComplete?.();this.targetLayout=i}))}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this),this.getStack()?.remove(this),this.parent?.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),this.hasLayoutListener=!1,Cv(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes?.forEach(Cw),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete?.();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&aw(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;iw(this),this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,iw(t),(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1),t.isAnimationBlocked&&(t.dragSnapshot||=t.measure(),this.dragAncestor=t)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(mw),this.nodes.forEach(pw);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(hw);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(_w),this.nodes.forEach(vw),this.nodes.forEach(yw),this.nodes.forEach(cw),this.nodes.forEach(lw)):this.nodes.forEach(hw),this.clearAllSnapshots();let e=r_.now();e_.delta=Sg(0,1e3/60,e-e_.timestamp),e_.timestamp=e,e_.isProcessing=!0,wv.update.process(e_),wv.preRender.process(e_),wv.render.process(e_),e_.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,GS.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(fw),this.sharedNodes.forEach((e,t)=>e.members.length?e.removeLeadSnapshot():this.sharedNodes.delete(t))}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Sv.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Sv.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!hC(this.snapshot.measuredBox.x)&&!hC(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutCorrected||=IC(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t?.notify(`LayoutMeasure`,this.layout.layoutBox,e?.layoutBox)}updateScroll(e=`measure`){let{scroll:t,instance:i}=this,{animationId:a}=this.root;if(this.options.layoutScroll&&i&&!(t&&t.animationId===a&&t.phase===e)){let o=r(i);this.scroll={animationId:a,phase:e,isRoot:o,offset:n(i),wasRoot:t?t.isRoot:o}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout;e&&iw(this);let t=this.projectionDelta&&!RC(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||DS(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),MC(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return IC();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(jw))){let{scroll:e}=this.root;e&&(RS(t.x,e.offset.x),RS(t.y,e.offset.y))}return t}removeElementScroll(e){let t=IC();if(lC(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&lC(t,e),RS(t.x,i.offset.x),RS(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n,r,i=0){let a=n||IC();lC(a,e);for(let e=i;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(RS(a.x,-n.scroll.offset.x),RS(a.y,-n.scroll.offset.y)),DS(n.latestValues)&&VS(a,n.latestValues,n.layout?.layoutBox)}return!r&&DS(this.latestValues)&&VS(a,this.latestValues,this.layout?.layoutBox),a}removeTransform(e){let t=IC();lC(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!DS(n.latestValues))continue;let r;n.instance&&(TS(n.latestValues)&&n.updateSnapshot(),r=IC(),lC(r,n.measurePageBox())),OC(t,n.latestValues,n.snapshot?.layoutBox,r)}return DS(this.latestValues)&&OC(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade},this.addLayoutListener()}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==e_.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=e_.timestamp;let a=this.getClosestProjectingParent();!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),(this.relativeTarget||this.targetDelta)&&(this.target||(this.target=IC(),this.targetWithTransforms=IC()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),bC(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target,!0):lC(this.target,this.layout.layoutBox),PS(this.target,this.targetDelta)):lC(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&(!a.resumingFrom==!this.resumingFrom||a.options.layoutRoot&&!a.resumingFrom)&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),YS.countProjection?.(1))}getClosestProjectingParent(){if(!(!this.parent||TS(this.parent.latestValues)||kS(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget=IC(),this.relativeTargetOrigin=IC(),SC(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),lC(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===e_.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent?.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;lC(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;LS(this.layoutCorrected,this.treeScale,this.path,t&&(e.relativeTarget&&!e.relativeParent.resumingFrom?e.relativeParent:!0)),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=IC());let{target:s}=e;s?(!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(uC(this.prevProjectionDelta.x,this.projectionDelta.x),uC(this.prevProjectionDelta.y,this.projectionDelta.y)),vC(this.projectionDelta,this.layoutCorrected,s,this.latestValues),this.treeScale.x===a&&this.treeScale.y===o&&WC(this.projectionDelta.x,this.prevProjectionDelta.x)&&WC(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),YS.countProjection?.(2)):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){this.options.visualElement?.scheduleRender(),e&&this.getStack()?.scheduleRender(),this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=PC(),this.projectionDelta=PC(),this.projectionDeltaWithTransform=PC()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=PC();this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=IC(),c=r?.source!==this.layout?.source,l=this.getStack(),u=!l||l.members.length<=1,d=!(!c||u||this.options.crossfade!==!0||this.path.some(Dw));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);ww(o.x,e.x,n),ww(o.y,e.y,n),r&&(o.x.translate=r.x,o.y.translate=r.y),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(SC(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Ew(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&BC(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=IC(),lC(f,this.relativeTarget)),c&&(this.animationValues=a,rC(a,i,this.latestValues,n,d,u)),r?.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Cv(this.pendingAnimation),void 0),this.pendingAnimation=Sv.update(()=>{$C.hasAnimatedSinceResize=!0,this.motionValue||=bx(0),this.motionValue.jump(0,!1),this.currentAnimation=qS(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),by(this.currentAnimation,this),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta?.(tw),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,layout:n,latestValues:r}=e,{target:i}=e;if(t&&i&&n){if(this!==e&&this.layout&&n&&Aw(this.options.animationType,this.layout.layoutBox,n.layoutBox)){let{layoutBox:e}=this.layout,t=i;i=this.target||IC(),kw(i.x,t.x,e.x),kw(i.y,t.y,e.y)}lC(t,i),VS(t,r),vC(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new GC),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?.transition,preserveFollowOpacity:n?.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){this.getStack()?.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){return this.getStack()?.relegate(this)||!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let{latestValues:t}=e;if(!OS(t))return;let n={};for(let t=0;t<ew.length;t++)rw(ew[t],e,n,this.animationValues);for(let t=0;t<ES.length;t++)rw(ES[t],e,n,this.animationValues);e.render();for(let t in n)e.setStaticValue(t,n[t]),this.animationValues&&(this.animationValues[t]=n[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;let n=this.getLead();if(!this.isVisible&&n!==this){e.visibility=`hidden`;return}let r=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=$S(t?.pointerEvents)||``,e.transform=r?r(this.latestValues,``):`none`;return}if(!this.projectionDelta||!this.layout||!n.target){(this.options.layoutId||this.needsShow)&&(this.needsShow=!1,e.visibility=``,e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=$S(t?.pointerEvents)||``),this.hasProjected&&!DS(this.latestValues)&&(e.transform=r?r({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=n.animationValues||n.latestValues;this.applyTransformsToTarget();let a=YC(this.projectionDeltaWithTransform,this.treeScale,i);r&&(a=r(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,e.opacity=n.animationValues?n===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:n===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in JS){if(i[t]===void 0)continue;let{correct:r,applyTo:o,isCSSVariable:s}=JS[t],c=a===`none`?i[t]:r(i[t],n);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=n===this?$S(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=this.dragSnapshot=this.dragAncestor=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(pw),this.root.sharedNodes.clear()}}}function cw(e){e.updateLayout(),gw(e)}function lw(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source,o=(r,a)=>{if(i===`size`)XC(e=>{let t=hC(r[e]);r[e].min=a[e].min,r[e].max=r[e].min+t});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;cC(r[e],a[e])}else Aw(i,t.layoutBox,n)&&XC(t=>{let n=hC(a[t]);r[t].max=r[t].min+n,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[t].max=e.relativeTarget[t].min+n)})},s=a?t.measuredBox:t.layoutBox;o(s,n);let c=PC();vC(c,n,t.layoutBox);let l=PC();vC(l,a?e.applyTransform(r,!0):n,s);let u=!RC(c),d=!1,f=e.getClosestProjectingParent();if((!e.resumeFrom||f?.options.layoutRoot&&e.resumeFrom.path.includes(f))&&f&&!f.resumeFrom){let{snapshot:r,layout:i}=f;if(r&&i){let s=e.options.layoutAnchor||void 0,c=IC();SC(c,a?e.resumeFrom.applyTransform(t.layoutBox,!0,void 0,!0,f.depth+1):t.layoutBox,r.layoutBox,s);let l=IC();SC(l,n,i.layoutBox,s),a&&o(c,l),HC(c,l)||(d=!0),f.options.layoutRoot&&(e.relativeTarget=l,e.relativeTargetOrigin=c,e.relativeParent=f)}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:l,layoutDelta:c,hasLayoutChanged:u,hasRelativeLayoutChanged:d})}else e.isLead()&&e.options.onExitComplete?.();e.options.transition=void 0}function uw(e){YS.countProjection?.(0),e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function dw(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function fw(e){e.clearSnapshot()}function pw(e){e.clearMeasurements()}function mw(e){e.isLayoutDirty=!0,e.updateLayout()}function hw(e){e.isLayoutDirty=!1}function gw(e){let{snapshot:t,dragAncestor:n}=e,r=n?.isAnimationBlocked&&n.layout;if(!t||!r||e.resumeFrom||e.isAnimationBlocked)return;let i=n.dragSnapshot;XC(e=>RS(t.layoutBox[e],r.layoutBox[e].min-i.layoutBox[e].min))}function _w(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.dragSnapshot||e.layout,e.isLayoutDirty=!0)}function vw(e){e.relativeTarget&&e.relativeParent?.isLayoutDirty&&(e.currentAnimation?e.isLayoutDirty=!0:(e.targetDelta=void 0,e.removeRelativeTarget()))}function yw(e){let{visualElement:t}=e.options;t?.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function bw(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function xw(e){e.resolveTargetDelta()}function Sw(e){e.calcProjection()}function Cw(e){e.resetSkewAndRotation()}function ww(e,t,n){e.translate=tv(t.translate,0,n),e.scale=tv(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Tw(e,t,n,r){e.min=tv(t.min,n.min,r),e.max=tv(t.max,n.max,r)}function Ew(e,t,n,r){Tw(e.x,t.x,n.x,r),Tw(e.y,t.y,n.y,r)}function Dw(e){return e.animationValues?.opacityExit!==void 0}var Ow={duration:.45,ease:[.4,0,.1,1]};function kw(e,t,n){e.max=hC(n)+(e.min=t.min)}function Aw(e,t,n){return e===`position`||e===`preserve-aspect`&&!gC(UC(t),UC(n),.2)}function jw(e){return e!==e.root&&e.scroll?.wasRoot}function Mw(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var Nw=sw({attachResizeListener:(e,t)=>Mw(e,`resize`,t),measureScroll:WS,checkIsScrollRoot:()=>!0}),Pw={current:void 0},Fw=sw({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Pw.current){let e=new Nw({});e.mount(window),e.setOptions({layoutScroll:!0}),Pw.current=e}return Pw.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Iw=new WeakMap;function Lw(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function Rw(e){return typeof e==`string`||Array.isArray(e)}var zw=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Bw=[`initial`].concat(zw);function Vw(e){if(Lw(e.animate))return!0;for(let t=0;t<Bw.length;t++)if(Rw(e[Bw[t]]))return!0;return!1}function Hw(e){return!!(Vw(e)||e.variants)}function Uw(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Ux(i))e.addValue(r,i);else if(Ux(a))e.addValue(r,bx(i,{owner:e}));else if(a!==i){if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,bx(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var Ww={current:null},Gw={current:!1},Kw=typeof window<`u`;function qw(){if(Gw.current=!0,Kw){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>Ww.current=e.matches;e.addEventListener(`change`,t),t()}else Ww.current=!1}}var Jw=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Yw={};function Xw(e){Yw=e}function Zw(){return Yw}var Qw=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=mb,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=r_.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Sv.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=Vw(t),this.isVariantNode=Hw(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&Ux(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];if(this.current=e,Iw.set(e,this),this.projection?.instance||this.projection?.mount(e),this.isVariantNode&&!this.isControllingVariants){let e=this;do e=e.props.inherit!==!1&&e.parent;while(e&&!e.isVariantNode);if(e){let{variantChildren:t}=e;t.add(this),this.removeFromVariantTree=()=>t.delete(this)}}this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(Gw.current||qw(),this.shouldReduceMotion=Ww.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection?.unmount(),Cv(this.notifyUpdate),Cv(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree?.(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),(this.enteringChildren||=new Set).add(e)}removeChild(e){this.children.delete(e),this.enteringChildren?.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.get(e)?.(),t.accelerate&&Ib.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Db({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:Mg(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Xy.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Sv.preRender(this.notifyUpdate),n&&(this.projection&&(this.projection.isTransformDirty=!0),Xb.get(this.current)?.check()),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i?.()})}sortNodePosition(e){return!this.current||!e.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Yw){let t=Yw[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):IC()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){let{transformTemplate:n,onUpdate:r}=this.props;(e.transformTemplate||n)&&this.scheduleRender(),(e.transformTemplate&&!n||e.onUpdate&&!r)&&Xb.get(this.current)?.demote(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<Jw.length;t++){let n=Jw[t];this.propEventSubscriptions[n]?.(),delete this.propEventSubscriptions[n];let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=Uw(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue?.()}getProps(){return this.props}getVariant(e){return this.props.variants?.[e]}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}addValue(e,t){let n=this.values.get(e);if(t!==n){n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t);let r=t.get();r!==void 0&&(this.latestValues[e]=r)}}removeValue(e){this.values.delete(e),this.valueSubscriptions.get(e)?.(),this.valueSubscriptions.delete(e),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){let n=this.props.values?.[e];return n||(n=this.values.get(e),n===void 0&&t!==void 0&&(n=bx(t??this.getDefaultValue?.(e),{owner:this}),this.addValue(e,n)),n)}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(wg(n)||Eg(n))?n=parseFloat(n):typeof n!=`number`&&!Z_.test(n)&&Z_.test(t)&&(n=Iy(e,t)),this.setBaseTarget(e,Ux(n)?n.get():n)),Ux(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}on(e,t){return(this.events[e]||(this.events[e]=new jg)).add(t)}notify(e,...t){this.events[e]?.notify(...t)}scheduleRenderMicrotask(){GS.render(this.render)}},$w=class extends Qw{constructor(){super(...arguments),this.KeyframeResolver=oS}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;Ux(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}};function eT(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function tT(e,{layout:t,layoutId:n}){return Xy.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!JS[e]||e===`opacity`)}function nT(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Ux(r[t])||i&&Ux(i[t])||tT(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function rT(e){return window.getComputedStyle(e)}var iT=class extends $w{constructor(){super(...arguments),this.type=`html`,this.renderInstance=eT}mount(e){super.mount(e)}readValueFromInstance(e,t){if(Xy.has(t))return this.projection?.isProjecting?Ky(t):Jy(e,t);{let n=rT(e),r=(o_(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return HS(e,t)}build(e,t,n){hS(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return nT(e,t,n)}},aT=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1;function oT(e){return{point:{x:e.pageX,y:e.pageY}}}var sT=e=>t=>aT(t)&&e(t,oT(t));function cT(e,t,n,r){return Mw(e,t,sT(n),r)}var lT=new WeakMap,uT,dT=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:lS(r)&&`getBBox`in r?r.getBBox()[t]:r[n],fT=dT(`inline`,`width`,`offsetWidth`),pT=dT(`block`,`height`,`offsetHeight`);function mT({target:e,borderBoxSize:t}){lT.get(e)?.forEach(n=>{n(e,{get width(){return fT(e,t)},get height(){return pT(e,t)}})})}function hT(e){e.forEach(mT)}function gT(){typeof ResizeObserver<`u`&&(uT=new ResizeObserver(hT))}function _T(e,t){uT||gT();let n=pS(e);return n.forEach(e=>{let n=lT.get(e);n||(n=new Set,lT.set(e,n)),n.add(t),uT?.observe(e)}),()=>{n.forEach(e=>{let n=lT.get(e);n?.delete(t),n?.size||uT?.unobserve(e)})}}var vT=new Set,yT;function bT(){yT=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};vT.forEach(t=>t(e))},window.addEventListener(`resize`,yT)}function xT(e){return vT.add(e),yT||bT(),()=>{vT.delete(e),!vT.size&&typeof yT==`function`&&(window.removeEventListener(`resize`,yT),yT=void 0)}}function ST(e,t){return dS(typeof e==`function`?xT(e):_T(e,t))}var CT=(e,t)=>Math.abs(e-t);function wT(e,t){let n=CT(e.x,t.x),r=CT(e.y,t.y);return Math.sqrt(n**2+r**2)}var TT=new Set([`auto`,`scroll`]),ET=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.hasPendingMove=!1,this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=OT(this.lastRawMoveEventInfo,this.transformPagePoint));let e=AT(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=wT(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e;this.history.push({...r,timestamp:r_.now()});let{onStart:i,onMove:a}=this.handlers;t||(i?.(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),a?.(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.handleScroll(window),this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=OT(t,this.transformPagePoint),this.hasPendingMove=!0,Sv.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.hasPendingMove&&this.updatePoint(),this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i?.(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=AT(e.type===`pointercancel`?this.lastMoveEventInfo:OT(t,this.transformPagePoint),this.history);this.startEvent&&n?.(e,a),r?.(e,a)},!aT(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=OT(oT(e),this.transformPagePoint),{point:c}=s;this.history=[{...c,timestamp:r_.now()}];let{onSessionStart:l}=t;l&&l(e,AT(s,this.history));let u={passive:!0,capture:!0};this.removeListeners=kg(cT(this.contextWindow,`pointermove`,this.handlePointerMove,u),cT(this.contextWindow,`pointerup`,this.handlePointerUp,u),cT(this.contextWindow,`pointercancel`,this.handlePointerUp,u)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(TT.has(e.overflowX)||TT.has(e.overflowY))&&this.scrollPositions.set(t,DT(t)),t=t.parentElement}this.scrollPositions.set(window,DT(window)),this.removeScrollListeners=kg(Mw(window,`scroll`,this.onElementScroll,{capture:!0}),Mw(window,`scroll`,this.onWindowScroll,{}))}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=DT(e),i={x:r.x-t.x,y:r.y-t.y};(i.x!==0||i.y!==0)&&(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Sv.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners?.(),this.removeScrollListeners?.(),this.scrollPositions.clear(),Cv(this.updatePoint)}},DT=e=>e===window?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop};function OT(e,t){return t?{point:t(e.point)}:e}function kT(e,t){return{x:e.x-t.x,y:e.y-t.y}}function AT({point:e},t){return{point:e,delta:kT(e,MT(t)),offset:kT(e,jT(t)),velocity:NT(t,.1)}}function jT(e){return e[0]}function MT(e){return e[e.length-1]}function NT(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=MT(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Mg(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Mg(t)*2&&(r=e[1]);let a=Ng(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}var PT=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function FT(e){return PT.has(e.tagName)||e.isContentEditable===!0}var IT=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function LT(e){return IT.has(e.tagName)||e.isContentEditable===!0}var RT={x:!1,y:!1};function zT(){return RT.x||RT.y}function BT(e){return e===`x`||e===`y`?RT[e]?null:(RT[e]=!0,()=>{RT[e]=!1}):RT.x||RT.y?null:(RT.x=RT.y=!0,()=>{RT.x=RT.y=!1})}function VT(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?tv(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?tv(n,e,r.max):Math.min(e,n)),e}function HT(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function UT(e,{top:t,left:n,bottom:r,right:i}){return{x:HT(e.x,n,i),y:HT(e.y,t,r)}}function WT(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function GT(e,t){return{x:WT(e.x,t.x),y:WT(e.y,t.y)}}function KT(e,t){let n=.5,r=hC(e),i=hC(t);return i>r?n=Ag(t.min,t.max-r,e.min):r>i&&(n=Ag(e.min,e.max-i,t.min)),Sg(0,1,n)}function qT(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var JT=.35;function YT(e=JT){return e===!1?e=0:e===!0&&(e=JT),{x:XT(e,`left`,`right`),y:XT(e,`top`,`bottom`)}}function XT(e,t,n){return{min:ZT(e,t),max:ZT(e,n)}}function ZT(e,t){return typeof e==`number`?e:e[t]||0}function QT(e){let t=``;for(let n of e.path){n.scroll=void 0,n.updateScroll();let{scroll:r}=n;n!==e.root&&r&&(t+=r.offset.x+`,`+r.offset.y+`,`)}return t}var $T=new WeakMap,eE=class{constructor(e,t=()=>e.getProps()){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=IC(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e,this.readProps=t}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){if(this.visualElement.presenceContext?.isPresent===!1)return;let r=e=>{t&&this.snapToCursor(e),this.stopAnimation()},i=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock?.(),this.openDragLock=BT(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints();let{projection:a}=this.visualElement;a&&(a.isAnimationBlocked=!0,a.target=void 0),XC(e=>{let t=this.getAxisMotionValue(e).get()||0;if(c_(t)&&(t=Nx(t,this.visualElement.current)||0),$.test(t))t=parseFloat(t);else if(D_.test(t)){let n=a?.layout?.layoutBox[e];n&&(t=hC(n)*(parseFloat(t)/100))}this.originPoint[e]=t}),i&&Sv.update(()=>i(e,t),!1,!0),Gx(this.visualElement,`transform`),this.visualElement.animationState?.setActive(`whileDrag`,!0)},a=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){if(this.currentDirection=oE(o),this.currentDirection===null)return;i&&i(this.currentDirection)}this.updateAxis(`x`,o),this.updateAxis(`y`,o),this.visualElement.render(),a&&Sv.update(()=>a(e,t),!1,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},s=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:c}=this.getProps();this.panSession=new ET(e,{onSessionStart:r,onStart:i,onMove:a,onSessionEnd:o,resumeAnimation:s},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:n,contextWindow:this.visualElement.current?.ownerDocument.defaultView,element:this.visualElement.current})}stop(e,t,n){let r=e||this.latestPointerEvent,i=t||this.latestPanInfo,a=this.isDragging;if(this.cancel(),!a||!i||!r)return;let{velocity:o}=i;this.startAnimation(o,n);let{onDragEnd:s}=this.getProps();s&&Sv.postRender(()=>s(r,i))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession(),!this.getProps().dragPropagation&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t?.setActive(`whileDrag`,!1)}endPanSession(){this.panSession?.end(),this.panSession=void 0}updateAxis(e,t){let{drag:n}=this.readProps();if(!t||!aE(e,n,this.currentDirection))return;let r=this.getAxisMotionValue(e),i=this.originPoint[e]+t[e],a=this.constraints&&this.constraints[e];a&&(i=VT(i,a,this.elastic[e])),r.set(i)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),{projection:n}=this.visualElement,r=n&&(n.layout||n.measure(!1)),i=this.constraints;tE(e)?this.constraints&&this.scroll===QT(n)||(this.constraints=this.resolveRefConstraints()):this.constraints=e&&r?UT(r.layoutBox,e):!1,this.elastic=YT(t),i!==this.constraints&&!tE(e)&&r&&this.constraints&&!this.hasMutatedConstraints&&XC(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=qT(r.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!tE(e))return!1;let n=nE(e),{projection:r}=this.visualElement;if(!r||!r.layout)return!1;this.scroll=QT(r);let i=US(n,r.root,this.visualElement.getTransformPagePoint()),a=GT(r.layout.layoutBox,r.removeElementScroll(i));if(t){let e=t(SS(a));this.hasMutatedConstraints=!!e,e&&(a=xS(e))}return a}startAnimation(e,t){let{drag:n,dragMomentum:r,dragElastic:i,dragTransition:a,dragSnapToOrigin:o,onDragTransitionEnd:s}=this.getProps(),c=this.constraints||{},l=XC(s=>{if(!aE(s,t||n,this.currentDirection))return;let l=c[s]||{};(o===!0||o===s)&&(l={min:0,max:0});let u=i?200:1e6,d=i?40:1e7,f={type:`inertia`,velocity:r?e[s]:0,bounceStiffness:u,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...a,...l};return this.startAxisValueAnimation(s,f)});return Promise.all(l).then(s)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return Gx(this.visualElement,e),n.start(Ax(e,n,0,t,this.visualElement,!1))}stopAnimation(){XC(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.readProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor({clientX:e,clientY:t}){let{drag:n}=this.getProps(),r={x:e,y:t},i=this.visualElement.getTransformPagePoint()?.(r)||r,a=this.visualElement.measureViewportBox();XC(e=>{if(!aE(e,n,this.currentDirection))return;let t=this.getAxisMotionValue(e),{min:r,max:o}=a[e];t.set((t.get()||0)+i[e]-tv(r,o,.5))})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!tE(t)||!n||!this.constraints)return;this.stopAnimation();let r=this.constraints,i={x:0,y:0};XC(e=>{let t=this.getAxisMotionValue(e).get();i[e]=KT({min:t,max:t},r[e])});let{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},``):`none`,n.root?.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),XC(t=>{let n=this.getAxisMotionValue(t);if(!aE(t,e,null)||!n.get())return;let{min:r,max:a}=this.constraints[t];n.set(tv(r,a,i[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;$T.set(this.visualElement,this);let e=this.visualElement.current,t=cT(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&<(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps(),r=tE(t)&&nE(t);r&&(this.constraints=this.resolveRefConstraints(),n||=iE(e,r,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i.layout||(i.root?.updateScroll(),i.updateLayout()),Sv.read(r);let o=Mw(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(XC(t=>{if(!aE(t,this.getProps().drag,this.currentDirection))return;let n=this.getAxisMotionValue(t);this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate)}),this.visualElement.render())}));return()=>{o(),t(),a(),s(),n?.()}}getProps(){let e=this.readProps(),{dragElastic:t=JT,dragMomentum:n=!0}=e;return{...e,dragElastic:t,dragMomentum:n}}};function tE(e){return!!e&&typeof e==`object`&&(`current`in e||`nodeType`in e)}var nE=e=>`current`in e?e.current:e;function rE(e){let t=!0;return()=>{t?t=!1:e()}}function iE(e,t,n){let r=ST(e,rE(n)),i=ST(t,rE(n));return()=>{r(),i()}}function aE(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function oE(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}function sE(e,t){let n=pS(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},dS(()=>r.abort())]}function cE(e){return!(e.pointerType===`touch`||zT())}function lE(e,t,n={}){t=fS(t);let[r,i,a]=sE(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{e.pointerType!==`touch`&&(n?r=!0:s(e))};e.addEventListener(`pointerenter`,n=>{if(!cE(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var uE=(e,t)=>t?e===t||uE(e,t.parentElement):!1,dE=new WeakSet;function fE(e){return t=>{t.key===`Enter`&&e(t)}}function pE(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var mE=(e,t)=>{let n=!1,r=fE(()=>{dE.has(e)||(n=!0,pE(e,`down`))}),i=fE(()=>{n&&(n=!1,pE(e,`up`))});e.addEventListener(`keydown`,r,t),e.addEventListener(`keyup`,i,t),e.addEventListener(`blur`,()=>{e.removeEventListener(`keydown`,r),e.removeEventListener(`keyup`,i),n&&pE(e,`cancel`)},{...t,once:!0})};function hE(e){return aT(e)&&!zT()}var gE=new WeakSet;function _E(e,t,n={}){t=fS(t);let[r,i,a]=sE(e,n),o=e=>{let r=e.currentTarget;if(!hE(e)||gE.has(e))return;dE.add(r),n.stopPropagation&&gE.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),dE.has(r)&&dE.delete(r),hE(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||uE(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),cS(e)&&(e.addEventListener(`focus`,()=>mE(e,i),i),!FT(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function vE(...e){let t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],i=e[1+n],a=e[2+n],o=e[3+n],s=ry(i,a,o);return t?s(r):s}var yE=class{constructor(e){this.isMounted=!1,this.node=e}update(){}},bE=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),xE=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function SE(e,t,n,r){eT(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(bE.has(n)?n:mS(n),t.attrs[n])}function CE(e,t,n){let r=nT(e,t,n);for(let n in e)if(n!==`children`&&(Ux(e[n])||Ux(t[n]))){let t=Yy.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var wE=class extends $w{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=IC}getBaseTargetFromProps(e,t){return Xy.has(t)?super.getBaseTargetFromProps(e,t)??Ky(t):e[t]}getDefaultValue(e){return Xy.has(e)?this.latestValues[e]??Ky(e):void 0}readValueFromInstance(e,t){if(Xy.has(t)){let e=Py(t);return e&&e.default||0}if(yS.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=bE.has(t)?t:mS(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return CE(e,t,n)}build(e,t,n){bS(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){SE(e,t,n,r)}mount(e){this.isSVGTag=xE(e.tagName),super.mount(e)}};function TE(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var EE=[...zw].reverse(),DE=e=>e?.out===!0?e:e?.out;function OE(e){let t=t=>Promise.all(t.map(({animation:t,options:n})=>Qx(e,t,n))),n=AE(),r=!0,i=!1;function a(a){let{props:o,parent:s,manuallyAnimateOnMount:c}=e,{initial:l}=o,u=r||i,d=[],f=(t=l)=>typeof t!=`boolean`&&Ix(e,Array.isArray(t)?t[0]:t,e.presenceContext?.custom)||void 0,p=new Map,m={},h=1/0,g=e;do g=g.props.inherit!==!1&&g.parent;while(g&&!g.isControllingVariants);let _=u&&DE(f(l??(g&&g.props.initial))?.transition);if(EE.forEach((t,r)=>{let i=n[t],l=o[t],f=g&&g.props[t],v=l===void 0?Rw(f)||f===!1?f:void 0:l,y=Rw(v),b=t===a?i.isActive:null,x=y&&l===void 0&&!(u&&c);if(i.protectedKeys={...m},!i.isActive&&b===null||!v&&!i.prevProp||Lw(v)||typeof v==`boolean`)return;if(b===!1&&(h=r),t===`exit`&&i.isActive&&b!==!0){m={...m,...i.prevResolvedValues};return}let S=kE(i.prevProp,v),C=S||y&&(b&&!x||r>h),w=!1,T=Array.isArray(v)?v:[v],E={},D;if(b!==!1)for(let n of T){let{transition:r,transitionEnd:i,...a}=Ix(e,n,Lx(e,t))||{};E={...E,...a,...i},D=DE(r)||D}let{prevResolvedValues:O}=i;for(let t in{...O,...E}){if(t in m)continue;let n=E[t],r=O[t],a=Array.isArray(n)&&Array.isArray(r)?!TE(n,r)||S:n!==r,o;if(a&&n==null)p.has(t)||p.set(t,i.prevOut);else if(a||n!==void 0&&p.has(t)){C=!0,o=p.get(t)||_,p.delete(t)&&(w=!0),i.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)}else i.protectedKeys[t]=!0;i.out[t]=o}if(i.prevProp=v,i.prevResolvedValues=E,i.prevOut=D,i.isActive&&(m={...m,...E}),C&&(!(x&&S)||w))for(let n of T){let r={type:t};if(typeof n==`string`&&u&&c&&s?.enteringChildren){let t=Ix(s,n)?.transition?.delayChildren;r.delay=hx(s.enteringChildren,e,t)}d.push({animation:n,options:r})}}),p.size){let t={},n=f(),r=n?.transition;p.forEach((i,a)=>{i&&(r={...r||e.getDefaultTransition(),[a]:i});let s=e.getValue(a);s&&(s.liveStyle=!0);let c=n&&!Array.isArray(l)?n[a]:void 0,u=e.getBaseTargetFromProps(o,a);t[a]=(c===void 0?u!==void 0&&!Ux(u)?u:e.initialValues[a]===void 0?e.baseTarget[a]:void 0:c)??null}),r&&(t.transition=r),d.push({animation:t})}let v=u&&e.blockInitialAnimation||r&&!c&&(o.initial===!1||o.initial===o.animate);return r=i=!1,!v&&d.length?t(d):Promise.resolve()}function o(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=a(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:a,setActive:o,setAnimateFunction:n=>{t=n(e)},getState:()=>n,reset:()=>{n=AE(),i=!0}}}function kE(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!TE(t,e):!1}function AE(){let e={};for(let t of zw)e[t]={isActive:t===`animate`,protectedKeys:{},needsAnimating:{},prevResolvedValues:{},out:{}};return e}var jE=(0,W.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function ME(e=!0){let t=(0,W.useContext)(vg);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,W.useId)();(0,W.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,W.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var NE=(0,W.createContext)({strict:!1}),PE={animation:[`variants`,...zw],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},FE=!1;function IE(){if(FE)return;let e={};for(let t in PE)e[t]={isEnabled:e=>PE[t].some(t=>!!e[t])};Xw(e),FE=!0}function LE(){return IE(),Zw()}function RE(e){let t=LE();for(let n in e)t[n]={...t[n],...e[n]};Xw(t)}var zE=(0,W.createContext)({});function BE(e,t){if(Vw(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Rw(t)?t:void 0,animate:Rw(n)?n:void 0}}return e.inherit===!1?{}:t}function VE(e){let{initial:t,animate:n}=BE(e,(0,W.useContext)(zE));return(0,W.useMemo)(()=>({initial:t,animate:n}),[HE(t),HE(n)])}function HE(e){return Array.isArray(e)?e.join(` `):e}var UE=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function WE(e,t,n){for(let r in t)!Ux(t[r])&&!tT(r,n)&&(e[r]=t[r])}function GE({transformTemplate:e},t){return(0,W.useMemo)(()=>{let n=UE();return hS(n,t,e),Object.assign({},n.vars,n.style)},[t])}function KE(e,t){let n=e.style||{},r={};return WE(r,n,e),Object.assign(r,GE(e,t)),r}function qE(e,t){let n={},r=KE(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var JE=()=>({...UE(),attrs:{}});function YE(e,t,n,r){let i=(0,W.useMemo)(()=>{let n=JE();return bS(n,t,xE(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};return WE(t,e.style,e),{...i,style:{...t,...i.style}}}return i}var XE=new Set(`animate.exit.variants.initial.style.values.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function ZE(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||XE.has(e)}function QE(e,t){return e.startsWith(`on`)?!ZE(e):t?.(e)??!ZE(e)}function $E(e,t,n,r){let i={};for(let a in e)a===`values`&&typeof e.values==`object`||Ux(e[a])||(QE(a,r)||n===!0&&ZE(a)||!t&&!ZE(a)||e.draggable&&a.startsWith(`onDrag`))&&(i[a]=e[a]);return i}var eD=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function tD(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(eD.indexOf(e)>-1||/[A-Z]/u.test(e))}function nD(e,t,n,{latestValues:r},i,a=!1,o,s){let c=(o??tD(e)?YE:qE)(t,r,i,e),l=$E(t,typeof e==`string`,a,s),u=e===W.Fragment?{}:{...l,...c,ref:n},{children:d}=t,f=(0,W.useMemo)(()=>Ux(d)?d.get():d,[d]);return(0,W.createElement)(e,{...u,children:f})}function rD({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:iD(n,r,i,e),renderState:t()}}function iD(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=$S(a[e]);let{initial:o,animate:s}=e,c=Vw(e),l=Hw(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Lw(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Fx(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var aD=e=>(t,n)=>{let r=(0,W.useContext)(zE),i=(0,W.useContext)(vg),a=()=>rD(e,t,r,i);return n?a():gg(a)},oD=aD({scrapeMotionValuesFromProps:nT,createRenderState:UE}),sD=aD({scrapeMotionValuesFromProps:CE,createRenderState:JE}),cD=Symbol.for(`motionComponentSymbol`);function lD(e,t,n){let r=(0,W.useRef)(n);(0,W.useInsertionEffect)(()=>{r.current=n});let i=(0,W.useRef)(null);return(0,W.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`){if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n)}else a&&(a.current=n)},[t])}var uD=(0,W.createContext)({});function dD(e,t,n,r,i,a){let{visualElement:o}=(0,W.useContext)(zE),s=(0,W.useContext)(NE),c=(0,W.useContext)(vg),l=(0,W.useContext)(jE),u=l.reducedMotion,d=l.skipAnimations,f=(0,W.useRef)(null),p=(0,W.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,W.useContext)(uD);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&i.create(m,n,h),(0,W.useInsertionEffect)(()=>{m&&m.props!==n&&m.update(n,c)});let g=n[Kx],_=(0,W.useRef)(!!g&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return _g(()=>{p.current&&m&&(m.animationState?.animateChanges(),m.enteringChildren=void 0)},[]),_g(()=>{p.current=!0,m&&(window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),_.current&&m.animationState&&m.animationState.animateChanges())}),(0,W.useEffect)(()=>{m&&(!_.current&&m.animationState&&m.animationState.animateChanges(),_.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),!1),m.enteringChildren=void 0)}),m}function fD(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&RE(r);let a=n?n===`svg`:tD(e),o=a?sD:oD;function s(n,s){let c,l=pD(n);gg(()=>!!Pw.current?.sharedNodes.get(l)?.lead&&n.initial)&&(n={...n,initial:!1});let u={...(0,W.useContext)(jE),...n,layoutId:l},{isStatic:d,isValidProp:f}=u,p=VE(n),m=o(n,d);if(!d&&typeof window<`u`){mD(u,r);let t=hD(u);p.visualElement=dD(e,m,u,i,t.ProjectionNode,a),(t.isEnabled||p.visualElement?.projection?.options.layoutId)&&(c=t.MeasureLayout)}return(0,G.jsxs)(zE.Provider,{value:p,children:[c&&p.visualElement?(0,G.jsx)(c,{visualElement:p.visualElement,...u}):null,nD(e,n,lD(m,p.visualElement,s),m,d,t,a,f)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,W.forwardRef)(s);return c[cD]=e,c}function pD({layoutId:e}){let t=(0,W.useContext)(hg).id;return t&&e!==void 0?t+`-`+e:e}function mD(e,t){(0,W.useContext)(NE).strict}function hD(e){let{drag:t,layout:n}=LE();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:r.MeasureLayout,isEnabled:t?.isEnabled(e)||n?.isEnabled(e),ProjectionNode:r.ProjectionNode}}function gD(e,t){if(typeof Proxy>`u`)return fD;let n=new Map,r=(n,r)=>fD(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,fD(a,void 0,e,t)),n.get(a))})}var _D=(e,t)=>t.isSVG??tD(e)?new wE(t):new iT(t,{allowProjection:e!==W.Fragment}),vD=class extends yE{constructor(e){super(e),e.animationState||=OE(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Lw(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){this.node.getProps().animate!==this.node.prevProps?.animate&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},yD=0,bD={animation:{Feature:vD},exit:{Feature:class extends yE{constructor(){super(...arguments),this.id=yD++}update(){let{presenceContext:e,prevPresenceContext:t,animationState:n}=this.node;if(!e||!n)return;let{isPresent:r,onExitComplete:i}=e,a=t?.isPresent;if(r===a)return;if(r&&a===!1){if(this.exit===!0){let{initial:e}=this.node.getProps();if(e&&!Array.isArray(e)){let{transition:t,transitionEnd:n,...r}=Ix(this.node,e)||{};for(let e in r)this.node.getValue(e)?.jump(r[e])}this.node.blockInitialAnimation=!1,n.reset(),n.animateChanges()}else n.setActive(`exit`,!1);this.exit=void 0;return}let o=this.exit=n.setActive(`exit`,!r);i&&!r&&o.then(()=>{this.exit===o&&(this.exit=!0,i(this.id))})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id,this.node))}unmount(){}}}},xD=class extends yE{constructor(e){super(e),this.removeGroupControls=Og,this.removeListeners=Og,this.controls=new eE(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Og}update(){let{dragControls:e,drag:t}=this.node.getProps(),{dragControls:n,drag:r}=this.node.prevProps||{};e!==n&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls))),r&&!t&&this.controls.stop(void 0,void 0,r)}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},SD=e=>(t,n)=>{e&&Sv.update(()=>e(t,n),!1,!0)},CD=class extends yE{constructor(){super(...arguments),this.removePointerDownListener=Og}onPointerDown(e){this.session=new ET(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:this.node.current?.ownerDocument.defaultView})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:SD(e),onStart:SD(t),onMove:SD(n),onEnd:(e,t)=>{delete this.session,r&&Sv.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=cT(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session?.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session?.end()}},wD=!1,TD=({layout:e,layoutDependency:t,layoutAnchor:n})=>({layout:e,layoutDependency:t,layoutAnchor:n,animationType:typeof e==`string`?e:`both`}),ED=(e,t)=>{let{snapshot:n}=e,r=e.getStack();r?.remove(e);let i=r?.lead;if(r?.prevLead===e&&i.resumeFrom===e&&(i.resumeFrom=i.currentAnimation=e.resumingFrom=void 0),e.options.layoutId=t,!t)e.needsShow=!0;else return e.root.registerSharedNode(t,e),()=>{let{resumeFrom:t}=e;t?.isPresent!==!1&&e.getStack().members.includes(t)&&(t.hide(),e.resumeFrom=void 0,e.snapshot=n)}},DD=class extends W.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group?.add(i),r&&n?.register?.(i),wD&&i.root.didUpdate(),i.options.layoutId!==r&&ED(i,r)?.(),i.addEventListener(`animationComplete`,()=>this.safeToRemove()),i.setOptions({...i.options,...TD(this.props),onExitComplete:()=>this.safeToRemove()})),$C.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,layoutId:n,visualElement:r,drag:i,isPresent:a}=this.props,{projection:o}=r;return o&&(o.isPresent=a,this.takeOver=e.layoutId===n?void 0:(o.willUpdate(),ED(o,n)),o.setOptions({...o.options,...TD(this.props)}),wD=!0,i||e.layoutDependency!==t||t===void 0||e.isPresent!==a?o.willUpdate():this.safeToRemove(),e.isPresent!==a&&(a?o.promote():o.relegate()||Sv.postRender(()=>{o.getStack()?.members.length||this.safeToRemove()}))),null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(this.takeOver?.(),e.root.didUpdate(),GS.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;wD=!0,r&&(r.scheduleCheckAfterUnmount(),t.group?.remove(r),n?.deregister?.(r))}safeToRemove(){this.props.safeToRemove?.()}render(){return null}};function OD(e){let[t,n]=ME(),r=(0,W.useContext)(hg);return(0,G.jsx)(DD,{...e,layoutGroup:r,switchLayoutGroup:(0,W.useContext)(uD),isPresent:t,safeToRemove:n})}var kD={pan:{Feature:CD},drag:{Feature:xD,ProjectionNode:Fw,MeasureLayout:OD}};function AD(e,t,n,r){let{props:i}=e,a=`while`+n;e.animationState&&i[a]&&e.animationState.setActive(a,r===`Start`);let o=i[`on`+n+r];o&&Sv.postRender(()=>o(t,oT(t)))}var jD=class extends yE{mount(){let{current:e}=this.node;e&&(this.unmount=lE(e,(e,t)=>(AD(this.node,t,`Hover`,`Start`),e=>AD(this.node,e,`Hover`,`End`))))}unmount(){}},MD=class extends yE{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}e&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=kg(Mw(this.node.current,`focus`,()=>this.onFocus()),Mw(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function ND(e,t,n){e.current instanceof HTMLButtonElement&&e.current.disabled||AD(e,t,`Tap`,n)}var PD=class extends yE{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=_E(e,(e,t)=>(ND(this.node,t,`Start`),(e,{success:t})=>ND(this.node,e,t?``:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},FD=new WeakMap,ID=new WeakMap,LD=e=>{let t=FD.get(e.target);t&&t(e)},RD=e=>{e.forEach(LD)};function zD({root:e,...t}){let n=e||document;ID.has(n)||ID.set(n,{});let r=ID.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(RD,{root:e,...t})),r[i]}function BD(e,t,n){let r=zD(t);return FD.set(e,n),r.observe(e),()=>{FD.delete(e),r.unobserve(e)}}var VD={some:0,all:1},HD=class extends yE{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:VD[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=BD(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(UD(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function UD({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var WD=gD(Object.assign({},bD,{inView:{Feature:HD},tap:{Feature:PD},focus:{Feature:MD},hover:{Feature:jD}},kD,{layout:{ProjectionNode:Fw,MeasureLayout:OD}}),_D);function GD(e){let t=gg(()=>bx(e)),{isStatic:n}=(0,W.useContext)(jE);if(n){let[,n]=(0,W.useState)(e);(0,W.useEffect)(()=>t.on(`change`,n),[])}return t}function KD(e,t){let n=GD(t()),r=()=>n.set(t());return r(),_g(()=>{let t=()=>Sv.preRender(r,!1,!0),n=e.map(e=>e.on(`change`,t));return r(),()=>{n.forEach(e=>e()),Cv(r)}}),n}function qD(e){vx.current=[],e();let t=KD(vx.current,e);return vx.current=void 0,t}function JD(e,t,n,r){if(typeof e==`function`)return qD(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!=`function`)return XD(e,t,n,r);let i=typeof t==`function`?t:vE(t,n,r),a=Array.isArray(e)?YD(e,i):YD([e],([e])=>i(e)),o=Array.isArray(e)?void 0:e.accelerate;if(o&&!o.isTransformed&&typeof t!=`function`&&Array.isArray(n)&&r?.clamp!==!1&&!r?.mixer){let e=r?.ease;a.accelerate={...o,times:[0,...t,1],keyframes:[n[0],...n,n[n.length-1]],isTransformed:!0,...e?{ease:Array.isArray(e)?[e[0],...e]:e}:{}}}return a}function YD(e,t){let n=gg(()=>[]);return KD(e,()=>{n.length=0;let r=e.length;for(let t=0;t<r;t++)n[t]=e[t].get();return t(n)})}function XD(e,t,n,r){let i=gg(()=>Object.keys(n)),a=gg(()=>({}));for(let o of i)a[o]=JD(e,t,n[o],r);return a}var ZD=class{constructor(){this.componentControls=new Set}subscribe(e){return this.componentControls.add(e),()=>this.componentControls.delete(e)}start(e,t){this.componentControls.forEach(n=>{n.start(e.nativeEvent||e,t)})}cancel(){this.componentControls.forEach(e=>{e.cancel()})}stop(){this.componentControls.forEach(e=>{e.stop()})}},QD=()=>new ZD;function $D(){return gg(QD)}var eO=(0,W.createContext)(null);function tO(e,t,n,r,i,a=`ltr`){let o=e.findIndex(e=>e.value===t);if(o===-1)return e;if(i===`xy`){let{layout:t}=e[o],r={x:tv(t.x.min,t.x.max,.5)+n.x,y:tv(t.y.min,t.y.max,.5)+n.y},i=nO(e),s=i.find(t=>t.items.includes(e[o])),c=i.reduce((e,t)=>rO(r.y,t)<rO(r.y,e)?t:e);if(c!==s)return iO(e,o,r.x,c,a);let l=aO(r,t),u=-1,d=l;return e.forEach((e,t)=>{if(t===o)return;let n=aO(r,e.layout);n<d&&(u=t,d=n)}),u===-1?e:xg(e,o,o+Math.sign(u-o))}if(!r[i])return e;let s=r[i]>0?1:-1,c=e[o+s];if(!c)return e;let l=e[o].layout[i],u=c.layout[i],d=tv(u.min,u.max,.5);return s===1&&l.max+n[i]>d||s===-1&&l.min+n[i]<d?xg(e,o,o+s):e}function nO(e){let t=[];return e.forEach(e=>{let{min:n,max:r}=e.layout.y,i=t[t.length-1];!i||n>=i.max||r<=i.min?t.push({items:[e],min:n,max:r}):(i.items.push(e),i.min=Math.min(i.min,n),i.max=Math.max(i.max,r))}),t}function rO(e,t){return e<t.min?t.min-e:e>t.max?e-t.max:0}function iO(e,t,n,r,i){let a=e.filter((e,n)=>n!==t),o=r.items.find(e=>{let t=tv(e.layout.x.min,e.layout.x.max,.5);return i===`ltr`?n<t:n>t}),s=o?a.indexOf(o):a.indexOf(r.items[r.items.length-1])+1,c=[...a];return c.splice(s,0,e[t]),c.every((t,n)=>t===e[n])?e:c}function aO(e,t){let n=Math.max(t.x.min-e.x,0,e.x-t.x.max),r=Math.max(t.y.min-e.y,0,e.y-t.y.max);return n*n+r*r}var oO=(e,t)=>e.max<=t.min||t.max<=e.min;function sO(e){let t=!1,n=!1;for(let r=0;r<e.length;r++)for(let i=r+1;i<e.length;i++)if(t||=oO(e[r].x,e[i].x),n||=oO(e[r].y,e[i].y),t&&n)return`xy`;return t?`x`:`y`}function cO({children:e,as:t=`ul`,axis:n,onReorder:r,values:i,onPointerDownCapture:a,onClickCapture:o,...s},c,l){let u=gg(()=>l[t]),d=(0,W.useRef)(new Map),[f,p]=(0,W.useState)(`y`),m=(0,W.useRef)(!1),h=(0,W.useRef)(!1),g=(0,W.useRef)(null),_=n||f,v=new Set(i);d.current.forEach((e,t)=>{v.has(t)||d.current.delete(t)});let y=()=>i.flatMap(e=>{let t=d.current.get(e);return t?[{value:e,layout:t}]:[]}),b=()=>g.current?.ownerDocument.defaultView?.getComputedStyle(g.current).direction===`rtl`,x=(e,t)=>{let n=0,a=i.map(t=>d.current.has(t)?e[n++].value:t);a.some((e,t)=>e!==i[t])&&r(a,t)},S={axis:_,proxy:l,groupRef:g,hasReordered:h,onKeyDown:(e,t,n,r)=>{let{key:a,currentTarget:o}=e;if(e.defaultPrevented||e.target!==o||e.altKey||e.ctrlKey||e.metaKey)return;let s=y(),c=[`ArrowUp`,`ArrowLeft`,`ArrowDown`,`ArrowRight`].indexOf(a),l=c%2;if(a===` `)e.repeat||r(o,n?void 0:i);else if(!n)return;else if(a===`Escape`){let e=n.flatMap(e=>s.filter(t=>t.value===e));x(s.map(t=>n.includes(t.value)?e.shift():t),t),r(o)}else if(c<0||_!==`xy`&&_!==(l?`x`:`y`))return;else{let e=s.findIndex(({value:e})=>e===t),n=e+(c>1==!!(l&&b())?-1:1);e>-1&&s[n]&&x(xg(s,e,n),t)}e.preventDefault()},registerItem:(e,t)=>{if(d.current.set(e,t),!n){let e=sO(i.flatMap(e=>{let t=d.current.get(e);return t?[t]:[]}));e!==f&&p(e)}},updateOrder:(e,t,n)=>{if(m.current)return;let r=y(),i=tO(r,e,t,n,_,b()?`rtl`:`ltr`);r!==i&&(m.current=!0,h.current=!0,x(i,e))}};(0,W.useEffect)(()=>{m.current=!1},[i]);let C=e=>{g.current=e,typeof c==`function`?c(e):c&&(c.current=e)},w={overflowAnchor:`none`,...s.style};return(0,G.jsx)(u,{...s,style:w,ref:C,onPointerDownCapture:e=>{h.current=!1,a?.(e)},onClickCapture:e=>{h.current&&e.detail&&(h.current=!1,e.stopPropagation(),e.preventDefault()),o?.(e)},ignoreStrict:!0,children:(0,G.jsx)(eO.Provider,{value:S,children:e})})}var lO=e=>(0,W.forwardRef)((t,n)=>cO(t,n,e)),uO=50,dO=1.5,fO=new Set([`auto`,`scroll`]),pO=new WeakMap,mO=new WeakMap,hO=null;function gO(){if(hO){let e=vO(hO,`y`);e&&(mO.delete(e),pO.delete(e));let t=vO(hO,`x`);t&&t!==e&&(mO.delete(t),pO.delete(t)),hO=null}}function _O(e,t){let n=getComputedStyle(e),r=t===`x`?n.overflowX:n.overflowY,i=e===document.body||e===document.documentElement;return fO.has(r)||i}function vO(e,t){let n=e?.parentElement;for(;n;){if(_O(n,t))return n;n=n.parentElement}return null}function yO(e){let t=Math.min(1,1-e/uO);return dO*t*t*e_.delta}function bO(e,t,n){let r=t.getBoundingClientRect(),i=n===`x`?Math.max(0,r.left):Math.max(0,r.top),a=n===`x`?Math.min(window.innerWidth,r.right):Math.min(window.innerHeight,r.bottom),o=e-i,s=a-e;return o<uO?{amount:-yO(o),edge:`start`}:s<uO?{amount:yO(s),edge:`end`}:{amount:0,edge:null}}function xO(e,t,n,r){if(!e)return;hO=e;let i=vO(e,n);if(!i)return;let{amount:a,edge:o}=bO(t-(n===`x`?window.scrollX:window.scrollY),i,n);if(o===null){mO.delete(i),pO.delete(i);return}let s=mO.get(i),c=i===document.body||i===document.documentElement;if(s!==o){if(!(o===`start`&&r<0||o===`end`&&r>0))return;mO.set(i,o);let e=n===`x`?i.scrollWidth-(c?window.innerWidth:i.clientWidth):i.scrollHeight-(c?window.innerHeight:i.clientHeight);pO.set(i,e)}if(a>0){let e=pO.get(i);if((n===`x`?c?window.scrollX:i.scrollLeft:c?window.scrollY:i.scrollTop)>=e)return}n===`x`?c?window.scrollBy({left:a}):i.scrollLeft+=a:c?window.scrollBy({top:a}):i.scrollTop+=a}function SO(e,t=0){return Ux(e)?e:GD(t)}function CO({children:e,style:t={},value:n,as:r=`li`,onDrag:i,onDragEnd:a,onKeyDown:o,onBlur:s,layout:c=!0,...l},u){let d=(0,W.useContext)(eO),f=gg(()=>d.proxy[r]),[p,m]=(0,W.useState)(),h={x:SO(t.x),y:SO(t.y)},g=JD([h.x,h.y],([e,t])=>e||t?1:`unset`),{axis:_,registerItem:v,updateOrder:y,groupRef:b,hasReordered:x,onKeyDown:S}=d,C=_===`xy`||_,w=(e,t)=>{m(t),Iw.get(e)?.animationState?.setActive(`whileDrag`,!!t)};return(0,G.jsx)(f,{drag:C,tabIndex:0,...l,dragSnapToOrigin:!0,style:{...t,x:h.x,y:h.y,zIndex:g},layout:c,onDrag:(e,t)=>{let{velocity:r,point:a}=t,o={x:h.x.get(),y:h.y.get()};y(n,o,r);let s=_===`xy`?Math.abs(r.x)>Math.abs(r.y)?`x`:`y`:_;xO(b.current,a[s],s,r[s]),i&&i(e,t)},onDragEnd:(e,t)=>{x.current=!1,gO(),a&&a(e,t)},onKeyDown:e=>{o?.(e),S(e,n,p,w)},onBlur:e=>{s?.(e),p&&w(e.currentTarget)},onLayoutMeasure:e=>{v(n,e)},ref:u,ignoreStrict:!0,children:e})}var wO=(0,W.forwardRef)(CO),TO=lO(WD);function EO(e){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(``),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(null);return(0,G.jsxs)(`form`,{className:`grid`,onSubmit:async n=>{n.preventDefault(),u(null);try{if(t)await Ft([ut(a).address],s.trim()===``?null:s.trim());else{let e=ut(r);await Ft([e.address],e.code)}e.onAdded?.()}catch(e){u(Ht(e))}},children:[(0,G.jsxs)(`div`,{className:B(`grid gap-2`,e.fieldsClassName),children:[t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Tp,{"aria-label":`Server URL`,placeholder:`Server URL, e.g. http://127.0.0.1:47841`,spellCheck:!1,autoComplete:`off`,value:a,onChange:e=>o(e.target.value)}),(0,G.jsx)(Tp,{"aria-label":`Pairing code`,placeholder:`Pairing code, empty if auth is off`,spellCheck:!1,autoComplete:`off`,value:s,onChange:e=>c(e.target.value)})]}):(0,G.jsx)(Tp,{"aria-label":`Pairing link`,placeholder:`Pairing link`,spellCheck:!1,autoComplete:`off`,value:r,onChange:e=>i(e.target.value)}),l!==null&&(0,G.jsx)(`p`,{className:`text-destructive text-sm break-all`,children:l}),(0,G.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground w-fit cursor-pointer text-xs`,onClick:()=>{n(!t),u(null)},children:t?`Paste a pairing link instead`:`Enter the server URL and code separately`})]}),e.actions(t?a.trim()!==``:r.trim()!==``)]})}function DO(e){return(0,G.jsx)(oi,{open:!0,onOpenChange:()=>e.onClose(),children:(0,G.jsxs)($r,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,children:[(0,G.jsxs)(ei,{className:`gap-1 px-6 pt-4 pr-12`,children:[(0,G.jsx)(ri,{className:`text-base`,children:`Add machine`}),(0,G.jsx)(ii,{children:`Paste the pairing link that OffSite printed when it started.`})]}),(0,G.jsx)(EO,{fieldsClassName:`p-6`,onAdded:e.onClose,actions:t=>(0,G.jsxs)(si,{className:`bg-muted/40 border-t px-6 py-4`,children:[(0,G.jsx)(U,{type:`button`,variant:`outline`,onClick:e.onClose,children:`Cancel`}),(0,G.jsx)(U,{type:`submit`,disabled:!t,children:`Add machine`})]})})]})})}function OO(e){let t=e.machine,n=t.icon??`computer`,[r,i]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`flex min-h-13 items-center justify-between gap-4 px-4 py-2.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Icon`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(Df.includes(n)?Df:[n,...Df]).map(e=>(0,G.jsx)(U,{title:e,size:`icon-sm`,"aria-pressed":e===n,variant:e===n?`default`:`ghost`,onClick:()=>I(t.id,{icon:e}),children:(0,G.jsx)(Of,{icon:e})},e)),(0,G.jsxs)(ln,{open:r,onOpenChange:i,modal:!0,children:[(0,G.jsx)(Sn,{asChild:!0,children:(0,G.jsx)(U,{title:`More icons`,size:`icon-sm`,variant:`ghost`,children:(0,G.jsx)(H,{icon:wr})})}),(0,G.jsx)(sn,{align:`end`,collisionPadding:12,className:`flex max-h-96 w-80 flex-col gap-3 overflow-y-auto p-3`,children:(0,G.jsx)(kO,{machine:t.id,selected:n,onClose:()=>i(!1)})})]})]})]})}function kO(e){return(0,G.jsx)(G.Fragment,{children:[...new Set(Object.values(Ef).map(e=>e.group))].map(t=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}),(0,G.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(2rem,1fr))] gap-1`,children:Object.keys(Ef).filter(e=>Ef[e].group===t&&!Df.includes(e)).map(t=>(0,G.jsx)(U,{title:t,size:`icon-sm`,className:`aspect-square h-auto! w-full!`,"aria-pressed":t===e.selected,variant:t===e.selected?`default`:`ghost`,onClick:()=>{I(e.machine,{icon:t}),e.onClose()},children:(0,G.jsx)(Of,{icon:t,className:`block aspect-square! h-auto! w-[66%]! min-w-0! shrink-0!`})},t))})]},t))})}var AO={connecting:`Connecting…`,online:`Online`,offline:`Offline`,unpaired:`Needs pairing`};function jO(){let e=k(e=>e.machines),t=k(e=>e.machines.find(t=>t.id===e.settingsEditedMachine)),[n,r]=(0,W.useState)(!1),[a,o]=(0,W.useState)(null),s=a===null?e:[...e].sort((e,t)=>a.indexOf(e.id)-a.indexOf(t.id));return t===void 0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Nh,{title:`Machines`,note:`This browser connects to each one directly. The list stays in this browser`,children:(0,G.jsx)(TO,{as:`div`,axis:`y`,className:`divide-y`,values:s.map(e=>e.id),onReorder:o,children:s.map(e=>(0,G.jsxs)(NO,{value:e.id,disabled:!1,className:`min-h-13 gap-4`,onDragEnd:()=>{a!==null&&be(a),o(null)},children:[(0,G.jsx)(Of,{icon:e.icon,className:`text-muted-foreground size-5 shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.name}),e.addresses.map(e=>(0,G.jsx)(`p`,{className:`text-muted-foreground truncate font-mono text-xs`,children:e},e)),e.providers.filter(e=>e.state===`error`).map(e=>(0,G.jsxs)(`p`,{className:`text-destructive truncate text-xs`,title:e.error??void 0,children:[rr[e.provider],` threads: `,e.error]},e.provider))]}),(0,G.jsxs)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:[AO[e.status],e.status===`online`&&e.via!==null&&e.via!==e.addresses[0]&&` · via ${new URL(e.via).host}`]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost`,title:`Reconnect, trying the first address first`,onClick:()=>ve(e.id),children:(0,G.jsx)(H,{icon:Bs})}),(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost-muted`,title:`Open machine`,onClick:()=>i({settingsEditedMachine:e.id}),children:(0,G.jsx)(H,{icon:kn})})]})]},e.id))})}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:(0,G.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>r(!0),children:`Add machine…`})}),n&&(0,G.jsx)(DO,{onClose:()=>r(!1)})]}):(0,G.jsx)(MO,{machine:t})}function MO(e){let t=e.machine,[n,r]=(0,W.useState)(!1),[a,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(null),f=u??t.addresses,p=t.addresses.some(e=>o!==null&&o.includes(e)),m=(0,W.useRef)(null);(0,W.useEffect)(()=>{n&&m.current?.focus()},[n]);function h(e){l(null);try{return I(t.id,{addresses:[...new Set(e.map(e=>ut(e).address))]}),!0}catch(e){return l(Ht(e)),!1}}async function g(e){l(null);let n=e.trim();if(n===``)return!0;try{let e=n.includes(`#`)?ut(n).code:n;if(e===null)throw Error(`That link has no pairing code`);return await me(t.id,e),!0}catch(e){return l(Ht(e)),!1}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Nh,{title:`Machine`,children:[(0,G.jsx)(Q,{label:`Name`,children:(0,G.jsx)(Ph,{value:t.label??``,placeholder:t.hostname,onCommit:e=>I(t.id,{label:e.trim()===``?null:e.trim()})},t.label)}),(0,G.jsx)(OO,{machine:t})]}),!p&&(0,G.jsx)(Nh,{title:`Pairing`,children:(0,G.jsxs)(`div`,{className:`flex min-h-13 items-center justify-between gap-4 px-4 py-2.5`,children:[t.pairedAt!==null&&t.status!==`unpaired`&&(0,G.jsx)(`span`,{className:`text-sm`,children:t.pairedAt===null?`Paired`:`Paired ${ar(t.pairedAt)}`}),(t.pairedAt===null||t.status===`unpaired`)&&(0,G.jsxs)(`form`,{className:`flex flex-1 items-center gap-3`,onSubmit:async e=>{e.preventDefault(),await g(a)&&s(``)},children:[(0,G.jsx)(Tp,{className:`flex-1 font-mono`,placeholder:`Pairing link or code`,spellCheck:!1,autoComplete:`off`,value:a,onChange:e=>s(e.target.value)}),(0,G.jsxs)(U,{type:`submit`,variant:`outline`,className:`px-4`,disabled:a.trim()===``,children:[(0,G.jsx)(H,{icon:bs}),`Pair`]})]})]})}),(0,G.jsxs)(Nh,{title:`Addresses`,note:`OffSite tries them in order whenever it reconnects`,children:[(0,G.jsx)(TO,{as:`div`,axis:`y`,className:`divide-y`,values:f,onReorder:d,children:f.map((e,t)=>(0,G.jsxs)(NO,{value:e,disabled:p,onDragEnd:()=>{u!==null&&h(u),d(null)},children:[(0,G.jsx)(Ph,{className:`flex-1 font-mono`,value:e,disabled:p,onCommit:e=>h(f.map((n,r)=>r===t?e:n))}),(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost`,title:`Remove address`,disabled:p||f.length===1,onClick:()=>h(f.filter((e,n)=>n!==t)),children:(0,G.jsx)(H,{icon:is})})]},e))}),n&&(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,G.jsx)(Tp,{ref:m,className:`font-mono`,placeholder:`http://192.168.1.10:47841`,spellCheck:!1,autoComplete:`off`,onBlur:e=>{let n=e.target.value.trim();(n===``||h([...t.addresses,n]))&&r(!1)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}),!n&&!p&&(0,G.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted/50 hover:text-foreground flex w-full items-center gap-2 px-4 py-3 text-sm transition-colors`,onClick:()=>r(!0),children:[(0,G.jsx)(H,{icon:Oo,className:`size-4`}),`Add address`]})]}),c!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-1 text-xs break-all`,children:c}),!p&&(0,G.jsxs)(mr,{children:[(0,G.jsx)(Or,{asChild:!0,children:(0,G.jsx)(U,{variant:`outline`,className:`text-destructive`,children:`Remove machine`})}),(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsxs)(Hn,{children:[`Remove `,t.name,`?`]}),(0,G.jsx)(Rn,{children:`This browser forgets the machine. The machine and its threads stay untouched.`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>{i({settingsEditedMachine:null}),ge(t.id)},children:`Remove machine`})]})]})]})]})}function NO(e){let t=$D();return(0,G.jsxs)(wO,{as:`div`,value:e.value,dragListener:!1,dragControls:t,onDragEnd:e.onDragEnd,className:B(`bg-background relative flex items-center gap-3 px-4 py-2.5`,e.className),children:[(0,G.jsx)(`span`,{className:B(`text-muted-foreground hover:text-foreground cursor-grab touch-none active:cursor-grabbing`,e.disabled&&`pointer-events-none opacity-50`),title:`Drag to reorder`,onPointerDown:e=>t.start(e),children:(0,G.jsx)(H,{icon:as,className:`size-4`})}),e.children]})}var PO=Fe.withTag(`notifications`),FO=new Map([[`denied`,`Blocked in the browser's site settings`],[`insecure`,`Needs https or localhost`],[`install`,`Add OffSite to the Home Screen first`],[`unsupported`,`Not supported in this browser`]]);function IO(e){let t=e.prefs.terminal,n=t.behavior;function r(r){Ye({...e.prefs,terminal:{...t,behavior:{...n,...r}}})}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Nh,{title:`Notifications`,children:[(0,G.jsx)(Q,{label:`Desktop notifications on this device`,children:(0,G.jsx)(LO,{})}),(0,G.jsx)(Q,{label:`Push terminal alerts when no OffSite page is open`,children:(0,G.jsx)(RO,{})})]}),(0,G.jsxs)(Nh,{title:`Terminal bell`,children:[(0,G.jsx)(Q,{label:`Flash the screen on bell`,children:(0,G.jsx)(Mh,{checked:n.bellFlash,onCheckedChange:e=>r({bellFlash:e})})}),(0,G.jsx)(Q,{label:`Play a sound on bell`,children:(0,G.jsx)(Mh,{checked:n.bellSound,onCheckedChange:e=>r({bellSound:e})})})]})]})}function LO(){let[e,t]=(0,W.useState)(Oa),[n,r]=(0,W.useState)(ka);(0,W.useEffect)(()=>{let e=Oa();if(e===`insecure`||e===`unsupported`)return;let n=new AbortController;return ja(n.signal,()=>t(Oa())).catch(e=>PO.error(`could not watch the notification permission`,e)),()=>n.abort()},[]);async function i(e){await Aa(e),r(e),t(Oa())}return(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[FO.has(e)&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:FO.get(e)}),(0,G.jsx)(Mh,{checked:e===`granted`&&n,disabled:e!==`granted`&&e!=="default",onCheckedChange:e=>void i(e)})]})}function RO(){let[e,t]=(0,W.useState)(za),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(()=>za()===`supported`),[o,s]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(za()!==`supported`)return;let e=!0;async function t(){try{let t=await Va();e&&r(t)}catch(e){PO.error(`could not read the push subscription`,e)}e&&a(!1)}return t(),()=>{e=!1}},[]);async function c(e){a(!0),s(null);try{e?r(await Ha()):(await Ua(),r(!1))}catch(e){PO.error(`could not change push notifications`,e),s(Ht(e))}t(za()),a(!1)}return(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o!==null&&(0,G.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[`Could not update: `,o]}),FO.has(e)&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:FO.get(e)}),(0,G.jsx)(Mh,{checked:e===`supported`&&n,disabled:e!==`supported`||i,onCheckedChange:e=>void c(e)})]})}function zO(e){let t=k(e=>e.projects),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[l,u]=zr(`sidebarScope`,null),d=t.filter(t=>t.machine===e.machine&&!t.scratch).sort((e,t)=>n===null?0:n.indexOf(e.id)-n.indexOf(t.id));return(0,G.jsxs)(G.Fragment,{children:[d.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground py-8 text-center text-sm`,children:`No projects yet`}),(0,G.jsx)(TO,{as:`div`,axis:`y`,values:d.map(e=>e.id),onReorder:r,children:d.map(t=>(0,G.jsxs)(NO,{value:t.id,disabled:!1,className:`min-h-13 px-1 outline-none`,onDragEnd:async()=>{if(n!==null){try{await fc(e.machine,n)}catch(e){c(e)}r(null)}},children:[(0,G.jsx)(mc,{machine:t.machine,projectId:t.id,className:`size-5 shrink-0 [&>img]:rounded-[4px] [&>svg]:rounded-[4px]`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,title:t.path,children:[(0,G.jsx)(`span`,{className:B(`block truncate text-sm`,t.hidden&&`text-muted-foreground`),children:t.name}),(0,G.jsx)(`span`,{className:`text-muted-foreground block truncate font-mono text-xs`,children:BO(t.path,e.homeDir)})]}),(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost-muted`,title:`Configure project`,"aria-label":`Configure ${t.name}`,onClick:()=>a(t),children:(0,G.jsx)(H,{icon:Us})}),(0,G.jsx)(Mh,{size:`sm`,checked:!t.hidden,onCheckedChange:e=>uc(t.machine,t.id,{hidden:!e}).catch(c),"aria-label":`Show ${t.name}`})]},t.id))}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:(0,G.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>s(!0),children:`Add project…`})}),o&&(0,G.jsx)(Am,{machine:e.machine,onClose:()=>s(!1),onAdd:()=>s(!1)}),i!==null&&(0,G.jsx)(Mm,{project:i,onClose:()=>a(null),onRemoved:()=>{l?.machine===i.machine&&l.projectId===i.id&&u(null),a(null)}})]})}function BO(e,t){return e===t?`~`:e.startsWith(`${t}/`)||e.startsWith(`${t}\\`)?`~${e.slice(t.length)}`:e}function VO(e){let t=e.account,[n,r]=(0,W.useState)(null);async function a(n){r(null);try{await L(e.machine,`accounts.update`,{id:t.id,name:t.name,color:t.color,configDir:t.configDir,enabled:t.enabled,...n})}catch(e){r(Ht(e))}}async function o(){r(null);try{await L(e.machine,`accounts.remove`,{id:t.id}),i({settingsAccount:null})}catch(e){r(Ht(e))}}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Nh,{title:`Account`,children:[(0,G.jsx)(Q,{label:`Name`,children:(0,G.jsx)(Ph,{value:t.name,valid:e=>e.trim()!==``,onCommit:e=>void a({name:e})},t.name)}),(0,G.jsx)(Q,{label:`Color`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.color!==null&&(0,G.jsx)(`span`,{className:`size-5 shrink-0 rounded-full`,style:{backgroundColor:t.color}}),(0,G.jsx)(Ph,{className:`w-28 font-mono`,value:t.color??``,placeholder:`#3b82f6`,valid:e=>e===``||/^#[0-9a-f]{6}$/i.test(e),onCommit:e=>void a({color:e===``?null:e})},t.color??``)]})}),(0,G.jsx)(Q,{label:`Config directory`,children:(0,G.jsx)(Ph,{className:`w-72 font-mono`,value:t.configDir??``,placeholder:t.provider===`claude`?`~/.claude or empty for default`:`~/.codex or empty for default`,onCommit:e=>void a({configDir:e})},t.configDir??``)})]}),n!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-1 text-xs`,children:n}),(0,G.jsxs)(mr,{children:[(0,G.jsx)(Or,{asChild:!0,children:(0,G.jsx)(U,{variant:`outline`,className:`text-destructive`,children:`Remove account`})}),(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsxs)(Hn,{children:[`Remove `,t.name,`?`]}),(0,G.jsx)(Rn,{children:`OffSite stops using this account. Its config directory and sessions stay untouched.`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>void o(),children:`Remove account`})]})]})]})]})}function HO(e){let[t,n]=(0,W.useState)(``),[r,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null);async function u(){s(!0),l(null);try{await L(e.machine,`accounts.add`,{provider:e.provider,name:t,configDir:r}),i({settingsAccount:null})}catch(e){l(Ht(e)),s(!1)}}return(0,G.jsxs)(`form`,{className:`space-y-5`,onSubmit:e=>{e.preventDefault(),u()},children:[(0,G.jsxs)(Nh,{title:`Account`,children:[(0,G.jsx)(Q,{label:`Name`,children:(0,G.jsx)(Tp,{className:`w-56`,value:t,onChange:e=>n(e.target.value),placeholder:`Work`})}),(0,G.jsx)(Q,{label:`Config directory`,children:(0,G.jsx)(Tp,{className:`w-72 font-mono`,value:r,onChange:e=>a(e.target.value),placeholder:e.provider===`claude`?`~/.claude or empty for default`:`~/.codex or empty for default`})})]}),c!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-1 text-xs`,children:c}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(U,{type:`button`,variant:`ghost`,onClick:()=>i({settingsAccount:null}),children:`Cancel`}),(0,G.jsx)(U,{type:`submit`,disabled:o||t.trim()===``,children:`Add account`})]})]})}function UO(e){let t=e.config,n=t.enabledProviders[e.provider],r=e.provider===`claude`?e.claudeAccounts:e.provider===`codex`?e.codexAccounts:[],i=r.find(e=>e.valid),a=t.claudeBaseDir[e.platform]??e.defaultClaudeBaseDir;if(e.selected===`new`){if(e.provider===`opencode`)throw Error(`OpenCode accounts cannot be added`);return(0,G.jsx)(HO,{machine:e.machine,provider:e.provider})}if(e.selected!==null){let t=r.find(t=>t.id===e.selected);return t===void 0?(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This account no longer exists.`}):(0,G.jsx)(VO,{machine:e.machine,account:t})}return(0,G.jsxs)(G.Fragment,{children:[e.provider===`claude`&&(0,G.jsx)(`div`,{className:`divide-y overflow-hidden rounded-xl border`,children:(0,G.jsx)(Q,{label:`Base directory`,children:(0,G.jsx)(Ph,{className:`w-72 font-mono`,value:a,valid:e=>e.trim()!==``,onCommit:n=>po(e.machine,{...t,claudeBaseDir:{...t.claudeBaseDir,[e.platform]:n}})},a)})}),(0,G.jsxs)(`div`,{className:B(`space-y-5 transition-opacity`,!n&&`opacity-50`),children:[e.provider!==`opencode`&&(0,G.jsx)(Nh,{title:`Accounts`,children:(0,G.jsx)(GO,{machine:e.machine,accounts:r})}),n&&e.provider===`opencode`&&e.openCode.available&&(0,G.jsx)(WO,{machine:e.machine,config:t,provider:e.provider,accountId:null}),n&&e.provider!==`opencode`&&i!==void 0&&(0,G.jsx)(WO,{machine:e.machine,config:t,provider:e.provider,accountId:i.id})]})]})}function WO(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null),a=e.config.models[e.provider],o=t===null?null:t.models;(0,W.useEffect)(()=>{let t=!0;return n(null),i(null),L(e.machine,`capabilities`,{provider:e.provider,accountId:e.accountId,projectId:null}).then(e=>{t&&n(e)},e=>{t&&i(Ht(e))}),()=>{t=!1}},[e.machine,e.provider,e.accountId]);function s(t,n){po(e.machine,{...e.config,models:{...e.config.models,[e.provider]:{...a,[t]:n}}})}return(0,G.jsxs)(Nh,{title:`Models`,children:[r!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:r}),r===null&&o===null&&(0,G.jsx)(`p`,{className:`text-muted-foreground px-4 py-3 text-xs`,children:`Loading…`}),(o??[]).map(t=>{let n=a[t.value]??{hidden:t.deprecated,effort:t.effort};return(0,G.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 px-4 py-1.5`,children:[(0,G.jsxs)(`div`,{className:B(`min-w-0 flex-1 truncate text-sm`,n.hidden&&`text-muted-foreground`),children:[t.name,e.provider===`opencode`&&(0,G.jsx)(`span`,{className:`text-muted-foreground ml-2 text-xs`,children:t.description})]}),t.efforts.length>0&&(0,G.jsxs)(fh,{value:n.effort??t.effort??void 0,onValueChange:e=>s(t.value,{...n,effort:e}),children:[(0,G.jsx)(mh,{size:`sm`,className:`w-28`,children:(0,G.jsx)(ph,{placeholder:`Effort`})}),(0,G.jsx)(hh,{children:t.efforts.map(e=>(0,G.jsx)(gh,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,G.jsx)(Mh,{size:`sm`,checked:!n.hidden,onCheckedChange:e=>s(t.value,{...n,hidden:!e}),"aria-label":`Show ${t.name}`})]},t.value)})]})}function GO(e){let[t,n]=(0,W.useState)(!1),[r,a]=(0,W.useState)(null);async function o(e){n(!0),a(null);try{await e()}catch(e){a(Ht(e))}finally{n(!1)}}return(0,G.jsxs)(G.Fragment,{children:[e.accounts.map(n=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:B(`min-w-0 flex-1`,!n.enabled&&`opacity-50`),children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:B(`size-2 shrink-0 rounded-full`,!n.enabled&&`bg-muted-foreground/40`,n.enabled&&n.error!==null&&`bg-destructive`,n.enabled&&n.error===null&&!n.linked&&`bg-warning`,n.enabled&&n.error===null&&n.linked&&`bg-success`)}),(0,G.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n.name}),n.plan!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:n.plan})]}),n.error!==null&&(0,G.jsx)(`p`,{className:`text-destructive mt-1 truncate pl-4 text-xs`,children:n.error}),n.error===null&&!n.linked&&(0,G.jsx)(`p`,{className:`text-warning mt-1 truncate pl-4 text-xs`,children:`Not linked to shared threads · hidden in the composer`}),n.error===null&&n.linked&&(0,G.jsx)(KO,{machine:e.machine,account:n})]}),(0,G.jsx)(Mh,{size:`sm`,checked:n.enabled,disabled:t,onCheckedChange:t=>void o(()=>L(e.machine,`accounts.update`,{id:n.id,name:n.name,color:n.color,configDir:n.configDir,enabled:t})),"aria-label":`Enable ${n.name}`}),(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost-muted`,title:`Open account`,onClick:()=>i({settingsAccount:n.id}),children:(0,G.jsx)(H,{icon:kn})})]},n.id)),(0,G.jsxs)(`button`,{type:`button`,className:`text-muted-foreground hover:bg-muted/50 hover:text-foreground flex w-full items-center gap-2 px-4 py-3 text-sm transition-colors`,onClick:()=>i({settingsAccount:`new`}),children:[(0,G.jsx)(H,{icon:Oo,className:`size-4`}),`Add account`]}),r!==null&&(0,G.jsx)(`p`,{className:`text-destructive px-4 py-3 text-xs`,children:r})]})}function KO(e){let t=ro(e.machine,e.account);return t===void 0||t.limits.length===0?null:(0,G.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-5 gap-y-1.5 pl-4`,children:t.limits.map(e=>(0,G.jsx)(qO,{limit:e},e.window))})}function qO(e){let t=e.limit,n=t.rejected?100:t.utilization===null?null:Math.min(100,Math.round(t.utilization*100));return n===null?null:(0,G.jsx)(Xr,{label:t.resetsAt===null?`Reset time unknown`:`Resets ${ar(t.resetsAt*1e3)}`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:Xm(t)}),(0,G.jsx)(`div`,{className:`bg-foreground/10 h-1 w-16 overflow-hidden rounded-full`,children:(0,G.jsx)(`div`,{className:B(`h-full rounded-full`,t.rejected&&`bg-destructive`,!t.rejected&&n>=80&&`bg-warning`,!t.rejected&&n<80&&`bg-foreground/50`),style:{width:`${n}%`}})}),(0,G.jsxs)(`span`,{className:B(`tabular-nums`,t.rejected&&`text-destructive`,!t.rejected&&`text-muted-foreground`),children:[n,`%`]})]})})}var JO=zt?`⌘`:`Ctrl+Shift`,YO=[[`Enter`,`Send, or queue or steer while the agent works`],[`${z}+Enter`,`Send the other way while the agent works`],[`Shift+Enter`,`New line`],[`↑`,`Recall your last message`],[`Esc`,`Stop the agent`],[`/`,`Slash commands`],[`@`,`Mention a file`],[`${z}+S`,`Stash the prompt, or bring back the last stash`],[`${z}+Shift+V`,`Paste long text inline instead of as a file`],[`${z}+Shift+D`,`Start or stop dictation`],[`${z}+. or ${z}+Shift+M`,`Choose the model`],[`${z}+/ or ${z}+Shift+E`,`Choose the effort`],[`${z}+P`,`Choose the project, or the sidebar scope`],[`${z}+;`,`Choose the project of a new thread`],[`${z}+F`,`Find in the thread`],[`${z}+K or ${z}+Shift+P`,`Search sessions and actions`],[`${z}+,`,`Open settings`],[`${z}+1…9`,`Open a session from the sidebar`],[`${z}+N or ${z}+T`,`New thread`],[zt?"⌘+` or Ctrl+`":"Ctrl+`",`Toggle the terminal`],[`${z}+B or ${z}+Shift+J`,`Toggle the sidebar`],[`${z}+J or ${z}+Shift+B`,`Toggle the right panel`],[`${z}+E`,`Toggle the editor`],[`${JO}+T`,`New terminal tab, in the terminal`],[`${JO}+W`,`Close the terminal tab`],[`${JO}+F`,`Find in the terminal`],[`Ctrl+Tab`,`Next terminal tab`],[`Ctrl+Shift+Tab`,`Previous terminal tab`]];function XO(){return(0,G.jsx)(Nh,{title:`Keyboard shortcuts`,children:YO.map(([e,t])=>(0,G.jsx)(Q,{label:t,children:(0,G.jsx)(`kbd`,{className:`bg-muted text-muted-foreground rounded px-1.5 py-0.5 font-sans text-xs`,children:e})},e))})}var ZO=Fe.withTag(`terminal`),QO=1048576;function $O(e){window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{ZO.warn(`could not copy to the clipboard`,e),ca(`Could not copy to the clipboard`)}):ZO.warn(`copy from the terminal needs https or localhost`)}async function ek(e){if(!window.isSecureContext){ZO.warn(`programs can read the clipboard only over https or localhost`),ca(`Programs can read the clipboard only over https or localhost`);return}let t;try{t=await navigator.clipboard.readText()}catch(e){ZO.warn(`could not read the clipboard`,e),ca(`Could not read the clipboard`);return}new TextEncoder().encode(t).length>QO?(ZO.warn(`the clipboard is over 1 MiB, not replying`),ca(`The clipboard is too large to share (over 1 MiB)`)):e(t)}var tk={macos:{label:`Ctrl+V`,ctrl:!0,alt:!1,data:``},linux:{label:`Ctrl+V`,ctrl:!0,alt:!1,data:``},windows:{label:`Alt+V`,ctrl:!1,alt:!0,data:`\x1Bv`}};function nk(e,t){let n=tk[t];return e.key.toLowerCase()===`v`&&e.ctrlKey===n.ctrl&&e.altKey===n.alt&&!e.shiftKey&&!e.metaKey}async function rk(e,t){let n=[];for(let e of await navigator.clipboard.read()){let t=e.types.find(e=>e.startsWith(`image/`));t&&n.push(await e.getType(t))}return n.length===0?(ca(`No image in the clipboard`),!1):(await ik(e,t,n),!0)}async function ik(e,t,n){let r=[];for(let t of n){let n=await L(e,`terminal.paste`,{type:t.type,data:await Af(t)});r.push(/\s/.test(n)?`"${n}"`:n)}t.paste(r.join(` `))}function ak(e){ZO.error(`could not paste image`,e),ca(`Could not paste the image`)}function ok(e){let t=e.prefs.terminal,[n,r]=(0,W.useState)(!zh.some(e=>e.family===t.font.family));function i(t){Ye({...e.prefs,terminal:t})}function a(e,n){i({...t,[e]:{...t[e],...n}})}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Nh,{title:`Font`,children:[(0,G.jsx)(Q,{label:`Family`,children:(0,G.jsxs)(fh,{value:n?`custom`:t.font.family,onValueChange:e=>{r(e===`custom`),e!==`custom`&&a(`font`,{family:e})},children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[zh.map(e=>(0,G.jsx)(gh,{value:e.family,children:e.label},e.family)),(0,G.jsx)(gh,{value:`custom`,children:`Custom`})]})]})}),n&&(0,G.jsx)(Q,{label:`Custom family`,children:(0,G.jsx)(Ph,{placeholder:`Installed font name`,value:t.font.family,onCommit:e=>a(`font`,{family:e})})}),(0,G.jsx)(Q,{label:`Size`,children:(0,G.jsx)(Fh,{value:t.font.size,step:.5,onCommit:e=>a(`font`,{size:e})})}),(0,G.jsx)(Q,{label:`Line height`,children:(0,G.jsx)(Fh,{value:t.font.lineHeight,step:.05,onCommit:e=>a(`font`,{lineHeight:e})})}),(0,G.jsx)(Q,{label:`Ligatures`,children:(0,G.jsx)(Mh,{checked:t.font.ligatures,onCheckedChange:e=>a(`font`,{ligatures:e})})}),(0,G.jsx)(Q,{label:`Bold text in bright colors`,children:(0,G.jsx)(Mh,{checked:t.boldIsBright,onCheckedChange:e=>i({...t,boldIsBright:e})})})]}),(0,G.jsxs)(Nh,{title:`Cursor`,children:[(0,G.jsx)(Q,{label:`Style`,children:(0,G.jsxs)(fh,{value:t.cursor.style,onValueChange:e=>a(`cursor`,{style:e}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`block`,children:`Block`}),(0,G.jsx)(gh,{value:`bar`,children:`Bar`}),(0,G.jsx)(gh,{value:`underline`,children:`Underline`})]})]})}),(0,G.jsx)(Q,{label:`Blink`,children:(0,G.jsx)(Mh,{checked:t.cursor.blink,onCheckedChange:e=>a(`cursor`,{blink:e})})})]}),(0,G.jsx)(sk,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,G.jsx)(ck,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,G.jsx)(lk,{behavior:t.behavior,onChange:e=>a(`behavior`,e)}),(0,G.jsxs)(Nh,{title:`Layout`,children:[[`top`,`right`,`bottom`,`left`].map(e=>(0,G.jsx)(Q,{label:`Padding ${e}`,children:(0,G.jsx)(Fh,{value:t.padding[e],onCommit:t=>a(`padding`,{[e]:t})})},e)),(0,G.jsx)(Q,{label:`Scrollback lines`,children:(0,G.jsx)(Fh,{value:t.scrollback,step:1e3,onCommit:e=>i({...t,scrollback:e})})})]})]})}function sk(e){return(0,G.jsxs)(Nh,{title:`Behavior`,children:[(0,G.jsx)(Q,{label:`Modernize Shift+Enter`,children:(0,G.jsx)(Mh,{checked:e.behavior.modernizeShiftEnter,onCheckedChange:t=>e.onChange({modernizeShiftEnter:t})})}),(0,G.jsx)(Q,{label:`${tk.linux.label} (${tk.windows.label} on Windows machines) pastes images from the browser clipboard`,children:(0,G.jsx)(Mh,{checked:e.behavior.pasteBrowserImages,onCheckedChange:t=>e.onChange({pasteBrowserImages:t})})}),(0,G.jsx)(Q,{label:`Capture browser shortcuts`,children:(0,G.jsx)(Mh,{checked:e.behavior.captureShortcuts,onCheckedChange:t=>e.onChange({captureShortcuts:t})})}),(0,G.jsx)(Q,{label:`Click moves the cursor in the command line`,children:(0,G.jsx)(Mh,{checked:e.behavior.clickToMoveCursor,onCheckedChange:t=>e.onChange({clickToMoveCursor:t})})}),(0,G.jsx)(Q,{label:`Ask before closing a tab that is running a program`,children:(0,G.jsx)(Mh,{checked:e.behavior.confirmCloseBusyTab,onCheckedChange:t=>e.onChange({confirmCloseBusyTab:t})})})]})}function ck(e){return zt?(0,G.jsx)(Nh,{title:`Mac keys`,note:`Meta keeps that Option key from typing @, | and other symbols. Safari and Firefox use US key positions`,children:(0,G.jsx)(Q,{label:`Use Option as Meta`,children:(0,G.jsxs)(fh,{value:e.behavior.optionAsMeta,onValueChange:t=>e.onChange({optionAsMeta:t}),children:[(0,G.jsx)(mh,{className:`w-56`,children:(0,G.jsx)(ph,{})}),(0,G.jsxs)(hh,{children:[(0,G.jsx)(gh,{value:`off`,children:`Off`}),(0,G.jsx)(gh,{value:`left`,children:`Left Option`}),(0,G.jsx)(gh,{value:`right`,children:`Right Option`}),(0,G.jsx)(gh,{value:`both`,children:`Both Options`})]})]})})}):null}function lk(e){return Lt?(0,G.jsx)(Nh,{title:`Windows keys`,note:`Ctrl+C sends an interrupt when nothing is selected. Ctrl+Shift+C and Ctrl+Shift+V always copy and paste`,children:(0,G.jsx)(Q,{label:`Ctrl+C copies the selection and Ctrl+V pastes`,children:(0,G.jsx)(Mh,{checked:e.behavior.windowsCopyPaste,onCheckedChange:t=>e.onChange({windowsCopyPaste:t})})})}):null}var uk=[`General`,`Editor`,`Terminal`,`Notifications`,`Shortcuts`,`Machines`],dk=[`Machine`,`Projects`,`Dictation`,`Claude`,`Codex`,`OpenCode`];function fk(){let e=k(e=>e.machines),t=k(e=>e.settingsMachine===null?null:Ge(e,e.settingsMachine)),n=k(e=>e.settingsPage),r=vk(n),i=k(e=>r===null?null:e.settingsAccount),a=k(e=>n===`Machines`?e.machines.find(t=>t.id===e.settingsEditedMachine)??null:null);return{machines:e,machine:t,config:t===null?null:t.config,system:t===null?null:t.system,page:n,provider:r,account:i,editedMachine:a,subpage:i!==null||a!==null,subpageTitle:i===`new`?`New account`:i===null?a?.name:[...t?.claudeAccounts??[],...t?.codexAccounts??[]].find(e=>e.id===i)?.name}}function pk(){let e=k(e=>e.settingsOpen);return vr(`mod+comma`,()=>p(!e),{enableOnFormTags:!0,preventDefault:!0}),(0,G.jsx)(oi,{open:e,onOpenChange:p,children:(0,G.jsx)($r,{showCloseButton:!1,"aria-describedby":void 0,className:`flex h-[min(44rem,calc(100dvh-2rem))] flex-col gap-0 overflow-hidden p-0 sm:max-w-4xl sm:flex-row`,children:(0,G.jsx)(mk,{})})})}function mk(){let e=fk(),t=e.page,n=e.machine;function r(e){return(0,G.jsx)(`button`,{className:B(`text-muted-foreground hover:bg-accent hover:text-foreground flex h-9 flex-none items-center rounded-md px-2 text-sm transition-colors`,e===t&&`bg-accent text-foreground`),onClick:()=>d(e),children:(0,G.jsx)(hk,{page:e})},e)}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`nav`,{className:`flex flex-none gap-1 overflow-x-auto border-b p-3 sm:w-48 sm:flex-col sm:border-r sm:border-b-0`,children:[(0,G.jsx)(ri,{className:`hidden px-2 pt-1 pb-3 text-base font-semibold sm:block`,children:`Settings`}),uk.map(r),(0,G.jsxs)(`div`,{className:`flex flex-none items-center gap-1 sm:mt-6 sm:flex-col sm:items-stretch`,children:[n!==null&&e.machines.length>1&&(0,G.jsxs)(fh,{value:n.id,onValueChange:e=>i({settingsMachine:e,settingsAccount:null}),children:[(0,G.jsx)(mh,{className:`mb-1 w-40 sm:w-full`,children:(0,G.jsx)(ph,{})}),(0,G.jsx)(hh,{children:e.machines.map(e=>(0,G.jsxs)(gh,{value:e.id,children:[(0,G.jsx)(Of,{icon:e.icon}),e.name]},e.id))})]}),n!==null&&e.machines.length===1&&(0,G.jsxs)(`p`,{className:`text-muted-foreground flex h-9 items-center gap-1.5 px-2 text-xs font-medium [&_svg]:size-4`,children:[(0,G.jsx)(Of,{icon:n.icon}),(0,G.jsx)(`span`,{className:`truncate`,children:n.name})]}),dk.map(r)]})]}),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pt-4 pb-7`,children:[(0,G.jsxs)(`div`,{className:`mb-5 flex h-9 items-center`,children:[e.subpage&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground text-xl font-semibold tracking-tight transition-colors`,onClick:()=>i({settingsAccount:null,settingsEditedMachine:null}),children:t}),(0,G.jsx)(H,{icon:kn,className:`text-muted-foreground mx-1.5 size-5`}),(0,G.jsx)(`h2`,{className:`truncate text-xl font-semibold tracking-tight`,children:e.subpageTitle})]}),!e.subpage&&(0,G.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight`,children:t===`Machine`?`General`:t}),(0,G.jsx)(gk,{view:e,className:`ml-3`}),(0,G.jsx)(ni,{asChild:!0,children:(0,G.jsx)(U,{variant:`ghost`,size:`icon`,className:`-mr-2 ml-auto`,"aria-label":`Close settings`,children:(0,G.jsx)(H,{icon:Go})})})]}),(0,G.jsx)(_k,{view:e})]})]})}function hk(e){let t=vk(e.page);return(0,G.jsxs)(G.Fragment,{children:[t!==null&&(0,G.jsx)(`span`,{className:`mr-2.5 flex size-4 items-center justify-center`,children:(0,G.jsx)(gc,{provider:t,className:B(t===`claude`&&`size-4`,t===`codex`&&`size-[19px] shrink-0`,t===`opencode`&&`h-3.5`)})}),e.page===`Machine`?`General`:e.page]})}function gk(e){let t=e.view.machine,n=e.view.config,r=e.view.provider;return r===null||e.view.account!==null||t===null||n===null?null:(0,G.jsx)(Mh,{className:e.className,checked:n.enabledProviders[r],onCheckedChange:e=>void po(t.id,{...n,enabledProviders:{...n.enabledProviders,[r]:e}}),"aria-label":`Enable ${e.view.page}`})}function _k(e){let t=k(e=>e.prefs),n=e.view.page,r=e.view.machine,i=e.view.config,a=e.view.system,o=dk.includes(n),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(0);return(0,G.jsxs)(G.Fragment,{children:[o&&r!==null&&r.configError!==null&&(0,G.jsxs)(`p`,{className:`text-destructive mb-5 text-sm whitespace-pre-wrap`,children:[`Not saved: `,r.configError]}),(0,G.jsxs)(`div`,{className:`w-full space-y-5`,children:[n===`General`&&(0,G.jsx)(qh,{prefs:t,onRestore:()=>c(`browser`)}),n===`Machine`&&r!==null&&i!==null&&a!==null&&(0,G.jsx)(fg,{machine:r.id,config:i,platform:a.platform,defaultShell:a.defaultShell,claudeAccounts:r.claudeAccounts,codexAccounts:r.codexAccounts,openCode:r.openCode,onRestore:()=>c(`machine`)}),n===`Dictation`&&r!==null&&i!==null&&(0,G.jsx)(Ih,{machine:r.id,config:i}),n===`Projects`&&r!==null&&a!==null&&(0,G.jsx)(zO,{machine:r.id,homeDir:a.homeDir}),o&&r===null&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Add a machine to see its settings.`}),o&&r!==null&&(i===null||a===null)&&(0,G.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[r.name,` is not connected. Its settings show up once it is.`]}),n===`Editor`&&(0,G.jsx)(Wh,{prefs:t}),n===`Terminal`&&(0,G.jsx)(ok,{prefs:t}),n===`Notifications`&&(0,G.jsx)(IO,{prefs:t}),e.view.provider!==null&&r!==null&&i!==null&&a!==null&&(0,G.jsx)(UO,{machine:r.id,config:i,platform:a.platform,defaultClaudeBaseDir:a.defaultClaudeBaseDir,provider:e.view.provider,claudeAccounts:r.claudeAccounts,codexAccounts:r.codexAccounts,openCode:r.openCode,selected:e.view.account},e.view.provider),n===`Machines`&&(0,G.jsx)(jO,{}),n===`Shortcuts`&&(0,G.jsx)(XO,{})]},l),(0,G.jsx)(mr,{open:s!==null,onOpenChange:e=>{e||c(null)},children:(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:s===`browser`?`Restore browser defaults?`:`Restore machine defaults?`}),(0,G.jsx)(Rn,{children:s===`browser`?`All settings of this browser go back to their defaults.`:`All settings of ${r?.name} go back to their defaults.`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>{if(u(l+1),s===`browser`)Ye(x);else{if(r===null||i===null||a===null)throw Error(`Restoring machine defaults needs a connected machine`);po(r.id,{...a.defaults,claudeAccounts:i.claudeAccounts,codexAccounts:i.codexAccounts})}},children:`Restore defaults`})]})]})})]})}function vk(e){return e===`Claude`?`claude`:e===`Codex`?`codex`:e===`OpenCode`?`opencode`:null}function yk(){let e=k(e=>e.settingsOpen);return(0,G.jsx)(ai,{open:e,onOpenChange:p,children:(0,G.jsx)(li,{children:(0,G.jsx)(ti,{"aria-describedby":void 0,className:`bg-background text-foreground data-open:animate-in data-open:slide-in-from-right fixed inset-0 z-50 flex flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] text-sm duration-200 outline-none motion-reduce:animate-none`,children:(0,G.jsx)(bk,{})})})})}function bk(){let e=k(e=>e.settingsListing),t=fk(),n=t.machine;M(!0,r);function r(){e?p(!1):t.subpage?i({settingsAccount:null,settingsEditedMachine:null}):i({settingsListing:!0})}function a(e){return(0,G.jsxs)(`button`,{className:`active:bg-accent flex min-h-12 w-full items-center px-4 text-left text-sm font-medium`,onClick:()=>d(e),children:[(0,G.jsx)(hk,{page:e}),(0,G.jsx)(H,{icon:kn,className:`text-muted-foreground ml-auto size-4`})]},e)}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`header`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-1.5 px-2`,children:[(0,G.jsx)(U,{variant:`ghost`,size:`icon`,"aria-label":`Back`,onClick:r,children:(0,G.jsx)(H,{icon:Br,className:`text-foreground size-5`,strokeWidth:2})}),(0,G.jsxs)(di,{className:`min-w-0 flex-1 truncate font-medium`,children:[e&&`Settings`,!e&&t.subpage&&t.subpageTitle,!e&&!t.subpage&&t.page]}),!e&&(0,G.jsx)(gk,{view:t,className:`shrink-0`})]}),(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pt-2 pb-6`,children:[e&&(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsx)(Nh,{title:`This browser`,children:uk.map(a)}),(0,G.jsxs)(Nh,{title:`Machine`,children:[n!==null&&(0,G.jsxs)(Q,{label:`Machine`,children:[t.machines.length>1&&(0,G.jsxs)(fh,{value:n.id,onValueChange:e=>i({settingsMachine:e,settingsAccount:null}),children:[(0,G.jsx)(mh,{className:`w-40`,children:(0,G.jsx)(ph,{})}),(0,G.jsx)(hh,{children:t.machines.map(e=>(0,G.jsxs)(gh,{value:e.id,children:[(0,G.jsx)(Of,{icon:e.icon}),e.name]},e.id))})]}),t.machines.length===1&&(0,G.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1.5 text-sm [&_svg]:size-4`,children:[(0,G.jsx)(Of,{icon:n.icon}),n.name]})]}),dk.map(a)]})]}),!e&&(0,G.jsx)(_k,{view:t})]})]})}function xk(){return(0,G.jsx)(`div`,{className:`grid flex-1 place-items-center p-6`,children:(0,G.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,G.jsx)(`h1`,{className:`text-foreground text-center text-2xl font-normal tracking-tight sm:text-3xl`,children:`Connect a machine`}),(0,G.jsx)(`p`,{className:`text-muted-foreground mt-2 text-center text-sm`,children:`Run this on the computer you want to use, then open the pairing link it prints.`}),(0,G.jsx)(`pre`,{className:`bg-muted text-foreground mt-5 rounded-lg px-4 py-3 font-mono text-sm select-all`,children:`npx offsite serve`}),(0,G.jsx)(`p`,{className:`text-muted-foreground mt-8 mb-3 text-sm`,children:`Or connect it here.`}),(0,G.jsx)(EO,{actions:e=>(0,G.jsx)(U,{type:`submit`,className:`mt-4`,disabled:!e,children:`Connect`})})]})})}var Sk=[`messages`,`steps`,`details`,`full`],Ck={messages:`Messages`,steps:`Steps`,details:`Details`,full:`Everything`},wk=[{label:`Messages, plans and answers`,how:{messages:`Full text`,steps:`Full text`,details:`Full text`,full:`Full text`}},{label:`Commands`,how:{messages:null,steps:`One line each`,details:`Full command`,full:`Command and output`}},{label:`File edits`,how:{messages:null,steps:`File path`,details:`Path and diff`,full:`Diff and output`}},{label:`Tools, skills and web searches`,how:{messages:null,steps:`Name only`,details:`Inputs and search results`,full:`Inputs and outputs`}},{label:`Subagents and notices`,how:{messages:null,steps:`One line each`,details:`With compaction summaries`,full:`With compaction summaries`}},{label:`Thinking`,how:{messages:null,steps:null,details:`Full text`,full:`Full text`}},{label:`Todo lists`,how:{messages:null,steps:null,details:`Every step`,full:`Every step`}}];function Tk(e){let t=e.session,n=nn(),[r,i]=(0,W.useState)(`steps`),[a,o]=(0,W.useState)(null);(0,W.useEffect)(()=>{L(t.machine,`sessions.export`,{sessionId:t.id,projectId:t.projectId}).then(o).catch(e=>{c(e),Et(null)})},[t.machine,t.id,t.projectId]);function s(e){let n=t.title.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);wn(new Blob([e],{type:`text/markdown;charset=utf-8`}),`${n===``?`chat`:n}.md`),Et(null)}return(0,G.jsx)(oi,{open:!0,onOpenChange:()=>Et(null),children:(0,G.jsxs)($r,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,"aria-describedby":void 0,children:[(0,G.jsx)(ei,{className:`gap-1 px-6 pt-4 pr-12`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ri,{className:`text-base`,children:`Export to Markdown`}),a!==null&&a.context!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground rounded-full border px-2 py-0.5 text-xs tabular-nums`,children:Cn(a.context.tokens)})]})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-6 pt-5 pb-6`,children:[(0,G.jsxs)(mu,{className:`relative flex h-5 w-full touch-none items-center select-none`,min:0,max:Sk.length-1,step:1,value:[Sk.indexOf(r)],onValueChange:e=>i(Sk[e[0]]),children:[(0,G.jsx)(xu,{className:`bg-muted relative h-1.5 grow overflow-hidden rounded-full`,children:(0,G.jsx)(Cu,{className:`bg-primary absolute h-full`})}),(0,G.jsx)(Au,{"aria-label":`Detail`,className:`border-primary bg-background ring-ring/50 block size-4 rounded-full border-2 shadow-sm transition-shadow hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden`})]}),(0,G.jsx)(`div`,{className:`relative h-8 text-xs`,children:Sk.map((e,t)=>(0,G.jsxs)(`button`,{type:`button`,className:B(`text-muted-foreground hover:text-foreground absolute top-0 flex cursor-pointer flex-col`,t===0&&`left-0 items-start`,t>0&&t<Sk.length-1&&`-translate-x-1/2 items-center`,t===Sk.length-1&&`right-0 items-end`,e===r&&`text-foreground font-medium`),style:t>0&&t<Sk.length-1?{left:`calc(8px + (100% - 16px) * ${t/(Sk.length-1)})`}:void 0,onClick:()=>i(e),children:[(0,G.jsx)(`span`,{children:Ck[e]}),(0,G.jsx)(`span`,{className:`text-muted-foreground/70 font-normal tabular-nums`,children:a===null?`…`:`~${Cn(Ek(a.markdown[e]))}`})]},e))}),(0,G.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1.5`,children:wk.map(e=>(0,G.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(H,{icon:e.how[r]===null?Gr:nr,className:B(`size-4 shrink-0`,e.how[r]===null&&`text-muted-foreground/50`,e.how[r]!==null&&`text-primary`),strokeWidth:2}),(0,G.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate`,e.how[r]===null&&`text-muted-foreground/60`,e.how[r]!==null&&`text-foreground`),children:e.label}),(0,G.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:e.how[r]??`Not included`})]},e.label))})]}),(0,G.jsxs)(si,{className:`bg-muted/40 border-t px-6 py-4 sm:justify-between`,children:[(0,G.jsx)(U,{type:`button`,variant:`ghost`,onClick:()=>Et(null),children:`Cancel`}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(U,{type:`button`,variant:`outline`,disabled:a===null||n.copied,onClick:()=>{a!==null&&n.copy(a.markdown[r])},children:[(0,G.jsx)(H,{icon:n.copied?Un:Qn}),n.copied?`Copied`:`Copy`]}),(0,G.jsxs)(U,{type:`button`,disabled:a===null,onClick:()=>{a!==null&&s(a.markdown[r])},children:[(0,G.jsx)(H,{icon:er}),`Export`]})]})]})]})})}function Ek(e){return Math.round(e.length/4)}var Dk=.5,Ok=.8,kk=.6,Ak=.45,jk=.3,Mk=.25,Nk=.25,Pk=4,Fk=new Set([`a`,`an`,`and`,`for`,`in`,`of`,`on`,`the`,`to`,`with`]),Ik=/[\p{L}\p{N}]/u,Lk=/\p{Ll}/u,Rk=/\p{Lu}/u,zk=/\p{N}/u,Bk=/\p{L}/u;function Vk(e){return e.replace(/[\u0080-]/g,e=>{let t=e.normalize(`NFKD`).replace(/\p{M}/gu,``).toLowerCase();return t.length===1?t:e}).toLowerCase()}function Hk(e){let t=/^"([^"]+)"$/.exec(e.trim())?.[1].trim();return t===void 0||t===``?null:t}function Uk(e){let t=Hk(e);return t===null?Vk(e).replace(/^["'`]+|["'`]+$/g,``).split(/\s+/).filter(Boolean):[Vk(t)]}function Wk(e){return Uk(e).some(e=>e.length>=3)}function Gk(e,t){let n=e[t],r=e[t-1]??``,i=e[t+1]??``;return Ik.test(n)&&(r===``||!Ik.test(r)||Lk.test(r)&&Rk.test(n)||Rk.test(r)&&Rk.test(n)&&Lk.test(i)||zk.test(r)!==zk.test(n))}function Kk(e,t){return t>=e.length||!Ik.test(e[t])||Gk(e,t)}function qk(e,t){let n=t+1;for(;n<e.length&&Ik.test(e[n])&&!Gk(e,n);)n+=1;return n}function Jk(e){return Array.from({length:e.length},(e,t)=>t).filter(t=>Gk(e,t))}function Yk(e,t,n){let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];)r+=1;let i=e.slice(r),a=t.slice(r),o=i.length>1&&i[0]===a[1]&&i[1]===a[0]&&i.slice(2)===a.slice(2);return n?o:o||i===a||i.slice(1)===a.slice(1)||i.slice(1)===a||i===a.slice(1)}function Xk(e,t,n){for(let r of Jk(e)){if(t[r]!==n[0])continue;let i=[],a=r,o=n;for(;o!==``&&a<t.length;){let n=qk(e,a);if(o.length<=n-a&&t.startsWith(o,a))i.push({start:a,end:a+o.length}),o=``;else if(o.startsWith(t.slice(a,n)))for(i.push({start:a,end:n}),o=o.slice(n-a),a=n;a<t.length&&!Gk(e,a);)a+=1;else break}if(o===``&&i.length>1)return{score:kk,start:r,end:i[i.length-1].end,pieces:i}}return null}function Zk(e,t,n){if(n.length<3||!Bk.test(n))return null;let r=n.length<=Pk;for(let i of Jk(e)){if(!(t[i]===n[0]||!r&&t[i]===n[1]&&t[i+1]===n[0]))continue;let e=i+1;for(;e<t.length&&Ik.test(t[e]);)e+=1;let a=r?[n.length,n.length+1]:[n.length,n.length-1,n.length+1];for(let o of a)if(!(o>e-i)&&Yk(n,t.slice(i,i+o),r&&o===n.length)){let e={start:i,end:i+o};return{score:Ak,...e,pieces:[e]}}}return null}function Qk(e,t,n){let r=e.source,i=e.folded,a=null;for(let n=i.indexOf(t);n!==-1;n=i.indexOf(t,n+1)){let i={start:n,end:n+t.length};if(Gk(r,n)){let e=Kk(r,i.end)?1:Ok;if((a===null||e>a.score)&&(a={score:e,...i,pieces:[i]}),e===1)return a}else e.midWord&&t.length>=Pk&&a===null&&(a={score:jk,...i,pieces:[i]})}if(a!==null&&a.score>jk)return a;let o=n.primary?Xk(r,i,t):null;return o===null?n.typos?Zk(r,i,t)??a:a:o}function $k(e){let t=[];for(let n of[...e].sort((e,t)=>e.start-t.start)){let e=t.at(-1);e!==void 0&&n.start<=e.end?e.end=Math.max(e.end,n.end):t.push({...n})}return t}function eA(e,t){let n=[];for(let r=e.indexOf(t);r!==-1;r=e.indexOf(t,r+1)){let i=r+t.length,a=Ik.test(t[0])&&Ik.test(e[r-1]??``),o=Ik.test(t[t.length-1])&&Ik.test(e[i]??``);!a&&!o&&n.push({start:r,end:i})}return $k(n)}function tA(e,t){let n=eA(e.folded,t);return n.length===0?null:{score:1,...n[0],pieces:n}}function nA(e,t,n){let r=Uk(e);if(r.length===0)return null;let i=Hk(e)!==null,a=t.filter(e=>e.value!==``).map(e=>({...e,source:e.value,folded:Vk(e.value)})),o=r.some(e=>!Fk.has(e)),s=[],c=0,l=0,u=!0;for(let e of r){let t=0,r=!1;for(let[o,c]of a.entries()){let a=i?tA(c,e):Qk(c,e,{primary:o===0,typos:n});a!==null&&(o===0&&s.push(...a.pieces),a.score>=Ok&&c.weight>Nk&&(r=!0),t=Math.max(t,a.score*c.weight))}if(t===0){if(o&&Fk.has(e))continue;return null}u&&=r,c+=t,l+=1}let d=a.at(0)?.folded??``,f=r.join(` `),p=d===f?Dk:r.length>1&&d.includes(f)?Mk:0;return{quality:c/l+p,strong:u,ranges:$k(s)}}function rA(e,t){let n=Vk(t);return Hk(e)===null?$k(Uk(e).filter(e=>e.length>=3).flatMap(e=>{let t=[];for(let r=n.indexOf(e);r!==-1;r=n.indexOf(e,r+e.length))t.push({start:r,end:r+e.length});return t})):eA(n,Uk(e)[0])}var iA=.6,aA=.25,oA=.6,sA=8,cA=3,lA=18144e5,uA=32,dA=12096e5,fA=2.5;function pA(e){return 2**(-Math.max(0,e)/dA)}function mA(e,t){let n=pA(t-e.updatedAt),r=e.opens===null?0:e.opens.score*pA(t-e.opens.openedAt);return Math.min(fA,1+n+.5*Math.log2(1+r))}function hA(e){return Uk(e).join(` `).slice(0,uA).trim()}function gA(e,t,n){let r=hA(t),i=(e.opens?.picks??[]).filter(e=>n-e.at<=lA&&(e.query===r||r.length>=cA&&e.query.startsWith(r)));return Math.max(0,...i.map(e=>e.at))}function _A(e,t,n){let r=nA(t,[{value:e.title,weight:1,midWord:!0},{value:e.branch??``,weight:oA,midWord:!1},{value:e.projectName??``,weight:aA,midWord:!1},{value:e.machineName??``,weight:aA,midWord:!1}],n);if(r!==null)return r;let i=t.trim().toLowerCase();return i.length>=sA&&e.id.toLowerCase().includes(i)?{quality:iA,strong:!0,ranges:[]}:null}function vA(e){return e>=1.5?3:e>=.7?2:+(e>=.4)}function yA(e,t,n,r){function i(i){return e.flatMap(e=>{let a=t(e),o=_A(a,n,i);return o===null?[]:[{item:e,match:o,picked:gA(a,n,r),score:o.quality*mA(a,r)}]})}let a=i(!1);return[...a.some(e=>e.match.strong)?a:i(!0)].sort((e,t)=>vA(t.match.quality)-vA(e.match.quality)||t.picked-e.picked||t.score-e.score).map(e=>({item:e.item,ranges:e.match.ranges}))}function bA(e){return Math.max(e.updatedAt,e.opens?.openedAt??0)}function xA(e,t,n){return nA(e,[{value:t,weight:1,midWord:!0},{value:n,weight:oA,midWord:!1}],!1)}function SA(e,t,n,r){return e.flatMap(e=>{let n=t(e);return n===void 0?[]:[{match:e,subject:n}]}).sort((e,t)=>CA(e.match,t.match)||gA(t.subject,n,r)-gA(e.subject,n,r)||mA(t.subject,r)-mA(e.subject,r)).map(e=>e.match)}function CA(e,t){return t.quality-e.quality||Number(t.author===`user`)-Number(e.author===`user`)}function wA(e){let t=k(e=>e.machines);return(0,G.jsxs)(pn,{value:e.scope,onValueChange:e.onScope,children:[(0,G.jsx)(Mn,{value:`all`,children:`All machines`}),t.map(e=>(0,G.jsxs)(Mn,{value:e.id,disabled:e.status!==`online`,children:[(0,G.jsx)(Of,{icon:e.icon,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:TA(e)})]},e.id))]})}function TA(e){return e.status===`online`?e.name:e.status===`unpaired`?`${e.name} · needs pairing`:`${e.name} · offline`}function EA(e,t,n){let r=k(e=>e.machines),[i,a]=(0,W.useState)([]),[o,s]=(0,W.useState)([]),c=r.filter(e=>e.status===`online`).map(e=>e.id).join(` `),l=r.filter(e=>n===`all`||e.id===n),u=l.filter(e=>e.status===`online`).map(e=>e.id).join(` `);(0,W.useEffect)(()=>{let e=!0;for(let t of R().machines.filter(e=>e.status===`online`))L(t.id,`sessions.searchable`,void 0).then(n=>{e&&a(e=>DA(e,{machine:t.id,sessions:n.sessions.map(e=>({...e,machine:t.id})),failed:OA(n.failed)}))}).catch(()=>{e&&a(e=>DA(e,{machine:t.id,sessions:[],failed:[t.name]}))});return()=>{e=!1}},[c]),(0,W.useEffect)(()=>{if(t.startsWith(`>`)||!Wk(t))return;let e=!0;for(let n of R().machines.filter(e=>e.status===`online`))L(n.id,`sessions.searchMessages`,{query:t}).then(r=>{e&&s(e=>DA(e,{machine:n.id,query:t,matches:r.matches.map(e=>({...e,machine:n.id})),failed:OA(r.failed)}))}).catch(()=>{e&&s(e=>DA(e,{machine:n.id,query:t,matches:[],failed:[n.name]}))});return()=>{e=!1}},[t,c]);let d=o.filter(t=>u.split(` `).includes(t.machine)&&t.query===e);return{threadResults:i,reachable:u,messages:d.flatMap(e=>e.matches),searching:!e.startsWith(`>`)&&Wk(e)&&l.some(e=>e.status===`online`&&!d.some(t=>t.machine===e.id)),failures:[...new Set([...l.filter(e=>e.status!==`online`).map(e=>e.name),...i.filter(e=>u.split(` `).includes(e.machine)).flatMap(e=>e.failed),...d.flatMap(e=>e.failed)])]}}function DA(e,t){return[...e.filter(e=>e.machine!==t.machine),t]}function OA(e){return e.map(e=>rr[e])}var kA=20,AA=12,jA=10;function MA(){let e=k(e=>e.paletteOpen);return(0,G.jsx)(oi,{open:e,onOpenChange:ue,children:(0,G.jsxs)($r,{showCloseButton:!1,className:`top-[20%] translate-y-0 gap-0 overflow-hidden p-0 sm:max-w-xl`,children:[(0,G.jsx)(ri,{className:`sr-only`,children:`Search threads`}),(0,G.jsx)(NA,{})]})})}function NA(){let e=k(e=>e.selection),t=k(e=>e.machines),n=k(e=>e.projects),[r,i]=(0,W.useState)(``),[a]=Lr(r,300),[o,s]=(0,W.useState)(`all`),[c,l]=(0,W.useState)(null),[u]=(0,W.useState)(()=>Date.now()),f=(0,W.useRef)(null),m=(0,W.useRef)(null),h=r.startsWith(`>`),g=h?r.slice(1):r,_=EA(r,a,o),v=_.threadResults,y=_.reachable,b=t.find(e=>e.id===o),x=(0,W.useMemo)(()=>v.filter(e=>y.split(` `).includes(e.machine)).flatMap(e=>e.sessions).map(e=>({thread:e,subject:IA(e,t,n)})),[v,y,t,n]),S=new Map(x.map(e=>[P(e.thread.machine,e.thread.id),e.subject])),C=(0,W.useMemo)(()=>g.trim()===``?[]:yA(x,e=>e.subject,g,u).slice(0,kA).map(e=>({item:e.item.thread,ranges:e.ranges})),[x,g,u]),w=(0,W.useMemo)(()=>[...x].sort((e,t)=>bA(t.subject)-bA(e.subject)).slice(0,AA).map(e=>({item:e.thread,ranges:[]})),[x]),T=g.trim()===``?w:C,E=[...e===null?[]:[{key:`new`,label:`New thread`,place:{machine:e.machine,projectId:e.projectId},detail:RA(e.machine,e.projectId,n),run:()=>we(e.machine,e.projectId)}],{key:`accounts`,label:`Manage accounts`,detail:``,place:null,run:()=>d(Se[R().settings.provider])},{key:`settings`,label:`Settings`,detail:`Theme, notifications, keyboard shortcuts`,place:null,run:()=>p(!0)}].flatMap(e=>{let t={...e,section:`Actions`,labelRanges:[],detailRanges:[],branch:``,updatedAt:null};if(g.trim()===``)return[t];let n=xA(g,e.label,e.detail);return n===null?[]:[{...t,labelRanges:n.ranges}]}),D=new Set(C.map(e=>P(e.item.machine,e.item.id))),O=h?[]:T.map(e=>{let t=e.item,r=g.trim()!==``&&t.branch!==null?` | ${t.branch}`:``;return{key:P(t.machine,t.id),section:g.trim()===``?`Recent`:`Threads`,label:t.title,labelRanges:e.ranges,detail:LA(t,n),detailRanges:[],branch:r,updatedAt:t.updatedAt,place:{machine:t.machine,projectId:t.projectId},run:()=>Ie({machine:t.machine,projectId:t.projectId,sessionId:t.id},g.trim()===``?null:g)}}),A=h?[]:SA(_.messages.filter(e=>!D.has(P(e.machine,e.sessionId))),e=>S.get(P(e.machine,e.sessionId)),g,u).slice(0,jA).flatMap(e=>{let t=x.find(t=>t.thread.machine===e.machine&&t.thread.id===e.sessionId)?.thread;if(t===void 0)return[];let n=`${e.author===`user`?`You: `:``}${e.snippet}`;return[{key:`message:${P(e.machine,e.sessionId)}`,section:`In messages`,label:t.title,labelRanges:[],detail:n,detailRanges:rA(g,n),branch:``,updatedAt:t.updatedAt,place:{machine:t.machine,projectId:t.projectId},run:()=>Ie({machine:t.machine,projectId:t.projectId,sessionId:t.id},g)}]}),j=[...E,...O,...A],M=Math.min(Math.max(0,j.findIndex(e=>e.key===c)),j.length-1);(0,W.useLayoutEffect)(()=>{f.current?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})},[M]);function N(e){ue(!1),e.run()}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 border-b pr-2.5`,children:[(0,G.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 pl-4`,children:[(0,G.jsx)(H,{icon:br,className:`text-muted-foreground size-4 shrink-0`}),(0,G.jsx)(`input`,{ref:m,value:r,onChange:e=>{i(e.target.value),l(null)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;j.length>0&&l(j[(M+t+j.length)%j.length].key)}e.key===`Enter`&&M>=0&&(e.preventDefault(),N(j[M]))},placeholder:`Search threads and actions…`,className:`placeholder:text-placeholder/75 h-11 w-full bg-transparent text-sm outline-none`})]}),t.length>1&&(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:`text-secondary-label hover:bg-accent data-[state=open]:bg-accent flex h-7 max-w-40 shrink-0 cursor-pointer items-center gap-1.5 rounded-[var(--control-radius)] px-1.5 text-xs`,children:[b!==void 0&&(0,G.jsx)(Of,{icon:b.icon,className:`size-3 shrink-0`}),(0,G.jsx)(`span`,{className:`truncate`,children:b?.name??`All machines`}),(0,G.jsx)(H,{icon:Rr,className:`size-3 shrink-0`})]})}),(0,G.jsx)(Dn,{align:`end`,className:`w-56`,onCloseAutoFocus:e=>{e.preventDefault(),m.current?.focus()},children:(0,G.jsx)(wA,{scope:o,onScope:e=>{s(e),l(null)}})})]})]}),(0,G.jsxs)(`div`,{ref:f,className:`max-h-96 overflow-y-auto p-1`,children:[j.length===0&&!_.searching&&(0,G.jsx)(`p`,{className:`text-muted-foreground px-3 py-6 text-center text-xs`,children:`Nothing matches.`}),j.map((e,n)=>(0,G.jsxs)(`div`,{children:[e.section!==j[n-1]?.section&&(0,G.jsx)(`p`,{className:`text-secondary-label px-2.5 pt-2 pb-1 text-xs`,children:e.section}),(0,G.jsxs)(`button`,{"data-active":n===M,className:B(`flex w-full cursor-pointer flex-col rounded-lg px-2.5 py-1.5 text-left`,n===M&&`bg-accent`),onMouseMove:()=>l(e.key),onClick:()=>N(e),children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[e.place!==null&&(0,G.jsx)(mc,{machine:e.place.machine,projectId:e.place.projectId,className:`size-3.5 shrink-0 grayscale`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,G.jsx)(FA,{text:e.label,ranges:e.labelRanges})})]}),e.detail!==``&&(0,G.jsxs)(`span`,{className:`text-secondary-label flex min-w-0 items-center gap-1.5 text-xs`,children:[e.place!==null&&t.length>1&&(0,G.jsx)(PA,{id:e.place.machine,machines:t}),(0,G.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,G.jsx)(FA,{text:e.detail,ranges:e.detailRanges}),(0,G.jsx)(`span`,{className:`text-muted-foreground/40`,children:e.branch})]}),e.updatedAt!==null&&(0,G.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 tabular-nums`,children:yn(e.updatedAt)})]})]})]},e.key)),_.searching&&(0,G.jsx)(`p`,{className:`text-muted-foreground px-2.5 py-2 text-xs`,children:`Searching messages…`})]}),_.failures.length>0&&(0,G.jsxs)(`p`,{className:`text-muted-foreground border-t px-4 py-2 text-xs`,children:[`Couldn't search `,_.failures.join(`, `)]})]})}function PA(e){let t=e.machines.find(t=>t.id===e.id);return(0,G.jsx)(Of,{icon:t?.icon??null,className:`size-3 shrink-0`})}function FA(e){return(0,G.jsxs)(G.Fragment,{children:[e.ranges.map((t,n)=>(0,G.jsxs)(W.Fragment,{children:[e.text.slice(e.ranges[n-1]?.end??0,t.start),(0,G.jsx)(`mark`,{className:`text-foreground bg-transparent font-medium`,children:e.text.slice(t.start,t.end)})]},t.start)),e.text.slice(e.ranges.at(-1)?.end??0)]})}function IA(e,t,n){return{id:e.id,title:e.title,branch:e.branch,projectName:n.find(t=>t.machine===e.machine&&t.id===e.projectId)?.name??null,machineName:t.length>1?t.find(t=>t.id===e.machine)?.name??null:null,updatedAt:e.updatedAt,opens:e.opens}}function LA(e,t){return`${e.status===`minimized`?`Minimized · `:``}${RA(e.machine,e.projectId,t)}`}function RA(e,t,n){return t===`no-project`?`Chat`:n.find(n=>n.machine===e&&n.id===t)?.name??``}function zA(e){let t=e.session,[n,r]=(0,W.useState)(!1),i=k(e=>e.generatingTitles.includes(P(t.machine,t.id))),a=k(e=>He(e,t.machine,t.projectId)?.scratch===!0),o=e.context?Bn:Mr,s=e.context?Wn:Pn;return(0,G.jsxs)(G.Fragment,{children:[t.status!==`active`&&(0,G.jsxs)(o,{onSelect:()=>void Je(t.machine,t.id,{status:`active`}),children:[(0,G.jsx)(H,{icon:t.status===`pinned`?Fs:Ls}),t.status===`pinned`?`Unpin`:`Activate`]}),t.status!==`inactive`&&(0,G.jsxs)(o,{onSelect:e.onDeactivate,children:[(0,G.jsx)(H,{icon:nc}),`Done`]}),t.status!==`snoozed`&&(0,G.jsxs)(o,{onSelect:()=>void Je(t.machine,t.id,{status:`snoozed`}),children:[(0,G.jsx)(H,{icon:sc}),`Snooze`]}),t.status!==`minimized`&&(0,G.jsxs)(o,{onSelect:()=>void Je(t.machine,t.id,{status:`minimized`}),children:[(0,G.jsx)(H,{icon:As}),`Minimize`]}),t.status!==`pinned`&&(0,G.jsxs)(o,{onSelect:()=>void Je(t.machine,t.id,{status:`pinned`}),children:[(0,G.jsx)(H,{icon:Is}),`Pin`]}),(0,G.jsx)(s,{}),(0,G.jsxs)(o,{disabled:i,onSelect:()=>void lt(t),children:[(0,G.jsx)(H,{icon:ko}),`Refresh title`]}),(0,G.jsxs)(o,{onSelect:e.onRename,children:[(0,G.jsx)(H,{icon:Ps}),`Rename`]}),(0,G.jsxs)(o,{onSelect:()=>Et(t),children:[(0,G.jsx)(H,{icon:er}),`Export`]}),a&&(0,G.jsxs)(o,{onSelect:()=>uc(t.machine,t.projectId,{scratch:!1,name:t.title}).catch(c),children:[(0,G.jsx)(H,{icon:hr}),`Turn into project`]}),(0,G.jsxs)(o,{variant:`destructive`,title:`Also removes it from ${rr[t.provider]}`,onSelect:e=>{n?nt(t.machine,t.id,t.projectId):(e.preventDefault(),r(!0))},children:[(0,G.jsx)(H,{icon:is}),n?e.mobile?`Tap again to delete`:`Click again to delete`:`Delete`]})]})}function BA(e){return e.activity?.approval===!0&&e.activity?.question===!0?(0,G.jsx)(`span`,{title:`Waiting for approval and an answer`,className:`text-question flex`,children:(0,G.jsx)(H,{icon:qs,className:`size-4 shrink-0`})}):e.activity?.approval===!0?(0,G.jsx)(`span`,{title:`Waiting for approval`,className:`text-question flex`,children:(0,G.jsx)(H,{icon:Ws,className:`size-4 shrink-0`})}):e.activity?.question===!0?(0,G.jsx)(`span`,{title:`Waiting for an answer`,className:`text-question flex`,children:(0,G.jsx)(H,{icon:Vo,className:`size-4 shrink-0`})}):e.activity?.running===!0?(0,G.jsx)(`span`,{title:`Working`,className:`text-info flex`,children:(0,G.jsx)(H,{icon:Qo,className:`size-4 shrink-0 animate-spin`})}):e.backgroundRunning?e.activity?.backgroundAgent===!0?(0,G.jsx)(`span`,{title:`Agent running in background`,className:`text-info flex`,children:(0,G.jsx)(H,{icon:jr,className:`size-4 shrink-0 animate-spin`})}):(0,G.jsx)(`span`,{title:`Task running in background`,className:`text-muted-foreground flex`,children:(0,G.jsx)(H,{icon:jr,className:`size-4 shrink-0 animate-spin`})}):e.done?(0,G.jsx)(`span`,{title:`Done`,className:`text-success flex`,children:(0,G.jsx)(H,{icon:Yo,className:`size-4 shrink-0`})}):null}function VA(e){let t=k(t=>t.generatingTitles.includes(P(e.session.machine,e.session.id)));return(0,G.jsx)(`span`,{className:B((t||e.awaitingTitle)&&`text-shimmer`),children:e.session.title})}var HA=`group/sidebar-row relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,UA=(0,W.memo)(WA);function WA(e){let t=e.session,n=cc(t.machine,t.projectId),r=k(e=>Ge(e,t.machine).icon),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),c=(0,W.useRef)(null),l=e.activity?.waiting===!0,u=Object.values(e.activity?.tasks??{}).includes(`running`),d=!l&&(e.activity?.running===!0||u),f=e.activity?.running===!0||u,p=!l&&!d&&e.unseen,m=!e.selected&&!l&&!p;function h(){pt(t.machine,t.id,e.scope)}function g(){f?s(!0):h()}let _=(0,G.jsx)(mr,{open:o,onOpenChange:s,children:(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:`Stop running work?`}),(0,G.jsx)(Rn,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:h,children:`Stop and Mark Done`})]})]})}),v=e.saved&&(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Thread actions`,onClick:e=>e.stopPropagation(),children:(0,G.jsx)(H,{icon:os,className:`size-3.5`})})}),(0,G.jsx)(Dn,{align:`end`,className:`w-44`,onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>{c.current!==null&&(e.preventDefault(),c.current.focus(),c.current.select())},children:(0,G.jsx)(zA,{session:t,context:!1,mobile:!1,onDeactivate:g,onRename:()=>a(t.title)})})]}),y=(0,G.jsx)(tr,{className:`w-44`,onCloseAutoFocus:e=>{c.current!==null&&(e.preventDefault(),c.current.focus(),c.current.select())},children:(0,G.jsx)(zA,{session:t,context:!0,mobile:!1,onDeactivate:g,onRename:()=>a(t.title)})}),b=i===null?(0,G.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate text-sm`,m?`text-secondary-label font-normal`:`font-medium`,!m&&(e.unseen||l)&&`text-foreground`,!m&&!e.unseen&&!l&&`text-foreground/90`),children:(0,G.jsx)(VA,{session:t,awaitingTitle:!e.saved})}):(0,G.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&Je(t.machine,t.id,{title:n})},children:(0,G.jsx)(`input`,{ref:c,value:i,onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>a(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&a(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),x=B(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,m&&`text-sidebar-muted-foreground/75 hover:bg-sidebar-row-hover hover:text-sidebar-foreground has-[[data-state=open]]:bg-sidebar-row-hover has-[[data-state=open]]:text-sidebar-foreground`,!e.selected&&!m&&`text-sidebar-foreground hover:bg-sidebar-row-hover has-[[data-state=open]]:bg-sidebar-row-hover bg-transparent`);return e.slim?(0,G.jsxs)(`li`,{className:`list-none`,children:[(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(HA,x,`flex h-9 items-center gap-2.5 px-2.5`),onClick:()=>e.onSelect(t.machine,t.projectId,t.id),onKeyDown:n=>{n.key===`Enter`&&e.onSelect(t.machine,t.projectId,t.id)},children:[(0,G.jsx)(`span`,{className:`flex shrink-0 items-center opacity-40 grayscale transition-opacity group-hover/sidebar-row:opacity-100 group-hover/sidebar-row:grayscale-0 group-has-[[data-state=open]]/sidebar-row:opacity-100 group-has-[[data-state=open]]/sidebar-row:grayscale-0`,children:(0,G.jsx)(mc,{machine:t.machine,projectId:t.projectId})}),(0,G.jsx)(`span`,{className:`group-any-hover/sidebar-row:mask-r-from-[calc(100%-2rem)] group-any-hover/sidebar-row:mask-r-to-[calc(100%-0.5rem)] flex min-w-0 flex-1 group-has-[[data-state=open]]/sidebar-row:mask-r-from-[calc(100%-2rem)] group-has-[[data-state=open]]/sidebar-row:mask-r-to-[calc(100%-0.5rem)]`,children:b}),(0,G.jsxs)(`span`,{className:`relative ml-auto flex h-6 min-w-8 shrink-0 items-center justify-end`,children:[(0,G.jsx)(`span`,{className:`text-secondary-label group-any-hover/sidebar-row:opacity-0 inline-flex justify-end text-xs tabular-nums transition-opacity group-has-[[data-state=open]]/sidebar-row:opacity-0`,children:yn(t.updatedAt)}),(0,G.jsxs)(`span`,{className:`group-any-hover/sidebar-row:opacity-100 absolute inset-y-0 right-0 -mr-1 flex items-center opacity-0 transition-opacity has-[[data-state=open]]:opacity-100`,children:[v,e.saved&&(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Activate`,"aria-label":`Activate`,onClick:e=>{e.stopPropagation(),Je(t.machine,t.id,{status:`active`})},children:(0,G.jsx)(H,{icon:Ls,className:`size-3.5`})})]})]})]})}),y]}),_]}):(0,G.jsxs)(`li`,{className:`list-none py-0.5`,children:[(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(HA,x,d&&!e.selected&&`opacity-70 transition-opacity focus-within:opacity-100 hover:opacity-100`),onClick:()=>e.onSelect(t.machine,t.projectId,t.id),onKeyDown:n=>{n.key===`Enter`&&e.onSelect(t.machine,t.projectId,t.id)},children:[(0,G.jsxs)(`div`,{className:`group-any-hover/sidebar-row:mask-r-from-[calc(100%-4.5rem)] group-any-hover/sidebar-row:mask-r-to-[calc(100%-2.5rem)] px-(--sidebar-row-content-inset) py-(--sidebar-content-inset) group-has-[[data-state=open]]/sidebar-row:mask-r-from-[calc(100%-4.5rem)] group-has-[[data-state=open]]/sidebar-row:mask-r-to-[calc(100%-2.5rem)]`,children:[(0,G.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,G.jsx)(mc,{machine:t.machine,projectId:t.projectId,className:`size-5`}),b,(0,G.jsx)(BA,{activity:e.activity,backgroundRunning:u,done:p})]}),(0,G.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,G.jsx)(Of,{icon:r,className:`size-3 shrink-0`}),(0,G.jsxs)(`span`,{className:B(`min-w-0 flex-1 truncate`,m?`font-normal`:`font-medium`),children:[n,t.branch!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | ${t.branch}`})]}),t.status===`pinned`&&(0,G.jsx)(H,{icon:Is,className:`size-3 shrink-0`}),t.status===`snoozed`&&(0,G.jsx)(H,{icon:sc,className:`size-3 shrink-0`}),(0,G.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:yn(t.updatedAt)})]})]}),e.saved&&(0,G.jsxs)(`div`,{className:`group-any-hover/sidebar-row:pointer-events-auto group-any-hover/sidebar-row:opacity-100 pointer-events-none absolute inset-y-0 right-0 flex flex-col items-end py-(--sidebar-content-inset) pr-1.5 opacity-0 transition-opacity has-[[data-state=open]]:pointer-events-auto has-[[data-state=open]]:opacity-100`,children:[(0,G.jsx)(`div`,{className:`flex h-6 items-center`,children:(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground me-0.75 inline-flex size-5 cursor-pointer items-center justify-center transition-colors`,title:`Done`,"aria-label":`Done`,onClick:e=>{e.stopPropagation(),g()},children:(0,G.jsx)(H,{icon:nc,strokeWidth:1.25,className:`size-5 scale-110`})})}),(0,G.jsx)(`div`,{className:`mt-1 flex h-5 items-center`,children:v})]})]})}),y]}),_]})}function GA(e){let t=cc(e.machine,e.projectId),n=k(t=>Ge(t,e.machine).icon);return(0,G.jsx)(`li`,{className:`list-none py-0.5`,children:(0,G.jsx)(`div`,{role:`button`,tabIndex:0,className:B(HA,`bg-sidebar-row-active text-sidebar-foreground`),onClick:e.onSelect,children:(0,G.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,G.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,G.jsx)(mc,{machine:e.machine,projectId:e.projectId,className:`size-5`}),(0,G.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,G.jsx)(H,{icon:Ys,className:`text-warning-foreground size-4 shrink-0`})]}),(0,G.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,G.jsx)(Of,{icon:n,className:`size-3 shrink-0`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:[t,(0,G.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | Draft`})]}),(0,G.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`now`})]})]})})})}var KA=`/assets/ghostty-vt-CQAu1Gs5.wasm`,qA=Uint8Array,JA=Uint16Array,YA=Int32Array,XA=new qA([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ZA=new qA([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),QA=new qA([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$A=function(e,t){for(var n=new JA(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new YA(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},ej=$A(XA,2),tj=ej.b,nj=ej.r;tj[28]=258,nj[258]=28;var rj=$A(ZA,0),ij=rj.b;rj.r;for(var aj=new JA(32768),oj=0;oj<32768;++oj){var sj=(oj&43690)>>1|(oj&21845)<<1;sj=(sj&52428)>>2|(sj&13107)<<2,sj=(sj&61680)>>4|(sj&3855)<<4,aj[oj]=((sj&65280)>>8|(sj&255)<<8)>>1}for(var cj=(function(e,t,n){for(var r=e.length,i=0,a=new JA(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new JA(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new JA(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[aj[d]>>c]=l}else for(s=new JA(r),i=0;i<r;++i)e[i]&&(s[i]=aj[o[e[i]-1]++]>>15-e[i]);return s}),lj=new qA(288),oj=0;oj<144;++oj)lj[oj]=8;for(var oj=144;oj<256;++oj)lj[oj]=9;for(var oj=256;oj<280;++oj)lj[oj]=7;for(var oj=280;oj<288;++oj)lj[oj]=8;for(var uj=new qA(32),oj=0;oj<32;++oj)uj[oj]=5;var dj=cj(lj,9,1),fj=cj(uj,5,1),pj=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},mj=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},hj=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},gj=function(e){return(e+7)/8|0},_j=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new qA(e.subarray(t,n))},vj=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],yj=function(e,t,n){var r=Error(t||vj[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,yj),!n)throw r;return r},bj=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new qA(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new qA(i*3));var l=function(e){var t=n.length;if(e>t){var r=new qA(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=mj(e,d,1);var v=mj(e,d+1,3);if(d+=3,!v){var y=gj(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&yj(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=dj,m=fj,h=9,g=5;else if(v==2){var S=mj(e,d,31)+257,C=mj(e,d+10,15)+4,w=S+mj(e,d+5,31)+1;d+=14;for(var T=new qA(w),E=new qA(19),D=0;D<C;++D)E[QA[D]]=mj(e,d+D*3,7);d+=C*3;for(var O=pj(E),k=(1<<O)-1,A=cj(E,O,1),D=0;D<w;){var j=A[mj(e,d,k)];d+=j&15;var y=j>>4;if(y<16)T[D++]=y;else{var M=0,N=0;for(y==16?(N=3+mj(e,d,3),d+=2,M=T[D-1]):y==17?(N=3+mj(e,d,7),d+=3):y==18&&(N=11+mj(e,d,127),d+=7);N--;)T[D++]=M}}var ee=T.subarray(0,S),te=T.subarray(S);h=pj(ee),g=pj(te),p=cj(ee,h,1),m=cj(te,g,1)}else yj(1);if(d>_){c&&yj(0);break}}s&&l(f+131072);for(var ne=(1<<h)-1,re=(1<<g)-1,ie=d;;ie=d){var M=p[hj(e,d)&ne],ae=M>>4;if(d+=M&15,d>_){c&&yj(0);break}if(M||yj(2),ae<256)n[f++]=ae;else if(ae==256){ie=d,p=null;break}else{var oe=ae-254;if(ae>264){var D=ae-257,se=XA[D];oe=mj(e,d,(1<<se)-1)+tj[D],d+=se}var ce=m[hj(e,d)&re],le=ce>>4;ce||yj(3),d+=ce&15;var te=ij[le];if(le>3){var se=ZA[le];te+=hj(e,d)&(1<<se)-1,d+=se}if(d>_){c&&yj(0);break}s&&l(f+131072);var ue=f+oe;if(f<te){var de=a-te,fe=Math.min(te,ue);for(de+f<0&&yj(3);f<fe;++f)n[f]=r[de+f]}for(;f<ue;++f)n[f]=n[f-te]}}t.l=p,t.p=ie,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?_j(n,0,f):n.subarray(0,f)},xj=new qA(0),Sj=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&yj(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&yj(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2},Cj=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new qA(32768),this.p=new qA(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||yj(5),this.d&&yj(4),!this.p.length)this.p=e;else if(e.length){var t=new qA(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=bj(this.p,this.s,this.o);this.ondata(_j(n,t,this.s.b),this.d),this.o=_j(n,this.s.b-32768),this.s.b=this.o.length,this.p=_j(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),wj=function(){function e(e,t){Cj.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(Cj.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(Sj(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&yj(6,`invalid zlib data`),this.p=this.p.subarray(0,-4)),Cj.prototype.c.call(this,t)},e}();function Tj(e,t){return bj(e.subarray(Sj(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var Ej=typeof TextDecoder<`u`&&new TextDecoder;try{Ej.decode(xj,{stream:!0})}catch{}function Dj(e,t=`utf8`){return new TextDecoder(t).decode(e)}var Oj=new TextEncoder;function kj(e){return Oj.encode(e)}var Aj=8192,jj=(()=>{let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),Mj={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array},Nj=class e{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;constructor(t=Aj,n={}){let r=!1;typeof t==`number`?t=new ArrayBuffer(t):(r=!0,this.lastWrittenByte=t.byteLength);let i=n.offset?n.offset>>>0:0,a=t.byteLength-i,o=i;(ArrayBuffer.isView(t)||t instanceof e)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+i),t=t.buffer),this.lastWrittenByte=r?a:0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let e=this._marks.pop();if(e===void 0)throw Error(`Mark stack empty`);return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){let t=(this.offset+e)*2,n=new Uint8Array(t);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=t,this.byteLength=t,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,`uint8`)}readArray(e,t){let n=Mj[t].BYTES_PER_ELEMENT*e,r=this.byteOffset+this.offset,i=this.buffer.slice(r,r+n);if(this.littleEndian===jj&&t!==`uint8`&&t!==`int8`){let e=new Uint8Array(this.buffer.slice(r,r+n));e.reverse();let i=new Mj[t](e.buffer);return this.offset+=n,i.reverse(),i}let a=new Mj[t](i);return this.offset+=n,a}readInt16(){let e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){let e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){let e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){let e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){let e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){let e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){let e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){let e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t=``;for(let n=0;n<e;n++)t+=this.readChar();return t}readUtf8(e=1){return Dj(this.readBytes(e))}decodeText(e=1,t=`utf8`){return Dj(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(kj(e))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}},Pj=[];for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;Pj[e]=t}var Fj=4294967295;function Ij(e,t,n){let r=e;for(let e=0;e<n;e++)r=Pj[(r^t[e])&255]^r>>>8;return r}function Lj(e,t){return(Ij(Fj,e,t)^Fj)>>>0}function Rj(e,t,n){let r=e.readUint32(),i=Lj(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(i!==r)throw Error(`CRC mismatch for chunk ${n}. Expected ${r}, found ${i}`)}function zj(e,t,n){for(let r=0;r<n;r++)t[r]=e[r]}function Bj(e,t,n,r){let i=0;for(;i<r;i++)t[i]=e[i];for(;i<n;i++)t[i]=e[i]+t[i-r]&255}function Vj(e,t,n,r){let i=0;if(n.length===0)for(;i<r;i++)t[i]=e[i];else for(;i<r;i++)t[i]=e[i]+n[i]&255}function Hj(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+(t[a-i]>>1)&255}else{for(;a<i;a++)t[a]=e[a]+(n[a]>>1)&255;for(;a<r;a++)t[a]=e[a]+(t[a-i]+n[a]>>1)&255}}function Uj(e,t,n,r,i){let a=0;if(n.length===0){for(;a<i;a++)t[a]=e[a];for(;a<r;a++)t[a]=e[a]+t[a-i]&255}else{for(;a<i;a++)t[a]=e[a]+n[a]&255;for(;a<r;a++)t[a]=e[a]+Wj(t[a-i],n[a],n[a-i])&255}}function Wj(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function Gj(e,t,n,r,i,a){switch(e){case 0:zj(t,n,i);break;case 1:Bj(t,n,i,a);break;case 2:Vj(t,n,r,i);break;case 3:Hj(t,n,r,i,a);break;case 4:Uj(t,n,r,i,a);break;default:throw Error(`Unsupported filter: ${e}`)}}var Kj=new Uint16Array([255]),qj=new Uint8Array(Kj.buffer)[0]===255;function Jj(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],s=Math.ceil(a/8)*i,c=new Uint8Array(r*n*s),l=0;for(let e=0;e<7;e++){let i=o[e],a=Math.ceil((n-i.x)/i.xStep),u=Math.ceil((r-i.y)/i.yStep);if(a<=0||u<=0)continue;let d=a*s,f=new Uint8Array(d);for(let e=0;e<u;e++){let o=t[l++],u=t.subarray(l,l+d);l+=d;let p=new Uint8Array(d);Gj(o,u,p,f,d,s),f.set(p);for(let t=0;t<a;t++){let a=i.x+t*i.xStep,o=i.y+e*i.yStep;if(!(a>=n||o>=r))for(let e=0;e<s;e++)c[(o*n+a)*s+e]=p[t*s+e]}}}if(a===16){let e=new Uint16Array(c.buffer);if(qj)for(let t=0;t<e.length;t++)e[t]=Yj(e[t]);return e}return c}function Yj(e){return(e&255)<<8|e>>8&255}var Xj=new Uint16Array([255]),Zj=new Uint8Array(Xj.buffer)[0]===255,Qj=new Uint8Array;function $j(e){let{data:t,width:n,height:r,channels:i,depth:a}=e,o=Math.ceil(a/8)*i,s=Math.ceil(a/8*i*n),c=new Uint8Array(r*s),l=Qj,u=0,d,f;for(let e=0;e<r;e++){switch(d=t.subarray(u+1,u+1+s),f=c.subarray(e*s,(e+1)*s),t[u]){case 0:zj(d,f,s);break;case 1:Bj(d,f,s,o);break;case 2:Vj(d,f,l,s);break;case 3:Hj(d,f,l,s,o);break;case 4:Uj(d,f,l,s,o);break;default:throw Error(`Unsupported filter: ${t[u]}`)}l=f,u+=s+1}if(a===16){let e=new Uint16Array(c.buffer);if(Zj)for(let t=0;t<e.length;t++)e[t]=eM(e[t]);return e}return c}function eM(e){return(e&255)<<8|e>>8&255}var tM=Uint8Array.of(137,80,78,71,13,10,26,10);function nM(e){if(!rM(e.readBytes(tM.length)))throw Error(`wrong PNG signature`)}function rM(e){if(e.length<tM.length)return!1;for(let t=0;t<tM.length;t++)if(e[t]!==tM[t])return!1;return!0}var iM=`tEXt`,aM=0,oM=new TextDecoder(`latin1`);function sM(e){if(lM(e),e.length===0||e.length>79)throw Error(`keyword length must be between 1 and 79`)}var cM=/^[\u0000-\u00FF]*$/;function lM(e){if(!cM.test(e))throw Error(`invalid latin1 text`)}function uM(e,t,n){let r=dM(t);e[r]=fM(t,n-r.length-1)}function dM(e){for(e.mark();e.readByte()!==aM;);let t=e.offset;e.reset();let n=oM.decode(e.readBytes(t-e.offset-1));return e.skip(1),sM(n),n}function fM(e,t){return oM.decode(e.readBytes(t))}var pM={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},mM={UNKNOWN:-1,DEFLATE:0},hM={UNKNOWN:-1,ADAPTIVE:0},gM={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},_M={NONE:0,BACKGROUND:1,PREVIOUS:2},vM={SOURCE:0,OVER:1},yM=class extends Nj{_checkCrc;_inflator;_png;_apng;_end;_hasPalette;_palette;_hasTransparency;_transparency;_compressionMethod;_filterMethod;_interlaceMethod;_colorType;_isAnimated;_numberOfFrames;_numberOfPlays;_frames;_writingDataChunks;_chunks;_inflatorResult;constructor(e,t={}){super(e);let{checkCrc:n=!1}=t;this._checkCrc=n,this._inflator=new wj((e,t)=>{if(this._chunks.push(e),t){let e=this._chunks.reduce((e,t)=>e+t.length,0);this._inflatorResult=new Uint8Array(e);let t=0;for(let e of this._chunks)this._inflatorResult.set(e,t),t+=e.length;this._chunks=[]}}),this._chunks=[],this._png={width:-1,height:-1,channels:-1,data:new Uint8Array,depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array,this._compressionMethod=mM.UNKNOWN,this._filterMethod=hM.UNKNOWN,this._interlaceMethod=gM.UNKNOWN,this._colorType=pM.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this._inflatorResult=new Uint8Array,this.setBigEndian()}decode(){for(nM(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeChunk(e,t)}return this._inflator.push(new Uint8Array,!0),this.decodeImage(),this._png}decodeApng(){for(nM(this);!this._end;){let e=this.readUint32(),t=this.readChars(4);this.decodeApngChunk(e,t)}return this.decodeApngImage(),this._apng}decodeChunk(e,t){let n=this.offset;switch(t){case`IHDR`:this.decodeIHDR();break;case`PLTE`:this.decodePLTE(e);break;case`IDAT`:this.decodeIDAT(e);break;case`IEND`:this._end=!0;break;case`tRNS`:this.decodetRNS(e);break;case`iCCP`:this.decodeiCCP(e);break;case iM:uM(this._png.text,this,e);break;case`pHYs`:this.decodepHYs();break;default:this.skip(e)}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?Rj(this,e+4,t):this.skip(4)}decodeApngChunk(e,t){let n=this.offset;switch(t!==`fdAT`&&t!==`IDAT`&&this._writingDataChunks&&this.pushDataToFrame(),t){case`acTL`:this.decodeACTL();break;case`fcTL`:this.decodeFCTL();break;case`fdAT`:this.decodeFDAT(e);break;default:this.decodeChunk(e,t),this.offset=n+e}if(this.offset-n!==e)throw Error(`Length mismatch while decoding chunk ${t}`);this._checkCrc?Rj(this,e+4,t):this.skip(4)}decodeIHDR(){let e=this._png;e.width=this.readUint32(),e.height=this.readUint32(),e.depth=bM(this.readUint8());let t=this.readUint8();this._colorType=t;let n;switch(t){case pM.GREYSCALE:n=1;break;case pM.TRUECOLOUR:n=3;break;case pM.INDEXED_COLOUR:n=1;break;case pM.GREYSCALE_ALPHA:n=2;break;case pM.TRUECOLOUR_ALPHA:n=4;break;case pM.UNKNOWN:default:throw Error(`Unknown color type: ${t}`)}if(this._png.channels=n,this._compressionMethod=this.readUint8(),this._compressionMethod!==mM.DEFLATE)throw Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){let e={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array};this._frames.push(e)}decodePLTE(e){if(e%3!=0)throw RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);let t=e/3;this._hasPalette=!0;let n=[];this._palette=n;for(let e=0;e<t;e++)n.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;try{this._inflator.push(new Uint8Array(this.buffer,n,t),!1)}catch(e){throw Error(`Error while decompressing the data:`,{cause:e})}this.skip(e)}decodeFDAT(e){this._writingDataChunks=!0;let t=e,n=this.offset+this.byteOffset;n+=4,t-=4;try{this._inflator.push(new Uint8Array(this.buffer,n,t),!1)}catch(e){throw Error(`Error while decompressing the data:`,{cause:e})}this.skip(e)}decodetRNS(e){switch(this._colorType){case pM.GREYSCALE:case pM.TRUECOLOUR:if(e%2!=0)throw RangeError(`tRNS chunk length must be a multiple of 2. Got ${e}`);if(e/2>this._png.width*this._png.height)throw Error(`tRNS chunk contains more alpha values than there are pixels (${e/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(e/2);for(let t=0;t<e/2;t++)this._transparency[t]=this.readUint16();break;case pM.INDEXED_COLOUR:{if(e>this._palette.length)throw Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);let t=0;for(;t<e;t++){let e=this.readByte();this._palette[t].push(e)}for(;t<this._palette.length;t++)this._palette[t].push(255);break}case pM.UNKNOWN:case pM.GREYSCALE_ALPHA:case pM.TRUECOLOUR_ALPHA:default:throw Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(e){let t=dM(this),n=this.readUint8();if(n!==mM.DEFLATE)throw Error(`Unsupported iCCP compression method: ${n}`);let r=this.readBytes(e-t.length-2);this._png.iccEmbeddedProfile={name:t,profile:Tj(r)}}decodepHYs(){let e=this.readUint32(),t=this.readUint32(),n=this.readByte();this._png.resolution={x:e,y:t,unit:n}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let e=0;e<this._numberOfFrames;e++){let t={sequenceNumber:this._frames[e].sequenceNumber,delayNumber:this._frames[e].delayNumber,delayDenominator:this._frames[e].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},n=this._frames.at(e);if(n){if(n.data=$j({data:n.data,width:n.width,height:n.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),e===0||n.xOffset===0&&n.yOffset===0&&n.width===this._png.width&&n.height===this._png.height)t.data=n.data;else{let r=this._apng.frames.at(e-1);this.disposeFrame(n,r,t),this.addFrameDataToCanvas(t,n)}this._apng.frames.push(t)}}return this._apng}disposeFrame(e,t,n){switch(e.disposeOp){case _M.NONE:break;case _M.BACKGROUND:for(let t=0;t<this._png.height;t++)for(let r=0;r<this._png.width;r++){let i=(t*e.width+r)*this._png.channels;for(let e=0;e<this._png.channels;e++)n.data[i+e]=0}break;case _M.PREVIOUS:n.data.set(t.data);break;default:throw Error(`Unknown disposeOp`)}}addFrameDataToCanvas(e,t){let n=1<<this._png.depth,r=(e,n)=>({index:((e+t.yOffset)*this._png.width+t.xOffset+n)*this._png.channels,frameIndex:(e*t.width+n)*this._png.channels});switch(t.blendOp){case vM.SOURCE:for(let n=0;n<t.height;n++)for(let i=0;i<t.width;i++){let{index:a,frameIndex:o}=r(n,i);for(let n=0;n<this._png.channels;n++)e.data[a+n]=t.data[o+n]}break;case vM.OVER:for(let i=0;i<t.height;i++)for(let a=0;a<t.width;a++){let{index:o,frameIndex:s}=r(i,a);for(let r=0;r<this._png.channels;r++){let i=t.data[s+this._png.channels-1]/n,a=r%(this._png.channels-1)==0?1:t.data[s+r],c=Math.floor(i*a+(1-i)*e.data[o+r]);e.data[o+r]+=c}}break;default:throw Error(`Unknown blendOp`)}}decodeImage(){let e=this._inflatorResult;if(this._filterMethod!==hM.ADAPTIVE)throw Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===gM.NO_INTERLACE)this._png.data=$j({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===gM.ADAM7)this._png.data=Jj({data:e,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){this._inflator.push(new Uint8Array,!0);let e=this._inflatorResult,t=this._frames.at(-1);t?t.data=e:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:_M.NONE,blendOp:vM.SOURCE,data:e}),this._inflator=new wj((e,t)=>{if(this._chunks.push(e),t){let e=this._chunks.reduce((e,t)=>e+t.length,0);this._inflatorResult=new Uint8Array(e);let t=0;for(let e of this._chunks)this._inflatorResult.set(e,t),t+=e.length;this._chunks=[]}}),this._chunks=[],this._writingDataChunks=!1}};function bM(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw Error(`invalid bit depth: ${e}`);return e}function xM(e){let t=e.palette,n=e.depth;if(!t)throw Error(`Color palette is undefined.`);SM(e);let r=e.width*e.height,i=r*t[0].length,a=new Uint8Array(i),o=0,s=0,c=new Uint8Array(r),l=255;switch(n){case 1:l=128;break;case 2:l=192;break;case 4:l=240;break;case 8:l=255;break;default:throw Error(`Incorrect depth value`)}for(let t of e.data){let r=l,i=8;for(;r&&(i-=n,c[o++]=(t&r)>>i,r>>=n,o%e.width!==0););}if(e.palette)for(let t of c){let n=e.palette.at(t);if(!n)throw Error(`Incorrect index of palette color`);a.set(n,s),s+=n.length}return a}function SM(e){let t=e.depth<8?Math.ceil(e.width*e.depth/8)*e.height*e.channels:e.width*e.height*e.channels;if(e.data.length!==t)throw RangeError(`wrong data size. Found ${e.data.length}, expected ${t}`)}function CM(e,t){return new yM(e,t).decode()}var wM=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_FOREGROUND=e.DEFAULT_BACKGROUND=e.PALETTE_ANSI_256=e.PALETTE_VT340_GREY=e.PALETTE_VT340_COLOR=e.normalizeHLS=e.normalizeRGB=e.nearestColorIndex=e.fromRGBA8888=e.toRGBA8888=e.alpha=e.blue=e.green=e.red=e.BIG_ENDIAN=void 0,e.BIG_ENDIAN=new Uint8Array(new Uint32Array([4278190080]).buffer)[0]===255,e.BIG_ENDIAN&&console.warn(`BE platform detected. This version of node-sixel works only on LE properly.`);function t(e){return e&255}e.red=t;function n(e){return e>>>8&255}e.green=n;function r(e){return e>>>16&255}e.blue=r;function i(e){return e>>>24&255}e.alpha=i;function a(e,t,n,r=255){return((r&255)<<24|(n&255)<<16|(t&255)<<8|e&255)>>>0}e.toRGBA8888=a;function o(e){return[e&255,e>>8&255,e>>16&255,e>>>24]}e.fromRGBA8888=o;function s(e,i){let a=t(e),o=n(e),s=r(e),c=2**53-1,l=-1;for(let e=0;e<i.length;++e){let t=a-i[e][0],n=o-i[e][1],r=s-i[e][2],u=t*t+n*n+r*r;if(!u)return e;u<c&&(c=u,l=e)}return l}e.nearestColorIndex=s;function c(e,t,n){return Math.max(e,Math.min(n,t))}function l(e,t,n){return n<0&&(n+=1),n>1&&--n,n*6<1?t+(e-t)*6*n:n*2<1?e:n*3<2?t+(e-t)*(4-n*6):t}function u(e,t,n){if(!n){let e=Math.round(t*255);return a(e,e,e)}let r=t<.5?t*(1+n):t+n-t*n,i=2*t-r;return a(c(0,255,Math.round(l(r,i,e+1/3)*255)),c(0,255,Math.round(l(r,i,e)*255)),c(0,255,Math.round(l(r,i,e-1/3)*255)))}function d(e,t,n){return(4278190080|Math.round(n/100*255)<<16|Math.round(t/100*255)<<8|Math.round(e/100*255))>>>0}e.normalizeRGB=d;function f(e,t,n){return u((e+240)/360,t/100,n/100)}e.normalizeHLS=f,e.PALETTE_VT340_COLOR=new Uint32Array([d(0,0,0),d(20,20,80),d(80,13,13),d(20,80,20),d(80,20,80),d(20,80,80),d(80,80,20),d(53,53,53),d(26,26,26),d(33,33,60),d(60,26,26),d(33,60,33),d(60,33,60),d(33,60,60),d(60,60,33),d(80,80,80)]),e.PALETTE_VT340_GREY=new Uint32Array([d(0,0,0),d(13,13,13),d(26,26,26),d(40,40,40),d(6,6,6),d(20,20,20),d(33,33,33),d(46,46,46),d(0,0,0),d(13,13,13),d(26,26,26),d(40,40,40),d(6,6,6),d(20,20,20),d(33,33,33),d(46,46,46)]),e.PALETTE_ANSI_256=(()=>{let e=[a(0,0,0),a(205,0,0),a(0,205,0),a(205,205,0),a(0,0,238),a(205,0,205),a(0,250,205),a(229,229,229),a(127,127,127),a(255,0,0),a(0,255,0),a(255,255,0),a(92,92,255),a(255,0,255),a(0,255,255),a(255,255,255)],t=[0,95,135,175,215,255];for(let n=0;n<6;++n)for(let r=0;r<6;++r)for(let i=0;i<6;++i)e.push(a(t[n],t[r],t[i]));for(let t=8;t<=238;t+=10)e.push(a(t,t,t));return new Uint32Array(e)})(),e.DEFAULT_BACKGROUND=a(0,0,0,255),e.DEFAULT_FOREGROUND=a(255,255,255,255)})),TM=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LIMITS=void 0,e.LIMITS={CHUNK_SIZE:16384,PALETTE_SIZE:4096,MAX_WIDTH:16384,BYTES:`AGFzbQEAAAABJAdgAAF/YAJ/fwBgA39/fwF/YAF/AX9gAABgBH9/f38AYAF/AAIlAgNlbnYLaGFuZGxlX2JhbmQAAwNlbnYLbW9kZV9wYXJzZWQAAwMTEgQAAAAAAQQBAQUBAAACAgAGAwQFAXABBwcFBAEBBwcGCAF/AUGAihoLB9wBDgZtZW1vcnkCABFnZXRfc3RhdGVfYWRkcmVzcwADEWdldF9jaHVua19hZGRyZXNzAAQOZ2V0X3AwX2FkZHJlc3MABRNnZXRfcGFsZXR0ZV9hZGRyZXNzAAYEaW5pdAALBmRlY29kZQAMDWN1cnJlbnRfd2lkdGgADQ5jdXJyZW50X2hlaWdodAAOGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtfaW5pdGlhbGl6ZQACCXN0YWNrU2F2ZQARDHN0YWNrUmVzdG9yZQASCnN0YWNrQWxsb2MAEwkMAQBBAQsGCgcJDxACDAEBCq5UEgMAAQsFAEGgCAsGAEGQiQELBgBBsIkCCwUAQZAJC+okAQh/QeQIKAIAIQVB4AgoAgAhA0HoCCgCACEIIAFBkIkBaiIJQf8BOgAAIAAgAUgEQCAAQZCJAWohBgNAIAMhBCAGQQFqIQECQCAGLQAAQf8AcSIDQTBrQQlLBEAgASEGDAELQewIKAIAQQJ0QewIaiICKAIAIQADQCACIAMgAEEKbGpBMGsiADYCACABLQAAIQMgAUEBaiIGIQEgA0H/AHEiA0Ewa0EKSQ0ACwsCQAJAAkACQAJAAkACQAJ/AkACQCADQT9rIgBBP00EQCAERQ0BIARBIUYEQAJAQfAIKAIAIgFBASABGyIHIAhqIgFB1AgoAgAiA0gNACADQf//AEoNAANAIANBAnQiAkGgiQJqIgRBoAgpAwA3AwAgAkGoiQJqQaAIKQMANwMAIAJBsIkCakGgCCkDADcDACACQbiJAmpBoAgpAwA3AwAgAkHAiQJqQaAIKQMANwMAIAJByIkCakGgCCkDADcDACACQdCJAmpBoAgpAwA3AwAgAkHYiQJqQaAIKQMANwMAIAJB4IkCakGgCCkDADcDACACQeiJAmpBoAgpAwA3AwAgAkHwiQJqQaAIKQMANwMAIAJB+IkCakGgCCkDADcDACACQYCKAmpBoAgpAwA3AwAgAkGIigJqQaAIKQMANwMAIAJBkIoCakGgCCkDADcDACACQZiKAmpBoAgpAwA3AwAgAkGgigJqQaAIKQMANwMAIAJBqIoCakGgCCkDADcDACACQbCKAmpBoAgpAwA3AwAgAkG4igJqQaAIKQMANwMAIAJBwIoCakGgCCkDADcDACACQciKAmpBoAgpAwA3AwAgAkHQigJqQaAIKQMANwMAIAJB2IoCakGgCCkDADcDACACQeCKAmpBoAgpAwA3AwAgAkHoigJqQaAIKQMANwMAIAJB8IoCakGgCCkDADcDACACQfiKAmpBoAgpAwA3AwAgAkGAiwJqQaAIKQMANwMAIAJBiIsCakGgCCkDADcDACACQZCLAmpBoAgpAwA3AwAgAkGYiwJqQaAIKQMANwMAIAJBoIsCakGgCCkDADcDACACQaiLAmpBoAgpAwA3AwAgAkGwiwJqQaAIKQMANwMAIAJBuIsCakGgCCkDADcDACACQcCLAmpBoAgpAwA3AwAgAkHIiwJqQaAIKQMANwMAIAJB0IsCakGgCCkDADcDACACQdiLAmpBoAgpAwA3AwAgAkHgiwJqQaAIKQMANwMAIAJB6IsCakGgCCkDADcDACACQfCLAmpBoAgpAwA3AwAgAkH4iwJqQaAIKQMANwMAIAJBgIwCakGgCCkDADcDACACQYiMAmpBoAgpAwA3AwAgAkGQjAJqQaAIKQMANwMAIAJBmIwCakGgCCkDADcDACACQaCMAmpBoAgpAwA3AwAgAkGojAJqQaAIKQMANwMAIAJBsIwCakGgCCkDADcDACACQbiMAmpBoAgpAwA3AwAgAkHAjAJqQaAIKQMANwMAIAJByIwCakGgCCkDADcDACACQdCMAmpBoAgpAwA3AwAgAkHYjAJqQaAIKQMANwMAIAJB4IwCakGgCCkDADcDACACQeiMAmpBoAgpAwA3AwAgAkHwjAJqQaAIKQMANwMAIAJB+IwCakGgCCkDADcDACACQYCNAmpBoAgpAwA3AwAgAkGIjQJqQaAIKQMANwMAIAJBkI0CakGgCCkDADcDACACQZiNAmpBoAgpAwA3AwAgAkGwiQZqIARBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBEGABPwKAABB1AgoAgBBAnRB0IkOaiAEQYAE/AoAAEHUCCgCAEECdEHgiRJqIARBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBEGABPwKAABB1AhB1AgoAgAiAkGAAWoiAzYCACABIANIDQEgAkGA/wBIDQALCwJAIABFDQAgCEH//wBLDQBBgIABIAhrIAcgAUH//wBLGyECAkAgAEEBcUUNACACRQ0AIAhBAnRBoIkCaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBAnFFDQAgAkUNACAIQQJ0QbCJBmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsCQCAAQQRxRQ0AIAJFDQAgCEECdEHAiQpqIQMgAiEEIAJBB3EiBwRAA0AgAyAFNgIAIANBBGohAyAEQQFrIQQgB0EBayIHDQALCyACQQFrQQdJDQADQCADIAU2AhwgAyAFNgIYIAMgBTYCFCADIAU2AhAgAyAFNgIMIAMgBTYCCCADIAU2AgQgAyAFNgIAIANBIGohAyAEQQhrIgQNAAsLAkAgAEEIcUUNACACRQ0AIAhBAnRB0IkOaiEDIAIhBCACQQdxIgcEQANAIAMgBTYCACADQQRqIQMgBEEBayEEIAdBAWsiBw0ACwsgAkEBa0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgBEEIayIEDQALCwJAIABBEHFFDQAgAkUNACAIQQJ0QeCJEmohAyACIQQgAkEHcSIHBEADQCADIAU2AgAgA0EEaiEDIARBAWshBCAHQQFrIgcNAAsLIAJBAWtBB0kNAANAIAMgBTYCHCADIAU2AhggAyAFNgIUIAMgBTYCECADIAU2AgwgAyAFNgIIIAMgBTYCBCADIAU2AgAgA0EgaiEDIARBCGsiBA0ACwsgAEEgcUUNACACRQ0AIAJBAWshByAIQQJ0QfCJFmohAyACQQdxIgQEQANAIAMgBTYCACADQQRqIQMgAkEBayECIARBAWsiBA0ACwsgB0EHSQ0AA0AgAyAFNgIcIAMgBTYCGCADIAU2AhQgAyAFNgIQIAMgBTYCDCADIAU2AgggAyAFNgIEIAMgBTYCACADQSBqIQMgAkEIayICDQALC0HcCEHcCCgCACAAcjYCACAGQQFqIgIgBi0AAEH/AHEiA0E/ayIAQT9LDQQaDAMLAkBB7AgoAgAiBEEBRgRAQfAIKAIAIgNBzAgoAgAiAUkNASADIAFwIQMMAQtB+AgoAgAhAkH0CCgCACEBAkACQCAEQQVHDQAgAUEBRw0AIAJB6QJODQQMAQsgAkHkAEoNA0H8CCgCAEHkAEoNA0GACSgCAEHkAEoNAwsCQCABRQ0AIAFBAkoNACACQfwIKAIAQYAJKAIAIAFBAnRBiAhqKAIAEQIAIQFB8AgoAgAiA0HMCCgCACICTwR/IAMgAnAFIAMLQQJ0QZAJaiABNgIAC0HwCCgCACIDQcwIKAIAIgFJDQAgAyABcCEDCyADQQJ0QZAJaigCACEFDAELIANB/QBxQSFHBEAgCCEBIAYhAgwECyAEQSNHDQQCQEHsCCgCACICQQFGBEBB8AgoAgAiAUHMCCgCACIASQ0BIAEgAHAhAQwBC0H4CCgCACEBQfQIKAIAIQACQAJAIAJBBUcNACAAQQFHDQAgAUHpAkgNAQwHCyABQeQASg0GQfwIKAIAQeQASg0GQYAJKAIAQeQASg0GCwJAIABFDQAgAEECSg0AIAFB/AgoAgBBgAkoAgAgAEECdEGICGooAgARAgAhAEHwCCgCACIBQcwIKAIAIgJPBH8gASACcAUgAQtBAnRBkAlqIAA2AgALQfAIKAIAIgFBzAgoAgAiAEkNACABIABwIQELIAFBAnRBkAlqKAIAIQUMBAsgCCEBIAYhAgtB1AgoAgAhBgNAAkAgASAGSA0AIAZB//8ASg0AIAZBAnQiBEGgiQJqIgZBoAgpAwA3AwAgBEGoiQJqQaAIKQMANwMAIARBsIkCakGgCCkDADcDACAEQbiJAmpBoAgpAwA3AwAgBEHAiQJqQaAIKQMANwMAIARByIkCakGgCCkDADcDACAEQdCJAmpBoAgpAwA3AwAgBEHYiQJqQaAIKQMANwMAIARB4IkCakGgCCkDADcDACAEQeiJAmpBoAgpAwA3AwAgBEHwiQJqQaAIKQMANwMAIARB+IkCakGgCCkDADcDACAEQYCKAmpBoAgpAwA3AwAgBEGIigJqQaAIKQMANwMAIARBkIoCakGgCCkDADcDACAEQZiKAmpBoAgpAwA3AwAgBEGgigJqQaAIKQMANwMAIARBqIoCakGgCCkDADcDACAEQbCKAmpBoAgpAwA3AwAgBEG4igJqQaAIKQMANwMAIARBwIoCakGgCCkDADcDACAEQciKAmpBoAgpAwA3AwAgBEHQigJqQaAIKQMANwMAIARB2IoCakGgCCkDADcDACAEQeCKAmpBoAgpAwA3AwAgBEHoigJqQaAIKQMANwMAIARB8IoCakGgCCkDADcDACAEQfiKAmpBoAgpAwA3AwAgBEGAiwJqQaAIKQMANwMAIARBiIsCakGgCCkDADcDACAEQZCLAmpBoAgpAwA3AwAgBEGYiwJqQaAIKQMANwMAIARBoIsCakGgCCkDADcDACAEQaiLAmpBoAgpAwA3AwAgBEGwiwJqQaAIKQMANwMAIARBuIsCakGgCCkDADcDACAEQcCLAmpBoAgpAwA3AwAgBEHIiwJqQaAIKQMANwMAIARB0IsCakGgCCkDADcDACAEQdiLAmpBoAgpAwA3AwAgBEHgiwJqQaAIKQMANwMAIARB6IsCakGgCCkDADcDACAEQfCLAmpBoAgpAwA3AwAgBEH4iwJqQaAIKQMANwMAIARBgIwCakGgCCkDADcDACAEQYiMAmpBoAgpAwA3AwAgBEGQjAJqQaAIKQMANwMAIARBmIwCakGgCCkDADcDACAEQaCMAmpBoAgpAwA3AwAgBEGojAJqQaAIKQMANwMAIARBsIwCakGgCCkDADcDACAEQbiMAmpBoAgpAwA3AwAgBEHAjAJqQaAIKQMANwMAIARByIwCakGgCCkDADcDACAEQdCMAmpBoAgpAwA3AwAgBEHYjAJqQaAIKQMANwMAIARB4IwCakGgCCkDADcDACAEQeiMAmpBoAgpAwA3AwAgBEHwjAJqQaAIKQMANwMAIARB+IwCakGgCCkDADcDACAEQYCNAmpBoAgpAwA3AwAgBEGIjQJqQaAIKQMANwMAIARBkI0CakGgCCkDADcDACAEQZiNAmpBoAgpAwA3AwAgBEGwiQZqIAZBgAT8CgAAQdQIKAIAQQJ0QcCJCmogBkGABPwKAABB1AgoAgBBAnRB0IkOaiAGQYAE/AoAAEHUCCgCAEECdEHgiRJqIAZBgAT8CgAAQdQIKAIAQQJ0QfCJFmogBkGABPwKAABB1AhB1AgoAgBBgAFqIgY2AgALIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiAFNgIAIABBAXZBAXEgAWxBAnRBsIkGaiAFNgIAIABBAnZBAXEgAWxBAnRBwIkKaiAFNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiAFNgIAIABBBHZBAXEgAWxBAnRB4IkSaiAFNgIAIABBBXYgAWxBAnRB8IkWaiAFNgIAQdQIKAIAIQYLIAFBAWohAUHcCEHcCCgCACAAcjYCACACLQAAIQAgAkEBaiIEIQIgAEH/AHEiA0E/ayIAQcAASQ0ACyAECyECQQAhBCACIQYgASEIIANB/QBxQSFGDQELIANBJGsOCgEDAwMDAwMDAwIDC0HsCEIBNwIADAQLQdgIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbNgIADAILQegIIAFB2AgoAgAiACAAIAFIGyIAQYCAASAAQYCAAUgbIgA2AgBB2AggADYCACAAQQRrEAAEQEHoCEEENgIAQdgIQQQ2AgBB0AhBATYCAA8LEAgMAQsCQCADQTtHDQBB7AgoAgAiAEEHSg0AQewIIABBAWo2AgAgAEECdEHwCGpBADYCAAsgAiEGIAQhAyABIQgMAQtBBCEIIAIhBiAEIQMLIAYgCUkNAAsLQeQIIAU2AgBB4AggAzYCAEHoCCAINgIAC9ELAgF+CH9B2AhCBDcDAEGojQJBoAgpAwAiADcDAEGgjQIgADcDAEGYjQIgADcDAEGQjQIgADcDAEGIjQIgADcDAEGAjQIgADcDAEH4jAIgADcDAEHwjAIgADcDAEHojAIgADcDAEHgjAIgADcDAEHYjAIgADcDAEHQjAIgADcDAEHIjAIgADcDAEHAjAIgADcDAEG4jAIgADcDAEGwjAIgADcDAEGojAIgADcDAEGgjAIgADcDAEGYjAIgADcDAEGQjAIgADcDAEGIjAIgADcDAEGAjAIgADcDAEH4iwIgADcDAEHwiwIgADcDAEHoiwIgADcDAEHgiwIgADcDAEHYiwIgADcDAEHQiwIgADcDAEHIiwIgADcDAEHAiwIgADcDAEG4iwIgADcDAEGwiwIgADcDAEGoiwIgADcDAEGgiwIgADcDAEGYiwIgADcDAEGQiwIgADcDAEGIiwIgADcDAEGAiwIgADcDAEH4igIgADcDAEHwigIgADcDAEHoigIgADcDAEHgigIgADcDAEHYigIgADcDAEHQigIgADcDAEHIigIgADcDAEHAigIgADcDAEG4igIgADcDAEGwigIgADcDAEGoigIgADcDAEGgigIgADcDAEGYigIgADcDAEGQigIgADcDAEGIigIgADcDAEGAigIgADcDAEH4iQIgADcDAEHwiQIgADcDAEHoiQIgADcDAEHgiQIgADcDAEHYiQIgADcDAEHQiQIgADcDAEHIiQIgADcDAEHAiQIgADcDAEG4iQIgADcDAEGwiQIgADcDAEGoCCgCACIEQf8AakGAAW0hCAJAIARBgQFIDQBBASEBIAhBAiAIQQJKG0EBayICQQFxIQMgBEGBAk4EQCACQX5xIQIDQCABQQl0IgdBEHJBoIkCakGwiQJBgAT8CgAAIAdBsI0CakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsLIANFDQAgAUEJdEEQckGgiQJqQbCJAkGABPwKAAALAkAgBEEBSA0AIAhBASAIQQFKGyIDQQFxIQUCQCADQQFrIgdFBEBBACEBDAELIANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQbCJBmpBsIkCQYAE/AoAACAGQZAEckGwiQZqQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACwsgBQRAIAFBCXRBEHJBsIkGakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEFIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiBkEQckHAiQpqQbCJAkGABPwKAAAgBkGQBHJBwIkKakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAFBEAgAUECdEHAiQpqQbCJAkGABPwKAAALIARBAUgNACADQQFxIQUgBwR/IANB/v///wdxIQJBACEBA0AgAUEJdCIGQRByQdCJDmpBsIkCQYAE/AoAACAGQZAEckHQiQ5qQbCJAkGABPwKAAAgAUECaiEBIAJBAmsiAg0ACyABQQd0QQRyBUEECyEBIAUEQCABQQJ0QdCJDmpBsIkCQYAE/AoAAAsgBEEBSA0AIANBAXEhBSAHBH8gA0H+////B3EhAkEAIQEDQCABQQl0IgZBEHJB4IkSakGwiQJBgAT8CgAAIAZBkARyQeCJEmpBsIkCQYAE/AoAACABQQJqIQEgAkECayICDQALIAFBB3RBBHIFQQQLIQEgBQRAIAFBAnRB4IkSakGwiQJBgAT8CgAACyAEQQFIDQAgA0EBcSEEIAcEfyADQf7///8HcSECQQAhAQNAIAFBCXQiA0EQckHwiRZqQbCJAkGABPwKAAAgA0GQBHJB8IkWakGwiQJBgAT8CgAAIAFBAmohASACQQJrIgINAAsgAUEHdEEEcgVBBAshASAERQ0AIAFBAnRB8IkWakGwiQJBgAT8CgAAC0HUCCAIQQd0QQRyNgIAC58TAgh/AX5B5AgoAgAhA0HgCCgCACECQegIKAIAIQcgAUGQiQFqIglB/wE6AAAgACABSARAIABBkIkBaiEIA0AgAiEEIAhBAWohAQJAIAgtAABB/wBxIgJBMGtBCUsEQCABIQgMAQtB7AgoAgBBAnRB7AhqIgUoAgAhAANAIAUgAiAAQQpsakEwayIANgIAIAEtAAAhAiABQQFqIgghASACQf8AcSICQTBrQQpJDQALCwJAAkACQAJAAkACQAJ/AkAgAkE/ayIAQT9NBEAgBEUNASAEQSFGBEBB8AgoAgAiAUEBIAEbIgQgB2ohAQJAIABFDQAgB0H//wBLDQBBgIABIAdrIAQgAUH//wBLGyEFAkAgAEEBcUUNACAHQQJ0QaCJAmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEECcUUNACAHQQJ0QbCJBmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEEcUUNACAHQQJ0QcCJCmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEIcUUNACAHQQJ0QdCJDmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLAkAgAEEQcUUNACAHQQJ0QeCJEmohAiAFIgRBB3EiBgRAA0AgAiADNgIAIAJBBGohAiAEQQFrIQQgBkEBayIGDQALCyAFQQFrQQdJDQADQCACIAM2AhwgAiADNgIYIAIgAzYCFCACIAM2AhAgAiADNgIMIAIgAzYCCCACIAM2AgQgAiADNgIAIAJBIGohAiAEQQhrIgQNAAsLIABBIHFFDQAgBUEBayEEIAdBAnRB8IkWaiEAIAVBB3EiAgRAA0AgACADNgIAIABBBGohACAFQQFrIQUgAkEBayICDQALCyAEQQdJDQADQCAAIAM2AhwgACADNgIYIAAgAzYCFCAAIAM2AhAgACADNgIMIAAgAzYCCCAAIAM2AgQgACADNgIAIABBIGohACAFQQhrIgUNAAsLIAhBAWoiBSAILQAAQf8AcSICQT9rIgBBP00NAxoMBAsCQEHsCCgCACIFQQFGBEBB8AgoAgAiAUHMCCgCACIESQ0BIAEgBHAhAQwBC0H4CCgCACEEQfQIKAIAIQECQAJAIAVBBUcNACABQQFHDQAgBEHpAk4NBAwBCyAEQeQASg0DQfwIKAIAQeQASg0DQYAJKAIAQeQASg0DCwJAIAFFDQAgAUECSg0AIARB/AgoAgBBgAkoAgAgAUECdEGICGooAgARAgAhBEHwCCgCACIBQcwIKAIAIgVPBH8gASAFcAUgAQtBAnRBkAlqIAQ2AgALQfAIKAIAIgFBzAgoAgAiBEkNACABIARwIQELIAFBAnRBkAlqKAIAIQMMAQsgAkH9AHFBIUcEQCAHIQEgAiEADAQLIARBI0cNBAJAQewIKAIAIgRBAUYEQEHwCCgCACIBQcwIKAIAIgBJDQEgASAAcCEBDAELQfgIKAIAIQFB9AgoAgAhAAJAAkAgBEEFRw0AIABBAUcNACABQekCSA0BDAcLIAFB5ABKDQZB/AgoAgBB5ABKDQZBgAkoAgBB5ABKDQYLAkAgAEUNACAAQQJKDQAgAUH8CCgCAEGACSgCACAAQQJ0QYgIaigCABECACEAQfAIKAIAIgFBzAgoAgAiBE8EfyABIARwBSABC0ECdEGQCWogADYCAAtB8AgoAgAiAUHMCCgCACIASQ0AIAEgAHAhAQsgAUECdEGQCWooAgAhAwwECyAHIQEgCAshBQNAIAFB//8ATQRAIABBAXEgAWxBAnRBoIkCaiADNgIAIABBAXZBAXEgAWxBAnRBsIkGaiADNgIAIABBAnZBAXEgAWxBAnRBwIkKaiADNgIAIABBA3ZBAXEgAWxBAnRB0IkOaiADNgIAIABBBHZBAXEgAWxBAnRB4IkSaiADNgIAIABBBXYgAWxBAnRB8IkWaiADNgIACyABQQFqIQEgBS0AACEAIAVBAWoiBCEFIABB/wBxIgJBP2siAEHAAEkNAAsgBCEFC0EAIQQgBSEIIAEhByACIQAgAkH9AHFBIUYNAQtBBCEHIAQhAiAAQSRrDgoDAgICAgICAgIBAgtB7AhCATcCAAwCC0GoCCgCAEEEaxAABEBB0AhBATYCAA8LAkBBqAgoAgAiBkEFSA0AQaAIKQMAIQogBkEDa0EBdiIBQQdxIQJBACEAIAFBAWtBB08EQCABQfj///8HcSEFA0AgAEEDdCIBQbCJAmogCjcDACABQQhyQbCJAmogCjcDACABQRByQbCJAmogCjcDACABQRhyQbCJAmogCjcDACABQSByQbCJAmogCjcDACABQShyQbCJAmogCjcDACABQTByQbCJAmogCjcDACABQThyQbCJAmogCjcDACAAQQhqIQAgBUEIayIFDQALCyACRQ0AA0AgAEEDdEGwiQJqIAo3AwAgAEEBaiEAIAJBAWsiAg0ACwtBwIkGQbCJAiAGQQJ0IgD8CgAAQdCJCkGwiQIgAPwKAABB4IkOQbCJAiAA/AoAAEHwiRJBsIkCIAD8CgAAQYCKFkGwiQIgAPwKAAAgBCECDAELAkAgAEE7Rw0AQewIKAIAIgBBB0oNAEHsCCAAQQFqNgIAIABBAnRB8AhqQQA2AgALIAEhBwsgCCAJSQ0ACwtB5AggAzYCAEHgCCACNgIAQegIIAc2AgAL4gcCBX8BfgJAQdAIAn8CQAJAIAAgAU4NACABQZCJAWohBiAAQZCJAWohBQNAIAUtAAAiA0H/AHEhAgJAAkACQAJAAkACQAJAQeAIKAIAIgRBIkcEQCAEDQcgAkEiRgRAQewIQgE3AgBB4AhBIjYCAAwICyACQT9rQcAASQ0GIANBIWsiAkEMTQ0BDAULAkAgAkEwayIEQQlNBEBB7AgoAgBBAnRB7AhqIgIgBCACKAIAQQpsajYCAAwBC0HsCCgCACEEIAJBO0YEQCAEQQdKDQFB7AggBEEBajYCACAEQQJ0QfAIakEANgIADAELIARBBEYEQEHECEECNgIAQbAIQfAIKQMANwMAQbgIQfgIKAIAIgI2AgBBvAhB/AgoAgAiBDYCAEHICEECQQFBwAgoAgAiAxs2AgBBrAggBEEAIAMbNgIAQagIIAJBgIABIAJBgIABSBtBBGpBACADGzYCAEHgCEEANgIADAoLIAJBP2tBwABJDQQLIANBIWsiAkEMTQ0BDAILQQEgAnRBjSBxRQ0DDAQLQQEgAnRBjSBxDQELIANBoQFrIgJBDEsNA0EBIAJ0QY0gcUUNAwtBxAhCgYCAgBA3AgBBsAhB8AgoAgBBAEHsCCgCACICQQBKGzYCAEG0CEH0CCgCAEEAIAJBAUobNgIAQbgIQfgIKAIAQQAgAkECShs2AgBB4AhBADYCAEG8CEEANgIADAQLIANBoQFrIgJBDEsNAUEBIAJ0QY0gcUUNAQtBxAhCgYCAgBA3AgBBsAhCADcDAEG4CEIANwMADAMLIAVBAWoiBSAGSQ0ACwsCQEHICCgCAA4DAwEAAQsCQEGoCCgCACIFQQVIDQBBoAgpAwAhByAFQQNrQQF2IgNBB3EhBEEAIQIgA0EBa0EHTwRAIANB+P///wdxIQYDQCACQQN0IgNBsIkCaiAHNwMAIANBCHJBsIkCaiAHNwMAIANBEHJBsIkCaiAHNwMAIANBGHJBsIkCaiAHNwMAIANBIHJBsIkCaiAHNwMAIANBKHJBsIkCaiAHNwMAIANBMHJBsIkCaiAHNwMAIANBOHJBsIkCaiAHNwMAIAJBCGohAiAGQQhrIgYNAAsLIARFDQADQCACQQN0QbCJAmogBzcDACACQQFqIQIgBEEBayIEDQALC0HAiQZBsIkCIAVBAnQiA/wKAABB0IkKQbCJAiAD/AoAAEHgiQ5BsIkCIAP8CgAAQfCJEkGwiQIgA/wKAABBgIoWQbCJAiAD/AoAAEECDAELEAhByAgoAgALEAEiAjYCACACDQAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLdABB6AhBBDYCAEHkCCAANgIAQewIQgE3AgBBxAhCADcCAEHACCADNgIAQdwIQgA3AgBBqAhCADcDAEGwCEIANwMAQbgIQgA3AwBBzAggAkGAICACQYAgSRs2AgBBoAggAa1CgYCAgBB+NwMAQdAIQQA2AgALIwBB0AgoAgBFBEAgACABQcgIKAIAQQJ0QYAIaigCABEBAAsLWgECfwJAAkACQEHICCgCAEEBaw4CAAECC0HYCEHoCCgCACIAQdgIKAIAIgEgACABShsiAEGAgAEgAEGAgAFIGyIANgIAIABBBGsPC0GoCCgCAEEEayEACyAAC0IBAX8Cf0EGQdwIKAIAIgBBIHENABpBBSAAQRBxDQAaQQQgAEEIcQ0AGkEDIABBBHENABpBAiAAQQFxIABBAnEbCwu9BQEFfQJ/IAJFBEAgAUH/AWxBMmpB5ABtIgBBCHQgAHIgAEEQdHIMAQsgArJDAADIQpUhBiAAQfABarJDAAC0Q5UhBQJ9IAGyQwAAyEKVIgNDAAAAP10EQCADIAZDAACAP5KUDAELIAYgA0MAAIA/IAaTlJILIQcgAyADkiEGAkAgBUOrqqo+kiIEQwAAAABdBEAgBEMAAIA/kiEEDAELIARDAACAP15FDQAgBEMAAIC/kiEECyAGIAeTIQMgBUMAAAAAXSEAAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQECQCAABEAgBUMAAIA/kiEEDAELIAUiBEMAAIA/XkUNACAFQwAAgL+SIQQLIAVDq6qqvpIiBUMAAAAAXSECAn8CfSADIAcgA5NDAADAQJQgBJSSIARDq6oqPl0NABogByAEQwAAAD9dDQAaIAMgBEOrqio/XUUNABogAyAHIAOTIARDAADAwJRDAACAQJKUkgtDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALIQACQCACBEAgBUMAAIA/kiEFDAELIAVDAACAP15FDQAgBUMAAIC/kiEFCwJAIAVDq6oqPl0EQCADIAcgA5NDAADAQJQgBZSSIQcMAQsgBUMAAAA/XQ0AIAVDq6oqP11FBEAgAyEHDAELIAMgByADkyAFQwAAwMCUQwAAgECSlJIhBwsgAEEIdAJ/IAdDAAB/Q5RDAAAAP5IiBkMAAIBPXSAGQwAAAABgcQRAIAapDAELQQALQRB0ciABcgtBgICAeHILNwAgAEH/AWxBMmpB5ABtIAFB/wFsQTJqQeQAbUEIdHIgAkH/AWxBMmpB5ABtQRB0ckGAgIB4cgsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwsYAQBBgAgLEQEAAAACAAAAAwAAAAQAAAAF`}})),EM=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decodeAsync=e.decode=e.Decoder=e.DecoderAsync=void 0;var t=wM(),n=TM();function r(e){if(typeof Buffer<`u`)return Buffer.from(e,`base64`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<n.length;++e)n[e]=t.charCodeAt(e);return n}var i=r(n.LIMITS.BYTES),a,o=new Uint32Array,s=class{constructor(){this.bandHandler=e=>1,this.modeHandler=e=>1}handle_band(e){return this.bandHandler(e)}mode_parsed(e){return this.modeHandler(e)}},c={memoryLimit:134217728,sixelColor:t.DEFAULT_FOREGROUND,fillColor:t.DEFAULT_BACKGROUND,palette:t.PALETTE_VT340_COLOR,paletteLimit:n.LIMITS.PALETTE_SIZE,truncate:!0};function l(e){let t=new s,n={env:{handle_band:t.handle_band.bind(t),mode_parsed:t.mode_parsed.bind(t)}};return WebAssembly.instantiate(a||i,n).then(n=>(a||=n.module,new u(e,n.instance||n,t)))}e.DecoderAsync=l;var u=class{constructor(e,r,s){if(this._PIXEL_OFFSET=n.LIMITS.MAX_WIDTH+4,this._canvas=o,this._bandWidths=[],this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0,this._opts=Object.assign({},c,e),this._opts.paletteLimit>n.LIMITS.PALETTE_SIZE)throw Error(`DecoderOptions.paletteLimit must not exceed ${n.LIMITS.PALETTE_SIZE}`);if(r)s.bandHandler=this._handle_band.bind(this),s.modeHandler=this._initCanvas.bind(this);else{let e=a||=new WebAssembly.Module(i);r=new WebAssembly.Instance(e,{env:{handle_band:this._handle_band.bind(this),mode_parsed:this._initCanvas.bind(this)}})}this._instance=r,this._wasm=this._instance.exports,this._chunk=new Uint8Array(this._wasm.memory.buffer,this._wasm.get_chunk_address(),n.LIMITS.CHUNK_SIZE),this._states=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_state_address(),12),this._palette=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_palette_address(),n.LIMITS.PALETTE_SIZE),this._palette.set(this._opts.palette),this._pSrc=new Uint32Array(this._wasm.memory.buffer,this._wasm.get_p0_address()),this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}get _fillColor(){return this._states[0]}get _truncate(){return this._states[8]}get _rasterWidth(){return this._states[6]}get _rasterHeight(){return this._states[7]}get _width(){return this._states[2]?this._states[2]-4:0}get _height(){return this._states[3]}get _level(){return this._states[9]}get _mode(){return this._states[10]}get _paletteLimit(){return this._states[11]}_initCanvas(e){if(e===2){let e=this.width*this.height;if(e>this._canvas.length){if(this._opts.memoryLimit&&e*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);this._canvas=new Uint32Array(e)}this._maxWidth=this._width}else if(e===1){if(this._level===2){let e=Math.min(this._rasterWidth,n.LIMITS.MAX_WIDTH)*this._rasterHeight;if(e>this._canvas.length){if(this._opts.memoryLimit&&e*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);this._canvas=new Uint32Array(e)}}else this._canvas.length<65536&&(this._canvas=new Uint32Array(65536))}return 0}_realloc(e,t){let n=e+t;if(n>this._canvas.length){if(this._opts.memoryLimit&&n*4>this._opts.memoryLimit)throw this.release(),Error(`image exceeds memory limit`);let e=new Uint32Array(Math.ceil(n/65536)*65536);e.set(this._canvas),this._canvas=e}}_handle_band(e){let t=this._PIXEL_OFFSET,n=this._lastOffset;if(this._mode===2){let r=this.height-this._currentHeight,i=0;for(;i<6&&r>0;)this._canvas.set(this._pSrc.subarray(t*i,t*i+e),n+e*i),i++,r--;this._lastOffset+=e*i,this._currentHeight+=i}else if(this._mode===1){this._realloc(n,e*6),this._maxWidth=Math.max(this._maxWidth,e),this._minWidth=Math.min(this._minWidth,e);for(let r=0;r<6;++r)this._canvas.set(this._pSrc.subarray(t*r,t*r+e),n+e*r);this._bandWidths.push(e),this._lastOffset+=e*6,this._currentHeight+=6}return 0}get width(){return this._mode===1?Math.max(this._maxWidth,this._wasm.current_width()):this._width}get height(){return this._mode===1?this._wasm.current_width()?this._bandWidths.length*6+this._wasm.current_height():this._bandWidths.length*6:this._height}get palette(){return this._palette.subarray(0,this._paletteLimit)}get memoryUsage(){return this._canvas.byteLength+this._wasm.memory.buffer.byteLength+8*this._bandWidths.length}get properties(){return{width:this.width,height:this.height,mode:this._mode,level:this._level,truncate:!!this._truncate,paletteLimit:this._paletteLimit,fillColor:this._fillColor,memUsage:this.memoryUsage,rasterAttributes:{numerator:this._states[4],denominator:this._states[5],width:this._rasterWidth,height:this._rasterHeight}}}init(e=this._opts.fillColor,t=this._opts.palette,r=this._opts.paletteLimit,i=this._opts.truncate){this._wasm.init(this._opts.sixelColor,e,r,+!!i),t&&this._palette.set(t.subarray(0,n.LIMITS.PALETTE_SIZE)),this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._lastOffset=0,this._currentHeight=0}decode(e,t=0,r=e.length){let i=t;for(;i<r;){let t=Math.min(r-i,n.LIMITS.CHUNK_SIZE);this._chunk.set(e.subarray(i,i+=t)),this._wasm.decode(0,t)}}decodeString(e,t=0,r=e.length){let i=t;for(;i<r;){let t=Math.min(r-i,n.LIMITS.CHUNK_SIZE);for(let n=0,r=i;n<t;++n,++r)this._chunk[n]=e.charCodeAt(r);i+=t,this._wasm.decode(0,t)}}get data32(){if(this._mode===0||!this.width||!this.height)return o;let e=this._wasm.current_width();if(this._mode===2){let t=this.height-this._currentHeight;if(t>0){let n=this._PIXEL_OFFSET,r=this._lastOffset,i=0;for(;i<6&&t>0;)this._canvas.set(this._pSrc.subarray(n*i,n*i+e),r+e*i),i++,t--;t&&this._canvas.fill(this._fillColor,r+e*i)}return this._canvas.subarray(0,this.width*this.height)}if(this._mode===1){if(this._minWidth===this._maxWidth){let t=!1;if(e){if(e!==this._minWidth)t=!0;else{let t=this._PIXEL_OFFSET,n=this._lastOffset;this._realloc(n,e*6);for(let r=0;r<6;++r)this._canvas.set(this._pSrc.subarray(t*r,t*r+e),n+e*r)}}if(!t)return this._canvas.subarray(0,this.width*this.height)}let t=new Uint32Array(this.width*this.height);t.fill(this._fillColor);let n=0,r=0;for(let e=0;e<this._bandWidths.length;++e){let i=this._bandWidths[e];for(let e=0;e<6;++e)t.set(this._canvas.subarray(r,r+=i),n),n+=this.width}if(e){let r=this._PIXEL_OFFSET,i=this._wasm.current_height();for(let a=0;a<i;++a)t.set(this._pSrc.subarray(r*a,r*a+e),n+this.width*a)}return t}return o}get data8(){return new Uint8ClampedArray(this.data32.buffer,0,this.width*this.height*4)}release(){this._canvas=o,this._bandWidths.length=0,this._maxWidth=0,this._minWidth=n.LIMITS.MAX_WIDTH,this._wasm.init(t.DEFAULT_FOREGROUND,0,this._opts.paletteLimit,0)}};e.Decoder=u;function d(e,t){let n=new u(t);return n.init(),typeof e==`string`?n.decodeString(e):n.decode(e),{width:n.width,height:n.height,data32:n.data32,data8:n.data8}}e.decode=d;async function f(e,t){let n=await l(t);return n.init(),typeof e==`string`?n.decodeString(e):n.decode(e),{width:n.width,height:n.height,data32:n.data32,data8:n.data8}}e.decodeAsync=f})),DM=wM(),OM=EM(),kM=DM.PALETTE_ANSI_256.slice();kM.set(DM.PALETTE_VT340_COLOR);var AM=200,jM=new TextEncoder,MM=`offsite-image:`;async function NM(e){let t=await(0,OM.decodeAsync)(e,{fillColor:0,palette:kM});return!t.width||!t.height?null:createImageBitmap(new ImageData(new Uint8ClampedArray(t.data8),t.width,t.height))}function PM(e,t,n){return e===void 0||e===`auto`?0:e.endsWith(`%`)?parseInt(e.slice(0,-1))*t/100:e.endsWith(`px`)?parseInt(e.slice(0,-2)):parseInt(e)*n}async function FM(e,t){let n=e.indexOf(`:`);if(n===-1)return null;let r=new Map(e.slice(0,n).split(`;`).map(e=>{let t=e.indexOf(`=`);return[e.slice(0,t),e.slice(t+1)]}));if(r.get(`inline`)!==`1`)return null;let i=Uint8Array.from(atob(e.slice(n+1)),e=>e.charCodeAt(0)),a=await createImageBitmap(new Blob([i])),o=PM(r.get(`width`),t.width,t.cellWidth),s=PM(r.get(`height`),t.height,t.cellHeight),c=[a.width,a.height];if(!o&&!s){let e=Math.min(t.width/a.width,(t.height-t.cellHeight)/a.height);e<1&&(c=[a.width*e,a.height*e])}else c=o?r.get(`preserveAspectRatio`)!==`0`||!s?[o,a.height*o/a.width]:[o,s]:[a.width*s/a.height,s];let[l,u]=c.map(e=>Math.max(1,Math.floor(e*t.pixelRatio))),d=await createImageBitmap(a,{resizeWidth:l,resizeHeight:u});return a.close(),d}function IM(e){let t=CM(e),{width:n,height:r,depth:i,channels:a}=t,o=n*r,s=new Uint8Array(o*4);if(t.palette){let e=xM(t),i=t.palette[0].length;for(let t=0;t<o;t+=1)s.set(e.subarray(t*i,t*i+3),t*4),s[t*4+3]=i===4?e[t*i+3]:255;return{width:n,height:r,data:s}}let c=2**i-1,l=Math.ceil(n*i/8);function u(e){if(i>=8)return t.data[e];let r=e%n*i;return t.data[Math.floor(e/n)*l+(r>>3)]>>8-i-(r&7)&c}function d(e){return i===16?e>>8:i===8?e:Math.round(e*255/c)}let f=t.transparency;for(let e=0;e<o;e+=1){let t=e*4;if(a===1||a===2){let n=u(e*a);s.fill(d(n),t,t+3),s[t+3]=a===2?d(u(e*2+1)):f?.[0]===n?0:255}else if(a===3||a===4){let n=u(e*a),r=u(e*a+1),i=u(e*a+2);s[t]=d(n),s[t+1]=d(r),s[t+2]=d(i),s[t+3]=a===4?d(u(e*4+3)):f?.[0]===n&&f[1]===r&&f[2]===i?0:255}else throw Error(`unsupported PNG with ${a} channels`)}return{width:n,height:r,data:s}}var LM=class{core;images=[];nextImage=0;constructor(e){this.core=e}place(e,t,n){let r=`${MM}${this.nextImage++}`;this.core.write(jM.encode(`\x1b]8;;${r}\x1b\\ \x1b]8;;\x1b\\\b`));let i={ref:this.core.trackCursor(),marker:r,bitmap:e,width:e.width/t,height:e.height/t,alternate:this.core.isAlternateScreen()};if(this.images.push(i),this.images.length>AM){let e=this.images.shift();e&&this.remove(e)}let a=Math.ceil(i.height/n);a>1&&this.core.write(jM.encode(`\x1BD`.repeat(a-1)))}visible(e,t,n){if(this.images.length===0)return[];let r=this.core.isAlternateScreen(),i=[],a=[];for(let o of this.images){if(o.alternate!==r){a.push(o);continue}let s=this.core.trackedPoint(o.ref);if(s===null||this.core.trackedHyperlink(o.ref)!==o.marker){this.remove(o);continue}a.push(o);let c=s.y-e;c+Math.ceil(o.height/n)<=0||c>=t||i.push({bitmap:o.bitmap,width:o.width,height:o.height,x:s.x,y:c})}return this.images=a,i}clear(){for(let e of this.images)this.remove(e);this.images=[]}remove(e){this.core.untrack(e.ref),e.bitmap.close()}},RM=Fe.withTag(`terminal`),zM=new Uint8Array([0,97,115,109,1,0,0,0,1,35,5,96,4,127,127,127,127,0,96,3,127,127,127,1,127,96,2,127,127,0,96,3,127,127,127,0,96,5,127,127,127,127,127,1,127,2,49,6,3,101,110,118,1,119,0,0,3,101,110,118,1,100,0,1,3,101,110,118,1,115,0,1,3,101,110,118,1,98,0,2,3,101,110,118,1,118,0,3,3,101,110,118,1,112,0,4,7,25,6,1,119,0,0,1,100,0,1,1,115,0,2,1,98,0,3,1,118,0,4,1,112,0,5]),BM={userdata:0,writePty:1,bell:2,xtversion:4,size:6,deviceAttributes:8},VM=1,HM=-3,UM={width:0,height:4,data:8,length:12},WM=new TextDecoder,GM=new TextEncoder,KM=class e{memory;layouts;exports;memoryView;hosts=new Map;nextHostId=1;callbacks={writePty:0,deviceAttributes:0,size:0,bell:0,xtversion:0};version={pointer:0,size:0};constructor(e){this.exports=e.exports;let t=e.exports.memory;if(!(t instanceof WebAssembly.Memory))throw Error(`libghostty-vt did not export its memory`);this.memory=t,this.memoryView=new DataView(t.buffer);let n=this.call(`ghostty_type_json`),r=new Uint8Array(t.buffer),i=n;for(;i<r.length&&r[i]!==0;)i+=1;this.layouts=JSON.parse(WM.decode(r.subarray(n,i)))}static async load(){let t=await fetch(KA);if(!t.ok)throw Error(`could not load libghostty-vt (${t.status})`);let n=null,r=await WebAssembly.instantiate(await t.arrayBuffer(),{env:{log:(e,t)=>{n&&RM.debug(`[libghostty-vt]`,WM.decode(new Uint8Array(n.buffer,e,t)))}}}),i=new e(r.instance);return n=i.memory,i.installCallbacks(),i}call(e,...t){let n=this.exports[e];if(typeof n!=`function`)throw Error(`libghostty-vt export is missing: ${e}`);return n(...t)}layout(e){let t=this.layouts[e];if(!t)throw Error(`libghostty-vt layout is missing: ${e}`);return t}field(e,t){let n=this.layout(e).fields[t];if(!n)throw Error(`libghostty-vt field is missing: ${e}.${t}`);return n}alloc(e){let t=this.call(`ghostty_wasm_alloc_u8_array`,e);if(t===0)throw Error(`libghostty-vt could not allocate ${e} bytes`);return new Uint8Array(this.memory.buffer,t,e).fill(0),t}free(e,t){e!==0&&this.call(`ghostty_wasm_free_u8_array`,e,t)}allocOpaque(){let e=this.call(`ghostty_wasm_alloc_opaque`);if(e===0)throw Error(`libghostty-vt could not allocate a pointer`);return new DataView(this.memory.buffer).setUint32(e,0,!0),e}freeOpaque(e){e!==0&&this.call(`ghostty_wasm_free_opaque`,e)}readPointer(e){return this.dataView().getUint32(e,!0)}check(e,t){if(t!==0)throw Error(`${e} failed with result ${t}`)}flag(e,t,n){let r=this.alloc(1),i=this.call(e,t,n,r),a=this.bytes(r,1)[0];return this.free(r,1),i===0&&a!==0}encodeOutput(e){let t=this.call(`ghostty_wasm_alloc_usize`),n=``,r=e(0,0,t),i=this.view(t,4).getUint32(0,!0);if(r===HM&&i>0){let r=this.alloc(i),a=e(r,i,t),o=this.view(t,4).getUint32(0,!0);a===0&&(n=WM.decode(this.bytes(r,o))),this.free(r,i)}return this.call(`ghostty_wasm_free_usize`,t),n}attachHost(e,t){let n=this.nextHostId++;this.hosts.set(n,t),this.call(`ghostty_terminal_set`,e,BM.userdata,n);for(let t of[[BM.writePty,this.callbacks.writePty],[BM.deviceAttributes,this.callbacks.deviceAttributes],[BM.size,this.callbacks.size],[BM.bell,this.callbacks.bell],[BM.xtversion,this.callbacks.xtversion]])this.call(`ghostty_terminal_set`,e,t[0],t[1]);return n}detachHost(e,t){this.call(`ghostty_terminal_set`,e,BM.xtversion,0),this.call(`ghostty_terminal_set`,e,BM.bell,0),this.call(`ghostty_terminal_set`,e,BM.size,0),this.call(`ghostty_terminal_set`,e,BM.deviceAttributes,0),this.call(`ghostty_terminal_set`,e,BM.writePty,0),this.call(`ghostty_terminal_set`,e,BM.userdata,0),this.hosts.delete(t)}view(e,t){return new DataView(this.memory.buffer,e,t)}bytes(e,t){return new Uint8Array(this.memory.buffer,e,t)}dataView(){return this.memoryView.buffer!==this.memory.buffer&&(this.memoryView=new DataView(this.memory.buffer)),this.memoryView}setField(e,t,n,r){let i=this.field(t,n),a=this.dataView(),o=e+i.offset;if(i.type===`bool`||i.type===`u8`)a.setUint8(o,r);else if(i.type===`u16`)a.setUint16(o,r,!0);else if(i.type===`i32`)a.setInt32(o,r,!0);else if(i.type===`u32`||i.type===`enum`)a.setUint32(o,r,!0);else if(i.type===`u64`)a.setBigUint64(o,BigInt(r),!0);else throw Error(`unsupported libghostty-vt field type ${i.type}`)}readField(e,t,n){let r=this.field(t,n),i=this.dataView(),a=e+r.offset;if(r.type===`bool`||r.type===`u8`)return i.getUint8(a);if(r.type===`u16`)return i.getUint16(a,!0);if(r.type===`i32`)return i.getInt32(a,!0);if(r.type===`u32`||r.type===`enum`)return i.getUint32(a,!0);if(r.type===`u64`)return Number(i.getBigUint64(a,!0));throw Error(`unsupported libghostty-vt field type ${r.type}`)}installCallbacks(){let e=new WebAssembly.Instance(new WebAssembly.Module(zM),{env:{w:(e,t,n,r)=>{let i=this.hosts.get(t);i&&r!==0&&i.write(WM.decode(new Uint8Array(this.memory.buffer,n,r)))},d:(e,t,n)=>this.hosts.has(t)?(this.writeDeviceAttributes(n),1):0,s:(e,t,n)=>{let r=this.hosts.get(t);if(!r)return 0;let i=r.size(),a=`GhosttySizeReportSize`;return this.setField(n,a,`rows`,i.rows),this.setField(n,a,`columns`,i.columns),this.setField(n,a,`cell_width`,i.cellWidth),this.setField(n,a,`cell_height`,i.cellHeight),1},b:(e,t)=>{this.hosts.get(t)?.bell()},v:(e,t,n)=>{let r=this.hosts.get(n);r&&this.writeVersion(e,r.version())},p:(e,t,n,r,i)=>this.decodePng(t,n,r,i)}}),t=this.exports.__indirect_function_table;if(!(t instanceof WebAssembly.Table))throw Error(`libghostty-vt did not expose its callback table`);let n=[`w`,`d`,`s`,`b`,`v`,`p`].map(n=>{let r=e.exports[n];if(typeof r!=`function`)throw Error(`libghostty-vt callback is missing: ${n}`);let i=t.length;return t.grow(1),t.set(i,r),i});if(this.callbacks={writePty:n[0],deviceAttributes:n[1],size:n[2],bell:n[3],xtversion:n[4]},this.call(`ghostty_sys_set`,VM,n[5])!==0)throw Error(`libghostty-vt did not accept the PNG decoder`)}decodePng(e,t,n,r){let i;try{i=IM(new Uint8Array(this.memory.buffer,t,n))}catch(e){return RM.warn(`could not decode a kitty PNG image`,e),0}let a=this.call(`ghostty_alloc`,e,i.data.length);if(a===0)return 0;this.bytes(a,i.data.length).set(i.data);let o=this.dataView();return o.setUint32(r+UM.width,i.width,!0),o.setUint32(r+UM.height,i.height,!0),o.setUint32(r+UM.data,a,!0),o.setUint32(r+UM.length,i.data.length,!0),1}writeVersion(e,t){let n=GM.encode(t);this.free(this.version.pointer,this.version.size);let r=this.alloc(n.length);this.bytes(r,n.length).set(n),this.version={pointer:r,size:n.length},this.dataView().setUint32(e+this.field(`GhosttyString`,`ptr`).offset,r,!0),this.setField(e,`GhosttyString`,`len`,n.length)}writeDeviceAttributes(e){let t=e+this.field(`GhosttyDeviceAttributes`,`primary`).offset,n=e+this.field(`GhosttyDeviceAttributes`,`secondary`).offset,r=e+this.field(`GhosttyDeviceAttributes`,`tertiary`).offset,i=`GhosttyDeviceAttributesPrimary`,a=`GhosttyDeviceAttributesSecondary`,o=t+this.field(i,`features`).offset,s=this.dataView(),c=[4,22];c.forEach((e,t)=>s.setUint16(o+t*2,e,!0)),this.setField(t,i,`conformance_level`,62),this.setField(t,i,`num_features`,c.length),this.setField(n,a,`device_type`,0),this.setField(n,a,`firmware_version`,276),this.setField(n,a,`rom_cartridge`,0),this.setField(r,`GhosttyDeviceAttributesTertiary`,`unit_id`,0)}},qM=null;async function JM(){qM=await KM.load()}function YM(){if(!qM)throw Error(`libghostty-vt is not loaded`);return qM}var XM=new Map(`Unidentified.Backquote.Backslash.BracketLeft.BracketRight.Comma.Digit0.Digit1.Digit2.Digit3.Digit4.Digit5.Digit6.Digit7.Digit8.Digit9.Equal.IntlBackslash.IntlRo.IntlYen.KeyA.KeyB.KeyC.KeyD.KeyE.KeyF.KeyG.KeyH.KeyI.KeyJ.KeyK.KeyL.KeyM.KeyN.KeyO.KeyP.KeyQ.KeyR.KeyS.KeyT.KeyU.KeyV.KeyW.KeyX.KeyY.KeyZ.Minus.Period.Quote.Semicolon.Slash.AltLeft.AltRight.Backspace.CapsLock.ContextMenu.ControlLeft.ControlRight.Enter.MetaLeft.MetaRight.ShiftLeft.ShiftRight.Space.Tab.Convert.KanaMode.NonConvert.Delete.End.Help.Home.Insert.PageDown.PageUp.ArrowDown.ArrowLeft.ArrowRight.ArrowUp.NumLock.Numpad0.Numpad1.Numpad2.Numpad3.Numpad4.Numpad5.Numpad6.Numpad7.Numpad8.Numpad9.NumpadAdd.NumpadBackspace.NumpadClear.NumpadClearEntry.NumpadComma.NumpadDecimal.NumpadDivide.NumpadEnter.NumpadEqual.NumpadMemoryAdd.NumpadMemoryClear.NumpadMemoryRecall.NumpadMemoryStore.NumpadMemorySubtract.NumpadMultiply.NumpadParenLeft.NumpadParenRight.NumpadSubtract.NumpadSeparator.NumpadArrowUp.NumpadArrowDown.NumpadArrowRight.NumpadArrowLeft.NumpadBegin.NumpadHome.NumpadEnd.NumpadInsert.NumpadDelete.NumpadPageUp.NumpadPageDown.Escape.F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12.F13.F14.F15.F16.F17.F18.F19.F20.F21.F22.F23.F24.F25.Fn.FnLock.PrintScreen.ScrollLock.Pause.BrowserBack.BrowserFavorites.BrowserForward.BrowserHome.BrowserRefresh.BrowserSearch.BrowserStop.Eject.LaunchApp1.LaunchApp2.LaunchMail.MediaPlayPause.MediaSelect.MediaStop.MediaTrackNext.MediaTrackPrevious.Power.Sleep.AudioVolumeDown.AudioVolumeMute.AudioVolumeUp.WakeUp.Copy.Cut.Paste`.split(`.`).map((e,t)=>[e,t]));function ZM(e){return XM.get(e)??0}var QM=new Map([[`!`,`1`],[`@`,`2`],[`#`,`3`],[`$`,`4`],[`%`,`5`],[`^`,`6`],[`&`,`7`],[`*`,`8`],[`(`,`9`],[`)`,`0`],[`~`,"`"],[`_`,`-`],[`+`,`=`],[`{`,`[`],[`}`,`]`],[`|`,`\\`],[`:`,`;`],[`"`,`'`],[`<`,`,`],[`>`,`.`],[`?`,`/`]]),$M;function eN(){return $M||($M=globalThis.navigator?.keyboard?.getLayoutMap().catch(()=>void 0)??Promise.resolve(void 0),$M)}function tN(){return $M=void 0,eN()}function nN(e){return!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey?0:+([...e.key].length===1)}function rN(e,t){if([...e.key].length!==1)return 0;let n=t?.get(e.code);if(n&&[...n].length===1)return n.codePointAt(0)??0;if(/^[A-Z]$/u.test(e.key))return e.key.charCodeAt(0)+32;if(e.shiftKey){let t=QM.get(e.key);if(t)return t.codePointAt(0)??0;let n=e.key.toLowerCase();return n!==e.key&&[...n].length===1?n.codePointAt(0)??0:0}return e.key.codePointAt(0)??0}var iN=new Map([[`Backquote`,"`"],[`Minus`,`-`],[`Equal`,`=`],[`BracketLeft`,`[`],[`BracketRight`,`]`],[`Backslash`,`\\`],[`Semicolon`,`;`],[`Quote`,`'`],[`Comma`,`,`],[`Period`,`.`],[`Slash`,`/`],[`Space`,` `]]),aN=[...`0123456789`].map(e=>[`Digit${e}`,e]),oN=new Map([...QM].map(e=>[e[1],e[0]]));function sN(e){return/^Key[A-Z]$/u.test(e)?e[3].toLowerCase():/^Digit[0-9]$/u.test(e)?e[5]:iN.get(e)}function cN(e){return[...iN,...aN].every(t=>t[0]===`Space`||e.get(t[0])===t[1])}function lN(e,t){let n=t?.get(e.code),r=n&&[...n].length===1?n:sN(e.code);if(r===void 0)return[...e.key].length===1?null:e.key;if(!e.shiftKey)return r;let i=r.toUpperCase();return i!==r&&[...i].length===1?i:t===void 0||!cN(t)?null:oN.get(r)??r}var uN=new TextEncoder,dN=new Map([[`[`,`\x1B`],[`m`,`\r`],[`i`,` `],[`@`,`\0`]]),fN=class{runtime=YM();terminal;keyEncoderSlot;keyEncoder;keyEventSlot;keyEvent;mouseEncoderSlot;mouseEncoder;mouseEventSlot;mouseEvent;scratch;keyboardLayoutMap;constructor(e){let t=this.runtime;this.terminal=e,this.loadKeyboardLayout(eN()),this.keyEncoderSlot=t.allocOpaque(),t.check(`ghostty_key_encoder_new`,t.call(`ghostty_key_encoder_new`,0,this.keyEncoderSlot)),this.keyEncoder=t.readPointer(this.keyEncoderSlot),this.keyEventSlot=t.allocOpaque(),t.check(`ghostty_key_event_new`,t.call(`ghostty_key_event_new`,0,this.keyEventSlot)),this.keyEvent=t.readPointer(this.keyEventSlot),this.mouseEncoderSlot=t.allocOpaque(),t.check(`ghostty_mouse_encoder_new`,t.call(`ghostty_mouse_encoder_new`,0,this.mouseEncoderSlot)),this.mouseEncoder=t.readPointer(this.mouseEncoderSlot),this.mouseEventSlot=t.allocOpaque(),t.check(`ghostty_mouse_event_new`,t.call(`ghostty_mouse_event_new`,0,this.mouseEventSlot)),this.mouseEvent=t.readPointer(this.mouseEventSlot),this.scratch=t.alloc(1)}encodeKey(e,t=`press`,n=!1){let r=this.runtime,i=e.key.toLowerCase(),a=dN.get(i);if(a!==void 0&&t===`press`&&e.ctrlKey&&!e.altKey&&!e.metaKey&&!(e.shiftKey&&/^[a-z]$/u.test(i))&&!r.flag(`ghostty_terminal_get`,this.terminal,8))return a;let o=n?this.metaText(e):null,s=o??e.key;if(o!==null&&t===`press`&&!e.ctrlKey&&[...s].length===1&&(s.codePointAt(0)??0)>127&&r.flag(`ghostty_terminal_mode_get`,this.terminal,1036)&&this.isLegacyKeyboard())return`\x1b${s}`;r.call(`ghostty_key_encoder_setopt_from_terminal`,this.keyEncoder,this.terminal),r.call(`ghostty_key_event_set_action`,this.keyEvent,t===`release`?0:e.repeat?2:1),r.call(`ghostty_key_event_set_key`,this.keyEvent,ZM(e.code));let c=+!!e.shiftKey|(e.ctrlKey?2:0)|(e.altKey?4:0)|(e.metaKey?8:0)|(e.getModifierState(`CapsLock`)?16:0)|(e.getModifierState(`NumLock`)?32:0);r.call(`ghostty_key_event_set_mods`,this.keyEvent,c),r.call(`ghostty_key_event_set_consumed_mods`,this.keyEvent,nN(e)),r.call(`ghostty_key_event_set_composing`,this.keyEvent,+!!e.isComposing),r.call(`ghostty_key_event_set_unshifted_codepoint`,this.keyEvent,rN({code:e.code,key:s,shiftKey:e.shiftKey},this.keyboardLayoutMap));let l=uN.encode(s.length===1?s:``),u=l.length===0?0:r.alloc(l.length);u!==0&&r.bytes(u,l.length).set(l),r.call(`ghostty_key_event_set_utf8`,this.keyEvent,u,l.length);let d=r.encodeOutput((e,t,n)=>r.call(`ghostty_key_encoder_encode`,this.keyEncoder,this.keyEvent,e,t,n));return u!==0&&r.free(u,l.length),d}metaText(e){return lN(e,this.keyboardLayoutMap)}refreshKeyboardLayout(){this.loadKeyboardLayout(tN())}encodePaste(e){let t=this.runtime,n=uN.encode(e);if(n.length===0)return``;let r=t.alloc(n.length);t.bytes(r,n.length).set(n);let i=+!!t.flag(`ghostty_terminal_mode_get`,this.terminal,2004),a=t.encodeOutput((e,a,o)=>t.call(`ghostty_paste_encode`,r,n.length,i,e,a,o));return t.free(r,n.length),a}encodeMouse(e){let t=this.runtime;t.call(`ghostty_mouse_encoder_setopt_from_terminal`,this.mouseEncoder,this.terminal);let n=t.layout(`GhosttyMouseEncoderSize`),r=t.alloc(n.size);for(let i of[[`size`,n.size],[`screen_width`,e.screenWidth],[`screen_height`,e.screenHeight],[`cell_width`,e.cellWidth],[`cell_height`,e.cellHeight],[`padding_top`,0],[`padding_bottom`,0],[`padding_right`,0],[`padding_left`,0]])t.setField(r,`GhosttyMouseEncoderSize`,i[0],Math.max(0,Math.round(i[1])));t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,2,r),t.free(r,n.size),t.bytes(this.scratch,1)[0]=+!!e.anyButtonPressed,t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,3,this.scratch),t.bytes(this.scratch,1)[0]=1,t.call(`ghostty_mouse_encoder_setopt`,this.mouseEncoder,4,this.scratch),t.call(`ghostty_mouse_event_set_action`,this.mouseEvent,{press:0,release:1,motion:2}[e.action]),e.button===null?t.call(`ghostty_mouse_event_clear_button`,this.mouseEvent):t.call(`ghostty_mouse_event_set_button`,this.mouseEvent,e.button),t.call(`ghostty_mouse_event_set_mods`,this.mouseEvent,e.mods);let i=t.layout(`GhosttyMousePosition`),a=t.alloc(i.size),o=t.view(a,i.size);return o.setFloat32(t.field(`GhosttyMousePosition`,`x`).offset,e.x,!0),o.setFloat32(t.field(`GhosttyMousePosition`,`y`).offset,e.y,!0),t.call(`ghostty_mouse_event_set_position`,this.mouseEvent,a),t.free(a,i.size),t.encodeOutput((e,n,r)=>t.call(`ghostty_mouse_encoder_encode`,this.mouseEncoder,this.mouseEvent,e,n,r))}dispose(){let e=this.runtime;e.call(`ghostty_mouse_event_free`,this.mouseEvent),e.call(`ghostty_mouse_encoder_free`,this.mouseEncoder),e.call(`ghostty_key_event_free`,this.keyEvent),e.call(`ghostty_key_encoder_free`,this.keyEncoder),e.free(this.scratch,1),e.freeOpaque(this.mouseEventSlot),e.freeOpaque(this.mouseEncoderSlot),e.freeOpaque(this.keyEventSlot),e.freeOpaque(this.keyEncoderSlot)}async loadKeyboardLayout(e){this.keyboardLayoutMap=await e}isLegacyKeyboard(){return this.encodeKey(new KeyboardEvent(`keydown`,{key:`Tab`,code:`Tab`,shiftKey:!0}))===`\x1B[Z`}},pN=26,mN=30,hN=1,gN={imageId:1,placementId:2,isVirtual:3,xOffset:4,yOffset:5,columns:10,rows:11,z:12},_N={width:3,height:4,format:5,data:7,length:8},vN={size:48,pixelWidth:4,pixelHeight:8,column:20,row:24,visible:28,sourceX:32,sourceY:36,sourceWidth:40,sourceHeight:44},yN=new Map([[0,3],[1,4],[3,2],[4,1]]),bN=new Map([773,781,782,784,786,829,830,831,838,842,843,844,848,849,850,855,859,867,868,869,870,871,872,873,874,875,876,877,878,879,1155,1156,1157,1158,1159,1426,1427,1428,1429,1431,1432,1433,1436,1437,1438,1439,1440,1441,1448,1449,1451,1452,1455,1476,1552,1553,1554,1555,1556,1557,1558,1559,1623,1624,1625,1626,1627,1629,1630,1750,1751,1752,1753,1754,1755,1756,1759,1760,1761,1762,1764,1767,1768,1771,1772,1840,1842,1843,1845,1846,1850,1853,1855,1856,1857,1859,1861,1863,1865,1866,2027,2028,2029,2030,2031,2032,2033,2035,2070,2071,2072,2073,2075,2076,2077,2078,2079,2080,2081,2082,2083,2085,2086,2087,2089,2090,2091,2092,2093,2385,2387,2388,3970,3971,3974,3975,4957,4958,4959,6109,6458,6679,6773,6774,6775,6776,6777,6778,6779,6780,7019,7021,7022,7023,7024,7025,7026,7027,7376,7377,7378,7386,7387,7392,7616,7617,7619,7620,7621,7622,7623,7624,7625,7627,7628,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643,7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7678,8400,8401,8404,8405,8406,8407,8411,8412,8417,8423,8425,8432,11503,11504,11505,11744,11745,11746,11747,11748,11749,11750,11751,11752,11753,11754,11755,11756,11757,11758,11759,11760,11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,11771,11772,11773,11774,11775,42607,42620,42621,42736,42737,43232,43233,43234,43235,43236,43237,43238,43239,43240,43241,43242,43243,43244,43245,43246,43247,43248,43249,43696,43698,43699,43703,43704,43710,43711,43713,65056,65057,65058,65059,65060,65061,65062,68111,68152,119173,119174,119175,119176,119177,119210,119211,119212,119213,119362,119363,119364].map((e,t)=>[e,t]));function xN(e,t,n){let r=Array.from(e).slice(1,4).map(e=>bN.get(e.codePointAt(0)??0)??null),i=r[2]??null;return{imageId:t,placementId:n,row:r[0]??null,column:r[1]??null,imageIdHigh:i!==null&&i<256?i:null}}function SN(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n].cells,i=null;for(let e=0;e<r.length;e+=1){let a=r[e].placeholder;i!==null&&a!==null&&a.imageId===i.imageId&&a.placementId===i.placementId&&(a.row===null||a.row===i.row)&&(a.column===null||a.column===i.column+i.width)&&(a.imageIdHigh===null||a.imageIdHigh===i.imageIdHigh)?i.width+=1:(i!==null&&t.push(CN(i)),i=a===null?null:{x:e,y:n,imageId:a.imageId,imageIdHigh:a.imageIdHigh,placementId:a.placementId,row:a.row??0,column:a.column??0,width:1})}i!==null&&t.push(CN(i))}return t}function CN(e){return{x:e.x,y:e.y,imageId:e.imageId+(e.imageIdHigh??0)*2**24,placementId:e.placementId,row:e.row,column:e.column,width:e.width}}function wN(e,t,n,r){let i=t.columns===0?Math.ceil(n.width/r.width):t.columns,a=t.rows===0?Math.ceil(n.height/r.height):t.rows,o=i*r.width,s=a*r.height,c=n.width*s>n.height*o,l=c?o/Math.max(n.width,1):s/Math.max(n.height,1),u=c?0:(o-n.width*l)/2/l,d=c?(s-n.height*l)/2/l:0,f=n.width+u*2,p=n.height+d*2,m={x:f*e.column/i,y:p*e.row/a,width:f*e.width/i,height:p/a},h=0,g=0,_=e.width*r.width,v=r.height;if(m.y<d){let e=d-m.y;m.height-=e,g=e,v-=e*l,m.y=0,m.height>n.height&&(m.height=n.height,v=n.height*l)}else m.y+m.height>p-d?(m.y-=d,m.height=p-d-m.y-d,v=m.height*l):m.y-=d;if(m.x<u){let e=u-m.x;m.width-=e,h=e,_-=e*l,m.x=0,m.width>n.width&&(m.width=n.width,_=n.width*l)}else m.x+m.width>f-u?(m.x-=u,m.width=f-u-m.x-u,_=m.width*l):m.x-=u;if(m.width<=0||m.height<=0)return null;let y={xOffset:Math.round(h*l),yOffset:Math.round(g*l),width:Math.round(_),height:Math.round(v),source:{x:Math.round(m.x),y:Math.round(m.y),width:Math.round(m.width),height:Math.round(m.height)}};return y.width===0||y.height===0?null:y}function TN(e){let t=YM(),n=t.alloc(16),r=t.call(`ghostty_terminal_get`,e,pN,n);return t.free(n,16),r===0}var EN=class{runtime=YM();terminal;iteratorSlot;info;scratch;tail=[0,0];commands=0;cachedCommands=0;bitmaps=new Map;constructor(e){let t=this.runtime;this.terminal=e,this.iteratorSlot=t.allocOpaque(),t.check(`ghostty_kitty_graphics_placement_iterator_new`,t.call(`ghostty_kitty_graphics_placement_iterator_new`,0,this.iteratorSlot)),this.info=t.alloc(vN.size),this.scratch=t.alloc(16)}note(e){let t=[...this.tail,...e.subarray(0,2)],n=t.some((e,n)=>e===27&&t[n+1]===95&&t[n+2]===71),r=e.indexOf(27);for(;!n&&r!==-1;)n=e[r+1]===95&&e[r+2]===71,r=e.indexOf(27,r+1);n&&(this.commands+=1),this.tail=[...this.tail,...e.subarray(-2)].slice(-2)}images(e,t){this.commands!==this.cachedCommands&&(this.cachedCommands=this.commands,this.bitmaps.clear());let n=new Map,r=this.placements(e,t).map(e=>{let t=n.get(e.key)??this.bitmaps.get(e.key)??kN(e.image);return n.set(e.key,t),{placement:e,bitmap:t}});return this.bitmaps=n,r}dispose(){let e=this.runtime;e.call(`ghostty_kitty_graphics_placement_iterator_free`,e.readPointer(this.iteratorSlot)),e.free(this.info,vN.size),e.free(this.scratch,16),e.freeOpaque(this.iteratorSlot),this.bitmaps.clear()}placements(e,t){let n=this.runtime;n.check(`ghostty_terminal_get`,n.call(`ghostty_terminal_get`,this.terminal,mN,this.scratch));let r=n.readPointer(this.scratch);n.check(`ghostty_kitty_graphics_get`,n.call(`ghostty_kitty_graphics_get`,r,hN,this.iteratorSlot));let i=n.readPointer(this.iteratorSlot),a=[],o=[];for(;n.call(`ghostty_kitty_graphics_placement_next`,i);){let e=this.placementU32(i,gN.imageId);if(this.placementData(i,gN.isVirtual).getUint8(0)){o.push({imageId:e,placementId:this.placementU32(i,gN.placementId),columns:this.placementU32(i,gN.columns),rows:this.placementU32(i,gN.rows)});continue}let t=n.call(`ghostty_kitty_graphics_image`,r,e);if(t===0)throw Error(`kitty placement points to missing image ${e}`);n.bytes(this.info,vN.size).fill(0);let s=n.view(this.info,vN.size);s.setUint32(0,vN.size,!0),n.check(`ghostty_kitty_graphics_placement_render_info`,n.call(`ghostty_kitty_graphics_placement_render_info`,i,t,this.terminal,this.info)),s.getUint8(vN.visible)!==0&&a.push({...this.image(t,e),z:this.placementData(i,gN.z).getInt32(0,!0),column:s.getInt32(vN.column,!0),row:s.getInt32(vN.row,!0),xOffset:this.placementU32(i,gN.xOffset),yOffset:this.placementU32(i,gN.yOffset),width:s.getUint32(vN.pixelWidth,!0),height:s.getUint32(vN.pixelHeight,!0),source:{x:s.getUint32(vN.sourceX,!0),y:s.getUint32(vN.sourceY,!0),width:s.getUint32(vN.sourceWidth,!0),height:s.getUint32(vN.sourceHeight,!0)}})}if(o.length===0)return a;for(let i of SN(e)){let e=o.find(e=>e.imageId===i.imageId&&(i.placementId===0||e.placementId===i.placementId));if(e===void 0)continue;let s=n.call(`ghostty_kitty_graphics_image`,r,i.imageId);if(s===0)continue;let c=this.image(s,i.imageId),l=wN(i,e,c.image,t);l!==null&&a.push({...c,...l,z:-1,column:i.x,row:i.y})}return a}image(e,t){let n=this.imageData(e,_N.data),r=this.imageData(e,_N.length);return{key:`${t}:${n}:${r}`,image:{width:this.imageData(e,_N.width),height:this.imageData(e,_N.height),format:this.imageData(e,_N.format),pixels:this.runtime.bytes(n,r)}}}placementData(e,t){return this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_kitty_graphics_placement_get`,this.runtime.call(`ghostty_kitty_graphics_placement_get`,e,t,this.scratch)),this.runtime.view(this.scratch,4)}placementU32(e,t){return this.placementData(e,t).getUint32(0,!0)}imageData(e,t){return this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_kitty_graphics_image_get`,this.runtime.call(`ghostty_kitty_graphics_image_get`,e,t,this.scratch)),this.runtime.view(this.scratch,4).getUint32(0,!0)}};function DN(e,t,n,r,i){let a=r.width/i.width,o=r.height/i.height;for(let i of t){let t=i.placement;ON(t.z)===n&&e.drawImage(i.bitmap,t.source.x,t.source.y,t.source.width,t.source.height,t.column*r.width+t.xOffset*a,t.row*r.height+t.yOffset*o,t.width*a,t.height*o)}}function ON(e){return e<-1073741824?`belowBackground`:e<0?`belowText`:`aboveText`}function kN(e){let t=yN.get(e.format);if(t===void 0)throw Error(`unsupported kitty image format ${e.format}`);let n=e.width*e.height,r=e.pixels,i=new Uint8ClampedArray(n*4);if(t===4)i.set(r.subarray(0,n*4));else for(let e=0;e<n;e+=1){let n=e*t,a=e*4;t===3?i.set(r.subarray(n,n+3),a):i.fill(r[n],a,a+3),i[a+3]=t===2?r[n+1]:255}let a=new OffscreenCanvas(e.width,e.height),o=a.getContext(`2d`);if(!o)throw Error(`could not create a canvas for a kitty image`);return o.putImageData(new ImageData(i,e.width,e.height),0,0),a}var AN=8,jN=16,MN=0,NN=1,PN=2,FN=8,IN={cols:1,rows:2,dirty:3,rowIterator:4,background:5,foreground:6,cursor:7,cursorHasValue:8,cursorStyle:10,cursorVisible:11,cursorBlinking:12,cursorInViewport:14,cursorX:15,cursorY:16},LN={dirty:1,raw:2,cells:3},RN={raw:1,style:2,graphemesLength:3,graphemes:4,background:5,foreground:6,selected:7},zN={keys:0,values:20,graphemesLength:40,selected:44,background:48,foreground:52,written:56,size:60},BN={narrow:0,wide:1,spacerTail:2},VN={r:229,g:231,b:235},HN={r:0,g:0,b:0};function UN(e,t){return Math.floor((e*155+t*100)/255)}function WN(e,t){return{r:UN(e.r,t.r),g:UN(e.g,t.g),b:UN(e.b,t.b)}}function GN(e,t){let n=``;for(let r=0;r<t;r+=4096){let i=Math.min(4096,t-r),a=Array(i);for(let t=0;t<i;t+=1)a[t]=e.getUint32((r+t)*4,!0);n+=String.fromCodePoint(...a)}return n}function KN(e,t){return{text:``,wide:0,foreground:e,background:t,bold:!1,italic:!1,invisible:!1,strikethrough:!1,overline:!1,underline:0,underlineColor:null,selected:!1,placeholder:null}}function qN(e,t){let n=e.dataView();return{r:n.getUint8(t),g:n.getUint8(t+1),b:n.getUint8(t+2)}}function JN(e,t){let n=e.alloc(768);e.call(`ghostty_terminal_get`,t,21,n);let r=e.bytes(n,768),i=Array.from({length:256},(e,t)=>({r:r[t*3],g:r[t*3+1],b:r[t*3+2]}));return e.free(n,768),i}function YN(e,t){let n=[],r=[];return e.cells.forEach((e,i)=>{if(e.wide!==2)for(let a of(e.text||` `).split(``))n.push(a),r.push({x:i,y:t})}),{text:n.join(``),points:r}}var XN=class{runtime=YM();stateSlot;state;rowIteratorSlot;rowCellsSlot;scratch;style;cellQuery;graphemes=0;graphemeCapacity=0;rows=[];palette=[];constructor(){let e=this.runtime;this.stateSlot=e.allocOpaque(),e.check(`ghostty_render_state_new`,e.call(`ghostty_render_state_new`,0,this.stateSlot)),this.state=e.readPointer(this.stateSlot),this.rowIteratorSlot=e.allocOpaque(),e.check(`ghostty_render_state_row_iterator_new`,e.call(`ghostty_render_state_row_iterator_new`,0,this.rowIteratorSlot)),this.rowCellsSlot=e.allocOpaque(),e.check(`ghostty_render_state_row_cells_new`,e.call(`ghostty_render_state_row_cells_new`,0,this.rowCellsSlot)),this.scratch=e.alloc(16),this.style=e.alloc(e.layout(`GhosttyStyle`).size),this.cellQuery=e.alloc(zN.size);let t=e.dataView();[[RN.style,this.style],[RN.graphemesLength,this.cellQuery+zN.graphemesLength],[RN.selected,this.cellQuery+zN.selected],[RN.background,this.cellQuery+zN.background],[RN.foreground,this.cellQuery+zN.foreground]].forEach((e,n)=>{t.setUint32(this.cellQuery+zN.keys+n*4,e[0],!0),t.setUint32(this.cellQuery+zN.values+n*4,e[1],!0)})}snapshot(e,t){let n=this.runtime;n.check(`ghostty_render_state_update`,n.call(`ghostty_render_state_update`,this.state,e));let r=this.getRender(IN.cols,2),i=this.getRender(IN.rows,2),a=this.getRender(IN.dirty,4),o=this.getColor(IN.foreground,VN),s=this.getColor(IN.background,HN),c=this.getRender(IN.cursorHasValue,1)===0?o:this.getColor(IN.cursor,o),l=this.getRender(IN.cursorInViewport,1)!==0,u=this.getRender(IN.cursorVisible,1)!==0&&l;(this.rows.length!==i||this.rows.some(e=>e.cells.length!==r))&&(this.rows=Array.from({length:i},()=>({cells:Array.from({length:r},()=>KN(o,s)),isWrapContinuation:!1,wrapsToNext:!1})));let d=new Set;if(a!==0){this.palette=JN(n,e),n.check(`ghostty_render_state_get`,n.call(`ghostty_render_state_get`,this.state,IN.rowIterator,this.rowIteratorSlot));let c=n.readPointer(this.rowIteratorSlot),l=0;for(;l<i&&n.call(`ghostty_render_state_row_iterator_next`,c)!==0;)(a===2||this.getRowFlag(c,LN.dirty))&&(this.rows[l]=this.readRow(c,r,o,s,t),d.add(l),n.bytes(this.scratch,1)[0]=0,n.call(`ghostty_render_state_row_set`,c,0,this.scratch)),l+=1;n.view(this.scratch,4).setUint32(0,0,!0),n.call(`ghostty_render_state_set`,this.state,0,this.scratch)}return{cols:r,rows:i,foreground:o,background:s,cursor:c,cursorX:l?this.getRender(IN.cursorX,2):-1,cursorY:l?this.getRender(IN.cursorY,2):-1,cursorVisible:u,cursorBlinking:this.getRender(IN.cursorBlinking,1)!==0,cursorStyle:this.getRender(IN.cursorStyle,4),dirtyRows:d,rowData:this.rows}}invalidate(){this.rows=[]}dispose(){let e=this.runtime,t=e.readPointer(this.rowCellsSlot);t&&e.call(`ghostty_render_state_row_cells_free`,t);let n=e.readPointer(this.rowIteratorSlot);n&&e.call(`ghostty_render_state_row_iterator_free`,n),e.call(`ghostty_render_state_free`,this.state),e.free(this.style,e.layout(`GhosttyStyle`).size),e.free(this.cellQuery,zN.size),e.free(this.scratch,16),e.free(this.graphemes,this.graphemeCapacity),e.freeOpaque(this.rowCellsSlot),e.freeOpaque(this.rowIteratorSlot),e.freeOpaque(this.stateSlot)}readRow(e,t,n,r,i){let a=this.runtime;a.check(`ghostty_render_state_row_get`,a.call(`ghostty_render_state_row_get`,e,LN.raw,this.scratch));let o=a.view(this.scratch,8).getBigUint64(0,!0);a.bytes(this.scratch+8,1)[0]=0,a.call(`ghostty_row_get`,o,2,this.scratch+8);let s=a.bytes(this.scratch+8,1)[0]!==0;a.bytes(this.scratch+8,1)[0]=0,a.call(`ghostty_row_get`,o,1,this.scratch+8);let c=a.bytes(this.scratch+8,1)[0]!==0;a.check(`ghostty_render_state_row_get`,a.call(`ghostty_render_state_row_get`,e,LN.cells,this.rowCellsSlot));let l=a.readPointer(this.rowCellsSlot),u=a.layout(`GhosttyStyle`),d=u.size,f=u.fields,p=[];for(;p.length<t&&a.call(`ghostty_render_state_row_cells_next`,l)!==0;){a.bytes(this.style,d).fill(0),a.setField(this.style,`GhosttyStyle`,`size`,d);let e=a.call(`ghostty_render_state_row_cells_get_multi`,l,5,this.cellQuery+zN.keys,this.cellQuery+zN.values,this.cellQuery+zN.written),t=a.dataView(),o=t.getUint32(this.cellQuery+zN.written,!0);o<3&&a.check(`ghostty_render_state_row_cells_get_multi`,e);let s=t.getUint32(this.cellQuery+zN.graphemesLength,!0),c=t.getUint8(this.cellQuery+zN.selected)!==0,u=o>=4?qN(a,this.cellQuery+zN.background):r,m=o===5?qN(a,this.cellQuery+zN.foreground):o===3?this.getCellColor(l,n):n,h=``;if(s>0){let e=s*4;if(e>this.graphemeCapacity){let t=Math.max(e,this.graphemeCapacity*2),n=a.alloc(t);a.free(this.graphemes,this.graphemeCapacity),this.graphemes=n,this.graphemeCapacity=t}a.call(`ghostty_render_state_row_cells_get`,l,RN.graphemes,this.graphemes)===0&&(h=GN(a.view(this.graphemes,e),s))}let g=0;if(h.length===0&&p.at(-1)?.text.length){a.call(`ghostty_render_state_row_cells_get`,l,RN.raw,this.scratch);let e=a.view(this.scratch,8).getBigUint64(0,!0);a.view(this.scratch+8,4).setUint32(0,0,!0),a.call(`ghostty_cell_get`,e,3,this.scratch+8),g=a.view(this.scratch+8,4).getUint32(0,!0)}let _=a.dataView(),v=e=>_.getUint8(this.style+f[e].offset)!==0,y=v(`bold`);if(i&&y&&_.getUint32(this.style+AN,!0)===NN){let e=_.getUint8(this.style+jN);e<8&&(m=this.palette[e+8]??m)}if(v(`inverse`)){let e=m;m=u,u=e}v(`faint`)&&(m=WN(m,u));let b=this.style+f.underline_color.offset,x=_.getUint32(b,!0),S=b+FN,C=null;h.codePointAt(0)===1109742&&(C=xN(h,this.colorId(this.style+AN),this.colorId(b)),h=``),p.push({text:h,wide:g,foreground:m,background:u,bold:y,italic:v(`italic`),invisible:v(`invisible`),strikethrough:v(`strikethrough`),overline:v(`overline`),underline:_.getInt32(this.style+f.underline.offset,!0),underlineColor:x===NN?this.palette[_.getUint8(S)]:x===PN?qN(a,S):null,selected:c,placeholder:C})}for(;p.length<t;)p.push(KN(n,r));return{cells:p,isWrapContinuation:s,wrapsToNext:c}}getRender(e,t){this.runtime.bytes(this.scratch,4).fill(0),this.runtime.check(`ghostty_render_state_get`,this.runtime.call(`ghostty_render_state_get`,this.state,e,this.scratch));let n=this.runtime.view(this.scratch,4);return t===1?n.getUint8(0):t===2?n.getUint16(0,!0):n.getUint32(0,!0)}getColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_get`,this.state,e,this.scratch)===0?qN(this.runtime,this.scratch):t}getRowFlag(e,t){return this.runtime.bytes(this.scratch,1)[0]=0,this.runtime.call(`ghostty_render_state_row_get`,e,t,this.scratch)===0&&this.runtime.bytes(this.scratch,1)[0]!==0}getCellColor(e,t){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.call(`ghostty_render_state_row_cells_get`,e,RN.foreground,this.scratch)===0?qN(this.runtime,this.scratch):t}colorId(e){let t=this.runtime.dataView(),n=t.getUint32(e,!0);if(n===MN)return 0;if(n===NN)return t.getUint8(e+FN);if(n===PN){let t=qN(this.runtime,e+FN);return t.r<<16|t.g<<8|t.b}throw Error(`unknown style color tag ${n}`)}},ZN=16,QN=589824,$N=381888,eP=5e7,tP=new TextDecoder;function nP(e){let t=[...e],n=[0,95,135,175,215,255];for(let e=16;e<232;e+=1){let r=e-16;t.push({r:n[Math.floor(r/36)],g:n[Math.floor(r/6)%6],b:n[r%6]})}for(let e=0;e<24;e+=1){let n=8+e*10;t.push({r:n,g:n,b:n})}return t}var rP=class{encoder;kitty;runtime=YM();terminalSlot;terminal;renderState;formatterSlot;formatter;scratch;point;scrollbar;host;hostId=0;sizeReport;disposed=!1;boldIsBright=!1;version=``;constructor(e,t,n,r,i){let a=this.runtime,o=a.layout(`GhosttyTerminalOptions`).size,s=a.alloc(o);a.setField(s,`GhosttyTerminalOptions`,`cols`,e),a.setField(s,`GhosttyTerminalOptions`,`rows`,t);let c=Math.floor($N/(8*(e+1)));a.setField(s,`GhosttyTerminalOptions`,`max_scrollback`,n===0?0:Math.min((Math.ceil(n/c)+1)*QN,eP)),this.terminalSlot=a.allocOpaque();let l=a.call(`ghostty_terminal_new`,0,this.terminalSlot,s);if(a.free(s,o),a.check(`ghostty_terminal_new`,l),this.terminal=a.readPointer(this.terminalSlot),!TN(this.terminal))throw a.call(`ghostty_terminal_free`,this.terminal),a.freeOpaque(this.terminalSlot),Error(`libghostty-vt was built without kitty graphics, build it with scripts/build-ghostty-wasm.mts`);this.sizeReport={rows:t,columns:e,cellWidth:1,cellHeight:1},this.host={write:r,size:()=>this.sizeReport,bell:i,version:()=>this.version},this.hostId=a.attachHost(this.terminal,this.host),this.renderState=new XN,this.encoder=new fN(this.terminal),this.kitty=new EN(this.terminal);let u=`GhosttyFormatterTerminalOptions`,d=a.layout(u),f=a.alloc(d.size),p=a.field(u,`extra`),m=a.field(`GhosttyFormatterTerminalExtra`,`screen`);a.setField(f,u,`size`,d.size),a.setField(f,u,`trim`,1),a.setField(f+p.offset,`GhosttyFormatterTerminalExtra`,`size`,p.size),a.setField(f+p.offset+m.offset,`GhosttyFormatterScreenExtra`,`size`,m.size),this.formatterSlot=a.allocOpaque();let h=a.call(`ghostty_formatter_terminal_new`,0,this.formatterSlot,this.terminal,f);a.free(f,d.size),a.check(`ghostty_formatter_terminal_new`,h),this.formatter=a.readPointer(this.formatterSlot),this.scratch=a.alloc(16),this.point=a.alloc(a.layout(`GhosttyPoint`).size),this.scrollbar=a.alloc(a.layout(`GhosttyTerminalScrollbar`).size)}write(e){if(e.length===0)return;this.kitty.note(e);let t=this.runtime.alloc(e.length);this.runtime.bytes(t,e.length).set(e),this.runtime.call(`ghostty_terminal_vt_write`,this.terminal,t,e.length),this.runtime.free(t,e.length)}setReplies(e){e&&this.hostId===0?this.hostId=this.runtime.attachHost(this.terminal,this.host):!e&&this.hostId!==0&&(this.runtime.detachHost(this.terminal,this.hostId),this.hostId=0)}reset(){this.runtime.call(`ghostty_terminal_reset`,this.terminal),this.renderState.invalidate()}resize(e,t,n,r,i){this.sizeReport={rows:t,columns:e,cellWidth:Math.max(1,Math.round(n*i)),cellHeight:Math.max(1,Math.round(r*i))},this.runtime.check(`ghostty_terminal_resize`,this.runtime.call(`ghostty_terminal_resize`,this.terminal,Math.max(1,Math.min(65535,e)),Math.max(1,Math.min(65535,t)),this.sizeReport.cellWidth,this.sizeReport.cellHeight))}setColors(e){let t=this.runtime.alloc(3);for(let n of[[11,e.foreground],[12,e.background],[13,e.cursor]]){let e=n[1];this.runtime.bytes(t,3).set([e.r,e.g,e.b]),this.runtime.call(`ghostty_terminal_set`,this.terminal,n[0],t)}this.runtime.free(t,3);let n=nP(e.palette),r=this.runtime.alloc(n.length*3);this.runtime.bytes(r,n.length*3).set(n.flatMap(e=>[e.r,e.g,e.b])),this.runtime.call(`ghostty_terminal_set`,this.terminal,14,r),this.runtime.free(r,n.length*3),this.renderState.invalidate()}setCursor(e,t){let n={bar:0,block:1,underline:2}[e];this.runtime.view(this.scratch,4).setUint32(0,n,!0),this.runtime.call(`ghostty_terminal_set`,this.terminal,22,this.scratch),this.runtime.bytes(this.scratch,1)[0]=+!!t,this.runtime.call(`ghostty_terminal_set`,this.terminal,23,this.scratch)}title(){if(this.runtime.bytes(this.scratch,8).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,12,this.scratch)!==0)return``;let e=this.runtime.view(this.scratch,8),t=e.getUint32(0,!0),n=e.getUint32(4,!0);return n===0?``:tP.decode(this.runtime.bytes(t,n))}screenText(){let e=this.runtime.alloc(8),t=this.runtime.call(`ghostty_formatter_format_alloc`,this.formatter,0,e,e+4),n=this.runtime.view(e,8),r=n.getUint32(0,!0),i=n.getUint32(4,!0);if(this.runtime.free(e,8),t!==0)return``;let a=tP.decode(this.runtime.bytes(r,i));return this.runtime.call(`ghostty_free`,0,r,i),a}scroll(e){let t=this.runtime.layout(`GhosttyTerminalScrollViewport`),n=this.runtime.alloc(t.size);this.runtime.setField(n,`GhosttyTerminalScrollViewport`,`tag`,2);let r=this.runtime.field(`GhosttyTerminalScrollViewport`,`value`);this.runtime.view(n+r.offset,r.size).setInt32(0,e,!0),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,n),this.runtime.free(n,t.size)}scrollToBottom(){let e=this.runtime.layout(`GhosttyTerminalScrollViewport`),t=this.runtime.alloc(e.size);this.runtime.setField(t,`GhosttyTerminalScrollViewport`,`tag`,1),this.runtime.call(`ghostty_terminal_scroll_viewport`,this.terminal,t),this.runtime.free(t,e.size)}scrollbarState(){let e=this.runtime.layout(`GhosttyTerminalScrollbar`);return this.runtime.bytes(this.scrollbar,e.size).fill(0),this.runtime.call(`ghostty_terminal_get`,this.terminal,9,this.scrollbar)===0?{total:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`total`),offset:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`offset`),len:this.runtime.readField(this.scrollbar,`GhosttyTerminalScrollbar`,`len`)}:null}isMouseTracking(){return this.flag(`ghostty_terminal_get`,11)}isMouseAnyEventTracking(){return this.flag(`ghostty_terminal_mode_get`,1003)}isFocusReporting(){return this.flag(`ghostty_terminal_mode_get`,1004)}isSynchronizedOutput(){return this.flag(`ghostty_terminal_mode_get`,2026)}endSynchronizedOutput(){this.runtime.check(`ghostty_terminal_mode_set`,this.runtime.call(`ghostty_terminal_mode_set`,this.terminal,2026,0))}currentColors(){return{foreground:this.terminalColor(18),background:this.terminalColor(19),cursor:this.terminalColor(20),palette:JN(this.runtime,this.terminal)}}isApplicationCursorKeys(){return this.flag(`ghostty_terminal_mode_get`,1)}isKittyKeyboard(){return this.flag(`ghostty_terminal_get`,8)}isAlternateScreen(){return this.runtime.dataView().setUint32(this.scratch,0,!0),this.runtime.call(`ghostty_terminal_get`,this.terminal,6,this.scratch)===0&&this.runtime.dataView().getUint32(this.scratch,!0)===1}setSelection(e,t){let n=this.runtime.layout(`GhosttyGridRef`).size,r=this.gridRef(e.x,e.y,2);try{let e=this.gridRef(t.x,t.y,2),i=this.runtime.layout(`GhosttySelection`),a=this.runtime.alloc(i.size);this.runtime.setField(a,`GhosttySelection`,`size`,i.size);let o=this.runtime.field(`GhosttySelection`,`start`),s=this.runtime.field(`GhosttySelection`,`end`);this.runtime.bytes(a+o.offset,o.size).set(this.runtime.bytes(r,o.size)),this.runtime.bytes(a+s.offset,s.size).set(this.runtime.bytes(e,s.size)),this.runtime.call(`ghostty_terminal_set`,this.terminal,21,a),this.runtime.free(e,n),this.runtime.free(a,i.size)}finally{this.runtime.free(r,n)}}selectWord(e){return this.selectAt(`GhosttyTerminalSelectWordOptions`,`ghostty_terminal_select_word`,e)}selectLine(e){return this.selectAt(`GhosttyTerminalSelectLineOptions`,`ghostty_terminal_select_line`,e)}clearSelection(){this.runtime.call(`ghostty_terminal_set`,this.terminal,21,0)}selectionText(){let e=this.runtime.alloc(ZN),t=this.runtime.view(e,ZN);t.setUint32(0,ZN,!0),t.setUint8(8,1),t.setUint8(9,1);let n=this.runtime.encodeOutput((t,n,r)=>this.runtime.call(`ghostty_terminal_selection_format_buf`,this.terminal,e,t,n,r));return this.runtime.free(e,ZN),n}hyperlinkAt(e,t){let n=this.gridRef(e,t,1),r=this.hyperlinkOf(n);return this.runtime.free(n,this.runtime.layout(`GhosttyGridRef`).size),r}toScreen(e){let t=this.gridRef(e.x,e.y,1),n=this.pointFromGridRef(t,2);return this.runtime.free(t,this.runtime.layout(`GhosttyGridRef`).size),n}trackCursor(){let e=this.runtime.allocOpaque(),t=this.runtime.call(`ghostty_terminal_grid_ref_track`,this.terminal,this.cursorPoint(),e),n=this.runtime.readPointer(e);return this.runtime.freeOpaque(e),this.runtime.check(`ghostty_terminal_grid_ref_track`,t),n}retrack(e){let t=this.runtime.call(`ghostty_tracked_grid_ref_set`,e,this.terminal,this.cursorPoint());this.runtime.check(`ghostty_tracked_grid_ref_set`,t)}trackedPoint(e){return this.runtime.call(`ghostty_tracked_grid_ref_point`,e,2,this.scratch)===0?{x:this.runtime.readField(this.scratch,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(this.scratch,`GhosttyPointCoordinate`,`y`)}:null}trackedHyperlink(e){let t=this.runtime.layout(`GhosttyGridRef`).size,n=this.runtime.alloc(t);this.runtime.setField(n,`GhosttyGridRef`,`size`,t);let r=this.runtime.call(`ghostty_tracked_grid_ref_snapshot`,e,n)===0?this.hyperlinkOf(n):null;return this.runtime.free(n,t),r}untrack(e){this.runtime.call(`ghostty_tracked_grid_ref_free`,e)}snapshot(){return this.renderState.snapshot(this.terminal,this.boldIsBright)}invalidate(){this.renderState.invalidate()}cellSize(){return{width:this.sizeReport.cellWidth,height:this.sizeReport.cellHeight}}dispose(){if(this.disposed)return;this.disposed=!0;let e=this.runtime;e.call(`ghostty_formatter_free`,this.formatter),this.encoder.dispose(),this.kitty.dispose(),this.renderState.dispose(),this.hostId!==0&&e.detachHost(this.terminal,this.hostId),e.call(`ghostty_terminal_free`,this.terminal),e.free(this.scrollbar,e.layout(`GhosttyTerminalScrollbar`).size),e.free(this.scratch,16),e.free(this.point,e.layout(`GhosttyPoint`).size),e.freeOpaque(this.formatterSlot),e.freeOpaque(this.terminalSlot)}hyperlinkOf(e){let t=this.runtime.encodeOutput((t,n,r)=>this.runtime.call(`ghostty_grid_ref_hyperlink_uri`,e,t,n,r));return t===``?null:t}cursorPosition(){this.runtime.dataView().setUint32(this.scratch,0,!0),this.runtime.call(`ghostty_terminal_get`,this.terminal,3,this.scratch),this.runtime.call(`ghostty_terminal_get`,this.terminal,4,this.scratch+2);let e=this.runtime.dataView();return{x:e.getUint16(this.scratch,!0),y:e.getUint16(this.scratch+2,!0)}}cursorPoint(){let e=this.cursorPosition();return this.fillPoint(this.point,e.x,e.y,0),this.point}fillPoint(e,t,n,r){this.runtime.setField(e,`GhosttyPoint`,`tag`,r);let i=this.runtime.field(`GhosttyPoint`,`value`),a=this.runtime.dataView();a.setUint16(e+i.offset,Math.max(0,t),!0),a.setUint32(e+i.offset+4,Math.max(0,n),!0)}gridRef(e,t,n){let r=this.runtime.alloc(this.runtime.layout(`GhosttyPoint`).size);this.fillPoint(r,e,t,n);let i=this.runtime.layout(`GhosttyGridRef`).size,a=this.runtime.alloc(i);this.runtime.setField(a,`GhosttyGridRef`,`size`,i);let o=this.runtime.call(`ghostty_terminal_grid_ref`,this.terminal,r,a);return this.runtime.free(r,this.runtime.layout(`GhosttyPoint`).size),o!==0&&(this.runtime.free(a,i),this.runtime.check(`ghostty_terminal_grid_ref`,o)),a}selectAt(e,t,n){let r=this.gridRef(n.x,n.y,2),i=this.runtime.layout(e),a=this.runtime.layout(`GhosttySelection`),o=this.runtime.alloc(i.size),s=this.runtime.alloc(a.size);this.runtime.setField(o,e,`size`,i.size);let c=this.runtime.field(e,`ref`);this.runtime.bytes(o+c.offset,c.size).set(this.runtime.bytes(r,c.size)),this.runtime.setField(s,`GhosttySelection`,`size`,a.size);let l=null;if(this.runtime.call(t,this.terminal,o,s)===0){let e=this.pointFromGridRef(s+this.runtime.field(`GhosttySelection`,`start`).offset,2),t=this.pointFromGridRef(s+this.runtime.field(`GhosttySelection`,`end`).offset,2);e&&t&&(l={start:e,end:t})}return this.runtime.free(s,a.size),this.runtime.free(r,this.runtime.layout(`GhosttyGridRef`).size),this.runtime.free(o,i.size),l}pointFromGridRef(e,t){let n=this.runtime.layout(`GhosttyPointCoordinate`),r=this.runtime.alloc(n.size),i=this.runtime.call(`ghostty_terminal_point_from_grid_ref`,this.terminal,e,t,r)===0?{x:this.runtime.readField(r,`GhosttyPointCoordinate`,`x`),y:this.runtime.readField(r,`GhosttyPointCoordinate`,`y`)}:null;return this.runtime.free(r,n.size),i}flag(e,t){return this.runtime.flag(e,this.terminal,t)}terminalColor(e){return this.runtime.bytes(this.scratch,3).fill(0),this.runtime.check(`ghostty_terminal_get`,this.runtime.call(`ghostty_terminal_get`,this.terminal,e,this.scratch)),qN(this.runtime,this.scratch)}};function iP(e,t){let n=[],r=e.toLowerCase(),i=t.toLowerCase(),a=r.indexOf(i);for(;a!==-1;)n.push(a),a=r.indexOf(i,a+i.length);return n}var aP=class{core;redraw;listeners=new Set;query=``;matches=[];activeMatch=-1;stale=!1;timer=null;constructor(e,t){this.core=e,this.redraw=t}find(e,t,n,r){let i=this.matches[this.activeMatch]??null;if(this.query=e,this.refresh(),this.matches.length===0)this.activeMatch=-1;else if(n||i===null){let e=i?.row??r,t=this.matches.findIndex(t=>t.row>=e);this.activeMatch=t===-1?this.matches.length-1:t}else{let e=this.matches.findIndex(e=>e.row===i.row&&e.index===i.index),n=e===-1?0:e,r=t?-1:1;this.activeMatch=(n+r+this.matches.length)%this.matches.length}return this.emit(),this.matches[this.activeMatch]??null}onResults(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}clear(){this.query=``,this.matches=[],this.activeMatch=-1}outputChanged(){this.query!==``&&(this.stale=!0,this.timer===null&&(this.timer=window.setTimeout(()=>{if(this.timer=null,!this.stale||this.query===``)return;let e=this.matches[this.activeMatch];this.refresh();let t=e?this.matches.findIndex(t=>t.row===e.row&&t.index===e.index):-1;this.activeMatch=t===-1?this.matches.length-1:t,this.emit(),this.redraw()},200)))}highlights(e,t){if(this.query===``)return[];let n=this.matches[this.activeMatch],r=[];return e.rowData.forEach((e,i)=>{let a=YN(e,i);iP(a.text,this.query).forEach((e,o)=>{let s=a.points[e],c=a.points[e+this.query.length-1];s&&c&&r.push({row:i,start:s.x,end:c.x+1,active:n?.row===t+i&&n.index===o})})}),r}dispose(){this.timer!==null&&window.clearTimeout(this.timer),this.timer=null}refresh(){this.stale=!1,this.matches=[],this.query!==``&&this.core.screenText().split(`
|
|
15
15
|
`).forEach((e,t)=>{iP(e,this.query).forEach((e,n)=>this.matches.push({row:t,index:n}))})}emit(){let e={resultIndex:this.activeMatch,resultCount:this.matches.length};for(let t of this.listeners)t(e)}},oP=Fe.withTag(`terminal`),sP=new TextDecoder;function cP(e){function t(e){return e.toString(16).padStart(2,`0`).repeat(2)}return`rgb:${t(e.r)}/${t(e.g)}/${t(e.b)}`}function lP(e){return Math.min(Math.max(e,0),100)}function uP(e){return sP.decode(Uint8Array.from(atob(e),e=>e.charCodeAt(0)))}function dP(e){return e===``?`s0`:[...e].filter(e=>`cpqs01234567`.includes(e)).join(``)}function fP(e){try{return uP(e)}catch(e){return oP.warn(`invalid clipboard sequence`,e),null}}function pP(e,t,n){let r=Array.from(new TextEncoder().encode(e),e=>String.fromCharCode(e)).join(``);return`\x1b]52;${t};${btoa(r)}${n}`}function mP(e,t,n){let r=e===`10;?`?t.foreground:e===`11;?`?t.background:t.cursor;return`\x1b]${e.slice(0,2)};${cP(r)}${n}`}function hP(e,t,n){let r=e.split(`;`),i=[];for(let e=1;e+1<r.length;e+=2){if(r[e+1]!==`?`||!/^\d+$/.test(r[e]))continue;let a=t[Number(r[e])];a!==void 0&&i.push(`\x1b]4;${r[e]};${cP(a)}${n}`)}return i}function gP(e,t){let n=e.split(`;`);if(n.length>4)return null;let r=n[2]===void 0||n[2]===``?0:Number(n[2]),i=n[3]===void 0||n[3]===``?-1:Number(n[3]);return!Number.isInteger(r)||!Number.isInteger(i)?null:r===0?{state:r,value:0}:r===1?i<0?null:{state:r,value:lP(i)}:r===2||r===4?i<0?{state:r,value:t.value}:{state:r,value:lP(i||t.value)}:r===3?{state:r,value:t.value}:null}function _P(e,t){if(e.startsWith(`9;`)&&!/^9;\d+(;|$)/.test(e))return{title:``,body:sP.decode(t.subarray(2))};if(e.startsWith(`777;notify;`)){let e=sP.decode(t).split(`;`);return{title:e[2]??``,body:e.slice(3).join(`;`)}}return null}var vP=class{pending={id:``,title:``,body:``};add(e){let t=e.indexOf(`;`,3);if(t===-1)return null;let n=new Map;for(let r of e.slice(3,t).split(`:`)){let e=r.indexOf(`=`);e!==-1&&n.set(r.slice(0,e),r.slice(e+1))}let r=n.get(`p`)??`title`;if(r===`?`||r===`close`||r===`alive`)return null;let i=e.slice(t+1);if(n.get(`e`)===`1`)try{i=uP(i)}catch(e){return oP.warn(`invalid notification sequence`,e),null}let a=n.get(`i`)??``;if(a!==this.pending.id&&(this.pending={id:a,title:``,body:``}),r===`title`&&(this.pending.title+=i),r===`body`&&(this.pending.body+=i),n.get(`d`)===`0`)return null;let o=this.pending;return this.pending={id:``,title:``,body:``},o.title===``&&o.body===``?null:{title:o.title,body:o.body}}},yP=27,bP=7,xP=24,SP=26,CP=33554432,wP=class{state=`ground`;params=``;collecting=!1;chunks=[];size=0;reset(){this.state=`ground`,this.drop()}scan(e,t){let n=0;for(let r=0;r<e.length;r+=1){let i=e[r];if(i===xP||i===SP)this.state=`ground`,this.drop();else if(this.state===`ground`)i===yP&&(this.state=`escape`);else if(this.state===`escape`){if(this.params=``,i===93){this.state=`osc`,this.begin(),n=r+1;continue}if(i===80){this.state=`dcsHeader`;continue}this.state=i===yP?`escape`:`ground`}else if(this.state===`osc`){if(i===bP){if(this.state=`ground`,this.append(e,n,r),t({type:`osc`,data:this.take(),terminator:`\x07`},r+1))return r+1;continue}i===yP&&(this.state=`oscEscape`,this.append(e,n,r))}else if(this.state===`oscEscape`){if(i===92){if(this.state=`ground`,t({type:`osc`,data:this.take(),terminator:`\x1B\\`},r+1))return r+1;continue}this.drop(),this.state=`escape`,--r}else if(this.state===`dcsHeader`){if(i===yP){this.state=`dcsEscape`;continue}if(i>=32&&i<=63){this.params.length<16&&(this.params+=String.fromCharCode(i));continue}this.state=`dcs`,i===113&&/^[0-9;]*$/.test(this.params)&&(this.begin(),n=r+1)}else if(this.state===`dcs`)i===yP&&(this.state=`dcsEscape`,this.append(e,n,r));else if(i===92){if(this.state=`ground`,this.collecting&&t({type:`sixel`,data:this.take()},r+1))return r+1}else this.drop(),this.state=`escape`,--r}return(this.state===`osc`||this.state===`dcs`)&&this.append(e,n,e.length),e.length}begin(){this.collecting=!0,this.chunks=[],this.size=0}append(e,t,n){!this.collecting||n<=t||(this.size+n-t>CP?this.drop():(this.chunks.push(e.slice(t,n)),this.size+=n-t))}take(){let e=new Uint8Array(this.size),t=0;for(let n of this.chunks)e.set(n,t),t+=n.length;return this.drop(),e}drop(){this.collecting=!1,this.chunks=[],this.size=0}},TP=`0101.0202.1010.2020.........0110.0210.0120.0220.0011.0012.0021.0022.1100.1200.2100.2200.1001.1002.2001.2002.1110.1210.2110.1120.2120.2210.1220.2220.1011.1012.2011.1021.2021.2012.1022.2022.0111.0112.0211.0212.0121.0122.0221.0222.1101.1102.1201.1202.2101.2102.2201.2202.1111.1112.1211.1212.2111.1121.2121.2112.2211.1122.1221.2212.1222.2122.2221.2222`.split(`.`),EP=[`0001`,`1000`,`0100`,`0010`,`0002`,`2000`,`0200`,`0020`,`0201`,`1020`,`0102`,`2010`],DP=`0303.3030.0310.0130.0330.0013.0031.0033.1300.3100.3300.1003.3001.3003.1310.3130.3330.1013.3031.3033.0313.0131.0333.1303.3101.3303.1313.3131.3333`.split(`.`),OP=[0,0,4,4],kP=[4,0,4,4],AP=[0,4,4,4],jP=[4,4,4,4],MP=[[[0,0,8,4]],[[0,7,8,1]],[[0,6,8,2]],[[0,5,8,3]],[[0,4,8,4]],[[0,3,8,5]],[[0,2,8,6]],[[0,1,8,7]],[[0,0,8,8]],[[0,0,7,8]],[[0,0,6,8]],[[0,0,5,8]],[[0,0,4,8]],[[0,0,3,8]],[[0,0,2,8]],[[0,0,1,8]],[[4,0,4,8]],[],[],[],[[0,0,8,1]],[[7,0,1,8]],[AP],[jP],[OP],[OP,AP,jP],[OP,jP],[OP,kP,AP],[OP,kP,jP],[kP],[kP,AP],[kP,AP,jP]],NP={9617:.25,9618:.5,9619:.75},PP={9581:[1,1],9582:[-1,1],9583:[-1,-1],9584:[1,-1]};function FP(e){return e>=9472&&e<=9547?TP[e-9472]:e>=9552&&e<=9580?DP[e-9552]:e>=9588&&e<=9599?EP[e-9588]:``}function IP(e){if(e.length!==1)return!1;let t=e.charCodeAt(0);return FP(t)!==``||PP[t]!==void 0||t>=9600&&t<=9631}function LP(e){return Math.max(1,Math.round(e.height/20))}function RP(e,t,n){let[r,i,a,o]=t,s=LP(n),c=s*2,l=Math.floor(Math.max(0,n.height-s)/2),u=l+s,d=Math.floor(Math.max(0,n.height-c)/2),f=d+c,p=Math.max(0,l-s),m=u+s,h=Math.floor(Math.max(0,n.width-s)/2),g=h+s,_=Math.floor(Math.max(0,n.width-c)/2),v=_+c,y=Math.max(0,h-s),b=g+s;function x(t,r,i,a){e.fillRect(n.left+t,n.top+r,i-t,a-r)}let S=o===`2`||i===`2`?f:o!==i||a===r?o===`3`||i===`3`?m:u:o===`0`&&i===`0`?u:l,C=o===`2`||i===`2`?d:o!==i||r===a?o===`3`||i===`3`?p:l:o===`0`&&i===`0`?l:u,w=r===`2`||a===`2`?v:r!==a||o===i?r===`3`||a===`3`?b:g:r===`0`&&a===`0`?g:h,T=r===`2`||a===`2`?_:r!==a||i===o?r===`3`||a===`3`?y:h:r===`0`&&a===`0`?h:g;r===`1`&&x(h,0,g,S),r===`2`&&x(_,0,v,S),r===`3`&&(x(y,0,h,o===`3`?l:S),x(g,0,b,i===`3`?l:S)),i===`1`&&x(T,l,n.width,u),i===`2`&&x(T,d,n.width,f),i===`3`&&(x(r===`3`?g:T,p,n.width,l),x(a===`3`?g:T,u,n.width,m)),a===`1`&&x(h,C,g,n.height),a===`2`&&x(_,C,v,n.height),a===`3`&&(x(y,o===`3`?u:C,h,n.height),x(g,i===`3`?u:C,b,n.height)),o===`1`&&x(0,l,w,u),o===`2`&&x(0,d,w,f),o===`3`&&(x(0,p,r===`3`?h:w,l),x(0,u,a===`3`?h:w,m))}function zP(e,[t,n],r){let i=LP(r),a=r.left+Math.floor(Math.max(0,r.width-i)/2)+i/2,o=r.top+Math.floor(Math.max(0,r.height-i)/2)+i/2,s=t===1?r.left+r.width:r.left,c=n===1?r.top+r.height:r.top,l=Math.min(r.width,r.height)/2;e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=i,e.beginPath(),e.moveTo(a,c),e.arcTo(a,o,s,o,l),e.lineTo(s,o),e.stroke(),e.restore()}function BP(e,t,n,r){e.save(),e.setTransform(1,0,0,1,0,0),VP(e,t.charCodeAt(0),{left:Math.round(n.left*r),top:Math.round(n.top*r),width:Math.round((n.left+n.width)*r)-Math.round(n.left*r),height:Math.round((n.top+n.height)*r)-Math.round(n.top*r)}),e.restore()}function VP(e,t,n){let r=FP(t);if(r!==``){RP(e,r,n);return}let i=PP[t];if(i!==void 0){zP(e,i,n);return}let a=NP[t];if(a!==void 0)e.globalAlpha=a,e.fillRect(n.left,n.top,n.width,n.height);else for(let[r,i,a,o]of MP[t-9600]){let t=n.left+Math.round(n.width*r/8),s=n.top+Math.round(n.height*i/8);e.fillRect(t,s,n.left+Math.round(n.width*(r+a)/8)-t,n.top+Math.round(n.height*(i+o)/8)-s)}}function HP(e){return`rgb(${e.r}, ${e.g}, ${e.b})`}function UP(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b}function WP(e,t){return Math.round(e*t)/t}function GP(e,t,n,r){let i=WP(e*n.width,r);return{left:i,width:WP(t*n.width,r)-i}}function KP(e,t,n,r,i){let a=i-2,o=n+r;if(t===1)e.fillRect(n,a,r,1);else if(t===2)e.fillRect(n,a,r,1),e.fillRect(n,a-2,r,1);else if(t===3){function t(e){return a-1+Math.sin(e/3*Math.PI)*1.5}e.save(),e.strokeStyle=e.fillStyle,e.lineWidth=1,e.beginPath(),e.moveTo(n,t(n));for(let r=Math.floor(n)+1;r<o;r+=1)e.lineTo(r,t(r));e.lineTo(o,t(o)),e.stroke(),e.restore()}else if(t===4)for(let t=Math.ceil(n/2)*2;t<o;t+=2)e.fillRect(t,a,1,1);else if(t===5)for(let t=Math.floor(n/5)*5;t<o;t+=5){let r=Math.max(t,n),i=Math.min(t+3,o);i>r&&e.fillRect(r,a,i-r,1)}else throw Error(`unknown underline style ${t}`)}function qP(e,t){return e.selected===t.selected&&UP(e.foreground,t.foreground)&&e.bold===t.bold&&e.italic===t.italic&&e.invisible===t.invisible}function JP(e,t){return`${e.italic?`italic`:`normal`} ${e.bold?700:400} ${t.fontSize}px ${t.fontFamily}`}function YP(e,t,n,r,i){e.font=`normal 400 ${t}px ${n}`;let a=e.measureText(`M`).width,o=e.measureText(`Mg`),s=o.fontBoundingBoxAscent||t,c=s+o.fontBoundingBoxDescent,l=Math.max(1,Math.round(c*r*i))/i;return{width:Math.max(1,Math.round(a*i))/i,height:l,baseline:WP((l-c)/2+s,i),faceWidth:a}}function XP(e){return/^[!-/:-@[-`{-~]$/.test(e)}function ZP(e,t,n){return!(e===null||t<e.start.y||t>e.end.y||t===e.start.y&&n<e.start.x||t===e.end.y&&n>e.end.x)}function QP(e){let{context:t,snapshot:n,metrics:r,appearance:i,cursorOn:a,previousCursorY:o,pixelRatio:s}=e,c=e.forceFull?Array.from({length:n.rows},(e,t)=>t):[...n.dirtyRows];o!==null&&!c.includes(o)&&c.push(o),n.cursorVisible&&n.cursorY>=0&&!c.includes(n.cursorY)&&c.push(n.cursorY),e.forceFull&&(t.save(),t.resetTransform(),t.fillStyle=HP(n.background),t.fillRect(0,0,t.canvas.width,t.canvas.height),t.restore());function l(e){let t=e*r.height,n=WP(t,s);return{top:t,cellTop:n,cellHeight:WP(t+r.height,s)-n}}t.textBaseline=`alphabetic`;for(let e of c){if(!n.rowData[e])continue;let{cellTop:r,cellHeight:i}=l(e);t.fillStyle=HP(n.background),t.fillRect(0,r,t.canvas.width,i)}e.drawLayer(`belowBackground`);for(let a of c){let o=n.rowData[a];if(!o)continue;let{cellTop:c,cellHeight:u}=l(a),d=0;for(;d<o.cells.length;){let e=o.cells[d],a=d+1;for(;a<o.cells.length&&o.cells[a].selected===e.selected&&UP(o.cells[a].background,e.background);)a+=1;let{left:l,width:f}=GP(d,a,r,s);e.selected?(t.fillStyle=i.selectionBackground,t.fillRect(l,c,f,u)):UP(e.background,n.background)||(t.fillStyle=HP(e.background),t.fillRect(l,c,f,u)),d=a}for(let n of e.highlights){if(n.row!==a)continue;let{left:e,width:o}=GP(n.start,n.end,r,s);t.fillStyle=i.matchBackground,t.fillRect(e,c,o,u),n.active&&(t.strokeStyle=i.activeMatchBorder,t.strokeRect(e+.5,c+.5,o-1,u-1))}}e.drawLayer(`belowText`);for(let a of c){let o=n.rowData[a];if(!o)continue;let{top:c,cellTop:u,cellHeight:d}=l(a);t.save(),t.beginPath(),t.rect(0,u,t.canvas.width,d),t.clip();for(let e=0;e<o.cells.length;e+=1){let n=o.cells[e];if(n.invisible||n.text.trim().length===0)continue;t.fillStyle=n.selected?i.selectionForeground:HP(n.foreground);let a=e*r.width;if(IP(n.text)){BP(t,n.text,{left:a,top:c,width:r.width,height:r.height},s);continue}t.font=JP(n,i);let l=a+(r.width-r.faceWidth)/2,u=e,d=e+1;if(i.ligatures&&XP(n.text)){for(;u>e-3&&u>0&&XP(o.cells[u-1].text)&&qP(o.cells[u-1],n);)--u;for(;d<e+4&&d<o.cells.length&&XP(o.cells[d].text)&&qP(o.cells[d],n);)d+=1}d-u===1?t.fillText(n.text,l,c+r.baseline):(t.save(),t.beginPath(),t.rect(a,c,r.width,r.height),t.clip(),t.fillText(o.cells.slice(u,d).map(e=>e.text).join(``),l-(e-u)*r.faceWidth,c+r.baseline),t.restore())}t.restore();for(let n=0;n<o.cells.length;n+=1){let i=o.cells[n],l=ZP(e.hoveredLink,a,n);if(i.underline===0&&!i.strikethrough&&!i.overline&&!l)continue;let{left:f,width:p}=GP(n,n+1,r,s),m=u+d;t.fillStyle=HP(i.foreground),i.strikethrough&&t.fillRect(f,c+Math.floor(r.height*.55),p,1),i.overline&&t.fillRect(f,u+1,p,1),i.underline===0?l&&KP(t,1,f,p,m):(i.underlineColor!==null&&(t.fillStyle=HP(i.underlineColor)),KP(t,i.underline,f,p,m))}}if(!a||!n.cursorVisible||n.cursorX<0||n.cursorY<0)return;let u=n.cursorY*r.height,d=WP(u,s),f=WP(u+r.height,s)-d,p=n.rowData[n.cursorY]?.cells,m=p?.[n.cursorX],h=p?.[n.cursorX+1]?.wide===BN.spacerTail?2:1,{left:g,width:_}=GP(n.cursorX,n.cursorX+h,r,s);t.fillStyle=HP(n.cursor),t.strokeStyle=HP(n.cursor),!e.focused||n.cursorStyle===3?t.strokeRect(g+.5,d+.5,_-1,f-1):n.cursorStyle===0?t.fillRect(g,d,1,f):n.cursorStyle===2?t.fillRect(g,d+f-2,_,2):(t.fillRect(g,d,_,f),m?.text&&(t.fillStyle=i.cursorText,IP(m.text)?BP(t,m.text,{left:n.cursorX*r.width,top:u,width:r.width,height:r.height},s):(t.font=JP(m,i),t.fillText(m.text,n.cursorX*r.width+(r.width-r.faceWidth)/2,u+r.baseline))))}var $P=navigator.userAgent.includes(`Mac`),eF=500,tF=/https?:\/\/[^\s"'`<>]+/g;function nF(e){return e===0?1:e===1?3:e===2?2:null}function rF(e,t){let n=Math.max(0,e.total-e.len);if(t<=0||e.len<=0||n===0)return null;let r=Math.min(t,Math.max(20,t*e.len/e.total)),i=t-r;return{thumbHeight:r,thumbTop:i*(Math.min(e.offset,n)/n),travel:i,maxOffset:n}}var iF=class{hoveredLink=null;context;linkPointer=null;mousePointer=null;mouseButton=null;lastMotion=``;selectionPointer=null;selectionMode=`cell`;selectionAnchor=null;selectionBase=null;selectionMoved=!1;selectionScroll=null;selectionScrollDelta=0;selectionClient=null;clickMove=null;clicks={count:0,time:0,x:0,y:0};touch=null;wheelRemainder=0;scrollbarDrag=null;constructor(e){this.context=e;let t=e.canvas,n=e.scrollbar;t.addEventListener(`pointerdown`,this.onPointerDown),t.addEventListener(`pointermove`,this.onPointerMove),t.addEventListener(`pointerup`,this.onPointerUp),t.addEventListener(`pointercancel`,this.onPointerUp),t.addEventListener(`pointerleave`,this.onPointerLeave),t.addEventListener(`wheel`,this.onWheel,{passive:!1}),t.addEventListener(`mousedown`,this.onMouseDown),n.addEventListener(`pointerdown`,this.onScrollbarDown),n.addEventListener(`pointermove`,this.onScrollbarMove),n.addEventListener(`pointerup`,this.onScrollbarUp),n.addEventListener(`pointercancel`,this.onScrollbarUp)}updateScrollbar(e){let t=this.context.core.scrollbarState(),n=t===null?null:rF(t,e);this.context.scrollbar.hidden=n===null,n!==null&&(this.context.thumb.style.height=`${n.thumbHeight}px`,this.context.thumb.style.transform=`translateY(${n.thumbTop}px)`)}dispose(){this.setSelectionScroll(0)}scrollRows(e,t){let n=this.context.core,r=this.wheelRemainder+e/this.context.view().metrics.height,i=Math.trunc(r);if(this.wheelRemainder=r-i,i!==0){if(this.reportsMouse(t))for(let e=0;e<Math.abs(i);e+=1)this.sendMouse(`press`,i<0?4:5,t);else if(n.isAlternateScreen()){let e=(n.isApplicationCursorKeys()?`\x1BO`:`\x1B[`)+(i<0?`A`:`B`);this.context.onData(e.repeat(Math.abs(i)))}else this.context.scrollViewport(i)}}cellAt(e,t){let n=this.context.view(),r=this.context.canvas.getBoundingClientRect();return{x:Math.max(0,Math.min(n.cols-1,Math.floor((e-r.left)/n.metrics.width))),y:Math.max(0,Math.min(n.rows-1,Math.floor((t-r.top)/n.metrics.height)))}}reportsMouse(e){return this.context.core.isMouseTracking()&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey}sendMouse(e,t,n){let r=this.context.view(),i=this.context.canvas.getBoundingClientRect(),a=window.devicePixelRatio||1,o=this.context.core.encoder.encodeMouse({action:e,button:t,mods:+!!n.shiftKey|(n.ctrlKey?2:0)|(n.altKey?4:0)|(n.metaKey?8:0),x:Math.max(0,n.clientX-i.left)*a,y:Math.max(0,n.clientY-i.top)*a,screenWidth:r.cols*r.metrics.width*a,screenHeight:r.rows*r.metrics.height*a,cellWidth:r.metrics.width*a,cellHeight:r.metrics.height*a,anyButtonPressed:n.buttons!==0});if(o.length!==0){if(e===`motion`){if(o===this.lastMotion)return;this.lastMotion=o}else this.lastMotion=``;this.context.onData(o)}}linkAt(e,t){let n=this.context.view(),r=this.context.core,i=n.snapshot;if(!i)return null;let a=this.context.canvas.getBoundingClientRect(),o=e-a.left,s=t-a.top;if(o<0||s<0||o>=n.cols*n.metrics.width||s>=n.rows*n.metrics.height)return null;let c={x:Math.floor(o/n.metrics.width),y:Math.floor(s/n.metrics.height)},l=r.hyperlinkAt(c.x,c.y);if(l!==null){if(l.startsWith(`offsite-image:`))return null;let e=c.x,t=c.x;for(;e>0&&r.hyperlinkAt(e-1,c.y)===l;)--e;for(;t<n.cols-1&&r.hyperlinkAt(t+1,c.y)===l;)t+=1;return{uri:l,range:{start:{x:e,y:c.y},end:{x:t,y:c.y}}}}let u=c.y;for(;u>0&&i.rowData[u]?.isWrapContinuation;)--u;let d=c.y;for(;d<i.rows-1&&i.rowData[d]?.wrapsToNext;)d+=1;let f=``,p=[];for(let e=u;e<=d;e+=1){let t=i.rowData[e];if(!t)break;let n=YN(t,e);f+=n.text,p.push(...n.points)}for(let e of f.matchAll(tF)){let t=e[0].replace(/[.,;:!?)\]}'"]+$/,``),n=p[e.index],r=p[e.index+t.length-1];if(!n||!r)continue;let i={start:n,end:r};if(ZP(i,c.y,c.x))return{uri:t,range:i}}return null}setHoveredLink(e){let t=this.hoveredLink;this.context.canvas.style.cursor=e?`pointer`:``,(t?.uri!==e?.uri||t?.range.start.x!==e?.range.start.x||t?.range.start.y!==e?.range.start.y)&&(this.hoveredLink=e,this.context.redraw())}beginSelection(e,t){let n=this.context.core,r=this.cellAt(e.clientX,e.clientY),i=n.toScreen(r);if(!i)return;this.selectionMoved=!1,this.selectionMode=t>=3?`line`:t===2?`word`:`cell`;let a=this.selectionMode===`line`?n.selectLine(i):this.selectionMode===`word`?n.selectWord(i):null;this.selectionAnchor=a?a.start:i,this.selectionBase=a,a?n.setSelection(a.start,a.end):(this.selectionMode=`cell`,n.setSelection(i,i)),this.context.redraw()}extendSelection(e,t){let n=this.context.core,r=this.selectionAnchor;if(!r)return;let i=this.cellAt(e,t),a=n.toScreen(i);if(!a)return;this.selectionMoved=!0;let o=this.selectionBase;if(o===null)n.setSelection(r,a);else{let e=this.selectionMode===`line`?n.selectLine(a):n.selectWord(a),t=a.y<o.start.y||a.y===o.start.y&&a.x<o.start.x;n.setSelection(t?o.end:o.start,e?t?e.start:e.end:a)}this.context.redraw()}setSelectionScroll(e){this.selectionScrollDelta=e,e===0?(this.selectionScroll!==null&&window.clearInterval(this.selectionScroll),this.selectionScroll=null):this.selectionScroll===null&&(this.selectionScroll=window.setInterval(()=>{this.context.scrollViewport(this.selectionScrollDelta);let e=this.selectionClient;e&&this.extendSelection(e.x,e.y)},80))}dragScrollbar(e){let t=this.context.core.scrollbarState(),n=this.scrollbarDrag;if(t===null||n===null)return;let r=this.context.scrollbar.getBoundingClientRect(),i=rF(t,r.height);if(i===null||i.travel===0)return;let a=Math.max(0,Math.min(e-r.top-n.offset,i.travel)),o=Math.round(a/i.travel*i.maxOffset);this.context.scrollViewport(o-t.offset)}onPointerDown=e=>{let t=this.context.canvas;if(this.context.focus(),e.pointerType===`touch`){this.touch={id:e.pointerId,y:e.clientY,moved:!1},t.setPointerCapture(e.pointerId);return}if(this.reportsMouse(e)){let n=nF(e.button);if(n===null)return;e.preventDefault(),this.mousePointer=e.pointerId,this.mouseButton=n,this.sendMouse(`press`,n,e),t.setPointerCapture(e.pointerId);return}if(e.button!==0)return;if(this.linkAt(e.clientX,e.clientY)&&($P?e.metaKey:e.ctrlKey)){e.preventDefault(),this.linkPointer=e.pointerId;return}let n=e.timeStamp-this.clicks.time<=eF&&Math.hypot(e.clientX-this.clicks.x,e.clientY-this.clicks.y)<=4;this.clicks={count:n?this.clicks.count>=3?1:this.clicks.count+1:1,time:e.timeStamp,x:e.clientX,y:e.clientY},this.clickMove=!e.altKey&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this.context.view().clickToMoveCursor&&this.clicks.count===1?this.cellAt(e.clientX,e.clientY):null,this.selectionPointer=e.pointerId,this.beginSelection(e,this.clicks.count),t.setPointerCapture(e.pointerId)};onPointerMove=e=>{let t=this.touch;if(t?.id===e.pointerId){let n=t.y-e.clientY;if(Math.abs(n)<1)return;t.y=e.clientY,t.moved=!0,this.scrollRows(n,e)}else if(this.mousePointer===e.pointerId||this.context.core.isMouseAnyEventTracking()&&this.reportsMouse(e)){let t=e.buttons,n=t&1?1:t&4?3:t&2?2:null;this.sendMouse(`motion`,n,e)}else if(this.selectionPointer===e.pointerId){let t=this.cellAt(e.clientX,e.clientY);this.clickMove!==null&&(t.x!==this.clickMove.x||t.y!==this.clickMove.y)&&(this.clickMove=null),this.selectionClient={x:e.clientX,y:e.clientY};let n=this.context.canvas.getBoundingClientRect();this.setSelectionScroll(e.clientY<n.top?-1:+(e.clientY>n.bottom)),this.extendSelection(e.clientX,e.clientY)}else this.setHoveredLink(this.linkAt(e.clientX,e.clientY))};onPointerUp=e=>{let t=this.context.canvas;if(t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),this.touch?.id===e.pointerId)this.touch=null;else if(this.linkPointer===e.pointerId){this.linkPointer=null;let t=this.linkAt(e.clientX,e.clientY);t&&e.type===`pointerup`&&this.context.onLink(t.uri,e)}else if(this.mousePointer===e.pointerId)this.sendMouse(`release`,this.mouseButton,e),this.mousePointer=null,this.mouseButton=null;else if(this.selectionPointer===e.pointerId){this.selectionPointer=null,this.setSelectionScroll(0),!this.selectionMoved&&this.selectionMode===`cell`&&(this.context.core.clearSelection(),this.selectionAnchor=null,this.context.redraw());let t=this.clickMove;this.clickMove=null,t!==null&&e.type===`pointerup`&&this.context.moveCursorTo(t)}};onPointerLeave=()=>{this.lastMotion=``,this.setHoveredLink(null)};onWheel=e=>{if(e.deltaY===0)return;e.preventDefault();let t=this.context.view(),n=e.deltaMode===1?e.deltaY*t.metrics.height:e.deltaMode===2?e.deltaY*t.rows*t.metrics.height:e.deltaY;this.scrollRows(n,e)};onMouseDown=e=>{e.button===0&&e.preventDefault(),this.context.focus()};onScrollbarDown=e=>{let t=this.context.core.scrollbarState();if(e.button!==0||t===null)return;let n=this.context.scrollbar,r=n.getBoundingClientRect(),i=rF(t,r.height);i!==null&&(e.preventDefault(),e.stopPropagation(),this.scrollbarDrag={id:e.pointerId,offset:e.target===this.context.thumb?e.clientY-r.top-i.thumbTop:i.thumbHeight/2},n.setPointerCapture(e.pointerId),this.dragScrollbar(e.clientY))};onScrollbarMove=e=>{this.scrollbarDrag?.id===e.pointerId&&(e.preventDefault(),this.dragScrollbar(e.clientY))};onScrollbarUp=e=>{if(this.scrollbarDrag?.id!==e.pointerId)return;this.scrollbarDrag=null;let t=this.context.scrollbar;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}},aF=[`\r`,`
|
|
16
|
-
`,``,``,``,``,`\x1B[99;5u`,`\x1B[100;5u`,`\x1B[111;5u`,`\x1B[122;5u`];function oF(e,t){return e.y<t.y||e.y===t.y&&e.x<t.x}var sF=class{shell=`unknown`;generation=0;core;native=!1;input=!1;clickEvents=!1;inputRef=null;constructor(e){this.core=e}mark(e,t){let n=e.startsWith(`133;`),r=n?4:5;if(e.length>r+1&&e[r+1]!==`;`)return;let i=e.charAt(r);if(!this.core.isAlternateScreen()){if(i===`A`){let r=e.split(`;`);if(r.includes(`k=s`)||r.includes(`k=c`))return;let i=n&&r.includes(`click_events=1`),a=this.shell===`prompt`,o=a&&!this.input&&this.native!==n;if(this.shell=`prompt`,this.native=n,t&&this.trackInput(),o){this.clickEvents=this.clickEvents||i;return}if(this.input=!1,this.clickEvents=i,a)return;this.generation+=1}else if(i===`B`)this.shell=`prompt`,this.input=!0,t&&this.trackInput();else if(i===`C`)this.shell=`command`;else if(i===`D`){if(this.shell===`prompt`&&!this.input)return;this.shell=`unknown`}}}beforeInput(e){this.shell===`prompt`&&aF.some(t=>e.includes(t))&&(this.shell=`unknown`)}reset(){this.release(),this.shell=`unknown`,this.input=!1,this.clickEvents=!1}release(){this.inputRef!==null&&this.core.untrack(this.inputRef),this.inputRef=null}moveCursorInput(e,t,n){if(this.shell!==`prompt`||this.inputRef===null||t===null||t.cursorX<0||t.cursorY<0||this.core.isAlternateScreen()||this.core.isMouseTracking())return null;let r=this.core.trackedPoint(this.inputRef);if(r===null)return null;let i={x:r.x,y:r.y-n};if(oF(e,i))return null;if(this.clickEvents){let t=this.core.scrollbarState();if(t===null)return null;let r=e.y+n-(t.total-t.len);return r<0?null:`\x1b[<0;${e.x+1};${r+1}M`}if(!this.input)return null;let a={x:e.x,y:e.y};a.x>0&&t.rowData[a.y]?.cells[a.x]?.wide===BN.spacerTail&&--a.x;let o={x:t.cursorX,y:t.cursorY};if(oF(a,i)||oF(o,i))return null;let s=oF(a,o),c=s?a:o,l=s?o:a,u=0;for(let e=c.y;e<=l.y;e+=1){let n=t.rowData[e];if(n===void 0)return null;let r=e===l.y?l.x:n.cells.length;for(let t=e===c.y?c.x:0;t<r;t+=1)n.cells[t].text!==``&&(u+=1);if(e<l.y&&!n.wrapsToNext){if(s)return null;break}}let d=s?`ArrowLeft`:`ArrowRight`,f=this.core.encoder.encodeKey(new KeyboardEvent(`keydown`,{key:d,code:d}));return u>0?f.repeat(u):``}trackInput(){this.inputRef===null?this.inputRef=this.core.trackCursor():this.core.retrack(this.inputRef)}},cF=Fe.withTag(`terminal`),lF=navigator.userAgent.includes(`Mac`),uF=navigator.userAgent.includes(`Windows`),dF=600,fF=1e3,pF=1e4,mF=new TextDecoder(`latin1`),hF=new TextDecoder;function gF(e){let t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)throw Error(`unsupported color ${e}`);return{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}}function _F(e){return[...e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0).map(e=>/^(['"]).*\1$/.test(e)||/^[a-zA-Z][a-zA-Z0-9-]*$/.test(e)?e:`"${e.replaceAll(`"`,``)}"`),`monospace`].join(`, `)}async function vF(e){try{(await e)?.close()}catch(e){cF.warn(`could not decode image`,e)}}var yF=class{element;cols=80;rows=24;canvas;input;context;core;scanner=new wP;handlers;observer;prompt;search;images;pointer;notifications=new vP;options;appearance;metrics;snapshot=null;sized=!1;fitted=!1;frame=0;forceFull=!0;renderFailed=!1;cursorOn=!0;cursorTimer=null;syncTimer=null;renderedCursorY=null;focused=!1;composing=!1;suppressedKeys=new Set;heldOptionKeys=new Set;backlog=[];blocked=!1;epoch=0;title=``;progress={state:0,value:0};disposed=!1;constructor(e,t){this.options=e,this.handlers=t,this.element=document.createElement(`div`),this.element.className=`relative h-full overflow-hidden`,this.canvas=document.createElement(`canvas`),this.canvas.className=`absolute top-0 left-0 cursor-text touch-none`,this.input=document.createElement(`textarea`),this.input.setAttribute(`aria-label`,`Terminal input`),this.input.autocapitalize=`off`,this.input.autocomplete=`off`,this.input.spellcheck=!1,this.input.style.cssText=`position:absolute;left:0;top:0;width:1px;height:1px;opacity:0;padding:0;border:0;resize:none;pointer-events:none;`;let n=document.createElement(`div`);n.className=`absolute top-0 right-0 bottom-0 w-2 cursor-default touch-none`,n.hidden=!0;let r=document.createElement(`div`);r.className=`bg-foreground/15 hover:bg-foreground/30 absolute inset-x-0.5 top-0 rounded-full`,n.append(r),this.element.append(this.canvas,this.input,n);let i=this.canvas.getContext(`2d`,{alpha:!1});if(!i)throw Error(`canvas 2d is unavailable`);this.context=i,this.appearance=this.appearanceFor(e),this.metrics=this.measure(),this.core=new rP(Math.max(1,Math.floor(window.innerWidth/this.metrics.width)),this.rows,e.scrollback,t.onReply,t.onBell),this.prompt=new sF(this.core),this.search=new aP(this.core,()=>this.redraw()),this.images=new LM(this.core),this.pointer=new iF({canvas:this.canvas,scrollbar:n,thumb:r,core:this.core,view:()=>({cols:this.cols,rows:this.rows,metrics:this.metrics,snapshot:this.snapshot,clickToMoveCursor:this.options.clickToMoveCursor}),focus:()=>this.focus(),redraw:()=>this.redraw(),scrollViewport:e=>this.scrollViewport(e),moveCursorTo:e=>this.moveCursorTo(e),onData:t.onData,onLink:t.onLink}),this.applyTerminalOptions(),this.resizeCore(),this.installEvents(),this.observer=new ResizeObserver(()=>this.fit()),this.observer.observe(this.element)}setOptions(e){this.options=e,this.appearance=this.appearanceFor(e),this.metrics=this.measure(),e.clickToMoveCursor||this.prompt.release(),this.applyTerminalOptions(),this.resizeCore(),this.forceFull=!0,this.fit(),this.requestRender()}write(e,t){this.disposed||(this.backlog.push({data:e,replay:t}),this.blocked||this.drain())}reset(){this.epoch+=1,this.backlog=[],this.blocked=!1,this.scanner.reset(),this.prompt.reset(),this.core.reset(),this.applyTerminalOptions(),this.images.clear(),this.core.clearSelection(),this.redraw()}focus(){this.input.focus({preventScroll:!0})}isKittyKeyboard(){return this.core.isKittyKeyboard()}paste(e){let t=this.core.encoder.encodePaste(e);t.length>0&&this.sendInput(t)}presize(e,t){this.fitted||e===this.cols&&t===this.rows||(this.cols=e,this.rows=t,this.resizeCore())}fit(){if(this.disposed)return;let e=this.element.clientWidth,t=this.element.clientHeight;if(e===0||t===0){this.sized=!1;return}this.sized=!0,this.fitted=!0;let n=window.devicePixelRatio||1,r=Math.round(e*n),i=Math.round(t*n);(this.canvas.width!==r||this.canvas.height!==i)&&(this.canvas.width=r,this.canvas.height=i,this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this.context.setTransform(n,0,0,n,0,0),this.metrics=this.measure(),this.resizeCore(),this.forceFull=!0);let a=Math.max(1,Math.floor(e/this.metrics.width)),o=Math.max(1,Math.floor(t/this.metrics.height));(a!==this.cols||o!==this.rows)&&(this.cols=a,this.rows=o,this.resizeCore(),this.forceFull=!0,this.handlers.onResize(a,o)),this.renderFrame()}find(e,t,n){let r=this.viewportTop(),i=this.search.find(e,t,n,r);i!==null&&(i.row<r||i.row>=r+this.rows)&&this.scrollViewport(i.row-r-Math.floor(this.rows/2)),this.redraw()}onFindResults(e){return this.search.onResults(e)}clearFind(){this.search.clear(),this.redraw()}replyClipboard(e,t){t.epoch!==this.epoch||t.generation!==this.prompt.generation||t.atPrompt&&this.prompt.shell!==`prompt`||this.handlers.onReply(pP(e,t.selection,t.terminator))}beforeInput(e){this.prompt.beforeInput(e)}dispose(){this.disposed||(this.disposed=!0,this.observer.disconnect(),this.cancelRender(),this.pointer.dispose(),this.search.dispose(),window.removeEventListener(`focus`,this.onWindowFocus),document.removeEventListener(`visibilitychange`,this.onVisibilityChange),this.images.clear(),this.prompt.release(),this.core.dispose(),this.element.remove())}redraw(){this.forceFull=!0,this.requestRender()}resizeCore(){this.core.resize(this.cols,this.rows,this.metrics.width,this.metrics.height,window.devicePixelRatio||1)}appearanceFor(e){let t=e.colors;return{fontSize:e.fontSize,fontFamily:_F(e.fontFamily),ligatures:e.ligatures,cursorText:t.cursorText,selectionBackground:t.selectionBackground,selectionForeground:t.selectionForeground,matchBackground:t.palette[8],activeMatchBorder:t.palette[3]}}measure(){return YP(this.context,this.options.fontSize,this.appearance.fontFamily,this.options.lineHeight,window.devicePixelRatio||1)}applyTerminalOptions(){let e=this.options.colors;this.core.setColors({foreground:gF(e.foreground),background:gF(e.background),cursor:gF(e.cursor),palette:e.palette.map(gF)}),this.core.setCursor(this.options.cursorStyle,this.options.cursorBlink),this.core.boldIsBright=this.options.boldIsBright,this.core.version=this.options.version,this.core.invalidate()}drain(){for(;!this.blocked&&this.backlog.length>0;){let e=this.backlog.shift();e&&this.process(e)}let e=this.core.title();e!==this.title&&(this.title=e,this.handlers.onTitle(e)),this.search.outputChanged(),this.cursorOn=!0,this.requestRender()}process(e){let t=e.data,n=e.replay;this.core.setReplies(!n);let r=0,i=this.scanner.scan(t,(e,i)=>(this.core.write(t.subarray(r,i)),r=i,this.handleOutput(e,n)));this.core.write(t.subarray(r,i)),i<t.length&&this.backlog.unshift({data:t.subarray(i),replay:n})}handleOutput(e,t){if(e.type===`sixel`)return this.decodeImage(NM(e.data));let n=mF.decode(e.data);if(n.startsWith(`1337;File=`))return this.decodeImage(FM(n.slice(10),{cellWidth:this.metrics.width,cellHeight:this.metrics.height,width:this.cols*this.metrics.width,height:this.rows*this.metrics.height,pixelRatio:window.devicePixelRatio||1}));if(n.startsWith(`133;`)||n.startsWith(`6973;`))return this.prompt.mark(n,this.options.clickToMoveCursor),!1;if(n.startsWith(`52;`)){let r=n.split(`;`),i=r[2];if(t||i===void 0)return!1;if(i===`?`)return this.handlers.onClipboardRead({selection:dP(r[1]),terminator:e.terminator,generation:this.prompt.generation,epoch:this.epoch,atPrompt:this.prompt.shell===`prompt`}),!1;let a=fP(i);return a!==null&&this.handlers.onClipboard(a),!1}if(n===`10;?`||n===`11;?`||n===`12;?`)return t||this.handlers.onReply(mP(n,this.core.currentColors(),e.terminator)),!1;if(n.startsWith(`4;`)){if(!t)for(let t of hP(n,this.core.currentColors().palette,e.terminator))this.handlers.onReply(t);return!1}if(n===`9;4`||n.startsWith(`9;4;`)){let e=gP(n,this.progress);return e!==null&&(this.progress=e,this.handlers.onProgress(e)),!1}if(t)return!1;let r=n.startsWith(`99;`)?this.notifications.add(hF.decode(e.data)):_P(n,e.data);return r!==null&&this.handlers.onNotify(r.title,r.body),!1}decodeImage(e){return this.blocked=!0,this.placeImage(e,this.epoch,window.devicePixelRatio||1),!0}async placeImage(e,t,n){let r=0,i=new Promise(e=>{r=window.setTimeout(()=>e(`timeout`),pF)});try{let r=await Promise.race([e,i]);r===`timeout`?(cF.warn(`image decoding took too long, skipping the image`),vF(e)):r!==null&&(t===this.epoch&&!this.disposed?this.images.place(r,n,this.metrics.height):r.close())}catch(e){cF.warn(`could not decode image`,e)}window.clearTimeout(r),t!==this.epoch||this.disposed||(this.blocked=!1,this.drain())}moveCursorTo(e){if(!this.options.clickToMoveCursor)return;let t=this.prompt.moveCursorInput(e,this.snapshot,this.viewportTop());t!==null&&(t!==``&&this.sendInput(t),this.core.clearSelection(),this.redraw())}sendInput(e){this.prompt.beforeInput(e),this.core.scrollbarState()?.offset!==this.maxOffset()&&(this.core.scrollToBottom(),this.redraw()),this.handlers.onData(e)}maxOffset(){let e=this.core.scrollbarState();return e?Math.max(0,e.total-e.len):0}viewportTop(){return this.core.toScreen({x:0,y:0})?.y??0}scrollViewport(e){let t=this.core.scrollbarState(),n=Math.trunc(e);if(t!==null){let e=Math.max(0,t.total-t.len);n=Math.max(0,Math.min(t.offset+n,e))-t.offset}n!==0&&(this.core.scroll(n),this.redraw())}requestRender(){!this.disposed&&this.sized&&this.frame===0&&(this.frame=window.requestAnimationFrame(()=>{this.frame=0,this.renderFrame()}))}cancelRender(){this.frame!==0&&window.cancelAnimationFrame(this.frame),this.frame=0,this.cursorTimer!==null&&window.clearTimeout(this.cursorTimer),this.cursorTimer=null,this.syncTimer!==null&&window.clearTimeout(this.syncTimer),this.syncTimer=null}renderFrame(){if(!this.disposed&&this.sized&&this.element.isConnected){this.frame!==0&&window.cancelAnimationFrame(this.frame),this.frame=0;try{this.draw(),this.renderFailed=!1}catch(e){this.renderFailed||cF.error(`could not draw the terminal`,e),this.renderFailed=!0}}}draw(){if(this.core.isSynchronizedOutput()){this.syncTimer===null&&(this.syncTimer=window.setTimeout(()=>{this.syncTimer=null,this.core.endSynchronizedOutput(),this.requestRender()},fF));return}this.syncTimer!==null&&window.clearTimeout(this.syncTimer),this.syncTimer=null;let e=this.core.snapshot();this.snapshot=e;let t=this.focused&&e.cursorBlinking&&e.cursorVisible;t||(this.cursorOn=!0);let n=this.viewportTop(),r=this.images.visible(n,this.rows,this.metrics.height),i=this.core.cellSize(),a=this.core.kitty.images(e.rowData,i);QP({context:this.context,snapshot:e,metrics:this.metrics,appearance:this.appearance,forceFull:this.forceFull||r.length>0||a.length>0,cursorOn:this.cursorOn,previousCursorY:this.renderedCursorY,focused:this.focused,hoveredLink:this.pointer.hoveredLink?.range??null,highlights:this.search.highlights(e,n),pixelRatio:window.devicePixelRatio||1,drawLayer:e=>DN(this.context,a,e,this.metrics,i)}),DN(this.context,a,`aboveText`,this.metrics,i);for(let e of r)this.context.drawImage(e.bitmap,e.x*this.metrics.width,e.y*this.metrics.height,e.width,e.height);this.forceFull=r.length>0||a.length>0,this.renderedCursorY=this.cursorOn&&e.cursorVisible&&e.cursorY>=0?e.cursorY:null,e.cursorX>=0&&e.cursorY>=0&&(this.input.style.left=`${e.cursorX*this.metrics.width}px`,this.input.style.top=`${e.cursorY*this.metrics.height}px`),this.pointer.updateScrollbar(this.element.clientHeight),this.cursorTimer!==null&&window.clearTimeout(this.cursorTimer),this.cursorTimer=null,t&&(this.cursorTimer=window.setTimeout(()=>{this.cursorTimer=null,this.cursorOn=!this.cursorOn,this.requestRender()},dF))}copySelection(){let e=this.core.selectionText();e.length!==0&&(window.isSecureContext?navigator.clipboard.writeText(e):cF.warn(`copy from the terminal needs https or localhost`))}optionIsMeta(e){if(!lF||!e.altKey||e.metaKey)return!1;let t=this.options.optionAsMeta;if(t===`off`)return!1;if(t===`both`)return!0;if(t===`left`)return this.heldOptionKeys.has(`AltLeft`);if(t===`right`)return this.heldOptionKeys.has(`AltRight`);throw Error(`unknown option as meta mode ${t}`)}onKeyDown=e=>{if((e.code===`AltLeft`||e.code===`AltRight`)&&this.heldOptionKeys.add(e.code),!this.handlers.beforeKey(e)){this.suppressedKeys.add(e.code);return}let t=this.optionIsMeta(e),n=t&&this.core.encoder.metaText(e)!==null;if(e.isComposing||this.composing||!n&&(e.key===`Process`||e.keyCode===229)||lF&&this.options.optionAsMeta!==`off`&&!t&&e.altKey&&!e.ctrlKey&&!e.metaKey&&([...e.key].length===1||e.key===`Dead`)||!n&&e.getModifierState(`AltGraph`)&&[...e.key].length===1){this.suppressedKeys.add(e.code);return}let r=e.key.toLowerCase(),i=uF&&this.options.windowsCopyPaste&&e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey;if(i&&r===`c`&&this.core.selectionText().length>0){this.copySelection(),this.core.clearSelection(),this.redraw(),e.preventDefault(),this.suppressedKeys.add(e.code);return}if(lF?e.metaKey&&r===`c`:e.ctrlKey&&e.shiftKey&&r===`c`||e.ctrlKey&&!e.shiftKey&&r===`insert`){this.copySelection(),e.preventDefault(),this.suppressedKeys.add(e.code);return}if((lF?e.metaKey&&r===`v`:e.ctrlKey&&e.shiftKey&&r===`v`||e.shiftKey&&!e.ctrlKey&&r===`insert`||i&&r===`v`)||lF&&e.metaKey&&r===`q`){this.suppressedKeys.add(e.code);return}let a=this.core.encoder.encodeKey(e,`press`,n);a.length!==0&&(this.suppressedKeys.delete(e.code),e.preventDefault(),e.stopPropagation(),this.core.selectionText().length>0&&!e.shiftKey&&(this.core.clearSelection(),this.forceFull=!0),this.sendInput(a))};onKeyUp=e=>{if(this.heldOptionKeys.delete(e.code),this.suppressedKeys.delete(e.code)||e.isComposing||this.composing)return;let t=this.core.encoder.encodeKey(e,`release`,this.optionIsMeta(e));t.length!==0&&(e.preventDefault(),this.handlers.onData(t))};onInput=e=>{let t=e;if(this.composing||t.isComposing)return;let n=this.input.value||t.data||``;this.input.value=``,n.length>0&&this.sendInput(n)};onCompositionStart=()=>{this.composing=!0};onCompositionEnd=e=>{this.composing=!1;let t=this.input.value||e.data;this.input.value=``,t.length>0&&this.sendInput(t)};onPaste=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`)??``;t.length>0&&this.paste(t)};onCopy=e=>{let t=this.core.selectionText();t.length!==0&&e.clipboardData&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,t))};onWindowFocus=()=>{lF&&this.options.optionAsMeta!==`off`&&this.core.encoder.refreshKeyboardLayout()};onContextRestored=()=>{let e=window.devicePixelRatio||1;this.context.setTransform(e,0,0,e,0,0),this.redraw()};onVisibilityChange=()=>{document.visibilityState===`visible`&&this.redraw()};onFocus=()=>{this.focused=!0,this.cursorOn=!0,this.requestRender(),!this.disposed&&this.core.isFocusReporting()&&this.handlers.onReply(`\x1B[I`)};onBlur=()=>{this.focused=!1,this.heldOptionKeys.clear(),this.cursorOn=!0,this.requestRender(),!this.disposed&&this.core.isFocusReporting()&&this.handlers.onReply(`\x1B[O`)};installEvents(){this.input.addEventListener(`keydown`,this.onKeyDown),this.input.addEventListener(`keyup`,this.onKeyUp),this.input.addEventListener(`input`,this.onInput),this.input.addEventListener(`compositionstart`,this.onCompositionStart),this.input.addEventListener(`compositionend`,this.onCompositionEnd),this.input.addEventListener(`paste`,this.onPaste),this.input.addEventListener(`copy`,this.onCopy),this.input.addEventListener(`focus`,this.onFocus),this.input.addEventListener(`blur`,this.onBlur),this.canvas.addEventListener(`contextrestored`,this.onContextRestored),window.addEventListener(`focus`,this.onWindowFocus),document.addEventListener(`visibilitychange`,this.onVisibilityChange)}},bF=Fe.withTag(`terminal`),xF=new Map,SF=new Map,CF=null,wF=0;function TF(e){return iI().open&&sI()?.tabId===e&&!document.hidden&&document.hasFocus()}function EF(e){if(TF(e))return!1;let t=iI();return t.alerts.includes(e)||aI({alerts:[...t.alerts,e]}),!0}function DF(e){if(!EF(e)||SF.has(e))return;let t=xF.get(e);t!==void 0&&performance.now()-t<5e3||SF.set(e,window.setTimeout(()=>{SF.delete(e),TF(e)||(xF.set(e,performance.now()),kF(e,``,`Bell`))},500))}function OF(e,t,n){EF(e)&&(window.clearTimeout(SF.get(e)),SF.delete(e),xF.set(e,performance.now()),kF(e,t,n))}function kF(e,t,n){let r=uI(e);r&&Ia(t||dI(r),n,{machine:nI(),project:r.projectId??`global`,tabId:e}).catch(e=>bF.error(`could not show a notification`,e))}function AF(){let e=performance.now();if(e-wF<150)return;wF=e,CF??=new AudioContext,CF.state===`suspended`&&CF.resume();let t=CF.createOscillator(),n=CF.createGain(),r=CF.currentTime;t.frequency.value=880,n.gain.setValueAtTime(.1,r),n.gain.exponentialRampToValueAtTime(.001,r+.15),t.connect(n).connect(CF.destination),t.start(r),t.stop(r+.15)}function jF(e){return{alerts:iI().alerts.filter(t=>e(t)&&!TF(t))}}function MF(e){window.clearTimeout(SF.get(e)),SF.delete(e),xF.delete(e)}function NF(e){return e.key===`Enter`&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey}function PF(e){let t=new yF(tI(),{onData:t=>{iI().status===`active`&&yI(e,FF(t))},onReply:t=>{t===`\x1B[I`||t===`\x1B[O`?yI(e,t):bI(e,t)},onResize:(t,n)=>_I({type:`resize`,id:e,cols:t,rows:n}),onTitle:t=>aI({titles:{...iI().titles,[e]:t}}),onProgress:t=>aI({progress:{...iI().progress,[e]:t}}),onBell:()=>{let n=oI().behavior;n.bellSound&&AF(),n.bellFlash&&t.element.isConnected&&!document.hidden&&t.element.animate([{opacity:.4},{opacity:1}],{duration:200,easing:`ease-out`}),DF(e)},onNotify:(t,n)=>OF(e,t,n),onClipboard:$O,onClipboardRead:n=>{TF(e)&&ek(e=>t.replyClipboard(e,n))},onLink:e=>{e.startsWith(`file:`)?Ot(e):window.open(e,`_blank`,`noopener`)},beforeKey:n=>{if(n.type!==`keydown`)return!0;let r=oI(),i=Ge(R(),nI()).system;if(i===null)throw Error(`the terminal machine is not connected`);let a=i.platform;if(iI().status===`active`&&r.behavior.modernizeShiftEnter&&NF(n)&&!t.isKittyKeyboard())return n.preventDefault(),t.beforeInput(`\x1B\r`),yI(e,`\x1B\r`),!1;if(iI().status===`active`&&r.behavior.pasteBrowserImages&&window.isSecureContext&&nk(n,a)&&!(Lt&&r.behavior.windowsCopyPaste&&n.ctrlKey)){n.preventDefault();let r=tk[a].data;return t.beforeInput(r),rk(nI(),t).then(t=>{t||yI(e,r)}).catch(t=>{ak(t),yI(e,r)}),!1}return!OI(n)||(n.preventDefault(),aI({finding:e}),document.querySelector(`[data-find]`)?.select(),!1)}});return t.element.addEventListener(`paste`,e=>{if(!e.clipboardData||e.clipboardData.getData(`text/plain`)!==``)return;let n=[...e.clipboardData.files].filter(e=>e.type.startsWith(`image/`));n.length!==0&&(e.preventDefault(),e.stopPropagation(),ik(nI(),t,n).catch(ak))},!0),t}function FF(e){if(!iI().ctrl||(aI({ctrl:!1}),e.length!==1))return e;let t=e.toUpperCase().charCodeAt(0);return t>=64&&t<=95?String.fromCharCode(t-64):e}var IF=Fe.withTag(`terminal`);function LF(e,t){Ve(e,t)}function RF(e){let t=e.terminals.map(lI),n=localStorage.getItem(`lastTerminalView`);LF(e.id,t.find(e=>e===n)??t.at(0)??`global`)}async function zF(e,t){try{await L(e,`terminal`,{type:`createTab`,projectId:t})}catch(e){IF.error(`terminal request failed`,e);return}LF(e,t??`global`)}function BF(){let e=iI(),t=Xe();if(t===null||e.instance===null||t!==nI()||cI(e.layout,A()).length>0)return;let n=e.layout.tabs.at(0);if(n!==void 0){LF(t,lI(n));return}let r=R().machines.find(e=>e.id!==t&&e.status===`online`&&e.terminals.length>0);r===void 0?le(`chat`,()=>void yt.navigate({to:`/`,search:{},replace:!0})):RF(r)}var VF=Fe.withTag(`terminal`);function HF(){return{titles:{},progress:{},alerts:[],finding:null}}var UF=new TextEncoder,WF=new Map,GF=new Set,KF=new Set,qF={status:`connecting`,failure:null,loaded:!1,open:!1,instance:null,layout:{tabs:[],active:{}},ctrl:!1,...HF()},JF=null,YF=null,XF=!1,ZF=!1;async function QF(){h(),hI(),yt.history.subscribe(({action:e})=>{(e.type===`PUSH`||e.type===`REPLACE`)&&h(),hI()});try{await Promise.all([JM(),Vh(oI())]),aI({loaded:!0})}catch(e){VF.error(`could not start the terminal`,e),aI({failure:Ht(e)});return}ht({close:e=>{e===YF&&aI({status:`connecting`})},terminal:(e,t)=>{e===YF&&EI(t)},frame:(e,t)=>{e===YF&&TI(t)}}),$F(),yt.history.subscribe($F),yt.history.subscribe(BF),document.addEventListener(`visibilitychange`,()=>aI({})),window.addEventListener(`focus`,()=>{aI({}),JF!==null&&kI(JF,AI(JF))}),window.addEventListener(`blur`,()=>aI({})),`serviceWorker`in navigator&&navigator.serviceWorker.addEventListener(`message`,e=>{e.data.type===`select`&&gI(e.data.machine,e.data.project,e.data.tabId)});let e=R().prefs,t=eI();Ze(()=>{$F();let n=R().prefs,r=eI(),i=n.theme!==e.theme||n.terminal!==e.terminal||r!==t;e=n,t=r,i&&MI()}),NI()}function $F(){let e=Xe()??R().selection?.machine??null;if(e!==YF&&(YF!==null&&XF&&_I({type:`detach`}),DI([]),GF.clear(),YF=e,XF=!1,aI({status:`connecting`,instance:null,layout:{tabs:[],active:{}},...HF()})),YF===null)return;let t=Ge(R(),YF).status===`online`;t&&!XF&&(XF=!0,_I({type:`attach`})),t||(XF=!1)}function eI(){return YF===null?null:Ge(R(),YF).config?.terminal.behavior.terminalIdentity??null}function tI(){if(YF===null)throw Error(`the terminal has no machine`);let e=Ge(R(),YF);if(e.config===null||e.system===null)throw Error(`${e.name} is not connected`);return Hh(oI(),e.config.terminal.behavior.terminalIdentity)}function nI(){if(YF===null)throw Error(`the terminal has no machine`);return YF}function rI(e){return KF.add(e),()=>{KF.delete(e)}}function iI(){return qF}function aI(e){qF={...qF,...e},qF={...qF,...jF(e=>WF.has(e))};for(let e of KF)e()}function oI(){return R().prefs.terminal}function sI(){let e=Xe()===null?R().selection?.projectId:A();return e===void 0?null:{view:e,tabs:cI(qF.layout,e),tabId:qF.layout.active[e]??null}}function cI(e,t){return e.tabs.filter(e=>lI(e)===t)}function lI(e){return e.projectId??`global`}function uI(e){return qF.layout.tabs.find(t=>t.id===e)}function dI(e){return(e.customName??qF.titles[e.id])||`Terminal`}function fI(e){e?(pI(),f({bottom:`terminal`})):le(`overlay`,()=>f({bottom:void 0}))}function pI(){qF.open||(ZF=!0)}function mI(e){let t=ZF;ZF=!1,cI(qF.layout,e).length>0||(t?_I({type:`createTab`,projectId:e}):fI(!1))}function hI(){let e=jt().bottom===`terminal`||Xe()!==null;e!==qF.open&&aI({open:e})}function gI(e,t,n){if(t===`global`)LF(e,Ue);else{let n=R().selection;(n?.machine!==e||n.projectId!==t)&&Ie({machine:e,projectId:t,sessionId:null}),fI(!0)}vI(e,{type:`select`,view:t,tabId:n})}function _I(e){YF!==null&&vI(YF,e)}function vI(e,t){ot(e)&&L(e,`terminal`,t).catch(e=>VF.error(`terminal request failed`,e))}function yI(e,t){YF!==null&&et(YF,0,e,typeof t==`string`?UF.encode(t):t)}function bI(e,t){YF!==null&&et(YF,1,e,UF.encode(t))}function xI(e,t,n,r){AI(e).find(t,n,r)}function SI(e,t){return AI(e).onFindResults(t)}function CI(e){let t=AI(e);t.clearFind(),aI({finding:null}),t.focus()}function wI(){aI({ctrl:!qF.ctrl})}function TI(e){let t=WF.get(e.id);if(!t)return;let n=e.kind===3,r=n&&GF.delete(e.id);r&&t.reset(),t.write(e.data,n),r&&GF.size===0&&aI({status:`active`})}function EI(e){let t=e.type===`active`&&e.instance!==qF.instance;if(t&&DI([]),DI(e.layout.tabs),e.type===`active`){GF.clear(),WF.forEach((e,t)=>{GF.add(t),e.element.isConnected&&kI(t,e)}),aI({...t&&{instance:e.instance,...HF()},status:GF.size===0?`active`:`connecting`,layout:e.layout}),BF();return}for(let e of GF)WF.has(e)||GF.delete(e);let n=R().selection?.projectId,r=n!==void 0&&cI(qF.layout,n).length>0&&cI(e.layout,n).length===0;aI({status:GF.size===0?`active`:`connecting`,layout:e.layout}),r&&qF.open&&fI(!1),BF()}function DI(e){let t=new Set(e.map(e=>e.id));WF.forEach((e,n)=>{t.has(n)||(e.dispose(),WF.delete(n),MF(n))});for(let e of t)WF.has(e)||WF.set(e,PF(e))}function OI(e){return e.key.toLowerCase()===`f`?zt?e.metaKey&&!e.ctrlKey&&!e.altKey:e.ctrlKey&&e.shiftKey&&!e.altKey&&!e.metaKey:!1}function kI(e,t){_I({type:`resize`,id:e,cols:t.cols,rows:t.rows})}function AI(e){let t=WF.get(e);if(!t)throw Error(`terminal ${e} does not exist`);return t}function jI(e,t){let n=AI(e);t.append(n.element),n.fit();for(let e of WF.values())e.presize(n.cols,n.rows);return JF=e,kI(e,n),n.focus(),()=>{let t=n.element.contains(document.activeElement);n.element.remove(),t&&document.querySelector(`[data-composer]`)?.focus(),JF===e&&(JF=null)}}async function MI(){if(await Vh(oI()),WF.size>0){let e=tI();for(let t of WF.values())t.setOptions(e)}aI({})}function NI(){let e=jt(),t=Xe(),n=t??e.machine,r=t===null?e.project:Ue,i=e.terminal;if(n===void 0||r===void 0||i===void 0)return;f({terminal:void 0});let a=rI(()=>{qF.status===`active`&&YF===n&&(a(),gI(n,r,Number(i)))})}var PI=Fe.withTag(`terminal`),FI=null,II=null,LI=new Set,RI=new Set;function zI(e){return RI.add(e),()=>{RI.delete(e)}}function BI(){return FI}function VI(){FI!==null&&WI({open:!1,closing:FI.closing})}function HI(){return II}function UI(){II!==null&&GI({open:!1,closing:II.closing})}function WI(e){FI=e;for(let e of RI)e()}function GI(e){II=e;for(let e of RI)e()}function KI(){return document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)!==null}async function qI(e,t){try{let n=await Promise.race([L(e,`terminal.busy`,{id:t}),new Promise((e,t)=>window.setTimeout(()=>t(Error(`timed out`)),5e3))]);return`error`in n?(PI.error(`could not check whether tab ${t} is running a program`,n.error),{checked:!1}):{checked:!0,program:n.program}}catch(e){return PI.error(`could not check whether a program is running`,e),{checked:!1}}}async function JI(e){if(!oI().behavior.confirmCloseBusyTab){_I({type:`closeTab`,id:e});return}if(!uI(e)||LI.has(e))return;LI.add(e);let t=await qI(nI(),e);if(LI.delete(e),t.checked&&t.program===null){_I({type:`closeTab`,id:e});return}let n=uI(e);n&&!KI()&&WI({open:!0,closing:{id:e,name:dI(n),program:t.checked?t.program:null}})}function YI(e){for(let t of e)vI(t.machine,{type:`closeTab`,id:t.id})}async function XI(e){if(!oI().behavior.confirmCloseBusyTab){YI(e);return}let t=await Promise.all(e.map(e=>qI(e.machine,e.id)));if(t.every(e=>e.checked&&e.program===null)){YI(e);return}if(KI())return;let n=t.flatMap(e=>e.checked&&e.program!==null?[e.program]:[]);GI({open:!0,closing:{tabs:e,programs:[...new Set(n)]}})}var ZI=zt?`meta+t`:`ctrl+shift+t`,QI=zt?`meta+w`:`ctrl+shift+w`,$I=`ctrl+tab`,eL=`ctrl+shift+tab`;function tL(){let e=sI()?.tabId??null;iI().open&&e!==null&&AI(e).focus()}function nL(){return vr([ZI,QI,$I,eL],(e,t)=>{e.preventDefault(),e.stopPropagation();let n=sI();if(n===null)return;if(t.hotkey===ZI){_I({type:`createTab`,projectId:n.view===`global`?null:n.view});return}if(n.tabId===null)return;if(t.hotkey===QI){JI(n.tabId);return}let r;if(t.hotkey===$I)r=1;else if(t.hotkey===eL)r=-1;else throw Error(`unknown terminal shortcut ${t.hotkey}`);let i=n.tabs,a=i[(i.findIndex(e=>e.id===n.tabId)+r+i.length)%i.length];a&&_I({type:`select`,view:n.view,tabId:a.id})},{enabled:()=>oI().behavior.captureShortcuts,enableOnFormTags:!0,eventListenerOptions:{capture:!0}})}function rL(e){let[t,n]=(0,W.useState)(e.name);return(0,G.jsx)(oi,{open:!0,onOpenChange:t=>{t||e.onDone()},children:(0,G.jsx)($r,{onCloseAutoFocus:sL,children:(0,G.jsxs)(`form`,{className:`grid gap-4`,onSubmit:n=>{n.preventDefault(),_I({type:`renameTab`,id:e.id,name:t.trim()}),e.onDone()},children:[(0,G.jsx)(ei,{children:(0,G.jsx)(ri,{children:`Rename tab`})}),(0,G.jsx)(Tp,{"aria-label":`Name`,placeholder:`Use terminal title`,value:t,onChange:e=>n(e.target.value)}),(0,G.jsxs)(si,{children:[(0,G.jsx)(U,{type:`button`,variant:`outline`,onClick:e.onDone,children:`Cancel`}),(0,G.jsx)(U,{type:`submit`,children:`Rename`})]})]})})})}function iL(){let e=(0,W.useSyncExternalStore)(zI,BI);return e===null?null:(0,G.jsx)(mr,{open:e.open,onOpenChange:e=>{e||VI()},children:(0,G.jsx)(Zn,{onOpenAutoFocus:e=>{if(e.preventDefault(),!(e.currentTarget instanceof HTMLElement))throw Error(`close dialog is not an element`);e.currentTarget.querySelector(`[data-slot=alert-dialog-action]`)?.focus()},onCloseAutoFocus:sL,children:(0,G.jsx)(aL,{closing:e.closing})})})}function aL(e){let t=e.closing;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsxs)(Hn,{children:[`Close “`,t.name,`”?`]}),(0,G.jsx)(Rn,{children:t.program===null?`OffSite couldn’t check whether a program is still running.`:`${t.program} is still running.`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>_I({type:`closeTab`,id:t.id}),children:`Close`})]})]})}function oL(){let e=(0,W.useSyncExternalStore)(zI,HI);if(e===null)return null;let t=e.closing;return(0,G.jsx)(mr,{open:e.open,onOpenChange:e=>{e||UI()},children:(0,G.jsxs)(Zn,{onCloseAutoFocus:sL,children:[(0,G.jsxs)(Ar,{children:[(0,G.jsxs)(Hn,{children:[`Close `,t.tabs.length,` `,t.tabs.length===1?`terminal`:`terminals`,`?`]}),(0,G.jsx)(Rn,{children:t.programs.length===0?`OffSite couldn’t check whether programs are still running.`:`Still running: ${t.programs.join(`, `)}.`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>YI(t.tabs),children:`Close all`})]})]})})}function sL(e){e.preventDefault();let t=document.querySelector(`[role="dialog"], [role="alertdialog"]`);t===null?tL():t.focus()}function cL(e){let t=(0,W.useRef)(null),[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)({resultIndex:-1,resultCount:0});(0,W.useEffect)(()=>SI(e.id,a),[e.id]),(0,W.useEffect)(()=>t.current?.focus(),[]);function o(t,n,i){r(t),xI(e.id,t,n,i)}return(0,G.jsxs)(`div`,{className:`bg-card absolute top-2 right-4 z-10 flex items-center gap-1 rounded-lg border p-1 shadow-lg`,children:[(0,G.jsx)(Tp,{ref:t,"data-find":!0,className:`h-7 w-52`,placeholder:`Find`,value:n,onChange:e=>o(e.target.value,!1,!0),onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),CI(e.id)):t.key===`Enter`?(t.preventDefault(),o(n,t.shiftKey,!1)):OI(t.nativeEvent)&&(t.preventDefault(),t.currentTarget.select())}}),(0,G.jsx)(`span`,{className:`text-muted-foreground w-16 text-center text-xs tabular-nums`,children:n===``?``:i.resultCount===0?`No results`:`${i.resultIndex+1} of ${i.resultCount}`}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous match`,onClick:()=>o(n,!0,!1),children:(0,G.jsx)(H,{icon:Bo})}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next match`,onClick:()=>o(n,!1,!1),children:(0,G.jsx)(H,{icon:Dr})}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close find`,onClick:()=>CI(e.id),children:(0,G.jsx)(H,{icon:Go})})]})}var lL=[{label:`Esc`,sequence:`\x1B`},{label:`Tab`,sequence:` `},{label:`↑`,sequence:`\x1B[A`},{label:`↓`,sequence:`\x1B[B`},{label:`←`,sequence:`\x1B[D`},{label:`→`,sequence:`\x1B[C`}];function uL(e){let t=(0,W.useSyncExternalStore)(rI,iI),n=t.status===`active`,r=cI(t.layout,e.view),i=t.layout.active[e.view]??null,a=nL(),[o,s]=(0,W.useState)(!1);(0,W.useEffect)(()=>{n&&!e.page&&mI(e.view)},[e.view,n,e.page]);function c(){_I({type:`createTab`,projectId:e.view===`global`?null:e.view})}if(!t.loaded)return(0,G.jsx)(`div`,{className:`text-muted-foreground grid h-full place-items-center p-4 text-xs whitespace-pre-wrap`,children:t.failure===null?`Starting the terminal…`:`The terminal could not start: ${t.failure}`});let l=r.find(e=>e.id===i);return(0,G.jsxs)(`div`,{ref:a,className:`flex h-full flex-col text-sm`,children:[e.mobile?(0,G.jsxs)(`header`,{className:`bg-background grid h-(--workspace-topbar-height) flex-none grid-cols-[1fr_auto_1fr] items-center border-b select-none`,children:[(0,G.jsx)(`div`,{className:`flex min-w-0 items-center self-stretch`,children:e.leading}),(0,G.jsx)(`span`,{className:`bg-border h-4 w-px`}),(0,G.jsx)(`div`,{className:`flex min-w-0 items-center self-stretch`,children:l===void 0?(0,G.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground flex min-w-0 flex-1 items-center gap-1.5 self-stretch px-3 text-[13px] transition-colors`,onClick:c,children:[(0,G.jsx)(H,{icon:Oo,className:`size-4`}),`New tab`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(mn,{open:o,onOpenChange:s,children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:`text-foreground relative flex min-w-0 flex-1 items-center gap-3.5 self-stretch px-3 text-[13px]`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground relative flex-none`,children:[(0,G.jsx)(H,{icon:Zs,className:`size-4`}),r.length>1&&(0,G.jsx)(`span`,{className:`text-foreground/75 ring-background absolute -top-1.5 -right-2 grid h-3.5 min-w-3.5 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_14%,var(--background))] px-0.5 text-[9px] leading-none font-medium tabular-nums ring-2`,children:r.length})]}),(0,G.jsx)(`span`,{className:`truncate`,children:dI(l)}),r.some(e=>e.id!==i&&t.alerts.includes(e.id))&&(0,G.jsx)(`span`,{className:`bg-primary size-1.5 flex-none rounded-full`}),(0,G.jsx)(gL,{progress:t.progress[l.id]})]})}),(0,G.jsx)(Dn,{align:`start`,className:`w-auto min-w-48`,children:(0,G.jsx)(pL,{view:e.view,onCreate:c,onClose:()=>s(!1)})})]}),(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground grid w-11 flex-none place-items-center self-stretch transition-colors`,"aria-label":`Close tab`,title:`Close tab`,onClick:()=>void JI(l.id),children:(0,G.jsx)(H,{icon:Go,className:`size-4`})})]})})]}):(0,G.jsxs)(`header`,{className:B(`flex h-9 flex-none select-none`,e.tabSize===`lg`&&`h-(--workspace-topbar-height)`,r.length===1?`bg-background`:`bg-sidebar`),children:[e.leading&&(0,G.jsx)(`div`,{className:`flex flex-none items-center border-b px-1.5`,children:e.leading}),(0,G.jsx)(`div`,{className:`flex min-w-0 flex-1 [scrollbar-width:none] overflow-x-auto`,children:r.map(n=>(0,G.jsx)(fL,{tab:n,children:(0,G.jsxs)(`div`,{className:B(`group/tab text-muted-foreground hover:text-foreground relative flex min-w-28 flex-1 items-center justify-center border-r border-b px-7 text-xs transition-colors last:border-r-0`,e.tabSize===`lg`&&`text-[13px]`,n.id===i&&`bg-background text-foreground border-b-transparent`),onMouseDown:e=>e.preventDefault(),onClick:()=>_I({type:`select`,view:e.view,tabId:n.id}),children:[(0,G.jsx)(`span`,{className:`truncate`,children:dI(n)}),(0,G.jsx)(hL,{id:n.id,className:`ml-1.5 size-1.5 flex-none rounded-full`}),(0,G.jsx)(gL,{progress:t.progress[n.id]}),(0,G.jsx)(`button`,{className:B(`text-muted-foreground hover:bg-accent hover:text-foreground absolute left-1.5 grid size-4.5 place-items-center rounded opacity-0 transition-opacity group-hover/tab:opacity-100`,n.id===i&&`pointer-coarse:opacity-100`),"aria-label":`Close tab`,onClick:e=>{e.stopPropagation(),JI(n.id)},children:(0,G.jsx)(H,{icon:Go,className:`size-3`})})]})},n.id))}),(0,G.jsx)(`button`,{className:B(`text-muted-foreground hover:text-foreground grid w-8 flex-none place-items-center transition-colors`,r.length>1&&`border-b border-l`),"aria-label":`New tab`,title:`New tab`,onClick:c,children:(0,G.jsx)(H,{icon:Oo,className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[i!==null&&(0,G.jsx)(dL,{id:i},`${t.instance}-${i}`),i!==null&&t.finding===i&&(0,G.jsx)(cL,{id:i},i),n&&i===null&&!e.page&&(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground grid size-full cursor-pointer place-items-center text-xs transition-colors`,onClick:c,children:`New terminal`}),!n&&(0,G.jsx)(`div`,{className:`bg-background/80 animate-in fade-in absolute inset-0 z-20 grid place-items-center p-6 text-center backdrop-blur-md duration-200`,children:(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,G.jsx)(`span`,{className:`border-foreground/15 border-t-foreground/70 size-6 animate-spin rounded-full border-[3px]`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Connecting. Your terminals keep running while you wait.`})]})})]}),i!==null&&(0,G.jsxs)(`div`,{className:`bg-card hidden flex-none gap-1.5 overflow-x-auto border-t p-1.5 pointer-coarse:flex`,children:[lL.map(e=>(0,G.jsx)(U,{variant:`secondary`,className:`min-w-11`,onPointerDown:e=>e.preventDefault(),onClick:()=>yI(i,e.sequence),children:e.label},e.label)),(0,G.jsx)(U,{variant:t.ctrl?`default`:`secondary`,className:`min-w-11`,onPointerDown:e=>e.preventDefault(),onClick:wI,children:`Ctrl`})]}),(0,G.jsx)(iL,{})]})}function dL(e){let t=(0,W.useRef)(null);return(0,W.useEffect)(()=>{if(!t.current)throw Error(`terminal container missing`);return jI(e.id,t.current)},[e.id]),(0,G.jsx)(`div`,{className:`bg-background absolute inset-0 pt-(--pad-top) pr-(--pad-right) pb-(--pad-bottom) pl-(--pad-left)`,ref:t})}function fL(e){let[t,n]=(0,W.useState)(!1),r=e.tab;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,children:e.children}),(0,G.jsx)(tr,{children:(0,G.jsx)(mL,{tab:r,onRename:()=>n(!0)})})]}),t&&(0,G.jsx)(rL,{id:r.id,name:r.customName??``,onDone:()=>n(!1)})]})}function pL(e){let t=(0,W.useSyncExternalStore)(rI,iI),n=t.layout.active[e.view]??null;return(0,G.jsxs)(G.Fragment,{children:[cI(t.layout,e.view).map(t=>(0,G.jsxs)(Mr,{className:B(t.id===n&&`bg-accent`),onSelect:()=>_I({type:`select`,view:e.view,tabId:t.id}),children:[(0,G.jsx)(`span`,{className:`max-w-60 truncate`,children:dI(t)}),(0,G.jsxs)(`span`,{className:`-mr-1 ml-auto flex flex-none items-center gap-2`,children:[(0,G.jsx)(hL,{id:t.id,className:`size-1.5 rounded-full`}),(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground grid size-6 place-items-center rounded`,"aria-label":`Close tab`,title:`Close tab`,onClick:n=>{n.stopPropagation(),e.onClose(),JI(t.id)},children:(0,G.jsx)(H,{icon:Go,className:`size-3.5`})})]})]},t.id)),(0,G.jsx)(Pn,{}),(0,G.jsxs)(Mr,{onSelect:e.onCreate,children:[(0,G.jsx)(H,{icon:Oo}),`New tab`]})]})}function mL(e){let t=k(e=>e.projects).filter(e=>e.machine===nI()&&!e.scratch),n=e.tab;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Bn,{onSelect:e.onRename,children:[(0,G.jsx)(H,{icon:Ps}),`Rename`]}),(0,G.jsxs)(or,{children:[(0,G.jsxs)(Kn,{children:[(0,G.jsx)(H,{icon:lr}),`Move to`]}),(0,G.jsx)(Cr,{className:`max-h-80 overflow-y-auto`,children:(0,G.jsxs)(fr,{value:n.projectId??``,onValueChange:e=>_I({type:`assignTab`,id:n.id,projectId:e===``?null:e}),children:[(0,G.jsx)(yr,{value:``,children:`No project`}),t.length>0&&(0,G.jsx)(Wn,{}),t.map(e=>(0,G.jsx)(yr,{value:e.id,children:(0,G.jsx)(`span`,{className:`max-w-60 truncate`,children:e.name})},e.id))]})})]}),(0,G.jsxs)(Bn,{variant:`destructive`,onSelect:()=>void JI(n.id),children:[(0,G.jsx)(H,{icon:is}),`Close tab`]})]})}function hL(e){return iI().alerts.includes(e.id)?(0,G.jsx)(`span`,{className:B(`bg-primary`,e.className)}):null}function gL(e){let t=e.progress;return!t||t.state===0?null:t.state===3?(0,G.jsx)(`span`,{className:`bg-primary absolute inset-x-0 bottom-0 h-0.5 animate-pulse`}):(0,G.jsx)(`span`,{className:B(`absolute bottom-0 left-0 h-0.5 transition-[width]`,t.state===1&&`bg-primary`,t.state===2&&`bg-destructive`,t.state===4&&`bg-yellow-500`),style:{width:`${t.state!==1&&t.value===0?100:t.value}%`}})}function _L(e){(0,W.useSyncExternalStore)(rI,iI);let[t,n]=(0,W.useState)(!1),r=g(),i=yL().find(t=>t.machine.id===e.machine&&t.view===r);return(0,W.useEffect)(()=>{localStorage.setItem(`lastTerminal`,e.machine),localStorage.setItem(`lastTerminalView`,r)},[e.machine,r]),e.mobile?(0,G.jsx)(`main`,{className:`bg-background flex min-w-0 flex-1 flex-col overflow-hidden pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(uL,{view:r,page:!0,mobile:!0,leading:(0,G.jsxs)(G.Fragment,{children:[e.leading,(0,G.jsxs)(ln,{open:t,onOpenChange:n,children:[(0,G.jsx)(Sn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground flex min-w-0 flex-1 items-center gap-1.5 self-stretch px-2 text-[13px]`,children:[i!==void 0&&(0,G.jsx)(xL,{group:i}),(0,G.jsx)(`span`,{className:`truncate`,children:i?.name}),(0,G.jsx)(H,{icon:Dr,className:`size-3.5 flex-none`})]})}),(0,G.jsx)(sn,{align:`start`,className:`w-56 p-1`,onClick:()=>n(!1),children:(0,G.jsx)(vL,{})})]})]})})})}):(0,G.jsx)(`main`,{className:`bg-background flex min-w-0 flex-1 flex-col overflow-hidden`,children:(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(uL,{view:r,page:!0,tabSize:`lg`,leading:e.leading})})})}function vL(){(0,W.useSyncExternalStore)(rI,iI);let e=ne(),t=g(),n=yL().filter(e=>e.machine.status===`online`);return n.length===0?null:(0,G.jsx)(`div`,{className:`flex max-h-80 flex-col gap-px overflow-y-auto`,children:n.map(n=>(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,children:(0,G.jsxs)(`div`,{className:B(`group/row text-popover-foreground hover:bg-sidebar-row-hover data-[state=open]:bg-sidebar-row-hover relative shrink-0 rounded-[var(--control-radius)]`,n.machine.id===e&&n.view===t&&`bg-sidebar-row-hover text-sidebar-foreground`),children:[(0,G.jsxs)(`button`,{className:B(`flex h-7 w-full cursor-pointer items-center gap-2 rounded-[var(--control-radius)] pr-2.5 pl-2 text-left text-[13px]`,n.view!==`global`&&`pl-6`),onClick:()=>n.count===0?void zF(n.machine.id,n.view===`global`?null:n.view):LF(n.machine.id,n.view),children:[(0,G.jsx)(xL,{group:n}),(0,G.jsx)(`span`,{className:`truncate`,children:n.name}),(0,G.jsx)(SL,{count:n.count,alert:bL(n,e),className:`group-hover/row:invisible pointer-coarse:mr-7`})]}),(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground absolute top-0.5 right-1.5 grid size-6 cursor-pointer place-items-center rounded-md opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100`,"aria-label":`New terminal`,title:`New terminal`,onClick:()=>void zF(n.machine.id,n.view===`global`?null:n.view),children:(0,G.jsx)(H,{icon:Oo,className:`size-4`})})]})}),(0,G.jsxs)(tr,{onCloseAutoFocus:e=>e.preventDefault(),children:[(0,G.jsxs)(Bn,{onSelect:()=>void zF(n.machine.id,n.view===`global`?null:n.view),children:[(0,G.jsx)(H,{icon:Oo}),`New terminal`]}),n.view===`global`&&(0,G.jsxs)(Bn,{variant:`destructive`,onSelect:()=>void XI(n.machine.terminals.map(e=>({machine:n.machine.id,id:e.id}))),children:[(0,G.jsx)(H,{icon:is}),`Close All`]}),(0,G.jsxs)(Bn,{variant:`destructive`,disabled:n.count===0,onSelect:()=>void XI(n.machine.terminals.filter(e=>lI(e)===n.view).map(e=>({machine:n.machine.id,id:e.id}))),children:[(0,G.jsx)(H,{icon:is}),n.view===`global`?`Close All Except Projects`:`Close All`]})]})]},`${n.machine.id}:${n.view}`))})}function yL(){let e=k(e=>e.machines),t=k(e=>e.projects);return e.flatMap(e=>{let n=e.status===`online`?e.terminals:[],r=[...new Set([...t.filter(t=>e.status===`online`&&t.machine===e.id&&!t.hidden&&!t.scratch).map(e=>e.id),...n.flatMap(e=>e.projectId===null?[]:[e.projectId])])];return[{machine:e,view:Ue,name:e.name,count:n.filter(e=>e.projectId===null).length},...r.map(r=>({machine:e,view:r,name:t.find(t=>t.machine===e.id&&t.id===r)?.name??`Removed project`,count:n.filter(e=>e.projectId===r).length}))]})}function bL(e,t){let n=iI();return e.machine.id===t&&n.layout.tabs.some(t=>(t.projectId??`global`)===e.view&&n.alerts.includes(t.id))}function xL(e){return e.group.view===`global`?(0,G.jsx)(Of,{icon:e.group.machine.icon,className:`size-4 shrink-0`}):(0,G.jsx)(mc,{machine:e.group.machine.id,projectId:e.group.view,className:`size-4 shrink-0`})}function SL(e){return e.count===0?null:(0,G.jsx)(`span`,{className:B(`ml-auto grid h-4 min-w-4 shrink-0 place-items-center rounded-full px-1 text-[10px] leading-none font-medium tabular-nums`,e.alert?`bg-primary text-primary-foreground`:`text-foreground/75 bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))]`,e.className),children:e.count})}function CL(e){let t=k(e=>e.machines),[n,r]=(0,W.useState)(!1),i=t.filter(e=>e.status===`online`),a=i.reduce((e,t)=>e+t.terminals.length,0);return(0,G.jsxs)(`div`,{className:`mr-1.5 flex items-center gap-0.75`,children:[(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(`button`,{className:B(e.buttonClassName,`size-7 [&>svg]:size-4.5`),title:`Menu`,"aria-label":`Menu`,children:(0,G.jsx)(H,{icon:Ts})})}),(0,G.jsxs)(Dn,{align:`start`,className:`w-auto min-w-40`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,G.jsxs)(Mr,{onSelect:()=>N(!0),children:[(0,G.jsx)(H,{icon:rs}),`Usage`]}),(0,G.jsxs)(Mr,{onSelect:()=>p(!0),children:[(0,G.jsx)(H,{icon:Us}),`Settings`]})]})]}),(0,G.jsxs)(ln,{open:n,onOpenChange:r,children:[(0,G.jsx)(Sn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:B(e.buttonClassName,`relative size-7 [&>svg]:size-4.5`),title:`Terminal`,"aria-label":`Terminal`,disabled:i.length===0,children:[(0,G.jsx)(H,{icon:Zs}),a>0&&(0,G.jsx)(`span`,{className:`text-foreground/75 border-sidebar pointer-events-none absolute -top-0.5 -right-0.5 grid h-3.5 min-w-3.5 place-items-center rounded-full border bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))] px-0.5 text-[9px] leading-none font-medium tabular-nums`,children:a})]})}),(0,G.jsx)(sn,{align:`start`,className:`w-56 p-1`,onCloseAutoFocus:e=>e.preventDefault(),onClick:()=>r(!1),children:(0,G.jsx)(vL,{})})]})]})}var wL=`relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none touch-pan-y [-webkit-touch-callout:none] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,TL={active:{status:`snoozed`,icon:sc},snoozed:{status:`active`,icon:$s},minimized:{status:`active`,icon:Ro},inactive:{status:`minimized`,icon:As},pinned:{status:`active`,icon:Fs}},EL=(0,W.memo)(DL);function DL(e){let t=e.session,n=cc(t.machine,t.projectId),r=k(e=>Ge(e,t.machine).icon),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(0),u=(0,W.useRef)(null),d=(0,W.useRef)(null),f=(0,W.useRef)(!1),p=e.activity?.waiting===!0,m=Object.values(e.activity?.tasks??{}).includes(`running`),h=!p&&(e.activity?.running===!0||m),g=e.activity?.running===!0||m,_=!p&&!h&&e.unseen,v=!e.selected&&!p&&!_;function y(){pt(t.machine,t.id,e.scope)}function b(){g?s(!0):y()}function x(e){let n=d.current;d.current=null,l(0),n!==null&&n.swiping&&(f.current=!0,e.clientX-n.x>e.currentTarget.offsetWidth*.4&&(t.status===`inactive`?Je(t.machine,t.id,{status:`active`}):b()),e.clientX-n.x<-e.currentTarget.offsetWidth*.4&&Je(t.machine,t.id,{status:TL[t.status].status}))}let S={onClick:()=>{f.current?f.current=!1:e.onSelect(t.machine,t.projectId,t.id)},onPointerDown:t=>{e.saved&&t.pointerType===`touch`&&(f.current=!1,d.current={x:t.clientX,y:t.clientY,swiping:!1})},onPointerMove:e=>{let t=d.current;if(t===null)return;let n=e.clientX-t.x,r=e.clientY-t.y;!t.swiping&&Math.abs(n)<10&&Math.abs(r)<10||(!t.swiping&&Math.abs(n)<=Math.abs(r)?d.current=null:(t.swiping=!0,l(n)))},onPointerUp:x,onPointerCancel:()=>{d.current=null,l(0)}},C=c!==0&&(0,G.jsx)(`div`,{className:B(`absolute inset-x-0 flex items-center rounded-md px-4 text-white`,e.slim?`inset-y-0`:`inset-y-0.5`,c>0&&t.status!==`inactive`&&`bg-success`,c>0&&t.status===`inactive`&&`bg-[#56b6c2]`,c<0&&t.status===`active`&&`bg-[#c678dd]`,c<0&&t.status===`snoozed`&&`bg-[#d19a66]`,c<0&&t.status===`minimized`&&`bg-info`,c<0&&t.status===`inactive`&&`bg-[#5c6370]`,c<0&&t.status===`pinned`&&`bg-[#e06c75]`,c<0&&`justify-end`),children:(0,G.jsx)(H,{icon:c<0?TL[t.status].icon:t.status===`inactive`?Ls:nc,className:`size-6`})}),w=(0,G.jsx)(mr,{open:o,onOpenChange:s,children:(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:`Stop running work?`}),(0,G.jsx)(Rn,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:y,children:`Stop and Mark Done`})]})]})}),T=(0,G.jsx)(tr,{className:`w-44`,onCloseAutoFocus:e=>{u.current!==null&&(e.preventDefault(),u.current.focus(),u.current.select())},children:(0,G.jsx)(zA,{session:t,context:!0,mobile:!0,onDeactivate:b,onRename:()=>a(t.title)})}),E=i===null?(0,G.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate text-sm`,v?`text-secondary-label font-normal`:`font-medium`,!v&&(e.unseen||p)&&`text-foreground`,!v&&!e.unseen&&!p&&`text-foreground/90`),children:(0,G.jsx)(VA,{session:t,awaitingTitle:!e.saved})}):(0,G.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&Je(t.machine,t.id,{title:n})},children:(0,G.jsx)(`input`,{ref:u,value:i,onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>a(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&a(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),D=B(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,v&&`text-sidebar-muted-foreground/75`,!e.selected&&!v&&`text-sidebar-foreground bg-transparent`);return e.slim?(0,G.jsxs)(`li`,{className:`relative list-none`,children:[C,(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(wL,D,`flex h-9 items-center gap-2.5 px-2.5`,c!==0&&`bg-sidebar`),style:c===0?void 0:{transform:`translateX(${c}px)`},...S,onKeyDown:n=>{n.key===`Enter`&&e.onSelect(t.machine,t.projectId,t.id)},children:[(0,G.jsx)(`span`,{className:`flex shrink-0 items-center opacity-40 grayscale`,children:(0,G.jsx)(mc,{machine:t.machine,projectId:t.projectId})}),E,(0,G.jsx)(`span`,{className:`text-secondary-label ml-auto shrink-0 text-xs tabular-nums`,children:yn(t.updatedAt)})]})}),T]}),w]}):(0,G.jsxs)(`li`,{className:`relative list-none py-0.5`,children:[C,(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsx)(`div`,{role:`button`,tabIndex:0,className:B(wL,D,h&&!e.selected&&c===0&&`opacity-70`,c!==0&&`bg-sidebar`),style:c===0?void 0:{transform:`translateX(${c}px)`},...S,onKeyDown:n=>{n.key===`Enter`&&e.onSelect(t.machine,t.projectId,t.id)},children:(0,G.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,G.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,G.jsx)(mc,{machine:t.machine,projectId:t.projectId,className:`size-5`}),E,(0,G.jsx)(BA,{activity:e.activity,backgroundRunning:m,done:_})]}),(0,G.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,G.jsx)(Of,{icon:r,className:`size-3 shrink-0`}),(0,G.jsxs)(`span`,{className:B(`min-w-0 flex-1 truncate`,v?`font-normal`:`font-medium`),children:[n,t.branch!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | ${t.branch}`})]}),t.status===`pinned`&&(0,G.jsx)(H,{icon:Is,className:`size-3 shrink-0`}),t.status===`snoozed`&&(0,G.jsx)(H,{icon:sc,className:`size-3 shrink-0`}),(0,G.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:yn(t.updatedAt)})]})]})})}),T]}),w]})}function OL(e){let t=cc(e.machine,e.projectId),n=k(t=>Ge(t,e.machine).icon);return(0,G.jsx)(`li`,{className:`list-none py-0.5`,children:(0,G.jsx)(`div`,{role:`button`,tabIndex:0,className:B(wL,`bg-sidebar-row-active text-sidebar-foreground`),onClick:e.onSelect,children:(0,G.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,G.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,G.jsx)(mc,{machine:e.machine,projectId:e.projectId,className:`size-5`}),(0,G.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,G.jsx)(H,{icon:Ys,className:`text-warning-foreground size-4 shrink-0`})]}),(0,G.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,G.jsx)(Of,{icon:n,className:`size-3 shrink-0`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:[t,(0,G.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | Draft`})]}),(0,G.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`now`})]})]})})})}var kL=`group/sidebar-row relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`;function AL(e){let t=e.session,[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(!1),o=(0,W.useRef)(null),s=e.activity?.waiting===!0,c=Object.values(e.activity?.tasks??{}).includes(`running`),l=!s&&(e.activity?.running===!0||c),u=e.activity?.running===!0||c,d=!s&&!l&&e.unseen,f=!e.selected&&!s&&!d;function p(){pt(t.machine,t.id,null)}function m(){u?a(!0):p()}let h=(0,G.jsx)(mr,{open:i,onOpenChange:a,children:(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:`Stop running work?`}),(0,G.jsx)(Rn,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:p,children:`Stop and Mark Done`})]})]})}),g=e.saved&&(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Thread actions`,onClick:e=>e.stopPropagation(),children:(0,G.jsx)(H,{icon:os,className:`size-3.5`})})}),(0,G.jsx)(Dn,{align:`end`,className:`w-44`,onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>{o.current!==null&&(e.preventDefault(),o.current.focus(),o.current.select())},children:(0,G.jsx)(zA,{session:t,context:!1,mobile:!1,onDeactivate:m,onRename:()=>r(t.title)})})]}),_=(0,G.jsx)(tr,{className:`w-44`,onCloseAutoFocus:e=>{o.current!==null&&(e.preventDefault(),o.current.focus(),o.current.select())},children:(0,G.jsx)(zA,{session:t,context:!0,mobile:!1,onDeactivate:m,onRename:()=>r(t.title)})}),v=n===null?(0,G.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate text-sm`,f?`text-secondary-label font-normal`:`font-medium`,!f&&(e.unseen||s)&&`text-foreground`,!f&&!e.unseen&&!s&&`text-foreground/90`),children:(0,G.jsx)(VA,{session:t,awaitingTitle:!e.saved})}):(0,G.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let i=n.trim();r(null),i!==``&&i!==t.title&&Je(t.machine,t.id,{title:i})},children:(0,G.jsx)(`input`,{ref:o,value:n,onChange:e=>r(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>r(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&r(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),y=B(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,f&&`text-sidebar-muted-foreground/75 hover:bg-sidebar-row-hover hover:text-sidebar-foreground has-[[data-state=open]]:bg-sidebar-row-hover has-[[data-state=open]]:text-sidebar-foreground`,!e.selected&&!f&&`text-sidebar-foreground hover:bg-sidebar-row-hover has-[[data-state=open]]:bg-sidebar-row-hover bg-transparent`);return(0,G.jsxs)(`li`,{className:`list-none`,children:[(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(kL,y,`flex h-9 items-center gap-2 px-2.5`,l&&!e.selected&&`opacity-70 transition-opacity focus-within:opacity-100 hover:opacity-100`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,G.jsxs)(`span`,{className:`group-any-hover/sidebar-row:mask-r-from-[calc(100%-5rem)] group-any-hover/sidebar-row:mask-r-to-[calc(100%-3rem)] flex min-w-0 flex-1 items-center gap-2 group-has-[[data-state=open]]/sidebar-row:mask-r-from-[calc(100%-5rem)] group-has-[[data-state=open]]/sidebar-row:mask-r-to-[calc(100%-3rem)]`,children:[v,t.status===`pinned`&&(0,G.jsx)(H,{icon:Is,className:`text-muted-foreground/65 size-3 shrink-0`}),t.status===`snoozed`&&(0,G.jsx)(H,{icon:sc,className:`text-secondary-label size-3 shrink-0`}),(0,G.jsx)(BA,{activity:e.activity,backgroundRunning:c,done:d}),(0,G.jsx)(`span`,{className:`text-secondary-label shrink-0 text-xs tabular-nums`,children:yn(t.updatedAt)})]}),e.saved&&(0,G.jsxs)(`div`,{className:`group-any-hover/sidebar-row:pointer-events-auto group-any-hover/sidebar-row:opacity-100 pointer-events-none absolute inset-y-0 right-0 flex items-center pr-1.5 opacity-0 transition-opacity has-[[data-state=open]]:pointer-events-auto has-[[data-state=open]]:opacity-100`,children:[g,(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground ms-0.5 me-0.5 inline-flex size-5 cursor-pointer items-center justify-center transition-colors`,title:`Done`,"aria-label":`Done`,onClick:e=>{e.stopPropagation(),m()},children:(0,G.jsx)(H,{icon:nc,strokeWidth:1.35,className:`size-5 scale-110`})})]})]})}),_]}),h]})}function jL(e){return(0,G.jsx)(`li`,{className:`list-none`,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(kL,`bg-sidebar-row-active text-sidebar-foreground flex h-9 items-center gap-2 px-2.5`),onClick:e.onSelect,children:[(0,G.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,G.jsx)(H,{icon:Ys,className:`text-warning-foreground size-4 shrink-0`})]})})}var ML=`relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none touch-pan-y [-webkit-touch-callout:none] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`;function NL(e){let t=e.session,[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(0),c=(0,W.useRef)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(!1),d=e.activity?.waiting===!0,f=Object.values(e.activity?.tasks??{}).includes(`running`),p=!d&&(e.activity?.running===!0||f),m=e.activity?.running===!0||f,h=!d&&!p&&e.unseen,g=!e.selected&&!d&&!h;function _(){pt(t.machine,t.id,null)}function v(){m?a(!0):_()}function y(e){let n=l.current;l.current=null,s(0),n!==null&&n.swiping&&(u.current=!0,e.clientX-n.x>e.currentTarget.offsetWidth*.4&&(t.status===`inactive`?Je(t.machine,t.id,{status:`active`}):v()),e.clientX-n.x<-e.currentTarget.offsetWidth*.4&&Je(t.machine,t.id,{status:TL[t.status].status}))}let b={onClick:()=>{u.current?u.current=!1:e.onSelect()},onPointerDown:t=>{e.saved&&t.pointerType===`touch`&&(u.current=!1,l.current={x:t.clientX,y:t.clientY,swiping:!1})},onPointerMove:e=>{let t=l.current;if(t===null)return;let n=e.clientX-t.x,r=e.clientY-t.y;!t.swiping&&Math.abs(n)<10&&Math.abs(r)<10||(!t.swiping&&Math.abs(n)<=Math.abs(r)?l.current=null:(t.swiping=!0,s(n)))},onPointerUp:y,onPointerCancel:()=>{l.current=null,s(0)}},x=o!==0&&(0,G.jsx)(`div`,{className:B(`absolute inset-0 flex items-center rounded-md px-4 text-white`,o>0&&t.status!==`inactive`&&`bg-success`,o>0&&t.status===`inactive`&&`bg-[#56b6c2]`,o<0&&t.status===`active`&&`bg-[#c678dd]`,o<0&&t.status===`snoozed`&&`bg-[#d19a66]`,o<0&&t.status===`minimized`&&`bg-info`,o<0&&t.status===`inactive`&&`bg-[#5c6370]`,o<0&&t.status===`pinned`&&`bg-[#e06c75]`,o<0&&`justify-end`),children:(0,G.jsx)(H,{icon:o<0?TL[t.status].icon:t.status===`inactive`?Ls:nc,className:`size-6`})}),S=(0,G.jsx)(mr,{open:i,onOpenChange:a,children:(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:`Stop running work?`}),(0,G.jsx)(Rn,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:_,children:`Stop and Mark Done`})]})]})}),C=(0,G.jsx)(tr,{className:`w-44`,onCloseAutoFocus:e=>{c.current!==null&&(e.preventDefault(),c.current.focus(),c.current.select())},children:(0,G.jsx)(zA,{session:t,context:!0,mobile:!0,onDeactivate:v,onRename:()=>r(t.title)})}),w=n===null?(0,G.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate text-sm`,g?`text-secondary-label font-normal`:`font-medium`,!g&&(e.unseen||d)&&`text-foreground`,!g&&!e.unseen&&!d&&`text-foreground/90`),children:(0,G.jsx)(VA,{session:t,awaitingTitle:!e.saved})}):(0,G.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let i=n.trim();r(null),i!==``&&i!==t.title&&Je(t.machine,t.id,{title:i})},children:(0,G.jsx)(`input`,{ref:c,value:n,onChange:e=>r(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>r(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&r(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),T=B(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,g&&`text-sidebar-muted-foreground/75`,!e.selected&&!g&&`text-sidebar-foreground bg-transparent`);return(0,G.jsxs)(`li`,{className:`relative list-none`,children:[x,(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(ML,T,`flex h-9 items-center gap-2 px-2.5`,p&&!e.selected&&o===0&&`opacity-70`,o!==0&&`bg-sidebar`),style:o===0?void 0:{transform:`translateX(${o}px)`},...b,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[w,t.status===`pinned`&&(0,G.jsx)(H,{icon:Is,className:`text-muted-foreground/65 size-3 shrink-0`}),t.status===`snoozed`&&(0,G.jsx)(H,{icon:sc,className:`text-secondary-label size-3 shrink-0`}),(0,G.jsx)(BA,{activity:e.activity,backgroundRunning:f,done:h}),(0,G.jsx)(`span`,{className:`text-secondary-label shrink-0 text-xs tabular-nums`,children:yn(t.updatedAt)})]})}),C]}),S]})}function PL(e){return(0,G.jsx)(`li`,{className:`list-none`,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(ML,`bg-sidebar-row-active text-sidebar-foreground flex h-9 items-center gap-2 px-2.5`),onClick:e.onSelect,children:[(0,G.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,G.jsx)(H,{icon:Ys,className:`text-warning-foreground size-4 shrink-0`})]})})}function FL(e){let t=cc(e.machine,e.projectId),n=k(t=>Ge(t,e.machine).icon),r=k(e=>e.selection),i=k(e=>e.machines),a=k(e=>e.unseen),o=r!==null&&r.sessionId===null&&r.machine===e.machine&&r.projectId===e.projectId,s=e.mobile?PL:jL,c=e.mobile?NL:AL;function l(){Ie({machine:e.machine,projectId:e.projectId,sessionId:null})}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`li`,{className:`text-sidebar-muted-foreground/60 mx-0.5 mt-2 flex h-7 items-center gap-2 pl-2 text-xs font-medium first:mt-0`,children:[(0,G.jsx)(Of,{icon:n,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`bg-sidebar-border/60 h-px min-w-2 flex-1`}),(0,G.jsx)(mc,{machine:e.machine,projectId:e.projectId,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,G.jsx)(`span`,{className:`bg-sidebar-border/60 h-px min-w-2 flex-1`}),(0,G.jsx)(`button`,{className:`text-sidebar-muted-foreground/80 hover:bg-sidebar-row-hover hover:text-sidebar-foreground flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-[var(--control-radius)]`,title:`New thread`,"aria-label":`New thread`,onClick:l,children:(0,G.jsx)(H,{icon:Oo,className:`size-4 text-(--sidebar-icon-color)`})})]}),o&&(0,G.jsx)(s,{onSelect:l}),e.sessions.map(t=>(0,G.jsx)(c,{session:t,selected:r?.machine===t.machine&&r.sessionId===t.id,activity:$e(i,t.machine,t.id),unseen:a.includes(P(t.machine,t.id)),saved:t!==e.started,onSelect:()=>Ie({machine:t.machine,projectId:t.projectId,sessionId:t.id})},P(t.machine,t.id)))]})}function IL(e){let t=k(e=>e.errors),n=k(e=>e.machines),r=k(e=>e.sessions),i=k(e=>e.unseen),a=n.filter(e=>e.status===`offline`||e.status===`unpaired`),o=r.filter(e=>Object.values($e(n,e.machine,e.id)?.tasks??{}).includes(`failed`)),s=r.filter(e=>$e(n,e.machine,e.id)?.waiting===!0),c=r.filter(e=>{let t=$e(n,e.machine,e.id);return i.includes(P(e.machine,e.id))&&t?.waiting!==!0&&t?.running!==!0&&!Object.values(t?.tasks??{}).includes(`running`)}),l=t.length+a.length+o.length,u=!e.hideDone&&c.length>0;if(l===0&&s.length===0&&!u)return null;let d=e.collapsed===!0&&u&&s.length>0&&l>0;return(0,G.jsxs)(`div`,{className:B(`flex shrink-0 items-center gap-1`,e.className),children:[d&&(0,G.jsx)(RL,{className:`bg-question/15 text-question`,icon:qs,count:s.length+c.length,label:`${s.length} waiting for approval, ${c.length} done`,children:(0,G.jsx)(LL,{kind:`merged`})}),!d&&u&&(0,G.jsx)(RL,{className:`bg-success/15 text-success`,icon:Zo,count:c.length,label:`${c.length} done`,children:(0,G.jsx)(LL,{kind:`done`})}),!d&&s.length>0&&(0,G.jsx)(RL,{className:`bg-question/15 text-question`,icon:qs,count:s.length,label:`${s.length} waiting for approval`,children:(0,G.jsx)(LL,{kind:`waiting`})}),l>0&&(0,G.jsx)(RL,{className:B(t.length>0&&`bg-error/15 text-error`,t.length===0&&`bg-warning/15 text-warning-foreground`),icon:t.length>0?un:jo,count:l,label:l===1?`1 problem`:`${l} problems`,onClose:ze,children:(0,G.jsx)(LL,{kind:`problems`})})]})}function LL(e){let t=k(e=>e.errors),n=k(e=>e.machines),r=k(e=>e.sessions),i=k(e=>e.unseen),a=n.filter(e=>e.status===`offline`||e.status===`unpaired`),o=r.filter(e=>Object.values($e(n,e.machine,e.id)?.tasks??{}).includes(`failed`)),s=r.filter(e=>$e(n,e.machine,e.id)?.waiting===!0),c=r.filter(e=>{let t=$e(n,e.machine,e.id);return i.includes(P(e.machine,e.id))&&t?.waiting!==!0&&t?.running!==!0&&!Object.values(t?.tasks??{}).includes(`running`)}).map(e=>(0,G.jsx)(BL,{session:e,icon:Zo,className:`text-success`,detail:`Done`},P(e.machine,e.id))),l=s.map(e=>(0,G.jsx)(BL,{session:e,icon:qs,className:`text-question`,detail:`Waiting for approval`},P(e.machine,e.id)));if(e.kind===`done`)return c;if(e.kind===`waiting`)return l;if(e.kind===`merged`)return(0,G.jsxs)(G.Fragment,{children:[l,c]});if(e.kind===`problems`)return(0,G.jsxs)(G.Fragment,{children:[t.map((e,t)=>(0,G.jsx)(zL,{icon:un,className:`text-error`,children:(0,G.jsx)(`span`,{className:`text-error-foreground whitespace-pre-wrap`,children:e})},t)),a.map(e=>(0,G.jsxs)(zL,{icon:jo,className:`text-warning-foreground`,children:[e.status===`offline`&&`${e.name} is offline`,e.status===`unpaired`&&`${e.name} needs pairing`]},e.id)),o.map(e=>(0,G.jsx)(BL,{session:e,icon:jo,className:`text-warning-foreground`,detail:`Background task failed`},P(e.machine,e.id)))]});throw Error(`Unknown chip list`)}function RL(e){return(0,G.jsxs)(ln,{onOpenChange:t=>!t&&e.onClose?.(),children:[(0,G.jsx)(Sn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:B(`flex h-5 shrink-0 cursor-pointer items-center gap-0.75 rounded-[6px] px-1.25 text-[11px] font-medium tabular-nums`,e.className),title:e.label,"aria-label":e.label,children:[(0,G.jsx)(H,{icon:e.icon,className:`size-3 shrink-0`}),e.count]})}),(0,G.jsx)(sn,{align:`end`,collisionPadding:12,className:`flex max-h-80 w-[min(20rem,calc(100vw-2rem))] flex-col gap-px overflow-y-auto p-1 text-sm`,children:e.children})]})}function zL(e){return(0,G.jsxs)(`div`,{className:`flex items-start gap-2 px-2 py-1.5`,children:[(0,G.jsx)(H,{icon:e.icon,className:B(`mt-0.5 size-4 shrink-0`,e.className)}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children})]})}function BL(e){return(0,G.jsx)(Fn,{asChild:!0,children:(0,G.jsx)(`button`,{className:`hover:bg-accent cursor-pointer rounded-md text-left`,onClick:()=>Ie({machine:e.session.machine,projectId:e.session.projectId,sessionId:e.session.id}),children:(0,G.jsxs)(zL,{icon:e.icon,className:e.className,children:[(0,G.jsx)(`div`,{className:`text-foreground truncate`,children:e.session.title}),(0,G.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:e.detail})]})})})}function VL({...e}){return(0,G.jsx)(Ac,{"data-slot":`hover-card`,...e})}function HL({...e}){return(0,G.jsx)(Mc,{"data-slot":`hover-card-trigger`,...e})}function UL({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,G.jsx)(Ic,{children:(0,G.jsx)(Rc,{"data-slot":`hover-card-content`,sideOffset:n,align:t,className:B(`z-50 origin-(--radix-hover-card-content-transform-origin) overflow-hidden rounded-lg dropdown-glass text-popover-foreground shadow-[0_16px_40px_-18px_rgb(0_0_0/55%)] outline-none dark:shadow-[0_18px_44px_-18px_rgb(0_0_0/80%)] duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function WL(e){let t=k(e=>e.machines),n=k(e=>e.projects),r=e.contextMenu?Bn:Mr;return t.filter(e=>e.status===`online`).flatMap(e=>[(0,G.jsxs)(r,{onSelect:()=>void zF(e.id,null),children:[(0,G.jsx)(Of,{icon:e.icon}),(0,G.jsx)(`span`,{className:`max-w-60 truncate`,children:e.name})]},e.id),...n.filter(t=>t.machine===e.id&&!t.hidden&&!t.scratch).map(t=>(0,G.jsxs)(r,{className:`pl-7`,onSelect:()=>void zF(e.id,t.id),children:[(0,G.jsx)(mc,{machine:e.id,projectId:t.id,className:`size-4`}),(0,G.jsx)(`span`,{className:`max-w-60 truncate`,children:t.name})]},`${e.id}:${t.id}`))])}function GL(e){let t=k(e=>e.machines),[n,r]=(0,W.useState)(!1),i=t.reduce((e,t)=>e+t.terminals.length,0),a=t.some(e=>e.status===`online`&&e.terminals.length>0),o=t.some(e=>e.status===`online`);if(t.length===0)return null;let s=(0,G.jsxs)(`button`,{className:B(e.buttonClassName,`group-hover/terminal:text-sidebar-foreground group-hover/terminal:[&>svg]:text-sidebar-foreground group-has-[[data-state=open]]/terminal:text-sidebar-foreground group-has-[[data-state=open]]/terminal:[&>svg]:text-sidebar-foreground h-8 w-full justify-start gap-2 px-2.5 text-sm`),title:`Terminal`,disabled:!o,onClick:o?()=>r(!0):void 0,children:[(0,G.jsx)(H,{icon:Zs}),`Terminal`,i>0&&(0,G.jsx)(`span`,{className:B(`text-foreground/75 ml-auto grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,o&&`group-hover/terminal:invisible group-has-[[data-state=open]]/terminal:invisible`,o&&`pointer-coarse:invisible`),children:i}),o&&(0,G.jsx)(H,{icon:mi,"aria-hidden":!0,className:`text-muted-foreground absolute right-2.5 size-4 opacity-0 group-hover/terminal:opacity-100 group-has-[[data-state=open]]/terminal:opacity-100 pointer-coarse:opacity-100`})]});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!o,children:(0,G.jsx)(`div`,{className:`group/terminal hover:bg-sidebar-row-hover has-[[data-state=open]]:bg-sidebar-row-hover data-[state=open]:bg-sidebar-row-hover relative rounded-[var(--control-radius)]`,children:o?(0,G.jsxs)(VL,{openDelay:0,open:n,onOpenChange:r,children:[(0,G.jsx)(HL,{asChild:!0,children:s}),(0,G.jsx)(UL,{side:`right`,align:`end`,className:`w-56 p-1`,onClick:()=>r(!1),children:(0,G.jsx)(vL,{})})]}):s})}),(0,G.jsxs)(tr,{onCloseAutoFocus:e=>e.preventDefault(),children:[(0,G.jsxs)(or,{children:[(0,G.jsxs)(Kn,{children:[(0,G.jsx)(H,{icon:Oo}),`New terminal`]}),(0,G.jsx)(Cr,{className:`max-h-80 overflow-y-auto`,children:(0,G.jsx)(WL,{contextMenu:!0})})]}),(0,G.jsxs)(Bn,{variant:`destructive`,disabled:!a,onSelect:()=>void XI(t.filter(e=>e.status===`online`).flatMap(e=>e.terminals.map(t=>({machine:e.id,id:t.id})))),children:[(0,G.jsx)(H,{icon:is}),`Close All`]})]})]}),(0,G.jsx)(oL,{})]})}var KL=null;function qL(e,t,n,r){let a=k(e=>e.inactiveVersion),o=k(e=>e.machines.filter(e=>e.status===`online`).map(e=>e.id).join(` `));(0,W.useEffect)(()=>{let a=JSON.stringify([t,n,o]);if(!e&&KL===a)return;let s=!0;async function l(){let e=o.split(` `).filter(e=>e!==``&&(t===null||e===t)),c=await Promise.all(e.map(async e=>{let t=await L(e,`sessions.inactive`,{projectId:n,limit:r});return{sessions:t.sessions.map(t=>({...t,machine:e})),total:t.total}}));if(!s)return;KL=a;let l=R(),u=new Map(l.inactive.map(e=>[P(e.machine,e.id),e])),d=c.flatMap(e=>e.sessions).sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,r).map(e=>{let t=u.get(P(e.machine,e.id));return t!==void 0&&Tn(t,e)?t:e}),f=c.reduce((e,t)=>e+t.total,0);Tn(d,l.inactive)&&f===l.inactiveTotal||i({inactive:d,inactiveTotal:f})}return l().catch(c),()=>{s=!1}},[e,t,n,o,a,r])}function JL(){let e=k(e=>e.usageOpen);return(0,G.jsx)(oi,{open:e,onOpenChange:N,children:(0,G.jsxs)($r,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,"aria-describedby":void 0,children:[(0,G.jsx)(ei,{className:`px-5 pt-4 pr-12 pb-3`,children:(0,G.jsx)(ri,{children:`Usage`})}),(0,G.jsx)(YL,{})]})})}function YL(){let e=k(e=>e.machines),[t,n]=(0,W.useState)(Date.now());(0,W.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),3e4);return()=>clearInterval(e)},[]);let r=e.filter(e=>e.status===`online`),i=new Map;for(let e of[...r.flatMap(e=>tR(e,e.claudeAccounts)),...r.flatMap(e=>tR(e,e.codexAccounts))]){if(!no(e.account))continue;let t=to(e.machine.id,e.account),n=i.get(t);n===void 0?i.set(t,{machine:e.machine.id,account:e.account,machines:[e.machine],names:[e.account.name]}):(n.machines.push(e.machine),n.names.push(e.account.name))}return i.size===0?(0,G.jsx)(`p`,{className:`text-muted-foreground border-t px-5 py-8 text-center text-xs`,children:`No Claude or Codex accounts with plan limits`}):(0,G.jsx)(`ul`,{className:`max-h-[70dvh] divide-y overflow-y-auto border-t`,children:[...i].map(e=>(0,G.jsx)(XL,{machine:e[1].machine,account:e[1].account,machines:e[1].machines,names:e[1].names,now:t},e[0]))})}function XL(e){let t=e.account,n=ro(e.machine,t),r=n?.limits.filter(e=>e.rejected||e.utilization!==null)??[],i=n?.updatedAt??n?.fetchedAt??null,a=i===null?null:yn(i),[o,s]=(0,W.useState)(!1),c=o||n===void 0;return(0,G.jsxs)(`li`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,G.jsx)(gc,{provider:t.provider,className:`size-3.5 shrink-0`}),(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:B(`truncate font-medium`,c&&`text-shimmer`),style:c?{"--shimmer-color":ZL[t.provider]}:{color:ZL[t.provider]},children:new Set(e.names).size===1?t.name:QL(t)}),t.plan!==null&&(0,G.jsxs)(`span`,{className:B(`shrink-0`,c?`text-shimmer`:`text-muted-foreground`),children:[`· `,$L(t.provider,t.plan)]})]}),(0,G.jsx)(`span`,{className:`bg-foreground/5 ml-1 flex shrink-0 items-center gap-1 rounded-full border px-1 py-0.5`,children:e.machines.map(e=>(0,G.jsx)(Xr,{label:e.name,children:(0,G.jsx)(`span`,{className:`text-icon-muted`,children:(0,G.jsx)(Of,{icon:e.icon,className:`size-3`})})},e.id))})]}),(0,G.jsxs)(U,{variant:`ghost-muted`,size:`xs`,className:`text-muted-foreground/70 -mr-2 h-6 shrink-0 gap-1.5 text-[11px] font-normal tabular-nums [&_svg]:mx-0`,title:`Refresh`,disabled:o,onClick:async()=>{s(!0),await so(e.machine,t,!0),s(!1)},children:[a!==null&&(a===`now`?`now`:`${a} ago`),(0,G.jsx)(H,{icon:Gn,className:B(`size-3`,o&&`animate-spin`)})]})]}),n===void 0&&(0,G.jsx)(`div`,{className:`grid grid-cols-[minmax(2.5rem,max-content)_minmax(0,1fr)_2.25rem_3.25rem] items-center gap-x-3 gap-y-2 text-xs`,children:Array.from({length:2},(e,t)=>(0,G.jsxs)(W.Fragment,{children:[(0,G.jsx)(`span`,{className:`bg-foreground/10 my-0.5 h-3 w-12 animate-pulse rounded`}),(0,G.jsx)(`span`,{className:`bg-foreground/10 h-1.5 animate-pulse rounded-full`}),(0,G.jsx)(`span`,{className:`bg-foreground/10 ml-auto h-3 w-7 animate-pulse rounded`}),(0,G.jsx)(`span`,{className:`bg-foreground/10 h-3 w-10 animate-pulse rounded`})]},t))}),r.length>0&&(0,G.jsx)(`div`,{className:`grid grid-cols-[minmax(2.5rem,max-content)_minmax(0,1fr)_2.25rem_3.25rem] items-center gap-x-3 gap-y-2 text-xs`,children:r.map(t=>{let n=t.rejected?0:Math.max(0,100-Math.round((t.utilization??0)*100));return(0,G.jsxs)(W.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground capitalize`,children:Xm(t)}),(0,G.jsx)(`div`,{className:`bg-foreground/10 h-1.5 overflow-hidden rounded-full`,children:(0,G.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${n}%`,backgroundColor:eR(n)}})}),(0,G.jsxs)(`span`,{className:`text-right tabular-nums`,style:{color:eR(n)},children:[n,`%`]}),(0,G.jsx)(`span`,{className:`text-muted-foreground whitespace-nowrap tabular-nums`,title:t.resetsAt===null?void 0:ar(t.resetsAt*1e3),children:t.resetsAt===null?``:xn(t.resetsAt*1e3-e.now)})]},t.window)})}),n!==void 0&&n.error!==null&&(0,G.jsxs)(`p`,{className:`text-destructive text-xs`,children:[`Couldn't refresh: `,n.error]}),n!==void 0&&n.error===null&&r.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground/70 text-xs`,children:`No limits reported for this account`})]})}var ZL={claude:`#d97757`,codex:`#6e5ae6`};function QL(e){if(e.displayName!==null)return e.displayName;if(e.email===null)throw Error(`${e.name} has no email`);return e.organization!==null&&e.organization!==`${e.email}'s Organization`?e.organization:e.email.split(`@`)[0]}function $L(e,t){return t.split(/[\s_]+/).filter(t=>t.toLowerCase()!==e).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}function eR(e){return`hsl(${e/100*130} 40% 48%)`}function tR(e,t){return t.map(t=>({machine:e,account:t}))}var nR=`text-sidebar-muted-foreground/80 hover:bg-sidebar-row-hover hover:text-sidebar-foreground flex shrink-0 cursor-pointer items-center justify-center rounded-[var(--control-radius)] [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-(--sidebar-icon-color) hover:[&>svg]:text-sidebar-foreground`,rR=50;function iR(e){let t=k(e=>e.selection),n=k(e=>e.machines),r=k(e=>e.sessions),i=k(e=>e.projects),a=k(e=>e.settings.provider),o=k(e=>e.unseen),s=k(e=>e.loaded),c=k(e=>e.inactive),l=k(e=>e.inactiveTotal),u=k(e=>e.prefs.groupActiveByProject),[f,m]=zr(`sidebarScope`,null),[h,g]=(0,W.useState)(null),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)(!1),[x,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(!1),[E,D]=(0,W.useState)(rR),[O,A]=zr(`sidebarWidth`,240),j=r.filter(e=>f===null||e.machine===f.machine&&de(e.machine,e.projectId)===f.projectId).sort((e,t)=>t.updatedAt-e.updatedAt),M=j.filter(e=>{let t=$e(n,e.machine,e.id);return e.status===`snoozed`&&t?.waiting!==!0&&(t?.running===!0||Object.values(t?.tasks??{}).includes(`running`))}),ee=[...j.filter(e=>e.status===`pinned`),...j.filter(e=>e.status===`active`||e.status===`snoozed`&&!M.includes(e))],te=j.filter(e=>e.status===`minimized`),ne=f?.machine??null,re=f?.projectId??null,ie=t!==null&&t.sessionId!==null&&s&&!r.some(e=>e.machine===t.machine&&e.id===t.sessionId)?{machine:t.machine,id:t.sessionId,provider:a,title:`New thread`,projectId:t.projectId,branch:null,updatedAt:Date.now(),status:`active`}:null,ae=t!==null&&t.sessionId===null?t:null,oe=ie===null?ee:[ie,...ee],se=u&&f===null,ce=[...new Map([...ae===null?[]:[ae],...oe].map(e=>{let t=de(e.machine,e.projectId);return[P(e.machine,t),{machine:e.machine,projectId:t}]}))],le=e.mobile?OL:GA;function de(e,t){return i.some(n=>n.machine===e&&n.id===t&&n.scratch)?S:t}qL(w,ne,re,E);function fe(){let e=f??t??gt();e===null?n.length>0?g(n[0].id):d(`Machines`):we(e.machine,e.projectId)}vr([`mod+n`,`mod+t`],fe,{enableOnFormTags:!0,preventDefault:!0}),vr([`mod+1`,`mod+2`,`mod+3`,`mod+4`,`mod+5`,`mod+6`,`mod+7`,`mod+8`,`mod+9`],e=>{let t=se?ce.flatMap(e=>oe.filter(t=>P(t.machine,de(t.machine,t.projectId))===e[0])):oe,n=/^(?:Digit|Numpad)([1-9])$/.exec(e.code);if(n===null)throw Error(`unexpected session shortcut key ${e.code}`);let r=t[Number(n[1])-1];r!==void 0&&aR(r.machine,r.projectId,r.id)},{enableOnFormTags:!0,preventDefault:!0,enabled:!e.mobile});function F(e){let t=e.clientX-O;Vt(e,e=>{let n=Math.min(480,Math.max(200,e.clientX-t));A(n)})}function I(r,i){let a=e.mobile?EL:UA;return(0,G.jsx)(a,{session:r,slim:i,selected:t?.machine===r.machine&&t.sessionId===r.id,activity:$e(n,r.machine,r.id),unseen:o.includes(P(r.machine,r.id)),saved:r!==ie,scope:f,onSelect:aR},P(r.machine,r.id))}function pe(e){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`li`,{className:B(`mx-0.5 h-9 pt-2`,e.first&&`mt-auto`),children:(0,G.jsxs)(`button`,{"aria-expanded":e.open,className:`text-sidebar-muted-foreground/60 flex h-9 w-full cursor-pointer items-center gap-2 rounded-md px-2 text-left text-xs font-medium`,onClick:e.onToggle,children:[(0,G.jsx)(H,{icon:e.icon,className:`size-3 shrink-0`}),(0,G.jsx)(`span`,{className:`-ms-1 shrink-0`,children:e.label}),(0,G.jsx)(`span`,{className:`bg-sidebar-border/60 h-px min-w-2 flex-1`}),(0,G.jsx)(H,{icon:Rr,className:B(`size-3 shrink-0 transition-transform`,!e.open&&`rotate-180`)})]})}),e.open&&e.items.map(e=>I(e,e.status===`inactive`))]})}return(0,G.jsxs)(`aside`,{className:B(`bg-sidebar text-sidebar-foreground border-sidebar-border flex flex-none border-r select-none`,e.className),children:[(0,G.jsxs)(`div`,{className:B(`relative flex min-w-0 flex-col`,e.mobile&&`flex-1`),style:e.mobile?void 0:{width:O},children:[(0,G.jsxs)(`div`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-2 px-3`,children:[e.mobile?(0,G.jsx)(CL,{buttonClassName:nR}):(0,G.jsx)(`button`,{className:B(nR,`size-7 [&>svg]:size-4.5`),title:`Hide sidebar (${z}+B)`,"aria-label":`Hide sidebar`,onClick:e.onHide,children:(0,G.jsx)(H,{icon:Ms})}),(0,G.jsx)(Nm,{scope:f,onScope:m,onEdit:v,onAddProject:g}),e.mobile&&(0,G.jsx)(IL,{hideDone:!0}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.75`,children:[(0,G.jsx)(`button`,{className:B(nR,`size-7 [&>svg]:size-4.5`),title:`Search (${z}+K)`,"aria-label":`Search`,onClick:()=>ue(!0),children:(0,G.jsx)(H,{icon:br})}),(0,G.jsx)(`button`,{className:B(nR,`size-7 [&>svg]:size-4.5`),title:`New thread (${z}+N)`,onClick:fe,children:(0,G.jsx)(H,{icon:Ys})})]})]}),(0,G.jsx)(`nav`,{className:`flex min-h-0 flex-1 [scrollbar-width:none] flex-col overflow-y-auto px-(--sidebar-content-inset) pb-(--sidebar-content-inset)`,children:(0,G.jsxs)(`ul`,{className:`flex flex-1 flex-col gap-px`,children:[se?ce.map(([t,n])=>(0,G.jsx)(FL,{machine:n.machine,projectId:n.projectId,sessions:oe.filter(e=>P(e.machine,de(e.machine,e.projectId))===t),started:ie,mobile:e.mobile},t)):(0,G.jsxs)(G.Fragment,{children:[ae!==null&&(0,G.jsx)(le,{machine:ae.machine,projectId:ae.projectId,onSelect:()=>aR(ae.machine,ae.projectId,null)}),oe.map(e=>I(e,!1))]}),ee.length===0&&ie===null&&t?.sessionId!==null&&(0,G.jsx)(`li`,{className:`text-sidebar-muted-foreground/60 px-2.5 py-6 text-center text-xs`,children:`No threads yet`}),M.length>0&&pe({icon:sc,label:y?`Snoozed`:`Snoozed (${M.length})`,items:M,open:y,onToggle:()=>b(!y),first:!0}),te.length>0&&pe({icon:As,label:x?`Minimized`:`Minimized (${te.length})`,items:te,open:x,onToggle:()=>C(!x),first:M.length===0}),pe({icon:tc,label:`Done`,items:c.slice(0,E),open:w,onToggle:()=>{T(!w),D(rR)},first:M.length===0&&te.length===0}),w&&l>E&&c.length>=E&&(0,G.jsx)(`li`,{"aria-hidden":!0,className:`h-px shrink-0`,ref:e=>{if(e===null)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&D(E+rR)});return t.observe(e),()=>t.disconnect()}})]})}),!e.mobile&&(0,G.jsxs)(`div`,{className:`border-sidebar-border @container flex shrink-0 flex-col gap-px border-t p-(--sidebar-content-inset)`,children:[(0,G.jsx)(GL,{buttonClassName:nR}),(0,G.jsxs)(`button`,{className:B(nR,`h-8 w-full justify-start gap-2 px-2.5 text-sm`),title:`Usage`,onClick:()=>N(!0),children:[(0,G.jsx)(H,{icon:rs}),(0,G.jsx)(`span`,{className:`truncate`,children:`Usage`})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`button`,{className:B(nR,`h-8 w-full justify-start gap-2 px-2.5 text-sm`),title:`Settings`,onClick:()=>p(!0),children:[(0,G.jsx)(H,{icon:Us}),(0,G.jsx)(`span`,{className:`truncate`,children:`Settings`})]}),(0,G.jsxs)(`div`,{className:`absolute top-1.5 right-1.5`,children:[(0,G.jsx)(IL,{className:`@max-[13rem]:hidden`,hideDone:!1}),(0,G.jsx)(IL,{className:`hidden @max-[13rem]:flex`,hideDone:!1,collapsed:!0})]})]})]}),!e.mobile&&(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize select-none`,onPointerDown:F,children:(0,G.jsx)(`span`,{className:`group-hover:bg-border group-active:bg-primary/60 pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 transition-colors`})})]}),(0,G.jsx)(JL,{}),h!==null&&(0,G.jsx)(Am,{machine:h,onClose:()=>g(null),onAdd:e=>{g(null),aR(e.machine,e.id,null)}}),_!==null&&(0,G.jsx)(Mm,{project:_,onClose:()=>v(null),onRemoved:()=>{f?.machine===_.machine&&f.projectId===_.id&&m(null),v(null)}})]})}function aR(e,t,n){Ie({machine:e,projectId:t,sessionId:n})}var oR={running:`Running`,completed:`Done`,failed:`Failed`,stopped:`Stopped`};function sR(e,t){return{agents:e.flatMap(e=>e.kind===`subagent`?[{item:e,agentId:e.agentId,status:lR(e.status,e.agentId,t)}]:[]),tasks:e.flatMap(e=>e.kind===`command`&&e.background!==null?[{item:e,taskId:e.background.taskId,path:e.background.outputPath,events:e.background.events,status:lR(e.status,e.background.taskId,t)}]:[])}}function cR(e){return e.description===``?e.command:e.description}function lR(e,t,n){let r=t===null?void 0:n?.tasks[t];return r===void 0?e===`running`?t===null&&n?.running===!0?`Running`:`Stopped`:oR[e]:oR[r]}function uR(e){return(0,G.jsx)(`span`,{className:B(e.active&&`text-shimmer`),children:e.text})}function dR(e){return(0,G.jsxs)(`span`,{className:B(`flex min-w-0 items-baseline overflow-hidden text-[13px] leading-4 tracking-[-0.04px]`,e.grouped?`gap-1.5`:`gap-2`),children:[(0,G.jsx)(`span`,{className:B(`text-foreground shrink-0`,e.grouped?`font-normal`:`font-medium`),children:(0,G.jsx)(uR,{text:e.title,active:e.pending})}),e.subtitle!==void 0&&e.subtitle!==``&&(0,G.jsx)(`span`,{className:B(`min-w-0 truncate tabular-nums`,e.grouped?`text-muted-foreground/70`:`text-muted-foreground`),children:e.subtitle}),e.args?.map(t=>(0,G.jsx)(`span`,{className:B(`min-w-0 truncate tabular-nums`,e.grouped?`text-muted-foreground/70`:`text-muted-foreground`),children:t},t))]})}function fR(e){return(0,G.jsx)(`span`,{"aria-hidden":!0,className:B(`text-muted-foreground/70 flex size-6 shrink-0 items-center justify-center transition-opacity`,e.open?`opacity-100`:`opacity-0 group-hover/tool:opacity-100`,e.className),children:(0,G.jsx)(H,{icon:Dr,strokeWidth:2.5,className:B(`size-3.5 transition-transform`,!e.open&&`-rotate-90`)})})}function pR(e){let t=e.onToggle,n=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`flex max-w-[calc(100%-24px)] min-w-0 items-center`,children:(0,G.jsx)(dR,{title:e.title,subtitle:e.subtitle,args:e.args,pending:e.pending,grouped:e.grouped})}),t!==null&&(0,G.jsx)(fR,{open:e.open})]});return(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[t===null?(0,G.jsx)(`div`,{className:B(`flex w-full items-center select-none`,e.grouped?`min-h-7`:`min-h-9`),children:n}):(0,G.jsx)(`button`,{type:`button`,"aria-expanded":e.open,onClick:t,className:B(`group/tool focus-visible:ring-ring/70 flex w-full cursor-pointer items-center rounded-md text-left select-none focus-visible:ring-2 focus-visible:outline-none`,e.grouped?`h-7`:`h-9`),children:n}),e.open&&e.children!==void 0&&(0,G.jsx)(`div`,{className:B(`min-w-0 pt-1`,e.rail!==!1&&`ps-3`),children:e.children})]})}var mR=new Map([[`build`,`text-blue-400`],[`explore`,`text-yellow-400`],[`plan`,`text-pink-400`],[`review`,`text-green-400`],[`writer`,`text-purple-400`]]),hR=new Map([[`Running`,`Launched agent`],[`Done`,`Agent finished`],[`Failed`,`Agent failed`],[`Stopped`,`Agent stopped`]]),gR=new Map([[`Running`,`Started in background`],[`Done`,`Background task finished`],[`Failed`,`Background task failed`],[`Stopped`,`Background task stopped`]]),_R=[`text-sky-400`,`text-amber-400`,`text-fuchsia-400`,`text-emerald-400`,`text-violet-400`,`text-cyan-400`,`text-orange-400`,`text-teal-400`,`text-rose-400`,`text-indigo-400`,`text-lime-400`,`text-red-400`];function vR(e){let t=e.agent,n=t.toLowerCase(),r=0;for(let e of n)r=r*31+e.charCodeAt(0)>>>0;return{name:t[0].toUpperCase()+t.slice(1),description:e.description,tone:mR.get(n)??_R[r%_R.length]}}function yR(e){return(0,G.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,className:B(`size-4 shrink-0`,e.className),children:[(0,G.jsx)(`path`,{d:`M4 4.5C4 4.22386 4.22386 4 4.5 4H11.5C11.7761 4 12 4.22386 12 4.5V11.5C12 11.7761 11.7761 12 11.5 12H4.5C4.22386 12 4 11.7761 4 11.5V4.5Z`,fill:`currentColor`}),(0,G.jsx)(`path`,{d:`M14.5 1C14.7761 1 15 1.22386 15 1.5V14.5C15 14.7761 14.7761 15 14.5 15H1.5C1.22386 15 1 14.7761 1 14.5V1.5C1 1.22386 1.22386 1 1.5 1H14.5ZM2 14H14V2H2V14Z`,fill:`currentColor`})]})}function bR(e){return(0,G.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":!0,className:B(`size-4 shrink-0`,e.className),children:Array.from({length:25},(e,t)=>(0,G.jsx)(`rect`,{x:1+t%5*3,y:1+Math.floor(t/5)*3,width:2,height:2,fill:`currentColor`,className:`agent-dot`,style:{animationDelay:`${(t%5+Math.floor(t/5))*90}ms`}},t))})}function xR(e){let t=e.item;if(t.kind===`agent_message`){let n=t.target;return(0,G.jsx)(SR,{label:`Messaged agent`,detail:t.summary,pending:e.sending,onOpen:n===null?null:()=>e.onOpen(n)})}if(t.kind===`command`){let n=e.tasks.find(e=>e.item.id===t.id);if(n===void 0)throw Error(`Task ${t.id} is missing from the thread`);return(0,G.jsx)(SR,{label:gR.get(n.status)??`Background task ${n.status.toLowerCase()}`,detail:cR(n.item),pending:n.status===`Running`,onOpen:()=>e.onOpen(t.id)})}let n=e.agents.find(e=>e.item.id===t.id);if(n===void 0)throw Error(`Agent ${t.id} is missing from the thread`);return(0,G.jsx)(SR,{label:hR.get(n.status)??`Agent ${n.status.toLowerCase()}`,detail:t.description,pending:n.status===`Running`,onOpen:()=>e.onOpen(t.id)})}function SR(e){let t=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:(0,G.jsx)(uR,{text:e.detail===``?e.label:`${e.label}:`,active:e.pending})}),e.detail!==``&&(0,G.jsx)(`span`,{className:`text-foreground min-w-0 truncate`,children:e.detail})]});return e.onOpen===null?(0,G.jsx)(`div`,{className:`flex min-h-7 min-w-0 items-center gap-1 text-[13px] leading-4 tracking-[-0.04px] select-none`,children:t}):(0,G.jsxs)(`button`,{type:`button`,title:`Open in Tasks panel`,onClick:e.onOpen,className:`group/agent focus-visible:ring-ring/70 flex min-h-7 w-fit max-w-full cursor-pointer items-center gap-1 rounded-md text-left text-[13px] leading-4 tracking-[-0.04px] select-none focus-visible:ring-2 focus-visible:outline-none`,children:[t,(0,G.jsx)(`span`,{className:`text-muted-foreground/70 flex shrink-0 opacity-0 transition-opacity group-hover/agent:opacity-100 group-focus-visible/agent:opacity-100 pointer-coarse:opacity-100`,children:(0,G.jsx)(H,{icon:kn,className:`size-3.5`})})]})}function CR(e){let t=(0,W.useRef)(null),[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(0),[o,s]=(0,W.useState)([]),c=o.length===0?-1:Math.min(i,o.length-1);(0,W.useEffect)(()=>t.current?.focus(),[]),(0,W.useEffect)(()=>{let t=e.content.current;if(t===null)throw Error(`transcript is not mounted`);if(n===``)return;let r=0,i=new MutationObserver(()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>s(wR(t,n)))});return i.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{i.disconnect(),cancelAnimationFrame(r)}},[n,e.content]),(0,W.useEffect)(()=>{if(o.length!==0)return CSS.highlights.set(`transcript-find`,new Highlight(...o)),c!==-1&&CSS.highlights.set(`transcript-find-current`,new Highlight(o[c])),()=>{CSS.highlights.delete(`transcript-find`),CSS.highlights.delete(`transcript-find-current`)}},[o,c]);function l(t,n){let i=e.content.current,o=e.scroller.current;if(i===null||o===null)throw Error(`transcript is not mounted`);let c=t===``?[]:wR(i,t),l=c.length===0?0:(n+c.length)%c.length;if(r(t),a(l),s(c),c.length===0)return;let u=c[l].getBoundingClientRect(),d=o.getBoundingClientRect();(u.top<d.top+48||u.bottom>d.bottom-48)&&o.scrollBy({top:u.top-d.top-d.height/3})}return(0,G.jsxs)(`div`,{"data-transcript":!0,className:`bg-card absolute top-2 right-6 z-30 flex items-center gap-1 rounded-lg border p-1 shadow-lg`,children:[(0,G.jsx)(Tp,{ref:t,"data-thread-find":!0,className:`h-7 w-52`,placeholder:`Find in thread`,"aria-label":`Find in thread`,value:n,onChange:e=>l(e.target.value,0),onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),e.onClose()):t.key===`Enter`&&(t.preventDefault(),l(n,c+(t.shiftKey?-1:1)))}}),(0,G.jsx)(`span`,{className:`text-muted-foreground w-16 text-center text-xs tabular-nums`,children:n===``?``:o.length===0?`No results`:`${c+1} of ${o.length}`}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous match`,onClick:()=>l(n,c-1),children:(0,G.jsx)(H,{icon:Bo})}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next match`,onClick:()=>l(n,c+1),children:(0,G.jsx)(H,{icon:Dr})}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close find`,onClick:e.onClose,children:(0,G.jsx)(H,{icon:Go})})]})}function wR(e,t){let n=[],r=[],i=``,a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=a.nextNode();e!==null;e=a.nextNode())e instanceof Text&&(n.push(e),r.push(i.length),i+=e.data);let o=new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`gi`),s=[],c=0;for(let e of i.matchAll(o)){let t=e.index+e[0].length;for(;c+1<r.length&&r[c+1]<=e.index;)c++;let i=c;for(;i+1<r.length&&r[i+1]<t;)i++;let a=document.createRange();a.setStart(n[c],e.index-r[c]),a.setEnd(n[i],t-r[i]),a.getClientRects().length>0&&s.push(a)}return s}function TR(e){let[t,n]=(0,W.useState)(!1),r=e.plan,i=DR(r),a=r.length>900||r.split(`
|
|
16
|
+
`,``,``,``,``,`\x1B[99;5u`,`\x1B[100;5u`,`\x1B[111;5u`,`\x1B[122;5u`];function oF(e,t){return e.y<t.y||e.y===t.y&&e.x<t.x}var sF=class{shell=`unknown`;generation=0;core;native=!1;input=!1;clickEvents=!1;inputRef=null;constructor(e){this.core=e}mark(e,t){let n=e.startsWith(`133;`),r=n?4:5;if(e.length>r+1&&e[r+1]!==`;`)return;let i=e.charAt(r);if(!this.core.isAlternateScreen()){if(i===`A`){let r=e.split(`;`);if(r.includes(`k=s`)||r.includes(`k=c`))return;let i=n&&r.includes(`click_events=1`),a=this.shell===`prompt`,o=a&&!this.input&&this.native!==n;if(this.shell=`prompt`,this.native=n,t&&this.trackInput(),o){this.clickEvents=this.clickEvents||i;return}if(this.input=!1,this.clickEvents=i,a)return;this.generation+=1}else if(i===`B`)this.shell=`prompt`,this.input=!0,t&&this.trackInput();else if(i===`C`)this.shell=`command`;else if(i===`D`){if(this.shell===`prompt`&&!this.input)return;this.shell=`unknown`}}}beforeInput(e){this.shell===`prompt`&&aF.some(t=>e.includes(t))&&(this.shell=`unknown`)}reset(){this.release(),this.shell=`unknown`,this.input=!1,this.clickEvents=!1}release(){this.inputRef!==null&&this.core.untrack(this.inputRef),this.inputRef=null}moveCursorInput(e,t,n){if(this.shell!==`prompt`||this.inputRef===null||t===null||t.cursorX<0||t.cursorY<0||this.core.isAlternateScreen()||this.core.isMouseTracking())return null;let r=this.core.trackedPoint(this.inputRef);if(r===null)return null;let i={x:r.x,y:r.y-n};if(oF(e,i))return null;if(this.clickEvents){let t=this.core.scrollbarState();if(t===null)return null;let r=e.y+n-(t.total-t.len);return r<0?null:`\x1b[<0;${e.x+1};${r+1}M`}if(!this.input)return null;let a={x:e.x,y:e.y};a.x>0&&t.rowData[a.y]?.cells[a.x]?.wide===BN.spacerTail&&--a.x;let o={x:t.cursorX,y:t.cursorY};if(oF(a,i)||oF(o,i))return null;let s=oF(a,o),c=s?a:o,l=s?o:a,u=0;for(let e=c.y;e<=l.y;e+=1){let n=t.rowData[e];if(n===void 0)return null;let r=e===l.y?l.x:n.cells.length;for(let t=e===c.y?c.x:0;t<r;t+=1)n.cells[t].text!==``&&(u+=1);if(e<l.y&&!n.wrapsToNext){if(s)return null;break}}let d=s?`ArrowLeft`:`ArrowRight`,f=this.core.encoder.encodeKey(new KeyboardEvent(`keydown`,{key:d,code:d}));return u>0?f.repeat(u):``}trackInput(){this.inputRef===null?this.inputRef=this.core.trackCursor():this.core.retrack(this.inputRef)}},cF=Fe.withTag(`terminal`),lF=navigator.userAgent.includes(`Mac`),uF=navigator.userAgent.includes(`Windows`),dF=600,fF=1e3,pF=1e4,mF=new TextDecoder(`latin1`),hF=new TextDecoder;function gF(e){let t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!t)throw Error(`unsupported color ${e}`);return{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}}function _F(e){return[...e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0).map(e=>/^(['"]).*\1$/.test(e)||/^[a-zA-Z][a-zA-Z0-9-]*$/.test(e)?e:`"${e.replaceAll(`"`,``)}"`),`monospace`].join(`, `)}async function vF(e){try{(await e)?.close()}catch(e){cF.warn(`could not decode image`,e)}}var yF=class{element;cols=80;rows=24;canvas;input;context;core;scanner=new wP;handlers;observer;prompt;search;images;pointer;notifications=new vP;options;appearance;metrics;snapshot=null;sized=!1;fitted=!1;frame=0;forceFull=!0;renderFailed=!1;cursorOn=!0;cursorTimer=null;syncTimer=null;renderedCursorY=null;focused=!1;composing=!1;suppressedKeys=new Set;heldOptionKeys=new Set;backlog=[];blocked=!1;epoch=0;title=``;progress={state:0,value:0};disposed=!1;constructor(e,t){this.options=e,this.handlers=t,this.element=document.createElement(`div`),this.element.className=`relative h-full overflow-hidden`,this.canvas=document.createElement(`canvas`),this.canvas.className=`absolute top-0 left-0 cursor-text touch-none`,this.input=document.createElement(`textarea`),this.input.setAttribute(`aria-label`,`Terminal input`),this.input.autocapitalize=`off`,this.input.autocomplete=`off`,this.input.spellcheck=!1,this.input.style.cssText=`position:absolute;left:0;top:0;width:1px;height:1px;opacity:0;padding:0;border:0;resize:none;pointer-events:none;`;let n=document.createElement(`div`);n.className=`absolute top-0 right-0 bottom-0 w-2 cursor-default touch-none`,n.hidden=!0;let r=document.createElement(`div`);r.className=`bg-foreground/15 hover:bg-foreground/30 absolute inset-x-0.5 top-0 rounded-full`,n.append(r),this.element.append(this.canvas,this.input,n);let i=this.canvas.getContext(`2d`,{alpha:!1});if(!i)throw Error(`canvas 2d is unavailable`);this.context=i,this.appearance=this.appearanceFor(e),this.metrics=this.measure(),this.core=new rP(Math.max(1,Math.floor(window.innerWidth/this.metrics.width)),this.rows,e.scrollback,t.onReply,t.onBell),this.prompt=new sF(this.core),this.search=new aP(this.core,()=>this.redraw()),this.images=new LM(this.core),this.pointer=new iF({canvas:this.canvas,scrollbar:n,thumb:r,core:this.core,view:()=>({cols:this.cols,rows:this.rows,metrics:this.metrics,snapshot:this.snapshot,clickToMoveCursor:this.options.clickToMoveCursor}),focus:()=>this.focus(),redraw:()=>this.redraw(),scrollViewport:e=>this.scrollViewport(e),moveCursorTo:e=>this.moveCursorTo(e),onData:t.onData,onLink:t.onLink}),this.applyTerminalOptions(),this.resizeCore(),this.installEvents(),this.observer=new ResizeObserver(()=>this.fit()),this.observer.observe(this.element)}setOptions(e){this.options=e,this.appearance=this.appearanceFor(e),this.metrics=this.measure(),e.clickToMoveCursor||this.prompt.release(),this.applyTerminalOptions(),this.resizeCore(),this.forceFull=!0,this.fit(),this.requestRender()}write(e,t){this.disposed||(this.backlog.push({data:e,replay:t}),this.blocked||this.drain())}reset(){this.epoch+=1,this.backlog=[],this.blocked=!1,this.scanner.reset(),this.prompt.reset(),this.core.reset(),this.applyTerminalOptions(),this.images.clear(),this.core.clearSelection(),this.redraw()}focus(){this.input.focus({preventScroll:!0})}isKittyKeyboard(){return this.core.isKittyKeyboard()}paste(e){let t=this.core.encoder.encodePaste(e);t.length>0&&this.sendInput(t)}presize(e,t){this.fitted||e===this.cols&&t===this.rows||(this.cols=e,this.rows=t,this.resizeCore())}fit(){if(this.disposed)return;let e=this.element.clientWidth,t=this.element.clientHeight;if(e===0||t===0){this.sized=!1;return}this.sized=!0,this.fitted=!0;let n=window.devicePixelRatio||1,r=Math.round(e*n),i=Math.round(t*n);(this.canvas.width!==r||this.canvas.height!==i)&&(this.canvas.width=r,this.canvas.height=i,this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this.context.setTransform(n,0,0,n,0,0),this.metrics=this.measure(),this.resizeCore(),this.forceFull=!0);let a=Math.max(1,Math.floor(e/this.metrics.width)),o=Math.max(1,Math.floor(t/this.metrics.height));(a!==this.cols||o!==this.rows)&&(this.cols=a,this.rows=o,this.resizeCore(),this.forceFull=!0,this.handlers.onResize(a,o)),this.renderFrame()}find(e,t,n){let r=this.viewportTop(),i=this.search.find(e,t,n,r);i!==null&&(i.row<r||i.row>=r+this.rows)&&this.scrollViewport(i.row-r-Math.floor(this.rows/2)),this.redraw()}onFindResults(e){return this.search.onResults(e)}clearFind(){this.search.clear(),this.redraw()}replyClipboard(e,t){t.epoch!==this.epoch||t.generation!==this.prompt.generation||t.atPrompt&&this.prompt.shell!==`prompt`||this.handlers.onReply(pP(e,t.selection,t.terminator))}beforeInput(e){this.prompt.beforeInput(e)}dispose(){this.disposed||(this.disposed=!0,this.observer.disconnect(),this.cancelRender(),this.pointer.dispose(),this.search.dispose(),window.removeEventListener(`focus`,this.onWindowFocus),document.removeEventListener(`visibilitychange`,this.onVisibilityChange),this.images.clear(),this.prompt.release(),this.core.dispose(),this.element.remove())}redraw(){this.forceFull=!0,this.requestRender()}resizeCore(){this.core.resize(this.cols,this.rows,this.metrics.width,this.metrics.height,window.devicePixelRatio||1)}appearanceFor(e){let t=e.colors;return{fontSize:e.fontSize,fontFamily:_F(e.fontFamily),ligatures:e.ligatures,cursorText:t.cursorText,selectionBackground:t.selectionBackground,selectionForeground:t.selectionForeground,matchBackground:t.palette[8],activeMatchBorder:t.palette[3]}}measure(){return YP(this.context,this.options.fontSize,this.appearance.fontFamily,this.options.lineHeight,window.devicePixelRatio||1)}applyTerminalOptions(){let e=this.options.colors;this.core.setColors({foreground:gF(e.foreground),background:gF(e.background),cursor:gF(e.cursor),palette:e.palette.map(gF)}),this.core.setCursor(this.options.cursorStyle,this.options.cursorBlink),this.core.boldIsBright=this.options.boldIsBright,this.core.version=this.options.version,this.core.invalidate()}drain(){for(;!this.blocked&&this.backlog.length>0;){let e=this.backlog.shift();e&&this.process(e)}let e=this.core.title();e!==this.title&&(this.title=e,this.handlers.onTitle(e)),this.search.outputChanged(),this.cursorOn=!0,this.requestRender()}process(e){let t=e.data,n=e.replay;this.core.setReplies(!n);let r=0,i=this.scanner.scan(t,(e,i)=>(this.core.write(t.subarray(r,i)),r=i,this.handleOutput(e,n)));this.core.write(t.subarray(r,i)),i<t.length&&this.backlog.unshift({data:t.subarray(i),replay:n})}handleOutput(e,t){if(e.type===`sixel`)return this.decodeImage(NM(e.data));let n=mF.decode(e.data);if(n.startsWith(`1337;File=`))return this.decodeImage(FM(n.slice(10),{cellWidth:this.metrics.width,cellHeight:this.metrics.height,width:this.cols*this.metrics.width,height:this.rows*this.metrics.height,pixelRatio:window.devicePixelRatio||1}));if(n.startsWith(`133;`)||n.startsWith(`6973;`))return this.prompt.mark(n,this.options.clickToMoveCursor),!1;if(n.startsWith(`52;`)){let r=n.split(`;`),i=r[2];if(t||i===void 0)return!1;if(i===`?`)return this.handlers.onClipboardRead({selection:dP(r[1]),terminator:e.terminator,generation:this.prompt.generation,epoch:this.epoch,atPrompt:this.prompt.shell===`prompt`}),!1;let a=fP(i);return a!==null&&this.handlers.onClipboard(a),!1}if(n===`10;?`||n===`11;?`||n===`12;?`)return t||this.handlers.onReply(mP(n,this.core.currentColors(),e.terminator)),!1;if(n.startsWith(`4;`)){if(!t)for(let t of hP(n,this.core.currentColors().palette,e.terminator))this.handlers.onReply(t);return!1}if(n===`9;4`||n.startsWith(`9;4;`)){let e=gP(n,this.progress);return e!==null&&(this.progress=e,this.handlers.onProgress(e)),!1}if(t)return!1;let r=n.startsWith(`99;`)?this.notifications.add(hF.decode(e.data)):_P(n,e.data);return r!==null&&this.handlers.onNotify(r.title,r.body),!1}decodeImage(e){return this.blocked=!0,this.placeImage(e,this.epoch,window.devicePixelRatio||1),!0}async placeImage(e,t,n){let r=0,i=new Promise(e=>{r=window.setTimeout(()=>e(`timeout`),pF)});try{let r=await Promise.race([e,i]);r===`timeout`?(cF.warn(`image decoding took too long, skipping the image`),vF(e)):r!==null&&(t===this.epoch&&!this.disposed?this.images.place(r,n,this.metrics.height):r.close())}catch(e){cF.warn(`could not decode image`,e)}window.clearTimeout(r),t!==this.epoch||this.disposed||(this.blocked=!1,this.drain())}moveCursorTo(e){if(!this.options.clickToMoveCursor)return;let t=this.prompt.moveCursorInput(e,this.snapshot,this.viewportTop());t!==null&&(t!==``&&this.sendInput(t),this.core.clearSelection(),this.redraw())}sendInput(e){this.prompt.beforeInput(e),this.core.scrollbarState()?.offset!==this.maxOffset()&&(this.core.scrollToBottom(),this.redraw()),this.handlers.onData(e)}maxOffset(){let e=this.core.scrollbarState();return e?Math.max(0,e.total-e.len):0}viewportTop(){return this.core.toScreen({x:0,y:0})?.y??0}scrollViewport(e){let t=this.core.scrollbarState(),n=Math.trunc(e);if(t!==null){let e=Math.max(0,t.total-t.len);n=Math.max(0,Math.min(t.offset+n,e))-t.offset}n!==0&&(this.core.scroll(n),this.redraw())}requestRender(){!this.disposed&&this.sized&&this.frame===0&&(this.frame=window.requestAnimationFrame(()=>{this.frame=0,this.renderFrame()}))}cancelRender(){this.frame!==0&&window.cancelAnimationFrame(this.frame),this.frame=0,this.cursorTimer!==null&&window.clearTimeout(this.cursorTimer),this.cursorTimer=null,this.syncTimer!==null&&window.clearTimeout(this.syncTimer),this.syncTimer=null}renderFrame(){if(!this.disposed&&this.sized&&this.element.isConnected){this.frame!==0&&window.cancelAnimationFrame(this.frame),this.frame=0;try{this.draw(),this.renderFailed=!1}catch(e){this.renderFailed||cF.error(`could not draw the terminal`,e),this.renderFailed=!0}}}draw(){if(this.core.isSynchronizedOutput()){this.syncTimer===null&&(this.syncTimer=window.setTimeout(()=>{this.syncTimer=null,this.core.endSynchronizedOutput(),this.requestRender()},fF));return}this.syncTimer!==null&&window.clearTimeout(this.syncTimer),this.syncTimer=null;let e=this.core.snapshot();this.snapshot=e;let t=this.focused&&e.cursorBlinking&&e.cursorVisible;t||(this.cursorOn=!0);let n=this.viewportTop(),r=this.images.visible(n,this.rows,this.metrics.height),i=this.core.cellSize(),a=this.core.kitty.images(e.rowData,i);QP({context:this.context,snapshot:e,metrics:this.metrics,appearance:this.appearance,forceFull:this.forceFull||r.length>0||a.length>0,cursorOn:this.cursorOn,previousCursorY:this.renderedCursorY,focused:this.focused,hoveredLink:this.pointer.hoveredLink?.range??null,highlights:this.search.highlights(e,n),pixelRatio:window.devicePixelRatio||1,drawLayer:e=>DN(this.context,a,e,this.metrics,i)}),DN(this.context,a,`aboveText`,this.metrics,i);for(let e of r)this.context.drawImage(e.bitmap,e.x*this.metrics.width,e.y*this.metrics.height,e.width,e.height);this.forceFull=r.length>0||a.length>0,this.renderedCursorY=this.cursorOn&&e.cursorVisible&&e.cursorY>=0?e.cursorY:null,e.cursorX>=0&&e.cursorY>=0&&(this.input.style.left=`${e.cursorX*this.metrics.width}px`,this.input.style.top=`${e.cursorY*this.metrics.height}px`),this.pointer.updateScrollbar(this.element.clientHeight),this.cursorTimer!==null&&window.clearTimeout(this.cursorTimer),this.cursorTimer=null,t&&(this.cursorTimer=window.setTimeout(()=>{this.cursorTimer=null,this.cursorOn=!this.cursorOn,this.requestRender()},dF))}copySelection(){let e=this.core.selectionText();e.length!==0&&(window.isSecureContext?navigator.clipboard.writeText(e):cF.warn(`copy from the terminal needs https or localhost`))}optionIsMeta(e){if(!lF||!e.altKey||e.metaKey)return!1;let t=this.options.optionAsMeta;if(t===`off`)return!1;if(t===`both`)return!0;if(t===`left`)return this.heldOptionKeys.has(`AltLeft`);if(t===`right`)return this.heldOptionKeys.has(`AltRight`);throw Error(`unknown option as meta mode ${t}`)}onKeyDown=e=>{if((e.code===`AltLeft`||e.code===`AltRight`)&&this.heldOptionKeys.add(e.code),!this.handlers.beforeKey(e)){this.suppressedKeys.add(e.code);return}let t=this.optionIsMeta(e),n=t&&this.core.encoder.metaText(e)!==null;if(e.isComposing||this.composing||!n&&(e.key===`Process`||e.keyCode===229)||lF&&this.options.optionAsMeta!==`off`&&!t&&e.altKey&&!e.ctrlKey&&!e.metaKey&&([...e.key].length===1||e.key===`Dead`)||!n&&e.getModifierState(`AltGraph`)&&[...e.key].length===1){this.suppressedKeys.add(e.code);return}let r=e.key.toLowerCase(),i=uF&&this.options.windowsCopyPaste&&e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey;if(i&&r===`c`&&this.core.selectionText().length>0){this.copySelection(),this.core.clearSelection(),this.redraw(),e.preventDefault(),this.suppressedKeys.add(e.code);return}if(lF?e.metaKey&&r===`c`:e.ctrlKey&&e.shiftKey&&r===`c`||e.ctrlKey&&!e.shiftKey&&r===`insert`){this.copySelection(),e.preventDefault(),this.suppressedKeys.add(e.code);return}if((lF?e.metaKey&&r===`v`:e.ctrlKey&&e.shiftKey&&r===`v`||e.shiftKey&&!e.ctrlKey&&r===`insert`||i&&r===`v`)||lF&&e.metaKey&&r===`q`){this.suppressedKeys.add(e.code);return}let a=this.core.encoder.encodeKey(e,`press`,n);a.length!==0&&(this.suppressedKeys.delete(e.code),e.preventDefault(),e.stopPropagation(),this.core.selectionText().length>0&&!e.shiftKey&&(this.core.clearSelection(),this.forceFull=!0),this.sendInput(a))};onKeyUp=e=>{if(this.heldOptionKeys.delete(e.code),this.suppressedKeys.delete(e.code)||e.isComposing||this.composing)return;let t=this.core.encoder.encodeKey(e,`release`,this.optionIsMeta(e));t.length!==0&&(e.preventDefault(),this.handlers.onData(t))};onInput=e=>{let t=e;if(this.composing||t.isComposing)return;let n=this.input.value||t.data||``;this.input.value=``,n.length>0&&this.sendInput(n)};onCompositionStart=()=>{this.composing=!0};onCompositionEnd=e=>{this.composing=!1;let t=this.input.value||e.data;this.input.value=``,t.length>0&&this.sendInput(t)};onPaste=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`)??``;t.length>0&&this.paste(t)};onCopy=e=>{let t=this.core.selectionText();t.length!==0&&e.clipboardData&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,t))};onWindowFocus=()=>{lF&&this.options.optionAsMeta!==`off`&&this.core.encoder.refreshKeyboardLayout()};onContextRestored=()=>{let e=window.devicePixelRatio||1;this.context.setTransform(e,0,0,e,0,0),this.redraw()};onVisibilityChange=()=>{document.visibilityState===`visible`&&this.redraw()};onFocus=()=>{this.focused=!0,this.cursorOn=!0,this.requestRender(),!this.disposed&&this.core.isFocusReporting()&&this.handlers.onReply(`\x1B[I`)};onBlur=()=>{this.focused=!1,this.heldOptionKeys.clear(),this.cursorOn=!0,this.requestRender(),!this.disposed&&this.core.isFocusReporting()&&this.handlers.onReply(`\x1B[O`)};installEvents(){this.input.addEventListener(`keydown`,this.onKeyDown),this.input.addEventListener(`keyup`,this.onKeyUp),this.input.addEventListener(`input`,this.onInput),this.input.addEventListener(`compositionstart`,this.onCompositionStart),this.input.addEventListener(`compositionend`,this.onCompositionEnd),this.input.addEventListener(`paste`,this.onPaste),this.input.addEventListener(`copy`,this.onCopy),this.input.addEventListener(`focus`,this.onFocus),this.input.addEventListener(`blur`,this.onBlur),this.canvas.addEventListener(`contextrestored`,this.onContextRestored),window.addEventListener(`focus`,this.onWindowFocus),document.addEventListener(`visibilitychange`,this.onVisibilityChange)}},bF=Fe.withTag(`terminal`),xF=new Map,SF=new Map,CF=null,wF=0;function TF(e){return iI().open&&sI()?.tabId===e&&!document.hidden&&document.hasFocus()}function EF(e){if(TF(e))return!1;let t=iI();return t.alerts.includes(e)||aI({alerts:[...t.alerts,e]}),!0}function DF(e){if(!EF(e)||SF.has(e))return;let t=xF.get(e);t!==void 0&&performance.now()-t<5e3||SF.set(e,window.setTimeout(()=>{SF.delete(e),TF(e)||(xF.set(e,performance.now()),kF(e,``,`Bell`))},500))}function OF(e,t,n){EF(e)&&(window.clearTimeout(SF.get(e)),SF.delete(e),xF.set(e,performance.now()),kF(e,t,n))}function kF(e,t,n){let r=uI(e);r&&Ia(t||dI(r),n,{machine:nI(),project:r.projectId??`global`,tabId:e}).catch(e=>bF.error(`could not show a notification`,e))}function AF(){let e=performance.now();if(e-wF<150)return;wF=e,CF??=new AudioContext,CF.state===`suspended`&&CF.resume();let t=CF.createOscillator(),n=CF.createGain(),r=CF.currentTime;t.frequency.value=880,n.gain.setValueAtTime(.1,r),n.gain.exponentialRampToValueAtTime(.001,r+.15),t.connect(n).connect(CF.destination),t.start(r),t.stop(r+.15)}function jF(e){return{alerts:iI().alerts.filter(t=>e(t)&&!TF(t))}}function MF(e){window.clearTimeout(SF.get(e)),SF.delete(e),xF.delete(e)}function NF(e){return e.key===`Enter`&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey}function PF(e){let t=new yF(tI(),{onData:t=>{iI().status===`active`&&yI(e,FF(t))},onReply:t=>{t===`\x1B[I`||t===`\x1B[O`?yI(e,t):bI(e,t)},onResize:(t,n)=>_I({type:`resize`,id:e,cols:t,rows:n}),onTitle:t=>aI({titles:{...iI().titles,[e]:t}}),onProgress:t=>aI({progress:{...iI().progress,[e]:t}}),onBell:()=>{let n=oI().behavior;n.bellSound&&AF(),n.bellFlash&&t.element.isConnected&&!document.hidden&&t.element.animate([{opacity:.4},{opacity:1}],{duration:200,easing:`ease-out`}),DF(e)},onNotify:(t,n)=>OF(e,t,n),onClipboard:$O,onClipboardRead:n=>{TF(e)&&ek(e=>t.replyClipboard(e,n))},onLink:e=>{e.startsWith(`file:`)?Ot(e):window.open(e,`_blank`,`noopener`)},beforeKey:n=>{if(n.type!==`keydown`)return!0;let r=oI(),i=Ge(R(),nI()).system;if(i===null)throw Error(`the terminal machine is not connected`);let a=i.platform;if(iI().status===`active`&&r.behavior.modernizeShiftEnter&&NF(n)&&!t.isKittyKeyboard())return n.preventDefault(),t.beforeInput(`\x1B\r`),yI(e,`\x1B\r`),!1;if(iI().status===`active`&&r.behavior.pasteBrowserImages&&window.isSecureContext&&nk(n,a)&&!(Lt&&r.behavior.windowsCopyPaste&&n.ctrlKey)){n.preventDefault();let r=tk[a].data;return t.beforeInput(r),rk(nI(),t).then(t=>{t||yI(e,r)}).catch(t=>{ak(t),yI(e,r)}),!1}return!OI(n)||(n.preventDefault(),aI({finding:e}),document.querySelector(`[data-find]`)?.select(),!1)}});return t.element.addEventListener(`paste`,e=>{if(!e.clipboardData||e.clipboardData.getData(`text/plain`)!==``)return;let n=[...e.clipboardData.files].filter(e=>e.type.startsWith(`image/`));n.length!==0&&(e.preventDefault(),e.stopPropagation(),ik(nI(),t,n).catch(ak))},!0),t}function FF(e){if(!iI().ctrl||(aI({ctrl:!1}),e.length!==1))return e;let t=e.toUpperCase().charCodeAt(0);return t>=64&&t<=95?String.fromCharCode(t-64):e}var IF=Fe.withTag(`terminal`);function LF(e,t){Ve(e,t)}function RF(e){let t=e.terminals.map(lI),n=localStorage.getItem(`lastTerminalView`);LF(e.id,t.find(e=>e===n)??t.at(0)??`global`)}async function zF(e,t){try{await L(e,`terminal`,{type:`createTab`,projectId:t})}catch(e){IF.error(`terminal request failed`,e);return}LF(e,t??`global`)}function BF(){let e=iI(),t=Xe();if(t===null||e.instance===null||t!==nI()||cI(e.layout,A()).length>0)return;let n=e.layout.tabs.at(0);if(n!==void 0){LF(t,lI(n));return}let r=R().machines.find(e=>e.id!==t&&e.status===`online`&&e.terminals.length>0);r===void 0?le(`chat`,()=>void yt.navigate({to:`/`,search:{},replace:!0})):RF(r)}var VF=Fe.withTag(`terminal`);function HF(){return{titles:{},progress:{},alerts:[],finding:null}}var UF=new TextEncoder,WF=new Map,GF=new Set,KF=new Set,qF={status:`connecting`,failure:null,loaded:!1,open:!1,instance:null,layout:{tabs:[],active:{}},ctrl:!1,...HF()},JF=null,YF=null,XF=!1,ZF=!1;async function QF(){h(),hI(),yt.history.subscribe(({action:e})=>{(e.type===`PUSH`||e.type===`REPLACE`)&&h(),hI()});try{await Promise.all([JM(),Vh(oI())]),aI({loaded:!0})}catch(e){VF.error(`could not start the terminal`,e),aI({failure:Ht(e)});return}ht({close:e=>{e===YF&&aI({status:`connecting`})},terminal:(e,t)=>{e===YF&&EI(t)},frame:(e,t)=>{e===YF&&TI(t)}}),$F(),yt.history.subscribe($F),yt.history.subscribe(BF),document.addEventListener(`visibilitychange`,()=>aI({})),window.addEventListener(`focus`,()=>{aI({}),JF!==null&&kI(JF,AI(JF))}),window.addEventListener(`blur`,()=>aI({})),`serviceWorker`in navigator&&navigator.serviceWorker.addEventListener(`message`,e=>{e.data.type===`select`&&gI(e.data.machine,e.data.project,e.data.tabId)});let e=R().prefs,t=eI();Ze(()=>{$F();let n=R().prefs,r=eI(),i=n.theme!==e.theme||n.terminal!==e.terminal||r!==t;e=n,t=r,i&&MI()}),NI()}function $F(){let e=Xe()??R().selection?.machine??null;if(e!==YF&&(YF!==null&&XF&&_I({type:`detach`}),DI([]),GF.clear(),YF=e,XF=!1,aI({status:`connecting`,instance:null,layout:{tabs:[],active:{}},...HF()})),YF===null)return;let t=Ge(R(),YF).status===`online`;t&&!XF&&(XF=!0,_I({type:`attach`})),t||(XF=!1)}function eI(){return YF===null?null:Ge(R(),YF).config?.terminal.behavior.terminalIdentity??null}function tI(){if(YF===null)throw Error(`the terminal has no machine`);let e=Ge(R(),YF);if(e.config===null||e.system===null)throw Error(`${e.name} is not connected`);return Hh(oI(),e.config.terminal.behavior.terminalIdentity)}function nI(){if(YF===null)throw Error(`the terminal has no machine`);return YF}function rI(e){return KF.add(e),()=>{KF.delete(e)}}function iI(){return qF}function aI(e){qF={...qF,...e},qF={...qF,...jF(e=>WF.has(e))};for(let e of KF)e()}function oI(){return R().prefs.terminal}function sI(){let e=Xe()===null?R().selection?.projectId:A();return e===void 0?null:{view:e,tabs:cI(qF.layout,e),tabId:qF.layout.active[e]??null}}function cI(e,t){return e.tabs.filter(e=>lI(e)===t)}function lI(e){return e.projectId??`global`}function uI(e){return qF.layout.tabs.find(t=>t.id===e)}function dI(e){return(e.customName??qF.titles[e.id])||`Terminal`}function fI(e){e?(pI(),f({bottom:`terminal`})):le(`overlay`,()=>f({bottom:void 0}))}function pI(){qF.open||(ZF=!0)}function mI(e){let t=ZF;ZF=!1,cI(qF.layout,e).length>0||(t?_I({type:`createTab`,projectId:e}):fI(!1))}function hI(){let e=jt().bottom===`terminal`||Xe()!==null;e!==qF.open&&aI({open:e})}function gI(e,t,n){if(t===`global`)LF(e,Ue);else{let n=R().selection;(n?.machine!==e||n.projectId!==t)&&Ie({machine:e,projectId:t,sessionId:null}),fI(!0)}vI(e,{type:`select`,view:t,tabId:n})}function _I(e){YF!==null&&vI(YF,e)}function vI(e,t){ot(e)&&L(e,`terminal`,t).catch(e=>VF.error(`terminal request failed`,e))}function yI(e,t){YF!==null&&et(YF,0,e,typeof t==`string`?UF.encode(t):t)}function bI(e,t){YF!==null&&et(YF,1,e,UF.encode(t))}function xI(e,t,n,r){AI(e).find(t,n,r)}function SI(e,t){return AI(e).onFindResults(t)}function CI(e){let t=AI(e);t.clearFind(),aI({finding:null}),t.focus()}function wI(){aI({ctrl:!qF.ctrl})}function TI(e){let t=WF.get(e.id);if(!t)return;let n=e.kind===3,r=n&&GF.delete(e.id);r&&t.reset(),t.write(e.data,n),r&&GF.size===0&&aI({status:`active`})}function EI(e){let t=e.type===`active`&&e.instance!==qF.instance;if(t&&DI([]),DI(e.layout.tabs),e.type===`active`){GF.clear(),WF.forEach((e,t)=>{GF.add(t),e.element.isConnected&&kI(t,e)}),aI({...t&&{instance:e.instance,...HF()},status:GF.size===0?`active`:`connecting`,layout:e.layout}),BF();return}for(let e of GF)WF.has(e)||GF.delete(e);let n=R().selection?.projectId,r=n!==void 0&&cI(qF.layout,n).length>0&&cI(e.layout,n).length===0;aI({status:GF.size===0?`active`:`connecting`,layout:e.layout}),r&&qF.open&&fI(!1),BF()}function DI(e){let t=new Set(e.map(e=>e.id));WF.forEach((e,n)=>{t.has(n)||(e.dispose(),WF.delete(n),MF(n))});for(let e of t)WF.has(e)||WF.set(e,PF(e))}function OI(e){return e.key.toLowerCase()===`f`?zt?e.metaKey&&!e.ctrlKey&&!e.altKey:e.ctrlKey&&e.shiftKey&&!e.altKey&&!e.metaKey:!1}function kI(e,t){_I({type:`resize`,id:e,cols:t.cols,rows:t.rows})}function AI(e){let t=WF.get(e);if(!t)throw Error(`terminal ${e} does not exist`);return t}function jI(e,t){let n=AI(e);t.append(n.element),n.fit();for(let e of WF.values())e.presize(n.cols,n.rows);return JF=e,kI(e,n),n.focus(),()=>{let t=n.element.contains(document.activeElement);n.element.remove(),t&&document.querySelector(`[data-composer]`)?.focus(),JF===e&&(JF=null)}}async function MI(){if(await Vh(oI()),WF.size>0){let e=tI();for(let t of WF.values())t.setOptions(e)}aI({})}function NI(){let e=jt(),t=Xe(),n=t??e.machine,r=t===null?e.project:Ue,i=e.terminal;if(n===void 0||r===void 0||i===void 0)return;f({terminal:void 0});let a=rI(()=>{qF.status===`active`&&YF===n&&(a(),gI(n,r,Number(i)))})}var PI=Fe.withTag(`terminal`),FI=null,II=null,LI=new Set,RI=new Set;function zI(e){return RI.add(e),()=>{RI.delete(e)}}function BI(){return FI}function VI(){FI!==null&&WI({open:!1,closing:FI.closing})}function HI(){return II}function UI(){II!==null&&GI({open:!1,closing:II.closing})}function WI(e){FI=e;for(let e of RI)e()}function GI(e){II=e;for(let e of RI)e()}function KI(){return document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)!==null}async function qI(e,t){try{let n=await Promise.race([L(e,`terminal.busy`,{id:t}),new Promise((e,t)=>window.setTimeout(()=>t(Error(`timed out`)),5e3))]);return`error`in n?(PI.error(`could not check whether tab ${t} is running a program`,n.error),{checked:!1}):{checked:!0,program:n.program}}catch(e){return PI.error(`could not check whether a program is running`,e),{checked:!1}}}async function JI(e){if(!oI().behavior.confirmCloseBusyTab){_I({type:`closeTab`,id:e});return}if(!uI(e)||LI.has(e))return;LI.add(e);let t=await qI(nI(),e);if(LI.delete(e),t.checked&&t.program===null){_I({type:`closeTab`,id:e});return}let n=uI(e);n&&!KI()&&WI({open:!0,closing:{id:e,name:dI(n),program:t.checked?t.program:null}})}function YI(e){for(let t of e)vI(t.machine,{type:`closeTab`,id:t.id})}async function XI(e){if(!oI().behavior.confirmCloseBusyTab){YI(e);return}let t=await Promise.all(e.map(e=>qI(e.machine,e.id)));if(t.every(e=>e.checked&&e.program===null)){YI(e);return}if(KI())return;let n=t.flatMap(e=>e.checked&&e.program!==null?[e.program]:[]);GI({open:!0,closing:{tabs:e,programs:[...new Set(n)]}})}var ZI=zt?`meta+t`:`ctrl+shift+t`,QI=zt?`meta+w`:`ctrl+shift+w`,$I=`ctrl+tab`,eL=`ctrl+shift+tab`;function tL(){let e=sI()?.tabId??null;iI().open&&e!==null&&AI(e).focus()}function nL(){return vr([ZI,QI,$I,eL],(e,t)=>{e.preventDefault(),e.stopPropagation();let n=sI();if(n===null)return;if(t.hotkey===ZI){_I({type:`createTab`,projectId:n.view===`global`?null:n.view});return}if(n.tabId===null)return;if(t.hotkey===QI){JI(n.tabId);return}let r;if(t.hotkey===$I)r=1;else if(t.hotkey===eL)r=-1;else throw Error(`unknown terminal shortcut ${t.hotkey}`);let i=n.tabs,a=i[(i.findIndex(e=>e.id===n.tabId)+r+i.length)%i.length];a&&_I({type:`select`,view:n.view,tabId:a.id})},{enabled:()=>oI().behavior.captureShortcuts,enableOnFormTags:!0,eventListenerOptions:{capture:!0}})}function rL(e){let[t,n]=(0,W.useState)(e.name);return(0,G.jsx)(oi,{open:!0,onOpenChange:t=>{t||e.onDone()},children:(0,G.jsx)($r,{onCloseAutoFocus:sL,children:(0,G.jsxs)(`form`,{className:`grid gap-4`,onSubmit:n=>{n.preventDefault(),_I({type:`renameTab`,id:e.id,name:t.trim()}),e.onDone()},children:[(0,G.jsx)(ei,{children:(0,G.jsx)(ri,{children:`Rename tab`})}),(0,G.jsx)(Tp,{"aria-label":`Name`,placeholder:`Use terminal title`,value:t,onChange:e=>n(e.target.value)}),(0,G.jsxs)(si,{children:[(0,G.jsx)(U,{type:`button`,variant:`outline`,onClick:e.onDone,children:`Cancel`}),(0,G.jsx)(U,{type:`submit`,children:`Rename`})]})]})})})}function iL(){let e=(0,W.useSyncExternalStore)(zI,BI);return e===null?null:(0,G.jsx)(mr,{open:e.open,onOpenChange:e=>{e||VI()},children:(0,G.jsx)(Zn,{onOpenAutoFocus:e=>{if(e.preventDefault(),!(e.currentTarget instanceof HTMLElement))throw Error(`close dialog is not an element`);e.currentTarget.querySelector(`[data-slot=alert-dialog-action]`)?.focus()},onCloseAutoFocus:sL,children:(0,G.jsx)(aL,{closing:e.closing})})})}function aL(e){let t=e.closing;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsxs)(Hn,{children:[`Close “`,t.name,`”?`]}),(0,G.jsx)(Rn,{children:t.program===null?`OffSite couldn’t check whether a program is still running.`:`${t.program} is still running.`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>_I({type:`closeTab`,id:t.id}),children:`Close`})]})]})}function oL(){let e=(0,W.useSyncExternalStore)(zI,HI);if(e===null)return null;let t=e.closing;return(0,G.jsx)(mr,{open:e.open,onOpenChange:e=>{e||UI()},children:(0,G.jsxs)(Zn,{onCloseAutoFocus:sL,children:[(0,G.jsxs)(Ar,{children:[(0,G.jsxs)(Hn,{children:[`Close `,t.tabs.length,` `,t.tabs.length===1?`terminal`:`terminals`,`?`]}),(0,G.jsx)(Rn,{children:t.programs.length===0?`OffSite couldn’t check whether programs are still running.`:`Still running: ${t.programs.join(`, `)}.`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>YI(t.tabs),children:`Close all`})]})]})})}function sL(e){e.preventDefault();let t=document.querySelector(`[role="dialog"], [role="alertdialog"]`);t===null?tL():t.focus()}function cL(e){let t=(0,W.useRef)(null),[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)({resultIndex:-1,resultCount:0});(0,W.useEffect)(()=>SI(e.id,a),[e.id]),(0,W.useEffect)(()=>t.current?.focus(),[]);function o(t,n,i){r(t),xI(e.id,t,n,i)}return(0,G.jsxs)(`div`,{className:`bg-card absolute top-2 right-4 z-10 flex items-center gap-1 rounded-lg border p-1 shadow-lg`,children:[(0,G.jsx)(Tp,{ref:t,"data-find":!0,className:`h-7 w-52`,placeholder:`Find`,value:n,onChange:e=>o(e.target.value,!1,!0),onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),CI(e.id)):t.key===`Enter`?(t.preventDefault(),o(n,t.shiftKey,!1)):OI(t.nativeEvent)&&(t.preventDefault(),t.currentTarget.select())}}),(0,G.jsx)(`span`,{className:`text-muted-foreground w-16 text-center text-xs tabular-nums`,children:n===``?``:i.resultCount===0?`No results`:`${i.resultIndex+1} of ${i.resultCount}`}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous match`,onClick:()=>o(n,!0,!1),children:(0,G.jsx)(H,{icon:Bo})}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next match`,onClick:()=>o(n,!1,!1),children:(0,G.jsx)(H,{icon:Dr})}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close find`,onClick:()=>CI(e.id),children:(0,G.jsx)(H,{icon:Go})})]})}var lL=[{label:`Esc`,sequence:`\x1B`},{label:`Tab`,sequence:` `},{label:`↑`,sequence:`\x1B[A`},{label:`↓`,sequence:`\x1B[B`},{label:`←`,sequence:`\x1B[D`},{label:`→`,sequence:`\x1B[C`}];function uL(e){let t=(0,W.useSyncExternalStore)(rI,iI),n=t.status===`active`,r=cI(t.layout,e.view),i=t.layout.active[e.view]??null,a=nL(),[o,s]=(0,W.useState)(!1);(0,W.useEffect)(()=>{n&&!e.page&&mI(e.view)},[e.view,n,e.page]);function c(){_I({type:`createTab`,projectId:e.view===`global`?null:e.view})}if(!t.loaded)return(0,G.jsx)(`div`,{className:`text-muted-foreground grid h-full place-items-center p-4 text-xs whitespace-pre-wrap`,children:t.failure===null?`Starting the terminal…`:`The terminal could not start: ${t.failure}`});let l=r.find(e=>e.id===i);return(0,G.jsxs)(`div`,{ref:a,className:`flex h-full flex-col text-sm`,children:[e.mobile?(0,G.jsxs)(`header`,{className:`bg-background flex h-(--workspace-topbar-height) flex-none items-center border-b select-none`,children:[e.leading,(0,G.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center self-stretch`,children:l===void 0?(0,G.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground flex min-w-0 flex-1 items-center gap-1.5 self-stretch px-2 text-[13px] transition-colors`,onClick:c,children:[(0,G.jsx)(H,{icon:Oo,className:`size-4`}),`New tab`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(mn,{open:o,onOpenChange:s,children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:`text-foreground relative flex min-w-0 flex-1 items-center gap-3.5 self-stretch pr-3 pl-2 text-[13px]`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground relative flex-none`,children:[(0,G.jsx)(H,{icon:Zs,className:`size-4`}),r.length>1&&(0,G.jsx)(`span`,{className:`text-foreground/75 ring-background absolute -top-1.5 -right-2 grid h-3.5 min-w-3.5 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_14%,var(--background))] px-0.5 text-[9px] leading-none font-medium tabular-nums ring-2`,children:r.length})]}),(0,G.jsx)(`span`,{className:`truncate`,children:dI(l)}),r.some(e=>e.id!==i&&t.alerts.includes(e.id))&&(0,G.jsx)(`span`,{className:`bg-primary size-1.5 flex-none rounded-full`}),(0,G.jsx)(gL,{progress:t.progress[l.id]})]})}),(0,G.jsx)(Dn,{align:`start`,className:`w-auto min-w-48`,children:(0,G.jsx)(pL,{view:e.view,onCreate:c,onClose:()=>s(!1)})})]}),(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground grid w-11 flex-none place-items-center self-stretch transition-colors`,"aria-label":`Close tab`,title:`Close tab`,onClick:()=>void JI(l.id),children:(0,G.jsx)(H,{icon:Go,className:`size-4`})})]})})]}):(0,G.jsxs)(`header`,{className:B(`flex h-9 flex-none select-none`,e.tabSize===`lg`&&`h-(--workspace-topbar-height)`,r.length===1?`bg-background`:`bg-sidebar`),children:[e.leading&&(0,G.jsx)(`div`,{className:`flex flex-none items-center border-b px-1.5`,children:e.leading}),(0,G.jsx)(`div`,{className:`flex min-w-0 flex-1 [scrollbar-width:none] overflow-x-auto`,children:r.map(n=>(0,G.jsx)(fL,{tab:n,children:(0,G.jsxs)(`div`,{className:B(`group/tab text-muted-foreground hover:text-foreground relative flex min-w-28 flex-1 items-center justify-center border-r border-b px-7 text-xs transition-colors last:border-r-0`,e.tabSize===`lg`&&`text-[13px]`,n.id===i&&`bg-background text-foreground border-b-transparent`),onMouseDown:e=>e.preventDefault(),onClick:()=>_I({type:`select`,view:e.view,tabId:n.id}),children:[(0,G.jsx)(`span`,{className:`truncate`,children:dI(n)}),(0,G.jsx)(hL,{id:n.id,className:`ml-1.5 size-1.5 flex-none rounded-full`}),(0,G.jsx)(gL,{progress:t.progress[n.id]}),(0,G.jsx)(`button`,{className:B(`text-muted-foreground hover:bg-accent hover:text-foreground absolute left-1.5 grid size-4.5 place-items-center rounded opacity-0 transition-opacity group-hover/tab:opacity-100`,n.id===i&&`pointer-coarse:opacity-100`),"aria-label":`Close tab`,onClick:e=>{e.stopPropagation(),JI(n.id)},children:(0,G.jsx)(H,{icon:Go,className:`size-3`})})]})},n.id))}),(0,G.jsx)(`button`,{className:B(`text-muted-foreground hover:text-foreground grid w-8 flex-none place-items-center transition-colors`,r.length>1&&`border-b border-l`),"aria-label":`New tab`,title:`New tab`,onClick:c,children:(0,G.jsx)(H,{icon:Oo,className:`size-4`})})]}),(0,G.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[i!==null&&(0,G.jsx)(dL,{id:i},`${t.instance}-${i}`),i!==null&&t.finding===i&&(0,G.jsx)(cL,{id:i},i),n&&i===null&&!e.page&&(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground grid size-full cursor-pointer place-items-center text-xs transition-colors`,onClick:c,children:`New terminal`}),!n&&(0,G.jsx)(`div`,{className:`bg-background/80 animate-in fade-in absolute inset-0 z-20 grid place-items-center p-6 text-center backdrop-blur-md duration-200`,children:(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,G.jsx)(`span`,{className:`border-foreground/15 border-t-foreground/70 size-6 animate-spin rounded-full border-[3px]`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Connecting. Your terminals keep running while you wait.`})]})})]}),i!==null&&(0,G.jsxs)(`div`,{className:`bg-card hidden flex-none gap-1.5 overflow-x-auto border-t p-1.5 pointer-coarse:flex`,children:[lL.map(e=>(0,G.jsx)(U,{variant:`secondary`,className:`min-w-11`,onPointerDown:e=>e.preventDefault(),onClick:()=>yI(i,e.sequence),children:e.label},e.label)),(0,G.jsx)(U,{variant:t.ctrl?`default`:`secondary`,className:`min-w-11`,onPointerDown:e=>e.preventDefault(),onClick:wI,children:`Ctrl`})]}),(0,G.jsx)(iL,{})]})}function dL(e){let t=(0,W.useRef)(null);return(0,W.useEffect)(()=>{if(!t.current)throw Error(`terminal container missing`);return jI(e.id,t.current)},[e.id]),(0,G.jsx)(`div`,{className:`bg-background absolute inset-0 pt-(--pad-top) pr-(--pad-right) pb-(--pad-bottom) pl-(--pad-left)`,ref:t})}function fL(e){let[t,n]=(0,W.useState)(!1),r=e.tab;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,children:e.children}),(0,G.jsx)(tr,{children:(0,G.jsx)(mL,{tab:r,onRename:()=>n(!0)})})]}),t&&(0,G.jsx)(rL,{id:r.id,name:r.customName??``,onDone:()=>n(!1)})]})}function pL(e){let t=(0,W.useSyncExternalStore)(rI,iI),n=t.layout.active[e.view]??null;return(0,G.jsxs)(G.Fragment,{children:[cI(t.layout,e.view).map(t=>(0,G.jsxs)(Mr,{className:B(t.id===n&&`bg-accent`),onSelect:()=>_I({type:`select`,view:e.view,tabId:t.id}),children:[(0,G.jsx)(`span`,{className:`max-w-60 truncate`,children:dI(t)}),(0,G.jsxs)(`span`,{className:`-mr-1 ml-auto flex flex-none items-center gap-2`,children:[(0,G.jsx)(hL,{id:t.id,className:`size-1.5 rounded-full`}),(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground grid size-6 place-items-center rounded`,"aria-label":`Close tab`,title:`Close tab`,onClick:n=>{n.stopPropagation(),e.onClose(),JI(t.id)},children:(0,G.jsx)(H,{icon:Go,className:`size-3.5`})})]})]},t.id)),(0,G.jsx)(Pn,{}),(0,G.jsxs)(Mr,{onSelect:e.onCreate,children:[(0,G.jsx)(H,{icon:Oo}),`New tab`]})]})}function mL(e){let t=k(e=>e.projects).filter(e=>e.machine===nI()&&!e.scratch),n=e.tab;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Bn,{onSelect:e.onRename,children:[(0,G.jsx)(H,{icon:Ps}),`Rename`]}),(0,G.jsxs)(or,{children:[(0,G.jsxs)(Kn,{children:[(0,G.jsx)(H,{icon:lr}),`Move to`]}),(0,G.jsx)(Cr,{className:`max-h-80 overflow-y-auto`,children:(0,G.jsxs)(fr,{value:n.projectId??``,onValueChange:e=>_I({type:`assignTab`,id:n.id,projectId:e===``?null:e}),children:[(0,G.jsx)(yr,{value:``,children:`No project`}),t.length>0&&(0,G.jsx)(Wn,{}),t.map(e=>(0,G.jsx)(yr,{value:e.id,children:(0,G.jsx)(`span`,{className:`max-w-60 truncate`,children:e.name})},e.id))]})})]}),(0,G.jsxs)(Bn,{variant:`destructive`,onSelect:()=>void JI(n.id),children:[(0,G.jsx)(H,{icon:is}),`Close tab`]})]})}function hL(e){return iI().alerts.includes(e.id)?(0,G.jsx)(`span`,{className:B(`bg-primary`,e.className)}):null}function gL(e){let t=e.progress;return!t||t.state===0?null:t.state===3?(0,G.jsx)(`span`,{className:`bg-primary absolute inset-x-0 bottom-0 h-0.5 animate-pulse`}):(0,G.jsx)(`span`,{className:B(`absolute bottom-0 left-0 h-0.5 transition-[width]`,t.state===1&&`bg-primary`,t.state===2&&`bg-destructive`,t.state===4&&`bg-yellow-500`),style:{width:`${t.state!==1&&t.value===0?100:t.value}%`}})}function _L(e){(0,W.useSyncExternalStore)(rI,iI);let[t,n]=(0,W.useState)(!1),r=g(),i=yL().find(t=>t.machine.id===e.machine&&t.view===r);return(0,W.useEffect)(()=>{localStorage.setItem(`lastTerminal`,e.machine),localStorage.setItem(`lastTerminalView`,r)},[e.machine,r]),e.mobile?(0,G.jsx)(`main`,{className:`bg-background flex min-w-0 flex-1 flex-col overflow-hidden pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(uL,{view:r,page:!0,mobile:!0,leading:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center self-stretch`,children:[e.leading,(0,G.jsxs)(ln,{open:t,onOpenChange:n,children:[(0,G.jsx)(Sn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:`text-muted-foreground hover:text-foreground flex min-w-0 flex-1 items-center gap-1.5 self-stretch px-2 text-[13px]`,children:[i!==void 0&&(0,G.jsx)(xL,{group:i}),(0,G.jsx)(`span`,{className:`truncate`,children:i?.name}),(0,G.jsx)(H,{icon:Dr,className:`size-3.5 flex-none`})]})}),(0,G.jsx)(sn,{align:`start`,className:`w-56 p-1`,onClick:()=>n(!1),children:(0,G.jsx)(vL,{})})]})]}),(0,G.jsx)(`span`,{className:`bg-border h-4 w-px flex-none`})]})})})}):(0,G.jsx)(`main`,{className:`bg-background flex min-w-0 flex-1 flex-col overflow-hidden`,children:(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(uL,{view:r,page:!0,tabSize:`lg`,leading:e.leading})})})}function vL(){(0,W.useSyncExternalStore)(rI,iI);let e=ne(),t=g(),n=yL().filter(e=>e.machine.status===`online`);return n.length===0?null:(0,G.jsx)(`div`,{className:`flex max-h-80 flex-col gap-px overflow-y-auto`,children:n.map(n=>(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,children:(0,G.jsxs)(`div`,{className:B(`group/row text-popover-foreground hover:bg-sidebar-row-hover data-[state=open]:bg-sidebar-row-hover relative shrink-0 rounded-[var(--control-radius)]`,n.machine.id===e&&n.view===t&&`bg-sidebar-row-hover text-sidebar-foreground`),children:[(0,G.jsxs)(`button`,{className:B(`flex h-7 w-full cursor-pointer items-center gap-2 rounded-[var(--control-radius)] pr-2.5 pl-2 text-left text-[13px]`,n.view!==`global`&&`pl-6`),onClick:()=>n.count===0?void zF(n.machine.id,n.view===`global`?null:n.view):LF(n.machine.id,n.view),children:[(0,G.jsx)(xL,{group:n}),(0,G.jsx)(`span`,{className:`truncate`,children:n.name}),(0,G.jsx)(SL,{count:n.count,alert:bL(n,e),className:`group-hover/row:invisible pointer-coarse:mr-7`})]}),(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground absolute top-0.5 right-1.5 grid size-6 cursor-pointer place-items-center rounded-md opacity-0 transition-opacity group-hover/row:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100`,"aria-label":`New terminal`,title:`New terminal`,onClick:()=>void zF(n.machine.id,n.view===`global`?null:n.view),children:(0,G.jsx)(H,{icon:Oo,className:`size-4`})})]})}),(0,G.jsxs)(tr,{onCloseAutoFocus:e=>e.preventDefault(),children:[(0,G.jsxs)(Bn,{onSelect:()=>void zF(n.machine.id,n.view===`global`?null:n.view),children:[(0,G.jsx)(H,{icon:Oo}),`New terminal`]}),n.view===`global`&&(0,G.jsxs)(Bn,{variant:`destructive`,onSelect:()=>void XI(n.machine.terminals.map(e=>({machine:n.machine.id,id:e.id}))),children:[(0,G.jsx)(H,{icon:is}),`Close All`]}),(0,G.jsxs)(Bn,{variant:`destructive`,disabled:n.count===0,onSelect:()=>void XI(n.machine.terminals.filter(e=>lI(e)===n.view).map(e=>({machine:n.machine.id,id:e.id}))),children:[(0,G.jsx)(H,{icon:is}),n.view===`global`?`Close All Except Projects`:`Close All`]})]})]},`${n.machine.id}:${n.view}`))})}function yL(){let e=k(e=>e.machines),t=k(e=>e.projects);return e.flatMap(e=>{let n=e.status===`online`?e.terminals:[],r=[...new Set([...t.filter(t=>e.status===`online`&&t.machine===e.id&&!t.hidden&&!t.scratch).map(e=>e.id),...n.flatMap(e=>e.projectId===null?[]:[e.projectId])])];return[{machine:e,view:Ue,name:e.name,count:n.filter(e=>e.projectId===null).length},...r.map(r=>({machine:e,view:r,name:t.find(t=>t.machine===e.id&&t.id===r)?.name??`Removed project`,count:n.filter(e=>e.projectId===r).length}))]})}function bL(e,t){let n=iI();return e.machine.id===t&&n.layout.tabs.some(t=>(t.projectId??`global`)===e.view&&n.alerts.includes(t.id))}function xL(e){return e.group.view===`global`?(0,G.jsx)(Of,{icon:e.group.machine.icon,className:`size-4 shrink-0`}):(0,G.jsx)(mc,{machine:e.group.machine.id,projectId:e.group.view,className:`size-4 shrink-0`})}function SL(e){return e.count===0?null:(0,G.jsx)(`span`,{className:B(`ml-auto grid h-4 min-w-4 shrink-0 place-items-center rounded-full px-1 text-[10px] leading-none font-medium tabular-nums`,e.alert?`bg-primary text-primary-foreground`:`text-foreground/75 bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))]`,e.className),children:e.count})}function CL(e){let t=k(e=>e.machines),[n,r]=(0,W.useState)(!1),i=t.filter(e=>e.status===`online`),a=i.reduce((e,t)=>e+t.terminals.length,0);return(0,G.jsxs)(`div`,{className:`mr-1.5 flex items-center gap-0.75`,children:[(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(`button`,{className:B(e.buttonClassName,`size-7 [&>svg]:size-4.5`),title:`Menu`,"aria-label":`Menu`,children:(0,G.jsx)(H,{icon:Ts})})}),(0,G.jsxs)(Dn,{align:`start`,className:`w-auto min-w-40`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,G.jsxs)(Mr,{onSelect:()=>N(!0),children:[(0,G.jsx)(H,{icon:rs}),`Usage`]}),(0,G.jsxs)(Mr,{onSelect:()=>p(!0),children:[(0,G.jsx)(H,{icon:Us}),`Settings`]})]})]}),(0,G.jsxs)(ln,{open:n,onOpenChange:r,children:[(0,G.jsx)(Sn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:B(e.buttonClassName,`relative size-7 [&>svg]:size-4.5`),title:`Terminal`,"aria-label":`Terminal`,disabled:i.length===0,children:[(0,G.jsx)(H,{icon:Zs}),a>0&&(0,G.jsx)(`span`,{className:`text-foreground/75 border-sidebar pointer-events-none absolute -top-0.5 -right-0.5 grid h-3.5 min-w-3.5 place-items-center rounded-full border bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))] px-0.5 text-[9px] leading-none font-medium tabular-nums`,children:a})]})}),(0,G.jsx)(sn,{align:`start`,className:`w-56 p-1`,onCloseAutoFocus:e=>e.preventDefault(),onClick:()=>r(!1),children:(0,G.jsx)(vL,{})})]})]})}var wL=`relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none touch-pan-y [-webkit-touch-callout:none] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,TL={active:{status:`snoozed`,icon:sc},snoozed:{status:`active`,icon:$s},minimized:{status:`active`,icon:Ro},inactive:{status:`minimized`,icon:As},pinned:{status:`active`,icon:Fs}},EL=(0,W.memo)(DL);function DL(e){let t=e.session,n=cc(t.machine,t.projectId),r=k(e=>Ge(e,t.machine).icon),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(0),u=(0,W.useRef)(null),d=(0,W.useRef)(null),f=(0,W.useRef)(!1),p=e.activity?.waiting===!0,m=Object.values(e.activity?.tasks??{}).includes(`running`),h=!p&&(e.activity?.running===!0||m),g=e.activity?.running===!0||m,_=!p&&!h&&e.unseen,v=!e.selected&&!p&&!_;function y(){pt(t.machine,t.id,e.scope)}function b(){g?s(!0):y()}function x(e){let n=d.current;d.current=null,l(0),n!==null&&n.swiping&&(f.current=!0,e.clientX-n.x>e.currentTarget.offsetWidth*.4&&(t.status===`inactive`?Je(t.machine,t.id,{status:`active`}):b()),e.clientX-n.x<-e.currentTarget.offsetWidth*.4&&Je(t.machine,t.id,{status:TL[t.status].status}))}let S={onClick:()=>{f.current?f.current=!1:e.onSelect(t.machine,t.projectId,t.id)},onPointerDown:t=>{e.saved&&t.pointerType===`touch`&&(f.current=!1,d.current={x:t.clientX,y:t.clientY,swiping:!1})},onPointerMove:e=>{let t=d.current;if(t===null)return;let n=e.clientX-t.x,r=e.clientY-t.y;!t.swiping&&Math.abs(n)<10&&Math.abs(r)<10||(!t.swiping&&Math.abs(n)<=Math.abs(r)?d.current=null:(t.swiping=!0,l(n)))},onPointerUp:x,onPointerCancel:()=>{d.current=null,l(0)}},C=c!==0&&(0,G.jsx)(`div`,{className:B(`absolute inset-x-0 flex items-center rounded-md px-4 text-white`,e.slim?`inset-y-0`:`inset-y-0.5`,c>0&&t.status!==`inactive`&&`bg-success`,c>0&&t.status===`inactive`&&`bg-[#56b6c2]`,c<0&&t.status===`active`&&`bg-[#c678dd]`,c<0&&t.status===`snoozed`&&`bg-[#d19a66]`,c<0&&t.status===`minimized`&&`bg-info`,c<0&&t.status===`inactive`&&`bg-[#5c6370]`,c<0&&t.status===`pinned`&&`bg-[#e06c75]`,c<0&&`justify-end`),children:(0,G.jsx)(H,{icon:c<0?TL[t.status].icon:t.status===`inactive`?Ls:nc,className:`size-6`})}),w=(0,G.jsx)(mr,{open:o,onOpenChange:s,children:(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:`Stop running work?`}),(0,G.jsx)(Rn,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:y,children:`Stop and Mark Done`})]})]})}),T=(0,G.jsx)(tr,{className:`w-44`,onCloseAutoFocus:e=>{u.current!==null&&(e.preventDefault(),u.current.focus(),u.current.select())},children:(0,G.jsx)(zA,{session:t,context:!0,mobile:!0,onDeactivate:b,onRename:()=>a(t.title)})}),E=i===null?(0,G.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate text-sm`,v?`text-secondary-label font-normal`:`font-medium`,!v&&(e.unseen||p)&&`text-foreground`,!v&&!e.unseen&&!p&&`text-foreground/90`),children:(0,G.jsx)(VA,{session:t,awaitingTitle:!e.saved})}):(0,G.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&Je(t.machine,t.id,{title:n})},children:(0,G.jsx)(`input`,{ref:u,value:i,onChange:e=>a(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>a(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&a(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),D=B(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,v&&`text-sidebar-muted-foreground/75`,!e.selected&&!v&&`text-sidebar-foreground bg-transparent`);return e.slim?(0,G.jsxs)(`li`,{className:`relative list-none`,children:[C,(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(wL,D,`flex h-9 items-center gap-2.5 px-2.5`,c!==0&&`bg-sidebar`),style:c===0?void 0:{transform:`translateX(${c}px)`},...S,onKeyDown:n=>{n.key===`Enter`&&e.onSelect(t.machine,t.projectId,t.id)},children:[(0,G.jsx)(`span`,{className:`flex shrink-0 items-center opacity-40 grayscale`,children:(0,G.jsx)(mc,{machine:t.machine,projectId:t.projectId})}),E,(0,G.jsx)(`span`,{className:`text-secondary-label ml-auto shrink-0 text-xs tabular-nums`,children:yn(t.updatedAt)})]})}),T]}),w]}):(0,G.jsxs)(`li`,{className:`relative list-none py-0.5`,children:[C,(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsx)(`div`,{role:`button`,tabIndex:0,className:B(wL,D,h&&!e.selected&&c===0&&`opacity-70`,c!==0&&`bg-sidebar`),style:c===0?void 0:{transform:`translateX(${c}px)`},...S,onKeyDown:n=>{n.key===`Enter`&&e.onSelect(t.machine,t.projectId,t.id)},children:(0,G.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,G.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,G.jsx)(mc,{machine:t.machine,projectId:t.projectId,className:`size-5`}),E,(0,G.jsx)(BA,{activity:e.activity,backgroundRunning:m,done:_})]}),(0,G.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,G.jsx)(Of,{icon:r,className:`size-3 shrink-0`}),(0,G.jsxs)(`span`,{className:B(`min-w-0 flex-1 truncate`,v?`font-normal`:`font-medium`),children:[n,t.branch!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | ${t.branch}`})]}),t.status===`pinned`&&(0,G.jsx)(H,{icon:Is,className:`size-3 shrink-0`}),t.status===`snoozed`&&(0,G.jsx)(H,{icon:sc,className:`size-3 shrink-0`}),(0,G.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:yn(t.updatedAt)})]})]})})}),T]}),w]})}function OL(e){let t=cc(e.machine,e.projectId),n=k(t=>Ge(t,e.machine).icon);return(0,G.jsx)(`li`,{className:`list-none py-0.5`,children:(0,G.jsx)(`div`,{role:`button`,tabIndex:0,className:B(wL,`bg-sidebar-row-active text-sidebar-foreground`),onClick:e.onSelect,children:(0,G.jsxs)(`div`,{className:`px-(--sidebar-row-content-inset) py-(--sidebar-content-inset)`,children:[(0,G.jsxs)(`div`,{className:`flex h-6 min-w-0 items-center gap-2`,children:[(0,G.jsx)(mc,{machine:e.machine,projectId:e.projectId,className:`size-5`}),(0,G.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,G.jsx)(H,{icon:Ys,className:`text-warning-foreground size-4 shrink-0`})]}),(0,G.jsxs)(`div`,{className:`text-secondary-label mt-1 flex h-5 min-w-0 items-center gap-1.5 text-xs`,children:[(0,G.jsx)(Of,{icon:n,className:`size-3 shrink-0`}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:[t,(0,G.jsx)(`span`,{className:`text-muted-foreground/40 font-normal`,children:` | Draft`})]}),(0,G.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`now`})]})]})})})}var kL=`group/sidebar-row relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`;function AL(e){let t=e.session,[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(!1),o=(0,W.useRef)(null),s=e.activity?.waiting===!0,c=Object.values(e.activity?.tasks??{}).includes(`running`),l=!s&&(e.activity?.running===!0||c),u=e.activity?.running===!0||c,d=!s&&!l&&e.unseen,f=!e.selected&&!s&&!d;function p(){pt(t.machine,t.id,null)}function m(){u?a(!0):p()}let h=(0,G.jsx)(mr,{open:i,onOpenChange:a,children:(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:`Stop running work?`}),(0,G.jsx)(Rn,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:p,children:`Stop and Mark Done`})]})]})}),g=e.saved&&(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground inline-flex h-5 cursor-pointer items-center rounded-md px-1.5`,title:`Thread actions`,onClick:e=>e.stopPropagation(),children:(0,G.jsx)(H,{icon:os,className:`size-3.5`})})}),(0,G.jsx)(Dn,{align:`end`,className:`w-44`,onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>{o.current!==null&&(e.preventDefault(),o.current.focus(),o.current.select())},children:(0,G.jsx)(zA,{session:t,context:!1,mobile:!1,onDeactivate:m,onRename:()=>r(t.title)})})]}),_=(0,G.jsx)(tr,{className:`w-44`,onCloseAutoFocus:e=>{o.current!==null&&(e.preventDefault(),o.current.focus(),o.current.select())},children:(0,G.jsx)(zA,{session:t,context:!0,mobile:!1,onDeactivate:m,onRename:()=>r(t.title)})}),v=n===null?(0,G.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate text-sm`,f?`text-secondary-label font-normal`:`font-medium`,!f&&(e.unseen||s)&&`text-foreground`,!f&&!e.unseen&&!s&&`text-foreground/90`),children:(0,G.jsx)(VA,{session:t,awaitingTitle:!e.saved})}):(0,G.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let i=n.trim();r(null),i!==``&&i!==t.title&&Je(t.machine,t.id,{title:i})},children:(0,G.jsx)(`input`,{ref:o,value:n,onChange:e=>r(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>r(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&r(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),y=B(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,f&&`text-sidebar-muted-foreground/75 hover:bg-sidebar-row-hover hover:text-sidebar-foreground has-[[data-state=open]]:bg-sidebar-row-hover has-[[data-state=open]]:text-sidebar-foreground`,!e.selected&&!f&&`text-sidebar-foreground hover:bg-sidebar-row-hover has-[[data-state=open]]:bg-sidebar-row-hover bg-transparent`);return(0,G.jsxs)(`li`,{className:`list-none`,children:[(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(kL,y,`flex h-9 items-center gap-2 px-2.5`,l&&!e.selected&&`opacity-70 transition-opacity focus-within:opacity-100 hover:opacity-100`),onClick:e.onSelect,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[(0,G.jsxs)(`span`,{className:`group-any-hover/sidebar-row:mask-r-from-[calc(100%-5rem)] group-any-hover/sidebar-row:mask-r-to-[calc(100%-3rem)] flex min-w-0 flex-1 items-center gap-2 group-has-[[data-state=open]]/sidebar-row:mask-r-from-[calc(100%-5rem)] group-has-[[data-state=open]]/sidebar-row:mask-r-to-[calc(100%-3rem)]`,children:[v,t.status===`pinned`&&(0,G.jsx)(H,{icon:Is,className:`text-muted-foreground/65 size-3 shrink-0`}),t.status===`snoozed`&&(0,G.jsx)(H,{icon:sc,className:`text-secondary-label size-3 shrink-0`}),(0,G.jsx)(BA,{activity:e.activity,backgroundRunning:c,done:d}),(0,G.jsx)(`span`,{className:`text-secondary-label shrink-0 text-xs tabular-nums`,children:yn(t.updatedAt)})]}),e.saved&&(0,G.jsxs)(`div`,{className:`group-any-hover/sidebar-row:pointer-events-auto group-any-hover/sidebar-row:opacity-100 pointer-events-none absolute inset-y-0 right-0 flex items-center pr-1.5 opacity-0 transition-opacity has-[[data-state=open]]:pointer-events-auto has-[[data-state=open]]:opacity-100`,children:[g,(0,G.jsx)(`button`,{className:`text-muted-foreground hover:text-foreground ms-0.5 me-0.5 inline-flex size-5 cursor-pointer items-center justify-center transition-colors`,title:`Done`,"aria-label":`Done`,onClick:e=>{e.stopPropagation(),m()},children:(0,G.jsx)(H,{icon:nc,strokeWidth:1.35,className:`size-5 scale-110`})})]})]})}),_]}),h]})}function jL(e){return(0,G.jsx)(`li`,{className:`list-none`,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(kL,`bg-sidebar-row-active text-sidebar-foreground flex h-9 items-center gap-2 px-2.5`),onClick:e.onSelect,children:[(0,G.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,G.jsx)(H,{icon:Ys,className:`text-warning-foreground size-4 shrink-0`})]})})}var ML=`relative w-full cursor-pointer overflow-hidden rounded-md text-left outline-none select-none touch-pan-y [-webkit-touch-callout:none] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`;function NL(e){let t=e.session,[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(0),c=(0,W.useRef)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(!1),d=e.activity?.waiting===!0,f=Object.values(e.activity?.tasks??{}).includes(`running`),p=!d&&(e.activity?.running===!0||f),m=e.activity?.running===!0||f,h=!d&&!p&&e.unseen,g=!e.selected&&!d&&!h;function _(){pt(t.machine,t.id,null)}function v(){m?a(!0):_()}function y(e){let n=l.current;l.current=null,s(0),n!==null&&n.swiping&&(u.current=!0,e.clientX-n.x>e.currentTarget.offsetWidth*.4&&(t.status===`inactive`?Je(t.machine,t.id,{status:`active`}):v()),e.clientX-n.x<-e.currentTarget.offsetWidth*.4&&Je(t.machine,t.id,{status:TL[t.status].status}))}let b={onClick:()=>{u.current?u.current=!1:e.onSelect()},onPointerDown:t=>{e.saved&&t.pointerType===`touch`&&(u.current=!1,l.current={x:t.clientX,y:t.clientY,swiping:!1})},onPointerMove:e=>{let t=l.current;if(t===null)return;let n=e.clientX-t.x,r=e.clientY-t.y;!t.swiping&&Math.abs(n)<10&&Math.abs(r)<10||(!t.swiping&&Math.abs(n)<=Math.abs(r)?l.current=null:(t.swiping=!0,s(n)))},onPointerUp:y,onPointerCancel:()=>{l.current=null,s(0)}},x=o!==0&&(0,G.jsx)(`div`,{className:B(`absolute inset-0 flex items-center rounded-md px-4 text-white`,o>0&&t.status!==`inactive`&&`bg-success`,o>0&&t.status===`inactive`&&`bg-[#56b6c2]`,o<0&&t.status===`active`&&`bg-[#c678dd]`,o<0&&t.status===`snoozed`&&`bg-[#d19a66]`,o<0&&t.status===`minimized`&&`bg-info`,o<0&&t.status===`inactive`&&`bg-[#5c6370]`,o<0&&t.status===`pinned`&&`bg-[#e06c75]`,o<0&&`justify-end`),children:(0,G.jsx)(H,{icon:o<0?TL[t.status].icon:t.status===`inactive`?Ls:nc,className:`size-6`})}),S=(0,G.jsx)(mr,{open:i,onOpenChange:a,children:(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:`Stop running work?`}),(0,G.jsx)(Rn,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:_,children:`Stop and Mark Done`})]})]})}),C=(0,G.jsx)(tr,{className:`w-44`,onCloseAutoFocus:e=>{c.current!==null&&(e.preventDefault(),c.current.focus(),c.current.select())},children:(0,G.jsx)(zA,{session:t,context:!0,mobile:!0,onDeactivate:v,onRename:()=>r(t.title)})}),w=n===null?(0,G.jsx)(`span`,{className:B(`min-w-0 flex-1 truncate text-sm`,g?`text-secondary-label font-normal`:`font-medium`,!g&&(e.unseen||d)&&`text-foreground`,!g&&!e.unseen&&!d&&`text-foreground/90`),children:(0,G.jsx)(VA,{session:t,awaitingTitle:!e.saved})}):(0,G.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let i=n.trim();r(null),i!==``&&i!==t.title&&Je(t.machine,t.id,{title:i})},children:(0,G.jsx)(`input`,{ref:c,value:n,onChange:e=>r(e.target.value),onClick:e=>e.stopPropagation(),onBlur:()=>r(null),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&r(null)},className:`text-foreground ring-ring/50 focus:ring-ring w-full rounded-sm bg-transparent text-sm font-medium ring-1 outline-none ring-inset`})}),T=B(e.selected&&`bg-sidebar-row-active text-sidebar-foreground`,g&&`text-sidebar-muted-foreground/75`,!e.selected&&!g&&`text-sidebar-foreground bg-transparent`);return(0,G.jsxs)(`li`,{className:`relative list-none`,children:[x,(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!e.saved,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(ML,T,`flex h-9 items-center gap-2 px-2.5`,p&&!e.selected&&o===0&&`opacity-70`,o!==0&&`bg-sidebar`),style:o===0?void 0:{transform:`translateX(${o}px)`},...b,onKeyDown:t=>{t.key===`Enter`&&e.onSelect()},children:[w,t.status===`pinned`&&(0,G.jsx)(H,{icon:Is,className:`text-muted-foreground/65 size-3 shrink-0`}),t.status===`snoozed`&&(0,G.jsx)(H,{icon:sc,className:`text-secondary-label size-3 shrink-0`}),(0,G.jsx)(BA,{activity:e.activity,backgroundRunning:f,done:h}),(0,G.jsx)(`span`,{className:`text-secondary-label shrink-0 text-xs tabular-nums`,children:yn(t.updatedAt)})]})}),C]}),S]})}function PL(e){return(0,G.jsx)(`li`,{className:`list-none`,children:(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:B(ML,`bg-sidebar-row-active text-sidebar-foreground flex h-9 items-center gap-2 px-2.5`),onClick:e.onSelect,children:[(0,G.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate text-sm font-medium`,children:`New thread`}),(0,G.jsx)(H,{icon:Ys,className:`text-warning-foreground size-4 shrink-0`})]})})}function FL(e){let t=cc(e.machine,e.projectId),n=k(t=>Ge(t,e.machine).icon),r=k(e=>e.selection),i=k(e=>e.machines),a=k(e=>e.unseen),o=r!==null&&r.sessionId===null&&r.machine===e.machine&&r.projectId===e.projectId,s=e.mobile?PL:jL,c=e.mobile?NL:AL;function l(){Ie({machine:e.machine,projectId:e.projectId,sessionId:null})}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`li`,{className:`text-sidebar-muted-foreground/60 mx-0.5 mt-2 flex h-7 items-center gap-2 pl-2 text-xs font-medium first:mt-0`,children:[(0,G.jsx)(Of,{icon:n,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`bg-sidebar-border/60 h-px min-w-2 flex-1`}),(0,G.jsx)(mc,{machine:e.machine,projectId:e.projectId,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,G.jsx)(`span`,{className:`bg-sidebar-border/60 h-px min-w-2 flex-1`}),(0,G.jsx)(`button`,{className:`text-sidebar-muted-foreground/80 hover:bg-sidebar-row-hover hover:text-sidebar-foreground flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-[var(--control-radius)]`,title:`New thread`,"aria-label":`New thread`,onClick:l,children:(0,G.jsx)(H,{icon:Oo,className:`size-4 text-(--sidebar-icon-color)`})})]}),o&&(0,G.jsx)(s,{onSelect:l}),e.sessions.map(t=>(0,G.jsx)(c,{session:t,selected:r?.machine===t.machine&&r.sessionId===t.id,activity:$e(i,t.machine,t.id),unseen:a.includes(P(t.machine,t.id)),saved:t!==e.started,onSelect:()=>Ie({machine:t.machine,projectId:t.projectId,sessionId:t.id})},P(t.machine,t.id)))]})}function IL(e){let t=k(e=>e.errors),n=k(e=>e.machines),r=k(e=>e.sessions),i=k(e=>e.unseen),a=n.filter(e=>e.status===`offline`||e.status===`unpaired`),o=r.filter(e=>Object.values($e(n,e.machine,e.id)?.tasks??{}).includes(`failed`)),s=r.filter(e=>$e(n,e.machine,e.id)?.waiting===!0),c=r.filter(e=>{let t=$e(n,e.machine,e.id);return i.includes(P(e.machine,e.id))&&t?.waiting!==!0&&t?.running!==!0&&!Object.values(t?.tasks??{}).includes(`running`)}),l=t.length+a.length+o.length,u=!e.hideDone&&c.length>0;if(l===0&&s.length===0&&!u)return null;let d=e.collapsed===!0&&u&&s.length>0&&l>0;return(0,G.jsxs)(`div`,{className:B(`flex shrink-0 items-center gap-1`,e.className),children:[d&&(0,G.jsx)(RL,{className:`bg-question/15 text-question`,icon:qs,count:s.length+c.length,label:`${s.length} waiting for approval, ${c.length} done`,children:(0,G.jsx)(LL,{kind:`merged`})}),!d&&u&&(0,G.jsx)(RL,{className:`bg-success/15 text-success`,icon:Zo,count:c.length,label:`${c.length} done`,children:(0,G.jsx)(LL,{kind:`done`})}),!d&&s.length>0&&(0,G.jsx)(RL,{className:`bg-question/15 text-question`,icon:qs,count:s.length,label:`${s.length} waiting for approval`,children:(0,G.jsx)(LL,{kind:`waiting`})}),l>0&&(0,G.jsx)(RL,{className:B(t.length>0&&`bg-error/15 text-error`,t.length===0&&`bg-warning/15 text-warning-foreground`),icon:t.length>0?un:jo,count:l,label:l===1?`1 problem`:`${l} problems`,onClose:ze,children:(0,G.jsx)(LL,{kind:`problems`})})]})}function LL(e){let t=k(e=>e.errors),n=k(e=>e.machines),r=k(e=>e.sessions),i=k(e=>e.unseen),a=n.filter(e=>e.status===`offline`||e.status===`unpaired`),o=r.filter(e=>Object.values($e(n,e.machine,e.id)?.tasks??{}).includes(`failed`)),s=r.filter(e=>$e(n,e.machine,e.id)?.waiting===!0),c=r.filter(e=>{let t=$e(n,e.machine,e.id);return i.includes(P(e.machine,e.id))&&t?.waiting!==!0&&t?.running!==!0&&!Object.values(t?.tasks??{}).includes(`running`)}).map(e=>(0,G.jsx)(BL,{session:e,icon:Zo,className:`text-success`,detail:`Done`},P(e.machine,e.id))),l=s.map(e=>(0,G.jsx)(BL,{session:e,icon:qs,className:`text-question`,detail:`Waiting for approval`},P(e.machine,e.id)));if(e.kind===`done`)return c;if(e.kind===`waiting`)return l;if(e.kind===`merged`)return(0,G.jsxs)(G.Fragment,{children:[l,c]});if(e.kind===`problems`)return(0,G.jsxs)(G.Fragment,{children:[t.map((e,t)=>(0,G.jsx)(zL,{icon:un,className:`text-error`,children:(0,G.jsx)(`span`,{className:`text-error-foreground whitespace-pre-wrap`,children:e})},t)),a.map(e=>(0,G.jsxs)(zL,{icon:jo,className:`text-warning-foreground`,children:[e.status===`offline`&&`${e.name} is offline`,e.status===`unpaired`&&`${e.name} needs pairing`]},e.id)),o.map(e=>(0,G.jsx)(BL,{session:e,icon:jo,className:`text-warning-foreground`,detail:`Background task failed`},P(e.machine,e.id)))]});throw Error(`Unknown chip list`)}function RL(e){return(0,G.jsxs)(ln,{onOpenChange:t=>!t&&e.onClose?.(),children:[(0,G.jsx)(Sn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:B(`flex h-5 shrink-0 cursor-pointer items-center gap-0.75 rounded-[6px] px-1.25 text-[11px] font-medium tabular-nums`,e.className),title:e.label,"aria-label":e.label,children:[(0,G.jsx)(H,{icon:e.icon,className:`size-3 shrink-0`}),e.count]})}),(0,G.jsx)(sn,{align:`end`,collisionPadding:12,className:`flex max-h-80 w-[min(20rem,calc(100vw-2rem))] flex-col gap-px overflow-y-auto p-1 text-sm`,children:e.children})]})}function zL(e){return(0,G.jsxs)(`div`,{className:`flex items-start gap-2 px-2 py-1.5`,children:[(0,G.jsx)(H,{icon:e.icon,className:B(`mt-0.5 size-4 shrink-0`,e.className)}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.children})]})}function BL(e){return(0,G.jsx)(Fn,{asChild:!0,children:(0,G.jsx)(`button`,{className:`hover:bg-accent cursor-pointer rounded-md text-left`,onClick:()=>Ie({machine:e.session.machine,projectId:e.session.projectId,sessionId:e.session.id}),children:(0,G.jsxs)(zL,{icon:e.icon,className:e.className,children:[(0,G.jsx)(`div`,{className:`text-foreground truncate`,children:e.session.title}),(0,G.jsx)(`div`,{className:`text-muted-foreground text-xs`,children:e.detail})]})})})}function VL({...e}){return(0,G.jsx)(Ac,{"data-slot":`hover-card`,...e})}function HL({...e}){return(0,G.jsx)(Mc,{"data-slot":`hover-card-trigger`,...e})}function UL({className:e,align:t=`start`,sideOffset:n=4,...r}){return(0,G.jsx)(Ic,{children:(0,G.jsx)(Rc,{"data-slot":`hover-card-content`,sideOffset:n,align:t,className:B(`z-50 origin-(--radix-hover-card-content-transform-origin) overflow-hidden rounded-lg dropdown-glass text-popover-foreground shadow-[0_16px_40px_-18px_rgb(0_0_0/55%)] outline-none dark:shadow-[0_18px_44px_-18px_rgb(0_0_0/80%)] duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function WL(e){let t=k(e=>e.machines),n=k(e=>e.projects),r=e.contextMenu?Bn:Mr;return t.filter(e=>e.status===`online`).flatMap(e=>[(0,G.jsxs)(r,{onSelect:()=>void zF(e.id,null),children:[(0,G.jsx)(Of,{icon:e.icon}),(0,G.jsx)(`span`,{className:`max-w-60 truncate`,children:e.name})]},e.id),...n.filter(t=>t.machine===e.id&&!t.hidden&&!t.scratch).map(t=>(0,G.jsxs)(r,{className:`pl-7`,onSelect:()=>void zF(e.id,t.id),children:[(0,G.jsx)(mc,{machine:e.id,projectId:t.id,className:`size-4`}),(0,G.jsx)(`span`,{className:`max-w-60 truncate`,children:t.name})]},`${e.id}:${t.id}`))])}function GL(e){let t=k(e=>e.machines),[n,r]=(0,W.useState)(!1),i=t.reduce((e,t)=>e+t.terminals.length,0),a=t.some(e=>e.status===`online`&&e.terminals.length>0),o=t.some(e=>e.status===`online`);if(t.length===0)return null;let s=(0,G.jsxs)(`button`,{className:B(e.buttonClassName,`group-hover/terminal:text-sidebar-foreground group-hover/terminal:[&>svg]:text-sidebar-foreground group-has-[[data-state=open]]/terminal:text-sidebar-foreground group-has-[[data-state=open]]/terminal:[&>svg]:text-sidebar-foreground h-8 w-full justify-start gap-2 px-2.5 text-sm`),title:`Terminal`,disabled:!o,onClick:o?()=>r(!0):void 0,children:[(0,G.jsx)(H,{icon:Zs}),`Terminal`,i>0&&(0,G.jsx)(`span`,{className:B(`text-foreground/75 ml-auto grid h-4 min-w-4 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))] px-1 text-[10px] leading-none font-medium tabular-nums`,o&&`group-hover/terminal:invisible group-has-[[data-state=open]]/terminal:invisible`,o&&`pointer-coarse:invisible`),children:i}),o&&(0,G.jsx)(H,{icon:mi,"aria-hidden":!0,className:`text-muted-foreground absolute right-2.5 size-4 opacity-0 group-hover/terminal:opacity-100 group-has-[[data-state=open]]/terminal:opacity-100 pointer-coarse:opacity-100`})]});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,disabled:!o,children:(0,G.jsx)(`div`,{className:`group/terminal hover:bg-sidebar-row-hover has-[[data-state=open]]:bg-sidebar-row-hover data-[state=open]:bg-sidebar-row-hover relative rounded-[var(--control-radius)]`,children:o?(0,G.jsxs)(VL,{openDelay:0,open:n,onOpenChange:r,children:[(0,G.jsx)(HL,{asChild:!0,children:s}),(0,G.jsx)(UL,{side:`right`,align:`end`,className:`w-56 p-1`,onClick:()=>r(!1),children:(0,G.jsx)(vL,{})})]}):s})}),(0,G.jsxs)(tr,{onCloseAutoFocus:e=>e.preventDefault(),children:[(0,G.jsxs)(or,{children:[(0,G.jsxs)(Kn,{children:[(0,G.jsx)(H,{icon:Oo}),`New terminal`]}),(0,G.jsx)(Cr,{className:`max-h-80 overflow-y-auto`,children:(0,G.jsx)(WL,{contextMenu:!0})})]}),(0,G.jsxs)(Bn,{variant:`destructive`,disabled:!a,onSelect:()=>void XI(t.filter(e=>e.status===`online`).flatMap(e=>e.terminals.map(t=>({machine:e.id,id:t.id})))),children:[(0,G.jsx)(H,{icon:is}),`Close All`]})]})]}),(0,G.jsx)(oL,{})]})}var KL=null;function qL(e,t,n,r){let a=k(e=>e.inactiveVersion),o=k(e=>e.machines.filter(e=>e.status===`online`).map(e=>e.id).join(` `));(0,W.useEffect)(()=>{let a=JSON.stringify([t,n,o]);if(!e&&KL===a)return;let s=!0;async function l(){let e=o.split(` `).filter(e=>e!==``&&(t===null||e===t)),c=await Promise.all(e.map(async e=>{let t=await L(e,`sessions.inactive`,{projectId:n,limit:r});return{sessions:t.sessions.map(t=>({...t,machine:e})),total:t.total}}));if(!s)return;KL=a;let l=R(),u=new Map(l.inactive.map(e=>[P(e.machine,e.id),e])),d=c.flatMap(e=>e.sessions).sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,r).map(e=>{let t=u.get(P(e.machine,e.id));return t!==void 0&&Tn(t,e)?t:e}),f=c.reduce((e,t)=>e+t.total,0);Tn(d,l.inactive)&&f===l.inactiveTotal||i({inactive:d,inactiveTotal:f})}return l().catch(c),()=>{s=!1}},[e,t,n,o,a,r])}function JL(){let e=k(e=>e.usageOpen);return(0,G.jsx)(oi,{open:e,onOpenChange:N,children:(0,G.jsxs)($r,{className:`gap-0 overflow-hidden p-0 sm:max-w-md`,"aria-describedby":void 0,children:[(0,G.jsx)(ei,{className:`px-5 pt-4 pr-12 pb-3`,children:(0,G.jsx)(ri,{children:`Usage`})}),(0,G.jsx)(YL,{})]})})}function YL(){let e=k(e=>e.machines),[t,n]=(0,W.useState)(Date.now());(0,W.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),3e4);return()=>clearInterval(e)},[]);let r=e.filter(e=>e.status===`online`),i=new Map;for(let e of[...r.flatMap(e=>tR(e,e.claudeAccounts)),...r.flatMap(e=>tR(e,e.codexAccounts))]){if(!no(e.account))continue;let t=to(e.machine.id,e.account),n=i.get(t);n===void 0?i.set(t,{machine:e.machine.id,account:e.account,machines:[e.machine],names:[e.account.name]}):(n.machines.push(e.machine),n.names.push(e.account.name))}return i.size===0?(0,G.jsx)(`p`,{className:`text-muted-foreground border-t px-5 py-8 text-center text-xs`,children:`No Claude or Codex accounts with plan limits`}):(0,G.jsx)(`ul`,{className:`max-h-[70dvh] divide-y overflow-y-auto border-t`,children:[...i].map(e=>(0,G.jsx)(XL,{machine:e[1].machine,account:e[1].account,machines:e[1].machines,names:e[1].names,now:t},e[0]))})}function XL(e){let t=e.account,n=ro(e.machine,t),r=n?.limits.filter(e=>e.rejected||e.utilization!==null)??[],i=n?.updatedAt??n?.fetchedAt??null,a=i===null?null:yn(i),[o,s]=(0,W.useState)(!1),c=o||n===void 0;return(0,G.jsxs)(`li`,{className:`flex flex-col gap-3 px-5 py-4`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,G.jsx)(gc,{provider:t.provider,className:`size-3.5 shrink-0`}),(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:B(`truncate font-medium`,c&&`text-shimmer`),style:c?{"--shimmer-color":ZL[t.provider]}:{color:ZL[t.provider]},children:new Set(e.names).size===1?t.name:QL(t)}),t.plan!==null&&(0,G.jsxs)(`span`,{className:B(`shrink-0`,c?`text-shimmer`:`text-muted-foreground`),children:[`· `,$L(t.provider,t.plan)]})]}),(0,G.jsx)(`span`,{className:`bg-foreground/5 ml-1 flex shrink-0 items-center gap-1 rounded-full border px-1 py-0.5`,children:e.machines.map(e=>(0,G.jsx)(Xr,{label:e.name,children:(0,G.jsx)(`span`,{className:`text-icon-muted`,children:(0,G.jsx)(Of,{icon:e.icon,className:`size-3`})})},e.id))})]}),(0,G.jsxs)(U,{variant:`ghost-muted`,size:`xs`,className:`text-muted-foreground/70 -mr-2 h-6 shrink-0 gap-1.5 text-[11px] font-normal tabular-nums [&_svg]:mx-0`,title:`Refresh`,disabled:o,onClick:async()=>{s(!0),await so(e.machine,t,!0),s(!1)},children:[a!==null&&(a===`now`?`now`:`${a} ago`),(0,G.jsx)(H,{icon:Gn,className:B(`size-3`,o&&`animate-spin`)})]})]}),n===void 0&&(0,G.jsx)(`div`,{className:`grid grid-cols-[minmax(2.5rem,max-content)_minmax(0,1fr)_2.25rem_3.25rem] items-center gap-x-3 gap-y-2 text-xs`,children:Array.from({length:2},(e,t)=>(0,G.jsxs)(W.Fragment,{children:[(0,G.jsx)(`span`,{className:`bg-foreground/10 my-0.5 h-3 w-12 animate-pulse rounded`}),(0,G.jsx)(`span`,{className:`bg-foreground/10 h-1.5 animate-pulse rounded-full`}),(0,G.jsx)(`span`,{className:`bg-foreground/10 ml-auto h-3 w-7 animate-pulse rounded`}),(0,G.jsx)(`span`,{className:`bg-foreground/10 h-3 w-10 animate-pulse rounded`})]},t))}),r.length>0&&(0,G.jsx)(`div`,{className:`grid grid-cols-[minmax(2.5rem,max-content)_minmax(0,1fr)_2.25rem_3.25rem] items-center gap-x-3 gap-y-2 text-xs`,children:r.map(t=>{let n=t.rejected?0:Math.max(0,100-Math.round((t.utilization??0)*100));return(0,G.jsxs)(W.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground capitalize`,children:Xm(t)}),(0,G.jsx)(`div`,{className:`bg-foreground/10 h-1.5 overflow-hidden rounded-full`,children:(0,G.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${n}%`,backgroundColor:eR(n)}})}),(0,G.jsxs)(`span`,{className:`text-right tabular-nums`,style:{color:eR(n)},children:[n,`%`]}),(0,G.jsx)(`span`,{className:`text-muted-foreground whitespace-nowrap tabular-nums`,title:t.resetsAt===null?void 0:ar(t.resetsAt*1e3),children:t.resetsAt===null?``:xn(t.resetsAt*1e3-e.now)})]},t.window)})}),n!==void 0&&n.error!==null&&(0,G.jsxs)(`p`,{className:`text-destructive text-xs`,children:[`Couldn't refresh: `,n.error]}),n!==void 0&&n.error===null&&r.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground/70 text-xs`,children:`No limits reported for this account`})]})}var ZL={claude:`#d97757`,codex:`#6e5ae6`};function QL(e){if(e.displayName!==null)return e.displayName;if(e.email===null)throw Error(`${e.name} has no email`);return e.organization!==null&&e.organization!==`${e.email}'s Organization`?e.organization:e.email.split(`@`)[0]}function $L(e,t){return t.split(/[\s_]+/).filter(t=>t.toLowerCase()!==e).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}function eR(e){return`hsl(${e/100*130} 40% 48%)`}function tR(e,t){return t.map(t=>({machine:e,account:t}))}var nR=`text-sidebar-muted-foreground/80 hover:bg-sidebar-row-hover hover:text-sidebar-foreground flex shrink-0 cursor-pointer items-center justify-center rounded-[var(--control-radius)] [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-(--sidebar-icon-color) hover:[&>svg]:text-sidebar-foreground`,rR=50;function iR(e){let t=k(e=>e.selection),n=k(e=>e.machines),r=k(e=>e.sessions),i=k(e=>e.projects),a=k(e=>e.settings.provider),o=k(e=>e.unseen),s=k(e=>e.loaded),c=k(e=>e.inactive),l=k(e=>e.inactiveTotal),u=k(e=>e.prefs.groupActiveByProject),[f,m]=zr(`sidebarScope`,null),[h,g]=(0,W.useState)(null),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)(!1),[x,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(!1),[E,D]=(0,W.useState)(rR),[O,A]=zr(`sidebarWidth`,240),j=r.filter(e=>f===null||e.machine===f.machine&&de(e.machine,e.projectId)===f.projectId).sort((e,t)=>t.updatedAt-e.updatedAt),M=j.filter(e=>{let t=$e(n,e.machine,e.id);return e.status===`snoozed`&&t?.waiting!==!0&&(t?.running===!0||Object.values(t?.tasks??{}).includes(`running`))}),ee=[...j.filter(e=>e.status===`pinned`),...j.filter(e=>e.status===`active`||e.status===`snoozed`&&!M.includes(e))],te=j.filter(e=>e.status===`minimized`),ne=f?.machine??null,re=f?.projectId??null,ie=t!==null&&t.sessionId!==null&&s&&!r.some(e=>e.machine===t.machine&&e.id===t.sessionId)?{machine:t.machine,id:t.sessionId,provider:a,title:`New thread`,projectId:t.projectId,branch:null,updatedAt:Date.now(),status:`active`}:null,ae=t!==null&&t.sessionId===null?t:null,oe=ie===null?ee:[ie,...ee],se=u&&f===null,ce=[...new Map([...ae===null?[]:[ae],...oe].map(e=>{let t=de(e.machine,e.projectId);return[P(e.machine,t),{machine:e.machine,projectId:t}]}))],le=e.mobile?OL:GA;function de(e,t){return i.some(n=>n.machine===e&&n.id===t&&n.scratch)?S:t}qL(w,ne,re,E);function fe(){let e=f??t??gt();e===null?n.length>0?g(n[0].id):d(`Machines`):we(e.machine,e.projectId)}vr([`mod+n`,`mod+t`],fe,{enableOnFormTags:!0,preventDefault:!0}),vr([`mod+1`,`mod+2`,`mod+3`,`mod+4`,`mod+5`,`mod+6`,`mod+7`,`mod+8`,`mod+9`],e=>{let t=se?ce.flatMap(e=>oe.filter(t=>P(t.machine,de(t.machine,t.projectId))===e[0])):oe,n=/^(?:Digit|Numpad)([1-9])$/.exec(e.code);if(n===null)throw Error(`unexpected session shortcut key ${e.code}`);let r=t[Number(n[1])-1];r!==void 0&&aR(r.machine,r.projectId,r.id)},{enableOnFormTags:!0,preventDefault:!0,enabled:!e.mobile});function F(e){let t=e.clientX-O;Vt(e,e=>{let n=Math.min(480,Math.max(200,e.clientX-t));A(n)})}function I(r,i){let a=e.mobile?EL:UA;return(0,G.jsx)(a,{session:r,slim:i,selected:t?.machine===r.machine&&t.sessionId===r.id,activity:$e(n,r.machine,r.id),unseen:o.includes(P(r.machine,r.id)),saved:r!==ie,scope:f,onSelect:aR},P(r.machine,r.id))}function pe(e){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`li`,{className:B(`mx-0.5 h-9 pt-2`,e.first&&`mt-auto`),children:(0,G.jsxs)(`button`,{"aria-expanded":e.open,className:`text-sidebar-muted-foreground/60 flex h-9 w-full cursor-pointer items-center gap-2 rounded-md px-2 text-left text-xs font-medium`,onClick:e.onToggle,children:[(0,G.jsx)(H,{icon:e.icon,className:`size-3 shrink-0`}),(0,G.jsx)(`span`,{className:`-ms-1 shrink-0`,children:e.label}),(0,G.jsx)(`span`,{className:`bg-sidebar-border/60 h-px min-w-2 flex-1`}),(0,G.jsx)(H,{icon:Rr,className:B(`size-3 shrink-0 transition-transform`,!e.open&&`rotate-180`)})]})}),e.open&&e.items.map(e=>I(e,e.status===`inactive`))]})}return(0,G.jsxs)(`aside`,{className:B(`bg-sidebar text-sidebar-foreground border-sidebar-border flex flex-none border-r select-none`,e.className),children:[(0,G.jsxs)(`div`,{className:B(`relative flex min-w-0 flex-col`,e.mobile&&`flex-1`),style:e.mobile?void 0:{width:O},children:[(0,G.jsxs)(`div`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-2 px-3`,children:[e.mobile?(0,G.jsx)(CL,{buttonClassName:nR}):(0,G.jsx)(`button`,{className:B(nR,`size-7 [&>svg]:size-4.5`),title:`Hide sidebar (${z}+B)`,"aria-label":`Hide sidebar`,onClick:e.onHide,children:(0,G.jsx)(H,{icon:Ms})}),(0,G.jsx)(Nm,{scope:f,onScope:m,onEdit:v,onAddProject:g}),e.mobile&&(0,G.jsx)(IL,{hideDone:!0}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.75`,children:[(0,G.jsx)(`button`,{className:B(nR,`size-7 [&>svg]:size-4.5`),title:`Search (${z}+K)`,"aria-label":`Search`,onClick:()=>ue(!0),children:(0,G.jsx)(H,{icon:br})}),(0,G.jsx)(`button`,{className:B(nR,`size-7 [&>svg]:size-4.5`),title:`New thread (${z}+N)`,onClick:fe,children:(0,G.jsx)(H,{icon:Ys})})]})]}),(0,G.jsx)(`nav`,{className:`flex min-h-0 flex-1 [scrollbar-width:none] flex-col overflow-y-auto px-(--sidebar-content-inset) pb-(--sidebar-content-inset)`,children:(0,G.jsxs)(`ul`,{className:`flex flex-1 flex-col gap-px`,children:[se?ce.map(([t,n])=>(0,G.jsx)(FL,{machine:n.machine,projectId:n.projectId,sessions:oe.filter(e=>P(e.machine,de(e.machine,e.projectId))===t),started:ie,mobile:e.mobile},t)):(0,G.jsxs)(G.Fragment,{children:[ae!==null&&(0,G.jsx)(le,{machine:ae.machine,projectId:ae.projectId,onSelect:()=>aR(ae.machine,ae.projectId,null)}),oe.map(e=>I(e,!1))]}),ee.length===0&&ie===null&&t?.sessionId!==null&&(0,G.jsx)(`li`,{className:`text-sidebar-muted-foreground/60 px-2.5 py-6 text-center text-xs`,children:`No threads yet`}),M.length>0&&pe({icon:sc,label:y?`Snoozed`:`Snoozed (${M.length})`,items:M,open:y,onToggle:()=>b(!y),first:!0}),te.length>0&&pe({icon:As,label:x?`Minimized`:`Minimized (${te.length})`,items:te,open:x,onToggle:()=>C(!x),first:M.length===0}),pe({icon:tc,label:`Done`,items:c.slice(0,E),open:w,onToggle:()=>{T(!w),D(rR)},first:M.length===0&&te.length===0}),w&&l>E&&c.length>=E&&(0,G.jsx)(`li`,{"aria-hidden":!0,className:`h-px shrink-0`,ref:e=>{if(e===null)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&D(E+rR)});return t.observe(e),()=>t.disconnect()}})]})}),!e.mobile&&(0,G.jsxs)(`div`,{className:`border-sidebar-border @container flex shrink-0 flex-col gap-px border-t p-(--sidebar-content-inset)`,children:[(0,G.jsx)(GL,{buttonClassName:nR}),(0,G.jsxs)(`button`,{className:B(nR,`h-8 w-full justify-start gap-2 px-2.5 text-sm`),title:`Usage`,onClick:()=>N(!0),children:[(0,G.jsx)(H,{icon:rs}),(0,G.jsx)(`span`,{className:`truncate`,children:`Usage`})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`button`,{className:B(nR,`h-8 w-full justify-start gap-2 px-2.5 text-sm`),title:`Settings`,onClick:()=>p(!0),children:[(0,G.jsx)(H,{icon:Us}),(0,G.jsx)(`span`,{className:`truncate`,children:`Settings`})]}),(0,G.jsxs)(`div`,{className:`absolute top-1.5 right-1.5`,children:[(0,G.jsx)(IL,{className:`@max-[13rem]:hidden`,hideDone:!1}),(0,G.jsx)(IL,{className:`hidden @max-[13rem]:flex`,hideDone:!1,collapsed:!0})]})]})]}),!e.mobile&&(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,className:`group absolute inset-y-0 -right-1 z-20 w-2 cursor-col-resize select-none`,onPointerDown:F,children:(0,G.jsx)(`span`,{className:`group-hover:bg-border group-active:bg-primary/60 pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 transition-colors`})})]}),(0,G.jsx)(JL,{}),h!==null&&(0,G.jsx)(Am,{machine:h,onClose:()=>g(null),onAdd:e=>{g(null),aR(e.machine,e.id,null)}}),_!==null&&(0,G.jsx)(Mm,{project:_,onClose:()=>v(null),onRemoved:()=>{f?.machine===_.machine&&f.projectId===_.id&&m(null),v(null)}})]})}function aR(e,t,n){Ie({machine:e,projectId:t,sessionId:n})}var oR={running:`Running`,completed:`Done`,failed:`Failed`,stopped:`Stopped`};function sR(e,t){return{agents:e.flatMap(e=>e.kind===`subagent`?[{item:e,agentId:e.agentId,status:lR(e.status,e.agentId,t)}]:[]),tasks:e.flatMap(e=>e.kind===`command`&&e.background!==null?[{item:e,taskId:e.background.taskId,path:e.background.outputPath,events:e.background.events,status:lR(e.status,e.background.taskId,t)}]:[])}}function cR(e){return e.description===``?e.command:e.description}function lR(e,t,n){let r=t===null?void 0:n?.tasks[t];return r===void 0?e===`running`?t===null&&n?.running===!0?`Running`:`Stopped`:oR[e]:oR[r]}function uR(e){return(0,G.jsx)(`span`,{className:B(e.active&&`text-shimmer`),children:e.text})}function dR(e){return(0,G.jsxs)(`span`,{className:B(`flex min-w-0 items-baseline overflow-hidden text-[13px] leading-4 tracking-[-0.04px]`,e.grouped?`gap-1.5`:`gap-2`),children:[(0,G.jsx)(`span`,{className:B(`text-foreground shrink-0`,e.grouped?`font-normal`:`font-medium`),children:(0,G.jsx)(uR,{text:e.title,active:e.pending})}),e.subtitle!==void 0&&e.subtitle!==``&&(0,G.jsx)(`span`,{className:B(`min-w-0 truncate tabular-nums`,e.grouped?`text-muted-foreground/70`:`text-muted-foreground`),children:e.subtitle}),e.args?.map(t=>(0,G.jsx)(`span`,{className:B(`min-w-0 truncate tabular-nums`,e.grouped?`text-muted-foreground/70`:`text-muted-foreground`),children:t},t))]})}function fR(e){return(0,G.jsx)(`span`,{"aria-hidden":!0,className:B(`text-muted-foreground/70 flex size-6 shrink-0 items-center justify-center transition-opacity`,e.open?`opacity-100`:`opacity-0 group-hover/tool:opacity-100`,e.className),children:(0,G.jsx)(H,{icon:Dr,strokeWidth:2.5,className:B(`size-3.5 transition-transform`,!e.open&&`-rotate-90`)})})}function pR(e){let t=e.onToggle,n=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`flex max-w-[calc(100%-24px)] min-w-0 items-center`,children:(0,G.jsx)(dR,{title:e.title,subtitle:e.subtitle,args:e.args,pending:e.pending,grouped:e.grouped})}),t!==null&&(0,G.jsx)(fR,{open:e.open})]});return(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[t===null?(0,G.jsx)(`div`,{className:B(`flex w-full items-center select-none`,e.grouped?`min-h-7`:`min-h-9`),children:n}):(0,G.jsx)(`button`,{type:`button`,"aria-expanded":e.open,onClick:t,className:B(`group/tool focus-visible:ring-ring/70 flex w-full cursor-pointer items-center rounded-md text-left select-none focus-visible:ring-2 focus-visible:outline-none`,e.grouped?`h-7`:`h-9`),children:n}),e.open&&e.children!==void 0&&(0,G.jsx)(`div`,{className:B(`min-w-0 pt-1`,e.rail!==!1&&`ps-3`),children:e.children})]})}var mR=new Map([[`build`,`text-blue-400`],[`explore`,`text-yellow-400`],[`plan`,`text-pink-400`],[`review`,`text-green-400`],[`writer`,`text-purple-400`]]),hR=new Map([[`Running`,`Launched agent`],[`Done`,`Agent finished`],[`Failed`,`Agent failed`],[`Stopped`,`Agent stopped`]]),gR=new Map([[`Running`,`Started in background`],[`Done`,`Background task finished`],[`Failed`,`Background task failed`],[`Stopped`,`Background task stopped`]]),_R=[`text-sky-400`,`text-amber-400`,`text-fuchsia-400`,`text-emerald-400`,`text-violet-400`,`text-cyan-400`,`text-orange-400`,`text-teal-400`,`text-rose-400`,`text-indigo-400`,`text-lime-400`,`text-red-400`];function vR(e){let t=e.agent,n=t.toLowerCase(),r=0;for(let e of n)r=r*31+e.charCodeAt(0)>>>0;return{name:t[0].toUpperCase()+t.slice(1),description:e.description,tone:mR.get(n)??_R[r%_R.length]}}function yR(e){return(0,G.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,className:B(`size-4 shrink-0`,e.className),children:[(0,G.jsx)(`path`,{d:`M4 4.5C4 4.22386 4.22386 4 4.5 4H11.5C11.7761 4 12 4.22386 12 4.5V11.5C12 11.7761 11.7761 12 11.5 12H4.5C4.22386 12 4 11.7761 4 11.5V4.5Z`,fill:`currentColor`}),(0,G.jsx)(`path`,{d:`M14.5 1C14.7761 1 15 1.22386 15 1.5V14.5C15 14.7761 14.7761 15 14.5 15H1.5C1.22386 15 1 14.7761 1 14.5V1.5C1 1.22386 1.22386 1 1.5 1H14.5ZM2 14H14V2H2V14Z`,fill:`currentColor`})]})}function bR(e){return(0,G.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":!0,className:B(`size-4 shrink-0`,e.className),children:Array.from({length:25},(e,t)=>(0,G.jsx)(`rect`,{x:1+t%5*3,y:1+Math.floor(t/5)*3,width:2,height:2,fill:`currentColor`,className:`agent-dot`,style:{animationDelay:`${(t%5+Math.floor(t/5))*90}ms`}},t))})}function xR(e){let t=e.item;if(t.kind===`agent_message`){let n=t.target;return(0,G.jsx)(SR,{label:`Messaged agent`,detail:t.summary,pending:e.sending,onOpen:n===null?null:()=>e.onOpen(n)})}if(t.kind===`command`){let n=e.tasks.find(e=>e.item.id===t.id);if(n===void 0)throw Error(`Task ${t.id} is missing from the thread`);return(0,G.jsx)(SR,{label:gR.get(n.status)??`Background task ${n.status.toLowerCase()}`,detail:cR(n.item),pending:n.status===`Running`,onOpen:()=>e.onOpen(t.id)})}let n=e.agents.find(e=>e.item.id===t.id);if(n===void 0)throw Error(`Agent ${t.id} is missing from the thread`);return(0,G.jsx)(SR,{label:hR.get(n.status)??`Agent ${n.status.toLowerCase()}`,detail:t.description,pending:n.status===`Running`,onOpen:()=>e.onOpen(t.id)})}function SR(e){let t=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:(0,G.jsx)(uR,{text:e.detail===``?e.label:`${e.label}:`,active:e.pending})}),e.detail!==``&&(0,G.jsx)(`span`,{className:`text-foreground min-w-0 truncate`,children:e.detail})]});return e.onOpen===null?(0,G.jsx)(`div`,{className:`flex min-h-7 min-w-0 items-center gap-1 text-[13px] leading-4 tracking-[-0.04px] select-none`,children:t}):(0,G.jsxs)(`button`,{type:`button`,title:`Open in Tasks panel`,onClick:e.onOpen,className:`group/agent focus-visible:ring-ring/70 flex min-h-7 w-fit max-w-full cursor-pointer items-center gap-1 rounded-md text-left text-[13px] leading-4 tracking-[-0.04px] select-none focus-visible:ring-2 focus-visible:outline-none`,children:[t,(0,G.jsx)(`span`,{className:`text-muted-foreground/70 flex shrink-0 opacity-0 transition-opacity group-hover/agent:opacity-100 group-focus-visible/agent:opacity-100 pointer-coarse:opacity-100`,children:(0,G.jsx)(H,{icon:kn,className:`size-3.5`})})]})}function CR(e){let t=(0,W.useRef)(null),[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(0),[o,s]=(0,W.useState)([]),c=o.length===0?-1:Math.min(i,o.length-1);(0,W.useEffect)(()=>t.current?.focus(),[]),(0,W.useEffect)(()=>{let t=e.content.current;if(t===null)throw Error(`transcript is not mounted`);if(n===``)return;let r=0,i=new MutationObserver(()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>s(wR(t,n)))});return i.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{i.disconnect(),cancelAnimationFrame(r)}},[n,e.content]),(0,W.useEffect)(()=>{if(o.length!==0)return CSS.highlights.set(`transcript-find`,new Highlight(...o)),c!==-1&&CSS.highlights.set(`transcript-find-current`,new Highlight(o[c])),()=>{CSS.highlights.delete(`transcript-find`),CSS.highlights.delete(`transcript-find-current`)}},[o,c]);function l(t,n){let i=e.content.current,o=e.scroller.current;if(i===null||o===null)throw Error(`transcript is not mounted`);let c=t===``?[]:wR(i,t),l=c.length===0?0:(n+c.length)%c.length;if(r(t),a(l),s(c),c.length===0)return;let u=c[l].getBoundingClientRect(),d=o.getBoundingClientRect();(u.top<d.top+48||u.bottom>d.bottom-48)&&o.scrollBy({top:u.top-d.top-d.height/3})}return(0,G.jsxs)(`div`,{"data-transcript":!0,className:`bg-card absolute top-2 right-6 z-30 flex items-center gap-1 rounded-lg border p-1 shadow-lg`,children:[(0,G.jsx)(Tp,{ref:t,"data-thread-find":!0,className:`h-7 w-52`,placeholder:`Find in thread`,"aria-label":`Find in thread`,value:n,onChange:e=>l(e.target.value,0),onKeyDown:t=>{t.key===`Escape`?(t.preventDefault(),e.onClose()):t.key===`Enter`&&(t.preventDefault(),l(n,c+(t.shiftKey?-1:1)))}}),(0,G.jsx)(`span`,{className:`text-muted-foreground w-16 text-center text-xs tabular-nums`,children:n===``?``:o.length===0?`No results`:`${c+1} of ${o.length}`}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Previous match`,onClick:()=>l(n,c-1),children:(0,G.jsx)(H,{icon:Bo})}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Next match`,onClick:()=>l(n,c+1),children:(0,G.jsx)(H,{icon:Dr})}),(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close find`,onClick:e.onClose,children:(0,G.jsx)(H,{icon:Go})})]})}function wR(e,t){let n=[],r=[],i=``,a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=a.nextNode();e!==null;e=a.nextNode())e instanceof Text&&(n.push(e),r.push(i.length),i+=e.data);let o=new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`gi`),s=[],c=0;for(let e of i.matchAll(o)){let t=e.index+e[0].length;for(;c+1<r.length&&r[c+1]<=e.index;)c++;let i=c;for(;i+1<r.length&&r[i+1]<t;)i++;let a=document.createRange();a.setStart(n[c],e.index-r[c]),a.setEnd(n[i],t-r[i]),a.getClientRects().length>0&&s.push(a)}return s}function TR(e){let[t,n]=(0,W.useState)(!1),r=e.plan,i=DR(r),a=r.length>900||r.split(`
|
|
17
17
|
`).length>20,o=a&&!t;return(0,G.jsxs)(`div`,{className:`border-border/80 bg-card/70 rounded-3xl border p-4 sm:p-5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`bg-secondary text-secondary-foreground relative inline-flex h-5.5 min-w-5.5 shrink-0 items-center justify-center gap-1 rounded-sm border border-transparent px-[calc(--spacing(1)-1px)] text-sm font-medium whitespace-nowrap sm:h-4.5 sm:min-w-4.5 sm:text-xs`,children:`Plan`}),(0,G.jsx)(`h3`,{className:`text-foreground truncate text-sm font-medium`,children:i??`Proposed plan`})]}),(0,G.jsxs)(mn,{children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(U,{"aria-label":`Plan actions`,size:`icon-xs`,variant:`outline`,children:(0,G.jsx)(H,{icon:wr,className:`size-4`})})}),(0,G.jsx)(Dn,{align:`end`,children:(0,G.jsx)(ER,{plan:r,title:i})})]})]}),(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsxs)(`div`,{className:B(`relative`,o&&`max-h-104 overflow-hidden`),children:[(0,G.jsx)(ir,{text:o?kR(r):OR(r)}),o&&(0,G.jsx)(`div`,{className:`from-card/95 via-card/80 pointer-events-none absolute inset-x-0 bottom-0 h-24 bg-linear-to-t to-transparent`})]}),a&&(0,G.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,G.jsx)(U,{size:`sm`,variant:`outline`,onClick:()=>n(!t),children:t?`Collapse plan`:`Expand plan`})})]})]})}function ER(e){let t=nn(),n=`${e.plan.trimEnd()}\n`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Mr,{onSelect:e=>{e.preventDefault(),t.copy(n)},children:t.copied?`Copied!`:`Copy to clipboard`}),(0,G.jsx)(Mr,{onSelect:()=>{let t=URL.createObjectURL(new Blob([n],{type:`text/markdown;charset=utf-8`})),r=document.createElement(`a`);r.href=t,r.download=`${AR(e.title??`plan`)}.md`,r.click(),setTimeout(()=>URL.revokeObjectURL(t),0)},children:`Download as markdown`})]})}function DR(e){let t=/^\s{0,3}#{1,6}\s+(.+)$/m.exec(e)?.[1]?.trim();return t===void 0||t===``?null:t}function OR(e){let t=e.trimEnd().split(/\r?\n/),n=/^\s{0,3}#{1,6}\s+/.test(t[0]??``)?t.slice(1):t;for(;n[0]?.trim()===``;)n.shift();if(/^\s{0,3}#{1,6}\s+(.+)$/.exec(n[0]??``)?.[1]?.trim().toLowerCase()===`summary`)for(n.shift();n[0]?.trim()===``;)n.shift();return n.join(`
|
|
18
18
|
`)}function kR(e){let t=OR(e).trimEnd().split(/\r?\n/).map(e=>e.trimEnd()),n=[],r=0,i=!1;for(let e of t){let t=e.trim()!==``;if(t&&r>=10){i=!0;break}n.push(e),t&&(r+=1)}for(;n.length>0&&n.at(-1)?.trim()===``;)n.pop();return n.length===0?DR(e)??`Plan preview unavailable.`:(i&&n.push(``,`...`),n.join(`
|
|
19
19
|
`))}function AR(e){let t=e.toLowerCase().replace(/[`'".,!?()[\]{}]+/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t===``?`plan`:t}function jR(e){let t=e.item.answers;return(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 text-sm leading-6 select-text`,children:[e.item.questions.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-foreground font-medium`,children:e.question}),(0,G.jsx)(`ul`,{className:`text-secondary-label list-disc pl-5`,children:e.options.map(e=>(0,G.jsxs)(`li`,{children:[e.label,e.description!==``&&` — ${e.description}`]},e.label))}),t?.[e.question]!==void 0&&(0,G.jsxs)(`p`,{className:`text-foreground whitespace-pre-wrap`,children:[`Answer: `,t[e.question]]})]},e.question)),e.item.status===`failed`&&(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:`Skipped`})]})}function MR(e){let[t,n]=(0,W.useState)(null);return(0,W.useEffect)(()=>{let t=!1;function r(){let r=e.scroller.current,i=window.getSelection();if(r===null||i===null||i.isCollapsed||i.rangeCount===0||t){n(null);return}let a=i.getRangeAt(0),o=i.toString().trim();if(o===``||!NR(a.startContainer,r)||!NR(a.endContainer,r)){n(null);return}let s=[...a.getClientRects()].filter(e=>e.width>0);if(s.length===0){n(null);return}let c=a.endContainer===i.focusNode&&a.endOffset===i.focusOffset,l=c?s[s.length-1]:s[0],u=r.getBoundingClientRect();n({text:o,top:l.bottom-u.top+r.scrollTop+6,left:Math.min(Math.max((c?l.right:l.left)-u.left,48),u.width-48)})}function i(){t=!0}function a(){t=!1,r()}return document.addEventListener(`selectionchange`,r),document.addEventListener(`pointerdown`,i),document.addEventListener(`pointerup`,a),document.addEventListener(`pointercancel`,a),()=>{document.removeEventListener(`selectionchange`,r),document.removeEventListener(`pointerdown`,i),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,a)}},[e.scroller]),t===null?null:(0,G.jsxs)(U,{type:`button`,size:`xs`,variant:`outline`,className:`animate-in fade-in-0 zoom-in-95 hover:bg-accent dark:hover:bg-accent absolute z-20 -translate-x-1/2 border-[color-mix(in_srgb,var(--bg)_85%,var(--text))] bg-[color-mix(in_srgb,var(--bg)_65%,black)] shadow-md duration-25 ease-out dark:bg-[color-mix(in_srgb,var(--bg)_65%,black)]`,style:{top:t.top,left:t.left},onPointerDown:e=>e.preventDefault(),onClick:()=>{PR(t.text),window.getSelection()?.removeAllRanges(),n(null)},children:[(0,G.jsx)(H,{icon:zs}),`Quote`]})}function NR(e,t){let n=e instanceof Element?e:e.parentElement;return n!==null&&t.contains(n)&&n.closest(`[data-quotable]`)!==null}function PR(e){let t=R().selection;if(t===null)throw Error(`no thread is open to quote into`);let n=e.split(`
|
|
@@ -21,7 +21,7 @@ Error generating stack: `+e.message+`
|
|
|
21
21
|
`);F(ct(t),e=>({...e,text:e.text.trim()===``?`${n}\n\n`:`${e.text.trimEnd()}\n\n${n}\n\n`})),requestAnimationFrame(()=>{let e=document.querySelector(`[data-composer]`);if(e===null)throw Error(`the composer is not mounted`);e.focus(),e.setSelectionRange(e.value.length,e.value.length)})}function FR(e){return e.kind===`group`||e.kind===`agent`}function IR(e,t){let n=[],r=e.prompt?.id??`start`;e.prompt!==null&&n.push({kind:`user`,key:e.prompt.id,item:e.prompt,first:e.first});for(let r of e.items){let e=LR(r,t!==null),i=n.at(-1);e?.kind===`group`&&i?.kind===`group`?i.entries.push(...e.entries):e!==null&&n.push(e)}let i=n.at(-1);return t!==null&&t.partial===``&&i?.kind===`group`&&(n[n.length-1]={...i,live:!0}),t!==null&&t.partial!==``&&n.push({kind:`assistant`,key:`${r}:partial`,message:``,text:t.partial,time:null,streaming:!0,meta:!1}),t!==null&&t.partial===``&&n.push({kind:`working`,key:`${r}:working`}),t===null&&i?.kind===`assistant`&&(n[n.length-1]={...i,meta:!0}),n}function LR(e,t){switch(e.kind){case`assistant`:return{kind:`assistant`,key:e.id,message:e.message,text:e.text,time:e.time,streaming:!1,meta:!1};case`reasoning`:case`file_change`:case`web_search`:case`skill`:case`tool`:return{kind:`group`,key:`group:${e.id}`,entries:[e],live:!1};case`command`:return e.background===null?{kind:`group`,key:`group:${e.id}`,entries:[e],live:!1}:{kind:`agent`,key:e.id,item:e,live:t};case`subagent`:case`agent_message`:return{kind:`agent`,key:e.id,item:e,live:t};case`plan`:return{kind:`plan`,key:e.id,plan:e.plan};case`question`:return{kind:`question`,key:e.id,item:e};case`notice`:return{kind:`notice`,key:e.id,text:e.text};case`compaction`:return{kind:`compaction`,key:e.id,summary:e.summary,time:e.time};case`error`:return{kind:`error`,key:e.id,text:e.text,time:e.time};case`user`:case`todo_list`:return null}}function RR(e,t,n){let r=[],i=!1;for(let t of e)t.parent===null&&(t.kind===`user`?(r.push({prompt:t,first:!i,items:[]}),i=!0):(t.kind!==`notice`&&t.kind!==`error`&&(i=!0),r.length===0&&r.push({prompt:null,first:!0,items:[]}),r[r.length-1].items.push(t)));let a=r.flatMap((e,i)=>IR(e,t&&i===r.length-1?{partial:n}:null));return t&&r.length===0&&a.push({kind:`working`,key:`working`}),a}var zR={all:{label:`Restore code and chat`,description:`This will undo file changes made since this message and remove this message and everything after it from the chat.`,icon:zo,code:!0,conversation:!0},chat:{label:`Restore chat`,description:`This will remove this message and everything after it from the chat. Files will not change.`,icon:Ps,code:!1,conversation:!0},code:{label:`Restore code`,description:`This will undo file changes made since this message. The chat will not change.`,icon:pr,code:!0,conversation:!1}};function BR(e){if(e===`claude`)return[`all`,`chat`,`code`];if(e===`opencode`)return[`all`,`chat`];if(e===`codex`)return[`chat`];throw Error(`unknown provider ${e}`)}function VR(e){let[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(null),s=BR(k(e=>e.settings.provider)),c=k(e=>e.prefs.rewind),l=s.includes(c)?c:`chat`;return(0,G.jsxs)(G.Fragment,{children:[s.length>1&&(0,G.jsxs)(mn,{open:t,onOpenChange:e=>{r||n(e)},children:[(0,G.jsx)(Xr,{label:`Restore options`,children:(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsx)(U,{type:`button`,size:`icon-micro`,variant:`ghost-muted`,"aria-label":`Restore options`,disabled:e.disabled,children:(0,G.jsx)(H,{icon:wr,className:`size-4`})})})}),(0,G.jsx)(Dn,{align:`end`,className:`w-72`,children:(0,G.jsx)(HR,{messageId:e.target.messageId,available:s,onPick:(e,t)=>o({mode:e,check:t})})})]}),(0,G.jsx)(Xr,{label:zR[l].label,children:(0,G.jsx)(U,{type:`button`,size:`icon-micro`,variant:`ghost-muted`,"aria-label":zR[l].label,disabled:e.disabled||r,onClick:()=>o({mode:l,check:null}),children:(0,G.jsx)(H,{icon:zR[l].icon,className:`size-4`})})}),(0,G.jsx)(mr,{open:a!==null,onOpenChange:e=>{e||o(null)},children:a!==null&&(0,G.jsx)(Zn,{children:(0,G.jsx)(UR,{target:e.target,mode:a.mode,check:a.check,onBusy:i})})})]})}function HR(e){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null),a=e.messageId,o=k(e=>e.selection),s=o?.machine??null,c=o?.sessionId??null,l=o?.projectId??``,u=k(e=>s===null?``:He(e,s,l)?.path??``);(0,W.useEffect)(()=>{if(n(null),i(null),s===null||c===null)return;let e=!0;return L(s,`sessions.rewind`,{sessionId:c,projectId:l,messageId:a,settings:R().settings,code:!0,conversation:!1,dryRun:!0}).then(t=>{e&&n(t)},t=>{e&&i(Ht(t))}),()=>{e=!1}},[a,s,c,l]);let d=t!==null&&r===null;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`text-muted-foreground px-2 py-1.5 text-xs`,children:[r!==null&&`Code can't be restored: ${r}`,r===null&&t===null&&`Checking file changes…`,t!==null&&t.files.length===0&&`No file changes since this message.`,t!==null&&t.files.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[`Restores `,t.files.length,` `,t.files.length===1?`file`:`files`,` (`,(0,G.jsxs)(`span`,{className:`text-diff-addition`,children:[`+`,t.insertions]}),` `,(0,G.jsxs)(`span`,{className:`text-diff-deletion`,children:[`−`,t.deletions]}),`)`]}),(0,G.jsx)(`ul`,{className:`mt-1 max-h-24 overflow-y-auto font-mono`,children:t.files.map(e=>(0,G.jsx)(`li`,{className:`truncate`,children:sp(e,u)},e))})]})]}),(0,G.jsx)(Pn,{}),e.available.map(n=>(0,G.jsxs)(Mr,{disabled:zR[n].code&&!d,onSelect:()=>e.onPick(n,{preview:t,codeError:r}),children:[(0,G.jsx)(H,{icon:zR[n].icon}),zR[n].label]},n))]})}function UR(e){let[t,n]=(0,W.useState)(e.check===null?null:e.check.preview),[r,a]=(0,W.useState)(e.check===null?null:e.check.codeError),o=e.target,s=o.messageId,l=e.check!==null,u=k(e=>e.selection),d=k(e=>e.settings.provider),f=u?.machine??null,p=u?.sessionId??null,m=u?.projectId??``;(0,W.useEffect)(()=>{if(l||f===null||p===null)return;n(null),a(null);let e=!0;return L(f,`sessions.rewind`,{sessionId:p,projectId:m,messageId:s,settings:R().settings,code:!0,conversation:!1,dryRun:!0}).then(t=>{e&&n(t)},t=>{e&&a(Ht(t))}),()=>{e=!1}},[l,s,f,p,m]);async function h(t){if(f===null||p===null)return;let n=zR[t].code,r=zR[t].conversation;e.onBusy(!0);try{let e=r?await Promise.all(o.images.map((e,t)=>e.data===null?L(f,`sessions.image`,{sessionId:p,itemId:o.messageId,index:t}):{mediaType:e.mediaType,data:e.data})):[],a=r&&o.first&&d===`claude`,s=r&&!a;(n||s)&&await L(f,`sessions.rewind`,{sessionId:p,projectId:m,messageId:o.messageId,settings:R().settings,code:n,conversation:s,dryRun:!1}),a&&(we(f,m,!0),i({replacing:{machine:f,projectId:m,sessionId:p}})),r&&Oe({text:o.text,images:e}),Ye({...R().prefs,rewind:t})}catch(e){ca(Ht(e)),c(e)}finally{e.onBusy(!1)}}let g=t!==null&&r===null;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsxs)(Hn,{children:[zR[e.mode].label,`?`]}),(0,G.jsxs)(Rn,{children:[zR[e.mode].description,` Do you really want to continue?`,zR[e.mode].code&&r!==null&&(0,G.jsx)(`span`,{className:`text-destructive mt-2 block`,children:`Code can't be restored: ${r}`})]})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,disabled:zR[e.mode].code&&!g,onClick:()=>void h(e.mode),children:zR[e.mode].label})]})]})}var WR=20,GR=`linear-gradient(to bottom, black calc(100% - 1.75rem), transparent)`,KR=new Map;function qR(e){let[t,n]=(0,W.useState)(!1),r=e.item,i=r.format===`text`||r.format===`command`?r.text:``,a=i.trim()!==``&&(i.length>600||i.split(`
|
|
22
22
|
`).length>8),o=a&&!t;return(0,G.jsxs)(`div`,{className:`group flex flex-col items-end gap-1`,children:[(0,G.jsxs)(`div`,{className:`bg-message text-message-foreground relative max-w-[80%] rounded-2xl px-3 py-2`,children:[r.images.length>0&&(0,G.jsx)(`div`,{className:`mb-2 grid max-w-[210px] grid-cols-2 gap-2`,children:r.images.map((e,t)=>(0,G.jsx)(`div`,{className:`border-border/80 bg-background/70 aspect-[4/3] overflow-hidden rounded-lg border`,children:(0,G.jsx)(YR,{itemId:r.id,index:t,mediaType:e.mediaType,data:e.data})},t))}),r.text!==``&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:B(`relative`,o&&`max-h-44 overflow-hidden`),style:o?{WebkitMaskImage:GR,maskImage:GR}:void 0,children:[r.format===`command`&&(0,G.jsx)(`span`,{className:`font-mono text-sm`,children:r.text}),r.format===`output`&&(0,G.jsx)(`pre`,{className:`text-muted-foreground font-mono text-xs whitespace-pre-wrap`,children:r.text}),r.format===`text`&&(0,G.jsx)(ir,{text:r.text,className:`text-foreground`,lineBreaks:!0,rawHtml:!1})]}),a&&(0,G.jsx)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2`,children:(0,G.jsx)(U,{type:`button`,size:`xs`,variant:`ghost-muted`,"aria-expanded":t,className:`-ml-1`,onClick:()=>n(!t),children:t?`Show less`:`Show full message`})})]})]}),(0,G.jsx)(`div`,{className:`flex w-full max-w-[80%] items-center justify-end pe-1 text-xs tabular-nums opacity-0 transition-opacity duration-200 group-hover:opacity-100 focus-within:opacity-100 has-aria-expanded:opacity-100 pointer-coarse:opacity-100`,children:(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[r.time!==null&&(0,G.jsx)(Xr,{label:ar(r.time),children:(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs tabular-nums`,children:cn(r.time)})}),i!==``&&(0,G.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[e.rewind&&(0,G.jsx)(VR,{target:{messageId:r.id,text:i,images:r.images,first:e.first},disabled:e.running}),(0,G.jsx)(JR,{text:i})]})]})})]})}function JR(e){let t=nn();return(0,G.jsx)(Xr,{label:`Copy message`,children:(0,G.jsx)(U,{type:`button`,size:`icon-micro`,variant:`ghost-muted`,"aria-label":`Copy message`,disabled:t.copied,onClick:()=>void t.copy(e.text),children:(0,G.jsx)(H,{icon:t.copied?Un:Qn,className:B(`size-4`,t.copied&&`text-primary`)})})})}function YR(e){let t=k(e=>e.selection),n=t?.machine??null,r=t?.sessionId??null,[i,a]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(e.data!==null||n===null||r===null)return;let t=!0,i=JSON.stringify([n,r,e.itemId,e.index]),o=KR.get(i);if(o===void 0){if(o=L(n,`sessions.image`,{sessionId:r,itemId:e.itemId,index:e.index}),KR.set(i,o),KR.size>WR){let[e]=KR.keys();KR.delete(e)}o.catch(()=>KR.delete(i))}return o.then(e=>{t&&a(e.data)}).catch(c),()=>{t=!1}},[e.data,e.itemId,e.index,n,r]);let o=e.data??i;return o===null?null:(0,G.jsx)(dn,{src:`data:${e.mediaType};base64,${o}`,alt:``,name:`Image`,className:`block size-full`,imageClassName:`block size-full object-cover`})}var XR=(0,W.lazy)(async()=>({default:(await hi(async()=>{let{ImageViewer:e}=await import(`./image-viewer-3S4rNjFt.js`);return{ImageViewer:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).ImageViewer}));function ZR(e){switch(e.kind){case`command`:return`Shell`;case`file_change`:return`Edit`;case`web_search`:return e.url===null?`Web Search`:`Webfetch`;case`skill`:return`Skill`;case`tool`:return e.name}}function QR(e){let t=e.item,n=e.live&&t.status===`running`;if(t.status===`failed`)return(0,G.jsx)(az,{title:ZR(t),subtitle:oz(t,e.cwd),error:t.output});switch(t.kind){case`command`:return(0,G.jsx)(ez,{command:t.command,output:t.output,pending:n});case`file_change`:return(0,G.jsx)(rz,{items:[t],cwd:e.cwd,live:e.live});case`web_search`:{let e=t.url;return e===null?(0,G.jsx)(tz,{query:t.query??``,links:t.results,pending:n}):(0,G.jsx)(pR,{title:`Webfetch`,subtitle:(0,G.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline hover:underline-offset-2`,children:e}),pending:n,grouped:!0,open:!1,onToggle:null})}case`skill`:return(0,G.jsxs)(`div`,{className:`flex min-h-7 items-center gap-1 text-[13px] leading-4 tracking-[-0.04px]`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Loaded`}),(0,G.jsx)(`span`,{className:`text-foreground`,children:(0,G.jsx)(uR,{text:t.skill,active:n})}),(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`skill`})]});case`tool`:{let r=t.input;switch(tp(t.name)){case`read`:return(0,G.jsx)(pR,{title:`Read`,subtitle:(0,G.jsx)($R,{path:np(r),children:cz(np(r))}),args:sz(r,[`offset`,`limit`]),pending:n,grouped:!0,open:!1,onToggle:null});case`search`:return(0,G.jsx)(pR,{title:t.name,subtitle:oz(t,e.cwd),args:[...sz(r,[`pattern`]),...op(r.glob)===``?[]:[`include=${op(r.glob)}`]],pending:n,grouped:!0,open:!1,onToggle:null});case`other`:return(0,G.jsx)(pR,{title:`Called ${t.name}`,subtitle:oz(t,e.cwd),args:sz(r,Object.keys(r).filter(e=>![`description`,`query`,`url`,`path`,`pattern`].includes(e))).slice(0,3),pending:n,grouped:!0,open:!1,onToggle:null})}}}}function $R(e){let t=k(e=>e.selection),[n,r]=(0,W.useState)(null);return t===null||vn(e.path)!==`image`?e.children:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,title:`View ${e.path}`,className:`hover:text-foreground focus-visible:ring-ring/70 cursor-zoom-in rounded-sm underline decoration-dotted underline-offset-2 focus-visible:ring-2 focus-visible:outline-none`,onClick:()=>void bn(t.machine,t.projectId,e.path).then(r).catch(c),children:e.children}),n!==null&&(0,G.jsx)(W.Suspense,{children:(0,G.jsx)(XR,{src:n,alt:cz(e.path),name:e.path,onClose:()=>r(null)})})]})}function ez(e){let[t,n]=(0,W.useState)(!1);return(0,G.jsx)(pR,{title:`Shell`,subtitle:t?void 0:e.command,pending:e.pending,grouped:!0,open:t,onToggle:()=>n(!t),rail:!1,children:(0,G.jsxs)(`div`,{dir:`ltr`,className:`group/output border-border relative w-full overflow-hidden rounded-md border`,children:[(0,G.jsx)(`div`,{className:`absolute top-1 right-1 opacity-0 transition-opacity group-hover/output:opacity-100 focus-within:opacity-100`,children:(0,G.jsx)(JR,{text:e.command})}),(0,G.jsx)(`div`,{className:`max-h-60 [scrollbar-width:none] overflow-x-hidden overflow-y-auto`,children:(0,G.jsx)(`pre`,{className:`m-0 font-mono text-[13px] leading-5 tracking-[-0.04px] [overflow-wrap:anywhere] whitespace-pre-wrap select-text`,children:(0,G.jsxs)(`code`,{children:[(0,G.jsx)(`span`,{className:`text-foreground block p-3`,children:e.command}),e.output!==``&&(0,G.jsx)(`span`,{className:`border-border bg-muted text-muted-foreground block border-t p-3`,children:e.output})]})})})]})})}function tz(e){let[t,n]=(0,W.useState)(!1),r=e.links;return(0,G.jsx)(pR,{title:`Web Search`,subtitle:e.query,pending:e.pending,grouped:!0,open:t,onToggle:r.length===0?null:()=>n(!t),children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 text-[13px] leading-5`,children:[r.slice(0,10).map(e=>(0,G.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary truncate hover:underline hover:underline-offset-2`,children:e.title===``?e.url:e.title},e.url)),r.length>10&&(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`+`,r.length-10,` more`]})]})})}function nz(e){let[t,n]=(0,W.useState)(!1);return(0,G.jsx)(pR,{title:e.streaming?`Thinking`:`Thought`,subtitle:e.streaming?lz(e.text):void 0,pending:e.streaming,grouped:!0,open:t,onToggle:()=>n(!t),children:(0,G.jsx)(ir,{text:e.text,className:`text-muted-foreground text-[13px]`,lineBreaks:!0})})}function rz(e){let t=new Map;for(let n of e.items){let r=sp(n.path,e.cwd);t.set(r,[...t.get(r)??[],n])}return(0,G.jsx)(`div`,{className:`border-border overflow-hidden rounded-md border`,children:[...t].map(([t,n])=>(0,G.jsx)(iz,{file:t,items:n,pending:e.live&&n.some(e=>e.status===`running`)},t))})}function iz(e){let[t,n]=(0,W.useState)(!1),r=Math.max(e.file.lastIndexOf(`/`),e.file.lastIndexOf(`\\`)),i=0,a=0;for(let t of e.items){let e=rp(t);i+=e.added,a+=e.removed}return(0,G.jsxs)(`div`,{className:`border-border border-b last:border-b-0`,children:[(0,G.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(!t),className:`group/tool flex h-9 w-full cursor-pointer items-center gap-2 ps-3 pe-1 text-left text-[13px] leading-4 tracking-[-0.04px] select-none`,children:[(0,G.jsx)(ci,{path:e.file,className:`size-4 shrink-0`}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline`,children:[r>=0&&(0,G.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e.file.slice(0,r+1)}),(0,G.jsx)(`span`,{className:`text-foreground shrink-0`,children:(0,G.jsx)(uR,{text:e.file.slice(r+1),active:e.pending})})]}),(0,G.jsxs)(`span`,{role:`group`,"aria-label":`${i} additions, ${a} deletions`,className:`inline-flex items-center gap-1 align-middle font-mono text-xs tabular-nums`,children:[(0,G.jsxs)(`span`,{"aria-hidden":!0,className:`text-diff-addition`,children:[`+`,Cn(i)]}),(0,G.jsxs)(`span`,{"aria-hidden":!0,className:`text-diff-deletion`,children:[`-`,Cn(a)]})]}),(0,G.jsx)(fR,{open:t})]}),t&&(0,G.jsx)(`div`,{className:`border-border flex flex-col gap-2 border-t p-2`,children:e.items.map(e=>(0,G.jsx)($f,{item:e},e.id))})]})}function az(e){let[t,n]=(0,W.useState)(!1),r=e.error.replace(/<\/?tool_use_error>/g,``).trim(),i=r.split(`: `)[0].trim();return(0,G.jsxs)(`div`,{className:`group/error flex w-full min-w-0 flex-col`,children:[(0,G.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(!t),className:`flex h-6 w-full cursor-pointer items-center text-left text-[13px] leading-4 tracking-[-0.04px] select-none`,children:[(0,G.jsxs)(`span`,{className:`flex max-w-[calc(100%-20px)] min-w-0 items-center gap-1.5`,children:[(0,G.jsx)(H,{icon:Mo,className:`text-destructive size-4 shrink-0`}),(0,G.jsx)(`span`,{className:`text-foreground shrink-0 font-medium`,children:e.title}),e.subtitle!==``&&!t&&(0,G.jsx)(`span`,{className:`text-muted-foreground min-w-0 truncate`,children:e.subtitle}),!t&&(0,G.jsx)(`span`,{className:`text-destructive min-w-0 truncate`,children:i===``?`Failed`:i[0].toUpperCase()+i.slice(1)})]}),(0,G.jsx)(fR,{open:!0,className:`ms-1.5 size-3.5`})]}),t&&(0,G.jsxs)(`div`,{className:`relative ps-6 pe-10 select-text`,children:[(0,G.jsx)(`div`,{className:`absolute top-0 right-0 opacity-0 transition-opacity group-hover/error:opacity-100 focus-within:opacity-100`,children:(0,G.jsx)(JR,{text:r})}),(0,G.jsx)(`p`,{className:`text-destructive text-[13px] leading-5 tracking-[-0.04px] [overflow-wrap:anywhere] whitespace-pre-wrap`,children:r})]})]})}function oz(e,t){switch(e.kind){case`command`:return e.command;case`file_change`:return e.path;case`web_search`:return e.url??e.query??``;case`skill`:return e.skill;case`tool`:{let n=e.input;if(tp(e.name)===`search`){let e=op(n.path);return e===``||e===t?``:sp(e,t)}return[`description`,`query`,`url`,`file_path`,`path`,`pattern`].map(e=>op(n[e])).find(e=>e!==``)??``}}}function sz(e,t){return t.flatMap(t=>{let n=e[t];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?[`${t}=${n}`]:[]})}function cz(e){return e.split(`/`).at(-1)??e}function lz(e){let t=[...e.matchAll(/^\s*(?:#{1,6}[ \t]+(.+?)|\*\*([^*\n]+)\*\*)\s*$/gm)].at(-1);return t===void 0?void 0:(t[1]??t[2]).trim()}var uz=new Intl.ListFormat(`en`,{style:`long`,type:`conjunction`});function dz(e){let t=e.entries.flatMap(e=>e.kind===`reasoning`?[]:[e]),n=e.entries.length-t.length,r=uz.format([...new Set(t.map(ZR))]),i=r===``?n===1?`Thought`:`Thoughts`:r,a=t.length>0?t.length:n;return(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col`,children:[(0,G.jsxs)(`button`,{type:`button`,"aria-expanded":e.open,"aria-label":`Used ${a} ${i}`,onClick:e.onToggle,className:B(`group/tool focus-visible:ring-ring/70 flex h-7 w-full cursor-pointer items-center rounded-md text-left text-xs select-none focus-visible:ring-2 focus-visible:outline-none`,e.open&&`bg-background sticky top-0 z-20 box-content pb-2`),children:[(0,G.jsxs)(`span`,{className:`flex max-w-[calc(100%-24px)] min-w-0 items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:`Used`}),(0,G.jsx)(`span`,{className:`text-muted-foreground shrink-0 tabular-nums`,children:a}),(0,G.jsx)(`span`,{className:`text-muted-foreground min-w-0 truncate`,children:i})]}),(0,G.jsx)(fR,{open:e.open})]}),e.open&&(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:pz(e.entries).map(t=>(0,G.jsx)(`div`,{className:`flex min-h-7 min-w-0 flex-col justify-center`,children:(0,G.jsx)(fz,{item:t,cwd:e.cwd,live:e.live})},t.key))})]})}function fz(e){let t=e.item;switch(t.kind){case`thinking`:return(0,G.jsx)(nz,{text:t.text,streaming:e.live&&t.last});case`tool`:return(0,G.jsx)(QR,{item:t.item,cwd:e.cwd,live:e.live});case`reads`:return(0,G.jsx)(pR,{title:`Read`,subtitle:(0,G.jsx)(`span`,{title:t.items.map(e=>np(e.input)).join(`
|
|
23
23
|
`),children:t.items.map((t,n)=>(0,G.jsxs)(`span`,{children:[n>0&&` `,(0,G.jsx)($R,{path:np(t.input),children:(0,G.jsx)(uR,{text:np(t.input).split(`/`).at(-1)??``,active:e.live&&t.status===`running`})})]},t.id))}),pending:e.live&&t.items.some(e=>e.status===`running`),grouped:!0,open:!1,onToggle:null});case`files`:return(0,G.jsx)(rz,{items:t.items,cwd:e.cwd,live:e.live})}}function pz(e){let t=[];return e.forEach((n,r)=>{if(n.kind===`reasoning`){t.push({kind:`thinking`,key:n.id,text:n.text,last:r===e.length-1});return}let i=t.at(-1);n.status!==`failed`&&n.kind===`file_change`?i?.kind===`files`?i.items.push(n):t.push({kind:`files`,key:n.id,items:[n]}):n.status!==`failed`&&n.kind===`tool`&&tp(n.name)===`read`?i?.kind===`reads`?i.items.push(n):t.push({kind:`reads`,key:n.id,items:[n]}):t.push({kind:`tool`,key:n.id,item:n})}),t}function mz(e){let[t,n]=(0,W.useState)([]),[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(!0),s=(0,W.useRef)(null),c=e.rows.flatMap((t,n)=>t.kind===`user`?[{key:t.key,prompt:gz(t.item),reply:_z(e.rows,n)}]:[]),l=Math.max(c.findIndex(e=>e.key===t[0]),0),u=r===null?null:c[r];if((0,W.useEffect)(()=>{let t=e.scroller.current;if(t===null)throw Error(`transcript is not mounted`);function r(){if(t===null)throw Error(`transcript is not mounted`);let e=t.getBoundingClientRect(),r=[...t.querySelectorAll(`[data-kind="user"]`)],i=r.flatMap((t,n)=>{let i=t.getBoundingClientRect().top,a=r[n+1]?.getBoundingClientRect().top??1/0;return i<e.bottom&&a>e.top&&t.dataset.row?[t.dataset.row]:[]});n(e=>Tn(e,i)?e:i)}let i=new ResizeObserver(()=>{if(t===null)throw Error(`transcript is not mounted`);r();let e=t.querySelector(`[data-row]`)?.parentElement;e!=null&&o(t.getBoundingClientRect().right-e.getBoundingClientRect().right>=40)});return r(),i.observe(t),t.addEventListener(`scroll`,r,{passive:!0}),()=>{i.disconnect(),t.removeEventListener(`scroll`,r)}},[e.scroller,c.length]),c.length<2)return null;function d(e){let t=s.current?.getBoundingClientRect();if(t===void 0)throw Error(`message rail is not mounted`);let n=Math.min(Math.max((e-t.top)/t.height,0),1);return Math.round(n*(c.length-1))}function f(e){return`${e/(c.length-1)*100}%`}return(0,G.jsxs)(`div`,{ref:s,className:B(`absolute top-1/2 right-[calc(var(--app-scrollbar-width)+0.25rem)] z-20 w-8 -translate-y-1/2 select-none pointer-coarse:hidden`,!a&&`hidden`),style:{height:`min(${(c.length-1)*10}px, 60%)`},children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":`Jump to your message: ${u?.prompt??c[l].prompt}`,className:`focus-visible:ring-ring absolute inset-x-0 -inset-y-3 cursor-pointer rounded-md outline-none focus-visible:ring-2`,onPointerMove:e=>i(d(e.clientY)),onPointerLeave:()=>i(null),onFocus:()=>i(e=>e??l),onBlur:()=>i(null),onWheel:t=>{if(e.scroller.current===null)throw Error(`transcript is not mounted`);e.scroller.current.scrollBy({top:t.deltaY})},onClick:t=>{let n=t.detail===0?r:d(t.clientY);if(n===null)throw Error(`no message is selected`);e.onJump(c[n].key)},onKeyDown:e=>{let t=r??l,n=e.key===`ArrowUp`?t-1:e.key===`ArrowDown`?t+1:e.key===`Home`?0:e.key===`End`?c.length-1:null;n!==null&&(e.preventDefault(),i(Math.min(Math.max(n,0),c.length-1)))}}),c.map((e,n)=>{let i=r===null?null:Math.abs(n-r),a=t.includes(e.key);return(0,G.jsx)(`span`,{"aria-hidden":`true`,className:B(`pointer-events-none absolute right-1 h-0.5 w-5 origin-right -translate-y-1/2 rounded-full transition-all duration-150 ease-out`,i===0?`bg-foreground/85`:a?`bg-foreground/55`:`bg-foreground/20`,i===0?`scale-x-100`:i===1?`scale-x-75`:i===2?`scale-x-[0.55]`:a?`scale-x-50`:`scale-x-[0.35]`),style:{top:f(n)}},e.key)}),u!==null&&r!==null&&(0,G.jsxs)(`div`,{className:`bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-98 pointer-events-none absolute right-9 w-80 rounded-xl border p-3 shadow-lg/10 transition-[top,translate] duration-100 ease-out`,style:{top:f(r),translate:r===0?`0 -0.75rem`:r===c.length-1?`0 calc(-100% + 0.75rem)`:`0 -50%`},children:[(0,G.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 font-medium wrap-anywhere`,children:u.prompt}),u.reply!==``&&(0,G.jsx)(`p`,{className:`text-muted-foreground mt-1 line-clamp-3 text-xs leading-[1.125rem] wrap-anywhere`,children:u.reply})]})]})}function hz(e,t){let n=e?.querySelector(`[data-row="${CSS.escape(t)}"]`);if(e===null||!(n instanceof HTMLElement))throw Error(`that message is not on screen`);e.scrollTop+=n.getBoundingClientRect().top-e.getBoundingClientRect().top-24}function gz(e){let t=e.text.replace(/\s+/g,` `).trim();return t===``?e.images.length>0?`Image`:`Message`:t.slice(0,300)}function _z(e,t){let n=``;for(let r of e.slice(t+1)){if(r.kind===`user`)break;r.kind===`assistant`&&(n=r.text)}return n.slice(0,600).replace(/[#*`>|]+/g,``).replace(/\s+/g,` `).trim()}var vz=30;function yz(e){let t=k(e=>e.selection),n=k(e=>e.loaded),r=k(e=>e.items),i=k(e=>e.earlier),a=k(e=>e.before),o=k(e=>e.partial),s=k(e=>e.requests),c=k(Ct),l=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useRef)(!0),f=(0,W.useRef)(null),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)([]),[_,v]=(0,W.useState)(null),[y,b]=(0,W.useState)(!1),x=(0,W.useRef)(null),S=k(e=>t===null?``:He(e,t.machine,t.projectId)?.path??``),C=k(Mt),w=k(e=>e.sentAt);(0,W.useLayoutEffect)(()=>{let e=l.current;e!==null&&w!==0&&(d.current=!0,e.scrollTop=e.scrollHeight)},[w]),(0,W.useEffect)(()=>{let e=l.current;if(e===null||u.current===null)throw Error(`transcript is not mounted`);let t=new ResizeObserver(()=>{d.current&&(e.scrollTop=e.scrollHeight)});return t.observe(e),t.observe(u.current),()=>t.disconnect()},[]),(0,W.useLayoutEffect)(()=>{let e=l.current;e!==null&&d.current&&(e.scrollTop=e.scrollHeight)},[r,o,s,C]);let T=(0,W.useMemo)(()=>sR([...i,...r],c),[i,r,c]),E=RR(i,!1,``),D=[...E,...RR(r,C,o)],O=D.findIndex(e=>e.key===_?.key),A=y?0:Math.max(0,O===-1?D.length-vz:O-(_?.above??0));(0,W.useLayoutEffect)(()=>{let e=l.current;e!==null&&f.current!==null&&(e.scrollTop=e.scrollHeight-f.current),f.current=null},[i,A]),(0,W.useLayoutEffect)(()=>{x.current!==null&&(hz(l.current,x.current),x.current=null)},[A]),vr(`mod+f`,e=>{let t=e.target;e.defaultPrevented||t instanceof Element&&t!==document.body&&t.closest(`[data-composer], [data-transcript]`)===null||(e.preventDefault(),b(!0),requestAnimationFrame(()=>document.querySelector(`[data-thread-find]`)?.select()))},{enableOnFormTags:!0}),(0,W.useLayoutEffect)(()=>{let e=l.current;e!==null&&D.length!==0&&(O===-1?v({key:D[A].key,above:0}):j(e))});function j(e){A===0||e.scrollTop>=e.clientHeight||(f.current=e.scrollHeight-e.scrollTop,v({key:D[A].key,above:vz}))}function M(e){let t=D.findIndex(t=>t.key===e);if(t===-1)throw Error(`that message is not loaded`);t>=A?hz(l.current,e):(x.current=e,v({key:e,above:1}))}let N=(0,W.useCallback)(e=>{g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]);return(0,G.jsxs)(G.Fragment,{children:[y&&(0,G.jsx)(CR,{content:u,scroller:l,onClose:()=>{b(!1),D.length>0&&v({key:D[0].key,above:0}),document.querySelector(`[data-composer]`)?.focus()}}),(0,G.jsx)(mz,{rows:D,scroller:l,onJump:M}),(0,G.jsxs)(`div`,{ref:l,"data-transcript":!0,className:`topbar-scroll-fade relative min-h-0 flex-1 overflow-y-auto overscroll-y-contain pb-8`,onScroll:e=>{let t=e.currentTarget;d.current=t.scrollHeight-t.scrollTop-t.clientHeight<40,j(t)},children:[(0,G.jsx)(`div`,{ref:u,children:(0,G.jsxs)(jf,{width:`chat`,className:`pt-3`,children:[!n&&(0,G.jsx)(`p`,{className:`text-muted-foreground py-6 text-center text-xs`,children:`Loading…`}),a!==null&&A===0&&(0,G.jsx)(`div`,{className:`flex justify-center pb-4`,children:(0,G.jsx)(U,{type:`button`,size:`xs`,variant:`ghost-muted`,disabled:p,onClick:async()=>{let e=l.current;e!==null&&(f.current=e.scrollHeight-e.scrollTop),v({key:D[0].key,above:vz}),m(!0),await tt(),m(!1)},children:p?`Loading…`:`Load earlier conversation`})}),D.slice(A).map((t,n)=>{let r=A+n,i=D[r-1],a=r<E.length;return(0,G.jsx)(`div`,{"data-row":t.key,"data-kind":t.kind,className:B(i===void 0?void 0:t.kind===`user`?`pt-6`:t.kind===`working`?void 0:FR(t)&&FR(i)?`pt-2`:FR(t)||FR(i)?`pt-3`:`pt-4`,t.kind===`assistant`&&`group/assistant`),children:(0,G.jsx)(Sz,{row:t,agents:T.agents,tasks:T.tasks,running:C,compacting:c?.compacting===!0,fork:!a,expanded:h.includes(t.key),onToggle:N,onOpenTask:e.onOpenTask,rewind:!a,cwd:S})},t.key)})]})}),(0,G.jsx)(MR,{scroller:l})]})]})}var bz=(0,W.memo)(yz);function xz(e){let t=e.row;switch(t.kind){case`user`:return(0,G.jsx)(qR,{item:t.item,first:t.first,running:e.running,rewind:e.rewind});case`working`:return(0,G.jsx)(`div`,{className:`text-muted-foreground h-9 pt-3 text-[13px] leading-5 font-medium tracking-[-0.04px]`,children:(0,G.jsx)(uR,{text:e.compacting?`Compacting conversation`:`Working`,active:!0})});case`group`:return(0,G.jsx)(dz,{entries:t.entries,cwd:e.cwd,live:t.live,open:e.expanded,onToggle:()=>e.onToggle(t.key)});case`agent`:return(0,G.jsx)(xR,{item:t.item,agents:e.agents,tasks:e.tasks,sending:t.live&&t.item.status===`running`,onOpen:e.onOpenTask});case`assistant`:return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{"data-quotable":!0,children:(0,G.jsx)(ir,{text:t.text===``&&!t.streaming?`(empty response)`:t.text,streaming:t.streaming})}),t.meta&&(0,G.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 text-xs tabular-nums opacity-0 transition-opacity duration-200 group-hover/assistant:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,G.jsx)(JR,{text:t.text}),e.fork&&(0,G.jsx)(Cz,{uuid:t.message})]}),t.time!==null&&(0,G.jsx)(Xr,{label:ar(t.time),children:(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs tabular-nums`,children:cn(t.time)})})]})]});case`error`:return(0,G.jsxs)(`div`,{className:`text-destructive flex gap-1.5 text-[13px] leading-5 tracking-[-0.04px]`,children:[(0,G.jsx)(H,{icon:Mo,className:`mt-0.5 size-4 shrink-0`}),(0,G.jsx)(`p`,{className:`min-w-0 [overflow-wrap:anywhere] whitespace-pre-wrap select-text`,children:t.text})]});case`notice`:return(0,G.jsxs)(`div`,{className:`text-muted-foreground mx-auto flex w-full max-w-(--chat-content-max-width) items-center gap-3 py-1 text-xs`,children:[(0,G.jsx)(`span`,{className:`bg-border/70 h-px flex-1`}),(0,G.jsx)(`span`,{children:t.text}),(0,G.jsx)(`span`,{className:`bg-border/70 h-px flex-1`})]});case`compaction`:return(0,G.jsxs)(`div`,{className:`mx-auto w-full max-w-(--chat-content-max-width)`,children:[(0,G.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-3 py-1 text-xs`,children:[(0,G.jsx)(`span`,{className:`bg-border/70 h-px flex-1`}),t.summary===null?(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(H,{icon:ks,className:`size-3`}),`Conversation compacted`]}):(0,G.jsxs)(`button`,{type:`button`,"aria-expanded":e.expanded,className:`hover:text-foreground flex items-center gap-1.5 transition-colors`,onClick:()=>e.onToggle(t.key),children:[(0,G.jsx)(H,{icon:ks,className:`size-3`}),`Compacted summary`,(0,G.jsx)(H,{icon:Dr,strokeWidth:2.5,className:B(`size-3 transition-transform`,!e.expanded&&`-rotate-90`)})]}),(0,G.jsx)(`span`,{className:`bg-border/70 h-px flex-1`})]}),e.expanded&&t.summary!==null&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`bg-muted/40 text-muted-foreground mt-2 rounded-lg border px-4 py-3 text-sm`,children:(0,G.jsx)(ir,{text:t.summary,streaming:!1})}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-end gap-2 text-xs tabular-nums`,children:[t.time!==null&&(0,G.jsx)(Xr,{label:ar(t.time),children:(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs tabular-nums`,children:cn(t.time)})}),(0,G.jsx)(JR,{text:t.summary})]})]})]});case`plan`:return(0,G.jsx)(`div`,{className:`min-w-0`,"data-quotable":!0,children:(0,G.jsx)(TR,{plan:t.plan})});case`question`:return(0,G.jsx)(jR,{item:t.item})}}var Sz=(0,W.memo)(xz,(e,t)=>t.row.kind===`agent`?Tn(e,t):Tn(Wi(e,[`agents`,`tasks`]),Wi(t,[`agents`,`tasks`])));function Cz(e){let[t,n]=(0,W.useState)(!1);return(0,G.jsx)(Xr,{label:`Fork from this response`,children:(0,G.jsx)(U,{type:`button`,size:`icon-micro`,variant:`ghost-muted`,disabled:t,"aria-label":`Fork from this response`,onClick:()=>{n(!0),De(e.uuid).finally(()=>n(!1))},children:(0,G.jsx)(H,{icon:ds,className:B(`size-4`,t&&`animate-pulse`)})})})}var wz=oe(`event`,[s({offsite:It(`browser`),event:It(`location`),url:pe(),replaced:O()}),s({offsite:It(`browser`),event:It(`open`),url:pe()}),s({offsite:It(`browser`),event:It(`loading`)})]);function Tz(e){let t=Ce({from:`__root__`,select:e=>e.browse??null}),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(0),[o,s]=(0,W.useState)(0),[l,u]=(0,W.useState)(!1),[d,p]=(0,W.useState)(null),m=(0,W.useRef)(null),h=(0,W.useRef)(null),g=(0,W.useRef)({entries:[],index:-1}),_=k(t=>Ge(t,e.machine).status===`online`);(0,W.useEffect)(()=>{if(t===null||!_)return;let n=`${e.machine} ${i} ${t}`;if(h.current===n)return;let a=!0;return Ez(e.machine,t).then(e=>{a&&(h.current=n,g.current={entries:[],index:-1},r({target:t,src:e,error:null}),s(e=>e+1),p(null),u(!0))},e=>{a&&(r({target:t,src:null,error:Ht(e)}),p(null),u(!1))}),()=>{a=!1}},[e.machine,t,i,_]),(0,W.useEffect)(()=>{function a(a){if(a.source===null||a.source!==m.current?.contentWindow)return;let o=wz.safeParse(a.data);if(!o.success)return;if(o.data.event===`loading`){p(null),u(!0);return}if(t===null||n===null)throw Error(`a page reported its location outside the browser`);let s=o.data.url;o.data.event===`open`?L(e.machine,`browser.open`,{url:s,fromPage:!0}).then(t=>{h.current=`${e.machine} ${i} ${s}`,r({target:s,src:`${Me(e.machine)}${t}`,error:null}),u(!0),f({browse:s})},c):(p(Dz(g.current,s,o.data.replaced)),s!==t&&(h.current=`${e.machine} ${i} ${s}`,r({...n,target:s}),f({browse:s})))}return window.addEventListener(`message`,a),()=>window.removeEventListener(`message`,a)},[e.machine,i,t,n]);let v=t!==null&&/^https?:\/\//i.test(t),y=t===null?null:n?.src??null,b=!v&&n?.target===t?n.src:null,x=n?.target===t?n.error:null,S=t!==null&&_&&(n?.target!==t||l);function C(e){if(d===null)throw Error(`no page is open to send a browser command to`);m.current?.contentWindow?.postMessage({offsite:`browser`,command:e},`*`)}return(0,G.jsxs)(`div`,{className:`bg-background flex h-full min-h-0 min-w-0 flex-col`,children:[(0,G.jsxs)(`div`,{className:`border-border/60 bg-background flex h-(--workspace-topbar-height) shrink-0 items-center gap-2 border-b pr-3 pl-3`,children:[(0,G.jsx)(Vr,{mobile:e.mobile,onClick:e.onClose}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost`,title:`Back`,"aria-label":`Back`,disabled:d?.back!==!0,onClick:()=>C(`back`),children:(0,G.jsx)(H,{icon:Br,className:`size-4`})}),(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost`,title:`Forward`,"aria-label":`Forward`,disabled:d?.forward!==!0,onClick:()=>C(`forward`),children:(0,G.jsx)(H,{icon:kn,className:`size-4`})}),(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost`,title:`Reload`,"aria-label":`Reload`,onClick:()=>{d===null?a(i+1):C(`reload`)},children:(0,G.jsx)(H,{icon:pi,className:B(`size-4`,S&&`animate-spin`)})})]}),(0,G.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault();let t=new FormData(e.currentTarget).get(`address`);if(typeof t!=`string`)throw Error(`the address field is missing`);let n=t.trim();n!==``&&Ot(Oz(n))},children:(0,G.jsx)(Tp,{name:`address`,className:`h-7 font-mono text-xs`,placeholder:`URL or file path`,"aria-label":`URL or file path`,defaultValue:t??``})},t),b!==null&&(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost`,asChild:!0,children:(0,G.jsx)(`a`,{href:b,target:`_blank`,rel:`noopener noreferrer`,title:`Open in a new tab`,"aria-label":`Open in a new tab`,children:(0,G.jsx)(H,{icon:xs,className:`size-4`})})})]}),x!==null&&(0,G.jsx)(`p`,{className:`text-muted-foreground p-4 text-center text-xs`,children:x}),t===null&&(0,G.jsx)(`p`,{className:`text-muted-foreground p-4 text-center text-xs`,children:`Type a URL or a file path above. URLs load from this machine.`}),y!==null&&(0,G.jsx)(`iframe`,{ref:m,src:y,sandbox:v?`allow-scripts allow-forms allow-popups allow-modals allow-downloads allow-presentation allow-pointer-lock`:void 0,title:t??``,className:`min-h-0 w-full flex-1 bg-white scheme-light`,onLoad:()=>u(!1)},o)]})}async function Ez(e,t){if(/^https?:\/\//i.test(t)){let n=await L(e,`browser.open`,{url:t,fromPage:!1});return`${Me(e)}${n}`}let n=await L(e,`files.browse`,void 0);return`${Me(e)}/api/browse/${n}${kz(t)}`}function Dz(e,t,n){return n&&e.index>=0?e.entries[e.index]=t:e.entries[e.index-1]===t?--e.index:e.entries[e.index+1]===t?e.index+=1:e.entries[e.index]!==t&&(e.entries=[...e.entries.slice(0,e.index+1),t],e.index+=1),{back:e.index>0,forward:e.index<e.entries.length-1}}function Oz(e){return/^(https?:\/\/|file:)/i.test(e)||/^[/.]/.test(e)||/^[a-z]:[\\/]/i.test(e)?e:/^(localhost|\d+(\.\d+){3}|[\w.-]+:\d+)([:/?#]\S*)?$/i.test(e)?`http://${e}`:/^[\w-]+(\.[\w-]+)+([/?#]\S*)?$/.test(e)?`https://${e}`:`https://www.google.com/search?q=${encodeURIComponent(e)}`}function kz(e){let t=e.replaceAll(`\\`,`/`).split(`/`).map(encodeURIComponent).join(`/`);return t.startsWith(`/`)?t:`/${t}`}function Az(e){let t=e.stopping;return(0,G.jsx)(mr,{open:t!==null,onOpenChange:t=>{t||e.onClose()},children:t!==null&&(0,G.jsxs)(Zn,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsxs)(Hn,{children:[`Stop `,t.title,`?`]}),(0,G.jsx)(Rn,{children:`It is still running. Do you really want to stop it?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>{if(e.sessionId===null)throw Error(`Cannot stop a task without a session`);Pt(e.machine,e.sessionId,t.taskId)},children:`Stop`})]})]})})}function jz(e){return(0,G.jsx)(`button`,{type:`button`,title:e.label,"aria-label":e.label,className:`text-muted-foreground hover:text-destructive focus-visible:ring-ring/70 mr-1.5 grid size-7 shrink-0 cursor-pointer place-items-center rounded-md focus-visible:ring-2 focus-visible:outline-none`,onClick:e.onClick,children:(0,G.jsx)(H,{icon:Qs,className:`size-4`})})}function Mz(e){return(0,G.jsx)(U,{size:`xs`,variant:`outline`,className:`shrink-0`,onClick:()=>Pt(e.machine,e.sessionId,e.taskId),children:`Stop`})}function Nz(e){let t=k(e=>e.items),n=k(e=>e.earlier),r=k(t=>$e(t.machines,e.machine,e.sessionId)),[i,a]=(0,W.useState)(null),o=[...n,...t],s=sR(o,r),c=s.agents.find(t=>t.item.id===e.selected),l=s.tasks.find(t=>t.item.id===e.selected),u=c===void 0?null:vR(c.item);return(0,G.jsxs)(`div`,{className:`bg-background flex h-full min-h-0 min-w-0 flex-col`,children:[(0,G.jsxs)(`div`,{className:`border-border/60 bg-background flex h-(--workspace-topbar-height) shrink-0 items-center gap-1 border-b pr-3 pl-3`,children:[(0,G.jsx)(Vr,{mobile:e.mobile,onClick:()=>e.mobile&&(c!==void 0||l!==void 0)?e.onSelect(null):e.onClose()}),c===void 0&&l===void 0&&(0,G.jsx)(`span`,{className:`text-foreground min-w-0 truncate text-xs font-medium`,children:`Tasks`}),(c!==void 0||l!==void 0)&&(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[!e.mobile&&(0,G.jsx)(U,{size:`icon-sm`,variant:`ghost`,title:`Back to tasks`,"aria-label":`Back to tasks`,onClick:()=>e.onSelect(null),children:(0,G.jsx)(H,{icon:Br,className:`size-4`})}),c!==void 0&&u!==null&&(0,G.jsxs)(G.Fragment,{children:[c.status===`Running`?(0,G.jsx)(bR,{className:u.tone}):(0,G.jsx)(yR,{className:u.tone}),(0,G.jsx)(`span`,{className:`text-foreground shrink-0 font-medium`,children:u.name}),u.description!==``&&(0,G.jsx)(`span`,{className:`text-muted-foreground min-w-0 truncate`,children:u.description}),c.status===`Running`&&c.agentId!==null&&e.sessionId!==null&&(0,G.jsx)(Mz,{machine:e.machine,sessionId:e.sessionId,taskId:c.agentId})]}),l!==void 0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(H,{icon:ts,className:`text-muted-foreground size-4 shrink-0`}),(0,G.jsx)(`span`,{className:`text-foreground min-w-0 truncate font-medium`,children:cR(l.item)}),(0,G.jsx)(`span`,{className:B(`text-muted-foreground shrink-0`,l.status===`Failed`&&`text-destructive`,l.status===`Running`&&`text-shimmer`),children:l.status}),l.status===`Running`&&l.taskId!==null&&e.sessionId!==null&&(0,G.jsx)(Mz,{machine:e.machine,sessionId:e.sessionId,taskId:l.taskId})]})]})]}),c===void 0&&l===void 0&&(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[(0,G.jsx)(`h2`,{className:`text-muted-foreground px-1 pb-1.5 text-xs font-medium`,children:`Agents`}),s.agents.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground px-1 py-1 text-xs`,children:`No agents in this thread.`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[...s.agents.filter(e=>e.status===`Running`),...s.agents.filter(e=>e.status!==`Running`)].map(t=>{let n=vR(t.item),r=t.agentId;return(0,G.jsxs)(`div`,{className:`bg-secondary hover:bg-accent flex items-center rounded-lg`,children:[(0,G.jsxs)(`button`,{type:`button`,"aria-label":`Open ${n.name} agent: ${n.description}`,className:`focus-visible:ring-ring/70 flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-left text-[13px] leading-5 tracking-[-0.04px] select-none focus-visible:ring-2 focus-visible:outline-none`,onClick:()=>e.onSelect(t.item.id),children:[t.status===`Running`?(0,G.jsx)(bR,{className:n.tone}):(0,G.jsx)(yR,{className:n.tone}),(0,G.jsx)(`span`,{className:`text-foreground shrink-0 font-medium`,children:n.name}),(0,G.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate`,children:n.description}),(0,G.jsx)(`span`,{className:B(`text-muted-foreground shrink-0 text-xs`,t.status===`Failed`&&`text-destructive`,t.status===`Running`&&`text-shimmer`),children:t.status})]}),t.status===`Running`&&r!==null&&e.sessionId!==null&&(0,G.jsx)(jz,{label:`Stop ${n.name} agent`,onClick:()=>a({taskId:r,title:`${n.name} agent`})})]},t.item.id)})}),(0,G.jsx)(`h2`,{className:`text-muted-foreground px-1 pt-5 pb-1.5 text-xs font-medium`,children:`Tasks`}),s.tasks.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground px-1 py-1 text-xs`,children:`No background tasks in this thread.`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:[...s.tasks.filter(e=>e.status===`Running`),...s.tasks.filter(e=>e.status!==`Running`)].map(t=>{let n=t.taskId;return(0,G.jsxs)(`div`,{className:`bg-secondary hover:bg-accent flex items-center rounded-lg`,children:[(0,G.jsxs)(`button`,{type:`button`,"aria-label":`Open task: ${cR(t.item)}`,className:`focus-visible:ring-ring/70 flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-left text-[13px] leading-5 tracking-[-0.04px] select-none focus-visible:ring-2 focus-visible:outline-none`,onClick:()=>e.onSelect(t.item.id),children:[(0,G.jsx)(H,{icon:ts,className:B(`size-4 shrink-0`,t.status===`Running`?`text-foreground animate-pulse`:`text-muted-foreground`)}),(0,G.jsx)(`span`,{className:`text-foreground min-w-0 flex-1 truncate`,children:cR(t.item)}),(0,G.jsx)(`span`,{className:B(`text-muted-foreground shrink-0 text-xs`,t.status===`Failed`&&`text-destructive`,t.status===`Running`&&`text-shimmer`),children:t.status})]}),t.status===`Running`&&n!==null&&e.sessionId!==null&&(0,G.jsx)(jz,{label:`Stop task: ${cR(t.item)}`,onClick:()=>a({taskId:n,title:cR(t.item)})})]},t.item.id)})})]}),c!==void 0&&(0,G.jsx)(Fz,{item:c.item,agentId:c.agentId,running:c.status===`Running`,items:o,found:s,cwd:e.cwd,onSelect:e.onSelect},c.item.id),l!==void 0&&e.sessionId!==null&&(0,G.jsx)(Pz,{machine:e.machine,sessionId:e.sessionId,command:l.item.command,path:l.path,events:l.events,running:l.status===`Running`},l.item.id),(0,G.jsx)(Az,{machine:e.machine,sessionId:e.sessionId,stopping:i,onClose:()=>a(null)})]})}function Pz(e){let[t,n]=(0,W.useState)(void 0),[r,i]=(0,W.useState)(null),a=(0,W.useRef)(null),o=(0,W.useRef)(!0);(0,W.useEffect)(()=>{let t=e.path;if(t===null)return;let r=!0;async function a(t){try{let a=await L(e.machine,`tasks.output`,{sessionId:e.sessionId,path:t});if(!r)return;n(a),i(null)}catch(e){r&&i(Ht(e))}}a(t);let o=e.running?window.setInterval(()=>void a(t),2e3):null;return()=>{r=!1,o!==null&&window.clearInterval(o)}},[e.machine,e.sessionId,e.path,e.running]),(0,W.useLayoutEffect)(()=>{let e=a.current;e!==null&&o.current&&(e.scrollTop=e.scrollHeight)},[t,e.events]);let s=e.path===null?e.events.join(`
|
|
24
|
-
`):t?.text??``;return(0,G.jsxs)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain p-3`,onScroll:e=>{let t=e.currentTarget;o.current=t.scrollHeight-t.scrollTop-t.clientHeight<40},children:[e.command!==``&&(0,G.jsxs)(`p`,{className:`text-muted-foreground pb-2 font-mono text-xs [overflow-wrap:anywhere] whitespace-pre-wrap`,children:[`$ `,e.command]}),r!==null&&(0,G.jsx)(`p`,{className:`text-destructive text-xs`,children:r}),r===null&&e.path!==null&&t===void 0&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Loading…`}),r===null&&e.path!==null&&t===null&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`The output file no longer exists.`}),t?.truncated===!0&&(0,G.jsx)(`p`,{className:`text-muted-foreground pb-2 text-xs`,children:`Showing the end of the output.`}),e.path===null&&e.events.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No events yet.`}),t?.text===``&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:e.running?`No output yet.`:`No output.`}),s!==``&&(0,G.jsx)(`pre`,{className:`bg-secondary text-foreground rounded-lg p-3 font-mono text-xs leading-5 [overflow-wrap:anywhere] whitespace-pre-wrap select-text`,children:s})]})}function Fz(e){let t=(0,W.useRef)(null),n=(0,W.useRef)(!0),[r,i]=(0,W.useState)([]);(0,W.useLayoutEffect)(()=>{let e=t.current;e!==null&&n.current&&(e.scrollTop=e.scrollHeight)},[e.items,e.running]);function a(e){i(r.includes(e)?r.filter(t=>t!==e):[...r,e])}let o=e.items.filter(t=>t.parent===e.item.id),s=o.length===0;(0,W.useEffect)(()=>{s&&e.agentId!==null&&Ne(e.item.id,e.agentId)},[s,e.item.id,e.agentId]);let c=o.at(0),l=c?.kind===`user`?c:null,u=IR({prompt:null,first:!1,items:l===null?o:o.slice(1)},e.running?{partial:``}:null);return(0,G.jsxs)(`div`,{ref:t,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-4 pt-1 pb-8`,onScroll:e=>{let t=e.currentTarget;n.current=t.scrollHeight-t.scrollTop-t.clientHeight<40},children:[l!==null&&(0,G.jsx)(pR,{title:`Prompt`,pending:!1,grouped:!0,open:r.includes(`prompt`),onToggle:()=>a(`prompt`),children:(0,G.jsx)(ir,{text:l.text,className:`text-muted-foreground text-[13px]`})}),u.map((t,n)=>{let i=u[n-1];return(0,G.jsx)(`div`,{className:B(i===void 0?`pt-2`:t.kind===`working`?void 0:FR(t)&&FR(i)?`pt-2`:`pt-4`,t.kind===`assistant`&&`group/assistant`),children:(0,G.jsx)(Sz,{row:t,agents:e.found.agents,tasks:e.found.tasks,running:e.running,compacting:!1,fork:!1,expanded:r.includes(t.key),onToggle:a,onOpenTask:e.onSelect,rewind:!1,cwd:e.cwd})},t.key)})]})}var Iz=(0,W.lazy)(async()=>({default:(await hi(async()=>{let{DiffPanel:e}=await import(`./diff-panel-CeJqpNi8.js`);return{DiffPanel:e}},__vite__mapDeps([10,2,11,3,6,5,12,13,14,15,16,17,18,19,20,21,22]))).DiffPanel})),Lz=`text-foreground hover:bg-accent data-[pressed=true]:bg-accent relative grid h-7 min-w-7 cursor-pointer place-items-center rounded-lg border border-transparent [&_svg]:size-4 [&_svg]:opacity-80`;function Rz(e){let t=Hz(e),n=k(e=>e.prefs),r=k(e=>e.editor===null);return xr(()=>se({machine:e.selection.machine,projectId:e.selection.projectId}),r),(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t.filter(e=>n.toolbar.includes(e.id)).map(e=>(0,G.jsxs)(`button`,{className:Lz,"data-pressed":e.pressed,"aria-label":e.label,title:e.title,onClick:e.onSelect,children:[(0,G.jsx)(H,{icon:e.icon}),e.badge]},e.id)),e.children]})}),(0,G.jsx)(tr,{className:`w-44`,children:t.map(e=>(0,G.jsxs)(_r,{checked:n.toolbar.includes(e.id),onCheckedChange:t=>Ye({...n,toolbar:t?[...n.toolbar,e.id]:n.toolbar.filter(t=>t!==e.id)}),children:[(0,G.jsx)(H,{icon:e.icon}),e.label]},e.id))})]})}function zz(e){let t=e.session,n=k(e=>e.prefs.toolbar),r=Hz(e).filter(t=>e.mobile||!n.includes(t.id)),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsxs)(mn,{open:e.open,onOpenChange:e.onOpenChange,children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:B(Lz,`data-[state=open]:bg-accent`),"aria-label":`More`,title:`More`,children:[(0,G.jsx)(H,{icon:wr}),r.some(e=>e.attention)&&(0,G.jsx)(`span`,{className:`bg-muted-foreground ring-background absolute top-0.5 right-0.5 size-1.5 rounded-full ring-2`})]})}),(0,G.jsxs)(Dn,{className:`w-56 [&>[data-slot=dropdown-menu-separator]:first-child]:hidden`,align:`end`,children:[r.map(e=>(0,G.jsxs)(Mr,{onSelect:e.onSelect,children:[(0,G.jsx)(H,{icon:e.icon}),(0,G.jsx)(`span`,{className:`flex-1`,children:e.label}),e.detail]},e.id)),e.children,t!==void 0&&(0,G.jsx)(Bz,{session:t,mobile:e.mobile,onWarn:()=>s(!0),onRename:()=>a(t.title)})]})]}),t!==void 0&&i!==null&&(0,G.jsx)(oi,{open:!0,onOpenChange:e=>{e||a(null)},children:(0,G.jsx)($r,{children:(0,G.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&Je(t.machine,t.id,{title:n})},children:[(0,G.jsx)(ei,{children:(0,G.jsx)(ri,{children:`Rename thread`})}),(0,G.jsx)(Tp,{"aria-label":`Title`,value:i,onChange:e=>a(e.target.value)}),(0,G.jsxs)(si,{children:[(0,G.jsx)(U,{type:`button`,variant:`outline`,onClick:()=>a(null),children:`Cancel`}),(0,G.jsx)(U,{type:`submit`,children:`Rename`})]})]})})}),(0,G.jsx)(mr,{open:o,onOpenChange:s,children:(0,G.jsx)(Zn,{children:(0,G.jsx)(Vz,{session:t})})})]})}function Bz(e){let t=e.session,n=Ir(`sidebarScope`),r=k(e=>{let n=$e(e.machines,t.machine,t.id);return n?.running===!0||Object.values(n?.tasks??{}).includes(`running`)});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Pn,{}),(0,G.jsx)(zA,{session:t,context:!1,mobile:e.mobile,onDeactivate:()=>{r?e.onWarn():pt(t.machine,t.id,n)},onRename:e.onRename})]})}function Vz(e){let t=Ir(`sidebarScope`);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:`Stop running work?`}),(0,G.jsx)(Rn,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>{if(e.session===void 0)throw Error(`session is missing`);pt(e.session.machine,e.session.id,t)},children:`Stop and Mark Done`})]})]})}function Hz(e){let t=(0,W.useSyncExternalStore)(rI,()=>iI().alerts.length>0),n=(0,W.useSyncExternalStore)(rI,()=>iI().layout.tabs.filter(t=>t.projectId===e.selection.projectId).length),r=k(e=>{if(e.selection?.sessionId===null)return 0;let t=sR([...e.earlier,...e.items],Ct(e));return[...t.agents,...t.tasks].filter(e=>e.status===`Running`).length});return[{id:`diff`,label:`Diff`,title:`Diff`,icon:us,pressed:e.panel===`diff`,attention:e.changed,badge:e.changed&&(0,G.jsx)(`span`,{className:`bg-muted-foreground ring-background absolute top-0.5 right-0.5 size-1.5 rounded-full ring-2`}),detail:e.changed&&(0,G.jsx)(`span`,{className:`bg-muted-foreground size-1.5 rounded-full`}),onSelect:()=>e.onPanel(e.panel===`diff`?null:`diff`)},{id:`terminal`,label:`Terminal`,title:`Terminal (${z}+\`)`,icon:Zs,pressed:e.terminal,attention:t,badge:n>0&&(0,G.jsx)(`span`,{className:B(`absolute top-0 right-0 grid h-3 min-w-3 place-items-center rounded-full px-0.5 text-[8px] leading-none font-medium tabular-nums`,t?`bg-primary text-primary-foreground`:`text-foreground bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))]`),children:n}),detail:n>0&&(0,G.jsx)(`span`,{className:B(`text-xs tabular-nums`,t?`text-primary`:`text-muted-foreground`),children:n}),onSelect:()=>e.onTerminal(!e.terminal)},{id:`tasks`,label:`Tasks`,title:`Tasks`,icon:ec,pressed:e.panel===`tasks`,attention:r>0,badge:r>0&&(0,G.jsx)(`span`,{className:`text-foreground absolute top-0 right-0 grid h-3 min-w-3 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-0.5 text-[8px] leading-none font-medium tabular-nums`,children:r}),detail:r>0&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs tabular-nums`,children:r}),onSelect:()=>e.onPanel(e.panel===`tasks`?null:`tasks`)},{id:`browser`,label:`Browser`,title:`Browser`,icon:Uo,pressed:e.panel===`browser`,attention:!1,badge:null,detail:null,onSelect:()=>e.onPanel(e.panel===`browser`?null:`browser`)},{id:`editor`,label:`Editor`,title:`Editor`,icon:oc,pressed:!1,attention:!1,badge:null,detail:null,onSelect:()=>se({machine:e.selection.machine,projectId:e.selection.projectId})}]}function Uz(e){let t=k(t=>He(t,e.selection.machine,e.selection.projectId)?.path??``);return(0,G.jsxs)(G.Fragment,{children:[e.panel===`browser`&&(0,G.jsx)(Tz,{machine:e.selection.machine,onClose:()=>e.onPanel(null),mobile:e.mobile}),e.panel===`diff`&&(0,G.jsx)(W.Suspense,{children:(0,G.jsx)(Iz,{machine:e.selection.machine,projectId:e.selection.projectId,running:e.running,onClose:()=>e.onPanel(null),mobile:e.mobile},`${e.selection.machine} ${e.selection.projectId}`)}),e.panel===`tasks`&&(0,G.jsx)(Nz,{machine:e.selection.machine,cwd:t,sessionId:e.selection.sessionId,selected:e.selectedTask,onSelect:e.onSelectTask,onClose:()=>e.onPanel(null),mobile:e.mobile})]})}function Wz(){let e=k(e=>e.selection),t=k(e=>e.machines.length>0),n=ne();return n===null?e===null?t?(0,G.jsx)(`div`,{className:`bg-sidebar relative flex min-w-0 flex-1 pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:(0,G.jsx)(iR,{className:`min-w-0 flex-1 border-r-0`,mobile:!0})}):(0,G.jsx)(`main`,{className:`bg-background flex flex-1 overflow-y-auto pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:(0,G.jsx)(xk,{})}):(0,G.jsx)(Gz,{selection:e}):(0,G.jsx)(_L,{machine:n,mobile:!0,leading:(0,G.jsx)(U,{variant:`ghost`,size:`icon`,className:`ml-2`,"aria-label":`Back`,title:`Back`,onClick:()=>le(`chat`,()=>void yt.navigate({to:`/`,search:{},replace:!0})),children:(0,G.jsx)(H,{icon:Br,className:`text-foreground size-5`,strokeWidth:2})})})}function Gz(e){let t=k(t=>Ge(t,e.selection.machine)),n=k(t=>t.sessions.find(t=>t.machine===e.selection.machine&&t.id===e.selection.sessionId)),r=k(e=>n!==void 0&&e.generatingTitles.includes(P(n.machine,n.id))),i=cc(e.selection.machine,e.selection.projectId),a=k(Mt),o=k(t=>e.selection.projectId===`no-project`||He(t,e.selection.machine,e.selection.projectId)?.scratch===!0),s=Dh(e.selection.machine,t.status===`online`&&!o?e.selection.projectId:null,a),c=Oh({machine:e.selection.machine,projectId:e.selection.projectId,repos:s.repos,onRefresh:s.refresh}),l=(0,W.useSyncExternalStore)(rI,()=>iI().open),u=Ce({from:`__root__`,select:e=>e.panel??null}),[d,p]=(0,W.useState)(null),m=s.repos.some(e=>e.changed>0),h=!o&&(u!==null||l),g=(0,W.useCallback)(e=>{h?f(e):fe(e,`overlay`)},[h]),_=(0,W.useCallback)(e=>{p(null),e===null?Kz():g({panel:e,bottom:void 0})},[g]),v=(0,W.useCallback)(e=>{_(`tasks`),p(e)},[_]);function y(e){e?(pI(),g({panel:void 0,bottom:`terminal`})):Kz()}return(0,G.jsxs)(`main`,{className:`bg-background flex min-w-0 flex-1 flex-col overflow-hidden pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[(0,G.jsxs)(`header`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-1.5 px-2`,children:[(0,G.jsx)(U,{variant:`ghost`,size:`icon`,"aria-label":`Back`,onClick:()=>le(`chat`,it),children:(0,G.jsx)(H,{icon:Br,className:`text-foreground size-5`,strokeWidth:2})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-foreground truncate font-medium`,children:(0,G.jsx)(`span`,{className:B((r||e.selection.sessionId!==null&&n===void 0)&&`text-shimmer`),children:n?.title??`New thread`})}),t.status===`online`&&(0,G.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-1 text-xs`,children:[(0,G.jsx)(Of,{icon:t.icon,className:`size-3.5 shrink-0`}),(0,G.jsxs)(`span`,{className:`truncate`,children:[t.name,` / `,i]})]}),t.status!==`online`&&(0,G.jsxs)(`div`,{className:`text-warning-foreground truncate text-xs`,children:[t.status===`connecting`&&`Connecting to ${t.name}…`,t.status===`offline`&&`${t.name} is offline, reconnecting…`,t.status===`unpaired`&&`${t.name} needs pairing`]})]}),(0,G.jsx)(Zm,{}),!o&&(0,G.jsx)(zz,{selection:e.selection,mobile:!0,session:n,panel:u,terminal:l,changed:m,open:c.menuOpen,onOpenChange:c.setMenuOpen,onPanel:_,onTerminal:y,children:s.repos.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Pn,{}),(0,G.jsx)(kh,{git:c,collapsed:!0})]})}),(0,G.jsx)(Ah,{git:c})]}),(0,G.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,G.jsxs)(W.Fragment,{children:[(0,G.jsx)(bz,{onOpenTask:v}),(0,G.jsx)(qm,{})]},`${e.selection.machine} ${e.selection.sessionId??e.selection.projectId}`)}),(0,G.jsx)(ai,{open:h,onOpenChange:()=>_(null),children:(0,G.jsx)(li,{children:(0,G.jsxs)(ti,{"aria-describedby":void 0,className:`bg-background data-open:animate-in data-open:slide-in-from-right fixed inset-0 z-40 flex flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] text-sm duration-200 outline-none motion-reduce:animate-none`,children:[(0,G.jsxs)(di,{className:`sr-only`,children:[u===`diff`&&`Diff`,u===`tasks`&&`Tasks`,u===`browser`&&`Browser`,u===null&&`Terminal`]}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[u!==null&&(0,G.jsx)(Uz,{panel:u,selection:e.selection,running:a,selectedTask:d,onSelectTask:p,onPanel:_,mobile:!0}),u===null&&l&&(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(uL,{view:e.selection.projectId,mobile:!0,leading:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(U,{variant:`ghost`,size:`icon`,className:`mr-1.5 ml-2`,title:`Back`,"aria-label":`Back`,onClick:()=>y(!1),children:(0,G.jsx)(H,{icon:Br,className:`text-foreground size-5`,strokeWidth:2})}),(0,G.jsx)(`span`,{className:`text-foreground min-w-0 truncate text-[13px]`,children:`Terminal`})]})})})]})]})})})]})}function Kz(){le(`overlay`,()=>f({panel:void 0,bottom:void 0}))}var qz=(0,W.lazy)(async()=>({default:(await hi(async()=>{let{EditorDialog:e}=await import(`./editor-dialog-CEMtEtdH.js`);return{EditorDialog:e}},__vite__mapDeps([23,2,24,3,6,4,5,25,12,9,1,16,17,26,13,14,15,18,19,20,21,22,27,28,29,30,31]))).EditorDialog})),Jz=window.matchMedia(`(min-width: 768px)`),Yz=800,Xz=[`mod+k`,`mod+shift+p`];function Zz(e){return Jz.addEventListener(`change`,e),()=>Jz.removeEventListener(`change`,e)}function Qz(){let e=(0,W.useSyncExternalStore)(Zz,()=>Jz.matches),t=k(e=>e.editor),n=k(e=>e.exporting);return Qa(),vr(Xz,()=>ue(!R().paletteOpen),{enableOnFormTags:!0,preventDefault:!0}),(0,G.jsxs)(`div`,{className:`flex h-dvh text-sm`,children:[e?(0,G.jsx)(eB,{}):(0,G.jsx)(Wz,{}),(0,G.jsx)(MA,{}),e?(0,G.jsx)(pk,{}):(0,G.jsx)(yk,{}),t!==null&&(0,G.jsx)(W.Suspense,{children:(0,G.jsx)(qz,{machine:t.machine,projectId:t.projectId,onClose:()=>se(null)})}),n!==null&&(0,G.jsx)(Tk,{session:n}),(0,G.jsx)(dh,{}),(0,G.jsx)(sd,{position:e?`bottom-right`:`top-center`,swipeDirections:e?[`right`,`bottom`]:[`left`,`right`,`top`]})]})}function $z(e){f({panel:e??void 0})}function eB(){let e=k(e=>e.selection),t=k(e=>e.sessions),n=ne(),r=k(e=>e.selection===null?``:He(e,e.selection.machine,e.selection.projectId)?.path??``),i=k(e=>{let t=Pe(e);return t===null?null:Ge(e,t)}),[a,o]=(0,W.useState)(!0),s=(0,W.useRef)(null),[c,l]=(0,W.useState)(!1),u=Ce({from:`__root__`,select:e=>e.panel??null}),d=(0,W.useRef)(`diff`),[f,p]=(0,W.useState)(null),m=(0,W.useCallback)(e=>{p(e),$z(`tasks`)},[]),[h,g]=zr(`panelWidth`,540),[_,v]=(0,W.useState)(280),y=(0,W.useSyncExternalStore)(rI,()=>iI().open),b=k(Mt),x=k(e=>e.selection?.projectId===`no-project`||e.selection!==null&&He(e,e.selection.machine,e.selection.projectId)?.scratch===!0),S=Dh(e?.machine??``,i?.status===`online`&&!x?e?.projectId??null:null,b),C=Oh({machine:e?.machine??``,projectId:e?.projectId??``,repos:S.repos,onRefresh:S.refresh}),w=t.find(t=>t.machine===e?.machine&&t.id===e.sessionId),T=k(e=>w!==void 0&&e.generatingTitles.includes(P(w.machine,w.id))),E=cc(e?.machine??``,e?.projectId??``);return vr([`meta+backquote`,`ctrl+backquote`],e=>{e.stopPropagation(),fI(!iI().open)},{enableOnFormTags:!0,preventDefault:!0,eventListenerOptions:{capture:!0}}),vr([`mod+j`,`mod+shift+b`],e=>{e.stopPropagation(),$z(jt().panel===void 0?d.current:null)},{enableOnFormTags:!0,preventDefault:!0,eventListenerOptions:{capture:!0}}),(0,W.useEffect)(()=>{u!==null&&(d.current=u)},[u]),vr([`mod+b`,`mod+shift+j`],()=>o(e=>!e),{enableOnFormTags:!0,preventDefault:!0}),(0,W.useEffect)(()=>{if(n!==null)return;let e=s.current;if(e===null)throw Error(`header is not mounted`);let t=new ResizeObserver(e=>l(e[0].contentRect.width<Yz));return t.observe(e),()=>t.disconnect()},[n]),n===null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(iR,{className:B(`relative`,!a&&`hidden`),mobile:!1,onHide:()=>o(!1)}),!a&&(0,G.jsx)(`div`,{className:`fixed top-0 left-3 z-50 flex h-(--workspace-topbar-height) items-center`,children:(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Show sidebar`,title:`Show sidebar (${z}+B)`,onClick:()=>o(!0),children:(0,G.jsx)(H,{icon:sr})})}),(0,G.jsxs)(`main`,{className:`bg-background relative flex min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,G.jsxs)(`header`,{ref:s,className:B(`bg-background flex h-(--workspace-topbar-height) shrink-0 items-center gap-3 pr-3 pl-[3.25rem]`,a&&`pl-5`),children:[e!==null&&i!==null&&(0,G.jsx)(`nav`,{className:`min-w-0 flex-1`,children:(0,G.jsxs)(`ol`,{className:`flex min-w-0 items-center gap-3 text-sm`,children:[(0,G.jsxs)(`li`,{className:`text-icon-muted flex shrink-0 items-center gap-1.5`,children:[(0,G.jsx)(Of,{icon:i.icon,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`max-w-40 truncate`,children:i.name})]}),(0,G.jsx)(`li`,{"aria-hidden":!0,className:`text-icon-muted shrink-0`,children:`/`}),(0,G.jsxs)(`li`,{className:`text-muted-foreground flex min-w-0 shrink items-center gap-1.5 font-medium`,title:`${i.name}:${r}`,children:[(0,G.jsx)(mc,{machine:e.machine,projectId:e.projectId,className:`size-3.5`}),(0,G.jsx)(`span`,{className:`max-w-40 truncate`,children:E})]}),(0,G.jsx)(`li`,{"aria-hidden":!0,className:`text-icon-muted shrink-0`,children:`/`}),(0,G.jsxs)(`li`,{className:B(`text-foreground flex min-w-10 items-center gap-2 font-medium`,a&&`flex-1`),children:[(0,G.jsx)(`span`,{className:B(`truncate`,(T||e.sessionId!==null&&w===void 0)&&`text-shimmer`),children:w?.title??`New thread`}),(0,G.jsx)(Zm,{})]}),!a&&(0,G.jsx)(`li`,{className:`shrink-0`,children:(0,G.jsx)(IL,{hideDone:!0})})]})}),e===null&&!a&&(0,G.jsx)(IL,{hideDone:!0}),e===null&&(0,G.jsx)(`span`,{className:`flex-1`}),i!==null&&i.status!==`online`&&(0,G.jsxs)(`span`,{className:`text-warning-foreground shrink-0 text-xs`,children:[i.status===`connecting`&&`Connecting to ${i.name}…`,i.status===`offline`&&`${i.name} is offline, reconnecting…`,i.status===`unpaired`&&`${i.name} needs pairing`]}),e!==null&&!x&&(0,G.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[!c&&S.repos.length>0&&(0,G.jsx)(jh,{machine:e.machine,projectId:e.projectId,repos:S.repos,onRefresh:S.refresh}),!c&&S.repos.length>0&&(0,G.jsx)(`span`,{className:`bg-foreground/15 mr-1 ml-2.5 h-4 w-px`}),(0,G.jsx)(Rz,{selection:e,panel:u,terminal:y,changed:S.repos.some(e=>e.changed>0),onPanel:e=>{p(null),$z(e)},onTerminal:fI,children:(0,G.jsx)(zz,{selection:e,mobile:!1,session:w,panel:u,terminal:y,changed:S.repos.some(e=>e.changed>0),open:C.menuOpen,onOpenChange:C.setMenuOpen,onPanel:e=>{p(null),$z(e)},onTerminal:fI,children:c&&S.repos.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Pn,{}),(0,G.jsx)(kh,{git:C,collapsed:!0})]})})})]})]}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden`,children:[(0,G.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[i===null&&(0,G.jsx)(xk,{}),e===null&&i!==null&&(0,G.jsx)(`div`,{className:`grid flex-1 place-items-center p-6 text-center`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-foreground text-3xl font-normal tracking-tight`,children:`Pick a thread, or start one`}),(0,G.jsx)(`p`,{className:`text-muted-foreground mt-2 text-sm`,children:`Open a project from the sidebar to talk to Claude.`})]})}),e!==null&&(0,G.jsxs)(W.Fragment,{children:[(0,G.jsx)(bz,{onOpenTask:m}),(0,G.jsx)(qm,{})]},`${e.machine} ${e.sessionId??e.projectId}`)]}),e!==null&&y&&!x&&(0,G.jsxs)(`aside`,{className:`border-border/80 bg-background relative shrink-0 overflow-hidden border-t`,style:{height:_},children:[(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,className:`group absolute inset-x-0 top-0 z-30 h-1.5 cursor-row-resize touch-none select-none`,onPointerDown:e=>Vt(e,e=>{let t=Math.max(120,Math.floor(window.innerHeight*.8));v(Math.min(t,Math.max(120,window.innerHeight-e.clientY)))}),children:(0,G.jsx)(`span`,{className:`group-hover:bg-border group-active:bg-primary/60 pointer-events-none absolute inset-x-0 top-0 h-px transition-colors`})}),(0,G.jsx)(uL,{view:e.projectId})]})]}),e!==null&&u!==null&&!x&&(0,G.jsxs)(`div`,{className:`relative flex shrink-0`,style:{width:h},children:[(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,className:`group absolute inset-y-0 -left-1 z-20 w-2 cursor-col-resize select-none`,onPointerDown:e=>Vt(e,e=>{let t=Math.max(360,Math.floor(window.innerWidth*.7)),n=Math.min(t,Math.max(360,window.innerWidth-e.clientX));g(n)}),children:(0,G.jsx)(`span`,{className:`group-hover:bg-border group-active:bg-primary/60 pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 transition-colors`})}),(0,G.jsx)(`div`,{className:`bg-background flex min-w-0 flex-1 flex-col overflow-hidden rounded-tl-lg border-t border-l`,children:(0,G.jsx)(Uz,{panel:u,selection:e,running:b,selectedTask:f,onSelectTask:p,onPanel:$z,mobile:!1})})]})]})]}),(0,G.jsx)(Ah,{git:C})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(iR,{className:B(`relative`,!a&&`hidden`),mobile:!1,onHide:()=>o(!1)}),(0,G.jsx)(_L,{machine:n,mobile:!1,leading:!a&&(0,G.jsx)(U,{variant:`ghost`,size:`icon-xs`,"aria-label":`Show sidebar`,title:`Show sidebar (${z}+B)`,onClick:()=>o(!0),children:(0,G.jsx)(H,{icon:sr})})})]})}var tB=Fe.withTag(`app`),nB=class extends W.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){tB.error(`a component crashed:`,e,t.componentStack)}render(){let e=this.state.error;return e===null?this.props.children:(0,G.jsxs)(`div`,{className:`flex h-dvh flex-col items-center justify-center gap-3 p-4 text-center`,children:[(0,G.jsx)(`p`,{className:`font-medium`,children:`Something went wrong`}),(0,G.jsx)(`p`,{className:`text-muted-foreground max-w-xl text-sm whitespace-pre-wrap`,children:e.message}),(0,G.jsx)(U,{onClick:()=>location.reload(),children:`Reload`})]})}},rB=[`typescript`,`tsx`,`javascript`],iB=`import { readFile } from 'node:fs/promises'
|
|
24
|
+
`):t?.text??``;return(0,G.jsxs)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain p-3`,onScroll:e=>{let t=e.currentTarget;o.current=t.scrollHeight-t.scrollTop-t.clientHeight<40},children:[e.command!==``&&(0,G.jsxs)(`p`,{className:`text-muted-foreground pb-2 font-mono text-xs [overflow-wrap:anywhere] whitespace-pre-wrap`,children:[`$ `,e.command]}),r!==null&&(0,G.jsx)(`p`,{className:`text-destructive text-xs`,children:r}),r===null&&e.path!==null&&t===void 0&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Loading…`}),r===null&&e.path!==null&&t===null&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`The output file no longer exists.`}),t?.truncated===!0&&(0,G.jsx)(`p`,{className:`text-muted-foreground pb-2 text-xs`,children:`Showing the end of the output.`}),e.path===null&&e.events.length===0&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No events yet.`}),t?.text===``&&(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:e.running?`No output yet.`:`No output.`}),s!==``&&(0,G.jsx)(`pre`,{className:`bg-secondary text-foreground rounded-lg p-3 font-mono text-xs leading-5 [overflow-wrap:anywhere] whitespace-pre-wrap select-text`,children:s})]})}function Fz(e){let t=(0,W.useRef)(null),n=(0,W.useRef)(!0),[r,i]=(0,W.useState)([]);(0,W.useLayoutEffect)(()=>{let e=t.current;e!==null&&n.current&&(e.scrollTop=e.scrollHeight)},[e.items,e.running]);function a(e){i(r.includes(e)?r.filter(t=>t!==e):[...r,e])}let o=e.items.filter(t=>t.parent===e.item.id),s=o.length===0;(0,W.useEffect)(()=>{s&&e.agentId!==null&&Ne(e.item.id,e.agentId)},[s,e.item.id,e.agentId]);let c=o.at(0),l=c?.kind===`user`?c:null,u=IR({prompt:null,first:!1,items:l===null?o:o.slice(1)},e.running?{partial:``}:null);return(0,G.jsxs)(`div`,{ref:t,className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain px-4 pt-1 pb-8`,onScroll:e=>{let t=e.currentTarget;n.current=t.scrollHeight-t.scrollTop-t.clientHeight<40},children:[l!==null&&(0,G.jsx)(pR,{title:`Prompt`,pending:!1,grouped:!0,open:r.includes(`prompt`),onToggle:()=>a(`prompt`),children:(0,G.jsx)(ir,{text:l.text,className:`text-muted-foreground text-[13px]`})}),u.map((t,n)=>{let i=u[n-1];return(0,G.jsx)(`div`,{className:B(i===void 0?`pt-2`:t.kind===`working`?void 0:FR(t)&&FR(i)?`pt-2`:`pt-4`,t.kind===`assistant`&&`group/assistant`),children:(0,G.jsx)(Sz,{row:t,agents:e.found.agents,tasks:e.found.tasks,running:e.running,compacting:!1,fork:!1,expanded:r.includes(t.key),onToggle:a,onOpenTask:e.onSelect,rewind:!1,cwd:e.cwd})},t.key)})]})}var Iz=(0,W.lazy)(async()=>({default:(await hi(async()=>{let{DiffPanel:e}=await import(`./diff-panel-CeJqpNi8.js`);return{DiffPanel:e}},__vite__mapDeps([10,2,11,3,6,5,12,13,14,15,16,17,18,19,20,21,22]))).DiffPanel})),Lz=`text-foreground hover:bg-accent data-[pressed=true]:bg-accent relative grid h-7 min-w-7 cursor-pointer place-items-center rounded-lg border border-transparent [&_svg]:size-4 [&_svg]:opacity-80`;function Rz(e){let t=Hz(e),n=k(e=>e.prefs),r=k(e=>e.editor===null);return xr(()=>se({machine:e.selection.machine,projectId:e.selection.projectId}),r),(0,G.jsxs)(ur,{children:[(0,G.jsx)(Yn,{asChild:!0,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t.filter(e=>n.toolbar.includes(e.id)).map(e=>(0,G.jsxs)(`button`,{className:Lz,"data-pressed":e.pressed,"aria-label":e.label,title:e.title,onClick:e.onSelect,children:[(0,G.jsx)(H,{icon:e.icon}),e.badge]},e.id)),e.children]})}),(0,G.jsx)(tr,{className:`w-44`,children:t.map(e=>(0,G.jsxs)(_r,{checked:n.toolbar.includes(e.id),onCheckedChange:t=>Ye({...n,toolbar:t?[...n.toolbar,e.id]:n.toolbar.filter(t=>t!==e.id)}),children:[(0,G.jsx)(H,{icon:e.icon}),e.label]},e.id))})]})}function zz(e){let t=e.session,n=k(e=>e.prefs.toolbar),r=Hz(e).filter(t=>e.mobile||!n.includes(t.id)),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsxs)(mn,{open:e.open,onOpenChange:e.onOpenChange,children:[(0,G.jsx)(hn,{asChild:!0,children:(0,G.jsxs)(`button`,{className:B(Lz,`data-[state=open]:bg-accent`),"aria-label":`More`,title:`More`,children:[(0,G.jsx)(H,{icon:wr}),r.some(e=>e.attention)&&(0,G.jsx)(`span`,{className:`bg-muted-foreground ring-background absolute top-0.5 right-0.5 size-1.5 rounded-full ring-2`})]})}),(0,G.jsxs)(Dn,{className:`w-56 [&>[data-slot=dropdown-menu-separator]:first-child]:hidden`,align:`end`,children:[r.map(e=>(0,G.jsxs)(Mr,{onSelect:e.onSelect,children:[(0,G.jsx)(H,{icon:e.icon}),(0,G.jsx)(`span`,{className:`flex-1`,children:e.label}),e.detail]},e.id)),e.children,t!==void 0&&(0,G.jsx)(Bz,{session:t,mobile:e.mobile,onWarn:()=>s(!0),onRename:()=>a(t.title)})]})]}),t!==void 0&&i!==null&&(0,G.jsx)(oi,{open:!0,onOpenChange:e=>{e||a(null)},children:(0,G.jsx)($r,{children:(0,G.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault();let n=i.trim();a(null),n!==``&&n!==t.title&&Je(t.machine,t.id,{title:n})},children:[(0,G.jsx)(ei,{children:(0,G.jsx)(ri,{children:`Rename thread`})}),(0,G.jsx)(Tp,{"aria-label":`Title`,value:i,onChange:e=>a(e.target.value)}),(0,G.jsxs)(si,{children:[(0,G.jsx)(U,{type:`button`,variant:`outline`,onClick:()=>a(null),children:`Cancel`}),(0,G.jsx)(U,{type:`submit`,children:`Rename`})]})]})})}),(0,G.jsx)(mr,{open:o,onOpenChange:s,children:(0,G.jsx)(Zn,{children:(0,G.jsx)(Vz,{session:t})})})]})}function Bz(e){let t=e.session,n=Ir(`sidebarScope`),r=k(e=>{let n=$e(e.machines,t.machine,t.id);return n?.running===!0||Object.values(n?.tasks??{}).includes(`running`)});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Pn,{}),(0,G.jsx)(zA,{session:t,context:!1,mobile:e.mobile,onDeactivate:()=>{r?e.onWarn():pt(t.machine,t.id,n)},onRename:e.onRename})]})}function Vz(e){let t=Ir(`sidebarScope`);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Ar,{children:[(0,G.jsx)(Hn,{children:`Stop running work?`}),(0,G.jsx)(Rn,{children:`The agent or background tasks are running. Do you really want to stop them?`})]}),(0,G.jsxs)(Tr,{children:[(0,G.jsx)($n,{children:`Cancel`}),(0,G.jsx)(cr,{variant:`destructive`,onClick:()=>{if(e.session===void 0)throw Error(`session is missing`);pt(e.session.machine,e.session.id,t)},children:`Stop and Mark Done`})]})]})}function Hz(e){let t=(0,W.useSyncExternalStore)(rI,()=>iI().alerts.length>0),n=(0,W.useSyncExternalStore)(rI,()=>iI().layout.tabs.filter(t=>t.projectId===e.selection.projectId).length),r=k(e=>{if(e.selection?.sessionId===null)return 0;let t=sR([...e.earlier,...e.items],Ct(e));return[...t.agents,...t.tasks].filter(e=>e.status===`Running`).length});return[{id:`diff`,label:`Diff`,title:`Diff`,icon:us,pressed:e.panel===`diff`,attention:e.changed,badge:e.changed&&(0,G.jsx)(`span`,{className:`bg-muted-foreground ring-background absolute top-0.5 right-0.5 size-1.5 rounded-full ring-2`}),detail:e.changed&&(0,G.jsx)(`span`,{className:`bg-muted-foreground size-1.5 rounded-full`}),onSelect:()=>e.onPanel(e.panel===`diff`?null:`diff`)},{id:`terminal`,label:`Terminal`,title:`Terminal (${z}+\`)`,icon:Zs,pressed:e.terminal,attention:t,badge:n>0&&(0,G.jsx)(`span`,{className:B(`absolute top-0 right-0 grid h-3 min-w-3 place-items-center rounded-full px-0.5 text-[8px] leading-none font-medium tabular-nums`,t?`bg-primary text-primary-foreground`:`text-foreground bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))]`),children:n}),detail:n>0&&(0,G.jsx)(`span`,{className:B(`text-xs tabular-nums`,t?`text-primary`:`text-muted-foreground`),children:n}),onSelect:()=>e.onTerminal(!e.terminal)},{id:`tasks`,label:`Tasks`,title:`Tasks`,icon:ec,pressed:e.panel===`tasks`,attention:r>0,badge:r>0&&(0,G.jsx)(`span`,{className:`text-foreground absolute top-0 right-0 grid h-3 min-w-3 place-items-center rounded-full bg-[color-mix(in_srgb,var(--foreground)_22%,var(--background))] px-0.5 text-[8px] leading-none font-medium tabular-nums`,children:r}),detail:r>0&&(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs tabular-nums`,children:r}),onSelect:()=>e.onPanel(e.panel===`tasks`?null:`tasks`)},{id:`browser`,label:`Browser`,title:`Browser`,icon:Uo,pressed:e.panel===`browser`,attention:!1,badge:null,detail:null,onSelect:()=>e.onPanel(e.panel===`browser`?null:`browser`)},{id:`editor`,label:`Editor`,title:`Editor`,icon:oc,pressed:!1,attention:!1,badge:null,detail:null,onSelect:()=>se({machine:e.selection.machine,projectId:e.selection.projectId})}]}function Uz(e){let t=k(t=>He(t,e.selection.machine,e.selection.projectId)?.path??``);return(0,G.jsxs)(G.Fragment,{children:[e.panel===`browser`&&(0,G.jsx)(Tz,{machine:e.selection.machine,onClose:()=>e.onPanel(null),mobile:e.mobile}),e.panel===`diff`&&(0,G.jsx)(W.Suspense,{children:(0,G.jsx)(Iz,{machine:e.selection.machine,projectId:e.selection.projectId,running:e.running,onClose:()=>e.onPanel(null),mobile:e.mobile},`${e.selection.machine} ${e.selection.projectId}`)}),e.panel===`tasks`&&(0,G.jsx)(Nz,{machine:e.selection.machine,cwd:t,sessionId:e.selection.sessionId,selected:e.selectedTask,onSelect:e.onSelectTask,onClose:()=>e.onPanel(null),mobile:e.mobile})]})}function Wz(){let e=k(e=>e.selection),t=k(e=>e.machines.length>0),n=ne();return n===null?e===null?t?(0,G.jsx)(`div`,{className:`bg-sidebar relative flex min-w-0 flex-1 pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:(0,G.jsx)(iR,{className:`min-w-0 flex-1 border-r-0`,mobile:!0})}):(0,G.jsx)(`main`,{className:`bg-background flex flex-1 overflow-y-auto pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:(0,G.jsx)(xk,{})}):(0,G.jsx)(Gz,{selection:e}):(0,G.jsx)(_L,{machine:n,mobile:!0,leading:(0,G.jsx)(U,{variant:`ghost`,size:`icon`,className:`ml-2`,"aria-label":`Back`,title:`Back`,onClick:()=>le(`chat`,()=>void yt.navigate({to:`/`,search:{},replace:!0})),children:(0,G.jsx)(H,{icon:Br,className:`text-foreground size-5`,strokeWidth:2})})})}function Gz(e){let t=k(t=>Ge(t,e.selection.machine)),n=k(t=>t.sessions.find(t=>t.machine===e.selection.machine&&t.id===e.selection.sessionId)),r=k(e=>n!==void 0&&e.generatingTitles.includes(P(n.machine,n.id))),i=cc(e.selection.machine,e.selection.projectId),a=k(Mt),o=k(t=>e.selection.projectId===`no-project`||He(t,e.selection.machine,e.selection.projectId)?.scratch===!0),s=Dh(e.selection.machine,t.status===`online`&&!o?e.selection.projectId:null,a),c=Oh({machine:e.selection.machine,projectId:e.selection.projectId,repos:s.repos,onRefresh:s.refresh}),l=(0,W.useSyncExternalStore)(rI,()=>iI().open),u=Ce({from:`__root__`,select:e=>e.panel??null}),[d,p]=(0,W.useState)(null),m=s.repos.some(e=>e.changed>0),h=!o&&(u!==null||l),g=(0,W.useCallback)(e=>{h?f(e):fe(e,`overlay`)},[h]),_=(0,W.useCallback)(e=>{p(null),e===null?Kz():g({panel:e,bottom:void 0})},[g]),v=(0,W.useCallback)(e=>{_(`tasks`),p(e)},[_]);function y(e){e?(pI(),g({panel:void 0,bottom:`terminal`})):Kz()}return(0,G.jsxs)(`main`,{className:`bg-background flex min-w-0 flex-1 flex-col overflow-hidden pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[(0,G.jsxs)(`header`,{className:`flex h-(--workspace-topbar-height) shrink-0 items-center gap-1.5 px-2`,children:[(0,G.jsx)(U,{variant:`ghost`,size:`icon`,"aria-label":`Back`,onClick:()=>le(`chat`,it),children:(0,G.jsx)(H,{icon:Br,className:`text-foreground size-5`,strokeWidth:2})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-foreground truncate font-medium`,children:(0,G.jsx)(`span`,{className:B((r||e.selection.sessionId!==null&&n===void 0)&&`text-shimmer`),children:n?.title??`New thread`})}),t.status===`online`&&(0,G.jsxs)(`div`,{className:`text-muted-foreground flex items-center gap-1 text-xs`,children:[(0,G.jsx)(Of,{icon:t.icon,className:`size-3.5 shrink-0`}),(0,G.jsxs)(`span`,{className:`truncate`,children:[t.name,` / `,i]})]}),t.status!==`online`&&(0,G.jsxs)(`div`,{className:`text-warning-foreground truncate text-xs`,children:[t.status===`connecting`&&`Connecting to ${t.name}…`,t.status===`offline`&&`${t.name} is offline, reconnecting…`,t.status===`unpaired`&&`${t.name} needs pairing`]})]}),(0,G.jsx)(Zm,{}),!o&&(0,G.jsx)(zz,{selection:e.selection,mobile:!0,session:n,panel:u,terminal:l,changed:m,open:c.menuOpen,onOpenChange:c.setMenuOpen,onPanel:_,onTerminal:y,children:s.repos.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Pn,{}),(0,G.jsx)(kh,{git:c,collapsed:!0})]})}),(0,G.jsx)(Ah,{git:c})]}),(0,G.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,G.jsxs)(W.Fragment,{children:[(0,G.jsx)(bz,{onOpenTask:v}),(0,G.jsx)(qm,{})]},`${e.selection.machine} ${e.selection.sessionId??e.selection.projectId}`)}),(0,G.jsx)(ai,{open:h,onOpenChange:()=>_(null),children:(0,G.jsx)(li,{children:(0,G.jsxs)(ti,{"aria-describedby":void 0,className:`bg-background data-open:animate-in data-open:slide-in-from-right fixed inset-0 z-40 flex flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] text-sm duration-200 outline-none motion-reduce:animate-none`,children:[(0,G.jsxs)(di,{className:`sr-only`,children:[u===`diff`&&`Diff`,u===`tasks`&&`Tasks`,u===`browser`&&`Browser`,u===null&&`Terminal`]}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[u!==null&&(0,G.jsx)(Uz,{panel:u,selection:e.selection,running:a,selectedTask:d,onSelectTask:p,onPanel:_,mobile:!0}),u===null&&l&&(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(uL,{view:e.selection.projectId,mobile:!0,leading:(0,G.jsx)(U,{variant:`ghost`,size:`icon`,className:`ml-2`,title:`Back`,"aria-label":`Back`,onClick:()=>y(!1),children:(0,G.jsx)(H,{icon:Br,className:`text-foreground size-5`,strokeWidth:2})})})})]})]})})})]})}function Kz(){le(`overlay`,()=>f({panel:void 0,bottom:void 0}))}var qz=(0,W.lazy)(async()=>({default:(await hi(async()=>{let{EditorDialog:e}=await import(`./editor-dialog-CEMtEtdH.js`);return{EditorDialog:e}},__vite__mapDeps([23,2,24,3,6,4,5,25,12,9,1,16,17,26,13,14,15,18,19,20,21,22,27,28,29,30,31]))).EditorDialog})),Jz=window.matchMedia(`(min-width: 768px)`),Yz=800,Xz=[`mod+k`,`mod+shift+p`];function Zz(e){return Jz.addEventListener(`change`,e),()=>Jz.removeEventListener(`change`,e)}function Qz(){let e=(0,W.useSyncExternalStore)(Zz,()=>Jz.matches),t=k(e=>e.editor),n=k(e=>e.exporting);return Qa(),vr(Xz,()=>ue(!R().paletteOpen),{enableOnFormTags:!0,preventDefault:!0}),(0,G.jsxs)(`div`,{className:`flex h-dvh text-sm`,children:[e?(0,G.jsx)(eB,{}):(0,G.jsx)(Wz,{}),(0,G.jsx)(MA,{}),e?(0,G.jsx)(pk,{}):(0,G.jsx)(yk,{}),t!==null&&(0,G.jsx)(W.Suspense,{children:(0,G.jsx)(qz,{machine:t.machine,projectId:t.projectId,onClose:()=>se(null)})}),n!==null&&(0,G.jsx)(Tk,{session:n}),(0,G.jsx)(dh,{}),(0,G.jsx)(sd,{position:e?`bottom-right`:`top-center`,swipeDirections:e?[`right`,`bottom`]:[`left`,`right`,`top`]})]})}function $z(e){f({panel:e??void 0})}function eB(){let e=k(e=>e.selection),t=k(e=>e.sessions),n=ne(),r=k(e=>e.selection===null?``:He(e,e.selection.machine,e.selection.projectId)?.path??``),i=k(e=>{let t=Pe(e);return t===null?null:Ge(e,t)}),[a,o]=(0,W.useState)(!0),s=(0,W.useRef)(null),[c,l]=(0,W.useState)(!1),u=Ce({from:`__root__`,select:e=>e.panel??null}),d=(0,W.useRef)(`diff`),[f,p]=(0,W.useState)(null),m=(0,W.useCallback)(e=>{p(e),$z(`tasks`)},[]),[h,g]=zr(`panelWidth`,540),[_,v]=(0,W.useState)(280),y=(0,W.useSyncExternalStore)(rI,()=>iI().open),b=k(Mt),x=k(e=>e.selection?.projectId===`no-project`||e.selection!==null&&He(e,e.selection.machine,e.selection.projectId)?.scratch===!0),S=Dh(e?.machine??``,i?.status===`online`&&!x?e?.projectId??null:null,b),C=Oh({machine:e?.machine??``,projectId:e?.projectId??``,repos:S.repos,onRefresh:S.refresh}),w=t.find(t=>t.machine===e?.machine&&t.id===e.sessionId),T=k(e=>w!==void 0&&e.generatingTitles.includes(P(w.machine,w.id))),E=cc(e?.machine??``,e?.projectId??``);return vr([`meta+backquote`,`ctrl+backquote`],e=>{e.stopPropagation(),fI(!iI().open)},{enableOnFormTags:!0,preventDefault:!0,eventListenerOptions:{capture:!0}}),vr([`mod+j`,`mod+shift+b`],e=>{e.stopPropagation(),$z(jt().panel===void 0?d.current:null)},{enableOnFormTags:!0,preventDefault:!0,eventListenerOptions:{capture:!0}}),(0,W.useEffect)(()=>{u!==null&&(d.current=u)},[u]),vr([`mod+b`,`mod+shift+j`],()=>o(e=>!e),{enableOnFormTags:!0,preventDefault:!0}),(0,W.useEffect)(()=>{if(n!==null)return;let e=s.current;if(e===null)throw Error(`header is not mounted`);let t=new ResizeObserver(e=>l(e[0].contentRect.width<Yz));return t.observe(e),()=>t.disconnect()},[n]),n===null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(iR,{className:B(`relative`,!a&&`hidden`),mobile:!1,onHide:()=>o(!1)}),!a&&(0,G.jsx)(`div`,{className:`fixed top-0 left-3 z-50 flex h-(--workspace-topbar-height) items-center`,children:(0,G.jsx)(U,{variant:`ghost`,size:`icon-sm`,"aria-label":`Show sidebar`,title:`Show sidebar (${z}+B)`,onClick:()=>o(!0),children:(0,G.jsx)(H,{icon:sr})})}),(0,G.jsxs)(`main`,{className:`bg-background relative flex min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,G.jsxs)(`header`,{ref:s,className:B(`bg-background flex h-(--workspace-topbar-height) shrink-0 items-center gap-3 pr-3 pl-[3.25rem]`,a&&`pl-5`),children:[e!==null&&i!==null&&(0,G.jsx)(`nav`,{className:`min-w-0 flex-1`,children:(0,G.jsxs)(`ol`,{className:`flex min-w-0 items-center gap-3 text-sm`,children:[(0,G.jsxs)(`li`,{className:`text-icon-muted flex shrink-0 items-center gap-1.5`,children:[(0,G.jsx)(Of,{icon:i.icon,className:`size-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`max-w-40 truncate`,children:i.name})]}),(0,G.jsx)(`li`,{"aria-hidden":!0,className:`text-icon-muted shrink-0`,children:`/`}),(0,G.jsxs)(`li`,{className:`text-muted-foreground flex min-w-0 shrink items-center gap-1.5 font-medium`,title:`${i.name}:${r}`,children:[(0,G.jsx)(mc,{machine:e.machine,projectId:e.projectId,className:`size-3.5`}),(0,G.jsx)(`span`,{className:`max-w-40 truncate`,children:E})]}),(0,G.jsx)(`li`,{"aria-hidden":!0,className:`text-icon-muted shrink-0`,children:`/`}),(0,G.jsxs)(`li`,{className:B(`text-foreground flex min-w-10 items-center gap-2 font-medium`,a&&`flex-1`),children:[(0,G.jsx)(`span`,{className:B(`truncate`,(T||e.sessionId!==null&&w===void 0)&&`text-shimmer`),children:w?.title??`New thread`}),(0,G.jsx)(Zm,{})]}),!a&&(0,G.jsx)(`li`,{className:`shrink-0`,children:(0,G.jsx)(IL,{hideDone:!0})})]})}),e===null&&!a&&(0,G.jsx)(IL,{hideDone:!0}),e===null&&(0,G.jsx)(`span`,{className:`flex-1`}),i!==null&&i.status!==`online`&&(0,G.jsxs)(`span`,{className:`text-warning-foreground shrink-0 text-xs`,children:[i.status===`connecting`&&`Connecting to ${i.name}…`,i.status===`offline`&&`${i.name} is offline, reconnecting…`,i.status===`unpaired`&&`${i.name} needs pairing`]}),e!==null&&!x&&(0,G.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[!c&&S.repos.length>0&&(0,G.jsx)(jh,{machine:e.machine,projectId:e.projectId,repos:S.repos,onRefresh:S.refresh}),!c&&S.repos.length>0&&(0,G.jsx)(`span`,{className:`bg-foreground/15 mr-1 ml-2.5 h-4 w-px`}),(0,G.jsx)(Rz,{selection:e,panel:u,terminal:y,changed:S.repos.some(e=>e.changed>0),onPanel:e=>{p(null),$z(e)},onTerminal:fI,children:(0,G.jsx)(zz,{selection:e,mobile:!1,session:w,panel:u,terminal:y,changed:S.repos.some(e=>e.changed>0),open:C.menuOpen,onOpenChange:C.setMenuOpen,onPanel:e=>{p(null),$z(e)},onTerminal:fI,children:c&&S.repos.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Pn,{}),(0,G.jsx)(kh,{git:C,collapsed:!0})]})})})]})]}),(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden`,children:[(0,G.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[i===null&&(0,G.jsx)(xk,{}),e===null&&i!==null&&(0,G.jsx)(`div`,{className:`grid flex-1 place-items-center p-6 text-center`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-foreground text-3xl font-normal tracking-tight`,children:`Pick a thread, or start one`}),(0,G.jsx)(`p`,{className:`text-muted-foreground mt-2 text-sm`,children:`Open a project from the sidebar to talk to Claude.`})]})}),e!==null&&(0,G.jsxs)(W.Fragment,{children:[(0,G.jsx)(bz,{onOpenTask:m}),(0,G.jsx)(qm,{})]},`${e.machine} ${e.sessionId??e.projectId}`)]}),e!==null&&y&&!x&&(0,G.jsxs)(`aside`,{className:`border-border/80 bg-background relative shrink-0 overflow-hidden border-t`,style:{height:_},children:[(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,className:`group absolute inset-x-0 top-0 z-30 h-1.5 cursor-row-resize touch-none select-none`,onPointerDown:e=>Vt(e,e=>{let t=Math.max(120,Math.floor(window.innerHeight*.8));v(Math.min(t,Math.max(120,window.innerHeight-e.clientY)))}),children:(0,G.jsx)(`span`,{className:`group-hover:bg-border group-active:bg-primary/60 pointer-events-none absolute inset-x-0 top-0 h-px transition-colors`})}),(0,G.jsx)(uL,{view:e.projectId})]})]}),e!==null&&u!==null&&!x&&(0,G.jsxs)(`div`,{className:`relative flex shrink-0`,style:{width:h},children:[(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,className:`group absolute inset-y-0 -left-1 z-20 w-2 cursor-col-resize select-none`,onPointerDown:e=>Vt(e,e=>{let t=Math.max(360,Math.floor(window.innerWidth*.7)),n=Math.min(t,Math.max(360,window.innerWidth-e.clientX));g(n)}),children:(0,G.jsx)(`span`,{className:`group-hover:bg-border group-active:bg-primary/60 pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 transition-colors`})}),(0,G.jsx)(`div`,{className:`bg-background flex min-w-0 flex-1 flex-col overflow-hidden rounded-tl-lg border-t border-l`,children:(0,G.jsx)(Uz,{panel:u,selection:e,running:b,selectedTask:f,onSelectTask:p,onPanel:$z,mobile:!1})})]})]})]}),(0,G.jsx)(Ah,{git:C})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(iR,{className:B(`relative`,!a&&`hidden`),mobile:!1,onHide:()=>o(!1)}),(0,G.jsx)(_L,{machine:n,mobile:!1,leading:!a&&(0,G.jsx)(U,{variant:`ghost`,size:`icon-xs`,"aria-label":`Show sidebar`,title:`Show sidebar (${z}+B)`,onClick:()=>o(!0),children:(0,G.jsx)(H,{icon:sr})})})]})}var tB=Fe.withTag(`app`),nB=class extends W.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){tB.error(`a component crashed:`,e,t.componentStack)}render(){let e=this.state.error;return e===null?this.props.children:(0,G.jsxs)(`div`,{className:`flex h-dvh flex-col items-center justify-center gap-3 p-4 text-center`,children:[(0,G.jsx)(`p`,{className:`font-medium`,children:`Something went wrong`}),(0,G.jsx)(`p`,{className:`text-muted-foreground max-w-xl text-sm whitespace-pre-wrap`,children:e.message}),(0,G.jsx)(U,{onClick:()=>location.reload(),children:`Reload`})]})}},rB=[`typescript`,`tsx`,`javascript`],iB=`import { readFile } from 'node:fs/promises'
|
|
25
25
|
import type { Config } from './config'
|
|
26
26
|
|
|
27
27
|
export interface Entry<T> {
|