@cuongtran001/kanna 0.43.1 → 0.43.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{index-xuP98LaG.js → index-UQWb6QtR.js} +1 -1
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
- package/src/server/cli.ts +1 -0
- package/src/server/server.ts +7 -1
- package/src/server/terminal-manager.test.ts +73 -1
- package/src/server/terminal-manager.ts +31 -0
- package/src/server/terminal-pid-registry.test.ts +111 -0
- package/src/server/terminal-pid-registry.ts +107 -0
- package/src/server/ws-router.test.ts +62 -0
- package/src/server/ws-router.ts +4 -0
- package/src/shared/branding.ts +4 -0
|
@@ -637,7 +637,7 @@ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}
|
|
|
637
637
|
|
|
638
638
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
639
639
|
|
|
640
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},zG="DialogDescriptionWarning",BG=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${YO(zG).contentName}}.`;return _.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},FG=OO,$G=BO,XO=FO,QO=$O,HG=UO,UG=WO,VG=qO;function ZO(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=ZO(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function JO(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=ZO(e))&&(r&&(r+=" "),r+=t);return r}const WG=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},GG=(e,t)=>({classGroupId:e,validator:t}),e5=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Cv="-",sN=[],qG="arbitrary..",KG=e=>{const t=XG(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return YG(o);const l=o.split(Cv),c=l[0]===""&&l.length>1?1:0;return t5(l,c,t)},getConflictingClassGroupIds:(o,l)=>{if(l){const c=r[o],d=n[o];return c?d?WG(d,c):c:d||sN}return n[o]||sN}}},t5=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],s=n.nextPart.get(i);if(s){const d=t5(e,t+1,s);if(d)return d}const o=n.validators;if(o===null)return;const l=t===0?e.join(Cv):e.slice(t).join(Cv),c=o.length;for(let d=0;d<c;d++){const f=o[d];if(f.validator(l))return f.classGroupId}},YG=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?qG+r:void 0})(),XG=e=>{const{theme:t,classGroups:n}=e;return QG(n,t)},QG=(e,t)=>{const n=e5();for(const r in e){const i=e[r];xC(i,n,r,t)}return n},xC=(e,t,n,r)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];ZG(o,t,n,r)}},ZG=(e,t,n,r)=>{if(typeof e=="string"){JG(e,t,n);return}if(typeof e=="function"){eq(e,t,n,r);return}tq(e,t,n,r)},JG=(e,t,n)=>{const r=e===""?t:n5(t,e);r.classGroupId=n},eq=(e,t,n,r)=>{if(nq(e)){xC(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(GG(n,e))},tq=(e,t,n,r)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[l,c]=i[o];xC(c,n5(t,l),n,r)}},n5=(e,t)=>{let n=e;const r=t.split(Cv),i=r.length;for(let s=0;s<i;s++){const o=r[s];let l=n.nextPart.get(o);l||(l=e5(),n.nextPart.set(o,l)),n=l}return n},nq=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,rq=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(s,o)=>{n[s]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=r[s])!==void 0)return i(s,o),o},set(s,o){s in n?n[s]=o:i(s,o)}}},$S="!",oN=":",iq=[],aN=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),sq=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const s=[];let o=0,l=0,c=0,d;const f=i.length;for(let x=0;x<f;x++){const w=i[x];if(o===0&&l===0){if(w===oN){s.push(i.slice(c,x)),c=x+1;continue}if(w==="/"){d=x;continue}}w==="["?o++:w==="]"?o--:w==="("?l++:w===")"&&l--}const h=s.length===0?i:i.slice(c);let g=h,b=!1;h.endsWith($S)?(g=h.slice(0,-1),b=!0):h.startsWith($S)&&(g=h.slice(1),b=!0);const y=d&&d>c?d-c:void 0;return aN(s,b,g,y)};if(t){const i=t+oN,s=r;r=o=>o.startsWith(i)?s(o.slice(i.length)):aN(iq,!1,o,void 0,!0)}if(n){const i=r;r=s=>n({className:s,parseClassName:i})}return r},oq=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let s=0;s<n.length;s++){const o=n[s],l=o[0]==="[",c=t.has(o);l||c?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},aq=e=>({cache:rq(e.cacheSize),parseClassName:sq(e),sortModifiers:oq(e),...KG(e)}),lq=/\s+/,cq=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],l=e.trim().split(lq);let c="";for(let d=l.length-1;d>=0;d-=1){const f=l[d],{isExternal:h,modifiers:g,hasImportantModifier:b,baseClassName:y,maybePostfixModifierPosition:x}=n(f);if(h){c=f+(c.length>0?" "+c:c);continue}let w=!!x,C=r(w?y.substring(0,x):y);if(!C){if(!w){c=f+(c.length>0?" "+c:c);continue}if(C=r(y),!C){c=f+(c.length>0?" "+c:c);continue}w=!1}const E=g.length===0?"":g.length===1?g[0]:s(g).join(":"),R=b?E+$S:E,T=R+C;if(o.indexOf(T)>-1)continue;o.push(T);const A=i(C,w);for(let N=0;N<A.length;++N){const D=A[N];o.push(R+D)}c=f+(c.length>0?" "+c:c)}return c},uq=(...e)=>{let t=0,n,r,i="";for(;t<e.length;)(n=e[t++])&&(r=r5(n))&&(i&&(i+=" "),i+=r);return i},r5=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=r5(e[r]))&&(n&&(n+=" "),n+=t);return n},dq=(e,...t)=>{let n,r,i,s;const o=c=>{const d=t.reduce((f,h)=>h(f),e());return n=aq(d),r=n.cache.get,i=n.cache.set,s=l,l(c)},l=c=>{const d=r(c);if(d)return d;const f=cq(c,n);return i(c,f),f};return s=o,(...c)=>s(uq(...c))},hq=[],dr=e=>{const t=n=>n[e]||hq;return t.isThemeGetter=!0,t},i5=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,s5=/^\((?:(\w[\w-]*):)?(.+)\)$/i,fq=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,pq=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,mq=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,gq=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,vq=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,bq=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ga=e=>fq.test(e),qt=e=>!!e&&!Number.isNaN(Number(e)),qa=e=>!!e&&Number.isInteger(Number(e)),Jy=e=>e.endsWith("%")&&qt(e.slice(0,-1)),Bo=e=>pq.test(e),o5=()=>!0,_q=e=>mq.test(e)&&!gq.test(e),SC=()=>!1,yq=e=>vq.test(e),xq=e=>bq.test(e),Sq=e=>!nt(e)&&!it(e),wq=e=>El(e,c5,SC),nt=e=>i5.test(e),Yl=e=>El(e,u5,_q),lN=e=>El(e,Mq,qt),Cq=e=>El(e,h5,o5),kq=e=>El(e,d5,SC),cN=e=>El(e,a5,SC),Eq=e=>El(e,l5,xq),Qm=e=>El(e,f5,yq),it=e=>s5.test(e),$h=e=>Ic(e,u5),Rq=e=>Ic(e,d5),uN=e=>Ic(e,a5),Tq=e=>Ic(e,c5),Aq=e=>Ic(e,l5),Zm=e=>Ic(e,f5,!0),Nq=e=>Ic(e,h5,!0),El=(e,t,n)=>{const r=i5.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ic=(e,t,n=!1)=>{const r=s5.exec(e);return r?r[1]?t(r[1]):n:!1},a5=e=>e==="position"||e==="percentage",l5=e=>e==="image"||e==="url",c5=e=>e==="length"||e==="size"||e==="bg-size",u5=e=>e==="length",Mq=e=>e==="number",d5=e=>e==="family-name",h5=e=>e==="number"||e==="weight",f5=e=>e==="shadow",Lq=()=>{const e=dr("color"),t=dr("font"),n=dr("text"),r=dr("font-weight"),i=dr("tracking"),s=dr("leading"),o=dr("breakpoint"),l=dr("container"),c=dr("spacing"),d=dr("radius"),f=dr("shadow"),h=dr("inset-shadow"),g=dr("text-shadow"),b=dr("drop-shadow"),y=dr("blur"),x=dr("perspective"),w=dr("aspect"),C=dr("ease"),E=dr("animate"),R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...T(),it,nt],N=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto","contain","none"],M=()=>[it,nt,c],W=()=>[Ga,"full","auto",...M()],j=()=>[qa,"none","subgrid",it,nt],$=()=>["auto",{span:["full",qa,it,nt]},qa,it,nt],F=()=>[qa,"auto",it,nt],P=()=>["auto","min","max","fr",it,nt],B=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],H=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...M()],U=()=>[Ga,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...M()],V=()=>[Ga,"screen","full","dvw","lvw","svw","min","max","fit",...M()],Y=()=>[Ga,"screen","full","lh","dvh","lvh","svh","min","max","fit",...M()],O=()=>[e,it,nt],G=()=>[...T(),uN,cN,{position:[it,nt]}],Z=()=>["no-repeat",{repeat:["","x","y","space","round"]}],I=()=>["auto","cover","contain",Tq,wq,{size:[it,nt]}],re=()=>[Jy,$h,Yl],te=()=>["","none","full",d,it,nt],oe=()=>["",qt,$h,Yl],se=()=>["solid","dashed","dotted","double"],pe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ce=()=>[qt,Jy,uN,cN],ge=()=>["","none",y,it,nt],Ce=()=>["none",qt,it,nt],ke=()=>["none",qt,it,nt],De=()=>[qt,it,nt],be=()=>[Ga,"full",...M()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Bo],breakpoint:[Bo],color:[o5],container:[Bo],"drop-shadow":[Bo],ease:["in","out","in-out"],font:[Sq],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Bo],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Bo],shadow:[Bo],spacing:["px",qt],text:[Bo],"text-shadow":[Bo],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ga,nt,it,w]}],container:["container"],columns:[{columns:[qt,nt,it,l]}],"break-after":[{"break-after":R()}],"break-before":[{"break-before":R()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:W()}],"inset-x":[{"inset-x":W()}],"inset-y":[{"inset-y":W()}],start:[{"inset-s":W(),start:W()}],end:[{"inset-e":W(),end:W()}],"inset-bs":[{"inset-bs":W()}],"inset-be":[{"inset-be":W()}],top:[{top:W()}],right:[{right:W()}],bottom:[{bottom:W()}],left:[{left:W()}],visibility:["visible","invisible","collapse"],z:[{z:[qa,"auto",it,nt]}],basis:[{basis:[Ga,"full","auto",l,...M()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[qt,Ga,"auto","initial","none",nt]}],grow:[{grow:["",qt,it,nt]}],shrink:[{shrink:["",qt,it,nt]}],order:[{order:[qa,"first","last","none",it,nt]}],"grid-cols":[{"grid-cols":j()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":F()}],"col-end":[{"col-end":F()}],"grid-rows":[{"grid-rows":j()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":F()}],"row-end":[{"row-end":F()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":P()}],"auto-rows":[{"auto-rows":P()}],gap:[{gap:M()}],"gap-x":[{"gap-x":M()}],"gap-y":[{"gap-y":M()}],"justify-content":[{justify:[...B(),"normal"]}],"justify-items":[{"justify-items":[...H(),"normal"]}],"justify-self":[{"justify-self":["auto",...H()]}],"align-content":[{content:["normal",...B()]}],"align-items":[{items:[...H(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...H(),{baseline:["","last"]}]}],"place-content":[{"place-content":B()}],"place-items":[{"place-items":[...H(),"baseline"]}],"place-self":[{"place-self":["auto",...H()]}],p:[{p:M()}],px:[{px:M()}],py:[{py:M()}],ps:[{ps:M()}],pe:[{pe:M()}],pbs:[{pbs:M()}],pbe:[{pbe:M()}],pt:[{pt:M()}],pr:[{pr:M()}],pb:[{pb:M()}],pl:[{pl:M()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mbs:[{mbs:z()}],mbe:[{mbe:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":M()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":M()}],"space-y-reverse":["space-y-reverse"],size:[{size:U()}],"inline-size":[{inline:["auto",...V()]}],"min-inline-size":[{"min-inline":["auto",...V()]}],"max-inline-size":[{"max-inline":["none",...V()]}],"block-size":[{block:["auto",...Y()]}],"min-block-size":[{"min-block":["auto",...Y()]}],"max-block-size":[{"max-block":["none",...Y()]}],w:[{w:[l,"screen",...U()]}],"min-w":[{"min-w":[l,"screen","none",...U()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...U()]}],h:[{h:["screen","lh",...U()]}],"min-h":[{"min-h":["screen","lh","none",...U()]}],"max-h":[{"max-h":["screen","lh",...U()]}],"font-size":[{text:["base",n,$h,Yl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Nq,Cq]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Jy,nt]}],"font-family":[{font:[Rq,kq,t]}],"font-features":[{"font-features":[nt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,it,nt]}],"line-clamp":[{"line-clamp":[qt,"none",it,lN]}],leading:[{leading:[s,...M()]}],"list-image":[{"list-image":["none",it,nt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",it,nt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:O()}],"text-color":[{text:O()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...se(),"wavy"]}],"text-decoration-thickness":[{decoration:[qt,"from-font","auto",it,Yl]}],"text-decoration-color":[{decoration:O()}],"underline-offset":[{"underline-offset":[qt,"auto",it,nt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:M()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",it,nt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",it,nt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:G()}],"bg-repeat":[{bg:Z()}],"bg-size":[{bg:I()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qa,it,nt],radial:["",it,nt],conic:[qa,it,nt]},Aq,Eq]}],"bg-color":[{bg:O()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:O()}],"gradient-via":[{via:O()}],"gradient-to":[{to:O()}],rounded:[{rounded:te()}],"rounded-s":[{"rounded-s":te()}],"rounded-e":[{"rounded-e":te()}],"rounded-t":[{"rounded-t":te()}],"rounded-r":[{"rounded-r":te()}],"rounded-b":[{"rounded-b":te()}],"rounded-l":[{"rounded-l":te()}],"rounded-ss":[{"rounded-ss":te()}],"rounded-se":[{"rounded-se":te()}],"rounded-ee":[{"rounded-ee":te()}],"rounded-es":[{"rounded-es":te()}],"rounded-tl":[{"rounded-tl":te()}],"rounded-tr":[{"rounded-tr":te()}],"rounded-br":[{"rounded-br":te()}],"rounded-bl":[{"rounded-bl":te()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-bs":[{"border-bs":oe()}],"border-w-be":[{"border-be":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...se(),"hidden","none"]}],"divide-style":[{divide:[...se(),"hidden","none"]}],"border-color":[{border:O()}],"border-color-x":[{"border-x":O()}],"border-color-y":[{"border-y":O()}],"border-color-s":[{"border-s":O()}],"border-color-e":[{"border-e":O()}],"border-color-bs":[{"border-bs":O()}],"border-color-be":[{"border-be":O()}],"border-color-t":[{"border-t":O()}],"border-color-r":[{"border-r":O()}],"border-color-b":[{"border-b":O()}],"border-color-l":[{"border-l":O()}],"divide-color":[{divide:O()}],"outline-style":[{outline:[...se(),"none","hidden"]}],"outline-offset":[{"outline-offset":[qt,it,nt]}],"outline-w":[{outline:["",qt,$h,Yl]}],"outline-color":[{outline:O()}],shadow:[{shadow:["","none",f,Zm,Qm]}],"shadow-color":[{shadow:O()}],"inset-shadow":[{"inset-shadow":["none",h,Zm,Qm]}],"inset-shadow-color":[{"inset-shadow":O()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:O()}],"ring-offset-w":[{"ring-offset":[qt,Yl]}],"ring-offset-color":[{"ring-offset":O()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":O()}],"text-shadow":[{"text-shadow":["none",g,Zm,Qm]}],"text-shadow-color":[{"text-shadow":O()}],opacity:[{opacity:[qt,it,nt]}],"mix-blend":[{"mix-blend":[...pe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":pe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[qt]}],"mask-image-linear-from-pos":[{"mask-linear-from":ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":ce()}],"mask-image-linear-from-color":[{"mask-linear-from":O()}],"mask-image-linear-to-color":[{"mask-linear-to":O()}],"mask-image-t-from-pos":[{"mask-t-from":ce()}],"mask-image-t-to-pos":[{"mask-t-to":ce()}],"mask-image-t-from-color":[{"mask-t-from":O()}],"mask-image-t-to-color":[{"mask-t-to":O()}],"mask-image-r-from-pos":[{"mask-r-from":ce()}],"mask-image-r-to-pos":[{"mask-r-to":ce()}],"mask-image-r-from-color":[{"mask-r-from":O()}],"mask-image-r-to-color":[{"mask-r-to":O()}],"mask-image-b-from-pos":[{"mask-b-from":ce()}],"mask-image-b-to-pos":[{"mask-b-to":ce()}],"mask-image-b-from-color":[{"mask-b-from":O()}],"mask-image-b-to-color":[{"mask-b-to":O()}],"mask-image-l-from-pos":[{"mask-l-from":ce()}],"mask-image-l-to-pos":[{"mask-l-to":ce()}],"mask-image-l-from-color":[{"mask-l-from":O()}],"mask-image-l-to-color":[{"mask-l-to":O()}],"mask-image-x-from-pos":[{"mask-x-from":ce()}],"mask-image-x-to-pos":[{"mask-x-to":ce()}],"mask-image-x-from-color":[{"mask-x-from":O()}],"mask-image-x-to-color":[{"mask-x-to":O()}],"mask-image-y-from-pos":[{"mask-y-from":ce()}],"mask-image-y-to-pos":[{"mask-y-to":ce()}],"mask-image-y-from-color":[{"mask-y-from":O()}],"mask-image-y-to-color":[{"mask-y-to":O()}],"mask-image-radial":[{"mask-radial":[it,nt]}],"mask-image-radial-from-pos":[{"mask-radial-from":ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":ce()}],"mask-image-radial-from-color":[{"mask-radial-from":O()}],"mask-image-radial-to-color":[{"mask-radial-to":O()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[qt]}],"mask-image-conic-from-pos":[{"mask-conic-from":ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":ce()}],"mask-image-conic-from-color":[{"mask-conic-from":O()}],"mask-image-conic-to-color":[{"mask-conic-to":O()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:G()}],"mask-repeat":[{mask:Z()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",it,nt]}],filter:[{filter:["","none",it,nt]}],blur:[{blur:ge()}],brightness:[{brightness:[qt,it,nt]}],contrast:[{contrast:[qt,it,nt]}],"drop-shadow":[{"drop-shadow":["","none",b,Zm,Qm]}],"drop-shadow-color":[{"drop-shadow":O()}],grayscale:[{grayscale:["",qt,it,nt]}],"hue-rotate":[{"hue-rotate":[qt,it,nt]}],invert:[{invert:["",qt,it,nt]}],saturate:[{saturate:[qt,it,nt]}],sepia:[{sepia:["",qt,it,nt]}],"backdrop-filter":[{"backdrop-filter":["","none",it,nt]}],"backdrop-blur":[{"backdrop-blur":ge()}],"backdrop-brightness":[{"backdrop-brightness":[qt,it,nt]}],"backdrop-contrast":[{"backdrop-contrast":[qt,it,nt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",qt,it,nt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[qt,it,nt]}],"backdrop-invert":[{"backdrop-invert":["",qt,it,nt]}],"backdrop-opacity":[{"backdrop-opacity":[qt,it,nt]}],"backdrop-saturate":[{"backdrop-saturate":[qt,it,nt]}],"backdrop-sepia":[{"backdrop-sepia":["",qt,it,nt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":M()}],"border-spacing-x":[{"border-spacing-x":M()}],"border-spacing-y":[{"border-spacing-y":M()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",it,nt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[qt,"initial",it,nt]}],ease:[{ease:["linear","initial",C,it,nt]}],delay:[{delay:[qt,it,nt]}],animate:[{animate:["none",E,it,nt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,it,nt]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:Ce()}],"rotate-x":[{"rotate-x":Ce()}],"rotate-y":[{"rotate-y":Ce()}],"rotate-z":[{"rotate-z":Ce()}],scale:[{scale:ke()}],"scale-x":[{"scale-x":ke()}],"scale-y":[{"scale-y":ke()}],"scale-z":[{"scale-z":ke()}],"scale-3d":["scale-3d"],skew:[{skew:De()}],"skew-x":[{"skew-x":De()}],"skew-y":[{"skew-y":De()}],transform:[{transform:[it,nt,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:be()}],"translate-x":[{"translate-x":be()}],"translate-y":[{"translate-y":be()}],"translate-z":[{"translate-z":be()}],"translate-none":["translate-none"],accent:[{accent:O()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:O()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",it,nt]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mbs":[{"scroll-mbs":M()}],"scroll-mbe":[{"scroll-mbe":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pbs":[{"scroll-pbs":M()}],"scroll-pbe":[{"scroll-pbe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",it,nt]}],fill:[{fill:["none",...O()]}],"stroke-w":[{stroke:[qt,$h,Yl,lN]}],stroke:[{stroke:["none",...O()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Dq=dq(Lq);function ye(...e){return Dq(JO(e))}function sc(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Iq(e){return e.startsWith("chatId:")?e.slice(7):e}const Df="data-focus-fallback-ignore",p5="data-allow-focus-retain",kv="kanna:restore-chat-input-focus",wC="data-chat-input",Ev="data-chat-selection-zone";function oc(e,t){return!!(e!=null&&e.closest(`[${t}]`))}function m5(e){var n;const t=e;return t!=null&&t.matches?t.matches("input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']), textarea, select")||t.isContentEditable||((n=t.getAttribute)==null?void 0:n.call(t,"role"))==="textbox"?!0:oc(e,p5):!1}function Pq(e){const t=e;return t!=null&&t.matches?m5(e)||(t.tabIndex??-1)>=0||t.matches("button, a[href], summary")?!0:oc(e,p5):!1}function dN(e){return!!e.querySelector(`[${Df}][data-state='open']`)}function Oq(e){return e?!e.isCollapsed&&e.toString().trim().length>0:!1}function jq(e,t){if(!e)return!1;const n=Array.from(t.querySelectorAll(`textarea[${wC}]`)).filter(o=>!o.disabled);if(n.length===0)return!1;const r=n.indexOf(e),i=r>=0?(r+1)%n.length:0,s=n[i];return s?(s.focus({preventScroll:!0}),!0):!1}function hN(e){const{activeElement:t,fallback:n,hasActiveOverlay:r}=e;if(!n||n.disabled||r||t===n)return"none";if(e.trigger==="escape")return e.defaultPrevented||oc(t,wC)||e.canCancel?"none":"escape-focus";const{pointerStartTarget:i,pointerEndTarget:s,root:o,hasActiveSelection:l}=e,c=s??i;return!o||!c||!o.contains(c)||oc(c,Df)||oc(t,Df)||l&&(oc(i,Ev)||oc(c,Ev))||m5(t)?"none":t&&t===c?"restore":Pq(t)?"none":"restore"}const na=FG,zq=$G,g5=_.forwardRef(({className:e,...t},n)=>m.jsx(XO,{ref:n,className:ye("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));g5.displayName=XO.displayName;const Bq={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},po=_.forwardRef(({className:e,children:t,size:n="md",...r},i)=>m.jsxs(zq,{children:[m.jsx(g5,{}),m.jsxs(QO,{ref:i,[Df]:"",onCloseAutoFocus:s=>{var o;s.preventDefault(),window.dispatchEvent(new Event(kv)),(o=r.onCloseAutoFocus)==null||o.call(r,s)},className:ye("fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-background shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]","max-h-[85vh] flex flex-col",Bq[n],e),...r,children:[t,m.jsxs(VG,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[m.jsx(ua,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));po.displayName=QO.displayName;function CC({className:e,...t}){return m.jsx("div",{className:ye("shrink-0 flex flex-col space-y-1.5 p-4 border-b border-border",e),...t})}function ra({className:e,...t}){return m.jsx(HG,{className:ye("text-lg font-medium leading-none tracking-tight",e),...t})}function Ld({className:e,...t}){return m.jsx(UG,{className:ye("text-sm text-muted-foreground",e),...t})}function ia({className:e,...t}){return m.jsx("div",{className:ye("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...t})}function xl({className:e,...t}){return m.jsx("div",{className:ye("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...t})}function Fq({className:e,...t}){return m.jsx("button",{className:ye("touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer text-sm font-medium transition-colors","rounded-full h-9 px-4","bg-primary text-primary-foreground hover:bg-primary/90","disabled:pointer-events-none disabled:bg-primary/20 disabled:text-primary/60",e),...t})}function $q({className:e,...t}){return m.jsx("button",{className:ye("touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer text-sm font-medium transition-colors","rounded-full h-9 px-4","hover:bg-accent dark:hover:bg-card hover:text-accent-foreground text-muted-foreground","disabled:pointer-events-none disabled:text-muted-foreground/50",e),...t})}function Hq({open:e,shareUrl:t,onOpenChange:n,onOpenLink:r,onCopyLink:i}){const[s,o]=_.useState(!1);_.useEffect(()=>{e||o(!1)},[e,t]);const l=async()=>{await i()&&(o(!0),window.setTimeout(()=>{o(!1)},2e3))};return m.jsx(na,{open:e,onOpenChange:n,children:m.jsxs(po,{size:"md",children:[m.jsxs(CC,{children:[m.jsx(ra,{children:"Shared Link"}),m.jsx(Ld,{children:"Shared links are snapshots in time and contain all attachments, tool calls and history. Be mindful of sensitive info."})]}),m.jsx(ia,{className:"space-y-3",children:m.jsxs("div",{className:"flex w-full items-center gap-2 rounded-2xl border border-border bg-muted/40 pl-4 px-3 py-2.5",children:[m.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-sm text-foreground",children:t}),m.jsx("button",{type:"button",onClick:()=>void l(),title:s?"Copied":"Copy link","aria-label":s?"Copied":"Copy link",className:"flex flex-shrink-0 items-center justify-center rounded-lg text-logo hover:text-logo/60 transition-colors hover:bg-background hover:text-foreground",children:s?m.jsx(ui,{className:"h-4 w-4 text-emerald-400"}):m.jsx(yl,{className:"h-4 w-4"})})]})}),m.jsx(xl,{children:m.jsxs(Fq,{type:"button",onClick:r,children:[m.jsx(Rb,{className:"mr-2 h-4 w-4"}),"Open"]})})]})})}const fN=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,pN=JO,Uq=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return pN(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(d=>{const f=n==null?void 0:n[d],h=s==null?void 0:s[d];if(f===null)return null;const g=fN(f)||fN(h);return i[d][g]}),l=n&&Object.entries(n).reduce((d,f)=>{let[h,g]=f;return g===void 0||(d[h]=g),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:h,className:g,...b}=f;return Object.entries(b).every(y=>{let[x,w]=y;return Array.isArray(w)?w.includes({...s,...l}[x]):{...s,...l}[x]===w})?[...d,h,g]:d},[]);return pN(e,o,c,n==null?void 0:n.class,n==null?void 0:n.className)},Pb=Uq("touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none",{variants:{variant:{default:"bg-primary text-primary-foreground disabled:bg-primary/50 disabled:text-primary-foreground/90 hover:bg-primary/90",juicy:"bg-logo text-primary-foreground disabled:text-primary-foreground/50 hover:bg-logo/90",destructive:"bg-destructive/80 dark:text-white",outline:"border disabled:bg-transparent disabled:text-foreground/50 border-inpu disabled:border-input/90 bg-card hover:bg-muted hover:text-accent-foreground",secondary:"bg-transparent border border-border text-secondary-foreground hover:text-secondary-foreground/60 disabled:text-secondary-foreground/50",ghost:"hover:bg-accent dark:hover:bg-card hover:text-accent-foreground text-muted-foreground disabled:text-muted-foreground/50 border border-border/0 hover:border-border",link:"text-primary disabled:text-primary/50 underline-offset-4 hover:underline",none:""},size:{default:"h-10 px-4 rounded-full py-2",sm:"h-9 rounded-full px-3",lg:"h-11 rounded-full px-8",icon:"h-9 w-9 rounded-full","icon-mobile":"h-11 w-11 rounded-full md:h-9 md:w-9",none:"","icon-sm":"h-5.5 w-5.5 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),st=_.forwardRef(({className:e,variant:t,size:n,type:r="button",...i},s)=>m.jsx("button",{type:r,className:ye(Pb({variant:t,size:n,className:e})),ref:s,...i}));st.displayName="Button";const wr=_.forwardRef(({className:e,type:t,...n},r)=>m.jsx("input",{ref:r,type:t,className:ye("flex w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...n}));wr.displayName="Input";const v5=_.createContext(null);function Vq({children:e}){const[t,n]=_.useState(null),[r,i]=_.useState(""),s=_.useRef(null);_.useEffect(()=>{(t==null?void 0:t.kind)==="prompt"&&(i(t.options.initialValue??""),setTimeout(()=>{var b,y;(b=s.current)==null||b.focus(),(y=s.current)==null||y.select()},0))},[t]);const o=_.useCallback(()=>{n(null),i("")},[]),l=_.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!1):t.kind==="prompt"?t.resolve(null):t.resolve(),o())},[o,t]),c=_.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!0):t.kind==="prompt"?t.resolve(r.trim()||null):t.resolve(),o())},[o,t,r]),d=_.useCallback(b=>new Promise(y=>{n({kind:"confirm",options:b,resolve:y})}),[]),f=_.useCallback(b=>new Promise(y=>{n({kind:"prompt",options:b,resolve:y})}),[]),h=_.useCallback(b=>new Promise(y=>{n({kind:"alert",options:b,resolve:y})}),[]),g=_.useMemo(()=>({confirm:d,prompt:f,alert:h}),[h,d,f]);return m.jsxs(v5.Provider,{value:g,children:[e,m.jsx(na,{open:t!==null,onOpenChange:b=>{b||!t||l()},children:m.jsx(po,{size:"sm",onKeyDown:b=>{b.key!=="Enter"||b.shiftKey||!t||t.kind!=="confirm"||(b.preventDefault(),c())},children:t?m.jsxs(m.Fragment,{children:[m.jsxs(ia,{className:"space-y-4",children:[m.jsx(ra,{children:t.options.title}),t.options.description?m.jsx(Ld,{children:t.options.description}):null,t.kind==="prompt"?m.jsx(wr,{ref:s,type:"text",value:r,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),c())},placeholder:t.options.placeholder}):null]}),m.jsxs(xl,{children:[m.jsx(st,{variant:"ghost",size:"sm",onClick:l,className:t.kind==="alert"?"hidden":void 0,children:"cancelLabel"in t.options?t.options.cancelLabel??"Cancel":"Cancel"}),m.jsx(st,{variant:t.kind==="confirm"?t.options.confirmVariant??"default":"secondary",size:"sm",onClick:c,disabled:t.kind==="prompt"&&!r.trim(),children:t.kind==="alert"?t.options.closeLabel??"OK":"confirmLabel"in t.options?t.options.confirmLabel??"Confirm":"Confirm"})]})]}):null})})]})}function fp(){const e=_.useContext(v5);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const kC=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:ye("bg-card text-card-foreground",e),...t}));kC.displayName="Card";const EC=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:ye("flex flex-col space-y-1.5 p-2",e),...t}));EC.displayName="CardHeader";const b5=_.forwardRef(({className:e,...t},n)=>m.jsx("h3",{ref:n,className:ye("text-2xl font-semibold leading-none tracking-tight",e),...t}));b5.displayName="CardTitle";const _5=_.forwardRef(({className:e,...t},n)=>m.jsx("p",{ref:n,className:ye("text-sm text-muted-foreground",e),...t}));_5.displayName="CardDescription";const RC=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:ye("p-6 pt-0",e),...t}));RC.displayName="CardContent";const Wq=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:ye("flex items-center p-6 pt-0",e),...t}));Wq.displayName="CardFooter";const Gq=["top","right","bottom","left"],Sl=Math.min,Fi=Math.max,Rv=Math.round,Jm=Math.floor,co=e=>({x:e,y:e}),qq={left:"right",right:"left",bottom:"top",top:"bottom"};function HS(e,t,n){return Fi(e,Sl(t,n))}function sa(e,t){return typeof e=="function"?e(t):e}function oa(e){return e.split("-")[0]}function Dd(e){return e.split("-")[1]}function TC(e){return e==="x"?"y":"x"}function AC(e){return e==="y"?"height":"width"}function io(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function NC(e){return TC(io(e))}function Kq(e,t,n){n===void 0&&(n=!1);const r=Dd(e),i=NC(e),s=AC(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=Tv(o)),[o,Tv(o)]}function Yq(e){const t=Tv(e);return[US(e),t,US(t)]}function US(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const mN=["left","right"],gN=["right","left"],Xq=["top","bottom"],Qq=["bottom","top"];function Zq(e,t,n){switch(e){case"top":case"bottom":return n?t?gN:mN:t?mN:gN;case"left":case"right":return t?Xq:Qq;default:return[]}}function Jq(e,t,n,r){const i=Dd(e);let s=Zq(oa(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(US)))),s}function Tv(e){const t=oa(e);return qq[t]+e.slice(t.length)}function eK(e){return{top:0,right:0,bottom:0,left:0,...e}}function y5(e){return typeof e!="number"?eK(e):{top:e,right:e,bottom:e,left:e}}function Av(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function vN(e,t,n){let{reference:r,floating:i}=e;const s=io(t),o=NC(t),l=AC(o),c=oa(t),d=s==="y",f=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,g=r[l]/2-i[l]/2;let b;switch(c){case"top":b={x:f,y:r.y-i.height};break;case"bottom":b={x:f,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:h};break;case"left":b={x:r.x-i.width,y:h};break;default:b={x:r.x,y:r.y}}switch(Dd(t)){case"start":b[o]-=g*(n&&d?-1:1);break;case"end":b[o]+=g*(n&&d?-1:1);break}return b}async function tK(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:g=!1,padding:b=0}=sa(t,e),y=y5(b),w=l[g?h==="floating"?"reference":"floating":h],C=Av(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:c})),E=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),T=await(s.isElement==null?void 0:s.isElement(R))?await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1}:{x:1,y:1},A=Av(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:E,offsetParent:R,strategy:c}):E);return{top:(C.top-A.top+y.top)/T.y,bottom:(A.bottom-C.bottom+y.bottom)/T.y,left:(C.left-A.left+y.left)/T.x,right:(A.right-C.right+y.right)/T.x}}const nK=50,rK=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:tK},c=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:h}=vN(d,r,c),g=r,b=0;const y={};for(let x=0;x<s.length;x++){const w=s[x];if(!w)continue;const{name:C,fn:E}=w,{x:R,y:T,data:A,reset:N}=await E({x:f,y:h,initialPlacement:r,placement:g,strategy:i,middlewareData:y,rects:d,platform:l,elements:{reference:e,floating:t}});f=R??f,h=T??h,y[C]={...y[C],...A},N&&b<nK&&(b++,typeof N=="object"&&(N.placement&&(g=N.placement),N.rects&&(d=N.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):N.rects),{x:f,y:h}=vN(d,g,c)),x=-1)}return{x:f,y:h,placement:g,strategy:i,middlewareData:y}},iK=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:c}=t,{element:d,padding:f=0}=sa(e,t)||{};if(d==null)return{};const h=y5(f),g={x:n,y:r},b=NC(i),y=AC(b),x=await o.getDimensions(d),w=b==="y",C=w?"top":"left",E=w?"bottom":"right",R=w?"clientHeight":"clientWidth",T=s.reference[y]+s.reference[b]-g[b]-s.floating[y],A=g[b]-s.reference[b],N=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let D=N?N[R]:0;(!D||!await(o.isElement==null?void 0:o.isElement(N)))&&(D=l.floating[R]||s.floating[y]);const M=T/2-A/2,W=D/2-x[y]/2-1,j=Sl(h[C],W),$=Sl(h[E],W),F=j,P=D-x[y]-$,B=D/2-x[y]/2+M,H=HS(F,B,P),z=!c.arrow&&Dd(i)!=null&&B!==H&&s.reference[y]/2-(B<F?j:$)-x[y]/2<0,U=z?B<F?B-F:B-P:0;return{[b]:g[b]+U,data:{[b]:H,centerOffset:B-H-U,...z&&{alignmentOffset:U}},reset:z}}}),sK=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:x=!0,...w}=sa(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const C=oa(i),E=io(l),R=oa(l)===l,T=await(c.isRTL==null?void 0:c.isRTL(d.floating)),A=g||(R||!x?[Tv(l)]:Yq(l)),N=y!=="none";!g&&N&&A.push(...Jq(l,x,y,T));const D=[l,...A],M=await c.detectOverflow(t,w),W=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&W.push(M[C]),h){const B=Kq(i,o,T);W.push(M[B[0]],M[B[1]])}if(j=[...j,{placement:i,overflows:W}],!W.every(B=>B<=0)){var $,F;const B=((($=s.flip)==null?void 0:$.index)||0)+1,H=D[B];if(H&&(!(h==="alignment"?E!==io(H):!1)||j.every(V=>io(V.placement)===E?V.overflows[0]>0:!0)))return{data:{index:B,overflows:j},reset:{placement:H}};let z=(F=j.filter(U=>U.overflows[0]<=0).sort((U,V)=>U.overflows[1]-V.overflows[1])[0])==null?void 0:F.placement;if(!z)switch(b){case"bestFit":{var P;const U=(P=j.filter(V=>{if(N){const Y=io(V.placement);return Y===E||Y==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(Y=>Y>0).reduce((Y,O)=>Y+O,0)]).sort((V,Y)=>V[1]-Y[1])[0])==null?void 0:P[0];U&&(z=U);break}case"initialPlacement":z=l;break}if(i!==z)return{reset:{placement:z}}}return{}}}};function bN(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function _N(e){return Gq.some(t=>e[t]>=0)}const oK=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=sa(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=bN(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:_N(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),l=bN(o,n.floating);return{data:{escapedOffsets:l,escaped:_N(l)}}}default:return{}}}}},x5=new Set(["left","top"]);async function aK(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=oa(n),l=Dd(n),c=io(n)==="y",d=x5.has(o)?-1:1,f=s&&c?-1:1,h=sa(t,e);let{mainAxis:g,crossAxis:b,alignmentAxis:y}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof y=="number"&&(b=l==="end"?y*-1:y),c?{x:b*f,y:g*d}:{x:g*d,y:b*f}}const lK=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:l}=t,c=await aK(t,e);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:o}}}}},cK=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:c={fn:C=>{let{x:E,y:R}=C;return{x:E,y:R}}},...d}=sa(e,t),f={x:n,y:r},h=await s.detectOverflow(t,d),g=io(oa(i)),b=TC(g);let y=f[b],x=f[g];if(o){const C=b==="y"?"top":"left",E=b==="y"?"bottom":"right",R=y+h[C],T=y-h[E];y=HS(R,y,T)}if(l){const C=g==="y"?"top":"left",E=g==="y"?"bottom":"right",R=x+h[C],T=x-h[E];x=HS(R,x,T)}const w=c.fn({...t,[b]:y,[g]:x});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[b]:o,[g]:l}}}}}},uK=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=sa(e,t),f={x:n,y:r},h=io(i),g=TC(h);let b=f[g],y=f[h];const x=sa(l,t),w=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const R=g==="y"?"height":"width",T=s.reference[g]-s.floating[R]+w.mainAxis,A=s.reference[g]+s.reference[R]-w.mainAxis;b<T?b=T:b>A&&(b=A)}if(d){var C,E;const R=g==="y"?"width":"height",T=x5.has(oa(i)),A=s.reference[h]-s.floating[R]+(T&&((C=o.offset)==null?void 0:C[h])||0)+(T?0:w.crossAxis),N=s.reference[h]+s.reference[R]+(T?0:((E=o.offset)==null?void 0:E[h])||0)-(T?w.crossAxis:0);y<A?y=A:y>N&&(y=N)}return{[g]:b,[h]:y}}}},dK=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:l}=t,{apply:c=()=>{},...d}=sa(e,t),f=await o.detectOverflow(t,d),h=oa(i),g=Dd(i),b=io(i)==="y",{width:y,height:x}=s.floating;let w,C;h==="top"||h==="bottom"?(w=h,C=g===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(C=h,w=g==="end"?"top":"bottom");const E=x-f.top-f.bottom,R=y-f.left-f.right,T=Sl(x-f[w],E),A=Sl(y-f[C],R),N=!t.middlewareData.shift;let D=T,M=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(M=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(D=E),N&&!g){const j=Fi(f.left,0),$=Fi(f.right,0),F=Fi(f.top,0),P=Fi(f.bottom,0);b?M=y-2*(j!==0||$!==0?j+$:Fi(f.left,f.right)):D=x-2*(F!==0||P!==0?F+P:Fi(f.top,f.bottom))}await c({...t,availableWidth:M,availableHeight:D});const W=await o.getDimensions(l.floating);return y!==W.width||x!==W.height?{reset:{rects:!0}}:{}}}};function Ob(){return typeof window<"u"}function Id(e){return S5(e)?(e.nodeName||"").toLowerCase():"#document"}function $i(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vo(e){var t;return(t=(S5(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function S5(e){return Ob()?e instanceof Node||e instanceof $i(e).Node:!1}function Bs(e){return Ob()?e instanceof Element||e instanceof $i(e).Element:!1}function ha(e){return Ob()?e instanceof HTMLElement||e instanceof $i(e).HTMLElement:!1}function yN(e){return!Ob()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $i(e).ShadowRoot}function pp(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Fs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function hK(e){return/^(table|td|th)$/.test(Id(e))}function jb(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const fK=/transform|translate|scale|rotate|perspective|filter/,pK=/paint|layout|strict|content/,Xl=e=>!!e&&e!=="none";let ex;function MC(e){const t=Bs(e)?Fs(e):e;return Xl(t.transform)||Xl(t.translate)||Xl(t.scale)||Xl(t.rotate)||Xl(t.perspective)||!LC()&&(Xl(t.backdropFilter)||Xl(t.filter))||fK.test(t.willChange||"")||pK.test(t.contain||"")}function mK(e){let t=wl(e);for(;ha(t)&&!dd(t);){if(MC(t))return t;if(jb(t))return null;t=wl(t)}return null}function LC(){return ex==null&&(ex=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ex}function dd(e){return/^(html|body|#document)$/.test(Id(e))}function Fs(e){return $i(e).getComputedStyle(e)}function zb(e){return Bs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wl(e){if(Id(e)==="html")return e;const t=e.assignedSlot||e.parentNode||yN(e)&&e.host||vo(e);return yN(t)?t.host:t}function w5(e){const t=wl(e);return dd(t)?e.ownerDocument?e.ownerDocument.body:e.body:ha(t)&&pp(t)?t:w5(t)}function If(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=w5(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=$i(i);if(s){const l=VS(o);return t.concat(o,o.visualViewport||[],pp(i)?i:[],l&&n?If(l):[])}else return t.concat(i,If(i,[],n))}function VS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function C5(e){const t=Fs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=ha(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,l=Rv(n)!==s||Rv(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function DC(e){return Bs(e)?e:e.contextElement}function Ju(e){const t=DC(e);if(!ha(t))return co(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=C5(t);let o=(s?Rv(n.width):n.width)/r,l=(s?Rv(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const gK=co(0);function k5(e){const t=$i(e);return!LC()||!t.visualViewport?gK:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function vK(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==$i(e)?!1:t}function Sc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=DC(e);let o=co(1);t&&(r?Bs(r)&&(o=Ju(r)):o=Ju(e));const l=vK(s,n,r)?k5(s):co(0);let c=(i.left+l.x)/o.x,d=(i.top+l.y)/o.y,f=i.width/o.x,h=i.height/o.y;if(s){const g=$i(s),b=r&&Bs(r)?$i(r):r;let y=g,x=VS(y);for(;x&&r&&b!==y;){const w=Ju(x),C=x.getBoundingClientRect(),E=Fs(x),R=C.left+(x.clientLeft+parseFloat(E.paddingLeft))*w.x,T=C.top+(x.clientTop+parseFloat(E.paddingTop))*w.y;c*=w.x,d*=w.y,f*=w.x,h*=w.y,c+=R,d+=T,y=$i(x),x=VS(y)}}return Av({width:f,height:h,x:c,y:d})}function Bb(e,t){const n=zb(e).scrollLeft;return t?t.left+n:Sc(vo(e)).left+n}function E5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Bb(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function bK(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=vo(r),l=t?jb(t.floating):!1;if(r===o||l&&s)return n;let c={scrollLeft:0,scrollTop:0},d=co(1);const f=co(0),h=ha(r);if((h||!h&&!s)&&((Id(r)!=="body"||pp(o))&&(c=zb(r)),h)){const b=Sc(r);d=Ju(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const g=o&&!h&&!s?E5(o,c):co(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+g.x,y:n.y*d.y-c.scrollTop*d.y+f.y+g.y}}function _K(e){return Array.from(e.getClientRects())}function yK(e){const t=vo(e),n=zb(e),r=e.ownerDocument.body,i=Fi(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Fi(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Bb(e);const l=-n.scrollTop;return Fs(r).direction==="rtl"&&(o+=Fi(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}const xN=25;function xK(e,t){const n=$i(e),r=vo(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,c=0;if(i){s=i.width,o=i.height;const f=LC();(!f||f&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const d=Bb(r);if(d<=0){const f=r.ownerDocument,h=f.body,g=getComputedStyle(h),b=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,y=Math.abs(r.clientWidth-h.clientWidth-b);y<=xN&&(s-=y)}else d<=xN&&(s+=d);return{width:s,height:o,x:l,y:c}}function SK(e,t){const n=Sc(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=ha(e)?Ju(e):co(1),o=e.clientWidth*s.x,l=e.clientHeight*s.y,c=i*s.x,d=r*s.y;return{width:o,height:l,x:c,y:d}}function SN(e,t,n){let r;if(t==="viewport")r=xK(e,n);else if(t==="document")r=yK(vo(e));else if(Bs(t))r=SK(t,n);else{const i=k5(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Av(r)}function R5(e,t){const n=wl(e);return n===t||!Bs(n)||dd(n)?!1:Fs(n).position==="fixed"||R5(n,t)}function wK(e,t){const n=t.get(e);if(n)return n;let r=If(e,[],!1).filter(l=>Bs(l)&&Id(l)!=="body"),i=null;const s=Fs(e).position==="fixed";let o=s?wl(e):e;for(;Bs(o)&&!dd(o);){const l=Fs(o),c=MC(o);!c&&l.position==="fixed"&&(i=null),(s?!c&&!i:!c&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||pp(o)&&!c&&R5(e,o))?r=r.filter(f=>f!==o):i=l,o=wl(o)}return t.set(e,r),r}function CK(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?jb(t)?[]:wK(t,this._c):[].concat(n),r],l=SN(t,o[0],i);let c=l.top,d=l.right,f=l.bottom,h=l.left;for(let g=1;g<o.length;g++){const b=SN(t,o[g],i);c=Fi(b.top,c),d=Sl(b.right,d),f=Sl(b.bottom,f),h=Fi(b.left,h)}return{width:d-h,height:f-c,x:h,y:c}}function kK(e){const{width:t,height:n}=C5(e);return{width:t,height:n}}function EK(e,t,n){const r=ha(t),i=vo(t),s=n==="fixed",o=Sc(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=co(0);function d(){c.x=Bb(i)}if(r||!r&&!s)if((Id(t)!=="body"||pp(i))&&(l=zb(t)),r){const b=Sc(t,!0,s,t);c.x=b.x+t.clientLeft,c.y=b.y+t.clientTop}else i&&d();s&&!r&&i&&d();const f=i&&!r&&!s?E5(i,l):co(0),h=o.left+l.scrollLeft-c.x-f.x,g=o.top+l.scrollTop-c.y-f.y;return{x:h,y:g,width:o.width,height:o.height}}function tx(e){return Fs(e).position==="static"}function wN(e,t){if(!ha(e)||Fs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vo(e)===n&&(n=n.ownerDocument.body),n}function T5(e,t){const n=$i(e);if(jb(e))return n;if(!ha(e)){let i=wl(e);for(;i&&!dd(i);){if(Bs(i)&&!tx(i))return i;i=wl(i)}return n}let r=wN(e,t);for(;r&&hK(r)&&tx(r);)r=wN(r,t);return r&&dd(r)&&tx(r)&&!MC(r)?n:r||mK(e)||n}const RK=async function(e){const t=this.getOffsetParent||T5,n=this.getDimensions,r=await n(e.floating);return{reference:EK(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function TK(e){return Fs(e).direction==="rtl"}const AK={convertOffsetParentRelativeRectToViewportRelativeRect:bK,getDocumentElement:vo,getClippingRect:CK,getOffsetParent:T5,getElementRects:RK,getClientRects:_K,getDimensions:kK,getScale:Ju,isElement:Bs,isRTL:TK};function A5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function NK(e,t){let n=null,r;const i=vo(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=e.getBoundingClientRect(),{left:f,top:h,width:g,height:b}=d;if(l||t(),!g||!b)return;const y=Jm(h),x=Jm(i.clientWidth-(f+g)),w=Jm(i.clientHeight-(h+b)),C=Jm(f),R={rootMargin:-y+"px "+-x+"px "+-w+"px "+-C+"px",threshold:Fi(0,Sl(1,c))||1};let T=!0;function A(N){const D=N[0].intersectionRatio;if(D!==c){if(!T)return o();D?o(!1,D):r=setTimeout(()=>{o(!1,1e-7)},1e3)}D===1&&!A5(d,e.getBoundingClientRect())&&o(),T=!1}try{n=new IntersectionObserver(A,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(A,R)}n.observe(e)}return o(!0),s}function MK(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=DC(e),f=i||s?[...d?If(d):[],...t?If(t):[]]:[];f.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),s&&C.addEventListener("resize",n)});const h=d&&l?NK(d,n):null;let g=-1,b=null;o&&(b=new ResizeObserver(C=>{let[E]=C;E&&E.target===d&&b&&t&&(b.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var R;(R=b)==null||R.observe(t)})),n()}),d&&!c&&b.observe(d),t&&b.observe(t));let y,x=c?Sc(e):null;c&&w();function w(){const C=Sc(e);x&&!A5(x,C)&&n(),x=C,y=requestAnimationFrame(w)}return n(),()=>{var C;f.forEach(E=>{i&&E.removeEventListener("scroll",n),s&&E.removeEventListener("resize",n)}),h==null||h(),(C=b)==null||C.disconnect(),b=null,c&&cancelAnimationFrame(y)}}const LK=lK,DK=cK,IK=sK,PK=dK,OK=oK,CN=iK,jK=uK,zK=(e,t,n)=>{const r=new Map,i={platform:AK,...n},s={...i.platform,_c:r};return rK(e,t,{...i,platform:s})};var BK=typeof document<"u",FK=function(){},Qg=BK?_.useLayoutEffect:FK;function Nv(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Nv(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!Nv(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function N5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function kN(e,t){const n=N5(e);return Math.round(t*n)/n}function nx(e){const t=_.useRef(e);return Qg(()=>{t.current=e}),t}function $K(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[f,h]=_.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,b]=_.useState(r);Nv(g,r)||b(r);const[y,x]=_.useState(null),[w,C]=_.useState(null),E=_.useCallback(V=>{V!==N.current&&(N.current=V,x(V))},[]),R=_.useCallback(V=>{V!==D.current&&(D.current=V,C(V))},[]),T=s||y,A=o||w,N=_.useRef(null),D=_.useRef(null),M=_.useRef(f),W=c!=null,j=nx(c),$=nx(i),F=nx(d),P=_.useCallback(()=>{if(!N.current||!D.current)return;const V={placement:t,strategy:n,middleware:g};$.current&&(V.platform=$.current),zK(N.current,D.current,V).then(Y=>{const O={...Y,isPositioned:F.current!==!1};B.current&&!Nv(M.current,O)&&(M.current=O,ps.flushSync(()=>{h(O)}))})},[g,t,n,$,F]);Qg(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,h(V=>({...V,isPositioned:!1})))},[d]);const B=_.useRef(!1);Qg(()=>(B.current=!0,()=>{B.current=!1}),[]),Qg(()=>{if(T&&(N.current=T),A&&(D.current=A),T&&A){if(j.current)return j.current(T,A,P);P()}},[T,A,P,j,W]);const H=_.useMemo(()=>({reference:N,floating:D,setReference:E,setFloating:R}),[E,R]),z=_.useMemo(()=>({reference:T,floating:A}),[T,A]),U=_.useMemo(()=>{const V={position:n,left:0,top:0};if(!z.floating)return V;const Y=kN(z.floating,f.x),O=kN(z.floating,f.y);return l?{...V,transform:"translate("+Y+"px, "+O+"px)",...N5(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:O}},[n,l,z.floating,f.x,f.y]);return _.useMemo(()=>({...f,update:P,refs:H,elements:z,floatingStyles:U}),[f,P,H,z,U])}const HK=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?CN({element:r.current,padding:i}).fn(n):{}:r?CN({element:r,padding:i}).fn(n):{}}}},UK=(e,t)=>{const n=LK(e);return{name:n.name,fn:n.fn,options:[e,t]}},VK=(e,t)=>{const n=DK(e);return{name:n.name,fn:n.fn,options:[e,t]}},WK=(e,t)=>({fn:jK(e).fn,options:[e,t]}),GK=(e,t)=>{const n=IK(e);return{name:n.name,fn:n.fn,options:[e,t]}},qK=(e,t)=>{const n=PK(e);return{name:n.name,fn:n.fn,options:[e,t]}},KK=(e,t)=>{const n=OK(e);return{name:n.name,fn:n.fn,options:[e,t]}},YK=(e,t)=>{const n=HK(e);return{name:n.name,fn:n.fn,options:[e,t]}};var XK="Arrow",M5=_.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return m.jsx(Jt.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});M5.displayName=XK;var QK=M5;function ZK(e){const[t,n]=_.useState(void 0);return Yr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,l;if("borderBoxSize"in s){const c=s.borderBoxSize,d=Array.isArray(c)?c[0]:c;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;n({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var IC="Popper",[L5,Rl]=da(IC),[JK,D5]=L5(IC),I5=e=>{const{__scopePopper:t,children:n}=e,[r,i]=_.useState(null);return m.jsx(JK,{scope:t,anchor:r,onAnchorChange:i,children:n})};I5.displayName=IC;var P5="PopperAnchor",O5=_.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=D5(P5,n),o=_.useRef(null),l=mn(t,o),c=_.useRef(null);return _.useEffect(()=>{const d=c.current;c.current=(r==null?void 0:r.current)||o.current,d!==c.current&&s.onAnchorChange(c.current)}),r?null:m.jsx(Jt.div,{...i,ref:l})});O5.displayName=P5;var PC="PopperContent",[eY,tY]=L5(PC),j5=_.forwardRef((e,t)=>{var se,pe,ce,ge,Ce,ke;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:b="optimized",onPlaced:y,...x}=e,w=D5(PC,n),[C,E]=_.useState(null),R=mn(t,De=>E(De)),[T,A]=_.useState(null),N=ZK(T),D=(N==null?void 0:N.width)??0,M=(N==null?void 0:N.height)??0,W=r+(s!=="center"?"-"+s:""),j=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},$=Array.isArray(d)?d:[d],F=$.length>0,P={padding:j,boundary:$.filter(rY),altBoundary:F},{refs:B,floatingStyles:H,placement:z,isPositioned:U,middlewareData:V}=$K({strategy:"fixed",placement:W,whileElementsMounted:(...De)=>MK(...De,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[UK({mainAxis:i+M,alignmentAxis:o}),c&&VK({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?WK():void 0,...P}),c&&GK({...P}),qK({...P,apply:({elements:De,rects:be,availableWidth:rt,availableHeight:Rt})=>{const{width:mt,height:sn}=be.reference,$t=De.floating.style;$t.setProperty("--radix-popper-available-width",`${rt}px`),$t.setProperty("--radix-popper-available-height",`${Rt}px`),$t.setProperty("--radix-popper-anchor-width",`${mt}px`),$t.setProperty("--radix-popper-anchor-height",`${sn}px`)}}),T&&YK({element:T,padding:l}),iY({arrowWidth:D,arrowHeight:M}),g&&KK({strategy:"referenceHidden",...P})]}),[Y,O]=F5(z),G=zs(y);Yr(()=>{U&&(G==null||G())},[U,G]);const Z=(se=V.arrow)==null?void 0:se.x,I=(pe=V.arrow)==null?void 0:pe.y,re=((ce=V.arrow)==null?void 0:ce.centerOffset)!==0,[te,oe]=_.useState();return Yr(()=>{C&&oe(window.getComputedStyle(C).zIndex)},[C]),m.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:U?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:te,"--radix-popper-transform-origin":[(ge=V.transformOrigin)==null?void 0:ge.x,(Ce=V.transformOrigin)==null?void 0:Ce.y].join(" "),...((ke=V.hide)==null?void 0:ke.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(eY,{scope:n,placedSide:Y,onArrowChange:A,arrowX:Z,arrowY:I,shouldHideArrow:re,children:m.jsx(Jt.div,{"data-side":Y,"data-align":O,...x,ref:R,style:{...x.style,animation:U?void 0:"none"}})})})});j5.displayName=PC;var z5="PopperArrow",nY={top:"bottom",right:"left",bottom:"top",left:"right"},B5=_.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=tY(z5,r),o=nY[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(QK,{...i,ref:n,style:{...i.style,display:"block"}})})});B5.displayName=z5;function rY(e){return e!==null}var iY=e=>({name:"transformOrigin",options:e,fn(t){var w,C,E;const{placement:n,rects:r,middlewareData:i}=t,o=((w=i.arrow)==null?void 0:w.centerOffset)!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[d,f]=F5(n),h={start:"0%",center:"50%",end:"100%"}[f],g=(((C=i.arrow)==null?void 0:C.x)??0)+l/2,b=(((E=i.arrow)==null?void 0:E.y)??0)+c/2;let y="",x="";return d==="bottom"?(y=o?h:`${g}px`,x=`${-c}px`):d==="top"?(y=o?h:`${g}px`,x=`${r.floating.height+c}px`):d==="right"?(y=`${-c}px`,x=o?h:`${b}px`):d==="left"&&(y=`${r.floating.width+c}px`,x=o?h:`${b}px`),{data:{x:y,y:x}}}});function F5(e){const[t,n="center"]=e.split("-");return[t,n]}var Fb=I5,mp=O5,$b=j5,Hb=B5,$5=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),sY="VisuallyHidden",H5=_.forwardRef((e,t)=>m.jsx(Jt.span,{...e,ref:t,style:{...$5,...e.style}}));H5.displayName=sY;var oY=H5,[Ub]=da("Tooltip",[Rl]),Vb=Rl(),U5="TooltipProvider",aY=700,WS="tooltip.open",[lY,OC]=Ub(U5),V5=e=>{const{__scopeTooltip:t,delayDuration:n=aY,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=_.useRef(!0),l=_.useRef(!1),c=_.useRef(0);return _.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),m.jsx(lY,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:_.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:_.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};V5.displayName=U5;var Pf="Tooltip",[cY,gp]=Ub(Pf),W5=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:l}=e,c=OC(Pf,e.__scopeTooltip),d=Vb(t),[f,h]=_.useState(null),g=ea(),b=_.useRef(0),y=o??c.disableHoverableContent,x=l??c.delayDuration,w=_.useRef(!1),[C,E]=ud({prop:r,defaultProp:i??!1,onChange:D=>{D?(c.onOpen(),document.dispatchEvent(new CustomEvent(WS))):c.onClose(),s==null||s(D)},caller:Pf}),R=_.useMemo(()=>C?w.current?"delayed-open":"instant-open":"closed",[C]),T=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,E(!0)},[E]),A=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E(!1)},[E]),N=_.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,E(!0),b.current=0},x)},[x,E]);return _.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),m.jsx(Fb,{...d,children:m.jsx(cY,{scope:t,contentId:g,open:C,stateAttribute:R,trigger:f,onTriggerChange:h,onTriggerEnter:_.useCallback(()=>{c.isOpenDelayedRef.current?N():T()},[c.isOpenDelayedRef,N,T]),onTriggerLeave:_.useCallback(()=>{y?A():(window.clearTimeout(b.current),b.current=0)},[A,y]),onOpen:T,onClose:A,disableHoverableContent:y,children:n})})};W5.displayName=Pf;var GS="TooltipTrigger",G5=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=gp(GS,n),s=OC(GS,n),o=Vb(n),l=_.useRef(null),c=mn(t,l,i.onTriggerChange),d=_.useRef(!1),f=_.useRef(!1),h=_.useCallback(()=>d.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),m.jsx(mp,{asChild:!0,...o,children:m.jsx(Jt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:Je(e.onPointerMove,g=>{g.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:Je(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:Je(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Je(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:Je(e.onBlur,i.onClose),onClick:Je(e.onClick,i.onClose)})})});G5.displayName=GS;var jC="TooltipPortal",[uY,dY]=Ub(jC,{forceMount:void 0}),q5=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=gp(jC,t);return m.jsx(uY,{scope:t,forceMount:n,children:m.jsx(xs,{present:n||s.open,children:m.jsx(Md,{asChild:!0,container:i,children:r})})})};q5.displayName=jC;var hd="TooltipContent",K5=_.forwardRef((e,t)=>{const n=dY(hd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=gp(hd,e.__scopeTooltip);return m.jsx(xs,{present:r||o.open,children:o.disableHoverableContent?m.jsx(Y5,{side:i,...s,ref:t}):m.jsx(hY,{side:i,...s,ref:t})})}),hY=_.forwardRef((e,t)=>{const n=gp(hd,e.__scopeTooltip),r=OC(hd,e.__scopeTooltip),i=_.useRef(null),s=mn(t,i),[o,l]=_.useState(null),{trigger:c,onClose:d}=n,f=i.current,{onPointerInTransitChange:h}=r,g=_.useCallback(()=>{l(null),h(!1)},[h]),b=_.useCallback((y,x)=>{const w=y.currentTarget,C={x:y.clientX,y:y.clientY},E=vY(C,w.getBoundingClientRect()),R=bY(C,E),T=_Y(x.getBoundingClientRect()),A=xY([...R,...T]);l(A),h(!0)},[h]);return _.useEffect(()=>()=>g(),[g]),_.useEffect(()=>{if(c&&f){const y=w=>b(w,f),x=w=>b(w,c);return c.addEventListener("pointerleave",y),f.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",y),f.removeEventListener("pointerleave",x)}}},[c,f,b,g]),_.useEffect(()=>{if(o){const y=x=>{const w=x.target,C={x:x.clientX,y:x.clientY},E=(c==null?void 0:c.contains(w))||(f==null?void 0:f.contains(w)),R=!yY(C,o);E?g():R&&(g(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[c,f,o,d,g]),m.jsx(Y5,{...e,ref:s})}),[fY,pY]=Ub(Pf,{isInside:!1}),mY=xW("TooltipContent"),Y5=_.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...l}=e,c=gp(hd,n),d=Vb(n),{onClose:f}=c;return _.useEffect(()=>(document.addEventListener(WS,f),()=>document.removeEventListener(WS,f)),[f]),_.useEffect(()=>{if(c.trigger){const h=g=>{const b=g.target;b!=null&&b.contains(c.trigger)&&f()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,f]),m.jsx(Nd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:f,children:m.jsxs($b,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(mY,{children:r}),m.jsx(fY,{scope:n,isInside:!0,children:m.jsx(oY,{id:c.contentId,role:"tooltip",children:i||r})})]})})});K5.displayName=hd;var X5="TooltipArrow",gY=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Vb(n);return pY(X5,n).isInside?null:m.jsx(Hb,{...i,...r,ref:t})});gY.displayName=X5;function vY(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function bY(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function _Y(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function yY(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const l=t[s],c=t[o],d=l.x,f=l.y,h=c.x,g=c.y;f>r!=g>r&&n<(h-d)*(r-f)/(g-f)+d&&(i=!i)}return i}function xY(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),SY(t)}function SY(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var wY=V5,Q5=W5,Z5=G5,J5=q5,zC=K5;function ej({className:e,...t}){return m.jsx("kbd",{className:ye("pointer-events-none inline-flex h-5 min-w-5 items-center justify-center rounded border border-border/60 bg-muted/50 px-1.5 font-mono text-[11px] font-medium text-current select-none",e),...t})}function CY({className:e,...t}){return m.jsx("span",{className:ye("inline-flex items-center gap-0.5",e),...t})}const kY="z-50 overflow-hidden rounded-md border border-border bg-card p-0.5 text-[11px] font-medium text-card-foreground shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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",EY=wY,uo=Q5,ho=Z5,Is=_.forwardRef(({className:e,sideOffset:t=4,...n},r)=>m.jsx(J5,{children:m.jsx(zC,{ref:r,sideOffset:t,className:ye("z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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",e),...n})}));Is.displayName=zC.displayName;const Mv=Q5,Lv=Z5;function tj(e){return e.toUpperCase()}function RY(e){const t=e.split("+");return m.jsx(CY,{children:t.map((n,r)=>m.jsx(ej,{children:tj(n)},`${n}-${r}`))})}const Of=_.forwardRef(({className:e,sideOffset:t=4,children:n,shortcut:r,...i},s)=>{const o=r===void 0?null:Array.isArray(r)?r[0]??null:r;return m.jsx(J5,{children:m.jsx(zC,{ref:s,sideOffset:t,className:ye(kY,e),...i,children:o?RY(o):m.jsx("span",{children:typeof n=="string"?tj(n):n})})})});Of.displayName="HotkeyTooltipContent";const TY="0.43.1",AY={version:TY},Jn="Kanna",EN="kanna",NY=".kanna",MY=".kanna-dev",LY="KANNA_RUNTIME_PROFILE",BC=`kanna/${AY.version}`,DY="[kanna]",IY=`~/${Jn}`;function Wb(){var t;return(t=globalThis.process)==null?void 0:t.env}function PY(e=Wb()){var t;return((t=e==null?void 0:e[LY])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function OY(e=Wb()){return PY(e)==="dev"?MY:NY}function jY(e=Wb()){return`~/${OY(e)}`}function zY(e=Wb()){return`${jY(e)}/keybindings.json`}function eg(e){return e?`${EN} ${e}`:EN}const RN=e=>{let t;const n=new Set,r=(d,f)=>{const h=typeof d=="function"?d(t):d;if(!Object.is(h,t)){const g=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(b=>b(t,g))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d))},c=t=e(r,i,l);return l},BY=(e=>e?RN(e):RN),FY=e=>e;function $Y(e,t=FY){const n=kn.useSyncExternalStore(e.subscribe,kn.useCallback(()=>t(e.getState()),[e,t]),kn.useCallback(()=>t(e.getInitialState()),[e,t]));return kn.useDebugValue(n),n}const HY=e=>{const t=BY(e),n=r=>$Y(t,r);return Object.assign(n,t),n},bo=(e=>HY),nj="always",rj="funk",UY=[{value:"blow",label:"Blow"},{value:"bottle",label:"Bottle"},{value:"frog",label:"Frog"},{value:"funk",label:"Funk"},{value:"glass",label:"Glass"},{value:"ping",label:"Ping"},{value:"pop",label:"Pop"},{value:"purr",label:"Purr"},{value:"tink",label:"Tink"}];function VY(e){switch(e){case"never":case"unfocused":case"always":return e;default:return nj}}function WY(e){switch(e){case"blow":case"bottle":case"frog":case"funk":case"glass":case"ping":case"pop":case"purr":case"tink":return e;default:return rj}}const uc=bo()(e=>({chatSoundPreference:nj,chatSoundId:rj,setChatSoundPreference:t=>e({chatSoundPreference:VY(t)}),setChatSoundId:t=>e({chatSoundId:WY(t)})})),GY={blow:"/chat-sounds/Blow.mp3",bottle:"/chat-sounds/Bottle.mp3",frog:"/chat-sounds/Frog.mp3",funk:"/chat-sounds/Funk.mp3",glass:"/chat-sounds/Glass.mp3",ping:"/chat-sounds/Ping.mp3",pop:"/chat-sounds/Pop.mp3",purr:"/chat-sounds/Purr.mp3",tink:"/chat-sounds/Tink.mp3"};function qY(e=document){return e.visibilityState!=="visible"||!e.hasFocus()}function KY(e){const t=new Audio(GY[e]);return t.preload="auto",t.play()}async function qS(e,t){if(t<=0)return;const n=Array.from({length:t},(r,i)=>new Promise(s=>{window.setTimeout(()=>{KY(e).catch(()=>{}).finally(()=>s())},i*90)}));await Promise.all(n)}function YY(e,t=document){return e==="never"?!1:e==="always"?!0:qY(t)}function XY(e){return e.projectGroups.reduce((t,n)=>t+n.chats.reduce((r,i)=>r+(i.unread?1:0)+(i.status==="waiting_for_user"?1:0),0),0)}function TN(e){let t=0;const n=new Set;for(const r of e.projectGroups)for(const i of r.chats)i.unread&&(t+=1),i.status==="waiting_for_user"&&n.add(i.chatId);return{unreadCount:t,waitingChatIds:n}}function QY(e,t){if(!e)return 0;const n=TN(e),r=TN(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const o of r.waitingChatIds)n.waitingChatIds.has(o)||(s+=1);return i+s}function KS(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const ZY=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function JY(e){const t=e.trim();for(const n of ZY){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function ij(e){return e.split("/").pop()||e}const eX=1440*6e4;function tX(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=eX,o=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<o?`${Math.floor(n/s)}d`:`${Math.floor(n/o)}w`}function nX(e){return e.lastMessageAt??e._creationTime}const Pd=({children:e,className:t,animate:n=!0,shimmerWidth:r,...i})=>m.jsx("span",{className:ye("mx-auto max-w-md text-foreground/60",n&&"animate-shiny-pulse",t),...i,children:e}),FC=1e3,Zg=60*FC,Gu=60*Zg,rx=24*Gu;function il(e){const t=Math.max(0,e);if(t<Zg)return`${Math.floor(t/FC)}s`;if(t<Gu)return`${Math.floor(t/Zg)}m`;if(t<rx){const i=Math.floor(t/Gu),s=Math.floor(t%Gu/Zg);return s===0?`${i}h`:`${i}h ${s}m`}const n=Math.floor(t/rx),r=Math.floor(t%rx/Gu);return r===0?`${n}d`:`${n}d ${r}h`}function YS(e){const t=Math.max(0,e);if(t>=Gu)return il(t);const n=Math.floor(t/FC),r=Math.floor(n/60),i=n%60;return`${r}:${i.toString().padStart(2,"0")}`}function XS(e){switch(e){case"idle":return"Idle";case"starting":return"Starting";case"running":return"Running";case"waiting_for_user":return"Waiting";case"failed":return"Failed"}}function QS(e){switch(e){case"running":return"active";case"waiting_for_user":return"attention";case"failed":return"destructive";case"idle":case"starting":default:return"muted"}}function ZS(e){switch(e){case"active":return"text-emerald-500 dark:text-emerald-400";case"attention":return"text-amber-500 dark:text-amber-400";case"destructive":return"text-destructive";case"muted":default:return"text-muted-foreground"}}function $C(e){const t=e+"CollectionProvider",[n,r]=da(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=x=>{const{scope:w,children:C}=x,E=kn.useRef(null),R=kn.useRef(new Map).current;return m.jsx(i,{scope:w,itemMap:R,collectionRef:E,children:C})};o.displayName=t;const l=e+"CollectionSlot",c=yc(l),d=kn.forwardRef((x,w)=>{const{scope:C,children:E}=x,R=s(l,C),T=mn(w,R.collectionRef);return m.jsx(c,{ref:T,children:E})});d.displayName=l;const f=e+"CollectionItemSlot",h="data-radix-collection-item",g=yc(f),b=kn.forwardRef((x,w)=>{const{scope:C,children:E,...R}=x,T=kn.useRef(null),A=mn(w,T),N=s(f,C);return kn.useEffect(()=>(N.itemMap.set(T,{ref:T,...R}),()=>void N.itemMap.delete(T))),m.jsx(g,{[h]:"",ref:A,children:E})});b.displayName=f;function y(x){const w=s(e+"CollectionConsumer",x);return kn.useCallback(()=>{const E=w.collectionRef.current;if(!E)return[];const R=Array.from(E.querySelectorAll(`[${h}]`));return Array.from(w.itemMap.values()).sort((N,D)=>R.indexOf(N.ref.current)-R.indexOf(D.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:d,ItemSlot:b},y,r]}var rX=_.createContext(void 0);function HC(e){const t=_.useContext(rX);return e||t||"ltr"}var ix="rovingFocusGroup.onEntryFocus",iX={bubbles:!1,cancelable:!0},vp="RovingFocusGroup",[JS,sj,sX]=$C(vp),[oX,oj]=da(vp,[sX]),[aX,lX]=oX(vp),aj=_.forwardRef((e,t)=>m.jsx(JS.Provider,{scope:e.__scopeRovingFocusGroup,children:m.jsx(JS.Slot,{scope:e.__scopeRovingFocusGroup,children:m.jsx(cX,{...e,ref:t})})}));aj.displayName=vp;var cX=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...h}=e,g=_.useRef(null),b=mn(t,g),y=HC(s),[x,w]=ud({prop:o,defaultProp:l??null,onChange:c,caller:vp}),[C,E]=_.useState(!1),R=zs(d),T=sj(n),A=_.useRef(!1),[N,D]=_.useState(0);return _.useEffect(()=>{const M=g.current;if(M)return M.addEventListener(ix,R),()=>M.removeEventListener(ix,R)},[R]),m.jsx(aX,{scope:n,orientation:r,dir:y,loop:i,currentTabStopId:x,onItemFocus:_.useCallback(M=>w(M),[w]),onItemShiftTab:_.useCallback(()=>E(!0),[]),onFocusableItemAdd:_.useCallback(()=>D(M=>M+1),[]),onFocusableItemRemove:_.useCallback(()=>D(M=>M-1),[]),children:m.jsx(Jt.div,{tabIndex:C||N===0?-1:0,"data-orientation":r,...h,ref:b,style:{outline:"none",...e.style},onMouseDown:Je(e.onMouseDown,()=>{A.current=!0}),onFocus:Je(e.onFocus,M=>{const W=!A.current;if(M.target===M.currentTarget&&W&&!C){const j=new CustomEvent(ix,iX);if(M.currentTarget.dispatchEvent(j),!j.defaultPrevented){const $=T().filter(z=>z.focusable),F=$.find(z=>z.active),P=$.find(z=>z.id===x),H=[F,P,...$].filter(Boolean).map(z=>z.ref.current);uj(H,f)}}A.current=!1}),onBlur:Je(e.onBlur,()=>E(!1))})})}),lj="RovingFocusGroupItem",cj=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...l}=e,c=ea(),d=s||c,f=lX(lj,n),h=f.currentTabStopId===d,g=sj(n),{onFocusableItemAdd:b,onFocusableItemRemove:y,currentTabStopId:x}=f;return _.useEffect(()=>{if(r)return b(),()=>y()},[r,b,y]),m.jsx(JS.ItemSlot,{scope:n,id:d,focusable:r,active:i,children:m.jsx(Jt.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:Je(e.onMouseDown,w=>{r?f.onItemFocus(d):w.preventDefault()}),onFocus:Je(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:Je(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const C=hX(w,f.orientation,f.dir);if(C!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let R=g().filter(T=>T.focusable).map(T=>T.ref.current);if(C==="last")R.reverse();else if(C==="prev"||C==="next"){C==="prev"&&R.reverse();const T=R.indexOf(w.currentTarget);R=f.loop?fX(R,T+1):R.slice(T+1)}setTimeout(()=>uj(R))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:x!=null}):o})})});cj.displayName=lj;var uX={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function dX(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function hX(e,t,n){const r=dX(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return uX[r]}function uj(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function fX(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var pX=aj,mX=cj,ew=["Enter"," "],gX=["ArrowDown","PageUp","Home"],dj=["ArrowUp","PageDown","End"],vX=[...gX,...dj],bX={ltr:[...ew,"ArrowRight"],rtl:[...ew,"ArrowLeft"]},_X={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bp="Menu",[jf,yX,xX]=$C(bp),[Pc,hj]=da(bp,[xX,Rl,oj]),Gb=Rl(),fj=oj(),[SX,Oc]=Pc(bp),[wX,_p]=Pc(bp),pj=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,l=Gb(t),[c,d]=_.useState(null),f=_.useRef(!1),h=zs(s),g=HC(i);return _.useEffect(()=>{const b=()=>{f.current=!0,document.addEventListener("pointerdown",y,{capture:!0,once:!0}),document.addEventListener("pointermove",y,{capture:!0,once:!0})},y=()=>f.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",y,{capture:!0}),document.removeEventListener("pointermove",y,{capture:!0})}},[]),m.jsx(Fb,{...l,children:m.jsx(SX,{scope:t,open:n,onOpenChange:h,content:c,onContentChange:d,children:m.jsx(wX,{scope:t,onClose:_.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:g,modal:o,children:r})})})};pj.displayName=bp;var CX="MenuAnchor",UC=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Gb(n);return m.jsx(mp,{...i,...r,ref:t})});UC.displayName=CX;var VC="MenuPortal",[kX,mj]=Pc(VC,{forceMount:void 0}),gj=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Oc(VC,t);return m.jsx(kX,{scope:t,forceMount:n,children:m.jsx(xs,{present:n||s.open,children:m.jsx(Md,{asChild:!0,container:i,children:r})})})};gj.displayName=VC;var gs="MenuContent",[EX,WC]=Pc(gs),vj=_.forwardRef((e,t)=>{const n=mj(gs,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Oc(gs,e.__scopeMenu),o=_p(gs,e.__scopeMenu);return m.jsx(jf.Provider,{scope:e.__scopeMenu,children:m.jsx(xs,{present:r||s.open,children:m.jsx(jf.Slot,{scope:e.__scopeMenu,children:o.modal?m.jsx(RX,{...i,ref:t}):m.jsx(TX,{...i,ref:t})})})})}),RX=_.forwardRef((e,t)=>{const n=Oc(gs,e.__scopeMenu),r=_.useRef(null),i=mn(t,r);return _.useEffect(()=>{const s=r.current;if(s)return Db(s)},[]),m.jsx(GC,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Je(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),TX=_.forwardRef((e,t)=>{const n=Oc(gs,e.__scopeMenu);return m.jsx(GC,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),AX=yc("MenuContent.ScrollLock"),GC=_.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:g,onDismiss:b,disableOutsideScroll:y,...x}=e,w=Oc(gs,n),C=_p(gs,n),E=Gb(n),R=fj(n),T=yX(n),[A,N]=_.useState(null),D=_.useRef(null),M=mn(t,D,w.onContentChange),W=_.useRef(0),j=_.useRef(""),$=_.useRef(0),F=_.useRef(null),P=_.useRef("right"),B=_.useRef(0),H=y?hp:_.Fragment,z=y?{as:AX,allowPinchZoom:!0}:void 0,U=Y=>{var se,pe;const O=j.current+Y,G=T().filter(ce=>!ce.disabled),Z=document.activeElement,I=(se=G.find(ce=>ce.ref.current===Z))==null?void 0:se.textValue,re=G.map(ce=>ce.textValue),te=$X(re,O,I),oe=(pe=G.find(ce=>ce.textValue===te))==null?void 0:pe.ref.current;(function ce(ge){j.current=ge,window.clearTimeout(W.current),ge!==""&&(W.current=window.setTimeout(()=>ce(""),1e3))})(O),oe&&setTimeout(()=>oe.focus())};_.useEffect(()=>()=>window.clearTimeout(W.current),[]),Mb();const V=_.useCallback(Y=>{var G,Z;return P.current===((G=F.current)==null?void 0:G.side)&&UX(Y,(Z=F.current)==null?void 0:Z.area)},[]);return m.jsx(EX,{scope:n,searchRef:j,onItemEnter:_.useCallback(Y=>{V(Y)&&Y.preventDefault()},[V]),onItemLeave:_.useCallback(Y=>{var O;V(Y)||((O=D.current)==null||O.focus(),N(null))},[V]),onTriggerLeave:_.useCallback(Y=>{V(Y)&&Y.preventDefault()},[V]),pointerGraceTimerRef:$,onPointerGraceIntentChange:_.useCallback(Y=>{F.current=Y},[]),children:m.jsx(H,{...z,children:m.jsx(dp,{asChild:!0,trapped:i,onMountAutoFocus:Je(s,Y=>{var O;Y.preventDefault(),(O=D.current)==null||O.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:m.jsx(Nd,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:g,onDismiss:b,children:m.jsx(pX,{asChild:!0,...R,dir:C.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:N,onEntryFocus:Je(c,Y=>{C.isUsingKeyboardRef.current||Y.preventDefault()}),preventScrollOnEntryFocus:!0,children:m.jsx($b,{role:"menu","aria-orientation":"vertical","data-state":Dj(w.open),"data-radix-menu-content":"",dir:C.dir,...E,...x,ref:M,style:{outline:"none",...x.style},onKeyDown:Je(x.onKeyDown,Y=>{const G=Y.target.closest("[data-radix-menu-content]")===Y.currentTarget,Z=Y.ctrlKey||Y.altKey||Y.metaKey,I=Y.key.length===1;G&&(Y.key==="Tab"&&Y.preventDefault(),!Z&&I&&U(Y.key));const re=D.current;if(Y.target!==re||!vX.includes(Y.key))return;Y.preventDefault();const oe=T().filter(se=>!se.disabled).map(se=>se.ref.current);dj.includes(Y.key)&&oe.reverse(),BX(oe)}),onBlur:Je(e.onBlur,Y=>{Y.currentTarget.contains(Y.target)||(window.clearTimeout(W.current),j.current="")}),onPointerMove:Je(e.onPointerMove,zf(Y=>{const O=Y.target,G=B.current!==Y.clientX;if(Y.currentTarget.contains(O)&&G){const Z=Y.clientX>B.current?"right":"left";P.current=Z,B.current=Y.clientX}}))})})})})})})});vj.displayName=gs;var NX="MenuGroup",qC=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(Jt.div,{role:"group",...r,ref:t})});qC.displayName=NX;var MX="MenuLabel",bj=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(Jt.div,{...r,ref:t})});bj.displayName=MX;var Dv="MenuItem",AN="menu.itemSelect",qb=_.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=_.useRef(null),o=_p(Dv,e.__scopeMenu),l=WC(Dv,e.__scopeMenu),c=mn(t,s),d=_.useRef(!1),f=()=>{const h=s.current;if(!n&&h){const g=new CustomEvent(AN,{bubbles:!0,cancelable:!0});h.addEventListener(AN,b=>r==null?void 0:r(b),{once:!0}),wO(h,g),g.defaultPrevented?d.current=!1:o.onClose()}};return m.jsx(_j,{...i,ref:c,disabled:n,onClick:Je(e.onClick,f),onPointerDown:h=>{var g;(g=e.onPointerDown)==null||g.call(e,h),d.current=!0},onPointerUp:Je(e.onPointerUp,h=>{var g;d.current||(g=h.currentTarget)==null||g.click()}),onKeyDown:Je(e.onKeyDown,h=>{const g=l.searchRef.current!=="";n||g&&h.key===" "||ew.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});qb.displayName=Dv;var _j=_.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=WC(Dv,n),l=fj(n),c=_.useRef(null),d=mn(t,c),[f,h]=_.useState(!1),[g,b]=_.useState("");return _.useEffect(()=>{const y=c.current;y&&b((y.textContent??"").trim())},[s.children]),m.jsx(jf.ItemSlot,{scope:n,disabled:r,textValue:i??g,children:m.jsx(mX,{asChild:!0,...l,focusable:!r,children:m.jsx(Jt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:d,onPointerMove:Je(e.onPointerMove,zf(y=>{r?o.onItemLeave(y):(o.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Je(e.onPointerLeave,zf(y=>o.onItemLeave(y))),onFocus:Je(e.onFocus,()=>h(!0)),onBlur:Je(e.onBlur,()=>h(!1))})})})}),LX="MenuCheckboxItem",yj=_.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return m.jsx(kj,{scope:e.__scopeMenu,checked:n,children:m.jsx(qb,{role:"menuitemcheckbox","aria-checked":Iv(n)?"mixed":n,...i,ref:t,"data-state":YC(n),onSelect:Je(i.onSelect,()=>r==null?void 0:r(Iv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});yj.displayName=LX;var xj="MenuRadioGroup",[DX,IX]=Pc(xj,{value:void 0,onValueChange:()=>{}}),Sj=_.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=zs(r);return m.jsx(DX,{scope:e.__scopeMenu,value:n,onValueChange:s,children:m.jsx(qC,{...i,ref:t})})});Sj.displayName=xj;var wj="MenuRadioItem",Cj=_.forwardRef((e,t)=>{const{value:n,...r}=e,i=IX(wj,e.__scopeMenu),s=n===i.value;return m.jsx(kj,{scope:e.__scopeMenu,checked:s,children:m.jsx(qb,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":YC(s),onSelect:Je(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});Cj.displayName=wj;var KC="MenuItemIndicator",[kj,PX]=Pc(KC,{checked:!1}),Ej=_.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=PX(KC,n);return m.jsx(xs,{present:r||Iv(s.checked)||s.checked===!0,children:m.jsx(Jt.span,{...i,ref:t,"data-state":YC(s.checked)})})});Ej.displayName=KC;var OX="MenuSeparator",Rj=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(Jt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Rj.displayName=OX;var jX="MenuArrow",Tj=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Gb(n);return m.jsx(Hb,{...i,...r,ref:t})});Tj.displayName=jX;var zX="MenuSub",[jCe,Aj]=Pc(zX),sf="MenuSubTrigger",Nj=_.forwardRef((e,t)=>{const n=Oc(sf,e.__scopeMenu),r=_p(sf,e.__scopeMenu),i=Aj(sf,e.__scopeMenu),s=WC(sf,e.__scopeMenu),o=_.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=s,d={__scopeMenu:e.__scopeMenu},f=_.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return _.useEffect(()=>f,[f]),_.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),c(null)}},[l,c]),m.jsx(UC,{asChild:!0,...d,children:m.jsx(_j,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Dj(n.open),...e,ref:vC(t,i.onTriggerChange),onClick:h=>{var g;(g=e.onClick)==null||g.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Je(e.onPointerMove,zf(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:Je(e.onPointerLeave,zf(h=>{var b,y;f();const g=(b=n.content)==null?void 0:b.getBoundingClientRect();if(g){const x=(y=n.content)==null?void 0:y.dataset.side,w=x==="right",C=w?-5:5,E=g[w?"left":"right"],R=g[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+C,y:h.clientY},{x:E,y:g.top},{x:R,y:g.top},{x:R,y:g.bottom},{x:E,y:g.bottom}],side:x}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Je(e.onKeyDown,h=>{var b;const g=s.searchRef.current!=="";e.disabled||g&&h.key===" "||bX[r.dir].includes(h.key)&&(n.onOpenChange(!0),(b=n.content)==null||b.focus(),h.preventDefault())})})})});Nj.displayName=sf;var Mj="MenuSubContent",Lj=_.forwardRef((e,t)=>{const n=mj(gs,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Oc(gs,e.__scopeMenu),o=_p(gs,e.__scopeMenu),l=Aj(Mj,e.__scopeMenu),c=_.useRef(null),d=mn(t,c);return m.jsx(jf.Provider,{scope:e.__scopeMenu,children:m.jsx(xs,{present:r||s.open,children:m.jsx(jf.Slot,{scope:e.__scopeMenu,children:m.jsx(GC,{id:l.contentId,"aria-labelledby":l.triggerId,...i,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var h;o.isUsingKeyboardRef.current&&((h=c.current)==null||h.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:Je(e.onFocusOutside,f=>{f.target!==l.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Je(e.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:Je(e.onKeyDown,f=>{var b;const h=f.currentTarget.contains(f.target),g=_X[o.dir].includes(f.key);h&&g&&(s.onOpenChange(!1),(b=l.trigger)==null||b.focus(),f.preventDefault())})})})})})});Lj.displayName=Mj;function Dj(e){return e?"open":"closed"}function Iv(e){return e==="indeterminate"}function YC(e){return Iv(e)?"indeterminate":e?"checked":"unchecked"}function BX(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function FX(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function $X(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=FX(e,Math.max(s,0));i.length===1&&(o=o.filter(d=>d!==n));const c=o.find(d=>d.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}function HX(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const l=t[s],c=t[o],d=l.x,f=l.y,h=c.x,g=c.y;f>r!=g>r&&n<(h-d)*(r-f)/(g-f)+d&&(i=!i)}return i}function UX(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return HX(n,t)}function zf(e){return t=>t.pointerType==="mouse"?e(t):void 0}var VX=pj,WX=UC,GX=gj,qX=vj,KX=qC,YX=bj,XX=qb,QX=yj,ZX=Sj,JX=Cj,eQ=Ej,tQ=Rj,nQ=Tj,rQ=Nj,iQ=Lj,XC="ContextMenu",[sQ]=da(XC,[hj]),di=hj(),[oQ,Ij]=sQ(XC),Pj=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:s=!0}=e,[o,l]=_.useState(!1),c=di(t),d=zs(r),f=_.useCallback(h=>{l(h),d(h)},[d]);return m.jsx(oQ,{scope:t,open:o,onOpenChange:f,modal:s,children:m.jsx(VX,{...c,dir:i,open:o,onOpenChange:f,modal:s,children:n})})};Pj.displayName=XC;var Oj="ContextMenuTrigger",jj=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...i}=e,s=Ij(Oj,n),o=di(n),l=_.useRef({x:0,y:0}),c=_.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=_.useRef(0),f=_.useCallback(()=>window.clearTimeout(d.current),[]),h=g=>{l.current={x:g.clientX,y:g.clientY},s.onOpenChange(!0)};return _.useEffect(()=>f,[f]),_.useEffect(()=>void(r&&f()),[r,f]),m.jsxs(m.Fragment,{children:[m.jsx(WX,{...o,virtualRef:c}),m.jsx(Jt.span,{"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:Je(e.onContextMenu,g=>{f(),h(g),g.preventDefault()}),onPointerDown:r?e.onPointerDown:Je(e.onPointerDown,tg(g=>{f(),d.current=window.setTimeout(()=>h(g),700)})),onPointerMove:r?e.onPointerMove:Je(e.onPointerMove,tg(f)),onPointerCancel:r?e.onPointerCancel:Je(e.onPointerCancel,tg(f)),onPointerUp:r?e.onPointerUp:Je(e.onPointerUp,tg(f))})]})});jj.displayName=Oj;var aQ="ContextMenuPortal",zj=e=>{const{__scopeContextMenu:t,...n}=e,r=di(t);return m.jsx(GX,{...r,...n})};zj.displayName=aQ;var Bj="ContextMenuContent",Fj=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Ij(Bj,n),s=di(n),o=_.useRef(!1);return m.jsx(qX,{...s,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{var c;(c=e.onCloseAutoFocus)==null||c.call(e,l),!l.defaultPrevented&&o.current&&l.preventDefault(),o.current=!1},onInteractOutside:l=>{var c;(c=e.onInteractOutside)==null||c.call(e,l),!l.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Fj.displayName=Bj;var lQ="ContextMenuGroup",cQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(KX,{...i,...r,ref:t})});cQ.displayName=lQ;var uQ="ContextMenuLabel",dQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(YX,{...i,...r,ref:t})});dQ.displayName=uQ;var hQ="ContextMenuItem",$j=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(XX,{...i,...r,ref:t})});$j.displayName=hQ;var fQ="ContextMenuCheckboxItem",pQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(QX,{...i,...r,ref:t})});pQ.displayName=fQ;var mQ="ContextMenuRadioGroup",gQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(ZX,{...i,...r,ref:t})});gQ.displayName=mQ;var vQ="ContextMenuRadioItem",bQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(JX,{...i,...r,ref:t})});bQ.displayName=vQ;var _Q="ContextMenuItemIndicator",yQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(eQ,{...i,...r,ref:t})});yQ.displayName=_Q;var xQ="ContextMenuSeparator",Hj=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(tQ,{...i,...r,ref:t})});Hj.displayName=xQ;var SQ="ContextMenuArrow",wQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(nQ,{...i,...r,ref:t})});wQ.displayName=SQ;var CQ="ContextMenuSubTrigger",kQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(rQ,{...i,...r,ref:t})});kQ.displayName=CQ;var EQ="ContextMenuSubContent",RQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(iQ,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});RQ.displayName=EQ;function tg(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var TQ=Pj,AQ=jj,NQ=zj,Uj=Fj,Vj=$j,Wj=Hj;const Gj=_.createContext(null);function Od({onOpenChange:e,...t}){const[n,r]=_.useState(0),i=_.useCallback(()=>{r(s=>s+1),e==null||e(!1)},[e]);return m.jsx(Gj.Provider,{value:i,children:m.jsx(TQ,{onOpenChange:e,...t},n)})}const jd=AQ,jc=_.forwardRef(({className:e,...t},n)=>m.jsx(NQ,{children:m.jsx(Uj,{ref:n,className:ye("z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",e),...t})}));jc.displayName=Uj.displayName;const $n=_.forwardRef(({className:e,onSelect:t,...n},r)=>{const i=_.useContext(Gj);return m.jsx(Vj,{ref:r,className:ye("relative flex cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium text-foreground outline-hidden transition-colors hover:bg-muted focus:bg-muted data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onSelect:s=>{t==null||t(s),i==null||i()},...n})});$n.displayName=Vj.displayName;const qj=_.forwardRef(({className:e,...t},n)=>m.jsx(Wj,{ref:n,className:ye("-mx-1 my-1 h-px bg-border",e),...t}));qj.displayName=Wj.displayName;function MQ({editorLabel:e,onCopyPath:t,onShowArchived:n,onOpenInFinder:r,onOpenInEditor:i,onHide:s,children:o}){return m.jsxs(Od,{children:[m.jsx(jd,{asChild:!0,children:o}),m.jsxs(jc,{children:[m.jsxs($n,{onSelect:l=>{l.stopPropagation(),t()},children:[m.jsx(yl,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Copy Path"})]}),m.jsxs($n,{onSelect:l=>{l.stopPropagation(),n()},children:[m.jsx(aC,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Show Archived"})]}),m.jsxs($n,{onSelect:l=>{l.stopPropagation(),r()},children:[m.jsx(Tb,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Show in Finder"})]}),m.jsxs($n,{onSelect:l=>{l.stopPropagation(),i()},children:[m.jsx(lC,{className:"h-3.5 w-3.5"}),m.jsxs("span",{className:"text-xs font-medium",children:["Open in ",e]})]}),m.jsxs($n,{onSelect:l=>{l.stopPropagation(),s()},className:"text-destructive hover:bg-destructive/10 focus:bg-destructive/10",children:[m.jsx(h9,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Hide"})]})]})]})}function LQ({canFork:e,onRename:t,onShare:n,onOpenInFinder:r,onFork:i,onArchive:s,onDelete:o,children:l}){return m.jsxs(Od,{children:[m.jsx(jd,{asChild:!0,children:l}),m.jsxs(jc,{children:[m.jsxs($n,{onSelect:c=>{c.preventDefault(),t()},children:[m.jsx(fC,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Rename"})]}),m.jsxs($n,{onSelect:c=>{c.preventDefault(),n()},children:[m.jsx(gC,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Share"})]}),m.jsxs($n,{onSelect:c=>{c.preventDefault(),r()},children:[m.jsx(Tb,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Open in Finder"})]}),m.jsxs($n,{disabled:!e,onSelect:c=>{c.preventDefault(),e&&i()},children:[m.jsx(xO,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Fork"})]}),m.jsxs($n,{onSelect:c=>{c.preventDefault(),s()},children:[m.jsx(aC,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Archive"})]}),m.jsxs($n,{onSelect:c=>{c.preventDefault(),o()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[m.jsx(mC,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Delete"})]})]})]})}const DQ=new Set(["starting","running"]);function IQ({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onRenameChat:o,onShareChat:l,onOpenInFinder:c,onForkChat:d,onArchiveChat:f,onDeleteChat:h}){const g=(e.status==="running"||e.status==="waiting_for_user")&&e.stateEnteredAt!=null,b=g&&e.stateEnteredAt!=null?`${XS(e.status)} ${YS(n-e.stateEnteredAt)}`:il(n-(e.lastMessageAt??e._creationTime)),y=i&&r?r:b,x=i&&!!r,w=Iq(e.chatId),C=m.jsxs("div",{"data-chat-id":w,className:ye("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-lg cursor-pointer border-border/0 hover:border-border hover:bg-muted/20 active:scale-[0.985] border transition-all",t===w?"bg-muted hover:bg-muted border-border":"border-border/0 dark:hover:border-border/40 "),onClick:()=>s(e.chatId),children:[DQ.has(e.status)?m.jsx(pn,{className:"size-3.5 flex-shrink-0 animate-spin text-logo"}):e.status==="waiting_for_user"?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-info/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-info ring-2 ring-muted/20 dark:ring-muted/50"})]})}):e.unread?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-success/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-success ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,m.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?m.jsx(Pd,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.status!=="idle"||t===w||e.unread?m.jsx("span",{className:"",children:e.title}):m.jsx("span",{className:"text-slate-500 dark:text-slate-400",children:e.title})}),m.jsxs("div",{className:ye("relative h-7 mr-[2px] shrink-0",e.canFork?"w-12":g?"w-20":"w-6"),children:[y?x?m.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-0.5 text-[11px] text-foreground transition-opacity group-hover:opacity-0",children:m.jsx(ej,{className:"h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-[10px]",children:r})}):m.jsx("span",{className:ye("hidden md:flex absolute inset-0 items-center justify-end pr-1 text-[11px] tabular-nums opacity-80 transition-opacity group-hover:opacity-0",g?ZS(QS(e.status)):"text-muted-foreground opacity-60"),children:y}):null,m.jsxs("div",{className:ye("absolute inset-0 flex items-center justify-end gap-0 opacity-100 mr-[3px]",y?"md:opacity-0 md:group-hover:opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100"),children:[e.canFork?m.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:E=>{E.stopPropagation(),d(e.chatId)},title:"Fork chat",children:m.jsx(xO,{className:"size-3.5"})}):null,m.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:E=>{E.stopPropagation(),f(e.chatId)},title:"Archive chat",children:m.jsx(aC,{className:"size-3.5"})})]})]})]},e._id);return m.jsx(LQ,{canFork:e.canFork,onRename:()=>o(e.chatId),onShare:()=>l(e.chatId),onOpenInFinder:()=>c(e.localPath),onFork:()=>d(e.chatId),onArchive:()=>f(e.chatId),onDelete:()=>h(e.chatId),children:C})}const PQ=_.memo(IQ);function OQ(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const Kb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zd(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function QC(e){return"nodeType"in e}function Ri(e){var t,n;return e?zd(e)?e:QC(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function ZC(e){const{Document:t}=Ri(e);return e instanceof t}function yp(e){return zd(e)?!1:e instanceof Ri(e).HTMLElement}function Kj(e){return e instanceof Ri(e).SVGElement}function Bd(e){return e?zd(e)?e.document:QC(e)?ZC(e)?e:yp(e)||Kj(e)?e.ownerDocument:document:document:document}const mo=Kb?_.useLayoutEffect:_.useEffect;function JC(e){const t=_.useRef(e);return mo(()=>{t.current=e}),_.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function jQ(){const e=_.useRef(null),t=_.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Bf(e,t){t===void 0&&(t=[e]);const n=_.useRef(e);return mo(()=>{n.current!==e&&(n.current=e)},t),n}function xp(e,t){const n=_.useRef();return _.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Pv(e){const t=JC(e),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function tw(e){const t=_.useRef();return _.useEffect(()=>{t.current=e},[e]),t.current}let sx={};function Sp(e,t){return _.useMemo(()=>{if(t)return t;const n=sx[e]==null?0:sx[e]+1;return sx[e]=n,e+"-"+n},[e,t])}function Yj(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,o)=>{const l=Object.entries(o);for(const[c,d]of l){const f=s[c];f!=null&&(s[c]=f+e*d)}return s},{...t})}}const ed=Yj(1),Ov=Yj(-1);function zQ(e){return"clientX"in e&&"clientY"in e}function ek(e){if(!e)return!1;const{KeyboardEvent:t}=Ri(e.target);return t&&e instanceof t}function BQ(e){if(!e)return!1;const{TouchEvent:t}=Ri(e.target);return t&&e instanceof t}function nw(e){if(BQ(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return zQ(e)?{x:e.clientX,y:e.clientY}:null}const Ff=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Ff.Translate.toString(e),Ff.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),NN="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function FQ(e){return e.matches(NN)?e:e.querySelector(NN)}const $Q={display:"none"};function HQ(e){let{id:t,value:n}=e;return kn.createElement("div",{id:t,style:$Q},n)}function UQ(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return kn.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function VQ(){const[e,t]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Xj=_.createContext(null);function WQ(e){const t=_.useContext(Xj);_.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function GQ(){const[e]=_.useState(()=>new Set),t=_.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[_.useCallback(r=>{let{type:i,event:s}=r;e.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,s)})},[e]),t]}const qQ={draggable:`
|
|
640
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},zG="DialogDescriptionWarning",BG=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${YO(zG).contentName}}.`;return _.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},FG=OO,$G=BO,XO=FO,QO=$O,HG=UO,UG=WO,VG=qO;function ZO(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=ZO(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function JO(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=ZO(e))&&(r&&(r+=" "),r+=t);return r}const WG=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},GG=(e,t)=>({classGroupId:e,validator:t}),e5=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Cv="-",sN=[],qG="arbitrary..",KG=e=>{const t=XG(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return YG(o);const l=o.split(Cv),c=l[0]===""&&l.length>1?1:0;return t5(l,c,t)},getConflictingClassGroupIds:(o,l)=>{if(l){const c=r[o],d=n[o];return c?d?WG(d,c):c:d||sN}return n[o]||sN}}},t5=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],s=n.nextPart.get(i);if(s){const d=t5(e,t+1,s);if(d)return d}const o=n.validators;if(o===null)return;const l=t===0?e.join(Cv):e.slice(t).join(Cv),c=o.length;for(let d=0;d<c;d++){const f=o[d];if(f.validator(l))return f.classGroupId}},YG=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?qG+r:void 0})(),XG=e=>{const{theme:t,classGroups:n}=e;return QG(n,t)},QG=(e,t)=>{const n=e5();for(const r in e){const i=e[r];xC(i,n,r,t)}return n},xC=(e,t,n,r)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];ZG(o,t,n,r)}},ZG=(e,t,n,r)=>{if(typeof e=="string"){JG(e,t,n);return}if(typeof e=="function"){eq(e,t,n,r);return}tq(e,t,n,r)},JG=(e,t,n)=>{const r=e===""?t:n5(t,e);r.classGroupId=n},eq=(e,t,n,r)=>{if(nq(e)){xC(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(GG(n,e))},tq=(e,t,n,r)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[l,c]=i[o];xC(c,n5(t,l),n,r)}},n5=(e,t)=>{let n=e;const r=t.split(Cv),i=r.length;for(let s=0;s<i;s++){const o=r[s];let l=n.nextPart.get(o);l||(l=e5(),n.nextPart.set(o,l)),n=l}return n},nq=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,rq=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(s,o)=>{n[s]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=r[s])!==void 0)return i(s,o),o},set(s,o){s in n?n[s]=o:i(s,o)}}},$S="!",oN=":",iq=[],aN=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),sq=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const s=[];let o=0,l=0,c=0,d;const f=i.length;for(let x=0;x<f;x++){const w=i[x];if(o===0&&l===0){if(w===oN){s.push(i.slice(c,x)),c=x+1;continue}if(w==="/"){d=x;continue}}w==="["?o++:w==="]"?o--:w==="("?l++:w===")"&&l--}const h=s.length===0?i:i.slice(c);let g=h,b=!1;h.endsWith($S)?(g=h.slice(0,-1),b=!0):h.startsWith($S)&&(g=h.slice(1),b=!0);const y=d&&d>c?d-c:void 0;return aN(s,b,g,y)};if(t){const i=t+oN,s=r;r=o=>o.startsWith(i)?s(o.slice(i.length)):aN(iq,!1,o,void 0,!0)}if(n){const i=r;r=s=>n({className:s,parseClassName:i})}return r},oq=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let s=0;s<n.length;s++){const o=n[s],l=o[0]==="[",c=t.has(o);l||c?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},aq=e=>({cache:rq(e.cacheSize),parseClassName:sq(e),sortModifiers:oq(e),...KG(e)}),lq=/\s+/,cq=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],l=e.trim().split(lq);let c="";for(let d=l.length-1;d>=0;d-=1){const f=l[d],{isExternal:h,modifiers:g,hasImportantModifier:b,baseClassName:y,maybePostfixModifierPosition:x}=n(f);if(h){c=f+(c.length>0?" "+c:c);continue}let w=!!x,C=r(w?y.substring(0,x):y);if(!C){if(!w){c=f+(c.length>0?" "+c:c);continue}if(C=r(y),!C){c=f+(c.length>0?" "+c:c);continue}w=!1}const E=g.length===0?"":g.length===1?g[0]:s(g).join(":"),R=b?E+$S:E,T=R+C;if(o.indexOf(T)>-1)continue;o.push(T);const A=i(C,w);for(let N=0;N<A.length;++N){const D=A[N];o.push(R+D)}c=f+(c.length>0?" "+c:c)}return c},uq=(...e)=>{let t=0,n,r,i="";for(;t<e.length;)(n=e[t++])&&(r=r5(n))&&(i&&(i+=" "),i+=r);return i},r5=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=r5(e[r]))&&(n&&(n+=" "),n+=t);return n},dq=(e,...t)=>{let n,r,i,s;const o=c=>{const d=t.reduce((f,h)=>h(f),e());return n=aq(d),r=n.cache.get,i=n.cache.set,s=l,l(c)},l=c=>{const d=r(c);if(d)return d;const f=cq(c,n);return i(c,f),f};return s=o,(...c)=>s(uq(...c))},hq=[],dr=e=>{const t=n=>n[e]||hq;return t.isThemeGetter=!0,t},i5=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,s5=/^\((?:(\w[\w-]*):)?(.+)\)$/i,fq=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,pq=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,mq=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,gq=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,vq=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,bq=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ga=e=>fq.test(e),qt=e=>!!e&&!Number.isNaN(Number(e)),qa=e=>!!e&&Number.isInteger(Number(e)),Jy=e=>e.endsWith("%")&&qt(e.slice(0,-1)),Bo=e=>pq.test(e),o5=()=>!0,_q=e=>mq.test(e)&&!gq.test(e),SC=()=>!1,yq=e=>vq.test(e),xq=e=>bq.test(e),Sq=e=>!nt(e)&&!it(e),wq=e=>El(e,c5,SC),nt=e=>i5.test(e),Yl=e=>El(e,u5,_q),lN=e=>El(e,Mq,qt),Cq=e=>El(e,h5,o5),kq=e=>El(e,d5,SC),cN=e=>El(e,a5,SC),Eq=e=>El(e,l5,xq),Qm=e=>El(e,f5,yq),it=e=>s5.test(e),$h=e=>Ic(e,u5),Rq=e=>Ic(e,d5),uN=e=>Ic(e,a5),Tq=e=>Ic(e,c5),Aq=e=>Ic(e,l5),Zm=e=>Ic(e,f5,!0),Nq=e=>Ic(e,h5,!0),El=(e,t,n)=>{const r=i5.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ic=(e,t,n=!1)=>{const r=s5.exec(e);return r?r[1]?t(r[1]):n:!1},a5=e=>e==="position"||e==="percentage",l5=e=>e==="image"||e==="url",c5=e=>e==="length"||e==="size"||e==="bg-size",u5=e=>e==="length",Mq=e=>e==="number",d5=e=>e==="family-name",h5=e=>e==="number"||e==="weight",f5=e=>e==="shadow",Lq=()=>{const e=dr("color"),t=dr("font"),n=dr("text"),r=dr("font-weight"),i=dr("tracking"),s=dr("leading"),o=dr("breakpoint"),l=dr("container"),c=dr("spacing"),d=dr("radius"),f=dr("shadow"),h=dr("inset-shadow"),g=dr("text-shadow"),b=dr("drop-shadow"),y=dr("blur"),x=dr("perspective"),w=dr("aspect"),C=dr("ease"),E=dr("animate"),R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...T(),it,nt],N=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto","contain","none"],M=()=>[it,nt,c],W=()=>[Ga,"full","auto",...M()],j=()=>[qa,"none","subgrid",it,nt],$=()=>["auto",{span:["full",qa,it,nt]},qa,it,nt],F=()=>[qa,"auto",it,nt],P=()=>["auto","min","max","fr",it,nt],B=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],H=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...M()],U=()=>[Ga,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...M()],V=()=>[Ga,"screen","full","dvw","lvw","svw","min","max","fit",...M()],Y=()=>[Ga,"screen","full","lh","dvh","lvh","svh","min","max","fit",...M()],O=()=>[e,it,nt],G=()=>[...T(),uN,cN,{position:[it,nt]}],Z=()=>["no-repeat",{repeat:["","x","y","space","round"]}],I=()=>["auto","cover","contain",Tq,wq,{size:[it,nt]}],re=()=>[Jy,$h,Yl],te=()=>["","none","full",d,it,nt],oe=()=>["",qt,$h,Yl],se=()=>["solid","dashed","dotted","double"],pe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ce=()=>[qt,Jy,uN,cN],ge=()=>["","none",y,it,nt],Ce=()=>["none",qt,it,nt],ke=()=>["none",qt,it,nt],De=()=>[qt,it,nt],be=()=>[Ga,"full",...M()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Bo],breakpoint:[Bo],color:[o5],container:[Bo],"drop-shadow":[Bo],ease:["in","out","in-out"],font:[Sq],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Bo],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Bo],shadow:[Bo],spacing:["px",qt],text:[Bo],"text-shadow":[Bo],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ga,nt,it,w]}],container:["container"],columns:[{columns:[qt,nt,it,l]}],"break-after":[{"break-after":R()}],"break-before":[{"break-before":R()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:W()}],"inset-x":[{"inset-x":W()}],"inset-y":[{"inset-y":W()}],start:[{"inset-s":W(),start:W()}],end:[{"inset-e":W(),end:W()}],"inset-bs":[{"inset-bs":W()}],"inset-be":[{"inset-be":W()}],top:[{top:W()}],right:[{right:W()}],bottom:[{bottom:W()}],left:[{left:W()}],visibility:["visible","invisible","collapse"],z:[{z:[qa,"auto",it,nt]}],basis:[{basis:[Ga,"full","auto",l,...M()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[qt,Ga,"auto","initial","none",nt]}],grow:[{grow:["",qt,it,nt]}],shrink:[{shrink:["",qt,it,nt]}],order:[{order:[qa,"first","last","none",it,nt]}],"grid-cols":[{"grid-cols":j()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":F()}],"col-end":[{"col-end":F()}],"grid-rows":[{"grid-rows":j()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":F()}],"row-end":[{"row-end":F()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":P()}],"auto-rows":[{"auto-rows":P()}],gap:[{gap:M()}],"gap-x":[{"gap-x":M()}],"gap-y":[{"gap-y":M()}],"justify-content":[{justify:[...B(),"normal"]}],"justify-items":[{"justify-items":[...H(),"normal"]}],"justify-self":[{"justify-self":["auto",...H()]}],"align-content":[{content:["normal",...B()]}],"align-items":[{items:[...H(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...H(),{baseline:["","last"]}]}],"place-content":[{"place-content":B()}],"place-items":[{"place-items":[...H(),"baseline"]}],"place-self":[{"place-self":["auto",...H()]}],p:[{p:M()}],px:[{px:M()}],py:[{py:M()}],ps:[{ps:M()}],pe:[{pe:M()}],pbs:[{pbs:M()}],pbe:[{pbe:M()}],pt:[{pt:M()}],pr:[{pr:M()}],pb:[{pb:M()}],pl:[{pl:M()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mbs:[{mbs:z()}],mbe:[{mbe:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":M()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":M()}],"space-y-reverse":["space-y-reverse"],size:[{size:U()}],"inline-size":[{inline:["auto",...V()]}],"min-inline-size":[{"min-inline":["auto",...V()]}],"max-inline-size":[{"max-inline":["none",...V()]}],"block-size":[{block:["auto",...Y()]}],"min-block-size":[{"min-block":["auto",...Y()]}],"max-block-size":[{"max-block":["none",...Y()]}],w:[{w:[l,"screen",...U()]}],"min-w":[{"min-w":[l,"screen","none",...U()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...U()]}],h:[{h:["screen","lh",...U()]}],"min-h":[{"min-h":["screen","lh","none",...U()]}],"max-h":[{"max-h":["screen","lh",...U()]}],"font-size":[{text:["base",n,$h,Yl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Nq,Cq]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Jy,nt]}],"font-family":[{font:[Rq,kq,t]}],"font-features":[{"font-features":[nt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,it,nt]}],"line-clamp":[{"line-clamp":[qt,"none",it,lN]}],leading:[{leading:[s,...M()]}],"list-image":[{"list-image":["none",it,nt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",it,nt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:O()}],"text-color":[{text:O()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...se(),"wavy"]}],"text-decoration-thickness":[{decoration:[qt,"from-font","auto",it,Yl]}],"text-decoration-color":[{decoration:O()}],"underline-offset":[{"underline-offset":[qt,"auto",it,nt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:M()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",it,nt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",it,nt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:G()}],"bg-repeat":[{bg:Z()}],"bg-size":[{bg:I()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qa,it,nt],radial:["",it,nt],conic:[qa,it,nt]},Aq,Eq]}],"bg-color":[{bg:O()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:O()}],"gradient-via":[{via:O()}],"gradient-to":[{to:O()}],rounded:[{rounded:te()}],"rounded-s":[{"rounded-s":te()}],"rounded-e":[{"rounded-e":te()}],"rounded-t":[{"rounded-t":te()}],"rounded-r":[{"rounded-r":te()}],"rounded-b":[{"rounded-b":te()}],"rounded-l":[{"rounded-l":te()}],"rounded-ss":[{"rounded-ss":te()}],"rounded-se":[{"rounded-se":te()}],"rounded-ee":[{"rounded-ee":te()}],"rounded-es":[{"rounded-es":te()}],"rounded-tl":[{"rounded-tl":te()}],"rounded-tr":[{"rounded-tr":te()}],"rounded-br":[{"rounded-br":te()}],"rounded-bl":[{"rounded-bl":te()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-bs":[{"border-bs":oe()}],"border-w-be":[{"border-be":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...se(),"hidden","none"]}],"divide-style":[{divide:[...se(),"hidden","none"]}],"border-color":[{border:O()}],"border-color-x":[{"border-x":O()}],"border-color-y":[{"border-y":O()}],"border-color-s":[{"border-s":O()}],"border-color-e":[{"border-e":O()}],"border-color-bs":[{"border-bs":O()}],"border-color-be":[{"border-be":O()}],"border-color-t":[{"border-t":O()}],"border-color-r":[{"border-r":O()}],"border-color-b":[{"border-b":O()}],"border-color-l":[{"border-l":O()}],"divide-color":[{divide:O()}],"outline-style":[{outline:[...se(),"none","hidden"]}],"outline-offset":[{"outline-offset":[qt,it,nt]}],"outline-w":[{outline:["",qt,$h,Yl]}],"outline-color":[{outline:O()}],shadow:[{shadow:["","none",f,Zm,Qm]}],"shadow-color":[{shadow:O()}],"inset-shadow":[{"inset-shadow":["none",h,Zm,Qm]}],"inset-shadow-color":[{"inset-shadow":O()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:O()}],"ring-offset-w":[{"ring-offset":[qt,Yl]}],"ring-offset-color":[{"ring-offset":O()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":O()}],"text-shadow":[{"text-shadow":["none",g,Zm,Qm]}],"text-shadow-color":[{"text-shadow":O()}],opacity:[{opacity:[qt,it,nt]}],"mix-blend":[{"mix-blend":[...pe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":pe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[qt]}],"mask-image-linear-from-pos":[{"mask-linear-from":ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":ce()}],"mask-image-linear-from-color":[{"mask-linear-from":O()}],"mask-image-linear-to-color":[{"mask-linear-to":O()}],"mask-image-t-from-pos":[{"mask-t-from":ce()}],"mask-image-t-to-pos":[{"mask-t-to":ce()}],"mask-image-t-from-color":[{"mask-t-from":O()}],"mask-image-t-to-color":[{"mask-t-to":O()}],"mask-image-r-from-pos":[{"mask-r-from":ce()}],"mask-image-r-to-pos":[{"mask-r-to":ce()}],"mask-image-r-from-color":[{"mask-r-from":O()}],"mask-image-r-to-color":[{"mask-r-to":O()}],"mask-image-b-from-pos":[{"mask-b-from":ce()}],"mask-image-b-to-pos":[{"mask-b-to":ce()}],"mask-image-b-from-color":[{"mask-b-from":O()}],"mask-image-b-to-color":[{"mask-b-to":O()}],"mask-image-l-from-pos":[{"mask-l-from":ce()}],"mask-image-l-to-pos":[{"mask-l-to":ce()}],"mask-image-l-from-color":[{"mask-l-from":O()}],"mask-image-l-to-color":[{"mask-l-to":O()}],"mask-image-x-from-pos":[{"mask-x-from":ce()}],"mask-image-x-to-pos":[{"mask-x-to":ce()}],"mask-image-x-from-color":[{"mask-x-from":O()}],"mask-image-x-to-color":[{"mask-x-to":O()}],"mask-image-y-from-pos":[{"mask-y-from":ce()}],"mask-image-y-to-pos":[{"mask-y-to":ce()}],"mask-image-y-from-color":[{"mask-y-from":O()}],"mask-image-y-to-color":[{"mask-y-to":O()}],"mask-image-radial":[{"mask-radial":[it,nt]}],"mask-image-radial-from-pos":[{"mask-radial-from":ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":ce()}],"mask-image-radial-from-color":[{"mask-radial-from":O()}],"mask-image-radial-to-color":[{"mask-radial-to":O()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[qt]}],"mask-image-conic-from-pos":[{"mask-conic-from":ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":ce()}],"mask-image-conic-from-color":[{"mask-conic-from":O()}],"mask-image-conic-to-color":[{"mask-conic-to":O()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:G()}],"mask-repeat":[{mask:Z()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",it,nt]}],filter:[{filter:["","none",it,nt]}],blur:[{blur:ge()}],brightness:[{brightness:[qt,it,nt]}],contrast:[{contrast:[qt,it,nt]}],"drop-shadow":[{"drop-shadow":["","none",b,Zm,Qm]}],"drop-shadow-color":[{"drop-shadow":O()}],grayscale:[{grayscale:["",qt,it,nt]}],"hue-rotate":[{"hue-rotate":[qt,it,nt]}],invert:[{invert:["",qt,it,nt]}],saturate:[{saturate:[qt,it,nt]}],sepia:[{sepia:["",qt,it,nt]}],"backdrop-filter":[{"backdrop-filter":["","none",it,nt]}],"backdrop-blur":[{"backdrop-blur":ge()}],"backdrop-brightness":[{"backdrop-brightness":[qt,it,nt]}],"backdrop-contrast":[{"backdrop-contrast":[qt,it,nt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",qt,it,nt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[qt,it,nt]}],"backdrop-invert":[{"backdrop-invert":["",qt,it,nt]}],"backdrop-opacity":[{"backdrop-opacity":[qt,it,nt]}],"backdrop-saturate":[{"backdrop-saturate":[qt,it,nt]}],"backdrop-sepia":[{"backdrop-sepia":["",qt,it,nt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":M()}],"border-spacing-x":[{"border-spacing-x":M()}],"border-spacing-y":[{"border-spacing-y":M()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",it,nt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[qt,"initial",it,nt]}],ease:[{ease:["linear","initial",C,it,nt]}],delay:[{delay:[qt,it,nt]}],animate:[{animate:["none",E,it,nt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,it,nt]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:Ce()}],"rotate-x":[{"rotate-x":Ce()}],"rotate-y":[{"rotate-y":Ce()}],"rotate-z":[{"rotate-z":Ce()}],scale:[{scale:ke()}],"scale-x":[{"scale-x":ke()}],"scale-y":[{"scale-y":ke()}],"scale-z":[{"scale-z":ke()}],"scale-3d":["scale-3d"],skew:[{skew:De()}],"skew-x":[{"skew-x":De()}],"skew-y":[{"skew-y":De()}],transform:[{transform:[it,nt,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:be()}],"translate-x":[{"translate-x":be()}],"translate-y":[{"translate-y":be()}],"translate-z":[{"translate-z":be()}],"translate-none":["translate-none"],accent:[{accent:O()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:O()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",it,nt]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":M()}],"scroll-mx":[{"scroll-mx":M()}],"scroll-my":[{"scroll-my":M()}],"scroll-ms":[{"scroll-ms":M()}],"scroll-me":[{"scroll-me":M()}],"scroll-mbs":[{"scroll-mbs":M()}],"scroll-mbe":[{"scroll-mbe":M()}],"scroll-mt":[{"scroll-mt":M()}],"scroll-mr":[{"scroll-mr":M()}],"scroll-mb":[{"scroll-mb":M()}],"scroll-ml":[{"scroll-ml":M()}],"scroll-p":[{"scroll-p":M()}],"scroll-px":[{"scroll-px":M()}],"scroll-py":[{"scroll-py":M()}],"scroll-ps":[{"scroll-ps":M()}],"scroll-pe":[{"scroll-pe":M()}],"scroll-pbs":[{"scroll-pbs":M()}],"scroll-pbe":[{"scroll-pbe":M()}],"scroll-pt":[{"scroll-pt":M()}],"scroll-pr":[{"scroll-pr":M()}],"scroll-pb":[{"scroll-pb":M()}],"scroll-pl":[{"scroll-pl":M()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",it,nt]}],fill:[{fill:["none",...O()]}],"stroke-w":[{stroke:[qt,$h,Yl,lN]}],stroke:[{stroke:["none",...O()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Dq=dq(Lq);function ye(...e){return Dq(JO(e))}function sc(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Iq(e){return e.startsWith("chatId:")?e.slice(7):e}const Df="data-focus-fallback-ignore",p5="data-allow-focus-retain",kv="kanna:restore-chat-input-focus",wC="data-chat-input",Ev="data-chat-selection-zone";function oc(e,t){return!!(e!=null&&e.closest(`[${t}]`))}function m5(e){var n;const t=e;return t!=null&&t.matches?t.matches("input:not([type='checkbox']):not([type='radio']):not([type='button']):not([type='submit']):not([type='reset']), textarea, select")||t.isContentEditable||((n=t.getAttribute)==null?void 0:n.call(t,"role"))==="textbox"?!0:oc(e,p5):!1}function Pq(e){const t=e;return t!=null&&t.matches?m5(e)||(t.tabIndex??-1)>=0||t.matches("button, a[href], summary")?!0:oc(e,p5):!1}function dN(e){return!!e.querySelector(`[${Df}][data-state='open']`)}function Oq(e){return e?!e.isCollapsed&&e.toString().trim().length>0:!1}function jq(e,t){if(!e)return!1;const n=Array.from(t.querySelectorAll(`textarea[${wC}]`)).filter(o=>!o.disabled);if(n.length===0)return!1;const r=n.indexOf(e),i=r>=0?(r+1)%n.length:0,s=n[i];return s?(s.focus({preventScroll:!0}),!0):!1}function hN(e){const{activeElement:t,fallback:n,hasActiveOverlay:r}=e;if(!n||n.disabled||r||t===n)return"none";if(e.trigger==="escape")return e.defaultPrevented||oc(t,wC)||e.canCancel?"none":"escape-focus";const{pointerStartTarget:i,pointerEndTarget:s,root:o,hasActiveSelection:l}=e,c=s??i;return!o||!c||!o.contains(c)||oc(c,Df)||oc(t,Df)||l&&(oc(i,Ev)||oc(c,Ev))||m5(t)?"none":t&&t===c?"restore":Pq(t)?"none":"restore"}const na=FG,zq=$G,g5=_.forwardRef(({className:e,...t},n)=>m.jsx(XO,{ref:n,className:ye("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));g5.displayName=XO.displayName;const Bq={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"},po=_.forwardRef(({className:e,children:t,size:n="md",...r},i)=>m.jsxs(zq,{children:[m.jsx(g5,{}),m.jsxs(QO,{ref:i,[Df]:"",onCloseAutoFocus:s=>{var o;s.preventDefault(),window.dispatchEvent(new Event(kv)),(o=r.onCloseAutoFocus)==null||o.call(r,s)},className:ye("fixed left-1/2 top-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-background shadow-xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]","max-h-[85vh] flex flex-col",Bq[n],e),...r,children:[t,m.jsxs(VG,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[m.jsx(ua,{className:"h-4 w-4"}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));po.displayName=QO.displayName;function CC({className:e,...t}){return m.jsx("div",{className:ye("shrink-0 flex flex-col space-y-1.5 p-4 border-b border-border",e),...t})}function ra({className:e,...t}){return m.jsx(HG,{className:ye("text-lg font-medium leading-none tracking-tight",e),...t})}function Ld({className:e,...t}){return m.jsx(UG,{className:ye("text-sm text-muted-foreground",e),...t})}function ia({className:e,...t}){return m.jsx("div",{className:ye("flex-1 min-h-0 overflow-y-auto px-4 pb-4 pt-3.5",e),...t})}function xl({className:e,...t}){return m.jsx("div",{className:ye("shrink-0 flex justify-end gap-2 border-t border-border bg-background p-2 rounded-b-xl",e),...t})}function Fq({className:e,...t}){return m.jsx("button",{className:ye("touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer text-sm font-medium transition-colors","rounded-full h-9 px-4","bg-primary text-primary-foreground hover:bg-primary/90","disabled:pointer-events-none disabled:bg-primary/20 disabled:text-primary/60",e),...t})}function $q({className:e,...t}){return m.jsx("button",{className:ye("touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer text-sm font-medium transition-colors","rounded-full h-9 px-4","hover:bg-accent dark:hover:bg-card hover:text-accent-foreground text-muted-foreground","disabled:pointer-events-none disabled:text-muted-foreground/50",e),...t})}function Hq({open:e,shareUrl:t,onOpenChange:n,onOpenLink:r,onCopyLink:i}){const[s,o]=_.useState(!1);_.useEffect(()=>{e||o(!1)},[e,t]);const l=async()=>{await i()&&(o(!0),window.setTimeout(()=>{o(!1)},2e3))};return m.jsx(na,{open:e,onOpenChange:n,children:m.jsxs(po,{size:"md",children:[m.jsxs(CC,{children:[m.jsx(ra,{children:"Shared Link"}),m.jsx(Ld,{children:"Shared links are snapshots in time and contain all attachments, tool calls and history. Be mindful of sensitive info."})]}),m.jsx(ia,{className:"space-y-3",children:m.jsxs("div",{className:"flex w-full items-center gap-2 rounded-2xl border border-border bg-muted/40 pl-4 px-3 py-2.5",children:[m.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-sm text-foreground",children:t}),m.jsx("button",{type:"button",onClick:()=>void l(),title:s?"Copied":"Copy link","aria-label":s?"Copied":"Copy link",className:"flex flex-shrink-0 items-center justify-center rounded-lg text-logo hover:text-logo/60 transition-colors hover:bg-background hover:text-foreground",children:s?m.jsx(ui,{className:"h-4 w-4 text-emerald-400"}):m.jsx(yl,{className:"h-4 w-4"})})]})}),m.jsx(xl,{children:m.jsxs(Fq,{type:"button",onClick:r,children:[m.jsx(Rb,{className:"mr-2 h-4 w-4"}),"Open"]})})]})})}const fN=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,pN=JO,Uq=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return pN(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(d=>{const f=n==null?void 0:n[d],h=s==null?void 0:s[d];if(f===null)return null;const g=fN(f)||fN(h);return i[d][g]}),l=n&&Object.entries(n).reduce((d,f)=>{let[h,g]=f;return g===void 0||(d[h]=g),d},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((d,f)=>{let{class:h,className:g,...b}=f;return Object.entries(b).every(y=>{let[x,w]=y;return Array.isArray(w)?w.includes({...s,...l}[x]):{...s,...l}[x]===w})?[...d,h,g]:d},[]);return pN(e,o,c,n==null?void 0:n.class,n==null?void 0:n.className)},Pb=Uq("touch-manipulation inline-flex items-center justify-center whitespace-nowrap cursor-pointer rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none",{variants:{variant:{default:"bg-primary text-primary-foreground disabled:bg-primary/50 disabled:text-primary-foreground/90 hover:bg-primary/90",juicy:"bg-logo text-primary-foreground disabled:text-primary-foreground/50 hover:bg-logo/90",destructive:"bg-destructive/80 dark:text-white",outline:"border disabled:bg-transparent disabled:text-foreground/50 border-inpu disabled:border-input/90 bg-card hover:bg-muted hover:text-accent-foreground",secondary:"bg-transparent border border-border text-secondary-foreground hover:text-secondary-foreground/60 disabled:text-secondary-foreground/50",ghost:"hover:bg-accent dark:hover:bg-card hover:text-accent-foreground text-muted-foreground disabled:text-muted-foreground/50 border border-border/0 hover:border-border",link:"text-primary disabled:text-primary/50 underline-offset-4 hover:underline",none:""},size:{default:"h-10 px-4 rounded-full py-2",sm:"h-9 rounded-full px-3",lg:"h-11 rounded-full px-8",icon:"h-9 w-9 rounded-full","icon-mobile":"h-11 w-11 rounded-full md:h-9 md:w-9",none:"","icon-sm":"h-5.5 w-5.5 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),st=_.forwardRef(({className:e,variant:t,size:n,type:r="button",...i},s)=>m.jsx("button",{type:r,className:ye(Pb({variant:t,size:n,className:e})),ref:s,...i}));st.displayName="Button";const wr=_.forwardRef(({className:e,type:t,...n},r)=>m.jsx("input",{ref:r,type:t,className:ye("flex w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...n}));wr.displayName="Input";const v5=_.createContext(null);function Vq({children:e}){const[t,n]=_.useState(null),[r,i]=_.useState(""),s=_.useRef(null);_.useEffect(()=>{(t==null?void 0:t.kind)==="prompt"&&(i(t.options.initialValue??""),setTimeout(()=>{var b,y;(b=s.current)==null||b.focus(),(y=s.current)==null||y.select()},0))},[t]);const o=_.useCallback(()=>{n(null),i("")},[]),l=_.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!1):t.kind==="prompt"?t.resolve(null):t.resolve(),o())},[o,t]),c=_.useCallback(()=>{t&&(t.kind==="confirm"?t.resolve(!0):t.kind==="prompt"?t.resolve(r.trim()||null):t.resolve(),o())},[o,t,r]),d=_.useCallback(b=>new Promise(y=>{n({kind:"confirm",options:b,resolve:y})}),[]),f=_.useCallback(b=>new Promise(y=>{n({kind:"prompt",options:b,resolve:y})}),[]),h=_.useCallback(b=>new Promise(y=>{n({kind:"alert",options:b,resolve:y})}),[]),g=_.useMemo(()=>({confirm:d,prompt:f,alert:h}),[h,d,f]);return m.jsxs(v5.Provider,{value:g,children:[e,m.jsx(na,{open:t!==null,onOpenChange:b=>{b||!t||l()},children:m.jsx(po,{size:"sm",onKeyDown:b=>{b.key!=="Enter"||b.shiftKey||!t||t.kind!=="confirm"||(b.preventDefault(),c())},children:t?m.jsxs(m.Fragment,{children:[m.jsxs(ia,{className:"space-y-4",children:[m.jsx(ra,{children:t.options.title}),t.options.description?m.jsx(Ld,{children:t.options.description}):null,t.kind==="prompt"?m.jsx(wr,{ref:s,type:"text",value:r,onChange:b=>i(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),c())},placeholder:t.options.placeholder}):null]}),m.jsxs(xl,{children:[m.jsx(st,{variant:"ghost",size:"sm",onClick:l,className:t.kind==="alert"?"hidden":void 0,children:"cancelLabel"in t.options?t.options.cancelLabel??"Cancel":"Cancel"}),m.jsx(st,{variant:t.kind==="confirm"?t.options.confirmVariant??"default":"secondary",size:"sm",onClick:c,disabled:t.kind==="prompt"&&!r.trim(),children:t.kind==="alert"?t.options.closeLabel??"OK":"confirmLabel"in t.options?t.options.confirmLabel??"Confirm":"Confirm"})]})]}):null})})]})}function fp(){const e=_.useContext(v5);if(!e)throw new Error("useAppDialog must be used within AppDialogProvider");return e}const kC=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:ye("bg-card text-card-foreground",e),...t}));kC.displayName="Card";const EC=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:ye("flex flex-col space-y-1.5 p-2",e),...t}));EC.displayName="CardHeader";const b5=_.forwardRef(({className:e,...t},n)=>m.jsx("h3",{ref:n,className:ye("text-2xl font-semibold leading-none tracking-tight",e),...t}));b5.displayName="CardTitle";const _5=_.forwardRef(({className:e,...t},n)=>m.jsx("p",{ref:n,className:ye("text-sm text-muted-foreground",e),...t}));_5.displayName="CardDescription";const RC=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:ye("p-6 pt-0",e),...t}));RC.displayName="CardContent";const Wq=_.forwardRef(({className:e,...t},n)=>m.jsx("div",{ref:n,className:ye("flex items-center p-6 pt-0",e),...t}));Wq.displayName="CardFooter";const Gq=["top","right","bottom","left"],Sl=Math.min,Fi=Math.max,Rv=Math.round,Jm=Math.floor,co=e=>({x:e,y:e}),qq={left:"right",right:"left",bottom:"top",top:"bottom"};function HS(e,t,n){return Fi(e,Sl(t,n))}function sa(e,t){return typeof e=="function"?e(t):e}function oa(e){return e.split("-")[0]}function Dd(e){return e.split("-")[1]}function TC(e){return e==="x"?"y":"x"}function AC(e){return e==="y"?"height":"width"}function io(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function NC(e){return TC(io(e))}function Kq(e,t,n){n===void 0&&(n=!1);const r=Dd(e),i=NC(e),s=AC(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=Tv(o)),[o,Tv(o)]}function Yq(e){const t=Tv(e);return[US(e),t,US(t)]}function US(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const mN=["left","right"],gN=["right","left"],Xq=["top","bottom"],Qq=["bottom","top"];function Zq(e,t,n){switch(e){case"top":case"bottom":return n?t?gN:mN:t?mN:gN;case"left":case"right":return t?Xq:Qq;default:return[]}}function Jq(e,t,n,r){const i=Dd(e);let s=Zq(oa(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(US)))),s}function Tv(e){const t=oa(e);return qq[t]+e.slice(t.length)}function eK(e){return{top:0,right:0,bottom:0,left:0,...e}}function y5(e){return typeof e!="number"?eK(e):{top:e,right:e,bottom:e,left:e}}function Av(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function vN(e,t,n){let{reference:r,floating:i}=e;const s=io(t),o=NC(t),l=AC(o),c=oa(t),d=s==="y",f=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,g=r[l]/2-i[l]/2;let b;switch(c){case"top":b={x:f,y:r.y-i.height};break;case"bottom":b={x:f,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:h};break;case"left":b={x:r.x-i.width,y:h};break;default:b={x:r.x,y:r.y}}switch(Dd(t)){case"start":b[o]-=g*(n&&d?-1:1);break;case"end":b[o]+=g*(n&&d?-1:1);break}return b}async function tK(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:g=!1,padding:b=0}=sa(t,e),y=y5(b),w=l[g?h==="floating"?"reference":"floating":h],C=Av(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:c})),E=h==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),T=await(s.isElement==null?void 0:s.isElement(R))?await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1}:{x:1,y:1},A=Av(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:E,offsetParent:R,strategy:c}):E);return{top:(C.top-A.top+y.top)/T.y,bottom:(A.bottom-C.bottom+y.bottom)/T.y,left:(C.left-A.left+y.left)/T.x,right:(A.right-C.right+y.right)/T.x}}const nK=50,rK=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:tK},c=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:h}=vN(d,r,c),g=r,b=0;const y={};for(let x=0;x<s.length;x++){const w=s[x];if(!w)continue;const{name:C,fn:E}=w,{x:R,y:T,data:A,reset:N}=await E({x:f,y:h,initialPlacement:r,placement:g,strategy:i,middlewareData:y,rects:d,platform:l,elements:{reference:e,floating:t}});f=R??f,h=T??h,y[C]={...y[C],...A},N&&b<nK&&(b++,typeof N=="object"&&(N.placement&&(g=N.placement),N.rects&&(d=N.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):N.rects),{x:f,y:h}=vN(d,g,c)),x=-1)}return{x:f,y:h,placement:g,strategy:i,middlewareData:y}},iK=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:c}=t,{element:d,padding:f=0}=sa(e,t)||{};if(d==null)return{};const h=y5(f),g={x:n,y:r},b=NC(i),y=AC(b),x=await o.getDimensions(d),w=b==="y",C=w?"top":"left",E=w?"bottom":"right",R=w?"clientHeight":"clientWidth",T=s.reference[y]+s.reference[b]-g[b]-s.floating[y],A=g[b]-s.reference[b],N=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let D=N?N[R]:0;(!D||!await(o.isElement==null?void 0:o.isElement(N)))&&(D=l.floating[R]||s.floating[y]);const M=T/2-A/2,W=D/2-x[y]/2-1,j=Sl(h[C],W),$=Sl(h[E],W),F=j,P=D-x[y]-$,B=D/2-x[y]/2+M,H=HS(F,B,P),z=!c.arrow&&Dd(i)!=null&&B!==H&&s.reference[y]/2-(B<F?j:$)-x[y]/2<0,U=z?B<F?B-F:B-P:0;return{[b]:g[b]+U,data:{[b]:H,centerOffset:B-H-U,...z&&{alignmentOffset:U}},reset:z}}}),sK=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:x=!0,...w}=sa(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const C=oa(i),E=io(l),R=oa(l)===l,T=await(c.isRTL==null?void 0:c.isRTL(d.floating)),A=g||(R||!x?[Tv(l)]:Yq(l)),N=y!=="none";!g&&N&&A.push(...Jq(l,x,y,T));const D=[l,...A],M=await c.detectOverflow(t,w),W=[];let j=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&W.push(M[C]),h){const B=Kq(i,o,T);W.push(M[B[0]],M[B[1]])}if(j=[...j,{placement:i,overflows:W}],!W.every(B=>B<=0)){var $,F;const B=((($=s.flip)==null?void 0:$.index)||0)+1,H=D[B];if(H&&(!(h==="alignment"?E!==io(H):!1)||j.every(V=>io(V.placement)===E?V.overflows[0]>0:!0)))return{data:{index:B,overflows:j},reset:{placement:H}};let z=(F=j.filter(U=>U.overflows[0]<=0).sort((U,V)=>U.overflows[1]-V.overflows[1])[0])==null?void 0:F.placement;if(!z)switch(b){case"bestFit":{var P;const U=(P=j.filter(V=>{if(N){const Y=io(V.placement);return Y===E||Y==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(Y=>Y>0).reduce((Y,O)=>Y+O,0)]).sort((V,Y)=>V[1]-Y[1])[0])==null?void 0:P[0];U&&(z=U);break}case"initialPlacement":z=l;break}if(i!==z)return{reset:{placement:z}}}return{}}}};function bN(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function _N(e){return Gq.some(t=>e[t]>=0)}const oK=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=sa(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=bN(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:_N(l)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),l=bN(o,n.floating);return{data:{escapedOffsets:l,escaped:_N(l)}}}default:return{}}}}},x5=new Set(["left","top"]);async function aK(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=oa(n),l=Dd(n),c=io(n)==="y",d=x5.has(o)?-1:1,f=s&&c?-1:1,h=sa(t,e);let{mainAxis:g,crossAxis:b,alignmentAxis:y}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof y=="number"&&(b=l==="end"?y*-1:y),c?{x:b*f,y:g*d}:{x:g*d,y:b*f}}const lK=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:l}=t,c=await aK(t,e);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:o}}}}},cK=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:c={fn:C=>{let{x:E,y:R}=C;return{x:E,y:R}}},...d}=sa(e,t),f={x:n,y:r},h=await s.detectOverflow(t,d),g=io(oa(i)),b=TC(g);let y=f[b],x=f[g];if(o){const C=b==="y"?"top":"left",E=b==="y"?"bottom":"right",R=y+h[C],T=y-h[E];y=HS(R,y,T)}if(l){const C=g==="y"?"top":"left",E=g==="y"?"bottom":"right",R=x+h[C],T=x-h[E];x=HS(R,x,T)}const w=c.fn({...t,[b]:y,[g]:x});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[b]:o,[g]:l}}}}}},uK=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=sa(e,t),f={x:n,y:r},h=io(i),g=TC(h);let b=f[g],y=f[h];const x=sa(l,t),w=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const R=g==="y"?"height":"width",T=s.reference[g]-s.floating[R]+w.mainAxis,A=s.reference[g]+s.reference[R]-w.mainAxis;b<T?b=T:b>A&&(b=A)}if(d){var C,E;const R=g==="y"?"width":"height",T=x5.has(oa(i)),A=s.reference[h]-s.floating[R]+(T&&((C=o.offset)==null?void 0:C[h])||0)+(T?0:w.crossAxis),N=s.reference[h]+s.reference[R]+(T?0:((E=o.offset)==null?void 0:E[h])||0)-(T?w.crossAxis:0);y<A?y=A:y>N&&(y=N)}return{[g]:b,[h]:y}}}},dK=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:l}=t,{apply:c=()=>{},...d}=sa(e,t),f=await o.detectOverflow(t,d),h=oa(i),g=Dd(i),b=io(i)==="y",{width:y,height:x}=s.floating;let w,C;h==="top"||h==="bottom"?(w=h,C=g===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(C=h,w=g==="end"?"top":"bottom");const E=x-f.top-f.bottom,R=y-f.left-f.right,T=Sl(x-f[w],E),A=Sl(y-f[C],R),N=!t.middlewareData.shift;let D=T,M=A;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(M=R),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(D=E),N&&!g){const j=Fi(f.left,0),$=Fi(f.right,0),F=Fi(f.top,0),P=Fi(f.bottom,0);b?M=y-2*(j!==0||$!==0?j+$:Fi(f.left,f.right)):D=x-2*(F!==0||P!==0?F+P:Fi(f.top,f.bottom))}await c({...t,availableWidth:M,availableHeight:D});const W=await o.getDimensions(l.floating);return y!==W.width||x!==W.height?{reset:{rects:!0}}:{}}}};function Ob(){return typeof window<"u"}function Id(e){return S5(e)?(e.nodeName||"").toLowerCase():"#document"}function $i(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vo(e){var t;return(t=(S5(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function S5(e){return Ob()?e instanceof Node||e instanceof $i(e).Node:!1}function Bs(e){return Ob()?e instanceof Element||e instanceof $i(e).Element:!1}function ha(e){return Ob()?e instanceof HTMLElement||e instanceof $i(e).HTMLElement:!1}function yN(e){return!Ob()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $i(e).ShadowRoot}function pp(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Fs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function hK(e){return/^(table|td|th)$/.test(Id(e))}function jb(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const fK=/transform|translate|scale|rotate|perspective|filter/,pK=/paint|layout|strict|content/,Xl=e=>!!e&&e!=="none";let ex;function MC(e){const t=Bs(e)?Fs(e):e;return Xl(t.transform)||Xl(t.translate)||Xl(t.scale)||Xl(t.rotate)||Xl(t.perspective)||!LC()&&(Xl(t.backdropFilter)||Xl(t.filter))||fK.test(t.willChange||"")||pK.test(t.contain||"")}function mK(e){let t=wl(e);for(;ha(t)&&!dd(t);){if(MC(t))return t;if(jb(t))return null;t=wl(t)}return null}function LC(){return ex==null&&(ex=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ex}function dd(e){return/^(html|body|#document)$/.test(Id(e))}function Fs(e){return $i(e).getComputedStyle(e)}function zb(e){return Bs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wl(e){if(Id(e)==="html")return e;const t=e.assignedSlot||e.parentNode||yN(e)&&e.host||vo(e);return yN(t)?t.host:t}function w5(e){const t=wl(e);return dd(t)?e.ownerDocument?e.ownerDocument.body:e.body:ha(t)&&pp(t)?t:w5(t)}function If(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=w5(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=$i(i);if(s){const l=VS(o);return t.concat(o,o.visualViewport||[],pp(i)?i:[],l&&n?If(l):[])}else return t.concat(i,If(i,[],n))}function VS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function C5(e){const t=Fs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=ha(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,l=Rv(n)!==s||Rv(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function DC(e){return Bs(e)?e:e.contextElement}function Ju(e){const t=DC(e);if(!ha(t))return co(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=C5(t);let o=(s?Rv(n.width):n.width)/r,l=(s?Rv(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const gK=co(0);function k5(e){const t=$i(e);return!LC()||!t.visualViewport?gK:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function vK(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==$i(e)?!1:t}function Sc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=DC(e);let o=co(1);t&&(r?Bs(r)&&(o=Ju(r)):o=Ju(e));const l=vK(s,n,r)?k5(s):co(0);let c=(i.left+l.x)/o.x,d=(i.top+l.y)/o.y,f=i.width/o.x,h=i.height/o.y;if(s){const g=$i(s),b=r&&Bs(r)?$i(r):r;let y=g,x=VS(y);for(;x&&r&&b!==y;){const w=Ju(x),C=x.getBoundingClientRect(),E=Fs(x),R=C.left+(x.clientLeft+parseFloat(E.paddingLeft))*w.x,T=C.top+(x.clientTop+parseFloat(E.paddingTop))*w.y;c*=w.x,d*=w.y,f*=w.x,h*=w.y,c+=R,d+=T,y=$i(x),x=VS(y)}}return Av({width:f,height:h,x:c,y:d})}function Bb(e,t){const n=zb(e).scrollLeft;return t?t.left+n:Sc(vo(e)).left+n}function E5(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Bb(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function bK(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=vo(r),l=t?jb(t.floating):!1;if(r===o||l&&s)return n;let c={scrollLeft:0,scrollTop:0},d=co(1);const f=co(0),h=ha(r);if((h||!h&&!s)&&((Id(r)!=="body"||pp(o))&&(c=zb(r)),h)){const b=Sc(r);d=Ju(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const g=o&&!h&&!s?E5(o,c):co(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+g.x,y:n.y*d.y-c.scrollTop*d.y+f.y+g.y}}function _K(e){return Array.from(e.getClientRects())}function yK(e){const t=vo(e),n=zb(e),r=e.ownerDocument.body,i=Fi(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Fi(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Bb(e);const l=-n.scrollTop;return Fs(r).direction==="rtl"&&(o+=Fi(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}const xN=25;function xK(e,t){const n=$i(e),r=vo(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,c=0;if(i){s=i.width,o=i.height;const f=LC();(!f||f&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const d=Bb(r);if(d<=0){const f=r.ownerDocument,h=f.body,g=getComputedStyle(h),b=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,y=Math.abs(r.clientWidth-h.clientWidth-b);y<=xN&&(s-=y)}else d<=xN&&(s+=d);return{width:s,height:o,x:l,y:c}}function SK(e,t){const n=Sc(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=ha(e)?Ju(e):co(1),o=e.clientWidth*s.x,l=e.clientHeight*s.y,c=i*s.x,d=r*s.y;return{width:o,height:l,x:c,y:d}}function SN(e,t,n){let r;if(t==="viewport")r=xK(e,n);else if(t==="document")r=yK(vo(e));else if(Bs(t))r=SK(t,n);else{const i=k5(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Av(r)}function R5(e,t){const n=wl(e);return n===t||!Bs(n)||dd(n)?!1:Fs(n).position==="fixed"||R5(n,t)}function wK(e,t){const n=t.get(e);if(n)return n;let r=If(e,[],!1).filter(l=>Bs(l)&&Id(l)!=="body"),i=null;const s=Fs(e).position==="fixed";let o=s?wl(e):e;for(;Bs(o)&&!dd(o);){const l=Fs(o),c=MC(o);!c&&l.position==="fixed"&&(i=null),(s?!c&&!i:!c&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||pp(o)&&!c&&R5(e,o))?r=r.filter(f=>f!==o):i=l,o=wl(o)}return t.set(e,r),r}function CK(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?jb(t)?[]:wK(t,this._c):[].concat(n),r],l=SN(t,o[0],i);let c=l.top,d=l.right,f=l.bottom,h=l.left;for(let g=1;g<o.length;g++){const b=SN(t,o[g],i);c=Fi(b.top,c),d=Sl(b.right,d),f=Sl(b.bottom,f),h=Fi(b.left,h)}return{width:d-h,height:f-c,x:h,y:c}}function kK(e){const{width:t,height:n}=C5(e);return{width:t,height:n}}function EK(e,t,n){const r=ha(t),i=vo(t),s=n==="fixed",o=Sc(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=co(0);function d(){c.x=Bb(i)}if(r||!r&&!s)if((Id(t)!=="body"||pp(i))&&(l=zb(t)),r){const b=Sc(t,!0,s,t);c.x=b.x+t.clientLeft,c.y=b.y+t.clientTop}else i&&d();s&&!r&&i&&d();const f=i&&!r&&!s?E5(i,l):co(0),h=o.left+l.scrollLeft-c.x-f.x,g=o.top+l.scrollTop-c.y-f.y;return{x:h,y:g,width:o.width,height:o.height}}function tx(e){return Fs(e).position==="static"}function wN(e,t){if(!ha(e)||Fs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vo(e)===n&&(n=n.ownerDocument.body),n}function T5(e,t){const n=$i(e);if(jb(e))return n;if(!ha(e)){let i=wl(e);for(;i&&!dd(i);){if(Bs(i)&&!tx(i))return i;i=wl(i)}return n}let r=wN(e,t);for(;r&&hK(r)&&tx(r);)r=wN(r,t);return r&&dd(r)&&tx(r)&&!MC(r)?n:r||mK(e)||n}const RK=async function(e){const t=this.getOffsetParent||T5,n=this.getDimensions,r=await n(e.floating);return{reference:EK(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function TK(e){return Fs(e).direction==="rtl"}const AK={convertOffsetParentRelativeRectToViewportRelativeRect:bK,getDocumentElement:vo,getClippingRect:CK,getOffsetParent:T5,getElementRects:RK,getClientRects:_K,getDimensions:kK,getScale:Ju,isElement:Bs,isRTL:TK};function A5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function NK(e,t){let n=null,r;const i=vo(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=e.getBoundingClientRect(),{left:f,top:h,width:g,height:b}=d;if(l||t(),!g||!b)return;const y=Jm(h),x=Jm(i.clientWidth-(f+g)),w=Jm(i.clientHeight-(h+b)),C=Jm(f),R={rootMargin:-y+"px "+-x+"px "+-w+"px "+-C+"px",threshold:Fi(0,Sl(1,c))||1};let T=!0;function A(N){const D=N[0].intersectionRatio;if(D!==c){if(!T)return o();D?o(!1,D):r=setTimeout(()=>{o(!1,1e-7)},1e3)}D===1&&!A5(d,e.getBoundingClientRect())&&o(),T=!1}try{n=new IntersectionObserver(A,{...R,root:i.ownerDocument})}catch{n=new IntersectionObserver(A,R)}n.observe(e)}return o(!0),s}function MK(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=DC(e),f=i||s?[...d?If(d):[],...t?If(t):[]]:[];f.forEach(C=>{i&&C.addEventListener("scroll",n,{passive:!0}),s&&C.addEventListener("resize",n)});const h=d&&l?NK(d,n):null;let g=-1,b=null;o&&(b=new ResizeObserver(C=>{let[E]=C;E&&E.target===d&&b&&t&&(b.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var R;(R=b)==null||R.observe(t)})),n()}),d&&!c&&b.observe(d),t&&b.observe(t));let y,x=c?Sc(e):null;c&&w();function w(){const C=Sc(e);x&&!A5(x,C)&&n(),x=C,y=requestAnimationFrame(w)}return n(),()=>{var C;f.forEach(E=>{i&&E.removeEventListener("scroll",n),s&&E.removeEventListener("resize",n)}),h==null||h(),(C=b)==null||C.disconnect(),b=null,c&&cancelAnimationFrame(y)}}const LK=lK,DK=cK,IK=sK,PK=dK,OK=oK,CN=iK,jK=uK,zK=(e,t,n)=>{const r=new Map,i={platform:AK,...n},s={...i.platform,_c:r};return rK(e,t,{...i,platform:s})};var BK=typeof document<"u",FK=function(){},Qg=BK?_.useLayoutEffect:FK;function Nv(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Nv(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!Nv(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function N5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function kN(e,t){const n=N5(e);return Math.round(t*n)/n}function nx(e){const t=_.useRef(e);return Qg(()=>{t.current=e}),t}function $K(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[f,h]=_.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,b]=_.useState(r);Nv(g,r)||b(r);const[y,x]=_.useState(null),[w,C]=_.useState(null),E=_.useCallback(V=>{V!==N.current&&(N.current=V,x(V))},[]),R=_.useCallback(V=>{V!==D.current&&(D.current=V,C(V))},[]),T=s||y,A=o||w,N=_.useRef(null),D=_.useRef(null),M=_.useRef(f),W=c!=null,j=nx(c),$=nx(i),F=nx(d),P=_.useCallback(()=>{if(!N.current||!D.current)return;const V={placement:t,strategy:n,middleware:g};$.current&&(V.platform=$.current),zK(N.current,D.current,V).then(Y=>{const O={...Y,isPositioned:F.current!==!1};B.current&&!Nv(M.current,O)&&(M.current=O,ps.flushSync(()=>{h(O)}))})},[g,t,n,$,F]);Qg(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,h(V=>({...V,isPositioned:!1})))},[d]);const B=_.useRef(!1);Qg(()=>(B.current=!0,()=>{B.current=!1}),[]),Qg(()=>{if(T&&(N.current=T),A&&(D.current=A),T&&A){if(j.current)return j.current(T,A,P);P()}},[T,A,P,j,W]);const H=_.useMemo(()=>({reference:N,floating:D,setReference:E,setFloating:R}),[E,R]),z=_.useMemo(()=>({reference:T,floating:A}),[T,A]),U=_.useMemo(()=>{const V={position:n,left:0,top:0};if(!z.floating)return V;const Y=kN(z.floating,f.x),O=kN(z.floating,f.y);return l?{...V,transform:"translate("+Y+"px, "+O+"px)",...N5(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:O}},[n,l,z.floating,f.x,f.y]);return _.useMemo(()=>({...f,update:P,refs:H,elements:z,floatingStyles:U}),[f,P,H,z,U])}const HK=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?CN({element:r.current,padding:i}).fn(n):{}:r?CN({element:r,padding:i}).fn(n):{}}}},UK=(e,t)=>{const n=LK(e);return{name:n.name,fn:n.fn,options:[e,t]}},VK=(e,t)=>{const n=DK(e);return{name:n.name,fn:n.fn,options:[e,t]}},WK=(e,t)=>({fn:jK(e).fn,options:[e,t]}),GK=(e,t)=>{const n=IK(e);return{name:n.name,fn:n.fn,options:[e,t]}},qK=(e,t)=>{const n=PK(e);return{name:n.name,fn:n.fn,options:[e,t]}},KK=(e,t)=>{const n=OK(e);return{name:n.name,fn:n.fn,options:[e,t]}},YK=(e,t)=>{const n=HK(e);return{name:n.name,fn:n.fn,options:[e,t]}};var XK="Arrow",M5=_.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return m.jsx(Jt.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});M5.displayName=XK;var QK=M5;function ZK(e){const[t,n]=_.useState(void 0);return Yr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,l;if("borderBoxSize"in s){const c=s.borderBoxSize,d=Array.isArray(c)?c[0]:c;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;n({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var IC="Popper",[L5,Rl]=da(IC),[JK,D5]=L5(IC),I5=e=>{const{__scopePopper:t,children:n}=e,[r,i]=_.useState(null);return m.jsx(JK,{scope:t,anchor:r,onAnchorChange:i,children:n})};I5.displayName=IC;var P5="PopperAnchor",O5=_.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=D5(P5,n),o=_.useRef(null),l=mn(t,o),c=_.useRef(null);return _.useEffect(()=>{const d=c.current;c.current=(r==null?void 0:r.current)||o.current,d!==c.current&&s.onAnchorChange(c.current)}),r?null:m.jsx(Jt.div,{...i,ref:l})});O5.displayName=P5;var PC="PopperContent",[eY,tY]=L5(PC),j5=_.forwardRef((e,t)=>{var se,pe,ce,ge,Ce,ke;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:b="optimized",onPlaced:y,...x}=e,w=D5(PC,n),[C,E]=_.useState(null),R=mn(t,De=>E(De)),[T,A]=_.useState(null),N=ZK(T),D=(N==null?void 0:N.width)??0,M=(N==null?void 0:N.height)??0,W=r+(s!=="center"?"-"+s:""),j=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},$=Array.isArray(d)?d:[d],F=$.length>0,P={padding:j,boundary:$.filter(rY),altBoundary:F},{refs:B,floatingStyles:H,placement:z,isPositioned:U,middlewareData:V}=$K({strategy:"fixed",placement:W,whileElementsMounted:(...De)=>MK(...De,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[UK({mainAxis:i+M,alignmentAxis:o}),c&&VK({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?WK():void 0,...P}),c&&GK({...P}),qK({...P,apply:({elements:De,rects:be,availableWidth:rt,availableHeight:Rt})=>{const{width:mt,height:sn}=be.reference,$t=De.floating.style;$t.setProperty("--radix-popper-available-width",`${rt}px`),$t.setProperty("--radix-popper-available-height",`${Rt}px`),$t.setProperty("--radix-popper-anchor-width",`${mt}px`),$t.setProperty("--radix-popper-anchor-height",`${sn}px`)}}),T&&YK({element:T,padding:l}),iY({arrowWidth:D,arrowHeight:M}),g&&KK({strategy:"referenceHidden",...P})]}),[Y,O]=F5(z),G=zs(y);Yr(()=>{U&&(G==null||G())},[U,G]);const Z=(se=V.arrow)==null?void 0:se.x,I=(pe=V.arrow)==null?void 0:pe.y,re=((ce=V.arrow)==null?void 0:ce.centerOffset)!==0,[te,oe]=_.useState();return Yr(()=>{C&&oe(window.getComputedStyle(C).zIndex)},[C]),m.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:U?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:te,"--radix-popper-transform-origin":[(ge=V.transformOrigin)==null?void 0:ge.x,(Ce=V.transformOrigin)==null?void 0:Ce.y].join(" "),...((ke=V.hide)==null?void 0:ke.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(eY,{scope:n,placedSide:Y,onArrowChange:A,arrowX:Z,arrowY:I,shouldHideArrow:re,children:m.jsx(Jt.div,{"data-side":Y,"data-align":O,...x,ref:R,style:{...x.style,animation:U?void 0:"none"}})})})});j5.displayName=PC;var z5="PopperArrow",nY={top:"bottom",right:"left",bottom:"top",left:"right"},B5=_.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=tY(z5,r),o=nY[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(QK,{...i,ref:n,style:{...i.style,display:"block"}})})});B5.displayName=z5;function rY(e){return e!==null}var iY=e=>({name:"transformOrigin",options:e,fn(t){var w,C,E;const{placement:n,rects:r,middlewareData:i}=t,o=((w=i.arrow)==null?void 0:w.centerOffset)!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[d,f]=F5(n),h={start:"0%",center:"50%",end:"100%"}[f],g=(((C=i.arrow)==null?void 0:C.x)??0)+l/2,b=(((E=i.arrow)==null?void 0:E.y)??0)+c/2;let y="",x="";return d==="bottom"?(y=o?h:`${g}px`,x=`${-c}px`):d==="top"?(y=o?h:`${g}px`,x=`${r.floating.height+c}px`):d==="right"?(y=`${-c}px`,x=o?h:`${b}px`):d==="left"&&(y=`${r.floating.width+c}px`,x=o?h:`${b}px`),{data:{x:y,y:x}}}});function F5(e){const[t,n="center"]=e.split("-");return[t,n]}var Fb=I5,mp=O5,$b=j5,Hb=B5,$5=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),sY="VisuallyHidden",H5=_.forwardRef((e,t)=>m.jsx(Jt.span,{...e,ref:t,style:{...$5,...e.style}}));H5.displayName=sY;var oY=H5,[Ub]=da("Tooltip",[Rl]),Vb=Rl(),U5="TooltipProvider",aY=700,WS="tooltip.open",[lY,OC]=Ub(U5),V5=e=>{const{__scopeTooltip:t,delayDuration:n=aY,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=_.useRef(!0),l=_.useRef(!1),c=_.useRef(0);return _.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),m.jsx(lY,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:_.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:_.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};V5.displayName=U5;var Pf="Tooltip",[cY,gp]=Ub(Pf),W5=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:l}=e,c=OC(Pf,e.__scopeTooltip),d=Vb(t),[f,h]=_.useState(null),g=ea(),b=_.useRef(0),y=o??c.disableHoverableContent,x=l??c.delayDuration,w=_.useRef(!1),[C,E]=ud({prop:r,defaultProp:i??!1,onChange:D=>{D?(c.onOpen(),document.dispatchEvent(new CustomEvent(WS))):c.onClose(),s==null||s(D)},caller:Pf}),R=_.useMemo(()=>C?w.current?"delayed-open":"instant-open":"closed",[C]),T=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,E(!0)},[E]),A=_.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E(!1)},[E]),N=_.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,E(!0),b.current=0},x)},[x,E]);return _.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),m.jsx(Fb,{...d,children:m.jsx(cY,{scope:t,contentId:g,open:C,stateAttribute:R,trigger:f,onTriggerChange:h,onTriggerEnter:_.useCallback(()=>{c.isOpenDelayedRef.current?N():T()},[c.isOpenDelayedRef,N,T]),onTriggerLeave:_.useCallback(()=>{y?A():(window.clearTimeout(b.current),b.current=0)},[A,y]),onOpen:T,onClose:A,disableHoverableContent:y,children:n})})};W5.displayName=Pf;var GS="TooltipTrigger",G5=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=gp(GS,n),s=OC(GS,n),o=Vb(n),l=_.useRef(null),c=mn(t,l,i.onTriggerChange),d=_.useRef(!1),f=_.useRef(!1),h=_.useCallback(()=>d.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),m.jsx(mp,{asChild:!0,...o,children:m.jsx(Jt.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:Je(e.onPointerMove,g=>{g.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),f.current=!0)}),onPointerLeave:Je(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:Je(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Je(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:Je(e.onBlur,i.onClose),onClick:Je(e.onClick,i.onClose)})})});G5.displayName=GS;var jC="TooltipPortal",[uY,dY]=Ub(jC,{forceMount:void 0}),q5=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=gp(jC,t);return m.jsx(uY,{scope:t,forceMount:n,children:m.jsx(xs,{present:n||s.open,children:m.jsx(Md,{asChild:!0,container:i,children:r})})})};q5.displayName=jC;var hd="TooltipContent",K5=_.forwardRef((e,t)=>{const n=dY(hd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=gp(hd,e.__scopeTooltip);return m.jsx(xs,{present:r||o.open,children:o.disableHoverableContent?m.jsx(Y5,{side:i,...s,ref:t}):m.jsx(hY,{side:i,...s,ref:t})})}),hY=_.forwardRef((e,t)=>{const n=gp(hd,e.__scopeTooltip),r=OC(hd,e.__scopeTooltip),i=_.useRef(null),s=mn(t,i),[o,l]=_.useState(null),{trigger:c,onClose:d}=n,f=i.current,{onPointerInTransitChange:h}=r,g=_.useCallback(()=>{l(null),h(!1)},[h]),b=_.useCallback((y,x)=>{const w=y.currentTarget,C={x:y.clientX,y:y.clientY},E=vY(C,w.getBoundingClientRect()),R=bY(C,E),T=_Y(x.getBoundingClientRect()),A=xY([...R,...T]);l(A),h(!0)},[h]);return _.useEffect(()=>()=>g(),[g]),_.useEffect(()=>{if(c&&f){const y=w=>b(w,f),x=w=>b(w,c);return c.addEventListener("pointerleave",y),f.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",y),f.removeEventListener("pointerleave",x)}}},[c,f,b,g]),_.useEffect(()=>{if(o){const y=x=>{const w=x.target,C={x:x.clientX,y:x.clientY},E=(c==null?void 0:c.contains(w))||(f==null?void 0:f.contains(w)),R=!yY(C,o);E?g():R&&(g(),d())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[c,f,o,d,g]),m.jsx(Y5,{...e,ref:s})}),[fY,pY]=Ub(Pf,{isInside:!1}),mY=xW("TooltipContent"),Y5=_.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...l}=e,c=gp(hd,n),d=Vb(n),{onClose:f}=c;return _.useEffect(()=>(document.addEventListener(WS,f),()=>document.removeEventListener(WS,f)),[f]),_.useEffect(()=>{if(c.trigger){const h=g=>{const b=g.target;b!=null&&b.contains(c.trigger)&&f()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,f]),m.jsx(Nd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:f,children:m.jsxs($b,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(mY,{children:r}),m.jsx(fY,{scope:n,isInside:!0,children:m.jsx(oY,{id:c.contentId,role:"tooltip",children:i||r})})]})})});K5.displayName=hd;var X5="TooltipArrow",gY=_.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Vb(n);return pY(X5,n).isInside?null:m.jsx(Hb,{...i,...r,ref:t})});gY.displayName=X5;function vY(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function bY(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function _Y(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function yY(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const l=t[s],c=t[o],d=l.x,f=l.y,h=c.x,g=c.y;f>r!=g>r&&n<(h-d)*(r-f)/(g-f)+d&&(i=!i)}return i}function xY(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),SY(t)}function SY(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var wY=V5,Q5=W5,Z5=G5,J5=q5,zC=K5;function ej({className:e,...t}){return m.jsx("kbd",{className:ye("pointer-events-none inline-flex h-5 min-w-5 items-center justify-center rounded border border-border/60 bg-muted/50 px-1.5 font-mono text-[11px] font-medium text-current select-none",e),...t})}function CY({className:e,...t}){return m.jsx("span",{className:ye("inline-flex items-center gap-0.5",e),...t})}const kY="z-50 overflow-hidden rounded-md border border-border bg-card p-0.5 text-[11px] font-medium text-card-foreground shadow-sm animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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",EY=wY,uo=Q5,ho=Z5,Is=_.forwardRef(({className:e,sideOffset:t=4,...n},r)=>m.jsx(J5,{children:m.jsx(zC,{ref:r,sideOffset:t,className:ye("z-50 overflow-hidden rounded-md bg-card text-card-foreground border border-border px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 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",e),...n})}));Is.displayName=zC.displayName;const Mv=Q5,Lv=Z5;function tj(e){return e.toUpperCase()}function RY(e){const t=e.split("+");return m.jsx(CY,{children:t.map((n,r)=>m.jsx(ej,{children:tj(n)},`${n}-${r}`))})}const Of=_.forwardRef(({className:e,sideOffset:t=4,children:n,shortcut:r,...i},s)=>{const o=r===void 0?null:Array.isArray(r)?r[0]??null:r;return m.jsx(J5,{children:m.jsx(zC,{ref:s,sideOffset:t,className:ye(kY,e),...i,children:o?RY(o):m.jsx("span",{children:typeof n=="string"?tj(n):n})})})});Of.displayName="HotkeyTooltipContent";const TY="0.43.2",AY={version:TY},Jn="Kanna",EN="kanna",NY=".kanna",MY=".kanna-dev",LY="KANNA_RUNTIME_PROFILE",BC=`kanna/${AY.version}`,DY="[kanna]",IY=`~/${Jn}`;function Wb(){var t;return(t=globalThis.process)==null?void 0:t.env}function PY(e=Wb()){var t;return((t=e==null?void 0:e[LY])==null?void 0:t.trim().toLowerCase())==="dev"?"dev":"prod"}function OY(e=Wb()){return PY(e)==="dev"?MY:NY}function jY(e=Wb()){return`~/${OY(e)}`}function zY(e=Wb()){return`${jY(e)}/keybindings.json`}function eg(e){return e?`${EN} ${e}`:EN}const RN=e=>{let t;const n=new Set,r=(d,f)=>{const h=typeof d=="function"?d(t):d;if(!Object.is(h,t)){const g=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(b=>b(t,g))}},i=()=>t,l={setState:r,getState:i,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d))},c=t=e(r,i,l);return l},BY=(e=>e?RN(e):RN),FY=e=>e;function $Y(e,t=FY){const n=kn.useSyncExternalStore(e.subscribe,kn.useCallback(()=>t(e.getState()),[e,t]),kn.useCallback(()=>t(e.getInitialState()),[e,t]));return kn.useDebugValue(n),n}const HY=e=>{const t=BY(e),n=r=>$Y(t,r);return Object.assign(n,t),n},bo=(e=>HY),nj="always",rj="funk",UY=[{value:"blow",label:"Blow"},{value:"bottle",label:"Bottle"},{value:"frog",label:"Frog"},{value:"funk",label:"Funk"},{value:"glass",label:"Glass"},{value:"ping",label:"Ping"},{value:"pop",label:"Pop"},{value:"purr",label:"Purr"},{value:"tink",label:"Tink"}];function VY(e){switch(e){case"never":case"unfocused":case"always":return e;default:return nj}}function WY(e){switch(e){case"blow":case"bottle":case"frog":case"funk":case"glass":case"ping":case"pop":case"purr":case"tink":return e;default:return rj}}const uc=bo()(e=>({chatSoundPreference:nj,chatSoundId:rj,setChatSoundPreference:t=>e({chatSoundPreference:VY(t)}),setChatSoundId:t=>e({chatSoundId:WY(t)})})),GY={blow:"/chat-sounds/Blow.mp3",bottle:"/chat-sounds/Bottle.mp3",frog:"/chat-sounds/Frog.mp3",funk:"/chat-sounds/Funk.mp3",glass:"/chat-sounds/Glass.mp3",ping:"/chat-sounds/Ping.mp3",pop:"/chat-sounds/Pop.mp3",purr:"/chat-sounds/Purr.mp3",tink:"/chat-sounds/Tink.mp3"};function qY(e=document){return e.visibilityState!=="visible"||!e.hasFocus()}function KY(e){const t=new Audio(GY[e]);return t.preload="auto",t.play()}async function qS(e,t){if(t<=0)return;const n=Array.from({length:t},(r,i)=>new Promise(s=>{window.setTimeout(()=>{KY(e).catch(()=>{}).finally(()=>s())},i*90)}));await Promise.all(n)}function YY(e,t=document){return e==="never"?!1:e==="always"?!0:qY(t)}function XY(e){return e.projectGroups.reduce((t,n)=>t+n.chats.reduce((r,i)=>r+(i.unread?1:0)+(i.status==="waiting_for_user"?1:0),0),0)}function TN(e){let t=0;const n=new Set;for(const r of e.projectGroups)for(const i of r.chats)i.unread&&(t+=1),i.status==="waiting_for_user"&&n.add(i.chatId);return{unreadCount:t,waitingChatIds:n}}function QY(e,t){if(!e)return 0;const n=TN(e),r=TN(t),i=Math.max(0,r.unreadCount-n.unreadCount);let s=0;for(const o of r.waitingChatIds)n.waitingChatIds.has(o)||(s+=1);return i+s}function KS(e){return e.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const ZY=[/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(['"])([\s\S]*)\1$/,/^(?:\/usr\/bin\/env\s+)?(?:\/bin\/)?(?:bash|zsh|sh)\s+(?:-[a-zA-Z]*c|-c)\s+(.+)$/,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:cmd(?:\.exe)?)\s+\/c\s+(.+)$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(['"])([\s\S]*)\1$/i,/^(?:\/usr\/bin\/env\s+)?(?:powershell(?:\.exe)?|pwsh)\s+(?:-NoProfile\s+)?-Command\s+(.+)$/i];function JY(e){const t=e.trim();for(const n of ZY){const r=t.match(n);if(!r)continue;const i=(r[2]??r[1]??"").trim();if(i)return i}return t}function ij(e){return e.split("/").pop()||e}const eX=1440*6e4;function tX(e,t){if(e===void 0)return null;const n=Math.max(0,t-e),r=6e4,i=60*r,s=eX,o=7*s;return n<r?"now":n<i?`${Math.floor(n/r)}m`:n<s?`${Math.floor(n/i)}h`:n<o?`${Math.floor(n/s)}d`:`${Math.floor(n/o)}w`}function nX(e){return e.lastMessageAt??e._creationTime}const Pd=({children:e,className:t,animate:n=!0,shimmerWidth:r,...i})=>m.jsx("span",{className:ye("mx-auto max-w-md text-foreground/60",n&&"animate-shiny-pulse",t),...i,children:e}),FC=1e3,Zg=60*FC,Gu=60*Zg,rx=24*Gu;function il(e){const t=Math.max(0,e);if(t<Zg)return`${Math.floor(t/FC)}s`;if(t<Gu)return`${Math.floor(t/Zg)}m`;if(t<rx){const i=Math.floor(t/Gu),s=Math.floor(t%Gu/Zg);return s===0?`${i}h`:`${i}h ${s}m`}const n=Math.floor(t/rx),r=Math.floor(t%rx/Gu);return r===0?`${n}d`:`${n}d ${r}h`}function YS(e){const t=Math.max(0,e);if(t>=Gu)return il(t);const n=Math.floor(t/FC),r=Math.floor(n/60),i=n%60;return`${r}:${i.toString().padStart(2,"0")}`}function XS(e){switch(e){case"idle":return"Idle";case"starting":return"Starting";case"running":return"Running";case"waiting_for_user":return"Waiting";case"failed":return"Failed"}}function QS(e){switch(e){case"running":return"active";case"waiting_for_user":return"attention";case"failed":return"destructive";case"idle":case"starting":default:return"muted"}}function ZS(e){switch(e){case"active":return"text-emerald-500 dark:text-emerald-400";case"attention":return"text-amber-500 dark:text-amber-400";case"destructive":return"text-destructive";case"muted":default:return"text-muted-foreground"}}function $C(e){const t=e+"CollectionProvider",[n,r]=da(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=x=>{const{scope:w,children:C}=x,E=kn.useRef(null),R=kn.useRef(new Map).current;return m.jsx(i,{scope:w,itemMap:R,collectionRef:E,children:C})};o.displayName=t;const l=e+"CollectionSlot",c=yc(l),d=kn.forwardRef((x,w)=>{const{scope:C,children:E}=x,R=s(l,C),T=mn(w,R.collectionRef);return m.jsx(c,{ref:T,children:E})});d.displayName=l;const f=e+"CollectionItemSlot",h="data-radix-collection-item",g=yc(f),b=kn.forwardRef((x,w)=>{const{scope:C,children:E,...R}=x,T=kn.useRef(null),A=mn(w,T),N=s(f,C);return kn.useEffect(()=>(N.itemMap.set(T,{ref:T,...R}),()=>void N.itemMap.delete(T))),m.jsx(g,{[h]:"",ref:A,children:E})});b.displayName=f;function y(x){const w=s(e+"CollectionConsumer",x);return kn.useCallback(()=>{const E=w.collectionRef.current;if(!E)return[];const R=Array.from(E.querySelectorAll(`[${h}]`));return Array.from(w.itemMap.values()).sort((N,D)=>R.indexOf(N.ref.current)-R.indexOf(D.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:d,ItemSlot:b},y,r]}var rX=_.createContext(void 0);function HC(e){const t=_.useContext(rX);return e||t||"ltr"}var ix="rovingFocusGroup.onEntryFocus",iX={bubbles:!1,cancelable:!0},vp="RovingFocusGroup",[JS,sj,sX]=$C(vp),[oX,oj]=da(vp,[sX]),[aX,lX]=oX(vp),aj=_.forwardRef((e,t)=>m.jsx(JS.Provider,{scope:e.__scopeRovingFocusGroup,children:m.jsx(JS.Slot,{scope:e.__scopeRovingFocusGroup,children:m.jsx(cX,{...e,ref:t})})}));aj.displayName=vp;var cX=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...h}=e,g=_.useRef(null),b=mn(t,g),y=HC(s),[x,w]=ud({prop:o,defaultProp:l??null,onChange:c,caller:vp}),[C,E]=_.useState(!1),R=zs(d),T=sj(n),A=_.useRef(!1),[N,D]=_.useState(0);return _.useEffect(()=>{const M=g.current;if(M)return M.addEventListener(ix,R),()=>M.removeEventListener(ix,R)},[R]),m.jsx(aX,{scope:n,orientation:r,dir:y,loop:i,currentTabStopId:x,onItemFocus:_.useCallback(M=>w(M),[w]),onItemShiftTab:_.useCallback(()=>E(!0),[]),onFocusableItemAdd:_.useCallback(()=>D(M=>M+1),[]),onFocusableItemRemove:_.useCallback(()=>D(M=>M-1),[]),children:m.jsx(Jt.div,{tabIndex:C||N===0?-1:0,"data-orientation":r,...h,ref:b,style:{outline:"none",...e.style},onMouseDown:Je(e.onMouseDown,()=>{A.current=!0}),onFocus:Je(e.onFocus,M=>{const W=!A.current;if(M.target===M.currentTarget&&W&&!C){const j=new CustomEvent(ix,iX);if(M.currentTarget.dispatchEvent(j),!j.defaultPrevented){const $=T().filter(z=>z.focusable),F=$.find(z=>z.active),P=$.find(z=>z.id===x),H=[F,P,...$].filter(Boolean).map(z=>z.ref.current);uj(H,f)}}A.current=!1}),onBlur:Je(e.onBlur,()=>E(!1))})})}),lj="RovingFocusGroupItem",cj=_.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...l}=e,c=ea(),d=s||c,f=lX(lj,n),h=f.currentTabStopId===d,g=sj(n),{onFocusableItemAdd:b,onFocusableItemRemove:y,currentTabStopId:x}=f;return _.useEffect(()=>{if(r)return b(),()=>y()},[r,b,y]),m.jsx(JS.ItemSlot,{scope:n,id:d,focusable:r,active:i,children:m.jsx(Jt.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:Je(e.onMouseDown,w=>{r?f.onItemFocus(d):w.preventDefault()}),onFocus:Je(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:Je(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const C=hX(w,f.orientation,f.dir);if(C!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let R=g().filter(T=>T.focusable).map(T=>T.ref.current);if(C==="last")R.reverse();else if(C==="prev"||C==="next"){C==="prev"&&R.reverse();const T=R.indexOf(w.currentTarget);R=f.loop?fX(R,T+1):R.slice(T+1)}setTimeout(()=>uj(R))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:x!=null}):o})})});cj.displayName=lj;var uX={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function dX(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function hX(e,t,n){const r=dX(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return uX[r]}function uj(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function fX(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var pX=aj,mX=cj,ew=["Enter"," "],gX=["ArrowDown","PageUp","Home"],dj=["ArrowUp","PageDown","End"],vX=[...gX,...dj],bX={ltr:[...ew,"ArrowRight"],rtl:[...ew,"ArrowLeft"]},_X={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bp="Menu",[jf,yX,xX]=$C(bp),[Pc,hj]=da(bp,[xX,Rl,oj]),Gb=Rl(),fj=oj(),[SX,Oc]=Pc(bp),[wX,_p]=Pc(bp),pj=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,l=Gb(t),[c,d]=_.useState(null),f=_.useRef(!1),h=zs(s),g=HC(i);return _.useEffect(()=>{const b=()=>{f.current=!0,document.addEventListener("pointerdown",y,{capture:!0,once:!0}),document.addEventListener("pointermove",y,{capture:!0,once:!0})},y=()=>f.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",y,{capture:!0}),document.removeEventListener("pointermove",y,{capture:!0})}},[]),m.jsx(Fb,{...l,children:m.jsx(SX,{scope:t,open:n,onOpenChange:h,content:c,onContentChange:d,children:m.jsx(wX,{scope:t,onClose:_.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:f,dir:g,modal:o,children:r})})})};pj.displayName=bp;var CX="MenuAnchor",UC=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Gb(n);return m.jsx(mp,{...i,...r,ref:t})});UC.displayName=CX;var VC="MenuPortal",[kX,mj]=Pc(VC,{forceMount:void 0}),gj=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Oc(VC,t);return m.jsx(kX,{scope:t,forceMount:n,children:m.jsx(xs,{present:n||s.open,children:m.jsx(Md,{asChild:!0,container:i,children:r})})})};gj.displayName=VC;var gs="MenuContent",[EX,WC]=Pc(gs),vj=_.forwardRef((e,t)=>{const n=mj(gs,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Oc(gs,e.__scopeMenu),o=_p(gs,e.__scopeMenu);return m.jsx(jf.Provider,{scope:e.__scopeMenu,children:m.jsx(xs,{present:r||s.open,children:m.jsx(jf.Slot,{scope:e.__scopeMenu,children:o.modal?m.jsx(RX,{...i,ref:t}):m.jsx(TX,{...i,ref:t})})})})}),RX=_.forwardRef((e,t)=>{const n=Oc(gs,e.__scopeMenu),r=_.useRef(null),i=mn(t,r);return _.useEffect(()=>{const s=r.current;if(s)return Db(s)},[]),m.jsx(GC,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Je(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),TX=_.forwardRef((e,t)=>{const n=Oc(gs,e.__scopeMenu);return m.jsx(GC,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),AX=yc("MenuContent.ScrollLock"),GC=_.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:g,onDismiss:b,disableOutsideScroll:y,...x}=e,w=Oc(gs,n),C=_p(gs,n),E=Gb(n),R=fj(n),T=yX(n),[A,N]=_.useState(null),D=_.useRef(null),M=mn(t,D,w.onContentChange),W=_.useRef(0),j=_.useRef(""),$=_.useRef(0),F=_.useRef(null),P=_.useRef("right"),B=_.useRef(0),H=y?hp:_.Fragment,z=y?{as:AX,allowPinchZoom:!0}:void 0,U=Y=>{var se,pe;const O=j.current+Y,G=T().filter(ce=>!ce.disabled),Z=document.activeElement,I=(se=G.find(ce=>ce.ref.current===Z))==null?void 0:se.textValue,re=G.map(ce=>ce.textValue),te=$X(re,O,I),oe=(pe=G.find(ce=>ce.textValue===te))==null?void 0:pe.ref.current;(function ce(ge){j.current=ge,window.clearTimeout(W.current),ge!==""&&(W.current=window.setTimeout(()=>ce(""),1e3))})(O),oe&&setTimeout(()=>oe.focus())};_.useEffect(()=>()=>window.clearTimeout(W.current),[]),Mb();const V=_.useCallback(Y=>{var G,Z;return P.current===((G=F.current)==null?void 0:G.side)&&UX(Y,(Z=F.current)==null?void 0:Z.area)},[]);return m.jsx(EX,{scope:n,searchRef:j,onItemEnter:_.useCallback(Y=>{V(Y)&&Y.preventDefault()},[V]),onItemLeave:_.useCallback(Y=>{var O;V(Y)||((O=D.current)==null||O.focus(),N(null))},[V]),onTriggerLeave:_.useCallback(Y=>{V(Y)&&Y.preventDefault()},[V]),pointerGraceTimerRef:$,onPointerGraceIntentChange:_.useCallback(Y=>{F.current=Y},[]),children:m.jsx(H,{...z,children:m.jsx(dp,{asChild:!0,trapped:i,onMountAutoFocus:Je(s,Y=>{var O;Y.preventDefault(),(O=D.current)==null||O.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:m.jsx(Nd,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:h,onInteractOutside:g,onDismiss:b,children:m.jsx(pX,{asChild:!0,...R,dir:C.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:N,onEntryFocus:Je(c,Y=>{C.isUsingKeyboardRef.current||Y.preventDefault()}),preventScrollOnEntryFocus:!0,children:m.jsx($b,{role:"menu","aria-orientation":"vertical","data-state":Dj(w.open),"data-radix-menu-content":"",dir:C.dir,...E,...x,ref:M,style:{outline:"none",...x.style},onKeyDown:Je(x.onKeyDown,Y=>{const G=Y.target.closest("[data-radix-menu-content]")===Y.currentTarget,Z=Y.ctrlKey||Y.altKey||Y.metaKey,I=Y.key.length===1;G&&(Y.key==="Tab"&&Y.preventDefault(),!Z&&I&&U(Y.key));const re=D.current;if(Y.target!==re||!vX.includes(Y.key))return;Y.preventDefault();const oe=T().filter(se=>!se.disabled).map(se=>se.ref.current);dj.includes(Y.key)&&oe.reverse(),BX(oe)}),onBlur:Je(e.onBlur,Y=>{Y.currentTarget.contains(Y.target)||(window.clearTimeout(W.current),j.current="")}),onPointerMove:Je(e.onPointerMove,zf(Y=>{const O=Y.target,G=B.current!==Y.clientX;if(Y.currentTarget.contains(O)&&G){const Z=Y.clientX>B.current?"right":"left";P.current=Z,B.current=Y.clientX}}))})})})})})})});vj.displayName=gs;var NX="MenuGroup",qC=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(Jt.div,{role:"group",...r,ref:t})});qC.displayName=NX;var MX="MenuLabel",bj=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(Jt.div,{...r,ref:t})});bj.displayName=MX;var Dv="MenuItem",AN="menu.itemSelect",qb=_.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=_.useRef(null),o=_p(Dv,e.__scopeMenu),l=WC(Dv,e.__scopeMenu),c=mn(t,s),d=_.useRef(!1),f=()=>{const h=s.current;if(!n&&h){const g=new CustomEvent(AN,{bubbles:!0,cancelable:!0});h.addEventListener(AN,b=>r==null?void 0:r(b),{once:!0}),wO(h,g),g.defaultPrevented?d.current=!1:o.onClose()}};return m.jsx(_j,{...i,ref:c,disabled:n,onClick:Je(e.onClick,f),onPointerDown:h=>{var g;(g=e.onPointerDown)==null||g.call(e,h),d.current=!0},onPointerUp:Je(e.onPointerUp,h=>{var g;d.current||(g=h.currentTarget)==null||g.click()}),onKeyDown:Je(e.onKeyDown,h=>{const g=l.searchRef.current!=="";n||g&&h.key===" "||ew.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});qb.displayName=Dv;var _j=_.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=WC(Dv,n),l=fj(n),c=_.useRef(null),d=mn(t,c),[f,h]=_.useState(!1),[g,b]=_.useState("");return _.useEffect(()=>{const y=c.current;y&&b((y.textContent??"").trim())},[s.children]),m.jsx(jf.ItemSlot,{scope:n,disabled:r,textValue:i??g,children:m.jsx(mX,{asChild:!0,...l,focusable:!r,children:m.jsx(Jt.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:d,onPointerMove:Je(e.onPointerMove,zf(y=>{r?o.onItemLeave(y):(o.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Je(e.onPointerLeave,zf(y=>o.onItemLeave(y))),onFocus:Je(e.onFocus,()=>h(!0)),onBlur:Je(e.onBlur,()=>h(!1))})})})}),LX="MenuCheckboxItem",yj=_.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return m.jsx(kj,{scope:e.__scopeMenu,checked:n,children:m.jsx(qb,{role:"menuitemcheckbox","aria-checked":Iv(n)?"mixed":n,...i,ref:t,"data-state":YC(n),onSelect:Je(i.onSelect,()=>r==null?void 0:r(Iv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});yj.displayName=LX;var xj="MenuRadioGroup",[DX,IX]=Pc(xj,{value:void 0,onValueChange:()=>{}}),Sj=_.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=zs(r);return m.jsx(DX,{scope:e.__scopeMenu,value:n,onValueChange:s,children:m.jsx(qC,{...i,ref:t})})});Sj.displayName=xj;var wj="MenuRadioItem",Cj=_.forwardRef((e,t)=>{const{value:n,...r}=e,i=IX(wj,e.__scopeMenu),s=n===i.value;return m.jsx(kj,{scope:e.__scopeMenu,checked:s,children:m.jsx(qb,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":YC(s),onSelect:Je(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});Cj.displayName=wj;var KC="MenuItemIndicator",[kj,PX]=Pc(KC,{checked:!1}),Ej=_.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=PX(KC,n);return m.jsx(xs,{present:r||Iv(s.checked)||s.checked===!0,children:m.jsx(Jt.span,{...i,ref:t,"data-state":YC(s.checked)})})});Ej.displayName=KC;var OX="MenuSeparator",Rj=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.jsx(Jt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Rj.displayName=OX;var jX="MenuArrow",Tj=_.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Gb(n);return m.jsx(Hb,{...i,...r,ref:t})});Tj.displayName=jX;var zX="MenuSub",[jCe,Aj]=Pc(zX),sf="MenuSubTrigger",Nj=_.forwardRef((e,t)=>{const n=Oc(sf,e.__scopeMenu),r=_p(sf,e.__scopeMenu),i=Aj(sf,e.__scopeMenu),s=WC(sf,e.__scopeMenu),o=_.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=s,d={__scopeMenu:e.__scopeMenu},f=_.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return _.useEffect(()=>f,[f]),_.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),c(null)}},[l,c]),m.jsx(UC,{asChild:!0,...d,children:m.jsx(_j,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Dj(n.open),...e,ref:vC(t,i.onTriggerChange),onClick:h=>{var g;(g=e.onClick)==null||g.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Je(e.onPointerMove,zf(h=>{s.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:Je(e.onPointerLeave,zf(h=>{var b,y;f();const g=(b=n.content)==null?void 0:b.getBoundingClientRect();if(g){const x=(y=n.content)==null?void 0:y.dataset.side,w=x==="right",C=w?-5:5,E=g[w?"left":"right"],R=g[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:h.clientX+C,y:h.clientY},{x:E,y:g.top},{x:R,y:g.top},{x:R,y:g.bottom},{x:E,y:g.bottom}],side:x}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(h),h.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Je(e.onKeyDown,h=>{var b;const g=s.searchRef.current!=="";e.disabled||g&&h.key===" "||bX[r.dir].includes(h.key)&&(n.onOpenChange(!0),(b=n.content)==null||b.focus(),h.preventDefault())})})})});Nj.displayName=sf;var Mj="MenuSubContent",Lj=_.forwardRef((e,t)=>{const n=mj(gs,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Oc(gs,e.__scopeMenu),o=_p(gs,e.__scopeMenu),l=Aj(Mj,e.__scopeMenu),c=_.useRef(null),d=mn(t,c);return m.jsx(jf.Provider,{scope:e.__scopeMenu,children:m.jsx(xs,{present:r||s.open,children:m.jsx(jf.Slot,{scope:e.__scopeMenu,children:m.jsx(GC,{id:l.contentId,"aria-labelledby":l.triggerId,...i,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{var h;o.isUsingKeyboardRef.current&&((h=c.current)==null||h.focus()),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:Je(e.onFocusOutside,f=>{f.target!==l.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Je(e.onEscapeKeyDown,f=>{o.onClose(),f.preventDefault()}),onKeyDown:Je(e.onKeyDown,f=>{var b;const h=f.currentTarget.contains(f.target),g=_X[o.dir].includes(f.key);h&&g&&(s.onOpenChange(!1),(b=l.trigger)==null||b.focus(),f.preventDefault())})})})})})});Lj.displayName=Mj;function Dj(e){return e?"open":"closed"}function Iv(e){return e==="indeterminate"}function YC(e){return Iv(e)?"indeterminate":e?"checked":"unchecked"}function BX(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function FX(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function $X(e,t,n){const i=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=FX(e,Math.max(s,0));i.length===1&&(o=o.filter(d=>d!==n));const c=o.find(d=>d.toLowerCase().startsWith(i.toLowerCase()));return c!==n?c:void 0}function HX(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const l=t[s],c=t[o],d=l.x,f=l.y,h=c.x,g=c.y;f>r!=g>r&&n<(h-d)*(r-f)/(g-f)+d&&(i=!i)}return i}function UX(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return HX(n,t)}function zf(e){return t=>t.pointerType==="mouse"?e(t):void 0}var VX=pj,WX=UC,GX=gj,qX=vj,KX=qC,YX=bj,XX=qb,QX=yj,ZX=Sj,JX=Cj,eQ=Ej,tQ=Rj,nQ=Tj,rQ=Nj,iQ=Lj,XC="ContextMenu",[sQ]=da(XC,[hj]),di=hj(),[oQ,Ij]=sQ(XC),Pj=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:s=!0}=e,[o,l]=_.useState(!1),c=di(t),d=zs(r),f=_.useCallback(h=>{l(h),d(h)},[d]);return m.jsx(oQ,{scope:t,open:o,onOpenChange:f,modal:s,children:m.jsx(VX,{...c,dir:i,open:o,onOpenChange:f,modal:s,children:n})})};Pj.displayName=XC;var Oj="ContextMenuTrigger",jj=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...i}=e,s=Ij(Oj,n),o=di(n),l=_.useRef({x:0,y:0}),c=_.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=_.useRef(0),f=_.useCallback(()=>window.clearTimeout(d.current),[]),h=g=>{l.current={x:g.clientX,y:g.clientY},s.onOpenChange(!0)};return _.useEffect(()=>f,[f]),_.useEffect(()=>void(r&&f()),[r,f]),m.jsxs(m.Fragment,{children:[m.jsx(WX,{...o,virtualRef:c}),m.jsx(Jt.span,{"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:Je(e.onContextMenu,g=>{f(),h(g),g.preventDefault()}),onPointerDown:r?e.onPointerDown:Je(e.onPointerDown,tg(g=>{f(),d.current=window.setTimeout(()=>h(g),700)})),onPointerMove:r?e.onPointerMove:Je(e.onPointerMove,tg(f)),onPointerCancel:r?e.onPointerCancel:Je(e.onPointerCancel,tg(f)),onPointerUp:r?e.onPointerUp:Je(e.onPointerUp,tg(f))})]})});jj.displayName=Oj;var aQ="ContextMenuPortal",zj=e=>{const{__scopeContextMenu:t,...n}=e,r=di(t);return m.jsx(GX,{...r,...n})};zj.displayName=aQ;var Bj="ContextMenuContent",Fj=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=Ij(Bj,n),s=di(n),o=_.useRef(!1);return m.jsx(qX,{...s,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{var c;(c=e.onCloseAutoFocus)==null||c.call(e,l),!l.defaultPrevented&&o.current&&l.preventDefault(),o.current=!1},onInteractOutside:l=>{var c;(c=e.onInteractOutside)==null||c.call(e,l),!l.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Fj.displayName=Bj;var lQ="ContextMenuGroup",cQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(KX,{...i,...r,ref:t})});cQ.displayName=lQ;var uQ="ContextMenuLabel",dQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(YX,{...i,...r,ref:t})});dQ.displayName=uQ;var hQ="ContextMenuItem",$j=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(XX,{...i,...r,ref:t})});$j.displayName=hQ;var fQ="ContextMenuCheckboxItem",pQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(QX,{...i,...r,ref:t})});pQ.displayName=fQ;var mQ="ContextMenuRadioGroup",gQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(ZX,{...i,...r,ref:t})});gQ.displayName=mQ;var vQ="ContextMenuRadioItem",bQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(JX,{...i,...r,ref:t})});bQ.displayName=vQ;var _Q="ContextMenuItemIndicator",yQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(eQ,{...i,...r,ref:t})});yQ.displayName=_Q;var xQ="ContextMenuSeparator",Hj=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(tQ,{...i,...r,ref:t})});Hj.displayName=xQ;var SQ="ContextMenuArrow",wQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(nQ,{...i,...r,ref:t})});wQ.displayName=SQ;var CQ="ContextMenuSubTrigger",kQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(rQ,{...i,...r,ref:t})});kQ.displayName=CQ;var EQ="ContextMenuSubContent",RQ=_.forwardRef((e,t)=>{const{__scopeContextMenu:n,...r}=e,i=di(n);return m.jsx(iQ,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});RQ.displayName=EQ;function tg(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var TQ=Pj,AQ=jj,NQ=zj,Uj=Fj,Vj=$j,Wj=Hj;const Gj=_.createContext(null);function Od({onOpenChange:e,...t}){const[n,r]=_.useState(0),i=_.useCallback(()=>{r(s=>s+1),e==null||e(!1)},[e]);return m.jsx(Gj.Provider,{value:i,children:m.jsx(TQ,{onOpenChange:e,...t},n)})}const jd=AQ,jc=_.forwardRef(({className:e,...t},n)=>m.jsx(NQ,{children:m.jsx(Uj,{ref:n,className:ye("z-50 min-w-[170px] overflow-hidden rounded-xl border border-border bg-background p-1 shadow-lg outline-hidden animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",e),...t})}));jc.displayName=Uj.displayName;const $n=_.forwardRef(({className:e,onSelect:t,...n},r)=>{const i=_.useContext(Gj);return m.jsx(Vj,{ref:r,className:ye("relative flex cursor-default select-none items-center gap-2.5 rounded-lg px-3 py-2 text-xs font-medium text-foreground outline-hidden transition-colors hover:bg-muted focus:bg-muted data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),onSelect:s=>{t==null||t(s),i==null||i()},...n})});$n.displayName=Vj.displayName;const qj=_.forwardRef(({className:e,...t},n)=>m.jsx(Wj,{ref:n,className:ye("-mx-1 my-1 h-px bg-border",e),...t}));qj.displayName=Wj.displayName;function MQ({editorLabel:e,onCopyPath:t,onShowArchived:n,onOpenInFinder:r,onOpenInEditor:i,onHide:s,children:o}){return m.jsxs(Od,{children:[m.jsx(jd,{asChild:!0,children:o}),m.jsxs(jc,{children:[m.jsxs($n,{onSelect:l=>{l.stopPropagation(),t()},children:[m.jsx(yl,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Copy Path"})]}),m.jsxs($n,{onSelect:l=>{l.stopPropagation(),n()},children:[m.jsx(aC,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Show Archived"})]}),m.jsxs($n,{onSelect:l=>{l.stopPropagation(),r()},children:[m.jsx(Tb,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Show in Finder"})]}),m.jsxs($n,{onSelect:l=>{l.stopPropagation(),i()},children:[m.jsx(lC,{className:"h-3.5 w-3.5"}),m.jsxs("span",{className:"text-xs font-medium",children:["Open in ",e]})]}),m.jsxs($n,{onSelect:l=>{l.stopPropagation(),s()},className:"text-destructive hover:bg-destructive/10 focus:bg-destructive/10",children:[m.jsx(h9,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Hide"})]})]})]})}function LQ({canFork:e,onRename:t,onShare:n,onOpenInFinder:r,onFork:i,onArchive:s,onDelete:o,children:l}){return m.jsxs(Od,{children:[m.jsx(jd,{asChild:!0,children:l}),m.jsxs(jc,{children:[m.jsxs($n,{onSelect:c=>{c.preventDefault(),t()},children:[m.jsx(fC,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Rename"})]}),m.jsxs($n,{onSelect:c=>{c.preventDefault(),n()},children:[m.jsx(gC,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Share"})]}),m.jsxs($n,{onSelect:c=>{c.preventDefault(),r()},children:[m.jsx(Tb,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Open in Finder"})]}),m.jsxs($n,{disabled:!e,onSelect:c=>{c.preventDefault(),e&&i()},children:[m.jsx(xO,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Fork"})]}),m.jsxs($n,{onSelect:c=>{c.preventDefault(),s()},children:[m.jsx(aC,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Archive"})]}),m.jsxs($n,{onSelect:c=>{c.preventDefault(),o()},className:"text-destructive dark:text-red-400 hover:bg-destructive/10 focus:bg-destructive/10 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",children:[m.jsx(mC,{className:"h-3.5 w-3.5"}),m.jsx("span",{className:"text-xs font-medium",children:"Delete"})]})]})]})}const DQ=new Set(["starting","running"]);function IQ({chat:e,activeChatId:t,nowMs:n,shortcutHint:r=null,showShortcutHint:i=!1,onSelectChat:s,onRenameChat:o,onShareChat:l,onOpenInFinder:c,onForkChat:d,onArchiveChat:f,onDeleteChat:h}){const g=(e.status==="running"||e.status==="waiting_for_user")&&e.stateEnteredAt!=null,b=g&&e.stateEnteredAt!=null?`${XS(e.status)} ${YS(n-e.stateEnteredAt)}`:il(n-(e.lastMessageAt??e._creationTime)),y=i&&r?r:b,x=i&&!!r,w=Iq(e.chatId),C=m.jsxs("div",{"data-chat-id":w,className:ye("group flex items-center gap-2 pl-2.5 pr-0.5 py-0.5 rounded-lg cursor-pointer border-border/0 hover:border-border hover:bg-muted/20 active:scale-[0.985] border transition-all",t===w?"bg-muted hover:bg-muted border-border":"border-border/0 dark:hover:border-border/40 "),onClick:()=>s(e.chatId),children:[DQ.has(e.status)?m.jsx(pn,{className:"size-3.5 flex-shrink-0 animate-spin text-logo"}):e.status==="waiting_for_user"?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-info/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-info ring-2 ring-muted/20 dark:ring-muted/50"})]})}):e.unread?m.jsx("div",{className:"relative ",children:m.jsxs("div",{className:" rounded-full z-0 size-3.5 flex items-center justify-center ",children:[m.jsx("div",{className:"absolute rounded-full z-0 size-2.5 bg-success/80 animate-ping"}),m.jsx("div",{className:" rounded-full z-0 size-2.5 bg-success ring-2 ring-muted/20 dark:ring-muted/50"})]})}):null,m.jsx("span",{className:"text-sm truncate flex-1 translate-y-[-0.5px]",children:e.status!=="idle"&&e.status!=="waiting_for_user"?m.jsx(Pd,{animate:e.status==="running",shimmerWidth:Math.max(20,e.title.length*3),children:e.title}):e.status!=="idle"||t===w||e.unread?m.jsx("span",{className:"",children:e.title}):m.jsx("span",{className:"text-slate-500 dark:text-slate-400",children:e.title})}),m.jsxs("div",{className:ye("relative h-7 mr-[2px] shrink-0",e.canFork?"w-12":g?"w-20":"w-6"),children:[y?x?m.jsx("span",{className:"hidden md:flex absolute inset-0 items-center justify-end pr-0.5 text-[11px] text-foreground transition-opacity group-hover:opacity-0",children:m.jsx(ej,{className:"h-4 min-w-4 rounded-sm border-border/50 bg-transparent px-1 text-[10px]",children:r})}):m.jsx("span",{className:ye("hidden md:flex absolute inset-0 items-center justify-end pr-1 text-[11px] tabular-nums opacity-80 transition-opacity group-hover:opacity-0",g?ZS(QS(e.status)):"text-muted-foreground opacity-60"),children:y}):null,m.jsxs("div",{className:ye("absolute inset-0 flex items-center justify-end gap-0 opacity-100 mr-[3px]",y?"md:opacity-0 md:group-hover:opacity-100":"opacity-100 md:opacity-0 md:group-hover:opacity-100"),children:[e.canFork?m.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:E=>{E.stopPropagation(),d(e.chatId)},title:"Fork chat",children:m.jsx(xO,{className:"size-3.5"})}):null,m.jsx(st,{variant:"ghost",size:"icon",className:"h-6 w-6 cursor-pointer rounded-sm hover:!bg-transparent !border-0",onClick:E=>{E.stopPropagation(),f(e.chatId)},title:"Archive chat",children:m.jsx(aC,{className:"size-3.5"})})]})]})]},e._id);return m.jsx(LQ,{canFork:e.canFork,onRename:()=>o(e.chatId),onShare:()=>l(e.chatId),onOpenInFinder:()=>c(e.localPath),onFork:()=>d(e.chatId),onArchive:()=>f(e.chatId),onDelete:()=>h(e.chatId),children:C})}const PQ=_.memo(IQ);function OQ(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>r=>{t.forEach(i=>i(r))},t)}const Kb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zd(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function QC(e){return"nodeType"in e}function Ri(e){var t,n;return e?zd(e)?e:QC(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function ZC(e){const{Document:t}=Ri(e);return e instanceof t}function yp(e){return zd(e)?!1:e instanceof Ri(e).HTMLElement}function Kj(e){return e instanceof Ri(e).SVGElement}function Bd(e){return e?zd(e)?e.document:QC(e)?ZC(e)?e:yp(e)||Kj(e)?e.ownerDocument:document:document:document}const mo=Kb?_.useLayoutEffect:_.useEffect;function JC(e){const t=_.useRef(e);return mo(()=>{t.current=e}),_.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function jQ(){const e=_.useRef(null),t=_.useCallback((r,i)=>{e.current=setInterval(r,i)},[]),n=_.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Bf(e,t){t===void 0&&(t=[e]);const n=_.useRef(e);return mo(()=>{n.current!==e&&(n.current=e)},t),n}function xp(e,t){const n=_.useRef();return _.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Pv(e){const t=JC(e),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&(t==null||t(i,n.current)),n.current=i},[]);return[n,r]}function tw(e){const t=_.useRef();return _.useEffect(()=>{t.current=e},[e]),t.current}let sx={};function Sp(e,t){return _.useMemo(()=>{if(t)return t;const n=sx[e]==null?0:sx[e]+1;return sx[e]=n,e+"-"+n},[e,t])}function Yj(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((s,o)=>{const l=Object.entries(o);for(const[c,d]of l){const f=s[c];f!=null&&(s[c]=f+e*d)}return s},{...t})}}const ed=Yj(1),Ov=Yj(-1);function zQ(e){return"clientX"in e&&"clientY"in e}function ek(e){if(!e)return!1;const{KeyboardEvent:t}=Ri(e.target);return t&&e instanceof t}function BQ(e){if(!e)return!1;const{TouchEvent:t}=Ri(e.target);return t&&e instanceof t}function nw(e){if(BQ(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return zQ(e)?{x:e.clientX,y:e.clientY}:null}const Ff=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Ff.Translate.toString(e),Ff.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),NN="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function FQ(e){return e.matches(NN)?e:e.querySelector(NN)}const $Q={display:"none"};function HQ(e){let{id:t,value:n}=e;return kn.createElement("div",{id:t,style:$Q},n)}function UQ(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const i={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return kn.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function VQ(){const[e,t]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Xj=_.createContext(null);function WQ(e){const t=_.useContext(Xj);_.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function GQ(){const[e]=_.useState(()=>new Set),t=_.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[_.useCallback(r=>{let{type:i,event:s}=r;e.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,s)})},[e]),t]}const qQ={draggable:`
|
|
641
641
|
To pick up a draggable item, press the space bar.
|
|
642
642
|
While dragging, use the arrow keys to move the item.
|
|
643
643
|
Press space again to drop the item in its new position, or press escape to cancel.
|
package/dist/client/index.html
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
})()
|
|
26
26
|
</script>
|
|
27
27
|
<title>Kanna</title>
|
|
28
|
-
<script type="module" crossorigin src="/assets/index-
|
|
28
|
+
<script type="module" crossorigin src="/assets/index-UQWb6QtR.js"></script>
|
|
29
29
|
<link rel="stylesheet" crossorigin href="/assets/index-CC4TiTzA.css">
|
|
30
30
|
</head>
|
|
31
31
|
<body>
|
package/package.json
CHANGED
package/src/server/cli.ts
CHANGED
package/src/server/server.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { KeybindingsManager } from "./keybindings"
|
|
|
19
19
|
import { readLlmProviderSnapshot, validateLlmProviderCredentials, writeLlmProviderSnapshot } from "./llm-provider"
|
|
20
20
|
import { getMachineDisplayName } from "./machine-name"
|
|
21
21
|
import { TerminalManager } from "./terminal-manager"
|
|
22
|
+
import { TerminalPidRegistry } from "./terminal-pid-registry"
|
|
22
23
|
import { UpdateManager } from "./update-manager"
|
|
23
24
|
import type { UpdateInstallAttemptResult } from "./cli-runtime"
|
|
24
25
|
import { compareVersions } from "./cli-runtime"
|
|
@@ -134,7 +135,12 @@ export async function startKannaServer(options: StartKannaServerOptions = {}) {
|
|
|
134
135
|
|
|
135
136
|
let server: ReturnType<typeof Bun.serve<ClientState>>
|
|
136
137
|
let router: ReturnType<typeof createWsRouter>
|
|
137
|
-
const
|
|
138
|
+
const terminalPidRegistry = new TerminalPidRegistry(path.join(store.dataDir, "terminals.json"))
|
|
139
|
+
const reapedTerminals = await terminalPidRegistry.reapStale()
|
|
140
|
+
if (reapedTerminals.length > 0) {
|
|
141
|
+
console.log(`[kanna] reaped ${reapedTerminals.length} orphan terminal process group(s) from previous run`)
|
|
142
|
+
}
|
|
143
|
+
const terminals = new TerminalManager({ pidRegistry: terminalPidRegistry })
|
|
138
144
|
const keybindings = new KeybindingsManager()
|
|
139
145
|
const appSettings = new AppSettingsManager(path.join(store.dataDir, "settings.json"))
|
|
140
146
|
await appSettings.initialize()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, describe, expect, test } from "bun:test"
|
|
2
|
-
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises"
|
|
2
|
+
import { mkdtemp, mkdir, readFile, rm, writeFile } from "node:fs/promises"
|
|
3
3
|
import os from "node:os"
|
|
4
4
|
import path from "node:path"
|
|
5
5
|
import { TerminalManager } from "./terminal-manager"
|
|
@@ -157,6 +157,78 @@ describeIfSupported("TerminalManager", () => {
|
|
|
157
157
|
}
|
|
158
158
|
})
|
|
159
159
|
|
|
160
|
+
test("registers terminal pids and unregisters on close", async () => {
|
|
161
|
+
const terminalId = "terminal-pid-registry-wiring"
|
|
162
|
+
const registryPath = path.join(tempProjectPath, "terminals.json")
|
|
163
|
+
const { TerminalPidRegistry } = await import("./terminal-pid-registry")
|
|
164
|
+
const registry = new TerminalPidRegistry(registryPath)
|
|
165
|
+
|
|
166
|
+
async function readEntries(): Promise<Array<{ terminalId: string; pid: number }>> {
|
|
167
|
+
try {
|
|
168
|
+
const raw = JSON.parse(await readFile(registryPath, "utf8")) as { entries: Array<{ terminalId: string; pid: number }> }
|
|
169
|
+
return raw.entries
|
|
170
|
+
} catch {
|
|
171
|
+
return []
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function waitForEntries(predicate: (entries: Array<{ terminalId: string; pid: number }>) => boolean) {
|
|
176
|
+
const deadline = Date.now() + COMMAND_TIMEOUT_MS
|
|
177
|
+
while (Date.now() < deadline) {
|
|
178
|
+
if (predicate(await readEntries())) return
|
|
179
|
+
await Bun.sleep(25)
|
|
180
|
+
}
|
|
181
|
+
throw new Error("Timed out waiting on registry entries")
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const manager = new TerminalManager({ pidRegistry: registry })
|
|
185
|
+
manager.createTerminal({
|
|
186
|
+
projectPath: tempProjectPath,
|
|
187
|
+
terminalId,
|
|
188
|
+
cols: 80,
|
|
189
|
+
rows: 24,
|
|
190
|
+
scrollback: 1_000,
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
await waitForEntries((entries) => entries.some((entry) => entry.terminalId === terminalId))
|
|
195
|
+
|
|
196
|
+
manager.close(terminalId)
|
|
197
|
+
|
|
198
|
+
await waitForEntries((entries) => !entries.some((entry) => entry.terminalId === terminalId))
|
|
199
|
+
} finally {
|
|
200
|
+
manager.close(terminalId)
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
test("kills the shell process group when the shell exits", async () => {
|
|
205
|
+
const terminalId = "terminal-descendant-reap"
|
|
206
|
+
const pgroupKillCalls: Array<{ pgid: number; signal: NodeJS.Signals | number }> = []
|
|
207
|
+
const originalKill = process.kill.bind(process)
|
|
208
|
+
process.kill = ((pid: number, signal: NodeJS.Signals | number = "SIGTERM") => {
|
|
209
|
+
if (pid < 0) {
|
|
210
|
+
pgroupKillCalls.push({ pgid: -pid, signal })
|
|
211
|
+
}
|
|
212
|
+
return originalKill(pid, signal)
|
|
213
|
+
}) as typeof process.kill
|
|
214
|
+
|
|
215
|
+
const { manager } = await createSession(terminalId)
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
// `exit\r` makes the shell exit naturally — the bug was that this
|
|
219
|
+
// path never reaped the shell's process group, leaving any
|
|
220
|
+
// background descendants (e.g. `bun run dev`) adopted by init.
|
|
221
|
+
manager.write(terminalId, "exit\r")
|
|
222
|
+
await waitFor(() => manager.getSnapshot(terminalId)?.status === "exited", COMMAND_TIMEOUT_MS)
|
|
223
|
+
|
|
224
|
+
// The exited handler must have issued a SIGKILL to the shell pgroup.
|
|
225
|
+
expect(pgroupKillCalls.some((call) => call.signal === "SIGKILL")).toBe(true)
|
|
226
|
+
} finally {
|
|
227
|
+
process.kill = originalKill
|
|
228
|
+
manager.close(terminalId)
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
|
|
160
232
|
test("filters leaked focus reports while focus mode is disabled", async () => {
|
|
161
233
|
const terminalId = "terminal-focus-filtered"
|
|
162
234
|
const { manager, getOutput } = await createSession(terminalId)
|
|
@@ -4,6 +4,7 @@ import defaultShell, { detectDefaultShell } from "default-shell"
|
|
|
4
4
|
import { Terminal } from "@xterm/headless"
|
|
5
5
|
import { SerializeAddon } from "@xterm/addon-serialize"
|
|
6
6
|
import type { TerminalEvent, TerminalSnapshot } from "../shared/protocol"
|
|
7
|
+
import type { TerminalPidRegistry } from "./terminal-pid-registry"
|
|
7
8
|
|
|
8
9
|
const DEFAULT_COLS = 80
|
|
9
10
|
const DEFAULT_ROWS = 24
|
|
@@ -124,6 +125,16 @@ function killTerminalProcessTree(subprocess: Bun.Subprocess | null) {
|
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
function reapShellPgroup(pid: number | undefined) {
|
|
129
|
+
if (process.platform === "win32") return
|
|
130
|
+
if (typeof pid !== "number" || pid <= 0) return
|
|
131
|
+
try {
|
|
132
|
+
process.kill(-pid, "SIGKILL")
|
|
133
|
+
} catch {
|
|
134
|
+
// ESRCH (empty pgrp) and EPERM (race with kernel reap) are expected.
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
127
138
|
function signalTerminalProcessGroup(subprocess: Bun.Subprocess | null, signal: NodeJS.Signals) {
|
|
128
139
|
if (!subprocess) return false
|
|
129
140
|
|
|
@@ -150,6 +161,11 @@ function signalTerminalProcessGroup(subprocess: Bun.Subprocess | null, signal: N
|
|
|
150
161
|
export class TerminalManager {
|
|
151
162
|
private readonly sessions = new Map<string, TerminalSession>()
|
|
152
163
|
private readonly listeners = new Set<(event: TerminalEvent) => void>()
|
|
164
|
+
private readonly pidRegistry: TerminalPidRegistry | null
|
|
165
|
+
|
|
166
|
+
constructor(options: { pidRegistry?: TerminalPidRegistry | null } = {}) {
|
|
167
|
+
this.pidRegistry = options.pidRegistry ?? null
|
|
168
|
+
}
|
|
153
169
|
|
|
154
170
|
onEvent(listener: (event: TerminalEvent) => void) {
|
|
155
171
|
this.listeners.add(listener)
|
|
@@ -231,7 +247,20 @@ export class TerminalManager {
|
|
|
231
247
|
session.headless.dispose()
|
|
232
248
|
throw error
|
|
233
249
|
}
|
|
250
|
+
const shellPid = session.process.pid
|
|
251
|
+
if (typeof shellPid === "number") {
|
|
252
|
+
void this.pidRegistry?.register({
|
|
253
|
+
terminalId: args.terminalId,
|
|
254
|
+
pid: shellPid,
|
|
255
|
+
cwd: args.projectPath,
|
|
256
|
+
})
|
|
257
|
+
}
|
|
258
|
+
const handleShellExit = () => {
|
|
259
|
+
reapShellPgroup(shellPid)
|
|
260
|
+
void this.pidRegistry?.unregister(args.terminalId)
|
|
261
|
+
}
|
|
234
262
|
void session.process.exited.then((exitCode) => {
|
|
263
|
+
handleShellExit()
|
|
235
264
|
const active = this.sessions.get(args.terminalId)
|
|
236
265
|
if (!active) return
|
|
237
266
|
active.status = "exited"
|
|
@@ -242,6 +271,7 @@ export class TerminalManager {
|
|
|
242
271
|
exitCode,
|
|
243
272
|
})
|
|
244
273
|
}).catch((error) => {
|
|
274
|
+
handleShellExit()
|
|
245
275
|
const active = this.sessions.get(args.terminalId)
|
|
246
276
|
if (!active) return
|
|
247
277
|
active.status = "exited"
|
|
@@ -309,6 +339,7 @@ export class TerminalManager {
|
|
|
309
339
|
|
|
310
340
|
this.sessions.delete(terminalId)
|
|
311
341
|
killTerminalProcessTree(session.process)
|
|
342
|
+
void this.pidRegistry?.unregister(terminalId)
|
|
312
343
|
session.terminal.close()
|
|
313
344
|
session.serializeAddon.dispose()
|
|
314
345
|
session.headless.dispose()
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
|
|
2
|
+
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises"
|
|
3
|
+
import os from "node:os"
|
|
4
|
+
import path from "node:path"
|
|
5
|
+
import { TerminalPidRegistry } from "./terminal-pid-registry"
|
|
6
|
+
|
|
7
|
+
let tempDir = ""
|
|
8
|
+
let registryPath = ""
|
|
9
|
+
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
tempDir = await mkdtemp(path.join(os.tmpdir(), "kanna-terminal-registry-"))
|
|
12
|
+
registryPath = path.join(tempDir, "terminals.json")
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
afterEach(async () => {
|
|
16
|
+
if (tempDir) {
|
|
17
|
+
await rm(tempDir, { recursive: true, force: true })
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe("TerminalPidRegistry", () => {
|
|
22
|
+
test("register persists entries to disk", async () => {
|
|
23
|
+
const registry = new TerminalPidRegistry(registryPath)
|
|
24
|
+
await registry.register({ terminalId: "t1", pid: 12345, cwd: "/tmp/a" })
|
|
25
|
+
await registry.register({ terminalId: "t2", pid: 23456, cwd: "/tmp/b" })
|
|
26
|
+
|
|
27
|
+
const raw = JSON.parse(await readFile(registryPath, "utf8")) as {
|
|
28
|
+
entries: Array<{ terminalId: string; pid: number; cwd: string }>
|
|
29
|
+
}
|
|
30
|
+
expect(raw.entries).toHaveLength(2)
|
|
31
|
+
expect(raw.entries[0]).toMatchObject({ terminalId: "t1", pid: 12345, cwd: "/tmp/a" })
|
|
32
|
+
expect(raw.entries[1]).toMatchObject({ terminalId: "t2", pid: 23456, cwd: "/tmp/b" })
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test("unregister removes entry and persists", async () => {
|
|
36
|
+
const registry = new TerminalPidRegistry(registryPath)
|
|
37
|
+
await registry.register({ terminalId: "t1", pid: 1, cwd: "/tmp/a" })
|
|
38
|
+
await registry.register({ terminalId: "t2", pid: 2, cwd: "/tmp/b" })
|
|
39
|
+
await registry.unregister("t1")
|
|
40
|
+
|
|
41
|
+
const raw = JSON.parse(await readFile(registryPath, "utf8")) as {
|
|
42
|
+
entries: Array<{ terminalId: string }>
|
|
43
|
+
}
|
|
44
|
+
expect(raw.entries).toHaveLength(1)
|
|
45
|
+
expect(raw.entries[0]?.terminalId).toBe("t2")
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test("reapStale kills live process groups and clears the file", async () => {
|
|
49
|
+
// Spawn a process that becomes its own pgroup leader (mirrors how
|
|
50
|
+
// PTY-allocated shells in TerminalManager have pid == pgid). The
|
|
51
|
+
// ready handshake ensures setsid() has run before we attempt to reap.
|
|
52
|
+
const child = Bun.spawn(
|
|
53
|
+
["python3", "-c", "import os, sys, time; os.setsid(); sys.stdout.write('ready\\n'); sys.stdout.flush(); time.sleep(60)"],
|
|
54
|
+
{ stdout: "pipe", stderr: "ignore" },
|
|
55
|
+
)
|
|
56
|
+
const reader = child.stdout.getReader()
|
|
57
|
+
const decoded = new TextDecoder().decode((await reader.read()).value ?? new Uint8Array())
|
|
58
|
+
expect(decoded).toContain("ready")
|
|
59
|
+
reader.releaseLock()
|
|
60
|
+
const childPid = child.pid
|
|
61
|
+
|
|
62
|
+
await writeFile(
|
|
63
|
+
registryPath,
|
|
64
|
+
JSON.stringify({
|
|
65
|
+
entries: [
|
|
66
|
+
{ terminalId: "t1", pid: childPid, cwd: "/tmp/a", createdAt: Date.now() },
|
|
67
|
+
{ terminalId: "t2", pid: 999_999_999, cwd: "/tmp/b", createdAt: Date.now() },
|
|
68
|
+
],
|
|
69
|
+
}),
|
|
70
|
+
"utf8",
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const registry = new TerminalPidRegistry(registryPath)
|
|
74
|
+
const reaped = await registry.reapStale()
|
|
75
|
+
|
|
76
|
+
expect(reaped.map((entry) => entry.terminalId).sort()).toEqual(["t1", "t2"])
|
|
77
|
+
|
|
78
|
+
// Wait for the kernel to reap the killed child.
|
|
79
|
+
const exitedWithTimeout = await Promise.race([
|
|
80
|
+
child.exited,
|
|
81
|
+
new Promise<"timeout">((resolve) => setTimeout(() => resolve("timeout"), 3_000)),
|
|
82
|
+
])
|
|
83
|
+
expect(exitedWithTimeout).not.toBe("timeout")
|
|
84
|
+
expect(child.signalCode).toBe("SIGKILL")
|
|
85
|
+
void childPid // pid retained for clarity; assertion is on the subprocess handle
|
|
86
|
+
|
|
87
|
+
const raw = JSON.parse(await readFile(registryPath, "utf8")) as { entries: unknown[] }
|
|
88
|
+
expect(raw.entries).toEqual([])
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
test("reapStale tolerates a missing registry file", async () => {
|
|
92
|
+
const registry = new TerminalPidRegistry(registryPath)
|
|
93
|
+
const reaped = await registry.reapStale()
|
|
94
|
+
expect(reaped).toEqual([])
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
test("reapStale tolerates a malformed registry file", async () => {
|
|
98
|
+
await writeFile(registryPath, "not json", "utf8")
|
|
99
|
+
const registry = new TerminalPidRegistry(registryPath)
|
|
100
|
+
const reaped = await registry.reapStale()
|
|
101
|
+
expect(reaped).toEqual([])
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test("register creates the parent directory if missing", async () => {
|
|
105
|
+
const nestedPath = path.join(tempDir, "nested", "deep", "terminals.json")
|
|
106
|
+
const registry = new TerminalPidRegistry(nestedPath)
|
|
107
|
+
await registry.register({ terminalId: "t1", pid: 1, cwd: "/tmp/a" })
|
|
108
|
+
const raw = JSON.parse(await readFile(nestedPath, "utf8")) as { entries: unknown[] }
|
|
109
|
+
expect(raw.entries).toHaveLength(1)
|
|
110
|
+
})
|
|
111
|
+
})
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
import process from "node:process"
|
|
4
|
+
|
|
5
|
+
export interface TerminalPidEntry {
|
|
6
|
+
terminalId: string
|
|
7
|
+
pid: number
|
|
8
|
+
cwd: string
|
|
9
|
+
createdAt: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface RegistryFile {
|
|
13
|
+
entries: TerminalPidEntry[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class TerminalPidRegistry {
|
|
17
|
+
private readonly filePath: string
|
|
18
|
+
private entries: TerminalPidEntry[] = []
|
|
19
|
+
private writeQueue: Promise<void> = Promise.resolve()
|
|
20
|
+
|
|
21
|
+
constructor(filePath: string) {
|
|
22
|
+
this.filePath = filePath
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async register(entry: Omit<TerminalPidEntry, "createdAt">): Promise<void> {
|
|
26
|
+
await this.loadIfNeeded()
|
|
27
|
+
const next = this.entries.filter((existing) => existing.terminalId !== entry.terminalId)
|
|
28
|
+
next.push({ ...entry, createdAt: Date.now() })
|
|
29
|
+
this.entries = next
|
|
30
|
+
await this.persist()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async unregister(terminalId: string): Promise<void> {
|
|
34
|
+
await this.loadIfNeeded()
|
|
35
|
+
this.entries = this.entries.filter((entry) => entry.terminalId !== terminalId)
|
|
36
|
+
await this.persist()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async reapStale(): Promise<TerminalPidEntry[]> {
|
|
40
|
+
const stored = await this.readFromDisk()
|
|
41
|
+
if (stored.length === 0) {
|
|
42
|
+
this.entries = []
|
|
43
|
+
return []
|
|
44
|
+
}
|
|
45
|
+
for (const entry of stored) {
|
|
46
|
+
killPgroup(entry.pid)
|
|
47
|
+
}
|
|
48
|
+
this.entries = []
|
|
49
|
+
await this.persist()
|
|
50
|
+
return stored
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private async loadIfNeeded() {
|
|
54
|
+
if (this.entries.length > 0) return
|
|
55
|
+
this.entries = await this.readFromDisk()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private async readFromDisk(): Promise<TerminalPidEntry[]> {
|
|
59
|
+
let raw: string
|
|
60
|
+
try {
|
|
61
|
+
raw = await readFile(this.filePath, "utf8")
|
|
62
|
+
} catch {
|
|
63
|
+
return []
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const parsed = JSON.parse(raw) as Partial<RegistryFile>
|
|
67
|
+
if (!parsed || !Array.isArray(parsed.entries)) return []
|
|
68
|
+
return parsed.entries.filter(isValidEntry)
|
|
69
|
+
} catch {
|
|
70
|
+
return []
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private async persist() {
|
|
75
|
+
const snapshot: RegistryFile = { entries: [...this.entries] }
|
|
76
|
+
const serialized = JSON.stringify(snapshot)
|
|
77
|
+
this.writeQueue = this.writeQueue
|
|
78
|
+
.catch(() => undefined)
|
|
79
|
+
.then(async () => {
|
|
80
|
+
await mkdir(path.dirname(this.filePath), { recursive: true })
|
|
81
|
+
await writeFile(this.filePath, serialized, "utf8")
|
|
82
|
+
})
|
|
83
|
+
await this.writeQueue
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isValidEntry(value: unknown): value is TerminalPidEntry {
|
|
88
|
+
if (!value || typeof value !== "object") return false
|
|
89
|
+
const candidate = value as Partial<TerminalPidEntry>
|
|
90
|
+
return (
|
|
91
|
+
typeof candidate.terminalId === "string"
|
|
92
|
+
&& typeof candidate.pid === "number"
|
|
93
|
+
&& Number.isFinite(candidate.pid)
|
|
94
|
+
&& typeof candidate.cwd === "string"
|
|
95
|
+
&& typeof candidate.createdAt === "number"
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function killPgroup(pid: number) {
|
|
100
|
+
if (process.platform === "win32") return
|
|
101
|
+
if (!Number.isFinite(pid) || pid <= 0) return
|
|
102
|
+
try {
|
|
103
|
+
process.kill(-pid, "SIGKILL")
|
|
104
|
+
} catch {
|
|
105
|
+
// ESRCH (already gone) and EPERM (race with kernel reap) are fine.
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -750,6 +750,68 @@ describe("ws-router", () => {
|
|
|
750
750
|
}
|
|
751
751
|
})
|
|
752
752
|
|
|
753
|
+
test("project.remove kills terminals running in the project's cwd", async () => {
|
|
754
|
+
const state = createEmptyState()
|
|
755
|
+
const projectPath = await mkdtemp(path.join(tmpdir(), "kanna-router-project-"))
|
|
756
|
+
const closeByCwdCalls: string[] = []
|
|
757
|
+
|
|
758
|
+
try {
|
|
759
|
+
const router = createWsRouter({
|
|
760
|
+
store: {
|
|
761
|
+
state,
|
|
762
|
+
getProject: () => ({
|
|
763
|
+
id: "project-1",
|
|
764
|
+
localPath: projectPath,
|
|
765
|
+
}),
|
|
766
|
+
listChatsByProject: () => [],
|
|
767
|
+
removeProject: async () => {},
|
|
768
|
+
} as never,
|
|
769
|
+
agent: {
|
|
770
|
+
cancel: async () => {},
|
|
771
|
+
closeChat: async () => {},
|
|
772
|
+
getActiveStatuses: () => new Map(),
|
|
773
|
+
getDrainingChatIds: () => new Set(),
|
|
774
|
+
getWaitStartedAtByChatId: () => new Map(),
|
|
775
|
+
} as never,
|
|
776
|
+
analytics: {
|
|
777
|
+
track: () => {},
|
|
778
|
+
trackLaunch: () => {},
|
|
779
|
+
},
|
|
780
|
+
terminals: {
|
|
781
|
+
closeByCwd: (cwd: string) => {
|
|
782
|
+
closeByCwdCalls.push(cwd)
|
|
783
|
+
},
|
|
784
|
+
getSnapshot: () => null,
|
|
785
|
+
onEvent: () => () => {},
|
|
786
|
+
} as never,
|
|
787
|
+
keybindings: {
|
|
788
|
+
getSnapshot: () => DEFAULT_KEYBINDINGS_SNAPSHOT,
|
|
789
|
+
onChange: () => () => {},
|
|
790
|
+
} as never,
|
|
791
|
+
refreshDiscovery: async () => [],
|
|
792
|
+
getDiscoveredProjects: () => [],
|
|
793
|
+
machineDisplayName: "Local Machine",
|
|
794
|
+
updateManager: null,
|
|
795
|
+
pushManager: NOOP_PUSH_MANAGER,
|
|
796
|
+
})
|
|
797
|
+
const ws = new FakeWebSocket()
|
|
798
|
+
|
|
799
|
+
await router.handleMessage(
|
|
800
|
+
ws as never,
|
|
801
|
+
JSON.stringify({
|
|
802
|
+
v: 1,
|
|
803
|
+
type: "command",
|
|
804
|
+
id: "project-remove-1",
|
|
805
|
+
command: { type: "project.remove", projectId: "project-1" },
|
|
806
|
+
})
|
|
807
|
+
)
|
|
808
|
+
|
|
809
|
+
expect(closeByCwdCalls).toEqual([projectPath])
|
|
810
|
+
} finally {
|
|
811
|
+
await rm(projectPath, { recursive: true, force: true })
|
|
812
|
+
}
|
|
813
|
+
})
|
|
814
|
+
|
|
753
815
|
test("acks terminal.input without rebroadcasting terminal snapshots", async () => {
|
|
754
816
|
const router = createWsRouter({
|
|
755
817
|
store: { state: createEmptyState() } as never,
|
package/src/server/ws-router.ts
CHANGED
|
@@ -1262,7 +1262,11 @@ export function createWsRouter({
|
|
|
1262
1262
|
break
|
|
1263
1263
|
}
|
|
1264
1264
|
case "project.remove": {
|
|
1265
|
+
const project = store.getProject(command.projectId)
|
|
1265
1266
|
await store.removeProject(command.projectId)
|
|
1267
|
+
if (project) {
|
|
1268
|
+
terminals.closeByCwd(project.localPath)
|
|
1269
|
+
}
|
|
1266
1270
|
send(ws, { v: PROTOCOL_VERSION, type: "ack", id })
|
|
1267
1271
|
resolvedAnalytics.track("project_removed")
|
|
1268
1272
|
break
|
package/src/shared/branding.ts
CHANGED
|
@@ -68,6 +68,10 @@ export function getLlmProviderFilePath(homeDir: string, env: RuntimeEnv = getRun
|
|
|
68
68
|
return `${getDataRootDir(homeDir, env)}/llm-provider.json`
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
export function getTerminalRegistryFilePath(homeDir: string, env: RuntimeEnv = getRuntimeEnv()) {
|
|
72
|
+
return `${getDataRootDir(homeDir, env)}/terminals.json`
|
|
73
|
+
}
|
|
74
|
+
|
|
71
75
|
export function getLlmProviderFilePathDisplay(env: RuntimeEnv = getRuntimeEnv()) {
|
|
72
76
|
return `${getDataRootDirDisplay(env)}/llm-provider.json`
|
|
73
77
|
}
|