shraga 0.1.137 → 0.1.138
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/defaults/skills/platform.md +2 -2
- package/dist/client/assets/{index-BeHb9WIo.js → index-C1weaEkP.js} +2 -2
- package/dist/client/index.html +1 -1
- package/package.json +2 -2
- package/src/client/components/ConfigPanel.tsx +2 -1
- package/src/server/engine/claude-code.ts +2 -1
- package/src/server/model-aliases.ts +2 -1
|
@@ -30,7 +30,7 @@ Users can prefix any message with `[directives]` to override settings. Parsed se
|
|
|
30
30
|
|
|
31
31
|
| Position | What | Examples |
|
|
32
32
|
|----------|------|----------|
|
|
33
|
-
| 1st | Model alias | `fable`, `opus`, `sonnet`, `haiku`, `fable-5-1`, `fable-5`, `opus-5`, `opus-4-8`, `opus-4-7` |
|
|
33
|
+
| 1st | Model alias | `fable`, `opus`, `sonnet`, `haiku`, `fable-5-1`, `fable-5`, `opus-5-5`, `opus-5`, `opus-4-8`, `opus-4-7` |
|
|
34
34
|
| 2nd | Max turns (integer) | `5`, `20`, `100` |
|
|
35
35
|
|
|
36
36
|
### Named directives
|
|
@@ -60,7 +60,7 @@ Persistent settings that apply to all messages until changed:
|
|
|
60
60
|
|
|
61
61
|
| Setting | Options | Default |
|
|
62
62
|
|---------|---------|---------|
|
|
63
|
-
| Model | Fable 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 4.6, Haiku 4.5 | Sonnet
|
|
63
|
+
| Model | Fable 5.1, Fable 5, Opus 5.5, Opus 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 5, Sonnet 4.6, Haiku 4.5 | Sonnet 5 |
|
|
64
64
|
| Permission Mode | Accept Edits, Plan, Bypass All | Accept Edits |
|
|
65
65
|
| Max Turns | 1–200 | 50 |
|
|
66
66
|
| Thinking | Adaptive, Enabled, Disabled | Off |
|
|
@@ -1904,7 +1904,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),bn=ve,At=je),rt===void
|
|
|
1904
1904
|
`)},LM=function(){var e=parseInt(document.body.getAttribute(Cu)||"0",10);return isFinite(e)?e:0},dre=function(){b.useEffect(function(){return document.body.setAttribute(Cu,(LM()+1).toString()),function(){var e=LM()-1;e<=0?document.body.removeAttribute(Cu):document.body.setAttribute(Cu,e.toString())}},[])},fre=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;dre();var a=b.useMemo(function(){return lre(i)},[i]);return b.createElement(cre,{styles:ure(a,!t,i,n?"":"!important")})},s1=!1;if(typeof window<"u")try{var Ap=Object.defineProperty({},"passive",{get:function(){return s1=!0,!0}});window.addEventListener("test",Ap,Ap),window.removeEventListener("test",Ap,Ap)}catch{s1=!1}var nu=s1?{passive:!1}:!1,hre=function(e){return e.tagName==="TEXTAREA"},fz=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!hre(e)&&n[t]==="visible")},mre=function(e){return fz(e,"overflowY")},pre=function(e){return fz(e,"overflowX")},zM=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=hz(e,r);if(i){var a=mz(e,r),s=a[1],l=a[2];if(s>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},gre=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},vre=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},hz=function(e,t){return e==="v"?mre(t):pre(t)},mz=function(e,t){return e==="v"?gre(t):vre(t)},yre=function(e,t){return e==="h"&&t==="rtl"?-1:1},bre=function(e,t,n,r,i){var a=yre(e,window.getComputedStyle(t).direction),s=a*r,l=n.target,u=t.contains(l),d=!1,h=s>0,m=0,p=0;do{if(!l)break;var g=mz(e,l),w=g[0],x=g[1],E=g[2],_=x-E-a*w;(w||_)&&hz(e,l)&&(m+=_,p+=w);var k=l.parentNode;l=k&&k.nodeType===Node.DOCUMENT_FRAGMENT_NODE?k.host:k}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(h&&Math.abs(m)<1||!h&&Math.abs(p)<1)&&(d=!0),d},kp=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},$M=function(e){return[e.deltaX,e.deltaY]},BM=function(e){return e&&"current"in e?e.current:e},xre=function(e,t){return e[0]===t[0]&&e[1]===t[1]},wre=function(e){return`
|
|
1905
1905
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
1906
1906
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
1907
|
-
`)},Ere=0,ru=[];function Sre(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),i=b.useState(Ere++)[0],a=b.useState(dz)[0],s=b.useRef(e);b.useEffect(function(){s.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var x=R7([e.lockRef.current],(e.shards||[]).map(BM),!0).filter(Boolean);return x.forEach(function(E){return E.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),x.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=b.useCallback(function(x,E){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!s.current.allowPinchZoom;var _=kp(x),k=n.current,O="deltaX"in x?x.deltaX:k[0]-_[0],N="deltaY"in x?x.deltaY:k[1]-_[1],T,C=x.target,M=Math.abs(O)>Math.abs(N)?"h":"v";if("touches"in x&&M==="h"&&C.type==="range")return!1;var D=window.getSelection(),j=D&&D.anchorNode,R=j?j===C||j.contains(C):!1;if(R)return!1;var H=zM(M,C);if(!H)return!0;if(H?T=M:(T=M==="v"?"h":"v",H=zM(M,C)),!H)return!1;if(!r.current&&"changedTouches"in x&&(O||N)&&(r.current=T),!T)return!0;var P=r.current||T;return bre(P,E,x,P==="h"?O:N)},[]),u=b.useCallback(function(x){var E=x;if(!(!ru.length||ru[ru.length-1]!==a)){var _="deltaY"in E?$M(E):kp(E),k=t.current.filter(function(T){return T.name===E.type&&(T.target===E.target||E.target===T.shadowParent)&&xre(T.delta,_)})[0];if(k&&k.should){E.cancelable&&E.preventDefault();return}if(!k){var O=(s.current.shards||[]).map(BM).filter(Boolean).filter(function(T){return T.contains(E.target)}),N=O.length>0?l(E,O[0]):!s.current.noIsolation;N&&E.cancelable&&E.preventDefault()}}},[]),d=b.useCallback(function(x,E,_,k){var O={name:x,delta:E,target:_,should:k,shadowParent:_re(_)};t.current.push(O),setTimeout(function(){t.current=t.current.filter(function(N){return N!==O})},1)},[]),h=b.useCallback(function(x){n.current=kp(x),r.current=void 0},[]),m=b.useCallback(function(x){d(x.type,$M(x),x.target,l(x,e.lockRef.current))},[]),p=b.useCallback(function(x){d(x.type,kp(x),x.target,l(x,e.lockRef.current))},[]);b.useEffect(function(){return ru.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:p}),document.addEventListener("wheel",u,nu),document.addEventListener("touchmove",u,nu),document.addEventListener("touchstart",h,nu),function(){ru=ru.filter(function(x){return x!==a}),document.removeEventListener("wheel",u,nu),document.removeEventListener("touchmove",u,nu),document.removeEventListener("touchstart",h,nu)}},[]);var g=e.removeScrollBar,w=e.inert;return b.createElement(b.Fragment,null,w?b.createElement(a,{styles:wre(i)}):null,g?b.createElement(fre,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function _re(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Are=Jne(uz,Sre);var vS=b.forwardRef(function(e,t){return b.createElement(Yv,xa({},e,{ref:t,sideCar:Are}))});vS.classNames=Yv.classNames;var kre=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},iu=new WeakMap,Op=new WeakMap,Np={},zx=0,pz=function(e){return e&&(e.host||pz(e.parentNode))},Ore=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=pz(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Nre=function(e,t,n,r){var i=Ore(t,Array.isArray(e)?e:[e]);Np[n]||(Np[n]=new WeakMap);var a=Np[n],s=[],l=new Set,u=new Set(i),d=function(m){!m||l.has(m)||(l.add(m),d(m.parentNode))};i.forEach(d);var h=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(p){if(l.has(p))h(p);else try{var g=p.getAttribute(r),w=g!==null&&g!=="false",x=(iu.get(p)||0)+1,E=(a.get(p)||0)+1;iu.set(p,x),a.set(p,E),s.push(p),x===1&&w&&Op.set(p,!0),E===1&&p.setAttribute(n,"true"),w||p.setAttribute(r,"true")}catch(_){console.error("aria-hidden: cannot operate on ",p,_)}})};return h(t),l.clear(),zx++,function(){s.forEach(function(m){var p=iu.get(m)-1,g=a.get(m)-1;iu.set(m,p),a.set(m,g),p||(Op.has(m)||m.removeAttribute(r),Op.delete(m)),g||m.removeAttribute(n)}),zx--,zx||(iu=new WeakMap,iu=new WeakMap,Op=new WeakMap,Np={})}},gz=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=kre(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),Nre(r,i,n,"aria-hidden")):function(){return null}},Xv="Dialog",[vz]=hL(Xv),[Cre,Ji]=vz(Xv),yz=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,l=b.useRef(null),u=b.useRef(null),[d,h]=_ne({prop:r,defaultProp:i??!1,onChange:a,caller:Xv});return y.jsx(Cre,{scope:t,triggerRef:l,contentRef:u,contentId:Ix(),titleId:Ix(),descriptionId:Ix(),open:d,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(m=>!m),[h]),modal:s,children:n})};yz.displayName=Xv;var bz="DialogTrigger",xz=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(bz,n),a=ui(t,i.triggerRef);return y.jsx(Fr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":ES(i.open),...r,ref:a,onClick:Sr(e.onClick,i.onOpenToggle)})});xz.displayName=bz;var yS="DialogPortal",[Tre,wz]=vz(yS,{forceMount:void 0}),Ez=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Ji(yS,t);return y.jsx(Tre,{scope:t,forceMount:n,children:b.Children.map(r,s=>y.jsx(Zs,{present:n||a.open,children:y.jsx(lz,{asChild:!0,container:i,children:s})}))})};Ez.displayName=yS;var Pg="DialogOverlay",bS=b.forwardRef((e,t)=>{const n=wz(Pg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ji(Pg,e.__scopeDialog);return a.modal?y.jsx(Zs,{present:r||a.open,children:y.jsx(Ire,{...i,ref:t})}):null});bS.displayName=Pg;var Mre=GE("DialogOverlay.RemoveScroll"),Ire=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(Pg,n),a=Ine(),s=ui(t,a);return y.jsx(vS,{as:Mre,allowPinchZoom:!0,shards:[i.contentRef],children:y.jsx(Fr.div,{"data-state":ES(i.open),...r,ref:s,style:{pointerEvents:"auto",...r.style}})})}),Uu="DialogContent",xS=b.forwardRef((e,t)=>{const n=wz(Uu,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ji(Uu,e.__scopeDialog);return y.jsx(Zs,{present:r||a.open,children:a.modal?y.jsx(Rre,{...i,ref:t}):y.jsx(Pre,{...i,ref:t})})});xS.displayName=Uu;var Rre=b.forwardRef((e,t)=>{const n=Ji(Uu,e.__scopeDialog),r=b.useRef(null),i=ui(t,n.contentRef,r);return b.useEffect(()=>{const a=r.current;if(a)return gz(a)},[]),y.jsx(Sz,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Sr(e.onCloseAutoFocus,a=>{var s;a.preventDefault(),(s=n.triggerRef.current)==null||s.focus()}),onPointerDownOutside:Sr(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0;(s.button===2||l)&&a.preventDefault()}),onFocusOutside:Sr(e.onFocusOutside,a=>a.preventDefault())})}),Pre=b.forwardRef((e,t)=>{const n=Ji(Uu,e.__scopeDialog),r=b.useRef(!1),i=b.useRef(!1);return y.jsx(Sz,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var s,l;(s=e.onCloseAutoFocus)==null||s.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:a=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(s))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),Sz=b.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...s}=e,l=Ji(Uu,n);return Kne(),y.jsx(y.Fragment,{children:y.jsx(oz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:y.jsx(iz,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":ES(l.open),...s,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),_z="DialogTitle",wS=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(_z,n);return y.jsx(Fr.h2,{id:i.titleId,...r,ref:t})});wS.displayName=_z;var Az="DialogDescription",Dre=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(Az,n);return y.jsx(Fr.p,{id:i.descriptionId,...r,ref:t})});Dre.displayName=Az;var kz="DialogClose",Oz=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(kz,n);return y.jsx(Fr.button,{type:"button",...r,ref:t,onClick:Sr(e.onClick,()=>i.onOpenChange(!1))})});Oz.displayName=kz;function ES(e){return e?"open":"closed"}const Oo=yz,rd=xz,jre=Ez,Nz=b.forwardRef(({className:e,...t},n)=>y.jsx(bS,{ref:n,className:ze("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Nz.displayName=bS.displayName;const Na=b.forwardRef(({className:e,children:t,...n},r)=>y.jsxs(jre,{children:[y.jsx(Nz,{}),y.jsxs(xS,{ref:r,className:ze("fixed left-[50%] top-[50%] z-50 flex flex-col w-[calc(100vw-2rem)] max-w-lg max-h-[85dvh] overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-4 sm:p-6 shadow-lg 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 sm:rounded-lg",e),...n,children:[t,y.jsxs(Oz,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[y.jsx(Bs,{className:"h-4 w-4"}),y.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Na.displayName=xS.displayName;function Us({className:e,...t}){return y.jsx("div",{className:ze("shrink-0 flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Cz({className:e,...t}){return y.jsx("div",{"data-dialog-body":!0,className:ze("flex-1 min-h-0 overflow-y-auto -mx-4 px-4 sm:-mx-6 sm:px-6",e),...t})}function Tz({className:e,...t}){return y.jsx("div",{className:ze("shrink-0 -mx-4 px-4 pt-3 border-t sm:-mx-6 sm:px-6","flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t})}const No=b.forwardRef(({className:e,...t},n)=>y.jsx(wS,{ref:n,className:ze("text-lg font-semibold leading-none tracking-tight",e),...t}));No.displayName=wS.displayName;const Lre=new Set(["png","jpg","jpeg","gif","webp","svg","ico","bmp","avif"]),zre=new Set(["pdf","mp4","webm","mp3","ogg","wav"]);async function $re(e,t){const n=await t();if(!n)return[];const r=await fetch(`/api/workspace/ls?path=${encodeURIComponent(e)}`,{headers:{Authorization:`Bearer ${n}`}});return r.ok?(await r.json()).entries??[]:[]}function Bre({getToken:e,onRefresh:t,refreshKey:n}){const[r,i]=b.useState(new Map),[a,s]=b.useState(()=>new Set),[l,u]=b.useState(null),[d,h]=b.useState(!1),[m,p]=b.useState("fit"),[g,w]=b.useState(null),[x,E]=b.useState(null),_=b.useRef(null),[k,O]=b.useState(null),[N,T]=b.useState(!1),[C,M]=b.useState([]),D=b.useCallback(async U=>{const K=await $re(U,e);i(F=>new Map(F).set(U,K))},[e]);b.useEffect(()=>{D(""),a.forEach(U=>D(U))},[D,n]);const j=r.get("")??[],R=b.useCallback(U=>{try{const K=U.contentDocument;if(!(K!=null&&K.body))return;const F=Math.max(K.body.offsetWidth,K.body.scrollWidth),V=Math.max(K.body.offsetHeight,K.body.scrollHeight);F&&V&&E({w:F,h:V})}catch{}},[]),H=b.useCallback(()=>{const U=_.current,K=x;if(!U||!K)return;const F=16,V=U.clientWidth-F,$=U.clientHeight-F,L=Math.min(V/K.w,$/K.h,1);w({scale:L,w:K.w,h:K.h})},[x]);b.useEffect(()=>{if(!(l!=null&&l.html)||m!=="fit"){w(null);return}const U=_.current;if(!U)return;const K=new ResizeObserver(()=>requestAnimationFrame(H));return K.observe(U),()=>K.disconnect()},[l==null?void 0:l.html,d,m,H]),b.useEffect(()=>{N&&e().then(U=>{U&&fetch("/api/data-sync/log",{headers:{Authorization:`Bearer ${U}`}}).then(K=>K.json()).then(M).catch(()=>{})})},[N]);const P=U=>{s(K=>{const F=new Set(K);return F.has(U)?F.delete(U):(F.add(U),r.has(U)||D(U)),F})},G=(U,K)=>{const F=new URLSearchParams({path:U});return k&&F.set("token",k),K&&F.set("dl","1"),`/api/workspace/raw?${F}`},q=async U=>{var V;const K=await e();if(!K)return;O(K);const F=((V=U.split(".").pop())==null?void 0:V.toLowerCase())??"";if(F==="html"||F==="htm"){u({path:U,content:"",binary:!1,html:!0});return}if(Lre.has(F)){u({path:U,content:"",binary:!1,image:!0});return}if(zre.has(F)){u({path:U,content:"",binary:!1,html:!0});return}try{const $=await fetch(`/api/workspace/file?path=${encodeURIComponent(U)}`,{headers:{Authorization:`Bearer ${K}`}});if(!$.ok)return;const L=await $.json();u({path:U,content:L.content,binary:!!L.binary})}catch{}},X=(U,K)=>y.jsx(y.Fragment,{children:U.map(F=>{const V=F.path.split("/").pop();return y.jsxs("div",{children:[F.type==="dir"?y.jsxs("button",{onClick:()=>P(F.path),className:"w-full flex items-center gap-1 px-2 py-1 rounded hover:bg-accent/50 text-left text-sm",style:{paddingLeft:8+K*12},children:[y.jsx(Xs,{className:ze("w-3 h-3 shrink-0 transition-transform",a.has(F.path)&&"rotate-90")}),y.jsx(JG,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),y.jsx("span",{className:"truncate",children:V})]}):y.jsxs("button",{onClick:()=>q(F.path),className:"w-full flex items-center gap-1 px-2 py-1 rounded hover:bg-accent/50 text-left text-sm",style:{paddingLeft:8+K*12+12},title:F.oneLiner||F.path,children:[y.jsx(UE,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),y.jsx("span",{className:"truncate",children:V})]}),F.type==="dir"&&a.has(F.path)&&X(r.get(F.path)??[],K+1)]},F.path)})});return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1 shrink-0",children:[y.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Workspace"}),y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx("button",{onClick:()=>T(!0),className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Activity log",children:y.jsx(tV,{className:"w-3 h-3"})}),y.jsx("button",{onClick:()=>{D(""),a.forEach(U=>D(U)),t==null||t()},className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Refresh",children:y.jsx(ed,{className:"w-3 h-3"})})]})]}),y.jsx("div",{className:"px-1 pb-2 overflow-y-auto min-h-0",children:j.length===0?y.jsx("p",{className:"text-xs text-muted-foreground px-3 py-2",children:"Empty. Drop .md files into data/workspace/ or ask the agent to create some."}):X(j,0)}),y.jsx(Oo,{open:!!l,onOpenChange:U=>{U||(u(null),h(!1),p("fit"),E(null))},children:y.jsxs(Na,{className:ze(l!=null&&l.html?ze("!flex !flex-col !p-0 !gap-0 overflow-hidden",d?"max-w-none w-[100vw] h-[100vh] rounded-none border-0":"max-w-[90vw] w-[90vw] h-[85vh]"):"max-w-3xl max-h-[80vh] !flex !flex-col overflow-hidden"),children:[y.jsxs("div",{className:"absolute right-12 top-4 flex items-center gap-1.5 z-10",children:[(l==null?void 0:l.html)&&y.jsxs(y.Fragment,{children:[y.jsx("button",{onClick:()=>p(U=>U==="fit"?"scroll":"fit"),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:m==="fit"?"Switch to scrollable (1:1)":"Switch to scale-to-fit",children:m==="fit"?y.jsx(oV,{className:"w-4 h-4"}):y.jsx(fV,{className:"w-4 h-4"})}),y.jsx("button",{onClick:()=>h(U=>!U),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:d?"Restore":"Maximize",children:d?y.jsx(HE,{className:"w-4 h-4"}):y.jsx(FE,{className:"w-4 h-4"})})]}),l&&y.jsx("a",{href:G(l.path,!0),download:!0,className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:"Download",children:y.jsx(lL,{className:"w-4 h-4"})})]}),y.jsx(Us,{className:ze((l==null?void 0:l.html)&&"px-4 py-3 shrink-0 border-b"),children:y.jsx(No,{className:"font-mono text-sm truncate pr-16",children:l==null?void 0:l.path})}),y.jsx("div",{ref:l!=null&&l.html?_:void 0,className:ze(l!=null&&l.html?ze("flex-1 min-h-0 bg-muted/10",m==="fit"?"overflow-hidden flex items-center justify-center":"overflow-auto"):"flex-1 min-h-0 overflow-y-auto"),children:l!=null&&l.html?m==="fit"?y.jsx("div",{style:g?{width:g.w*g.scale,height:g.h*g.scale}:{width:"100%",height:"100%"},children:y.jsx("iframe",{src:G(l.path),className:"border-0 bg-white origin-top-left",title:l.path,onLoad:U=>{R(U.currentTarget),H()},style:g?{width:g.w,height:g.h,transform:`scale(${g.scale})`}:{width:"100%",height:"100%"}})}):y.jsx("iframe",{src:G(l.path),className:"border-0 bg-white mx-auto block",title:l.path,onLoad:U=>R(U.currentTarget),style:{width:(x==null?void 0:x.w)||"100%",height:(x==null?void 0:x.h)||"100%"}}):l!=null&&l.image?y.jsx("div",{className:"flex items-center justify-center p-4",children:y.jsx("img",{src:G(l.path),alt:l.path,className:"max-w-full max-h-[70vh] object-contain"})}):l!=null&&l.binary?y.jsx("p",{className:"text-sm text-muted-foreground",children:"(binary file — preview unavailable)"}):l!=null&&l.path.toLowerCase().endsWith(".md")||l!=null&&l.path.toLowerCase().endsWith(".markdown")?y.jsx("div",{className:"text-sm",children:y.jsx(d3,{remarkPlugins:[D3],rehypePlugins:[rz],className:"prose prose-sm max-w-none dark:prose-invert prose-pre:bg-muted prose-pre:border prose-code:before:content-none prose-code:after:content-none",children:l.content})}):y.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l==null?void 0:l.content})})]})}),y.jsx(Oo,{open:N,onOpenChange:T,children:y.jsxs(Na,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[y.jsx(Us,{children:y.jsx(No,{className:"text-sm",children:"Activity Log"})}),y.jsxs("div",{className:"overflow-y-auto flex-1 space-y-2",children:[C.map(U=>y.jsxs("div",{className:"border-b border-border/50 pb-2 last:border-0",children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[y.jsx("span",{className:"text-sm text-foreground",children:U.message}),y.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Ure(U.date)})]}),U.files.length>0&&y.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:U.files.map(K=>y.jsx("span",{className:"inline-block mr-2 font-mono",children:K},K))})]},U.hash)),C.length===0&&y.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No activity yet"})]})]})})]})}function Ure(e){const t=new Date(e),r=new Date().getTime()-t.getTime(),i=Math.floor(r/6e4);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ag(e,t=Date.now()){if(!e)return null;const n=new Date(e).getTime()-t;if(!Number.isFinite(n)||n<=0)return null;const r=Math.round(n/6e4);if(r<1)return"1m";if(r<60)return`${r}m`;const i=Math.floor(r/60),a=r%60;if(i<48)return a?`${i}h ${a}m`:`${i}h`;const s=Math.floor(i/24),l=i%24;return l?`${s}d ${l}h`:`${s}d`}const Fre=/resets\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\s*\(UTC\)/i;function Hre(e,t=Date.now(),n=Date.now()){var m;const r=e.match(Fre);if(!r)return e;let i=Number(r[1]);const a=r[2]?Number(r[2]):0,s=(m=r[3])==null?void 0:m.toLowerCase();if(s==="pm"&&i<12&&(i+=12),s==="am"&&i===12&&(i=0),i>23||a>59)return e;const l=new Date(t),u=new Date(Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate(),i,a));u.getTime()<=t&&u.setUTCDate(u.getUTCDate()+1);const d=u.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=ag(u.toISOString(),n);return e.replace(r[0],`resets ${d}${h?` (in ${h})`:""}`)}var Kre=Object.defineProperty,id=(e,t)=>Kre(e,"name",{value:t,configurable:!0}),Mz=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ds(e,t,{checkForDefaultPrevented:n=!0}={}){return id(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}id(Ds,"composeEventHandlers");function qre(e){var t;if(!Mz)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}id(qre,"getOwnerWindow");function l1(e){if(!Mz)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}id(l1,"getOwnerDocument");function Iz(e,t=!1){const{activeElement:n}=l1(e);if(!(n!=null&&n.nodeName))return null;if(Rz(n)&&n.contentDocument)return Iz(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=l1(n).getElementById(r);if(i)return i}}return n}id(Iz,"getActiveElement");function Rz(e){return e.tagName==="IFRAME"}id(Rz,"isFrame");var Gre=Object.defineProperty,SS=(e,t)=>Gre(e,"name",{value:t,configurable:!0});function c1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}SS(c1,"setRef");function Pz(...e){return t=>{let n=!1;const r=e.map(i=>{const a=c1(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():c1(e[i],null)}}}}SS(Pz,"composeRefs");function ad(...e){return b.useCallback(Pz(...e),e)}SS(ad,"useComposedRefs");var Vre=Object.defineProperty,Ni=(e,t)=>Vre(e,"name",{value:t,configurable:!0});function Wre(e,t){const n=b.createContext(t);n.displayName=e+"Context";const r=Ni(a=>{const{children:s,...l}=a,u=b.useMemo(()=>l,Object.values(l));return y.jsx(n.Provider,{value:u,children:s})},"Provider");r.displayName=e+"Provider";function i(a,s={}){const{optional:l=!1}=s,u=b.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return Ni(i,"useContext"),[r,i]}Ni(Wre,"createContext");function Dz(e,t=[]){let n=[];function r(a,s){const l=b.createContext(s);l.displayName=a+"Context";const u=n.length;n=[...n,s];const d=Ni(m=>{var _;const{scope:p,children:g,...w}=m,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useMemo(()=>w,Object.values(w));return y.jsx(x.Provider,{value:E,children:g})},"Provider");d.displayName=a+"Provider";function h(m,p,g={}){var _;const{optional:w=!1}=g,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useContext(x);if(E)return E;if(s!==void 0)return s;if(!w)throw new Error(`\`${m}\` must be used within \`${a}\``)}return Ni(h,"useContext"),[d,h]}Ni(r,"createContext");const i=Ni(()=>{const a=n.map(s=>b.createContext(s));return Ni(function(l){const u=(l==null?void 0:l[e])||a;return b.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,jz(i,...t)]}Ni(Dz,"createContextScope");function jz(...e){const t=e[0];if(e.length===1)return t;const n=Ni(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Ni(function(a){const s=r.reduce((l,{useScope:u,scopeName:d})=>{const m=u(a)[`__scope${d}`];return{...l,...m}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Ni(jz,"composeContextScopes");var Yre=Object.defineProperty,ea=(e,t)=>Yre(e,"name",{value:t,configurable:!0});function _S(e){const t=b.forwardRef((n,r)=>{let{children:i,...a}=n,s=null,l=!1;const u=[];u1(i)&&typeof Cp=="function"&&(i=Cp(i._payload)),b.Children.forEach(i,p=>{var g;if(Bz(p)){l=!0;const w=p;let x="child"in w.props?w.props.child:w.props.children;u1(x)&&typeof Cp=="function"&&(x=Cp(x._payload)),s=Zre(w,x),u.push((g=s==null?void 0:s.props)==null?void 0:g.children)}else u.push(p)}),s?s=b.cloneElement(s,void 0,u):!l&&b.Children.count(i)===1&&b.isValidElement(i)&&(s=i);const d=s?$z(s):void 0,h=ad(r,d);if(!s){if(i||i===0)throw new Error(l?eie(e):Jre(e));return i}const m=zz(a,s.props??{});return s.type!==b.Fragment&&(m.ref=r?h:d),b.cloneElement(s,m)});return t.displayName=`${e}.Slot`,t}ea(_S,"createSlot");var Lz=Symbol.for("radix.slottable");function Xre(e){const t=ea(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=Lz,t}ea(Xre,"createSlottable");var Zre=ea((e,t)=>{if("child"in e.props){const n=e.props.child;return b.isValidElement(n)?b.cloneElement(n,void 0,e.props.children(n.props.children)):null}return b.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function zz(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...l)=>{const u=a(...l);return i(...l),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}ea(zz,"mergeProps");function $z(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ea($z,"getElementRef");function Bz(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Lz}ea(Bz,"isSlottable");var Qre=Symbol.for("react.lazy");function u1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Qre&&"_payload"in e&&Uz(e._payload)}ea(u1,"isLazyComponent");function Uz(e){return typeof e=="object"&&e!==null&&"then"in e}ea(Uz,"isPromiseLike");var Jre=ea(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),eie=ea(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Cp=ja[" use ".trim().toString()],tie=Object.defineProperty,nie=(e,t)=>tie(e,"name",{value:t,configurable:!0}),rie=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Zv=rie.reduce((e,t)=>{const n=_S(`Primitive.${t}`),r=b.forwardRef((i,a)=>{const{asChild:s,...l}=i,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fz(e,t){e&&La.flushSync(()=>e.dispatchEvent(t))}nie(Fz,"dispatchDiscreteCustomEvent");var iie=Object.defineProperty,aie=(e,t)=>iie(e,"name",{value:t,configurable:!0});function Qv(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}aie(Qv,"useCallbackRef");var oie=Object.defineProperty,qn=(e,t)=>oie(e,"name",{value:t,configurable:!0}),d1="dismissableLayer.update",sie="dismissableLayer.pointerDownOutside",lie="dismissableLayer.focusOutside",UM,Hz=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),cie=b.forwardRef(qn(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:l,onInteractOutside:u,onDismiss:d,...h}=t,m=b.useContext(Hz),[p,g]=b.useState(null),w=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=b.useState({}),E=ad(n,g),_=Array.from(m.layers),[k]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),O=k?_.indexOf(k):-1,N=p?_.indexOf(p):-1,T=m.layersWithOutsidePointerEventsDisabled.size>0,C=N>=O,M=b.useRef(!1),D=Kz(P=>{s==null||s(P),u==null||u(P),P.defaultPrevented||d==null||d()},{ownerDocument:w,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:M,dismissableSurfaces:m.dismissableSurfaces,shouldHandlePointerDownOutside:b.useCallback(P=>{if(!(P instanceof Node))return!1;const G=[...m.branches].some(q=>q.contains(P));return C&&!G},[m.branches,C])}),j=qz(P=>{if(i&&M.current)return;const G=P.target;[...m.branches].some(X=>X.contains(G))||(l==null||l(P),u==null||u(P),P.defaultPrevented||d==null||d())},w),R=p?N===_.length-1:!1,H=Qv(P=>{P.key==="Escape"&&(a==null||a(P),!P.defaultPrevented&&d&&(P.preventDefault(),d()))});return b.useEffect(()=>{if(R)return w.addEventListener("keydown",H,{capture:!0}),()=>w.removeEventListener("keydown",H,{capture:!0})},[w,R,H]),b.useEffect(()=>{if(p)return r&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(UM=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(p)),m.layers.add(p),f1(),()=>{r&&(m.layersWithOutsidePointerEventsDisabled.delete(p),m.layersWithOutsidePointerEventsDisabled.size===0&&(w.body.style.pointerEvents=UM))}},[p,w,r,m]),b.useEffect(()=>()=>{p&&(m.layers.delete(p),m.layersWithOutsidePointerEventsDisabled.delete(p),f1())},[p,m]),b.useEffect(()=>{const P=qn(()=>x({}),"handleUpdate");return document.addEventListener(d1,P),()=>document.removeEventListener(d1,P)},[]),y.jsx(Zv.div,{...h,ref:E,style:{pointerEvents:T?C?"auto":"none":void 0,...t.style},onFocusCapture:Ds(t.onFocusCapture,j.onFocusCapture),onBlurCapture:Ds(t.onBlurCapture,j.onBlurCapture),onPointerDownCapture:Ds(t.onPointerDownCapture,D.onPointerDownCapture)})},"DismissableLayer"));function uie(){const e=b.useContext(Hz),[t,n]=b.useState(null);return b.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}qn(uie,"useDismissableLayerSurface");var die=qn(()=>!0,"IS_TRUE");function Kz(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:s=die}=t,l=Qv(e),u=b.useRef(!1),d=b.useRef(!1),h=b.useRef(new Map),m=b.useRef(()=>{});return b.useEffect(()=>{function p(){d.current=!1,i.current=!1,h.current.clear()}qn(p,"resetOutsideInteraction");function g(){return Array.from(h.current.values()).some(Boolean)}qn(g,"isOutsideInteractionIntercepted");function w(O){if(!d.current)return;const N=O.target;N instanceof Node&&[...a].some(C=>C.contains(N))||h.current.set(O.type,!0),O.type==="click"&&window.setTimeout(()=>{d.current&&m.current()},0)}qn(w,"handleInteractionCapture");function x(O){d.current&&h.current.set(O.type,!1)}qn(x,"handleInteractionBubble");const E=qn(O=>{if(O.target&&!u.current){let N=function(){n.removeEventListener("click",m.current);const C=g();p(),C||AS(sie,l,T,{discrete:!0})};if(qn(N,"handleAndDispatchPointerDownOutsideEvent"),!s(O.target)){n.removeEventListener("click",m.current),p(),u.current=!1;return}const T={originalEvent:O};d.current=!0,i.current=r&&O.button===0,h.current.clear(),!r||O.button!==0?N():(n.removeEventListener("click",m.current),m.current=N,n.addEventListener("click",m.current,{once:!0}))}else n.removeEventListener("click",m.current),p();u.current=!1},"handlePointerDown"),_=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const O of _)n.addEventListener(O,w,!0),n.addEventListener(O,x);const k=window.setTimeout(()=>{n.addEventListener("pointerdown",E)},0);return()=>{window.clearTimeout(k),n.removeEventListener("pointerdown",E),n.removeEventListener("click",m.current);for(const O of _)n.removeEventListener(O,w,!0),n.removeEventListener(O,x)}},[n,l,r,i,a,s]),{onPointerDownCapture:qn(()=>u.current=!0,"onPointerDownCapture")}}qn(Kz,"usePointerDownOutside");function qz(e,t=globalThis==null?void 0:globalThis.document){const n=Qv(e),r=b.useRef(!1);return b.useEffect(()=>{const i=qn(a=>{a.target&&!r.current&&AS(lie,n,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:qn(()=>r.current=!0,"onFocusCapture"),onBlurCapture:qn(()=>r.current=!1,"onBlurCapture")}}qn(qz,"useFocusOutside");function f1(){const e=new CustomEvent(d1);document.dispatchEvent(e)}qn(f1,"dispatchUpdate");function AS(e,t,n,{discrete:r}){const i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Fz(i,a):i.dispatchEvent(a)}qn(AS,"handleAndDispatchCustomEvent");var fie=Object.defineProperty,kS=(e,t)=>fie(e,"name",{value:t,configurable:!0}),Tp=0,da=null;function hie(e){return OS(),e.children}kS(hie,"FocusGuards");function OS(){b.useEffect(()=>{da||(da={start:h1(),end:h1()});const{start:e,end:t}=da;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Tp++,()=>{Tp===1&&(da==null||da.start.remove(),da==null||da.end.remove(),da=null),Tp=Math.max(0,Tp-1)}},[])}kS(OS,"useFocusGuards");function h1(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}kS(h1,"createFocusGuard");var mie=Object.defineProperty,pie=(e,t)=>mie(e,"name",{value:t,configurable:!0});function m1(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}pie(m1,"useCallbackRef");var gie=Object.defineProperty,xr=(e,t)=>gie(e,"name",{value:t,configurable:!0}),$x="focusScope.autoFocusOnMount",Bx="focusScope.autoFocusOnUnmount",FM={bubbles:!1,cancelable:!0},vie=b.forwardRef(xr(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:s,...l}=t,[u,d]=b.useState(null),h=m1(a),m=m1(s),p=b.useRef(null),g=ad(n,d),w=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(i){let E=function(N){if(w.paused||!u)return;const T=N.target;u.contains(T)?p.current=T:uo(p.current,{select:!0})},_=function(N){if(w.paused||!u)return;const T=N.relatedTarget;T!==null&&(u.contains(T)||uo(p.current,{select:!0}))},k=function(N){if(document.activeElement===document.body)for(const C of N)C.removedNodes.length>0&&uo(u)};xr(E,"handleFocusIn"),xr(_,"handleFocusOut"),xr(k,"handleMutations"),document.addEventListener("focusin",E),document.addEventListener("focusout",_);const O=new MutationObserver(k);return u&&O.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",_),O.disconnect()}}},[i,u,w.paused]),b.useEffect(()=>{if(u){HM.add(w);const E=document.activeElement;if(!u.contains(E)){const k=new CustomEvent($x,FM);u.addEventListener($x,h),u.dispatchEvent(k),k.defaultPrevented||(Gz(Zz(NS(u)),{select:!0}),document.activeElement===E&&uo(u))}return()=>{u.removeEventListener($x,h),setTimeout(()=>{const k=new CustomEvent(Bx,FM);u.addEventListener(Bx,m),u.dispatchEvent(k),k.defaultPrevented||uo(E??document.body,{select:!0}),u.removeEventListener(Bx,m),HM.remove(w)},0)}}},[u,h,m,w]);const x=b.useCallback(E=>{if(!r&&!i||w.paused)return;const _=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,k=document.activeElement;if(_&&k){const O=E.currentTarget,[N,T]=Vz(O);N&&T?!E.shiftKey&&k===T?(E.preventDefault(),r&&uo(N,{select:!0})):E.shiftKey&&k===N&&(E.preventDefault(),r&&uo(T,{select:!0})):k===O&&E.preventDefault()}},[r,i,w.paused]);return y.jsx(Zv.div,{tabIndex:-1,...l,ref:g,onKeyDown:x})},"FocusScope"));function Gz(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(uo(r,{select:t}),document.activeElement!==n)return}xr(Gz,"focusFirst");function Vz(e){const t=NS(e),n=p1(t,e),r=p1(t.reverse(),e);return[n,r]}xr(Vz,"getTabbableEdges");function NS(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:xr(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}xr(NS,"getTabbableCandidates");function p1(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Wz(r,{upTo:t})))return r}xr(p1,"findVisible");function Wz(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}xr(Wz,"isHidden");function Yz(e){return e instanceof HTMLInputElement&&"select"in e}xr(Yz,"isSelectableInput");function uo(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Yz(e)&&t&&e.select()}}xr(uo,"focus");var HM=Xz();function Xz(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=g1(e,t),e.unshift(t)},remove(t){var n;e=g1(e,t),(n=e[0])==null||n.resume()}}}xr(Xz,"createFocusScopesStack");function g1(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}xr(g1,"arrayRemove");function Zz(e){return e.filter(t=>t.tagName!=="A")}xr(Zz,"removeLinks");var yie=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},bie=Object.defineProperty,xie=(e,t)=>bie(e,"name",{value:t,configurable:!0}),wie=ja[" useId ".trim().toString()]||(()=>{}),Eie=0;function Qz(e){const[t,n]=b.useState(wie());return yie(()=>{e||n(r=>r??String(Eie++))},[e]),e||(t?`radix-${t}`:"")}xie(Qz,"useId");const Sie=["top","right","bottom","left"],Fs=Math.min,xo=Math.max,Dg=Math.round,Mp=Math.floor,wo=e=>({x:e,y:e}),_ie={left:"right",right:"left",bottom:"top",top:"bottom"};function Jz(e,t,n){return xo(e,Fs(t,n))}function Co(e,t){return typeof e=="function"?e(t):e}function Hs(e){return e.split("-")[0]}function od(e){return e.split("-")[1]}function CS(e){return e==="x"?"y":"x"}function TS(e){return e==="y"?"height":"width"}function wa(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function MS(e){return CS(wa(e))}function Aie(e,t,n){n===void 0&&(n=!1);const r=od(e),i=MS(e),a=TS(i);let s=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(s=jg(s)),[s,jg(s)]}function kie(e){const t=jg(e);return[v1(e),t,v1(t)]}function v1(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const KM=["left","right"],qM=["right","left"],Oie=["top","bottom"],Nie=["bottom","top"];function Cie(e,t,n){switch(e){case"top":case"bottom":return n?t?qM:KM:t?KM:qM;case"left":case"right":return t?Oie:Nie;default:return[]}}function Tie(e,t,n,r){const i=od(e);let a=Cie(Hs(e),n==="start",r);return i&&(a=a.map(s=>s+"-"+i),t&&(a=a.concat(a.map(v1)))),a}function jg(e){const t=Hs(e);return _ie[t]+e.slice(t.length)}function Mie(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function e$(e){return typeof e!="number"?Mie(e):{top:e,right:e,bottom:e,left:e}}function Lg(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 GM(e,t,n){let{reference:r,floating:i}=e;const a=wa(t),s=MS(t),l=TS(s),u=Hs(t),d=a==="y",h=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,p=r[l]/2-i[l]/2;let g;switch(u){case"top":g={x:h,y:r.y-i.height};break;case"bottom":g={x:h,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:m};break;case"left":g={x:r.x-i.width,y:m};break;default:g={x:r.x,y:r.y}}const w=od(t);return w&&(g[s]+=p*(w==="end"?1:-1)*(n&&d?-1:1)),g}async function Iie(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:a,rects:s,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:m="floating",altBoundary:p=!1,padding:g=0}=Co(t,e),w=e$(g),E=l[p?m==="floating"?"reference":"floating":m],_=Lg(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(E)))==null||n?E:E.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:u})),k=m==="floating"?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,O=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),N=await(a.isElement==null?void 0:a.isElement(O))&&await(a.getScale==null?void 0:a.getScale(O))||{x:1,y:1},T=Lg(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:O,strategy:u}):k);return{top:(_.top-T.top+w.top)/N.y,bottom:(T.bottom-_.bottom+w.bottom)/N.y,left:(_.left-T.left+w.left)/N.x,right:(T.right-_.right+w.right)/N.x}}const Rie=50,Pie=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:s}=n,l=s.detectOverflow?s:{...s,detectOverflow:Iie},u=await(s.isRTL==null?void 0:s.isRTL(t));let d=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:m}=GM(d,r,u),p=r,g=0;const w={};for(let x=0;x<a.length;x++){const E=a[x];if(!E)continue;const{name:_,fn:k}=E,{x:O,y:N,data:T,reset:C}=await k({x:h,y:m,initialPlacement:r,placement:p,strategy:i,middlewareData:w,rects:d,platform:l,elements:{reference:e,floating:t}});h=O??h,m=N??m,w[_]={...w[_],...T},C&&g<Rie&&(g++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(d=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:h,y:m}=GM(d,p,u)),x=-1)}return{x:h,y:m,placement:p,strategy:i,middlewareData:w}},Die=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:a,platform:s,elements:l,middlewareData:u}=t,{element:d,padding:h=0}=Co(e,t)||{};if(d==null)return{};const m=e$(h),p={x:n,y:r},g=MS(i),w=TS(g),x=await s.getDimensions(d),E=g==="y",_=E?"top":"left",k=E?"bottom":"right",O=E?"clientHeight":"clientWidth",N=a.reference[w]+a.reference[g]-p[g]-a.floating[w],T=p[g]-a.reference[g],C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d));let M=C?C[O]:0;(!M||!await(s.isElement==null?void 0:s.isElement(C)))&&(M=l.floating[O]||a.floating[w]);const D=N/2-T/2,j=M/2-x[w]/2-1,R=Fs(m[_],j),H=Fs(m[k],j),P=M-x[w]-H,G=M/2-x[w]/2+D,q=Jz(R,G,P),X=!u.arrow&&od(i)!=null&&G!==q&&a.reference[w]/2-(G<R?R:H)-x[w]/2<0,U=X?G<R?G-R:G-P:0;return{[g]:p[g]+U,data:{[g]:q,centerOffset:G-q-U,...X&&{alignmentOffset:U}},reset:X}}}),jie=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:a,rects:s,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:h=!0,crossAxis:m=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:x=!0,...E}=Co(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const _=Hs(i),k=wa(l),O=Hs(l)===l,N=await(u.isRTL==null?void 0:u.isRTL(d.floating)),T=p||(O||!x?[jg(l)]:kie(l)),C=w!=="none";!p&&C&&T.push(...Tie(l,x,w,N));const M=[l,...T],D=await u.detectOverflow(t,E),j=[];let R=((r=a.flip)==null?void 0:r.overflows)||[];if(h&&j.push(D[_]),m){const q=Aie(i,s,N);j.push(D[q[0]],D[q[1]])}if(R=[...R,{placement:i,overflows:j}],!j.every(q=>q<=0)){var H,P;const q=(((H=a.flip)==null?void 0:H.index)||0)+1,X=M[q];if(X&&(!(m==="alignment"?k!==wa(X):!1)||R.every(F=>wa(F.placement)===k?F.overflows[0]>0:!0)))return{data:{index:q,overflows:R},reset:{placement:X}};let U=(P=R.filter(K=>K.overflows[0]<=0).sort((K,F)=>K.overflows[1]-F.overflows[1])[0])==null?void 0:P.placement;if(!U)switch(g){case"bestFit":{var G;const K=(G=R.filter(F=>{if(C){const V=wa(F.placement);return V===k||V==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(V=>V>0).reduce((V,$)=>V+$,0)]).sort((F,V)=>F[1]-V[1])[0])==null?void 0:G[0];K&&(U=K);break}case"initialPlacement":U=l;break}if(i!==U)return{reset:{placement:U}}}return{}}}};function VM(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function WM(e){return Sie.some(t=>e[t]>=0)}const Lie=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...a}=Co(e,t);switch(i){case"referenceHidden":{const s=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=VM(s,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:WM(l)}}}case"escaped":{const s=await r.detectOverflow(t,{...a,altBoundary:!0}),l=VM(s,n.floating);return{data:{escapedOffsets:l,escaped:WM(l)}}}default:return{}}}}},t$=new Set(["left","top"]);async function zie(e,t){const{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),s=Hs(n),l=od(n),u=wa(n)==="y",d=t$.has(s)?-1:1,h=a&&u?-1:1,m=Co(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:w}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return l&&typeof w=="number"&&(g=l==="end"?w*-1:w),u?{x:g*h,y:p*d}:{x:p*d,y:g*h}}const $ie=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:a,placement:s,middlewareData:l}=t,u=await zie(t,e);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:a+u.y,data:{...u,placement:s}}}}},Bie=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:a}=t,{mainAxis:s=!0,crossAxis:l=!1,limiter:u={fn:k=>{let{x:O,y:N}=k;return{x:O,y:N}}},...d}=Co(e,t),h={x:n,y:r},m=await a.detectOverflow(t,d),p=wa(i),g=CS(p);let w=h[g],x=h[p];const E=(k,O)=>Jz(O+m[k==="y"?"top":"left"],O,O-m[k==="y"?"bottom":"right"]);s&&(w=E(g,w)),l&&(x=E(p,x));const _=u.fn({...t,[g]:w,[p]:x});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[g]:s,[p]:l}}}}}},Uie=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:a,placement:s,rects:l,middlewareData:u}=t,{offset:d=0,mainAxis:h=!0,crossAxis:m=!0}=Co(e,t),p={x:i,y:a},g=wa(s),w=CS(g);let x=p[w],E=p[g];const _=Co(d,t),k=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:(n=_.mainAxis)!=null?n:0,crossAxis:(r=_.crossAxis)!=null?r:0};if(h){const T=w==="y"?"height":"width",C=l.reference[w]-l.floating[T]+k.mainAxis,M=l.reference[w]+l.reference[T]-k.mainAxis;x<C?x=C:x>M&&(x=M)}if(m){var O,N;const T=w==="y"?"width":"height",C=t$.has(Hs(s)),M=l.reference[g]-l.floating[T]+(C&&((O=u.offset)==null?void 0:O[g])||0)+(C?0:k.crossAxis),D=l.reference[g]+l.reference[T]+(C?0:((N=u.offset)==null?void 0:N[g])||0)-(C?k.crossAxis:0);E<M?E=M:E>D&&(E=D)}return{[w]:x,[g]:E}}}},Fie=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:a}=t,{apply:s=()=>{},...l}=Co(e,t),u=await i.detectOverflow(t,l),d=Hs(n),h=od(n),m=wa(n)==="y",{width:p,height:g}=r.floating;let w,x;d==="top"||d==="bottom"?(w=d,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,w=h==="end"?"top":"bottom");const E=g-u.top-u.bottom,_=p-u.left-u.right,k=Fs(g-u[w],E),O=Fs(p-u[x],_),N=t.middlewareData.shift,T=!N;let C=k,M=O;N!=null&&N.enabled.x&&(M=_),N!=null&&N.enabled.y&&(C=E),T&&!h&&(m?M=p-2*xo(u.left,u.right):C=g-2*xo(u.top,u.bottom)),await s({...t,availableWidth:M,availableHeight:C});const D=await i.getDimensions(a.floating);return p!==D.width||g!==D.height?{reset:{rects:!0}}:{}}}};function Jv(){return typeof window<"u"}function sd(e){return n$(e)?(e.nodeName||"").toLowerCase():"#document"}function Ur(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jo(e){var t;return(t=(n$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function n$(e){return Jv()?e instanceof Node||e instanceof Ur(e).Node:!1}function Ca(e){return Jv()?e instanceof Element||e instanceof Ur(e).Element:!1}function Js(e){return Jv()?e instanceof HTMLElement||e instanceof Ur(e).HTMLElement:!1}function YM(e){return!Jv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ur(e).ShadowRoot}function ey(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Ta(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function Hie(e){return/^(table|td|th)$/.test(sd(e))}function ty(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Kie=/transform|translate|scale|rotate|perspective|filter/,qie=/paint|layout|strict|content/,Al=e=>!!e&&e!=="none";let Ux;function IS(e){const t=Ca(e)?Ta(e):e;return Al(t.transform)||Al(t.translate)||Al(t.scale)||Al(t.rotate)||Al(t.perspective)||!RS()&&(Al(t.backdropFilter)||Al(t.filter))||Kie.test(t.willChange||"")||qie.test(t.contain||"")}function Gie(e){let t=ec(e);for(;Js(t)&&!nh(t);){if(IS(t))return t;if(ty(t))return null;t=ec(t)}return null}function RS(){return Ux==null&&(Ux=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ux}function nh(e){return/^(html|body|#document)$/.test(sd(e))}function Ta(e){return Ur(e).getComputedStyle(e)}function ny(e){return Ca(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ec(e){if(sd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||YM(e)&&e.host||jo(e);return YM(t)?t.host:t}function r$(e){const t=ec(e);return nh(t)?(e.ownerDocument||e).body:Js(t)&&ey(t)?t:r$(t)}function rh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=r$(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),s=Ur(i);if(a){const l=y1(s);return t.concat(s,s.visualViewport||[],ey(i)?i:[],l&&n?rh(l):[])}else return t.concat(i,rh(i,[],n))}function y1(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function i$(e){const t=Ta(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Js(e),a=i?e.offsetWidth:n,s=i?e.offsetHeight:r,l=Dg(n)!==a||Dg(r)!==s;return l&&(n=a,r=s),{width:n,height:r,$:l}}function PS(e){return Ca(e)?e:e.contextElement}function Tu(e){const t=PS(e);if(!Js(t))return wo(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:a}=i$(t);let s=(a?Dg(n.width):n.width)/r,l=(a?Dg(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const Vie=wo(0);function a$(e){const t=Ur(e);return!RS()||!t.visualViewport?Vie:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Wie(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ur(e)}function tc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),a=PS(e);let s=wo(1);t&&(r?Ca(r)&&(s=Tu(r)):s=Tu(e));const l=Wie(a,n,r)?a$(a):wo(0);let u=(i.left+l.x)/s.x,d=(i.top+l.y)/s.y,h=i.width/s.x,m=i.height/s.y;if(a&&r){const p=Ur(a),g=Ca(r)?Ur(r):r;let w=p,x=y1(w);for(;x&&g!==w;){const E=Tu(x),_=x.getBoundingClientRect(),k=Ta(x),O=_.left+(x.clientLeft+parseFloat(k.paddingLeft))*E.x,N=_.top+(x.clientTop+parseFloat(k.paddingTop))*E.y;u*=E.x,d*=E.y,h*=E.x,m*=E.y,u+=O,d+=N,w=Ur(x),x=y1(w)}}return Lg({width:h,height:m,x:u,y:d})}function ry(e,t){const n=ny(e).scrollLeft;return t?t.left+n:tc(jo(e)).left+n}function o$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ry(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function Yie(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const a=i==="fixed",s=jo(r),l=t?ty(t.floating):!1;if(r===s||l&&a)return n;let u={scrollLeft:0,scrollTop:0},d=wo(1);const h=wo(0),m=Js(r);if((m||!a)&&((sd(r)!=="body"||ey(s))&&(u=ny(r)),m)){const g=tc(r);d=Tu(r),h.x=g.x+r.clientLeft,h.y=g.y+r.clientTop}const p=s&&!m&&!a?o$(s,u):wo(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x+p.x,y:n.y*d.y-u.scrollTop*d.y+h.y+p.y}}function Xie(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Zie(e){const t=ny(e),n=e.ownerDocument.body,r=xo(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=xo(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let a=-t.scrollLeft+ry(e);const s=-t.scrollTop;return Ta(n).direction==="rtl"&&(a+=xo(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:s}}const Qie=25;function Jie(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=Ur(e),a=jo(e),s=i.visualViewport;let l=a.clientWidth,u=a.clientHeight,d=0,h=0;if(s){const p=!RS()||t==="fixed";r?p||(d=-s.offsetLeft,h=-s.offsetTop):(l=s.width,u=s.height,p&&(d=s.offsetLeft,h=s.offsetTop))}if(ry(a)<=0){const p=a.ownerDocument,g=p.body,w=getComputedStyle(g),x=p.compatMode==="CSS1Compat"&&parseFloat(w.marginLeft)+parseFloat(w.marginRight)||0,E=Math.abs(a.clientWidth-g.clientWidth-x),_=getComputedStyle(a).scrollbarGutter==="stable both-edges"?E/2:E;_<=Qie&&(l-=_)}return{width:l,height:u,x:d,y:h}}function eae(e,t){const n=tc(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Tu(e),s=e.clientWidth*a.x,l=e.clientHeight*a.y,u=i*a.x,d=r*a.y;return{width:s,height:l,x:u,y:d}}function XM(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=Jie(e,n,t);else if(t==="document")r=Zie(jo(e));else if(Ca(t))r=eae(t,n);else{const i=a$(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Lg(r)}function tae(e,t){const n=t.get(e);if(n)return n;let r=rh(e,[],!1).filter(l=>Ca(l)&&sd(l)!=="body"),i=null;const a=Ta(e).position==="fixed";let s=a?ec(e):e;for(;Ca(s)&&!nh(s);){const l=Ta(s),u=IS(s),d=i?i.position:a?"fixed":"";!u&&(d==="fixed"||d==="absolute"&&l.position==="static")?r=r.filter(m=>m!==s):i=l,s=ec(s)}return t.set(e,r),r}function nae(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[...n==="clippingAncestors"?ty(t)?[]:tae(t,this._c):[].concat(n),r],l=XM(t,s[0],i);let u=l.top,d=l.right,h=l.bottom,m=l.left;for(let p=1;p<s.length;p++){const g=XM(t,s[p],i);u=xo(g.top,u),d=Fs(g.right,d),h=Fs(g.bottom,h),m=xo(g.left,m)}return{width:d-m,height:h-u,x:m,y:u}}function rae(e){const{width:t,height:n}=i$(e);return{width:t,height:n}}function iae(e,t,n){const r=Js(t),i=jo(t),a=n==="fixed",s=tc(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const u=wo(0);if((r||!a)&&((sd(t)!=="body"||ey(i))&&(l=ny(t)),r)){const p=tc(t,!0,a,t);u.x=p.x+t.clientLeft,u.y=p.y+t.clientTop}!r&&i&&(u.x=ry(i));const d=i&&!r&&!a?o$(i,l):wo(0),h=s.left+l.scrollLeft-u.x-d.x,m=s.top+l.scrollTop-u.y-d.y;return{x:h,y:m,width:s.width,height:s.height}}function Fx(e){return Ta(e).position==="static"}function ZM(e,t){if(!Js(e)||Ta(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return jo(e)===n&&(n=n.ownerDocument.body),n}function s$(e,t){const n=Ur(e);if(ty(e))return n;if(!Js(e)){let i=ec(e);for(;i&&!nh(i);){if(Ca(i)&&!Fx(i))return i;i=ec(i)}return n}let r=ZM(e,t);for(;r&&Hie(r)&&Fx(r);)r=ZM(r,t);return r&&nh(r)&&Fx(r)&&!IS(r)?n:r||Gie(e)||n}const aae=async function(e){const t=this.getOffsetParent||s$,n=this.getDimensions,r=await n(e.floating);return{reference:iae(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function oae(e){return Ta(e).direction==="rtl"}const sae={convertOffsetParentRelativeRectToViewportRelativeRect:Yie,getDocumentElement:jo,getClippingRect:nae,getOffsetParent:s$,getElementRects:aae,getClientRects:Xie,getDimensions:rae,getScale:Tu,isElement:Ca,isRTL:oae};function l$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lae(e,t,n){let r=null,i;const a=jo(e);function s(){var h;clearTimeout(i),(h=r)==null||h.disconnect(),r=null}function l(h,m){h===void 0&&(h=!1),m===void 0&&(m=1),s();const p=e.getBoundingClientRect(),{left:g,top:w,width:x,height:E}=p;if(h||t(),!x||!E)return;const _=Mp(w),k=Mp(a.clientWidth-(g+x)),O=Mp(a.clientHeight-(w+E)),N=Mp(g),C={rootMargin:-_+"px "+-k+"px "+-O+"px "+-N+"px",threshold:xo(0,Fs(1,m))||1};let M=!0;function D(j){const R=j[0].intersectionRatio;if(!l$(p,e.getBoundingClientRect()))return l();if(R!==m){if(!M)return l();R?l(!1,R):i=setTimeout(()=>{l(!1,1e-7)},1e3)}M=!1}try{r=new IntersectionObserver(D,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(D,C)}r.observe(e)}const u=Ur(e),d=()=>l(n);return u.addEventListener("resize",d),l(!0),()=>{u.removeEventListener("resize",d),s()}}function cae(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=PS(e),h=i||a?[...d?rh(d):[],...t?rh(t):[]]:[];h.forEach(_=>{i&&_.addEventListener("scroll",n),a&&_.addEventListener("resize",n)});const m=d&&l?lae(d,n,a):null;let p=-1,g=null;s&&(g=new ResizeObserver(_=>{let[k]=_;k&&k.target===d&&g&&t&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var O;(O=g)==null||O.observe(t)})),n()}),d&&!u&&g.observe(d),t&&g.observe(t));let w,x=u?tc(e):null;u&&E();function E(){const _=tc(e);x&&!l$(x,_)&&n(),x=_,w=requestAnimationFrame(E)}return n(),()=>{var _;h.forEach(k=>{i&&k.removeEventListener("scroll",n),a&&k.removeEventListener("resize",n)}),m==null||m(),(_=g)==null||_.disconnect(),g=null,u&&cancelAnimationFrame(w)}}const uae=$ie,dae=Bie,fae=jie,hae=Fie,mae=Lie,QM=Die,pae=Uie,gae=(e,t,n)=>{const r=new Map,i=n??{},a={...sae,...i.platform,_c:r};return Pie(e,t,{...i,platform:a})};var vae=typeof document<"u",yae=function(){},og=vae?b.useLayoutEffect:yae;function zg(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(!zg(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 a=i[r];if(!(a==="_owner"&&e.$$typeof)&&!zg(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function c$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function JM(e,t){const n=c$(e);return Math.round(t*n)/n}function Hx(e){const t=b.useRef(e);return og(()=>{t.current=e}),t}function bae(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:s}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[h,m]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,g]=b.useState(r);zg(p,r)||g(r);const[w,x]=b.useState(null),[E,_]=b.useState(null),k=b.useCallback(F=>{F!==C.current&&(C.current=F,x(F))},[]),O=b.useCallback(F=>{F!==M.current&&(M.current=F,_(F))},[]),N=a||w,T=s||E,C=b.useRef(null),M=b.useRef(null),D=b.useRef(h),j=u!=null,R=Hx(u),H=Hx(i),P=Hx(d),G=b.useCallback(()=>{if(!C.current||!M.current)return;const F={placement:t,strategy:n,middleware:p};H.current&&(F.platform=H.current),gae(C.current,M.current,F).then(V=>{const $={...V,isPositioned:P.current!==!1};q.current&&!zg(D.current,$)&&(D.current=$,La.flushSync(()=>{m($)}))})},[p,t,n,H,P]);og(()=>{d===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,m(F=>({...F,isPositioned:!1})))},[d]);const q=b.useRef(!1);og(()=>(q.current=!0,()=>{q.current=!1}),[]),og(()=>{if(N&&(C.current=N),T&&(M.current=T),N&&T){if(R.current)return R.current(N,T,G);G()}},[N,T,G,R,j]);const X=b.useMemo(()=>({reference:C,floating:M,setReference:k,setFloating:O}),[k,O]),U=b.useMemo(()=>({reference:N,floating:T}),[N,T]),K=b.useMemo(()=>{const F={position:n,left:0,top:0};if(!U.floating)return F;const V=JM(U.floating,h.x),$=JM(U.floating,h.y);return l?{...F,transform:"translate("+V+"px, "+$+"px)",...c$(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:$}},[n,l,U.floating,h.x,h.y]);return b.useMemo(()=>({...h,update:G,refs:X,elements:U,floatingStyles:K}),[h,G,X,U,K])}const xae=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?QM({element:r.current,padding:i}).fn(n):{}:r?QM({element:r,padding:i}).fn(n):{}}}},wae=(e,t)=>{const n=uae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Eae=(e,t)=>{const n=dae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sae=(e,t)=>({fn:pae(e).fn,options:[e,t]}),_ae=(e,t)=>{const n=fae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Aae=(e,t)=>{const n=hae(e);return{name:n.name,fn:n.fn,options:[e,t]}},kae=(e,t)=>{const n=mae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Oae=(e,t)=>{const n=xae(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Nae=Object.defineProperty,DS=(e,t)=>Nae(e,"name",{value:t,configurable:!0});function b1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}DS(b1,"setRef");function u$(...e){return t=>{let n=!1;const r=e.map(i=>{const a=b1(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():b1(e[i],null)}}}}DS(u$,"composeRefs");function iy(...e){return b.useCallback(u$(...e),e)}DS(iy,"useComposedRefs");var Cae=Object.defineProperty,Ci=(e,t)=>Cae(e,"name",{value:t,configurable:!0});function Tae(e,t){const n=b.createContext(t);n.displayName=e+"Context";const r=Ci(a=>{const{children:s,...l}=a,u=b.useMemo(()=>l,Object.values(l));return y.jsx(n.Provider,{value:u,children:s})},"Provider");r.displayName=e+"Provider";function i(a,s={}){const{optional:l=!1}=s,u=b.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return Ci(i,"useContext"),[r,i]}Ci(Tae,"createContext");function d$(e,t=[]){let n=[];function r(a,s){const l=b.createContext(s);l.displayName=a+"Context";const u=n.length;n=[...n,s];const d=Ci(m=>{var _;const{scope:p,children:g,...w}=m,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useMemo(()=>w,Object.values(w));return y.jsx(x.Provider,{value:E,children:g})},"Provider");d.displayName=a+"Provider";function h(m,p,g={}){var _;const{optional:w=!1}=g,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useContext(x);if(E)return E;if(s!==void 0)return s;if(!w)throw new Error(`\`${m}\` must be used within \`${a}\``)}return Ci(h,"useContext"),[d,h]}Ci(r,"createContext");const i=Ci(()=>{const a=n.map(s=>b.createContext(s));return Ci(function(l){const u=(l==null?void 0:l[e])||a;return b.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,f$(i,...t)]}Ci(d$,"createContextScope");function f$(...e){const t=e[0];if(e.length===1)return t;const n=Ci(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Ci(function(a){const s=r.reduce((l,{useScope:u,scopeName:d})=>{const m=u(a)[`__scope${d}`];return{...l,...m}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Ci(f$,"composeContextScopes");var Mae=Object.defineProperty,ta=(e,t)=>Mae(e,"name",{value:t,configurable:!0});function h$(e){const t=b.forwardRef((n,r)=>{let{children:i,...a}=n,s=null,l=!1;const u=[];x1(i)&&typeof Ip=="function"&&(i=Ip(i._payload)),b.Children.forEach(i,p=>{var g;if(v$(p)){l=!0;const w=p;let x="child"in w.props?w.props.child:w.props.children;x1(x)&&typeof Ip=="function"&&(x=Ip(x._payload)),s=Rae(w,x),u.push((g=s==null?void 0:s.props)==null?void 0:g.children)}else u.push(p)}),s?s=b.cloneElement(s,void 0,u):!l&&b.Children.count(i)===1&&b.isValidElement(i)&&(s=i);const d=s?g$(s):void 0,h=iy(r,d);if(!s){if(i||i===0)throw new Error(l?jae(e):Dae(e));return i}const m=p$(a,s.props??{});return s.type!==b.Fragment&&(m.ref=r?h:d),b.cloneElement(s,m)});return t.displayName=`${e}.Slot`,t}ta(h$,"createSlot");var m$=Symbol.for("radix.slottable");function Iae(e){const t=ta(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=m$,t}ta(Iae,"createSlottable");var Rae=ta((e,t)=>{if("child"in e.props){const n=e.props.child;return b.isValidElement(n)?b.cloneElement(n,void 0,e.props.children(n.props.children)):null}return b.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function p$(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...l)=>{const u=a(...l);return i(...l),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}ta(p$,"mergeProps");function g$(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ta(g$,"getElementRef");function v$(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===m$}ta(v$,"isSlottable");var Pae=Symbol.for("react.lazy");function x1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Pae&&"_payload"in e&&y$(e._payload)}ta(x1,"isLazyComponent");function y$(e){return typeof e=="object"&&e!==null&&"then"in e}ta(y$,"isPromiseLike");var Dae=ta(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),jae=ta(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Ip=ja[" use ".trim().toString()],Lae=Object.defineProperty,zae=(e,t)=>Lae(e,"name",{value:t,configurable:!0}),$ae=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],b$=$ae.reduce((e,t)=>{const n=h$(`Primitive.${t}`),r=b.forwardRef((i,a)=>{const{asChild:s,...l}=i,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Bae(e,t){e&&La.flushSync(()=>e.dispatchEvent(t))}zae(Bae,"dispatchDiscreteCustomEvent");var Uae=Object.defineProperty,Fae=(e,t)=>Uae(e,"name",{value:t,configurable:!0});function x$(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}Fae(x$,"useCallbackRef");var Kx=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},Hae=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},Kae=Object.defineProperty,qae=(e,t)=>Kae(e,"name",{value:t,configurable:!0});function w$(e){const[t,n]=b.useState(void 0);return Hae(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[0];let s,l;if("borderBoxSize"in a){const u=a.borderBoxSize,d=Array.isArray(u)?u[0]:u;s=d.inlineSize,l=d.blockSize}else s=e.offsetWidth,l=e.offsetHeight;n({width:s,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}qae(w$,"useSize");var Gae=Object.defineProperty,js=(e,t)=>Gae(e,"name",{value:t,configurable:!0}),E$="Popper",[S$,_$]=d$(E$),[Vae,A$]=S$(E$),Wae=js(e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null),[a,s]=b.useState(void 0);return y.jsx(Vae,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:s,children:n})},"Popper"),Yae="PopperAnchor",Xae=b.forwardRef(js(function(t,n){const{__scopePopper:r,virtualRef:i,...a}=t,s=A$(Yae,r),l=b.useRef(null),u=s.onAnchorChange,d=b.useCallback(x=>{l.current=x,x&&u(x)},[u]),h=iy(n,d),m=b.useRef(null);b.useEffect(()=>{if(!i)return;const x=m.current;m.current=i.current,x!==m.current&&u(m.current)});const p=s.placementState&&ay(s.placementState),g=p==null?void 0:p[0],w=p==null?void 0:p[1];return i?null:y.jsx(b$.div,{"data-radix-popper-side":g,"data-radix-popper-align":w,...a,ref:h})},"PopperAnchor")),k$="PopperContent",[Zae,cCe]=S$(k$),Qae=b.forwardRef(js(function(t,n){var fe,Ee,Te,de,nt,He,Ae;const{__scopePopper:r,side:i="bottom",sideOffset:a=0,align:s="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:m=0,sticky:p="partial",hideWhenDetached:g=!1,updatePositionStrategy:w="optimized",onPlaced:x,...E}=t,_=A$(k$,r),[k,O]=b.useState(null),N=iy(n,O),[T,C]=b.useState(null),M=w$(T),D=(M==null?void 0:M.width)??0,j=(M==null?void 0:M.height)??0,R=i+(s!=="center"?"-"+s:""),H=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},P=Array.isArray(h)?h:[h],G=P.length>0,q={padding:H,boundary:P.filter(O$),altBoundary:G},{refs:X,floatingStyles:U,placement:K,isPositioned:F,middlewareData:V}=bae({strategy:"fixed",placement:R,whileElementsMounted:js((...De)=>cae(...De,{animationFrame:w==="always"}),"whileElementsMounted"),elements:{reference:_.anchor},middleware:[wae({mainAxis:a+j,alignmentAxis:l}),d&&Eae({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Sae():void 0,...q}),d&&_ae({...q}),Aae({...q,apply:js(({elements:De,rects:Ht,availableWidth:un,availableHeight:Yn})=>{const{width:Or,height:Li}=Ht.reference,ir=De.floating.style;ir.setProperty("--radix-popper-available-width",`${un}px`),ir.setProperty("--radix-popper-available-height",`${Yn}px`),ir.setProperty("--radix-popper-anchor-width",`${Or}px`),ir.setProperty("--radix-popper-anchor-height",`${Li}px`)},"apply")}),T&&Oae({element:T,padding:u}),Jae({arrowWidth:D,arrowHeight:j}),g&&kae({strategy:"referenceHidden",...q,boundary:G?q.boundary:void 0})]}),$=_.setPlacementState;Kx(()=>($(K),()=>{$(void 0)}),[K,$]);const[L,W]=ay(K),z=x$(x);Kx(()=>{F&&(z==null||z())},[F,z]);const ie=(fe=V.arrow)==null?void 0:fe.x,he=(Ee=V.arrow)==null?void 0:Ee.y,ge=((Te=V.arrow)==null?void 0:Te.centerOffset)!==0,[Se,$e]=b.useState();return Kx(()=>{k&&$e(window.getComputedStyle(k).zIndex)},[k]),y.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:F?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Se,"--radix-popper-transform-origin":[(de=V.transformOrigin)==null?void 0:de.x,(nt=V.transformOrigin)==null?void 0:nt.y].join(" "),...((He=V.hide)==null?void 0:He.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:y.jsx(Zae,{scope:r,placedSide:L,placedAlign:W,onArrowChange:C,arrowX:ie,arrowY:he,shouldHideArrow:ge,children:y.jsx(b$.div,{"data-side":L,"data-align":W,...E,ref:N,style:{...E.style,animation:F?(Ae=E.style)==null?void 0:Ae.animation:"none"}})})})},"PopperContent"));function O$(e){return e!==null}js(O$,"isNotNull");var Jae=js(e=>({name:"transformOrigin",options:e,fn(t){var E,_,k;const{placement:n,rects:r,middlewareData:i}=t,s=((E=i.arrow)==null?void 0:E.centerOffset)!==0,l=s?0:e.arrowWidth,u=s?0:e.arrowHeight,[d,h]=ay(n),m={start:"0%",center:"50%",end:"100%"}[h],p=(((_=i.arrow)==null?void 0:_.x)??0)+l/2,g=(((k=i.arrow)==null?void 0:k.y)??0)+u/2;let w="",x="";return d==="bottom"?(w=s?m:`${p}px`,x=`${-u}px`):d==="top"?(w=s?m:`${p}px`,x=`${r.floating.height+u}px`):d==="right"?(w=`${-u}px`,x=s?m:`${g}px`):d==="left"&&(w=`${r.floating.width+u}px`,x=s?m:`${g}px`),{data:{x:w,y:x}}}}),"transformOrigin");function ay(e){const[t,n="center"]=e.split("-");return[t,n]}js(ay,"getSideAndAlignFromPlacement");var eoe=Wae,toe=Xae,noe=Qae,roe=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},ioe=Object.defineProperty,aoe=(e,t)=>ioe(e,"name",{value:t,configurable:!0}),ooe=b.forwardRef(aoe(function(t,n){var u;const{container:r,...i}=t,[a,s]=b.useState(!1);roe(()=>s(!0),[]);const l=r||a&&((u=globalThis==null?void 0:globalThis.document)==null?void 0:u.body);return l?La.createPortal(y.jsx(Zv.div,{...i,ref:n}),l):null},"Portal")),eI=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},soe=Object.defineProperty,To=(e,t)=>soe(e,"name",{value:t,configurable:!0});function N$(e,t){return b.useReducer((n,r)=>t[n][r]??n,e)}To(N$,"useStateMachine");var C$=To(e=>{const{present:t,children:n}=e,r=T$(t),i=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),a=M$(r.ref,I$(i));return typeof n=="function"||r.isPresent?b.cloneElement(i,{ref:a}):null},"Presence");function T$(e){const[t,n]=b.useState(),r=b.useRef(null),i=b.useRef(e),a=b.useRef("none"),s=b.useRef(void 0),l=e?"mounted":"unmounted",[u,d]=N$(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{u==="mounted"?(a.current=s.current??bu(r.current),s.current=void 0):a.current="none"},[u]),eI(()=>{const h=r.current,m=i.current;if(m!==e){const g=a.current,w=bu(h);e?(s.current=w,d("MOUNT")):w==="none"||(h==null?void 0:h.display)==="none"?d("UNMOUNT"):d(m&&g!==w?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,d]),eI(()=>{if(t){let h;const m=t.ownerDocument.defaultView??window,p=To(w=>{const E=bu(r.current).includes(CSS.escape(w.animationName));if(w.target===t&&E&&(d("ANIMATION_END"),!i.current)){const _=t.style.animationFillMode;t.style.animationFillMode="forwards",h=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=_)})}},"handleAnimationEnd"),g=To(w=>{w.target===t&&(a.current=bu(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{m.clearTimeout(h),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:b.useCallback(h=>{if(h){const m=getComputedStyle(h);r.current=m,s.current=bu(m)}else r.current=null;n(h)},[])}}To(T$,"usePresence");function w1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}To(w1,"setRef");function M$(...e){const t=b.useRef(e);return t.current=e,b.useCallback(n=>{const r=t.current;let i=!1;const a=r.map(s=>{const l=w1(s,n);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let s=0;s<a.length;s++){const l=a[s];typeof l=="function"?l():w1(r[s],null)}}},[])}To(M$,"useStableComposedRefs");function bu(e){return(e==null?void 0:e.animationName)||"none"}To(bu,"getAnimationName");function I$(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}To(I$,"getElementRef");var R$=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},loe=Object.defineProperty,coe=(e,t)=>loe(e,"name",{value:t,configurable:!0}),tI=ja[" useEffectEvent ".trim().toString()],nI=ja[" useInsertionEffect ".trim().toString()];function P$(e){if(typeof tI=="function")return tI(e);const t=b.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof nI=="function"?nI(()=>{t.current=e}):R$(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}coe(P$,"useEffectEvent");var uoe=Object.defineProperty,Nh=(e,t)=>uoe(e,"name",{value:t,configurable:!0}),doe=ja[" useInsertionEffect ".trim().toString()]||R$;function D$({prop:e,defaultProp:t,onChange:n=Nh(()=>{},"onChange"),caller:r}){const[i,a,s]=j$({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:i,d=b.useCallback(h=>{var m;if(l){const p=L$(h)?h(e):h;p!==e&&((m=s.current)==null||m.call(s,p))}else a(h)},[l,e,a,s]);return[u,d]}Nh(D$,"useControllableState");function j$({defaultProp:e,onChange:t}){const[n,r]=b.useState(e),i=b.useRef(n),a=b.useRef(t);return doe(()=>{a.current=t},[t]),b.useEffect(()=>{var s;i.current!==n&&((s=a.current)==null||s.call(a,n),i.current=n)},[n,i]),[n,r,a]}Nh(j$,"useUncontrolledState");function L$(e){return typeof e=="function"}Nh(L$,"isFunction");var rI=Symbol("RADIX:SYNC_STATE");function foe(e,t,n,r){const{prop:i,defaultProp:a,onChange:s,caller:l}=t,u=i!==void 0,d=P$(s),h=[{...n,state:a}];r&&h.push(r);const[m,p]=b.useReducer((E,_)=>{if(_.type===rI)return{...E,state:_.state};const k=e(E,_);return u&&!Object.is(k.state,E.state)&&d(k.state),k},...h),g=m.state,w=b.useRef(g);b.useEffect(()=>{w.current!==g&&(w.current=g,u||d(g))},[g,w,u]);const x=b.useMemo(()=>i!==void 0?{...m,state:i}:m,[m,i]);return b.useEffect(()=>{u&&!Object.is(i,m.state)&&p({type:rI,state:i})},[i,m.state,u]),[x,p]}Nh(foe,"useControllableStateReducer");var hoe=Object.defineProperty,el=(e,t)=>hoe(e,"name",{value:t,configurable:!0}),jS="Popover",[z$,uCe]=Dz(jS,[_$]),LS=_$(),[moe,ld]=z$(jS),poe=el(e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!1}=e,l=LS(t),u=b.useRef(null),[d,h]=b.useState(!1),[m,p]=D$({prop:r,defaultProp:i??!1,onChange:a,caller:jS});return y.jsx(eoe,{...l,children:y.jsx(moe,{scope:t,contentId:Qz(),triggerRef:u,open:m,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:d,onCustomAnchorAdd:b.useCallback(()=>h(!0),[]),onCustomAnchorRemove:b.useCallback(()=>h(!1),[]),modal:s,children:n})})},"Popover"),goe="PopoverTrigger",voe=b.forwardRef(el(function(t,n){const{__scopePopover:r,...i}=t,a=ld(goe,r),s=LS(r),l=ad(n,a.triggerRef),u=y.jsx(Zv.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":zS(a.open),...i,ref:l,onClick:Ds(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:y.jsx(toe,{asChild:!0,...s,children:u})},"PopoverTrigger")),$$="PopoverPortal",[yoe,boe]=z$($$,{forceMount:void 0}),xoe=el(e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=ld($$,t);return y.jsx(yoe,{scope:t,forceMount:n,children:y.jsx(C$,{present:n||a.open,children:y.jsx(ooe,{asChild:!0,container:i,children:r})})})},"PopoverPortal"),ih="PopoverContent",woe=b.forwardRef(el(function(t,n){const r=boe(ih,t.__scopePopover),{forceMount:i=r.forceMount,...a}=t,s=ld(ih,t.__scopePopover);return y.jsx(C$,{present:i||s.open,children:s.modal?y.jsx(Soe,{...a,ref:n}):y.jsx(_oe,{...a,ref:n})})},"PopoverContent")),Eoe=_S("PopoverContent.RemoveScroll"),Soe=b.forwardRef(el(function(t,n){const r=ld(ih,t.__scopePopover),i=b.useRef(null),a=ad(n,i),s=b.useRef(!1);return b.useEffect(()=>{const l=i.current;if(l)return gz(l)},[]),y.jsx(vS,{as:Eoe,allowPinchZoom:!0,children:y.jsx(B$,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ds(t.onCloseAutoFocus,l=>{var u;l.preventDefault(),s.current||(u=r.triggerRef.current)==null||u.focus()}),onPointerDownOutside:Ds(t.onPointerDownOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,h=u.button===2||d;s.current=h},{checkForDefaultPrevented:!1}),onFocusOutside:Ds(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),_oe=b.forwardRef(el(function(t,n){const r=ld(ih,t.__scopePopover),i=b.useRef(!1),a=b.useRef(!1);return y.jsx(B$,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var l,u;(l=t.onCloseAutoFocus)==null||l.call(t,s),s.defaultPrevented||(i.current||(u=r.triggerRef.current)==null||u.focus(),s.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:s=>{var d,h;(d=t.onInteractOutside)==null||d.call(t,s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=s.target;((h=r.triggerRef.current)==null?void 0:h.contains(l))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&a.current&&s.preventDefault()}})},"PopoverContentNonModal")),B$=b.forwardRef(el(function(t,n){const{__scopePopover:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:s,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,...p}=t,g=ld(ih,r),w=LS(r);return OS(),y.jsx(vie,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:s,children:y.jsx(cie,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:m,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onDismiss:()=>g.onOpenChange(!1),deferPointerDownOutside:!0,children:y.jsx(noe,{"data-state":zS(g.open),role:"dialog",id:g.contentId,...w,...p,ref:n,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function zS(e){return e?"open":"closed"}el(zS,"getState");var Aoe=poe,koe=voe,Ooe=xoe,U$=woe;const Noe=Aoe,Coe=koe,F$=b.forwardRef(({className:e,align:t="start",side:n="top",sideOffset:r=8,collisionPadding:i=8,...a},s)=>y.jsx(Ooe,{children:y.jsx(U$,{ref:s,align:t,side:n,sideOffset:r,collisionPadding:i,className:ze("z-50 w-64 max-w-[calc(100vw-1rem)] rounded-md border bg-card p-3 text-card-foreground shadow-md outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...a})}));F$.displayName=U$.displayName;const H$=92,K$=96;function qx(e){if(!Number.isFinite(e)||e<0)return"?";const t=["B","KB","MB","GB","TB","PB"];let n=0;for(;e>=1024&&n<t.length-1;)e/=1024,n++;return`${e<10&&n>0?e.toFixed(1):Math.round(e)} ${t[n]}`}const iI=3e5;function Toe({socket:e,getToken:t}){const[n,r]=b.useState([]);if(b.useEffect(()=>{t().then(a=>a?fetch("/api/stats",{headers:{Authorization:`Bearer ${a}`}}):null).then(a=>a==null?void 0:a.json()).then(a=>(a==null?void 0:a.samples)&&r(a.samples)).catch(a=>console.warn("[MachineStats] seed failed",a))},[t]),b.useEffect(()=>{if(!e)return;const a=e.on(s=>{s.type==="stats"&&r(l=>[...l,s.sample].slice(-120))});return()=>{a()}},[e]),!n.length)return null;const i=n[n.length-1];return y.jsxs("div",{className:"w-full flex flex-wrap items-center justify-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground/60",children:[y.jsx(sg,{label:"cpu",value:i.cpu,series:n.map(a=>a.cpu)}),y.jsx(sg,{label:"mem",value:i.mem,series:n.map(a=>a.mem)}),i.disk>=0&&y.jsx(sg,{label:"disk",value:i.disk,severity:Loe(i.disk),title:$oe(i)}),y.jsx(Moe,{getToken:t})]})}function Moe({getToken:e}){const[t,n]=b.useState(null);return b.useEffect(()=>{let r=!0,i=0;const a=async()=>{var d;try{const h=await e();if(!h)return;i=Date.now();const m=await fetch("/api/claude-usage",{headers:{Authorization:`Bearer ${h}`}});if(!r)return;if(m.status===204){n(null);return}if(m.status!==200)return;const p=await m.json();if(!r||!((d=p==null?void 0:p.limits)!=null&&d.length))return;n(p)}catch(h){console.warn("[MachineStats] claude usage poll failed",h)}},s=()=>{document.visibilityState==="visible"&&a()},l=()=>{document.visibilityState==="visible"&&Date.now()-i>=iI&&a()};s();const u=setInterval(s,iI);return document.addEventListener("visibilitychange",l),()=>{r=!1,clearInterval(u),document.removeEventListener("visibilitychange",l)}},[e]),y.jsx(q$,{usage:t})}function q$({usage:e,compact:t}){const n=e&&G$(e.limits),[r,i]=b.useState(E1),a=b.useRef(null),s=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=b.useCallback((u,d=0)=>{if(s(),!d){i(h=>oI(h,u));return}a.current=setTimeout(()=>{a.current=null,i(h=>oI(h,u))},d)},[]);return b.useEffect(()=>s,[]),!e||!n?null:y.jsxs(Noe,{open:r.open,onOpenChange:u=>l(u?{type:"activate"}:{type:"dismiss"}),children:[y.jsx(Coe,{asChild:!0,children:y.jsx("button",{type:"button","aria-label":"claude usage breakdown",className:"cursor-default rounded-sm outline-none focus-visible:ring-1 focus-visible:ring-ring",onPointerEnter:u=>l({type:"pointerenter",pointerType:u.pointerType},Ioe),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},aI),children:t?y.jsxs("span",{className:ze("tabular-nums",$g(n.percent,n.severity)),children:[n.percent,"% used"]}):y.jsx(sg,{label:"usage",value:n.percent,severity:n.severity})})}),y.jsx(F$,{onOpenAutoFocus:u=>u.preventDefault(),onPointerEnter:()=>s(),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},aI),children:y.jsx(Roe,{usage:e})})]})}const Ioe=120,aI=80,E1={open:!1,byHover:!1};function oI(e,t){switch(t.type){case"pointerenter":return sI(t.pointerType)?{open:!0,byHover:!0}:e;case"pointerleave":return sI(t.pointerType)&&e.byHover?E1:e;case"activate":return{open:!0,byHover:!1};case"dismiss":return E1}}const sI=e=>e==="mouse"||e==="";function Roe({usage:e}){const t=G$(e.limits);return y.jsxs("div",{className:"text-[11px] leading-tight",children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2 pb-2 text-muted-foreground",children:[y.jsx("span",{className:"uppercase tracking-wide",children:"claude usage"}),e.subscriptionType&&y.jsxs("span",{className:"tabular-nums",children:[e.subscriptionType," plan"]})]}),y.jsxs("div",{className:"-mt-1 flex items-baseline justify-between gap-2 pb-2 text-[10px] text-muted-foreground",children:[e.account&&y.jsx("span",{className:"truncate",title:e.account,children:e.account}),y.jsx("span",{className:ze("shrink-0",e.stale&&"text-amber-500"),children:Doe(e)})]}),e.stale&&e.error&&y.jsxs("div",{"data-refresh-error":!0,className:"-mt-1 pb-2 text-[10px] text-amber-500 break-words",children:[e.error,ag(e.retryAt??null)&&` · retrying in ${ag(e.retryAt??null)}`]}),y.jsx("div",{className:"flex flex-col gap-3",children:e.limits.map((n,r)=>{const i=ag(n.resetsAt),a=n===t;return y.jsxs("div",{"data-headline":a||void 0,className:ze("flex flex-col gap-1",!a&&"opacity-60"),children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[y.jsxs("span",{className:ze("truncate",a&&"font-medium"),children:[a&&y.jsx("span",{className:"mr-1 text-muted-foreground","aria-hidden":!0,children:"▸"}),Poe(n)]}),y.jsxs("span",{className:ze("tabular-nums shrink-0",$g(n.percent,n.severity)),children:[n.percent,"%"]})]}),y.jsx(V$,{value:n.percent,className:ze("w-full",$g(n.percent,n.severity))}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:i?`resets in ${i}`:"no reset reported"})]},`${n.kind}-${r}`)})}),y.jsx("div",{className:"mt-3 border-t pt-2 text-[10px] text-muted-foreground",children:"▸ is the window the strip is showing"})]})}function Poe(e){return e.scopeLabel?`${e.scopeLabel} window`:e.kind==="session"?"current session":e.kind==="weekly_all"?"all models":e.kind.replace(/_/g," ")}function G$(e){return e.reduce((t,n)=>!t||n.percent>t.percent?n:t,null)}function Doe(e){const t=joe(e.fetchedAt);return t?e.stale?`${t} old — refresh failed`:`updated ${t} ago`:e.stale?"last reading — refresh failed":"updated just now"}function joe(e){if(!e)return null;const t=Date.now()-new Date(e).getTime();if(!Number.isFinite(t))return null;const n=Math.round(Math.max(0,t)/6e4);if(n<1)return null;if(n<60)return`${n}m`;const r=Math.floor(n/60),i=n%60;return r<24?i?`${r}h ${i}m`:`${r}h`:`${Math.floor(r/24)}d`}function Loe(e){return e>=K$?"critical":e>=H$?"warning":"ok"}const zoe={critical:"text-red-500",exceeded:"text-red-500",warning:"text-amber-500",warn:"text-amber-500",ok:"text-emerald-500"};function $g(e,t){const n=t?zoe[t]:void 0;return n||(e>=90?"text-red-500":e>=75?"text-amber-500":"text-emerald-500")}function $oe(e){const t=`warn at ${H$}%, critical at ${K$}%`;if(e.diskUsedBytes==null||e.diskTotalBytes==null)return`disk ${e.disk}% used — ${t}`;const n=Math.max(0,e.diskTotalBytes-e.diskUsedBytes);return`disk ${e.disk}% used — ${qx(e.diskUsedBytes)} of ${qx(e.diskTotalBytes)}, ${qx(n)} free — ${t}`}function sg({label:e,value:t,series:n,title:r,severity:i}){const a=$g(t,i),s=r??(n?`${e} ${t}% — last ${n.length} samples`:void 0);return y.jsxs("span",{className:"flex items-center gap-1",title:s,children:[y.jsx("span",{className:"uppercase tracking-wide",children:e}),n?y.jsx(Boe,{series:n,className:a}):y.jsx(V$,{value:t,className:a}),y.jsxs("span",{className:ze("tabular-nums",a),children:[t,"%"]})]})}function V$({value:e,className:t}){const i=Math.max(0,Math.min(100,e))/100*40;return y.jsxs("svg",{width:40,height:12,viewBox:"0 0 40 12",className:ze("overflow-visible",t),preserveAspectRatio:"none",children:[y.jsx("rect",{x:0,y:12/2-2,width:40,height:4,rx:2,fill:"currentColor",opacity:.2}),i>0&&y.jsx("rect",{x:0,y:12/2-2,width:i,height:4,rx:2,fill:"currentColor"})]})}function Boe({series:e,className:t}){const i=e.length;if(i<2)return null;const a=e.map((s,l)=>{const u=i>1?l/(i-1)*40:0,d=12-Math.max(0,Math.min(100,s))/100*12;return`${u.toFixed(1)},${d.toFixed(1)}`}).join(" ");return y.jsx("svg",{width:40,height:12,viewBox:"0 0 40 12",className:ze("overflow-visible",t),preserveAspectRatio:"none",children:y.jsx("polyline",{points:a,fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinejoin:"round",strokeLinecap:"round"})})}const kf=50;function Uoe({getToken:e,filter:t,refreshKey:n,hydrateIds:r}){const[i,a]=b.useState([]),[s,l]=b.useState(null),[u,d]=b.useState(!1),[h,m]=b.useState({}),p=b.useRef(new Set),g=b.useRef(null),w=b.useRef(null),x=b.useRef(t);x.current=t;const E=b.useRef(kf),_=b.useRef(t);_.current!==t&&(_.current=t,E.current=kf);const k=b.useCallback(async(M,D)=>{const j=await e();if(!j||D!=null&&D.aborted)return null;const R=await fetch(`/api/sessions?${new URLSearchParams(M)}`,{signal:D,headers:{Authorization:`Bearer ${j}`}});if(!R.ok)return null;const H=await R.json();return Array.isArray(H==null?void 0:H.sessions)?H:null},[e]),O=b.useCallback(async(M,D,j)=>{const R=[];let H,P=null;for(;R.length<M;){const G={filter:D,limit:String(Math.min(kf,M-R.length))};H&&(G.before=H);const q=await k(G,j);if(!q)return null;if(R.push(...q.sessions),P=q.nextCursor,!P||!q.sessions.length)break;H=P}return{sessions:R,nextCursor:P}},[k]);b.useEffect(()=>{var D,j;(D=g.current)==null||D.abort(),(j=w.current)==null||j.abort();const M=new AbortController;return g.current=M,d(!0),p.current.clear(),m({}),O(E.current,t,M.signal).then(R=>{!R||M.signal.aborted||(a(R.sessions),l(R.nextCursor))}).catch(()=>{}).finally(()=>{M.signal.aborted||d(!1)}),()=>M.abort()},[O,t,n]);const N=b.useCallback(()=>{var j;if(!s||u)return;(j=w.current)==null||j.abort();const M=new AbortController;w.current=M;const D=x.current;d(!0),k({filter:D,limit:String(kf),before:s},M.signal).then(R=>{!R||M.signal.aborted||D!==x.current||(a(H=>{const P=new Set(H.map(q=>q.sessionId)),G=[...H,...R.sessions.filter(q=>!P.has(q.sessionId))];return E.current=Math.max(kf,G.length),G}),l(R.nextCursor))}).catch(()=>{}).finally(()=>{M.signal.aborted||d(!1)})},[s,u,k]),T=b.useMemo(()=>{const M=new Map;for(const D of Object.values(h))M.set(D.sessionId,D);for(const D of i)M.set(D.sessionId,D);return M},[i,h]),C=r.join(",");return b.useEffect(()=>{const M=r.filter(j=>!!j&&!T.has(j)&&!p.current.has(j)).slice(0,200);if(!M.length)return;for(const j of M)p.current.add(j);let D=!1;return k({ids:M.join(",")}).then(j=>{!j||D||m(R=>{const H={...R};for(const P of j.sessions)H[P.sessionId]=P;return H})}).catch(()=>{}),()=>{D=!0}},[C,T,k]),{sessions:i,cursor:s,loading:u,byId:T,loadMore:N}}const Of="0.1.137";function Foe(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);if(r<24)return`${r}h ago`;const i=Math.floor(r/24);return i<7?`${i}d ago`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}const Nf="w-4 h-4 mt-0.5 shrink-0";function Hoe(e){const t=e.slackContext;return(t==null?void 0:t.type)==="dm"?y.jsx(aV,{className:`${Nf} text-purple-400`}):(t==null?void 0:t.type)==="mention"?y.jsx(qG,{className:`${Nf} text-blue-400`}):(t==null?void 0:t.type)==="channel"?y.jsx(eV,{className:`${Nf} text-green-400`}):e.sessionId.startsWith("slack-")?y.jsx(Vw,{className:`${Nf} text-yellow-400`}):y.jsx(Vw,{className:`${Nf} text-muted-foreground`})}function Koe(e){const t=e.slackContext;return(t==null?void 0:t.type)==="dm"?`DM${t.userName?` · ${t.userName}`:""}`:(t==null?void 0:t.type)==="mention"?`@mention${t.channelName?` · #${t.channelName}`:""}`:(t==null?void 0:t.type)==="channel"?`#${t.channelName||"channel"}`:e.sessionId.startsWith("slack-")?"Slack":null}function qoe(e,t,n){return Object.keys(e).map(r=>t.get(r)).filter(r=>!!r&&(n==="all"||r.mine!==!1))}const lI="chats-filter",cI="chats-unread-filter";function Goe({getToken:e,activeSessionId:t,onSelect:n,onNew:r,refreshKey:i,workspaceRefreshKey:a,onRefreshWorkspace:s,unreads:l={},busySessions:u=new Set,socket:d}){var F;const h=za(),[m,p]=b.useState(()=>localStorage.getItem(lI)||"mine"),[g,w]=b.useState(()=>localStorage.getItem(cI)==="true"),[x,E]=b.useState(""),_=b.useRef(null);function k(V){p(V),localStorage.setItem(lI,V)}function O(){const V=!g;w(V),localStorage.setItem(cI,String(V))}const N=b.useMemo(()=>[t,...Object.keys(l)].filter(V=>!!V),[t,l]),{sessions:T,cursor:C,loading:M,byId:D,loadMore:j}=Uoe({getToken:e,filter:m,refreshKey:i,hydrateIds:N}),R=b.useMemo(()=>qoe(l,D,m),[l,D,m]),H=R.length,P=b.useMemo(()=>g?[...R].sort((V,$)=>$.lastModified-V.lastModified):T,[g,R,T]),G=t&&!P.some(V=>V.sessionId===t)?D.get(t):void 0;b.useEffect(()=>{_.current&&_.current.scrollIntoView({block:"nearest"})},[t,P,G]);const q=b.useRef(null),X=b.useRef(j);X.current=j,b.useEffect(()=>{const V=q.current;if(!V||!C||g)return;const $=new IntersectionObserver(L=>{L.some(W=>W.isIntersecting)&&X.current()},{rootMargin:"300px"});return $.observe(V),()=>$.disconnect()},[C,M,g]),b.useEffect(()=>{e().then(V=>V?fetch("/api/version",{headers:{Authorization:`Bearer ${V}`}}):null).then(V=>V==null?void 0:V.json()).then(V=>V&&E(V.version)).catch(()=>{})},[]);const U=!!x&&x!=="unknown"&&Of!=="dev"&&x!==Of;b.useEffect(()=>{U&&console.warn(`[shraga] stale client bundle: built from v${Of}, server runs v${x} — rebuild dist/client`)},[U,x]);function K(V){const $=l[V.sessionId],L=u.has(V.sessionId)||V.runStatus==="running"||V.scheduleRunStatus==="running",W=!L&&(!!V.lastStopReason||V.scheduleRunStatus==="error"||V.scheduleRunStatus==="aborted"),z=L?"border-amber-500":W?"border-red-500":$?"border-blue-500":"",ie=!!(L||W||$);return y.jsx("button",{ref:V.sessionId===t?_:void 0,onClick:()=>n(V.sessionId,V.title),className:ze("w-full text-left px-3 py-2.5 text-sm transition-colors hover:bg-accent/50 group",ie?`rounded-r-lg border-l-[3px] ${z}`:"rounded-lg",t===V.sessionId&&"bg-accent"),children:y.jsxs("div",{className:"flex items-start gap-2",children:[Hoe(V),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("span",{className:ze("block truncate text-sm leading-snug",$&&"font-semibold"),children:V.title||"New session"}),y.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[y.jsx("span",{className:"text-[10px] text-muted-foreground font-medium",children:Koe(V)||V.userName}),y.jsx("span",{className:"text-[10px] text-muted-foreground/50",children:"·"}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:Foe(V.lastModified)})]})]})]})},V.sessionId)}return y.jsxs("div",{className:"flex flex-col h-full bg-muted/30",children:[y.jsx("div",{className:"p-3",children:y.jsxs(we,{variant:"outline",size:"sm",className:"w-full gap-2 justify-start",onClick:r,title:"New Chat (Ctrl+N)",children:[y.jsx(ko,{className:"w-4 h-4"})," New Chat",y.jsx("span",{className:"ml-auto flex items-center gap-0.5 text-[10px] text-muted-foreground/50 font-mono",children:"⌃N"})]})}),y.jsx("div",{className:"border-b shrink-0 flex flex-col max-h-[40vh]",children:y.jsx(Bre,{getToken:e,onRefresh:s,refreshKey:a})}),y.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1",children:[y.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Chats"}),y.jsxs("div",{className:"flex gap-0.5",children:[["mine","all"].map(V=>y.jsx("button",{onClick:()=>k(V),className:ze("text-[10px] px-1.5 rounded-full transition-colors capitalize leading-none",m===V?"text-foreground font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:V},V)),y.jsxs("button",{onClick:O,className:ze("text-[10px] px-1.5 rounded-full transition-colors leading-none",g?"text-blue-600 dark:text-blue-400 font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:["unread",H>0&&y.jsx("span",{className:"inline-block w-1.5 h-1.5 ml-1 rounded-full bg-blue-500 align-middle"})]})]})]}),y.jsx(OL,{className:"flex-1",children:y.jsxs("div",{className:"px-2 pb-2 space-y-0.5",children:[P.length===0&&!G&&y.jsx("p",{className:"text-xs text-muted-foreground px-3 py-6 text-center",children:M?"Loading…":g?"No unread conversations":"No conversations yet"}),G&&K(G),P.map(K),!g&&C&&y.jsx("div",{ref:q,className:"py-3 text-center text-[11px] text-muted-foreground/60",children:M?"Loading older…":"···"})]})}),y.jsxs("div",{className:"px-4 py-2 flex flex-col items-center gap-1",children:[y.jsx(Toe,{socket:d??null,getToken:e}),(F=h.sidebarExtras)==null?void 0:F.call(h),x&&(U?y.jsxs("button",{onClick:()=>location.reload(),title:`This page was built from v${Of}, the server runs v${x} — reload to update`,className:"text-[10px] text-amber-400 hover:text-amber-300 text-center underline decoration-dotted",children:["⚠️ stale page (v",Of," → v",x,") · reload"]}):y.jsxs("div",{className:"text-[10px] text-muted-foreground/50 text-center",children:["v",x]}))]})]})}function ni(e,t){const n=e[e.length-1];if((n==null?void 0:n.role)==="assistant"){if(t.type==="text"||t.type==="thinking"){const r=[...n.blocks],i=r[r.length-1];return(i==null?void 0:i.type)===t.type?(r[r.length-1]={...i,text:i.text+t.text},[...e.slice(0,-1),{...n,blocks:r}]):[...e.slice(0,-1),{...n,blocks:[...r,t]}]}return[...e.slice(0,-1),{...n,blocks:[...n.blocks,t]}]}return[...e,{id:Ms(),role:"assistant",blocks:[t]}]}function uI(e,t,n="text"){const r=e[e.length-1],i={type:n,text:t};return(r==null?void 0:r.role)==="assistant"?[...e.slice(0,-1),{...r,blocks:[...r.blocks,i]}]:[...e,{id:Ms(),role:"assistant",blocks:[i]}]}function W$(e,t,n){for(let r=e.length-1;r>=0;r--){const i=e[r];if(i.role!=="assistant")continue;const a=i.blocks.findIndex(l=>l.type==="tool_use"&&l.toolUseId===t);if(a===-1)continue;const s=[...i.blocks];return s[a]={...s[a],input:n},[...e.slice(0,r),{...i,blocks:s},...e.slice(r+1)]}return e}function Voe(e,t){const[n,r]=b.useState([]),[i,a]=b.useState(!1),[s,l]=b.useState([]),u=b.useRef(t.initialSessionId),d=b.useRef(!1),h=b.useRef(s);h.current=s;const m=b.useRef(t.getToken);m.current=t.getToken;const p=b.useRef(t.onNewSession);p.current=t.onNewSession;const g=b.useRef(t.onDirectivesChanged);g.current=t.onDirectivesChanged;const w=b.useRef(t.onParticipantsChanged);w.current=t.onParticipantsChanged;const x=b.useRef(t.onEvent);x.current=t.onEvent;const E=b.useRef(e);E.current=e;const _=b.useCallback(P=>P!=null&&P===u.current,[]),k=b.useCallback(async()=>{var G;const P=u.current;if(P)try{const X=await(await Ll(`/api/sessions/${P}/messages`,m.current)).json();r(nL(X)),a(!!X.busy),(G=w.current)==null||G.call(w,Array.isArray(X.participants)&&X.participants.length>1)}catch{}},[]);b.useEffect(()=>{if(!e)return;const P=e.on(G=>{var X,U,K,F,V,$;(X=x.current)==null||X.call(x,G);const q=G;if(q.type==="compact_marker")return _(q.sessionId)?r(L=>[...L,{id:Ms(),role:"assistant",blocks:[{type:"compact_marker",summary:q.summary??"",compactedCount:q.compactedCount??0}]}]):void 0;switch(G.type){case"thinking_delta":return _(G.sessionId)?r(L=>ni(L,{type:"thinking",text:G.text})):void 0;case"text_delta":return _(G.sessionId)?r(L=>ni(L,{type:"text",text:G.text})):void 0;case"tool_use":return _(G.sessionId)?r(L=>ni(L,{type:"tool_use",tool:G.tool,toolUseId:G.toolUseId,input:G.input})):void 0;case"tool_use_input":return _(G.sessionId)?r(L=>W$(L,G.toolUseId,G.input)):void 0;case"tool_result":return _(G.sessionId)?r(L=>ni(L,{type:"tool_result",toolUseId:G.toolUseId,output:G.output})):void 0;case"tool_result_image":return _(G.sessionId)?r(L=>ni(L,{type:"image",src:G.dataUrl})):void 0;case"permission_request":return _(G.sessionId)?r(L=>ni(L,{type:"permission_request",id:G.id,tool:G.tool,input:G.input})):void 0;case"question_request":return _(G.sessionId)?r(L=>ni(L,{type:"question_request",id:G.id,questions:G.questions})):void 0;case"directives":return d.current?(U=g.current)==null?void 0:U.call(g,G.directives):void 0;case"session_id":return!d.current||u.current?void 0:(u.current=G.sessionId,(K=p.current)==null?void 0:K.call(p,G.sessionId));case"forked":return G.sourceSessionId!==u.current?void 0:(u.current=G.sessionId,(F=p.current)==null?void 0:F.call(p,G.sessionId));case"session_busy":G.sessionId===u.current&&a(G.busy);return;case"session_stream":return G.sessionId!==u.current?void 0:Woe(r,G.event);case"session_messages_changed":G.sessionId===u.current&&k();return;case"done":{if(G.sessionId!==u.current)return;G.stopReason==="max_turns_reached"&&r(W=>ni(W,{type:"text",text:`
|
|
1907
|
+
`)},Ere=0,ru=[];function Sre(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),i=b.useState(Ere++)[0],a=b.useState(dz)[0],s=b.useRef(e);b.useEffect(function(){s.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var x=R7([e.lockRef.current],(e.shards||[]).map(BM),!0).filter(Boolean);return x.forEach(function(E){return E.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),x.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=b.useCallback(function(x,E){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!s.current.allowPinchZoom;var _=kp(x),k=n.current,O="deltaX"in x?x.deltaX:k[0]-_[0],N="deltaY"in x?x.deltaY:k[1]-_[1],T,C=x.target,M=Math.abs(O)>Math.abs(N)?"h":"v";if("touches"in x&&M==="h"&&C.type==="range")return!1;var D=window.getSelection(),j=D&&D.anchorNode,R=j?j===C||j.contains(C):!1;if(R)return!1;var H=zM(M,C);if(!H)return!0;if(H?T=M:(T=M==="v"?"h":"v",H=zM(M,C)),!H)return!1;if(!r.current&&"changedTouches"in x&&(O||N)&&(r.current=T),!T)return!0;var P=r.current||T;return bre(P,E,x,P==="h"?O:N)},[]),u=b.useCallback(function(x){var E=x;if(!(!ru.length||ru[ru.length-1]!==a)){var _="deltaY"in E?$M(E):kp(E),k=t.current.filter(function(T){return T.name===E.type&&(T.target===E.target||E.target===T.shadowParent)&&xre(T.delta,_)})[0];if(k&&k.should){E.cancelable&&E.preventDefault();return}if(!k){var O=(s.current.shards||[]).map(BM).filter(Boolean).filter(function(T){return T.contains(E.target)}),N=O.length>0?l(E,O[0]):!s.current.noIsolation;N&&E.cancelable&&E.preventDefault()}}},[]),d=b.useCallback(function(x,E,_,k){var O={name:x,delta:E,target:_,should:k,shadowParent:_re(_)};t.current.push(O),setTimeout(function(){t.current=t.current.filter(function(N){return N!==O})},1)},[]),h=b.useCallback(function(x){n.current=kp(x),r.current=void 0},[]),m=b.useCallback(function(x){d(x.type,$M(x),x.target,l(x,e.lockRef.current))},[]),p=b.useCallback(function(x){d(x.type,kp(x),x.target,l(x,e.lockRef.current))},[]);b.useEffect(function(){return ru.push(a),e.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:p}),document.addEventListener("wheel",u,nu),document.addEventListener("touchmove",u,nu),document.addEventListener("touchstart",h,nu),function(){ru=ru.filter(function(x){return x!==a}),document.removeEventListener("wheel",u,nu),document.removeEventListener("touchmove",u,nu),document.removeEventListener("touchstart",h,nu)}},[]);var g=e.removeScrollBar,w=e.inert;return b.createElement(b.Fragment,null,w?b.createElement(a,{styles:wre(i)}):null,g?b.createElement(fre,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function _re(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Are=Jne(uz,Sre);var vS=b.forwardRef(function(e,t){return b.createElement(Yv,xa({},e,{ref:t,sideCar:Are}))});vS.classNames=Yv.classNames;var kre=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},iu=new WeakMap,Op=new WeakMap,Np={},zx=0,pz=function(e){return e&&(e.host||pz(e.parentNode))},Ore=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=pz(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Nre=function(e,t,n,r){var i=Ore(t,Array.isArray(e)?e:[e]);Np[n]||(Np[n]=new WeakMap);var a=Np[n],s=[],l=new Set,u=new Set(i),d=function(m){!m||l.has(m)||(l.add(m),d(m.parentNode))};i.forEach(d);var h=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(p){if(l.has(p))h(p);else try{var g=p.getAttribute(r),w=g!==null&&g!=="false",x=(iu.get(p)||0)+1,E=(a.get(p)||0)+1;iu.set(p,x),a.set(p,E),s.push(p),x===1&&w&&Op.set(p,!0),E===1&&p.setAttribute(n,"true"),w||p.setAttribute(r,"true")}catch(_){console.error("aria-hidden: cannot operate on ",p,_)}})};return h(t),l.clear(),zx++,function(){s.forEach(function(m){var p=iu.get(m)-1,g=a.get(m)-1;iu.set(m,p),a.set(m,g),p||(Op.has(m)||m.removeAttribute(r),Op.delete(m)),g||m.removeAttribute(n)}),zx--,zx||(iu=new WeakMap,iu=new WeakMap,Op=new WeakMap,Np={})}},gz=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=kre(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),Nre(r,i,n,"aria-hidden")):function(){return null}},Xv="Dialog",[vz]=hL(Xv),[Cre,Ji]=vz(Xv),yz=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,l=b.useRef(null),u=b.useRef(null),[d,h]=_ne({prop:r,defaultProp:i??!1,onChange:a,caller:Xv});return y.jsx(Cre,{scope:t,triggerRef:l,contentRef:u,contentId:Ix(),titleId:Ix(),descriptionId:Ix(),open:d,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(m=>!m),[h]),modal:s,children:n})};yz.displayName=Xv;var bz="DialogTrigger",xz=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(bz,n),a=ui(t,i.triggerRef);return y.jsx(Fr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":ES(i.open),...r,ref:a,onClick:Sr(e.onClick,i.onOpenToggle)})});xz.displayName=bz;var yS="DialogPortal",[Tre,wz]=vz(yS,{forceMount:void 0}),Ez=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Ji(yS,t);return y.jsx(Tre,{scope:t,forceMount:n,children:b.Children.map(r,s=>y.jsx(Zs,{present:n||a.open,children:y.jsx(lz,{asChild:!0,container:i,children:s})}))})};Ez.displayName=yS;var Pg="DialogOverlay",bS=b.forwardRef((e,t)=>{const n=wz(Pg,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ji(Pg,e.__scopeDialog);return a.modal?y.jsx(Zs,{present:r||a.open,children:y.jsx(Ire,{...i,ref:t})}):null});bS.displayName=Pg;var Mre=GE("DialogOverlay.RemoveScroll"),Ire=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(Pg,n),a=Ine(),s=ui(t,a);return y.jsx(vS,{as:Mre,allowPinchZoom:!0,shards:[i.contentRef],children:y.jsx(Fr.div,{"data-state":ES(i.open),...r,ref:s,style:{pointerEvents:"auto",...r.style}})})}),Uu="DialogContent",xS=b.forwardRef((e,t)=>{const n=wz(Uu,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Ji(Uu,e.__scopeDialog);return y.jsx(Zs,{present:r||a.open,children:a.modal?y.jsx(Rre,{...i,ref:t}):y.jsx(Pre,{...i,ref:t})})});xS.displayName=Uu;var Rre=b.forwardRef((e,t)=>{const n=Ji(Uu,e.__scopeDialog),r=b.useRef(null),i=ui(t,n.contentRef,r);return b.useEffect(()=>{const a=r.current;if(a)return gz(a)},[]),y.jsx(Sz,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Sr(e.onCloseAutoFocus,a=>{var s;a.preventDefault(),(s=n.triggerRef.current)==null||s.focus()}),onPointerDownOutside:Sr(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0;(s.button===2||l)&&a.preventDefault()}),onFocusOutside:Sr(e.onFocusOutside,a=>a.preventDefault())})}),Pre=b.forwardRef((e,t)=>{const n=Ji(Uu,e.__scopeDialog),r=b.useRef(!1),i=b.useRef(!1);return y.jsx(Sz,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var s,l;(s=e.onCloseAutoFocus)==null||s.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:a=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const s=a.target;((d=n.triggerRef.current)==null?void 0:d.contains(s))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),Sz=b.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...s}=e,l=Ji(Uu,n);return Kne(),y.jsx(y.Fragment,{children:y.jsx(oz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:y.jsx(iz,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":ES(l.open),...s,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),_z="DialogTitle",wS=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(_z,n);return y.jsx(Fr.h2,{id:i.titleId,...r,ref:t})});wS.displayName=_z;var Az="DialogDescription",Dre=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(Az,n);return y.jsx(Fr.p,{id:i.descriptionId,...r,ref:t})});Dre.displayName=Az;var kz="DialogClose",Oz=b.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Ji(kz,n);return y.jsx(Fr.button,{type:"button",...r,ref:t,onClick:Sr(e.onClick,()=>i.onOpenChange(!1))})});Oz.displayName=kz;function ES(e){return e?"open":"closed"}const Oo=yz,rd=xz,jre=Ez,Nz=b.forwardRef(({className:e,...t},n)=>y.jsx(bS,{ref:n,className:ze("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Nz.displayName=bS.displayName;const Na=b.forwardRef(({className:e,children:t,...n},r)=>y.jsxs(jre,{children:[y.jsx(Nz,{}),y.jsxs(xS,{ref:r,className:ze("fixed left-[50%] top-[50%] z-50 flex flex-col w-[calc(100vw-2rem)] max-w-lg max-h-[85dvh] overflow-y-auto translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-4 sm:p-6 shadow-lg 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 sm:rounded-lg",e),...n,children:[t,y.jsxs(Oz,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[y.jsx(Bs,{className:"h-4 w-4"}),y.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Na.displayName=xS.displayName;function Us({className:e,...t}){return y.jsx("div",{className:ze("shrink-0 flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Cz({className:e,...t}){return y.jsx("div",{"data-dialog-body":!0,className:ze("flex-1 min-h-0 overflow-y-auto -mx-4 px-4 sm:-mx-6 sm:px-6",e),...t})}function Tz({className:e,...t}){return y.jsx("div",{className:ze("shrink-0 -mx-4 px-4 pt-3 border-t sm:-mx-6 sm:px-6","flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t})}const No=b.forwardRef(({className:e,...t},n)=>y.jsx(wS,{ref:n,className:ze("text-lg font-semibold leading-none tracking-tight",e),...t}));No.displayName=wS.displayName;const Lre=new Set(["png","jpg","jpeg","gif","webp","svg","ico","bmp","avif"]),zre=new Set(["pdf","mp4","webm","mp3","ogg","wav"]);async function $re(e,t){const n=await t();if(!n)return[];const r=await fetch(`/api/workspace/ls?path=${encodeURIComponent(e)}`,{headers:{Authorization:`Bearer ${n}`}});return r.ok?(await r.json()).entries??[]:[]}function Bre({getToken:e,onRefresh:t,refreshKey:n}){const[r,i]=b.useState(new Map),[a,s]=b.useState(()=>new Set),[l,u]=b.useState(null),[d,h]=b.useState(!1),[m,p]=b.useState("fit"),[g,w]=b.useState(null),[x,E]=b.useState(null),_=b.useRef(null),[k,O]=b.useState(null),[N,T]=b.useState(!1),[C,M]=b.useState([]),D=b.useCallback(async U=>{const K=await $re(U,e);i(F=>new Map(F).set(U,K))},[e]);b.useEffect(()=>{D(""),a.forEach(U=>D(U))},[D,n]);const j=r.get("")??[],R=b.useCallback(U=>{try{const K=U.contentDocument;if(!(K!=null&&K.body))return;const F=Math.max(K.body.offsetWidth,K.body.scrollWidth),V=Math.max(K.body.offsetHeight,K.body.scrollHeight);F&&V&&E({w:F,h:V})}catch{}},[]),H=b.useCallback(()=>{const U=_.current,K=x;if(!U||!K)return;const F=16,V=U.clientWidth-F,$=U.clientHeight-F,L=Math.min(V/K.w,$/K.h,1);w({scale:L,w:K.w,h:K.h})},[x]);b.useEffect(()=>{if(!(l!=null&&l.html)||m!=="fit"){w(null);return}const U=_.current;if(!U)return;const K=new ResizeObserver(()=>requestAnimationFrame(H));return K.observe(U),()=>K.disconnect()},[l==null?void 0:l.html,d,m,H]),b.useEffect(()=>{N&&e().then(U=>{U&&fetch("/api/data-sync/log",{headers:{Authorization:`Bearer ${U}`}}).then(K=>K.json()).then(M).catch(()=>{})})},[N]);const P=U=>{s(K=>{const F=new Set(K);return F.has(U)?F.delete(U):(F.add(U),r.has(U)||D(U)),F})},G=(U,K)=>{const F=new URLSearchParams({path:U});return k&&F.set("token",k),K&&F.set("dl","1"),`/api/workspace/raw?${F}`},q=async U=>{var V;const K=await e();if(!K)return;O(K);const F=((V=U.split(".").pop())==null?void 0:V.toLowerCase())??"";if(F==="html"||F==="htm"){u({path:U,content:"",binary:!1,html:!0});return}if(Lre.has(F)){u({path:U,content:"",binary:!1,image:!0});return}if(zre.has(F)){u({path:U,content:"",binary:!1,html:!0});return}try{const $=await fetch(`/api/workspace/file?path=${encodeURIComponent(U)}`,{headers:{Authorization:`Bearer ${K}`}});if(!$.ok)return;const L=await $.json();u({path:U,content:L.content,binary:!!L.binary})}catch{}},X=(U,K)=>y.jsx(y.Fragment,{children:U.map(F=>{const V=F.path.split("/").pop();return y.jsxs("div",{children:[F.type==="dir"?y.jsxs("button",{onClick:()=>P(F.path),className:"w-full flex items-center gap-1 px-2 py-1 rounded hover:bg-accent/50 text-left text-sm",style:{paddingLeft:8+K*12},children:[y.jsx(Xs,{className:ze("w-3 h-3 shrink-0 transition-transform",a.has(F.path)&&"rotate-90")}),y.jsx(JG,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),y.jsx("span",{className:"truncate",children:V})]}):y.jsxs("button",{onClick:()=>q(F.path),className:"w-full flex items-center gap-1 px-2 py-1 rounded hover:bg-accent/50 text-left text-sm",style:{paddingLeft:8+K*12+12},title:F.oneLiner||F.path,children:[y.jsx(UE,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),y.jsx("span",{className:"truncate",children:V})]}),F.type==="dir"&&a.has(F.path)&&X(r.get(F.path)??[],K+1)]},F.path)})});return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1 shrink-0",children:[y.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Workspace"}),y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx("button",{onClick:()=>T(!0),className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Activity log",children:y.jsx(tV,{className:"w-3 h-3"})}),y.jsx("button",{onClick:()=>{D(""),a.forEach(U=>D(U)),t==null||t()},className:"p-0.5 rounded hover:bg-accent text-muted-foreground",title:"Refresh",children:y.jsx(ed,{className:"w-3 h-3"})})]})]}),y.jsx("div",{className:"px-1 pb-2 overflow-y-auto min-h-0",children:j.length===0?y.jsx("p",{className:"text-xs text-muted-foreground px-3 py-2",children:"Empty. Drop .md files into data/workspace/ or ask the agent to create some."}):X(j,0)}),y.jsx(Oo,{open:!!l,onOpenChange:U=>{U||(u(null),h(!1),p("fit"),E(null))},children:y.jsxs(Na,{className:ze(l!=null&&l.html?ze("!flex !flex-col !p-0 !gap-0 overflow-hidden",d?"max-w-none w-[100vw] h-[100vh] rounded-none border-0":"max-w-[90vw] w-[90vw] h-[85vh]"):"max-w-3xl max-h-[80vh] !flex !flex-col overflow-hidden"),children:[y.jsxs("div",{className:"absolute right-12 top-4 flex items-center gap-1.5 z-10",children:[(l==null?void 0:l.html)&&y.jsxs(y.Fragment,{children:[y.jsx("button",{onClick:()=>p(U=>U==="fit"?"scroll":"fit"),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:m==="fit"?"Switch to scrollable (1:1)":"Switch to scale-to-fit",children:m==="fit"?y.jsx(oV,{className:"w-4 h-4"}):y.jsx(fV,{className:"w-4 h-4"})}),y.jsx("button",{onClick:()=>h(U=>!U),className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:d?"Restore":"Maximize",children:d?y.jsx(HE,{className:"w-4 h-4"}):y.jsx(FE,{className:"w-4 h-4"})})]}),l&&y.jsx("a",{href:G(l.path,!0),download:!0,className:"rounded-sm opacity-70 hover:opacity-100 text-muted-foreground",title:"Download",children:y.jsx(lL,{className:"w-4 h-4"})})]}),y.jsx(Us,{className:ze((l==null?void 0:l.html)&&"px-4 py-3 shrink-0 border-b"),children:y.jsx(No,{className:"font-mono text-sm truncate pr-16",children:l==null?void 0:l.path})}),y.jsx("div",{ref:l!=null&&l.html?_:void 0,className:ze(l!=null&&l.html?ze("flex-1 min-h-0 bg-muted/10",m==="fit"?"overflow-hidden flex items-center justify-center":"overflow-auto"):"flex-1 min-h-0 overflow-y-auto"),children:l!=null&&l.html?m==="fit"?y.jsx("div",{style:g?{width:g.w*g.scale,height:g.h*g.scale}:{width:"100%",height:"100%"},children:y.jsx("iframe",{src:G(l.path),className:"border-0 bg-white origin-top-left",title:l.path,onLoad:U=>{R(U.currentTarget),H()},style:g?{width:g.w,height:g.h,transform:`scale(${g.scale})`}:{width:"100%",height:"100%"}})}):y.jsx("iframe",{src:G(l.path),className:"border-0 bg-white mx-auto block",title:l.path,onLoad:U=>R(U.currentTarget),style:{width:(x==null?void 0:x.w)||"100%",height:(x==null?void 0:x.h)||"100%"}}):l!=null&&l.image?y.jsx("div",{className:"flex items-center justify-center p-4",children:y.jsx("img",{src:G(l.path),alt:l.path,className:"max-w-full max-h-[70vh] object-contain"})}):l!=null&&l.binary?y.jsx("p",{className:"text-sm text-muted-foreground",children:"(binary file — preview unavailable)"}):l!=null&&l.path.toLowerCase().endsWith(".md")||l!=null&&l.path.toLowerCase().endsWith(".markdown")?y.jsx("div",{className:"text-sm",children:y.jsx(d3,{remarkPlugins:[D3],rehypePlugins:[rz],className:"prose prose-sm max-w-none dark:prose-invert prose-pre:bg-muted prose-pre:border prose-code:before:content-none prose-code:after:content-none",children:l.content})}):y.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l==null?void 0:l.content})})]})}),y.jsx(Oo,{open:N,onOpenChange:T,children:y.jsxs(Na,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[y.jsx(Us,{children:y.jsx(No,{className:"text-sm",children:"Activity Log"})}),y.jsxs("div",{className:"overflow-y-auto flex-1 space-y-2",children:[C.map(U=>y.jsxs("div",{className:"border-b border-border/50 pb-2 last:border-0",children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[y.jsx("span",{className:"text-sm text-foreground",children:U.message}),y.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:Ure(U.date)})]}),U.files.length>0&&y.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:U.files.map(K=>y.jsx("span",{className:"inline-block mr-2 font-mono",children:K},K))})]},U.hash)),C.length===0&&y.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No activity yet"})]})]})})]})}function Ure(e){const t=new Date(e),r=new Date().getTime()-t.getTime(),i=Math.floor(r/6e4);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ag(e,t=Date.now()){if(!e)return null;const n=new Date(e).getTime()-t;if(!Number.isFinite(n)||n<=0)return null;const r=Math.round(n/6e4);if(r<1)return"1m";if(r<60)return`${r}m`;const i=Math.floor(r/60),a=r%60;if(i<48)return a?`${i}h ${a}m`:`${i}h`;const s=Math.floor(i/24),l=i%24;return l?`${s}d ${l}h`:`${s}d`}const Fre=/resets\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\s*\(UTC\)/i;function Hre(e,t=Date.now(),n=Date.now()){var m;const r=e.match(Fre);if(!r)return e;let i=Number(r[1]);const a=r[2]?Number(r[2]):0,s=(m=r[3])==null?void 0:m.toLowerCase();if(s==="pm"&&i<12&&(i+=12),s==="am"&&i===12&&(i=0),i>23||a>59)return e;const l=new Date(t),u=new Date(Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate(),i,a));u.getTime()<=t&&u.setUTCDate(u.getUTCDate()+1);const d=u.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}),h=ag(u.toISOString(),n);return e.replace(r[0],`resets ${d}${h?` (in ${h})`:""}`)}var Kre=Object.defineProperty,id=(e,t)=>Kre(e,"name",{value:t,configurable:!0}),Mz=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ds(e,t,{checkForDefaultPrevented:n=!0}={}){return id(function(i){if(e==null||e(i),n===!1||!i||!i.defaultPrevented)return t==null?void 0:t(i)},"handleEvent")}id(Ds,"composeEventHandlers");function qre(e){var t;if(!Mz)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}id(qre,"getOwnerWindow");function l1(e){if(!Mz)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}id(l1,"getOwnerDocument");function Iz(e,t=!1){const{activeElement:n}=l1(e);if(!(n!=null&&n.nodeName))return null;if(Rz(n)&&n.contentDocument)return Iz(n.contentDocument.body,t);if(t){const r=n.getAttribute("aria-activedescendant");if(r){const i=l1(n).getElementById(r);if(i)return i}}return n}id(Iz,"getActiveElement");function Rz(e){return e.tagName==="IFRAME"}id(Rz,"isFrame");var Gre=Object.defineProperty,SS=(e,t)=>Gre(e,"name",{value:t,configurable:!0});function c1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}SS(c1,"setRef");function Pz(...e){return t=>{let n=!1;const r=e.map(i=>{const a=c1(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():c1(e[i],null)}}}}SS(Pz,"composeRefs");function ad(...e){return b.useCallback(Pz(...e),e)}SS(ad,"useComposedRefs");var Vre=Object.defineProperty,Ni=(e,t)=>Vre(e,"name",{value:t,configurable:!0});function Wre(e,t){const n=b.createContext(t);n.displayName=e+"Context";const r=Ni(a=>{const{children:s,...l}=a,u=b.useMemo(()=>l,Object.values(l));return y.jsx(n.Provider,{value:u,children:s})},"Provider");r.displayName=e+"Provider";function i(a,s={}){const{optional:l=!1}=s,u=b.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return Ni(i,"useContext"),[r,i]}Ni(Wre,"createContext");function Dz(e,t=[]){let n=[];function r(a,s){const l=b.createContext(s);l.displayName=a+"Context";const u=n.length;n=[...n,s];const d=Ni(m=>{var _;const{scope:p,children:g,...w}=m,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useMemo(()=>w,Object.values(w));return y.jsx(x.Provider,{value:E,children:g})},"Provider");d.displayName=a+"Provider";function h(m,p,g={}){var _;const{optional:w=!1}=g,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useContext(x);if(E)return E;if(s!==void 0)return s;if(!w)throw new Error(`\`${m}\` must be used within \`${a}\``)}return Ni(h,"useContext"),[d,h]}Ni(r,"createContext");const i=Ni(()=>{const a=n.map(s=>b.createContext(s));return Ni(function(l){const u=(l==null?void 0:l[e])||a;return b.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,jz(i,...t)]}Ni(Dz,"createContextScope");function jz(...e){const t=e[0];if(e.length===1)return t;const n=Ni(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Ni(function(a){const s=r.reduce((l,{useScope:u,scopeName:d})=>{const m=u(a)[`__scope${d}`];return{...l,...m}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Ni(jz,"composeContextScopes");var Yre=Object.defineProperty,ea=(e,t)=>Yre(e,"name",{value:t,configurable:!0});function _S(e){const t=b.forwardRef((n,r)=>{let{children:i,...a}=n,s=null,l=!1;const u=[];u1(i)&&typeof Cp=="function"&&(i=Cp(i._payload)),b.Children.forEach(i,p=>{var g;if(Bz(p)){l=!0;const w=p;let x="child"in w.props?w.props.child:w.props.children;u1(x)&&typeof Cp=="function"&&(x=Cp(x._payload)),s=Zre(w,x),u.push((g=s==null?void 0:s.props)==null?void 0:g.children)}else u.push(p)}),s?s=b.cloneElement(s,void 0,u):!l&&b.Children.count(i)===1&&b.isValidElement(i)&&(s=i);const d=s?$z(s):void 0,h=ad(r,d);if(!s){if(i||i===0)throw new Error(l?eie(e):Jre(e));return i}const m=zz(a,s.props??{});return s.type!==b.Fragment&&(m.ref=r?h:d),b.cloneElement(s,m)});return t.displayName=`${e}.Slot`,t}ea(_S,"createSlot");var Lz=Symbol.for("radix.slottable");function Xre(e){const t=ea(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=Lz,t}ea(Xre,"createSlottable");var Zre=ea((e,t)=>{if("child"in e.props){const n=e.props.child;return b.isValidElement(n)?b.cloneElement(n,void 0,e.props.children(n.props.children)):null}return b.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function zz(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...l)=>{const u=a(...l);return i(...l),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}ea(zz,"mergeProps");function $z(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ea($z,"getElementRef");function Bz(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Lz}ea(Bz,"isSlottable");var Qre=Symbol.for("react.lazy");function u1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Qre&&"_payload"in e&&Uz(e._payload)}ea(u1,"isLazyComponent");function Uz(e){return typeof e=="object"&&e!==null&&"then"in e}ea(Uz,"isPromiseLike");var Jre=ea(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),eie=ea(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Cp=ja[" use ".trim().toString()],tie=Object.defineProperty,nie=(e,t)=>tie(e,"name",{value:t,configurable:!0}),rie=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Zv=rie.reduce((e,t)=>{const n=_S(`Primitive.${t}`),r=b.forwardRef((i,a)=>{const{asChild:s,...l}=i,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Fz(e,t){e&&La.flushSync(()=>e.dispatchEvent(t))}nie(Fz,"dispatchDiscreteCustomEvent");var iie=Object.defineProperty,aie=(e,t)=>iie(e,"name",{value:t,configurable:!0});function Qv(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}aie(Qv,"useCallbackRef");var oie=Object.defineProperty,qn=(e,t)=>oie(e,"name",{value:t,configurable:!0}),d1="dismissableLayer.update",sie="dismissableLayer.pointerDownOutside",lie="dismissableLayer.focusOutside",UM,Hz=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),cie=b.forwardRef(qn(function(t,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:l,onInteractOutside:u,onDismiss:d,...h}=t,m=b.useContext(Hz),[p,g]=b.useState(null),w=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=b.useState({}),E=ad(n,g),_=Array.from(m.layers),[k]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),O=k?_.indexOf(k):-1,N=p?_.indexOf(p):-1,T=m.layersWithOutsidePointerEventsDisabled.size>0,C=N>=O,M=b.useRef(!1),D=Kz(P=>{s==null||s(P),u==null||u(P),P.defaultPrevented||d==null||d()},{ownerDocument:w,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:M,dismissableSurfaces:m.dismissableSurfaces,shouldHandlePointerDownOutside:b.useCallback(P=>{if(!(P instanceof Node))return!1;const G=[...m.branches].some(q=>q.contains(P));return C&&!G},[m.branches,C])}),j=qz(P=>{if(i&&M.current)return;const G=P.target;[...m.branches].some(X=>X.contains(G))||(l==null||l(P),u==null||u(P),P.defaultPrevented||d==null||d())},w),R=p?N===_.length-1:!1,H=Qv(P=>{P.key==="Escape"&&(a==null||a(P),!P.defaultPrevented&&d&&(P.preventDefault(),d()))});return b.useEffect(()=>{if(R)return w.addEventListener("keydown",H,{capture:!0}),()=>w.removeEventListener("keydown",H,{capture:!0})},[w,R,H]),b.useEffect(()=>{if(p)return r&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(UM=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(p)),m.layers.add(p),f1(),()=>{r&&(m.layersWithOutsidePointerEventsDisabled.delete(p),m.layersWithOutsidePointerEventsDisabled.size===0&&(w.body.style.pointerEvents=UM))}},[p,w,r,m]),b.useEffect(()=>()=>{p&&(m.layers.delete(p),m.layersWithOutsidePointerEventsDisabled.delete(p),f1())},[p,m]),b.useEffect(()=>{const P=qn(()=>x({}),"handleUpdate");return document.addEventListener(d1,P),()=>document.removeEventListener(d1,P)},[]),y.jsx(Zv.div,{...h,ref:E,style:{pointerEvents:T?C?"auto":"none":void 0,...t.style},onFocusCapture:Ds(t.onFocusCapture,j.onFocusCapture),onBlurCapture:Ds(t.onBlurCapture,j.onBlurCapture),onPointerDownCapture:Ds(t.onPointerDownCapture,D.onPointerDownCapture)})},"DismissableLayer"));function uie(){const e=b.useContext(Hz),[t,n]=b.useState(null);return b.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}qn(uie,"useDismissableLayerSurface");var die=qn(()=>!0,"IS_TRUE");function Kz(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:s=die}=t,l=Qv(e),u=b.useRef(!1),d=b.useRef(!1),h=b.useRef(new Map),m=b.useRef(()=>{});return b.useEffect(()=>{function p(){d.current=!1,i.current=!1,h.current.clear()}qn(p,"resetOutsideInteraction");function g(){return Array.from(h.current.values()).some(Boolean)}qn(g,"isOutsideInteractionIntercepted");function w(O){if(!d.current)return;const N=O.target;N instanceof Node&&[...a].some(C=>C.contains(N))||h.current.set(O.type,!0),O.type==="click"&&window.setTimeout(()=>{d.current&&m.current()},0)}qn(w,"handleInteractionCapture");function x(O){d.current&&h.current.set(O.type,!1)}qn(x,"handleInteractionBubble");const E=qn(O=>{if(O.target&&!u.current){let N=function(){n.removeEventListener("click",m.current);const C=g();p(),C||AS(sie,l,T,{discrete:!0})};if(qn(N,"handleAndDispatchPointerDownOutsideEvent"),!s(O.target)){n.removeEventListener("click",m.current),p(),u.current=!1;return}const T={originalEvent:O};d.current=!0,i.current=r&&O.button===0,h.current.clear(),!r||O.button!==0?N():(n.removeEventListener("click",m.current),m.current=N,n.addEventListener("click",m.current,{once:!0}))}else n.removeEventListener("click",m.current),p();u.current=!1},"handlePointerDown"),_=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const O of _)n.addEventListener(O,w,!0),n.addEventListener(O,x);const k=window.setTimeout(()=>{n.addEventListener("pointerdown",E)},0);return()=>{window.clearTimeout(k),n.removeEventListener("pointerdown",E),n.removeEventListener("click",m.current);for(const O of _)n.removeEventListener(O,w,!0),n.removeEventListener(O,x)}},[n,l,r,i,a,s]),{onPointerDownCapture:qn(()=>u.current=!0,"onPointerDownCapture")}}qn(Kz,"usePointerDownOutside");function qz(e,t=globalThis==null?void 0:globalThis.document){const n=Qv(e),r=b.useRef(!1);return b.useEffect(()=>{const i=qn(a=>{a.target&&!r.current&&AS(lie,n,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:qn(()=>r.current=!0,"onFocusCapture"),onBlurCapture:qn(()=>r.current=!1,"onBlurCapture")}}qn(qz,"useFocusOutside");function f1(){const e=new CustomEvent(d1);document.dispatchEvent(e)}qn(f1,"dispatchUpdate");function AS(e,t,n,{discrete:r}){const i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Fz(i,a):i.dispatchEvent(a)}qn(AS,"handleAndDispatchCustomEvent");var fie=Object.defineProperty,kS=(e,t)=>fie(e,"name",{value:t,configurable:!0}),Tp=0,da=null;function hie(e){return OS(),e.children}kS(hie,"FocusGuards");function OS(){b.useEffect(()=>{da||(da={start:h1(),end:h1()});const{start:e,end:t}=da;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Tp++,()=>{Tp===1&&(da==null||da.start.remove(),da==null||da.end.remove(),da=null),Tp=Math.max(0,Tp-1)}},[])}kS(OS,"useFocusGuards");function h1(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}kS(h1,"createFocusGuard");var mie=Object.defineProperty,pie=(e,t)=>mie(e,"name",{value:t,configurable:!0});function m1(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}pie(m1,"useCallbackRef");var gie=Object.defineProperty,xr=(e,t)=>gie(e,"name",{value:t,configurable:!0}),$x="focusScope.autoFocusOnMount",Bx="focusScope.autoFocusOnUnmount",FM={bubbles:!1,cancelable:!0},vie=b.forwardRef(xr(function(t,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:s,...l}=t,[u,d]=b.useState(null),h=m1(a),m=m1(s),p=b.useRef(null),g=ad(n,d),w=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(i){let E=function(N){if(w.paused||!u)return;const T=N.target;u.contains(T)?p.current=T:uo(p.current,{select:!0})},_=function(N){if(w.paused||!u)return;const T=N.relatedTarget;T!==null&&(u.contains(T)||uo(p.current,{select:!0}))},k=function(N){if(document.activeElement===document.body)for(const C of N)C.removedNodes.length>0&&uo(u)};xr(E,"handleFocusIn"),xr(_,"handleFocusOut"),xr(k,"handleMutations"),document.addEventListener("focusin",E),document.addEventListener("focusout",_);const O=new MutationObserver(k);return u&&O.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",_),O.disconnect()}}},[i,u,w.paused]),b.useEffect(()=>{if(u){HM.add(w);const E=document.activeElement;if(!u.contains(E)){const k=new CustomEvent($x,FM);u.addEventListener($x,h),u.dispatchEvent(k),k.defaultPrevented||(Gz(Zz(NS(u)),{select:!0}),document.activeElement===E&&uo(u))}return()=>{u.removeEventListener($x,h),setTimeout(()=>{const k=new CustomEvent(Bx,FM);u.addEventListener(Bx,m),u.dispatchEvent(k),k.defaultPrevented||uo(E??document.body,{select:!0}),u.removeEventListener(Bx,m),HM.remove(w)},0)}}},[u,h,m,w]);const x=b.useCallback(E=>{if(!r&&!i||w.paused)return;const _=E.key==="Tab"&&!E.altKey&&!E.ctrlKey&&!E.metaKey,k=document.activeElement;if(_&&k){const O=E.currentTarget,[N,T]=Vz(O);N&&T?!E.shiftKey&&k===T?(E.preventDefault(),r&&uo(N,{select:!0})):E.shiftKey&&k===N&&(E.preventDefault(),r&&uo(T,{select:!0})):k===O&&E.preventDefault()}},[r,i,w.paused]);return y.jsx(Zv.div,{tabIndex:-1,...l,ref:g,onKeyDown:x})},"FocusScope"));function Gz(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(uo(r,{select:t}),document.activeElement!==n)return}xr(Gz,"focusFirst");function Vz(e){const t=NS(e),n=p1(t,e),r=p1(t.reverse(),e);return[n,r]}xr(Vz,"getTabbableEdges");function NS(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:xr(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}xr(NS,"getTabbableCandidates");function p1(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Wz(r,{upTo:t})))return r}xr(p1,"findVisible");function Wz(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}xr(Wz,"isHidden");function Yz(e){return e instanceof HTMLInputElement&&"select"in e}xr(Yz,"isSelectableInput");function uo(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Yz(e)&&t&&e.select()}}xr(uo,"focus");var HM=Xz();function Xz(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=g1(e,t),e.unshift(t)},remove(t){var n;e=g1(e,t),(n=e[0])==null||n.resume()}}}xr(Xz,"createFocusScopesStack");function g1(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}xr(g1,"arrayRemove");function Zz(e){return e.filter(t=>t.tagName!=="A")}xr(Zz,"removeLinks");var yie=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},bie=Object.defineProperty,xie=(e,t)=>bie(e,"name",{value:t,configurable:!0}),wie=ja[" useId ".trim().toString()]||(()=>{}),Eie=0;function Qz(e){const[t,n]=b.useState(wie());return yie(()=>{e||n(r=>r??String(Eie++))},[e]),e||(t?`radix-${t}`:"")}xie(Qz,"useId");const Sie=["top","right","bottom","left"],Fs=Math.min,xo=Math.max,Dg=Math.round,Mp=Math.floor,wo=e=>({x:e,y:e}),_ie={left:"right",right:"left",bottom:"top",top:"bottom"};function Jz(e,t,n){return xo(e,Fs(t,n))}function Co(e,t){return typeof e=="function"?e(t):e}function Hs(e){return e.split("-")[0]}function od(e){return e.split("-")[1]}function CS(e){return e==="x"?"y":"x"}function TS(e){return e==="y"?"height":"width"}function wa(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function MS(e){return CS(wa(e))}function Aie(e,t,n){n===void 0&&(n=!1);const r=od(e),i=MS(e),a=TS(i);let s=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(s=jg(s)),[s,jg(s)]}function kie(e){const t=jg(e);return[v1(e),t,v1(t)]}function v1(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const KM=["left","right"],qM=["right","left"],Oie=["top","bottom"],Nie=["bottom","top"];function Cie(e,t,n){switch(e){case"top":case"bottom":return n?t?qM:KM:t?KM:qM;case"left":case"right":return t?Oie:Nie;default:return[]}}function Tie(e,t,n,r){const i=od(e);let a=Cie(Hs(e),n==="start",r);return i&&(a=a.map(s=>s+"-"+i),t&&(a=a.concat(a.map(v1)))),a}function jg(e){const t=Hs(e);return _ie[t]+e.slice(t.length)}function Mie(e){var t,n,r,i;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(i=e.left)!=null?i:0}}function e$(e){return typeof e!="number"?Mie(e):{top:e,right:e,bottom:e,left:e}}function Lg(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 GM(e,t,n){let{reference:r,floating:i}=e;const a=wa(t),s=MS(t),l=TS(s),u=Hs(t),d=a==="y",h=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,p=r[l]/2-i[l]/2;let g;switch(u){case"top":g={x:h,y:r.y-i.height};break;case"bottom":g={x:h,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:m};break;case"left":g={x:r.x-i.width,y:m};break;default:g={x:r.x,y:r.y}}const w=od(t);return w&&(g[s]+=p*(w==="end"?1:-1)*(n&&d?-1:1)),g}async function Iie(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:a,rects:s,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:m="floating",altBoundary:p=!1,padding:g=0}=Co(t,e),w=e$(g),E=l[p?m==="floating"?"reference":"floating":m],_=Lg(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(E)))==null||n?E:E.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:u})),k=m==="floating"?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,O=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),N=await(a.isElement==null?void 0:a.isElement(O))&&await(a.getScale==null?void 0:a.getScale(O))||{x:1,y:1},T=Lg(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:O,strategy:u}):k);return{top:(_.top-T.top+w.top)/N.y,bottom:(T.bottom-_.bottom+w.bottom)/N.y,left:(_.left-T.left+w.left)/N.x,right:(T.right-_.right+w.right)/N.x}}const Rie=50,Pie=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:a=[],platform:s}=n,l=s.detectOverflow?s:{...s,detectOverflow:Iie},u=await(s.isRTL==null?void 0:s.isRTL(t));let d=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:h,y:m}=GM(d,r,u),p=r,g=0;const w={};for(let x=0;x<a.length;x++){const E=a[x];if(!E)continue;const{name:_,fn:k}=E,{x:O,y:N,data:T,reset:C}=await k({x:h,y:m,initialPlacement:r,placement:p,strategy:i,middlewareData:w,rects:d,platform:l,elements:{reference:e,floating:t}});h=O??h,m=N??m,w[_]={...w[_],...T},C&&g<Rie&&(g++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(d=C.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:h,y:m}=GM(d,p,u)),x=-1)}return{x:h,y:m,placement:p,strategy:i,middlewareData:w}},Die=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:a,platform:s,elements:l,middlewareData:u}=t,{element:d,padding:h=0}=Co(e,t)||{};if(d==null)return{};const m=e$(h),p={x:n,y:r},g=MS(i),w=TS(g),x=await s.getDimensions(d),E=g==="y",_=E?"top":"left",k=E?"bottom":"right",O=E?"clientHeight":"clientWidth",N=a.reference[w]+a.reference[g]-p[g]-a.floating[w],T=p[g]-a.reference[g],C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d));let M=C?C[O]:0;(!M||!await(s.isElement==null?void 0:s.isElement(C)))&&(M=l.floating[O]||a.floating[w]);const D=N/2-T/2,j=M/2-x[w]/2-1,R=Fs(m[_],j),H=Fs(m[k],j),P=M-x[w]-H,G=M/2-x[w]/2+D,q=Jz(R,G,P),X=!u.arrow&&od(i)!=null&&G!==q&&a.reference[w]/2-(G<R?R:H)-x[w]/2<0,U=X?G<R?G-R:G-P:0;return{[g]:p[g]+U,data:{[g]:q,centerOffset:G-q-U,...X&&{alignmentOffset:U}},reset:X}}}),jie=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:a,rects:s,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:h=!0,crossAxis:m=!0,fallbackPlacements:p,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:x=!0,...E}=Co(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const _=Hs(i),k=wa(l),O=Hs(l)===l,N=await(u.isRTL==null?void 0:u.isRTL(d.floating)),T=p||(O||!x?[jg(l)]:kie(l)),C=w!=="none";!p&&C&&T.push(...Tie(l,x,w,N));const M=[l,...T],D=await u.detectOverflow(t,E),j=[];let R=((r=a.flip)==null?void 0:r.overflows)||[];if(h&&j.push(D[_]),m){const q=Aie(i,s,N);j.push(D[q[0]],D[q[1]])}if(R=[...R,{placement:i,overflows:j}],!j.every(q=>q<=0)){var H,P;const q=(((H=a.flip)==null?void 0:H.index)||0)+1,X=M[q];if(X&&(!(m==="alignment"?k!==wa(X):!1)||R.every(F=>wa(F.placement)===k?F.overflows[0]>0:!0)))return{data:{index:q,overflows:R},reset:{placement:X}};let U=(P=R.filter(K=>K.overflows[0]<=0).sort((K,F)=>K.overflows[1]-F.overflows[1])[0])==null?void 0:P.placement;if(!U)switch(g){case"bestFit":{var G;const K=(G=R.filter(F=>{if(C){const V=wa(F.placement);return V===k||V==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(V=>V>0).reduce((V,$)=>V+$,0)]).sort((F,V)=>F[1]-V[1])[0])==null?void 0:G[0];K&&(U=K);break}case"initialPlacement":U=l;break}if(i!==U)return{reset:{placement:U}}}return{}}}};function VM(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function WM(e){return Sie.some(t=>e[t]>=0)}const Lie=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...a}=Co(e,t);switch(i){case"referenceHidden":{const s=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=VM(s,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:WM(l)}}}case"escaped":{const s=await r.detectOverflow(t,{...a,altBoundary:!0}),l=VM(s,n.floating);return{data:{escapedOffsets:l,escaped:WM(l)}}}default:return{}}}}},t$=new Set(["left","top"]);async function zie(e,t){const{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),s=Hs(n),l=od(n),u=wa(n)==="y",d=t$.has(s)?-1:1,h=a&&u?-1:1,m=Co(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:w}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return l&&typeof w=="number"&&(g=l==="end"?w*-1:w),u?{x:g*h,y:p*d}:{x:p*d,y:g*h}}const $ie=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:a,placement:s,middlewareData:l}=t,u=await zie(t,e);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:a+u.y,data:{...u,placement:s}}}}},Bie=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:a}=t,{mainAxis:s=!0,crossAxis:l=!1,limiter:u={fn:k=>{let{x:O,y:N}=k;return{x:O,y:N}}},...d}=Co(e,t),h={x:n,y:r},m=await a.detectOverflow(t,d),p=wa(i),g=CS(p);let w=h[g],x=h[p];const E=(k,O)=>Jz(O+m[k==="y"?"top":"left"],O,O-m[k==="y"?"bottom":"right"]);s&&(w=E(g,w)),l&&(x=E(p,x));const _=u.fn({...t,[g]:w,[p]:x});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[g]:s,[p]:l}}}}}},Uie=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;const{x:i,y:a,placement:s,rects:l,middlewareData:u}=t,{offset:d=0,mainAxis:h=!0,crossAxis:m=!0}=Co(e,t),p={x:i,y:a},g=wa(s),w=CS(g);let x=p[w],E=p[g];const _=Co(d,t),k=typeof _=="number"?{mainAxis:_,crossAxis:0}:{mainAxis:(n=_.mainAxis)!=null?n:0,crossAxis:(r=_.crossAxis)!=null?r:0};if(h){const T=w==="y"?"height":"width",C=l.reference[w]-l.floating[T]+k.mainAxis,M=l.reference[w]+l.reference[T]-k.mainAxis;x<C?x=C:x>M&&(x=M)}if(m){var O,N;const T=w==="y"?"width":"height",C=t$.has(Hs(s)),M=l.reference[g]-l.floating[T]+(C&&((O=u.offset)==null?void 0:O[g])||0)+(C?0:k.crossAxis),D=l.reference[g]+l.reference[T]+(C?0:((N=u.offset)==null?void 0:N[g])||0)-(C?k.crossAxis:0);E<M?E=M:E>D&&(E=D)}return{[w]:x,[g]:E}}}},Fie=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:n,rects:r,platform:i,elements:a}=t,{apply:s=()=>{},...l}=Co(e,t),u=await i.detectOverflow(t,l),d=Hs(n),h=od(n),m=wa(n)==="y",{width:p,height:g}=r.floating;let w,x;d==="top"||d==="bottom"?(w=d,x=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,w=h==="end"?"top":"bottom");const E=g-u.top-u.bottom,_=p-u.left-u.right,k=Fs(g-u[w],E),O=Fs(p-u[x],_),N=t.middlewareData.shift,T=!N;let C=k,M=O;N!=null&&N.enabled.x&&(M=_),N!=null&&N.enabled.y&&(C=E),T&&!h&&(m?M=p-2*xo(u.left,u.right):C=g-2*xo(u.top,u.bottom)),await s({...t,availableWidth:M,availableHeight:C});const D=await i.getDimensions(a.floating);return p!==D.width||g!==D.height?{reset:{rects:!0}}:{}}}};function Jv(){return typeof window<"u"}function sd(e){return n$(e)?(e.nodeName||"").toLowerCase():"#document"}function Ur(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jo(e){var t;return(t=(n$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function n$(e){return Jv()?e instanceof Node||e instanceof Ur(e).Node:!1}function Ca(e){return Jv()?e instanceof Element||e instanceof Ur(e).Element:!1}function Js(e){return Jv()?e instanceof HTMLElement||e instanceof Ur(e).HTMLElement:!1}function YM(e){return!Jv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ur(e).ShadowRoot}function ey(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Ta(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function Hie(e){return/^(table|td|th)$/.test(sd(e))}function ty(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Kie=/transform|translate|scale|rotate|perspective|filter/,qie=/paint|layout|strict|content/,Al=e=>!!e&&e!=="none";let Ux;function IS(e){const t=Ca(e)?Ta(e):e;return Al(t.transform)||Al(t.translate)||Al(t.scale)||Al(t.rotate)||Al(t.perspective)||!RS()&&(Al(t.backdropFilter)||Al(t.filter))||Kie.test(t.willChange||"")||qie.test(t.contain||"")}function Gie(e){let t=ec(e);for(;Js(t)&&!nh(t);){if(IS(t))return t;if(ty(t))return null;t=ec(t)}return null}function RS(){return Ux==null&&(Ux=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Ux}function nh(e){return/^(html|body|#document)$/.test(sd(e))}function Ta(e){return Ur(e).getComputedStyle(e)}function ny(e){return Ca(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ec(e){if(sd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||YM(e)&&e.host||jo(e);return YM(t)?t.host:t}function r$(e){const t=ec(e);return nh(t)?(e.ownerDocument||e).body:Js(t)&&ey(t)?t:r$(t)}function rh(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=r$(e),a=i===((r=e.ownerDocument)==null?void 0:r.body),s=Ur(i);if(a){const l=y1(s);return t.concat(s,s.visualViewport||[],ey(i)?i:[],l&&n?rh(l):[])}else return t.concat(i,rh(i,[],n))}function y1(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function i$(e){const t=Ta(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Js(e),a=i?e.offsetWidth:n,s=i?e.offsetHeight:r,l=Dg(n)!==a||Dg(r)!==s;return l&&(n=a,r=s),{width:n,height:r,$:l}}function PS(e){return Ca(e)?e:e.contextElement}function Tu(e){const t=PS(e);if(!Js(t))return wo(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:a}=i$(t);let s=(a?Dg(n.width):n.width)/r,l=(a?Dg(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const Vie=wo(0);function a$(e){const t=Ur(e);return!RS()||!t.visualViewport?Vie:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Wie(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ur(e)}function tc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),a=PS(e);let s=wo(1);t&&(r?Ca(r)&&(s=Tu(r)):s=Tu(e));const l=Wie(a,n,r)?a$(a):wo(0);let u=(i.left+l.x)/s.x,d=(i.top+l.y)/s.y,h=i.width/s.x,m=i.height/s.y;if(a&&r){const p=Ur(a),g=Ca(r)?Ur(r):r;let w=p,x=y1(w);for(;x&&g!==w;){const E=Tu(x),_=x.getBoundingClientRect(),k=Ta(x),O=_.left+(x.clientLeft+parseFloat(k.paddingLeft))*E.x,N=_.top+(x.clientTop+parseFloat(k.paddingTop))*E.y;u*=E.x,d*=E.y,h*=E.x,m*=E.y,u+=O,d+=N,w=Ur(x),x=y1(w)}}return Lg({width:h,height:m,x:u,y:d})}function ry(e,t){const n=ny(e).scrollLeft;return t?t.left+n:tc(jo(e)).left+n}function o$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ry(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function Yie(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const a=i==="fixed",s=jo(r),l=t?ty(t.floating):!1;if(r===s||l&&a)return n;let u={scrollLeft:0,scrollTop:0},d=wo(1);const h=wo(0),m=Js(r);if((m||!a)&&((sd(r)!=="body"||ey(s))&&(u=ny(r)),m)){const g=tc(r);d=Tu(r),h.x=g.x+r.clientLeft,h.y=g.y+r.clientTop}const p=s&&!m&&!a?o$(s,u):wo(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x+p.x,y:n.y*d.y-u.scrollTop*d.y+h.y+p.y}}function Xie(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Zie(e){const t=ny(e),n=e.ownerDocument.body,r=xo(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=xo(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let a=-t.scrollLeft+ry(e);const s=-t.scrollTop;return Ta(n).direction==="rtl"&&(a+=xo(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:s}}const Qie=25;function Jie(e,t,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=Ur(e),a=jo(e),s=i.visualViewport;let l=a.clientWidth,u=a.clientHeight,d=0,h=0;if(s){const p=!RS()||t==="fixed";r?p||(d=-s.offsetLeft,h=-s.offsetTop):(l=s.width,u=s.height,p&&(d=s.offsetLeft,h=s.offsetTop))}if(ry(a)<=0){const p=a.ownerDocument,g=p.body,w=getComputedStyle(g),x=p.compatMode==="CSS1Compat"&&parseFloat(w.marginLeft)+parseFloat(w.marginRight)||0,E=Math.abs(a.clientWidth-g.clientWidth-x),_=getComputedStyle(a).scrollbarGutter==="stable both-edges"?E/2:E;_<=Qie&&(l-=_)}return{width:l,height:u,x:d,y:h}}function eae(e,t){const n=tc(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Tu(e),s=e.clientWidth*a.x,l=e.clientHeight*a.y,u=i*a.x,d=r*a.y;return{width:s,height:l,x:u,y:d}}function XM(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=Jie(e,n,t);else if(t==="document")r=Zie(jo(e));else if(Ca(t))r=eae(t,n);else{const i=a$(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Lg(r)}function tae(e,t){const n=t.get(e);if(n)return n;let r=rh(e,[],!1).filter(l=>Ca(l)&&sd(l)!=="body"),i=null;const a=Ta(e).position==="fixed";let s=a?ec(e):e;for(;Ca(s)&&!nh(s);){const l=Ta(s),u=IS(s),d=i?i.position:a?"fixed":"";!u&&(d==="fixed"||d==="absolute"&&l.position==="static")?r=r.filter(m=>m!==s):i=l,s=ec(s)}return t.set(e,r),r}function nae(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[...n==="clippingAncestors"?ty(t)?[]:tae(t,this._c):[].concat(n),r],l=XM(t,s[0],i);let u=l.top,d=l.right,h=l.bottom,m=l.left;for(let p=1;p<s.length;p++){const g=XM(t,s[p],i);u=xo(g.top,u),d=Fs(g.right,d),h=Fs(g.bottom,h),m=xo(g.left,m)}return{width:d-m,height:h-u,x:m,y:u}}function rae(e){const{width:t,height:n}=i$(e);return{width:t,height:n}}function iae(e,t,n){const r=Js(t),i=jo(t),a=n==="fixed",s=tc(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const u=wo(0);if((r||!a)&&((sd(t)!=="body"||ey(i))&&(l=ny(t)),r)){const p=tc(t,!0,a,t);u.x=p.x+t.clientLeft,u.y=p.y+t.clientTop}!r&&i&&(u.x=ry(i));const d=i&&!r&&!a?o$(i,l):wo(0),h=s.left+l.scrollLeft-u.x-d.x,m=s.top+l.scrollTop-u.y-d.y;return{x:h,y:m,width:s.width,height:s.height}}function Fx(e){return Ta(e).position==="static"}function ZM(e,t){if(!Js(e)||Ta(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return jo(e)===n&&(n=n.ownerDocument.body),n}function s$(e,t){const n=Ur(e);if(ty(e))return n;if(!Js(e)){let i=ec(e);for(;i&&!nh(i);){if(Ca(i)&&!Fx(i))return i;i=ec(i)}return n}let r=ZM(e,t);for(;r&&Hie(r)&&Fx(r);)r=ZM(r,t);return r&&nh(r)&&Fx(r)&&!IS(r)?n:r||Gie(e)||n}const aae=async function(e){const t=this.getOffsetParent||s$,n=this.getDimensions,r=await n(e.floating);return{reference:iae(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function oae(e){return Ta(e).direction==="rtl"}const sae={convertOffsetParentRelativeRectToViewportRelativeRect:Yie,getDocumentElement:jo,getClippingRect:nae,getOffsetParent:s$,getElementRects:aae,getClientRects:Xie,getDimensions:rae,getScale:Tu,isElement:Ca,isRTL:oae};function l$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lae(e,t,n){let r=null,i;const a=jo(e);function s(){var h;clearTimeout(i),(h=r)==null||h.disconnect(),r=null}function l(h,m){h===void 0&&(h=!1),m===void 0&&(m=1),s();const p=e.getBoundingClientRect(),{left:g,top:w,width:x,height:E}=p;if(h||t(),!x||!E)return;const _=Mp(w),k=Mp(a.clientWidth-(g+x)),O=Mp(a.clientHeight-(w+E)),N=Mp(g),C={rootMargin:-_+"px "+-k+"px "+-O+"px "+-N+"px",threshold:xo(0,Fs(1,m))||1};let M=!0;function D(j){const R=j[0].intersectionRatio;if(!l$(p,e.getBoundingClientRect()))return l();if(R!==m){if(!M)return l();R?l(!1,R):i=setTimeout(()=>{l(!1,1e-7)},1e3)}M=!1}try{r=new IntersectionObserver(D,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(D,C)}r.observe(e)}const u=Ur(e),d=()=>l(n);return u.addEventListener("resize",d),l(!0),()=>{u.removeEventListener("resize",d),s()}}function cae(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=PS(e),h=i||a?[...d?rh(d):[],...t?rh(t):[]]:[];h.forEach(_=>{i&&_.addEventListener("scroll",n),a&&_.addEventListener("resize",n)});const m=d&&l?lae(d,n,a):null;let p=-1,g=null;s&&(g=new ResizeObserver(_=>{let[k]=_;k&&k.target===d&&g&&t&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var O;(O=g)==null||O.observe(t)})),n()}),d&&!u&&g.observe(d),t&&g.observe(t));let w,x=u?tc(e):null;u&&E();function E(){const _=tc(e);x&&!l$(x,_)&&n(),x=_,w=requestAnimationFrame(E)}return n(),()=>{var _;h.forEach(k=>{i&&k.removeEventListener("scroll",n),a&&k.removeEventListener("resize",n)}),m==null||m(),(_=g)==null||_.disconnect(),g=null,u&&cancelAnimationFrame(w)}}const uae=$ie,dae=Bie,fae=jie,hae=Fie,mae=Lie,QM=Die,pae=Uie,gae=(e,t,n)=>{const r=new Map,i=n??{},a={...sae,...i.platform,_c:r};return Pie(e,t,{...i,platform:a})};var vae=typeof document<"u",yae=function(){},og=vae?b.useLayoutEffect:yae;function zg(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(!zg(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 a=i[r];if(!(a==="_owner"&&e.$$typeof)&&!zg(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function c$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function JM(e,t){const n=c$(e);return Math.round(t*n)/n}function Hx(e){const t=b.useRef(e);return og(()=>{t.current=e}),t}function bae(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:s}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[h,m]=b.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,g]=b.useState(r);zg(p,r)||g(r);const[w,x]=b.useState(null),[E,_]=b.useState(null),k=b.useCallback(F=>{F!==C.current&&(C.current=F,x(F))},[]),O=b.useCallback(F=>{F!==M.current&&(M.current=F,_(F))},[]),N=a||w,T=s||E,C=b.useRef(null),M=b.useRef(null),D=b.useRef(h),j=u!=null,R=Hx(u),H=Hx(i),P=Hx(d),G=b.useCallback(()=>{if(!C.current||!M.current)return;const F={placement:t,strategy:n,middleware:p};H.current&&(F.platform=H.current),gae(C.current,M.current,F).then(V=>{const $={...V,isPositioned:P.current!==!1};q.current&&!zg(D.current,$)&&(D.current=$,La.flushSync(()=>{m($)}))})},[p,t,n,H,P]);og(()=>{d===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,m(F=>({...F,isPositioned:!1})))},[d]);const q=b.useRef(!1);og(()=>(q.current=!0,()=>{q.current=!1}),[]),og(()=>{if(N&&(C.current=N),T&&(M.current=T),N&&T){if(R.current)return R.current(N,T,G);G()}},[N,T,G,R,j]);const X=b.useMemo(()=>({reference:C,floating:M,setReference:k,setFloating:O}),[k,O]),U=b.useMemo(()=>({reference:N,floating:T}),[N,T]),K=b.useMemo(()=>{const F={position:n,left:0,top:0};if(!U.floating)return F;const V=JM(U.floating,h.x),$=JM(U.floating,h.y);return l?{...F,transform:"translate("+V+"px, "+$+"px)",...c$(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:$}},[n,l,U.floating,h.x,h.y]);return b.useMemo(()=>({...h,update:G,refs:X,elements:U,floatingStyles:K}),[h,G,X,U,K])}const xae=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?QM({element:r.current,padding:i}).fn(n):{}:r?QM({element:r,padding:i}).fn(n):{}}}},wae=(e,t)=>{const n=uae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Eae=(e,t)=>{const n=dae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sae=(e,t)=>({fn:pae(e).fn,options:[e,t]}),_ae=(e,t)=>{const n=fae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Aae=(e,t)=>{const n=hae(e);return{name:n.name,fn:n.fn,options:[e,t]}},kae=(e,t)=>{const n=mae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Oae=(e,t)=>{const n=xae(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Nae=Object.defineProperty,DS=(e,t)=>Nae(e,"name",{value:t,configurable:!0});function b1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}DS(b1,"setRef");function u$(...e){return t=>{let n=!1;const r=e.map(i=>{const a=b1(i,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i<r.length;i++){const a=r[i];typeof a=="function"?a():b1(e[i],null)}}}}DS(u$,"composeRefs");function iy(...e){return b.useCallback(u$(...e),e)}DS(iy,"useComposedRefs");var Cae=Object.defineProperty,Ci=(e,t)=>Cae(e,"name",{value:t,configurable:!0});function Tae(e,t){const n=b.createContext(t);n.displayName=e+"Context";const r=Ci(a=>{const{children:s,...l}=a,u=b.useMemo(()=>l,Object.values(l));return y.jsx(n.Provider,{value:u,children:s})},"Provider");r.displayName=e+"Provider";function i(a,s={}){const{optional:l=!1}=s,u=b.useContext(n);if(u)return u;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return Ci(i,"useContext"),[r,i]}Ci(Tae,"createContext");function d$(e,t=[]){let n=[];function r(a,s){const l=b.createContext(s);l.displayName=a+"Context";const u=n.length;n=[...n,s];const d=Ci(m=>{var _;const{scope:p,children:g,...w}=m,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useMemo(()=>w,Object.values(w));return y.jsx(x.Provider,{value:E,children:g})},"Provider");d.displayName=a+"Provider";function h(m,p,g={}){var _;const{optional:w=!1}=g,x=((_=p==null?void 0:p[e])==null?void 0:_[u])||l,E=b.useContext(x);if(E)return E;if(s!==void 0)return s;if(!w)throw new Error(`\`${m}\` must be used within \`${a}\``)}return Ci(h,"useContext"),[d,h]}Ci(r,"createContext");const i=Ci(()=>{const a=n.map(s=>b.createContext(s));return Ci(function(l){const u=(l==null?void 0:l[e])||a;return b.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=e,[r,f$(i,...t)]}Ci(d$,"createContextScope");function f$(...e){const t=e[0];if(e.length===1)return t;const n=Ci(()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return Ci(function(a){const s=r.reduce((l,{useScope:u,scopeName:d})=>{const m=u(a)[`__scope${d}`];return{...l,...m}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}Ci(f$,"composeContextScopes");var Mae=Object.defineProperty,ta=(e,t)=>Mae(e,"name",{value:t,configurable:!0});function h$(e){const t=b.forwardRef((n,r)=>{let{children:i,...a}=n,s=null,l=!1;const u=[];x1(i)&&typeof Ip=="function"&&(i=Ip(i._payload)),b.Children.forEach(i,p=>{var g;if(v$(p)){l=!0;const w=p;let x="child"in w.props?w.props.child:w.props.children;x1(x)&&typeof Ip=="function"&&(x=Ip(x._payload)),s=Rae(w,x),u.push((g=s==null?void 0:s.props)==null?void 0:g.children)}else u.push(p)}),s?s=b.cloneElement(s,void 0,u):!l&&b.Children.count(i)===1&&b.isValidElement(i)&&(s=i);const d=s?g$(s):void 0,h=iy(r,d);if(!s){if(i||i===0)throw new Error(l?jae(e):Dae(e));return i}const m=p$(a,s.props??{});return s.type!==b.Fragment&&(m.ref=r?h:d),b.cloneElement(s,m)});return t.displayName=`${e}.Slot`,t}ta(h$,"createSlot");var m$=Symbol.for("radix.slottable");function Iae(e){const t=ta(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=m$,t}ta(Iae,"createSlottable");var Rae=ta((e,t)=>{if("child"in e.props){const n=e.props.child;return b.isValidElement(n)?b.cloneElement(n,void 0,e.props.children(n.props.children)):null}return b.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function p$(e,t){const n={...t};for(const r in t){const i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...l)=>{const u=a(...l);return i(...l),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...e,...n}}ta(p$,"mergeProps");function g$(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}ta(g$,"getElementRef");function v$(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===m$}ta(v$,"isSlottable");var Pae=Symbol.for("react.lazy");function x1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Pae&&"_payload"in e&&y$(e._payload)}ta(x1,"isLazyComponent");function y$(e){return typeof e=="object"&&e!==null&&"then"in e}ta(y$,"isPromiseLike");var Dae=ta(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),jae=ta(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Ip=ja[" use ".trim().toString()],Lae=Object.defineProperty,zae=(e,t)=>Lae(e,"name",{value:t,configurable:!0}),$ae=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],b$=$ae.reduce((e,t)=>{const n=h$(`Primitive.${t}`),r=b.forwardRef((i,a)=>{const{asChild:s,...l}=i,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(u,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Bae(e,t){e&&La.flushSync(()=>e.dispatchEvent(t))}zae(Bae,"dispatchDiscreteCustomEvent");var Uae=Object.defineProperty,Fae=(e,t)=>Uae(e,"name",{value:t,configurable:!0});function x$(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}Fae(x$,"useCallbackRef");var Kx=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},Hae=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},Kae=Object.defineProperty,qae=(e,t)=>Kae(e,"name",{value:t,configurable:!0});function w$(e){const[t,n]=b.useState(void 0);return Hae(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[0];let s,l;if("borderBoxSize"in a){const u=a.borderBoxSize,d=Array.isArray(u)?u[0]:u;s=d.inlineSize,l=d.blockSize}else s=e.offsetWidth,l=e.offsetHeight;n({width:s,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}qae(w$,"useSize");var Gae=Object.defineProperty,js=(e,t)=>Gae(e,"name",{value:t,configurable:!0}),E$="Popper",[S$,_$]=d$(E$),[Vae,A$]=S$(E$),Wae=js(e=>{const{__scopePopper:t,children:n}=e,[r,i]=b.useState(null),[a,s]=b.useState(void 0);return y.jsx(Vae,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:s,children:n})},"Popper"),Yae="PopperAnchor",Xae=b.forwardRef(js(function(t,n){const{__scopePopper:r,virtualRef:i,...a}=t,s=A$(Yae,r),l=b.useRef(null),u=s.onAnchorChange,d=b.useCallback(x=>{l.current=x,x&&u(x)},[u]),h=iy(n,d),m=b.useRef(null);b.useEffect(()=>{if(!i)return;const x=m.current;m.current=i.current,x!==m.current&&u(m.current)});const p=s.placementState&&ay(s.placementState),g=p==null?void 0:p[0],w=p==null?void 0:p[1];return i?null:y.jsx(b$.div,{"data-radix-popper-side":g,"data-radix-popper-align":w,...a,ref:h})},"PopperAnchor")),k$="PopperContent",[Zae,cCe]=S$(k$),Qae=b.forwardRef(js(function(t,n){var fe,Ee,Te,de,nt,He,Ae;const{__scopePopper:r,side:i="bottom",sideOffset:a=0,align:s="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:m=0,sticky:p="partial",hideWhenDetached:g=!1,updatePositionStrategy:w="optimized",onPlaced:x,...E}=t,_=A$(k$,r),[k,O]=b.useState(null),N=iy(n,O),[T,C]=b.useState(null),M=w$(T),D=(M==null?void 0:M.width)??0,j=(M==null?void 0:M.height)??0,R=i+(s!=="center"?"-"+s:""),H=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},P=Array.isArray(h)?h:[h],G=P.length>0,q={padding:H,boundary:P.filter(O$),altBoundary:G},{refs:X,floatingStyles:U,placement:K,isPositioned:F,middlewareData:V}=bae({strategy:"fixed",placement:R,whileElementsMounted:js((...De)=>cae(...De,{animationFrame:w==="always"}),"whileElementsMounted"),elements:{reference:_.anchor},middleware:[wae({mainAxis:a+j,alignmentAxis:l}),d&&Eae({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?Sae():void 0,...q}),d&&_ae({...q}),Aae({...q,apply:js(({elements:De,rects:Ht,availableWidth:un,availableHeight:Yn})=>{const{width:Or,height:Li}=Ht.reference,ir=De.floating.style;ir.setProperty("--radix-popper-available-width",`${un}px`),ir.setProperty("--radix-popper-available-height",`${Yn}px`),ir.setProperty("--radix-popper-anchor-width",`${Or}px`),ir.setProperty("--radix-popper-anchor-height",`${Li}px`)},"apply")}),T&&Oae({element:T,padding:u}),Jae({arrowWidth:D,arrowHeight:j}),g&&kae({strategy:"referenceHidden",...q,boundary:G?q.boundary:void 0})]}),$=_.setPlacementState;Kx(()=>($(K),()=>{$(void 0)}),[K,$]);const[L,W]=ay(K),z=x$(x);Kx(()=>{F&&(z==null||z())},[F,z]);const ie=(fe=V.arrow)==null?void 0:fe.x,he=(Ee=V.arrow)==null?void 0:Ee.y,ge=((Te=V.arrow)==null?void 0:Te.centerOffset)!==0,[Se,$e]=b.useState();return Kx(()=>{k&&$e(window.getComputedStyle(k).zIndex)},[k]),y.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:F?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Se,"--radix-popper-transform-origin":[(de=V.transformOrigin)==null?void 0:de.x,(nt=V.transformOrigin)==null?void 0:nt.y].join(" "),...((He=V.hide)==null?void 0:He.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:y.jsx(Zae,{scope:r,placedSide:L,placedAlign:W,onArrowChange:C,arrowX:ie,arrowY:he,shouldHideArrow:ge,children:y.jsx(b$.div,{"data-side":L,"data-align":W,...E,ref:N,style:{...E.style,animation:F?(Ae=E.style)==null?void 0:Ae.animation:"none"}})})})},"PopperContent"));function O$(e){return e!==null}js(O$,"isNotNull");var Jae=js(e=>({name:"transformOrigin",options:e,fn(t){var E,_,k;const{placement:n,rects:r,middlewareData:i}=t,s=((E=i.arrow)==null?void 0:E.centerOffset)!==0,l=s?0:e.arrowWidth,u=s?0:e.arrowHeight,[d,h]=ay(n),m={start:"0%",center:"50%",end:"100%"}[h],p=(((_=i.arrow)==null?void 0:_.x)??0)+l/2,g=(((k=i.arrow)==null?void 0:k.y)??0)+u/2;let w="",x="";return d==="bottom"?(w=s?m:`${p}px`,x=`${-u}px`):d==="top"?(w=s?m:`${p}px`,x=`${r.floating.height+u}px`):d==="right"?(w=`${-u}px`,x=s?m:`${g}px`):d==="left"&&(w=`${r.floating.width+u}px`,x=s?m:`${g}px`),{data:{x:w,y:x}}}}),"transformOrigin");function ay(e){const[t,n="center"]=e.split("-");return[t,n]}js(ay,"getSideAndAlignFromPlacement");var eoe=Wae,toe=Xae,noe=Qae,roe=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},ioe=Object.defineProperty,aoe=(e,t)=>ioe(e,"name",{value:t,configurable:!0}),ooe=b.forwardRef(aoe(function(t,n){var u;const{container:r,...i}=t,[a,s]=b.useState(!1);roe(()=>s(!0),[]);const l=r||a&&((u=globalThis==null?void 0:globalThis.document)==null?void 0:u.body);return l?La.createPortal(y.jsx(Zv.div,{...i,ref:n}),l):null},"Portal")),eI=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},soe=Object.defineProperty,To=(e,t)=>soe(e,"name",{value:t,configurable:!0});function N$(e,t){return b.useReducer((n,r)=>t[n][r]??n,e)}To(N$,"useStateMachine");var C$=To(e=>{const{present:t,children:n}=e,r=T$(t),i=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),a=M$(r.ref,I$(i));return typeof n=="function"||r.isPresent?b.cloneElement(i,{ref:a}):null},"Presence");function T$(e){const[t,n]=b.useState(),r=b.useRef(null),i=b.useRef(e),a=b.useRef("none"),s=b.useRef(void 0),l=e?"mounted":"unmounted",[u,d]=N$(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{u==="mounted"?(a.current=s.current??bu(r.current),s.current=void 0):a.current="none"},[u]),eI(()=>{const h=r.current,m=i.current;if(m!==e){const g=a.current,w=bu(h);e?(s.current=w,d("MOUNT")):w==="none"||(h==null?void 0:h.display)==="none"?d("UNMOUNT"):d(m&&g!==w?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,d]),eI(()=>{if(t){let h;const m=t.ownerDocument.defaultView??window,p=To(w=>{const E=bu(r.current).includes(CSS.escape(w.animationName));if(w.target===t&&E&&(d("ANIMATION_END"),!i.current)){const _=t.style.animationFillMode;t.style.animationFillMode="forwards",h=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=_)})}},"handleAnimationEnd"),g=To(w=>{w.target===t&&(a.current=bu(r.current))},"handleAnimationStart");return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{m.clearTimeout(h),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:b.useCallback(h=>{if(h){const m=getComputedStyle(h);r.current=m,s.current=bu(m)}else r.current=null;n(h)},[])}}To(T$,"usePresence");function w1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}To(w1,"setRef");function M$(...e){const t=b.useRef(e);return t.current=e,b.useCallback(n=>{const r=t.current;let i=!1;const a=r.map(s=>{const l=w1(s,n);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let s=0;s<a.length;s++){const l=a[s];typeof l=="function"?l():w1(r[s],null)}}},[])}To(M$,"useStableComposedRefs");function bu(e){return(e==null?void 0:e.animationName)||"none"}To(bu,"getAnimationName");function I$(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}To(I$,"getElementRef");var R$=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},loe=Object.defineProperty,coe=(e,t)=>loe(e,"name",{value:t,configurable:!0}),tI=ja[" useEffectEvent ".trim().toString()],nI=ja[" useInsertionEffect ".trim().toString()];function P$(e){if(typeof tI=="function")return tI(e);const t=b.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof nI=="function"?nI(()=>{t.current=e}):R$(()=>{t.current=e}),b.useMemo(()=>((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)}),[])}coe(P$,"useEffectEvent");var uoe=Object.defineProperty,Nh=(e,t)=>uoe(e,"name",{value:t,configurable:!0}),doe=ja[" useInsertionEffect ".trim().toString()]||R$;function D$({prop:e,defaultProp:t,onChange:n=Nh(()=>{},"onChange"),caller:r}){const[i,a,s]=j$({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:i,d=b.useCallback(h=>{var m;if(l){const p=L$(h)?h(e):h;p!==e&&((m=s.current)==null||m.call(s,p))}else a(h)},[l,e,a,s]);return[u,d]}Nh(D$,"useControllableState");function j$({defaultProp:e,onChange:t}){const[n,r]=b.useState(e),i=b.useRef(n),a=b.useRef(t);return doe(()=>{a.current=t},[t]),b.useEffect(()=>{var s;i.current!==n&&((s=a.current)==null||s.call(a,n),i.current=n)},[n,i]),[n,r,a]}Nh(j$,"useUncontrolledState");function L$(e){return typeof e=="function"}Nh(L$,"isFunction");var rI=Symbol("RADIX:SYNC_STATE");function foe(e,t,n,r){const{prop:i,defaultProp:a,onChange:s,caller:l}=t,u=i!==void 0,d=P$(s),h=[{...n,state:a}];r&&h.push(r);const[m,p]=b.useReducer((E,_)=>{if(_.type===rI)return{...E,state:_.state};const k=e(E,_);return u&&!Object.is(k.state,E.state)&&d(k.state),k},...h),g=m.state,w=b.useRef(g);b.useEffect(()=>{w.current!==g&&(w.current=g,u||d(g))},[g,w,u]);const x=b.useMemo(()=>i!==void 0?{...m,state:i}:m,[m,i]);return b.useEffect(()=>{u&&!Object.is(i,m.state)&&p({type:rI,state:i})},[i,m.state,u]),[x,p]}Nh(foe,"useControllableStateReducer");var hoe=Object.defineProperty,el=(e,t)=>hoe(e,"name",{value:t,configurable:!0}),jS="Popover",[z$,uCe]=Dz(jS,[_$]),LS=_$(),[moe,ld]=z$(jS),poe=el(e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!1}=e,l=LS(t),u=b.useRef(null),[d,h]=b.useState(!1),[m,p]=D$({prop:r,defaultProp:i??!1,onChange:a,caller:jS});return y.jsx(eoe,{...l,children:y.jsx(moe,{scope:t,contentId:Qz(),triggerRef:u,open:m,onOpenChange:p,onOpenToggle:b.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:d,onCustomAnchorAdd:b.useCallback(()=>h(!0),[]),onCustomAnchorRemove:b.useCallback(()=>h(!1),[]),modal:s,children:n})})},"Popover"),goe="PopoverTrigger",voe=b.forwardRef(el(function(t,n){const{__scopePopover:r,...i}=t,a=ld(goe,r),s=LS(r),l=ad(n,a.triggerRef),u=y.jsx(Zv.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":zS(a.open),...i,ref:l,onClick:Ds(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:y.jsx(toe,{asChild:!0,...s,children:u})},"PopoverTrigger")),$$="PopoverPortal",[yoe,boe]=z$($$,{forceMount:void 0}),xoe=el(e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=ld($$,t);return y.jsx(yoe,{scope:t,forceMount:n,children:y.jsx(C$,{present:n||a.open,children:y.jsx(ooe,{asChild:!0,container:i,children:r})})})},"PopoverPortal"),ih="PopoverContent",woe=b.forwardRef(el(function(t,n){const r=boe(ih,t.__scopePopover),{forceMount:i=r.forceMount,...a}=t,s=ld(ih,t.__scopePopover);return y.jsx(C$,{present:i||s.open,children:s.modal?y.jsx(Soe,{...a,ref:n}):y.jsx(_oe,{...a,ref:n})})},"PopoverContent")),Eoe=_S("PopoverContent.RemoveScroll"),Soe=b.forwardRef(el(function(t,n){const r=ld(ih,t.__scopePopover),i=b.useRef(null),a=ad(n,i),s=b.useRef(!1);return b.useEffect(()=>{const l=i.current;if(l)return gz(l)},[]),y.jsx(vS,{as:Eoe,allowPinchZoom:!0,children:y.jsx(B$,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ds(t.onCloseAutoFocus,l=>{var u;l.preventDefault(),s.current||(u=r.triggerRef.current)==null||u.focus()}),onPointerDownOutside:Ds(t.onPointerDownOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,h=u.button===2||d;s.current=h},{checkForDefaultPrevented:!1}),onFocusOutside:Ds(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})},"PopoverContentModal")),_oe=b.forwardRef(el(function(t,n){const r=ld(ih,t.__scopePopover),i=b.useRef(!1),a=b.useRef(!1);return y.jsx(B$,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var l,u;(l=t.onCloseAutoFocus)==null||l.call(t,s),s.defaultPrevented||(i.current||(u=r.triggerRef.current)==null||u.focus(),s.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:s=>{var d,h;(d=t.onInteractOutside)==null||d.call(t,s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=s.target;((h=r.triggerRef.current)==null?void 0:h.contains(l))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&a.current&&s.preventDefault()}})},"PopoverContentNonModal")),B$=b.forwardRef(el(function(t,n){const{__scopePopover:r,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:s,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,...p}=t,g=ld(ih,r),w=LS(r);return OS(),y.jsx(vie,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:a,onUnmountAutoFocus:s,children:y.jsx(cie,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:m,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onDismiss:()=>g.onOpenChange(!1),deferPointerDownOutside:!0,children:y.jsx(noe,{"data-state":zS(g.open),role:"dialog",id:g.contentId,...w,...p,ref:n,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})},"PopoverContentImpl"));function zS(e){return e?"open":"closed"}el(zS,"getState");var Aoe=poe,koe=voe,Ooe=xoe,U$=woe;const Noe=Aoe,Coe=koe,F$=b.forwardRef(({className:e,align:t="start",side:n="top",sideOffset:r=8,collisionPadding:i=8,...a},s)=>y.jsx(Ooe,{children:y.jsx(U$,{ref:s,align:t,side:n,sideOffset:r,collisionPadding:i,className:ze("z-50 w-64 max-w-[calc(100vw-1rem)] rounded-md border bg-card p-3 text-card-foreground shadow-md outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...a})}));F$.displayName=U$.displayName;const H$=92,K$=96;function qx(e){if(!Number.isFinite(e)||e<0)return"?";const t=["B","KB","MB","GB","TB","PB"];let n=0;for(;e>=1024&&n<t.length-1;)e/=1024,n++;return`${e<10&&n>0?e.toFixed(1):Math.round(e)} ${t[n]}`}const iI=3e5;function Toe({socket:e,getToken:t}){const[n,r]=b.useState([]);if(b.useEffect(()=>{t().then(a=>a?fetch("/api/stats",{headers:{Authorization:`Bearer ${a}`}}):null).then(a=>a==null?void 0:a.json()).then(a=>(a==null?void 0:a.samples)&&r(a.samples)).catch(a=>console.warn("[MachineStats] seed failed",a))},[t]),b.useEffect(()=>{if(!e)return;const a=e.on(s=>{s.type==="stats"&&r(l=>[...l,s.sample].slice(-120))});return()=>{a()}},[e]),!n.length)return null;const i=n[n.length-1];return y.jsxs("div",{className:"w-full flex flex-wrap items-center justify-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground/60",children:[y.jsx(sg,{label:"cpu",value:i.cpu,series:n.map(a=>a.cpu)}),y.jsx(sg,{label:"mem",value:i.mem,series:n.map(a=>a.mem)}),i.disk>=0&&y.jsx(sg,{label:"disk",value:i.disk,severity:Loe(i.disk),title:$oe(i)}),y.jsx(Moe,{getToken:t})]})}function Moe({getToken:e}){const[t,n]=b.useState(null);return b.useEffect(()=>{let r=!0,i=0;const a=async()=>{var d;try{const h=await e();if(!h)return;i=Date.now();const m=await fetch("/api/claude-usage",{headers:{Authorization:`Bearer ${h}`}});if(!r)return;if(m.status===204){n(null);return}if(m.status!==200)return;const p=await m.json();if(!r||!((d=p==null?void 0:p.limits)!=null&&d.length))return;n(p)}catch(h){console.warn("[MachineStats] claude usage poll failed",h)}},s=()=>{document.visibilityState==="visible"&&a()},l=()=>{document.visibilityState==="visible"&&Date.now()-i>=iI&&a()};s();const u=setInterval(s,iI);return document.addEventListener("visibilitychange",l),()=>{r=!1,clearInterval(u),document.removeEventListener("visibilitychange",l)}},[e]),y.jsx(q$,{usage:t})}function q$({usage:e,compact:t}){const n=e&&G$(e.limits),[r,i]=b.useState(E1),a=b.useRef(null),s=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=b.useCallback((u,d=0)=>{if(s(),!d){i(h=>oI(h,u));return}a.current=setTimeout(()=>{a.current=null,i(h=>oI(h,u))},d)},[]);return b.useEffect(()=>s,[]),!e||!n?null:y.jsxs(Noe,{open:r.open,onOpenChange:u=>l(u?{type:"activate"}:{type:"dismiss"}),children:[y.jsx(Coe,{asChild:!0,children:y.jsx("button",{type:"button","aria-label":"claude usage breakdown",className:"cursor-default rounded-sm outline-none focus-visible:ring-1 focus-visible:ring-ring",onPointerEnter:u=>l({type:"pointerenter",pointerType:u.pointerType},Ioe),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},aI),children:t?y.jsxs("span",{className:ze("tabular-nums",$g(n.percent,n.severity)),children:[n.percent,"% used"]}):y.jsx(sg,{label:"usage",value:n.percent,severity:n.severity})})}),y.jsx(F$,{onOpenAutoFocus:u=>u.preventDefault(),onPointerEnter:()=>s(),onPointerLeave:u=>l({type:"pointerleave",pointerType:u.pointerType},aI),children:y.jsx(Roe,{usage:e})})]})}const Ioe=120,aI=80,E1={open:!1,byHover:!1};function oI(e,t){switch(t.type){case"pointerenter":return sI(t.pointerType)?{open:!0,byHover:!0}:e;case"pointerleave":return sI(t.pointerType)&&e.byHover?E1:e;case"activate":return{open:!0,byHover:!1};case"dismiss":return E1}}const sI=e=>e==="mouse"||e==="";function Roe({usage:e}){const t=G$(e.limits);return y.jsxs("div",{className:"text-[11px] leading-tight",children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2 pb-2 text-muted-foreground",children:[y.jsx("span",{className:"uppercase tracking-wide",children:"claude usage"}),e.subscriptionType&&y.jsxs("span",{className:"tabular-nums",children:[e.subscriptionType," plan"]})]}),y.jsxs("div",{className:"-mt-1 flex items-baseline justify-between gap-2 pb-2 text-[10px] text-muted-foreground",children:[e.account&&y.jsx("span",{className:"truncate",title:e.account,children:e.account}),y.jsx("span",{className:ze("shrink-0",e.stale&&"text-amber-500"),children:Doe(e)})]}),e.stale&&e.error&&y.jsxs("div",{"data-refresh-error":!0,className:"-mt-1 pb-2 text-[10px] text-amber-500 break-words",children:[e.error,ag(e.retryAt??null)&&` · retrying in ${ag(e.retryAt??null)}`]}),y.jsx("div",{className:"flex flex-col gap-3",children:e.limits.map((n,r)=>{const i=ag(n.resetsAt),a=n===t;return y.jsxs("div",{"data-headline":a||void 0,className:ze("flex flex-col gap-1",!a&&"opacity-60"),children:[y.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[y.jsxs("span",{className:ze("truncate",a&&"font-medium"),children:[a&&y.jsx("span",{className:"mr-1 text-muted-foreground","aria-hidden":!0,children:"▸"}),Poe(n)]}),y.jsxs("span",{className:ze("tabular-nums shrink-0",$g(n.percent,n.severity)),children:[n.percent,"%"]})]}),y.jsx(V$,{value:n.percent,className:ze("w-full",$g(n.percent,n.severity))}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:i?`resets in ${i}`:"no reset reported"})]},`${n.kind}-${r}`)})}),y.jsx("div",{className:"mt-3 border-t pt-2 text-[10px] text-muted-foreground",children:"▸ is the window the strip is showing"})]})}function Poe(e){return e.scopeLabel?`${e.scopeLabel} window`:e.kind==="session"?"current session":e.kind==="weekly_all"?"all models":e.kind.replace(/_/g," ")}function G$(e){return e.reduce((t,n)=>!t||n.percent>t.percent?n:t,null)}function Doe(e){const t=joe(e.fetchedAt);return t?e.stale?`${t} old — refresh failed`:`updated ${t} ago`:e.stale?"last reading — refresh failed":"updated just now"}function joe(e){if(!e)return null;const t=Date.now()-new Date(e).getTime();if(!Number.isFinite(t))return null;const n=Math.round(Math.max(0,t)/6e4);if(n<1)return null;if(n<60)return`${n}m`;const r=Math.floor(n/60),i=n%60;return r<24?i?`${r}h ${i}m`:`${r}h`:`${Math.floor(r/24)}d`}function Loe(e){return e>=K$?"critical":e>=H$?"warning":"ok"}const zoe={critical:"text-red-500",exceeded:"text-red-500",warning:"text-amber-500",warn:"text-amber-500",ok:"text-emerald-500"};function $g(e,t){const n=t?zoe[t]:void 0;return n||(e>=90?"text-red-500":e>=75?"text-amber-500":"text-emerald-500")}function $oe(e){const t=`warn at ${H$}%, critical at ${K$}%`;if(e.diskUsedBytes==null||e.diskTotalBytes==null)return`disk ${e.disk}% used — ${t}`;const n=Math.max(0,e.diskTotalBytes-e.diskUsedBytes);return`disk ${e.disk}% used — ${qx(e.diskUsedBytes)} of ${qx(e.diskTotalBytes)}, ${qx(n)} free — ${t}`}function sg({label:e,value:t,series:n,title:r,severity:i}){const a=$g(t,i),s=r??(n?`${e} ${t}% — last ${n.length} samples`:void 0);return y.jsxs("span",{className:"flex items-center gap-1",title:s,children:[y.jsx("span",{className:"uppercase tracking-wide",children:e}),n?y.jsx(Boe,{series:n,className:a}):y.jsx(V$,{value:t,className:a}),y.jsxs("span",{className:ze("tabular-nums",a),children:[t,"%"]})]})}function V$({value:e,className:t}){const i=Math.max(0,Math.min(100,e))/100*40;return y.jsxs("svg",{width:40,height:12,viewBox:"0 0 40 12",className:ze("overflow-visible",t),preserveAspectRatio:"none",children:[y.jsx("rect",{x:0,y:12/2-2,width:40,height:4,rx:2,fill:"currentColor",opacity:.2}),i>0&&y.jsx("rect",{x:0,y:12/2-2,width:i,height:4,rx:2,fill:"currentColor"})]})}function Boe({series:e,className:t}){const i=e.length;if(i<2)return null;const a=e.map((s,l)=>{const u=i>1?l/(i-1)*40:0,d=12-Math.max(0,Math.min(100,s))/100*12;return`${u.toFixed(1)},${d.toFixed(1)}`}).join(" ");return y.jsx("svg",{width:40,height:12,viewBox:"0 0 40 12",className:ze("overflow-visible",t),preserveAspectRatio:"none",children:y.jsx("polyline",{points:a,fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinejoin:"round",strokeLinecap:"round"})})}const kf=50;function Uoe({getToken:e,filter:t,refreshKey:n,hydrateIds:r}){const[i,a]=b.useState([]),[s,l]=b.useState(null),[u,d]=b.useState(!1),[h,m]=b.useState({}),p=b.useRef(new Set),g=b.useRef(null),w=b.useRef(null),x=b.useRef(t);x.current=t;const E=b.useRef(kf),_=b.useRef(t);_.current!==t&&(_.current=t,E.current=kf);const k=b.useCallback(async(M,D)=>{const j=await e();if(!j||D!=null&&D.aborted)return null;const R=await fetch(`/api/sessions?${new URLSearchParams(M)}`,{signal:D,headers:{Authorization:`Bearer ${j}`}});if(!R.ok)return null;const H=await R.json();return Array.isArray(H==null?void 0:H.sessions)?H:null},[e]),O=b.useCallback(async(M,D,j)=>{const R=[];let H,P=null;for(;R.length<M;){const G={filter:D,limit:String(Math.min(kf,M-R.length))};H&&(G.before=H);const q=await k(G,j);if(!q)return null;if(R.push(...q.sessions),P=q.nextCursor,!P||!q.sessions.length)break;H=P}return{sessions:R,nextCursor:P}},[k]);b.useEffect(()=>{var D,j;(D=g.current)==null||D.abort(),(j=w.current)==null||j.abort();const M=new AbortController;return g.current=M,d(!0),p.current.clear(),m({}),O(E.current,t,M.signal).then(R=>{!R||M.signal.aborted||(a(R.sessions),l(R.nextCursor))}).catch(()=>{}).finally(()=>{M.signal.aborted||d(!1)}),()=>M.abort()},[O,t,n]);const N=b.useCallback(()=>{var j;if(!s||u)return;(j=w.current)==null||j.abort();const M=new AbortController;w.current=M;const D=x.current;d(!0),k({filter:D,limit:String(kf),before:s},M.signal).then(R=>{!R||M.signal.aborted||D!==x.current||(a(H=>{const P=new Set(H.map(q=>q.sessionId)),G=[...H,...R.sessions.filter(q=>!P.has(q.sessionId))];return E.current=Math.max(kf,G.length),G}),l(R.nextCursor))}).catch(()=>{}).finally(()=>{M.signal.aborted||d(!1)})},[s,u,k]),T=b.useMemo(()=>{const M=new Map;for(const D of Object.values(h))M.set(D.sessionId,D);for(const D of i)M.set(D.sessionId,D);return M},[i,h]),C=r.join(",");return b.useEffect(()=>{const M=r.filter(j=>!!j&&!T.has(j)&&!p.current.has(j)).slice(0,200);if(!M.length)return;for(const j of M)p.current.add(j);let D=!1;return k({ids:M.join(",")}).then(j=>{!j||D||m(R=>{const H={...R};for(const P of j.sessions)H[P.sessionId]=P;return H})}).catch(()=>{}),()=>{D=!0}},[C,T,k]),{sessions:i,cursor:s,loading:u,byId:T,loadMore:N}}const Of="0.1.138";function Foe(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);if(r<24)return`${r}h ago`;const i=Math.floor(r/24);return i<7?`${i}d ago`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}const Nf="w-4 h-4 mt-0.5 shrink-0";function Hoe(e){const t=e.slackContext;return(t==null?void 0:t.type)==="dm"?y.jsx(aV,{className:`${Nf} text-purple-400`}):(t==null?void 0:t.type)==="mention"?y.jsx(qG,{className:`${Nf} text-blue-400`}):(t==null?void 0:t.type)==="channel"?y.jsx(eV,{className:`${Nf} text-green-400`}):e.sessionId.startsWith("slack-")?y.jsx(Vw,{className:`${Nf} text-yellow-400`}):y.jsx(Vw,{className:`${Nf} text-muted-foreground`})}function Koe(e){const t=e.slackContext;return(t==null?void 0:t.type)==="dm"?`DM${t.userName?` · ${t.userName}`:""}`:(t==null?void 0:t.type)==="mention"?`@mention${t.channelName?` · #${t.channelName}`:""}`:(t==null?void 0:t.type)==="channel"?`#${t.channelName||"channel"}`:e.sessionId.startsWith("slack-")?"Slack":null}function qoe(e,t,n){return Object.keys(e).map(r=>t.get(r)).filter(r=>!!r&&(n==="all"||r.mine!==!1))}const lI="chats-filter",cI="chats-unread-filter";function Goe({getToken:e,activeSessionId:t,onSelect:n,onNew:r,refreshKey:i,workspaceRefreshKey:a,onRefreshWorkspace:s,unreads:l={},busySessions:u=new Set,socket:d}){var F;const h=za(),[m,p]=b.useState(()=>localStorage.getItem(lI)||"mine"),[g,w]=b.useState(()=>localStorage.getItem(cI)==="true"),[x,E]=b.useState(""),_=b.useRef(null);function k(V){p(V),localStorage.setItem(lI,V)}function O(){const V=!g;w(V),localStorage.setItem(cI,String(V))}const N=b.useMemo(()=>[t,...Object.keys(l)].filter(V=>!!V),[t,l]),{sessions:T,cursor:C,loading:M,byId:D,loadMore:j}=Uoe({getToken:e,filter:m,refreshKey:i,hydrateIds:N}),R=b.useMemo(()=>qoe(l,D,m),[l,D,m]),H=R.length,P=b.useMemo(()=>g?[...R].sort((V,$)=>$.lastModified-V.lastModified):T,[g,R,T]),G=t&&!P.some(V=>V.sessionId===t)?D.get(t):void 0;b.useEffect(()=>{_.current&&_.current.scrollIntoView({block:"nearest"})},[t,P,G]);const q=b.useRef(null),X=b.useRef(j);X.current=j,b.useEffect(()=>{const V=q.current;if(!V||!C||g)return;const $=new IntersectionObserver(L=>{L.some(W=>W.isIntersecting)&&X.current()},{rootMargin:"300px"});return $.observe(V),()=>$.disconnect()},[C,M,g]),b.useEffect(()=>{e().then(V=>V?fetch("/api/version",{headers:{Authorization:`Bearer ${V}`}}):null).then(V=>V==null?void 0:V.json()).then(V=>V&&E(V.version)).catch(()=>{})},[]);const U=!!x&&x!=="unknown"&&Of!=="dev"&&x!==Of;b.useEffect(()=>{U&&console.warn(`[shraga] stale client bundle: built from v${Of}, server runs v${x} — rebuild dist/client`)},[U,x]);function K(V){const $=l[V.sessionId],L=u.has(V.sessionId)||V.runStatus==="running"||V.scheduleRunStatus==="running",W=!L&&(!!V.lastStopReason||V.scheduleRunStatus==="error"||V.scheduleRunStatus==="aborted"),z=L?"border-amber-500":W?"border-red-500":$?"border-blue-500":"",ie=!!(L||W||$);return y.jsx("button",{ref:V.sessionId===t?_:void 0,onClick:()=>n(V.sessionId,V.title),className:ze("w-full text-left px-3 py-2.5 text-sm transition-colors hover:bg-accent/50 group",ie?`rounded-r-lg border-l-[3px] ${z}`:"rounded-lg",t===V.sessionId&&"bg-accent"),children:y.jsxs("div",{className:"flex items-start gap-2",children:[Hoe(V),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("span",{className:ze("block truncate text-sm leading-snug",$&&"font-semibold"),children:V.title||"New session"}),y.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[y.jsx("span",{className:"text-[10px] text-muted-foreground font-medium",children:Koe(V)||V.userName}),y.jsx("span",{className:"text-[10px] text-muted-foreground/50",children:"·"}),y.jsx("span",{className:"text-[10px] text-muted-foreground",children:Foe(V.lastModified)})]})]})]})},V.sessionId)}return y.jsxs("div",{className:"flex flex-col h-full bg-muted/30",children:[y.jsx("div",{className:"p-3",children:y.jsxs(we,{variant:"outline",size:"sm",className:"w-full gap-2 justify-start",onClick:r,title:"New Chat (Ctrl+N)",children:[y.jsx(ko,{className:"w-4 h-4"})," New Chat",y.jsx("span",{className:"ml-auto flex items-center gap-0.5 text-[10px] text-muted-foreground/50 font-mono",children:"⌃N"})]})}),y.jsx("div",{className:"border-b shrink-0 flex flex-col max-h-[40vh]",children:y.jsx(Bre,{getToken:e,onRefresh:s,refreshKey:a})}),y.jsxs("div",{className:"flex items-center justify-between px-3 pt-2 pb-1",children:[y.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Chats"}),y.jsxs("div",{className:"flex gap-0.5",children:[["mine","all"].map(V=>y.jsx("button",{onClick:()=>k(V),className:ze("text-[10px] px-1.5 rounded-full transition-colors capitalize leading-none",m===V?"text-foreground font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:V},V)),y.jsxs("button",{onClick:O,className:ze("text-[10px] px-1.5 rounded-full transition-colors leading-none",g?"text-blue-600 dark:text-blue-400 font-medium":"text-muted-foreground/60 hover:text-muted-foreground"),children:["unread",H>0&&y.jsx("span",{className:"inline-block w-1.5 h-1.5 ml-1 rounded-full bg-blue-500 align-middle"})]})]})]}),y.jsx(OL,{className:"flex-1",children:y.jsxs("div",{className:"px-2 pb-2 space-y-0.5",children:[P.length===0&&!G&&y.jsx("p",{className:"text-xs text-muted-foreground px-3 py-6 text-center",children:M?"Loading…":g?"No unread conversations":"No conversations yet"}),G&&K(G),P.map(K),!g&&C&&y.jsx("div",{ref:q,className:"py-3 text-center text-[11px] text-muted-foreground/60",children:M?"Loading older…":"···"})]})}),y.jsxs("div",{className:"px-4 py-2 flex flex-col items-center gap-1",children:[y.jsx(Toe,{socket:d??null,getToken:e}),(F=h.sidebarExtras)==null?void 0:F.call(h),x&&(U?y.jsxs("button",{onClick:()=>location.reload(),title:`This page was built from v${Of}, the server runs v${x} — reload to update`,className:"text-[10px] text-amber-400 hover:text-amber-300 text-center underline decoration-dotted",children:["⚠️ stale page (v",Of," → v",x,") · reload"]}):y.jsxs("div",{className:"text-[10px] text-muted-foreground/50 text-center",children:["v",x]}))]})]})}function ni(e,t){const n=e[e.length-1];if((n==null?void 0:n.role)==="assistant"){if(t.type==="text"||t.type==="thinking"){const r=[...n.blocks],i=r[r.length-1];return(i==null?void 0:i.type)===t.type?(r[r.length-1]={...i,text:i.text+t.text},[...e.slice(0,-1),{...n,blocks:r}]):[...e.slice(0,-1),{...n,blocks:[...r,t]}]}return[...e.slice(0,-1),{...n,blocks:[...n.blocks,t]}]}return[...e,{id:Ms(),role:"assistant",blocks:[t]}]}function uI(e,t,n="text"){const r=e[e.length-1],i={type:n,text:t};return(r==null?void 0:r.role)==="assistant"?[...e.slice(0,-1),{...r,blocks:[...r.blocks,i]}]:[...e,{id:Ms(),role:"assistant",blocks:[i]}]}function W$(e,t,n){for(let r=e.length-1;r>=0;r--){const i=e[r];if(i.role!=="assistant")continue;const a=i.blocks.findIndex(l=>l.type==="tool_use"&&l.toolUseId===t);if(a===-1)continue;const s=[...i.blocks];return s[a]={...s[a],input:n},[...e.slice(0,r),{...i,blocks:s},...e.slice(r+1)]}return e}function Voe(e,t){const[n,r]=b.useState([]),[i,a]=b.useState(!1),[s,l]=b.useState([]),u=b.useRef(t.initialSessionId),d=b.useRef(!1),h=b.useRef(s);h.current=s;const m=b.useRef(t.getToken);m.current=t.getToken;const p=b.useRef(t.onNewSession);p.current=t.onNewSession;const g=b.useRef(t.onDirectivesChanged);g.current=t.onDirectivesChanged;const w=b.useRef(t.onParticipantsChanged);w.current=t.onParticipantsChanged;const x=b.useRef(t.onEvent);x.current=t.onEvent;const E=b.useRef(e);E.current=e;const _=b.useCallback(P=>P!=null&&P===u.current,[]),k=b.useCallback(async()=>{var G;const P=u.current;if(P)try{const X=await(await Ll(`/api/sessions/${P}/messages`,m.current)).json();r(nL(X)),a(!!X.busy),(G=w.current)==null||G.call(w,Array.isArray(X.participants)&&X.participants.length>1)}catch{}},[]);b.useEffect(()=>{if(!e)return;const P=e.on(G=>{var X,U,K,F,V,$;(X=x.current)==null||X.call(x,G);const q=G;if(q.type==="compact_marker")return _(q.sessionId)?r(L=>[...L,{id:Ms(),role:"assistant",blocks:[{type:"compact_marker",summary:q.summary??"",compactedCount:q.compactedCount??0}]}]):void 0;switch(G.type){case"thinking_delta":return _(G.sessionId)?r(L=>ni(L,{type:"thinking",text:G.text})):void 0;case"text_delta":return _(G.sessionId)?r(L=>ni(L,{type:"text",text:G.text})):void 0;case"tool_use":return _(G.sessionId)?r(L=>ni(L,{type:"tool_use",tool:G.tool,toolUseId:G.toolUseId,input:G.input})):void 0;case"tool_use_input":return _(G.sessionId)?r(L=>W$(L,G.toolUseId,G.input)):void 0;case"tool_result":return _(G.sessionId)?r(L=>ni(L,{type:"tool_result",toolUseId:G.toolUseId,output:G.output})):void 0;case"tool_result_image":return _(G.sessionId)?r(L=>ni(L,{type:"image",src:G.dataUrl})):void 0;case"permission_request":return _(G.sessionId)?r(L=>ni(L,{type:"permission_request",id:G.id,tool:G.tool,input:G.input})):void 0;case"question_request":return _(G.sessionId)?r(L=>ni(L,{type:"question_request",id:G.id,questions:G.questions})):void 0;case"directives":return d.current?(U=g.current)==null?void 0:U.call(g,G.directives):void 0;case"session_id":return!d.current||u.current?void 0:(u.current=G.sessionId,(K=p.current)==null?void 0:K.call(p,G.sessionId));case"forked":return G.sourceSessionId!==u.current?void 0:(u.current=G.sessionId,(F=p.current)==null?void 0:F.call(p,G.sessionId));case"session_busy":G.sessionId===u.current&&a(G.busy);return;case"session_stream":return G.sessionId!==u.current?void 0:Woe(r,G.event);case"session_messages_changed":G.sessionId===u.current&&k();return;case"done":{if(G.sessionId!==u.current)return;G.stopReason==="max_turns_reached"&&r(W=>ni(W,{type:"text",text:`
|
|
1908
1908
|
|
|
1909
1909
|
---
|
|
1910
1910
|
⚠️ Reached the maximum number of steps for this turn. Send "continue" to pick up where I left off.`})),(V=p.current)==null||V.call(p,G.sessionId);const L=h.current;if(L.length>0){const W=L.join(`
|
|
@@ -2002,7 +2002,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
2002
2002
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nke(e,t){if(e){if(typeof e=="string")return SD(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?SD(e,t):void 0}}function SD(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Cke(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,s,l=[],u=!0,d=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(u=(r=a.call(n)).done)&&(l.push(r.value),l.length!==t);u=!0);}catch(h){d=!0,i=h}finally{try{if(!u&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(d)throw i}}return l}}function Tke(e){if(Array.isArray(e))return e}var Mke=()=>(A0e(),null);function Iv(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var Ike=b.forwardRef((e,t)=>{var n,r,i=b.useRef(null),a=b.useState({containerWidth:Iv((n=e.style)===null||n===void 0?void 0:n.width),containerHeight:Iv((r=e.style)===null||r===void 0?void 0:r.height)}),s=Mv(a,2),l=s[0],u=s[1],d=b.useCallback((m,p)=>{u(g=>{var w=Math.round(m),x=Math.round(p);return g.containerWidth===w&&g.containerHeight===x?g:{containerWidth:w,containerHeight:x}})},[]),h=b.useCallback(m=>{if(typeof t=="function"&&t(m),i.current!=null&&(i.current.disconnect(),i.current=null),m!=null&&typeof ResizeObserver<"u"){var p=m.getBoundingClientRect(),g=p.width,w=p.height;d(g,w);var x=_=>{var k=_[0];if(k!=null){var O=k.contentRect,N=O.width,T=O.height;d(N,T)}},E=new ResizeObserver(x);E.observe(m),i.current=E}},[t,d]);return b.useEffect(()=>()=>{var m=i.current;m!=null&&m.disconnect()},[d]),b.createElement(b.Fragment,null,b.createElement(Ph,{width:l.containerWidth,height:l.containerHeight}),b.createElement("div",zs({ref:h},e)))}),Rke=b.forwardRef((e,t)=>{var n=e.width,r=e.height,i=b.useState({containerWidth:Iv(n),containerHeight:Iv(r)}),a=Mv(i,2),s=a[0],l=a[1],u=b.useCallback((h,m)=>{l(p=>{var g=Math.round(h),w=Math.round(m);return p.containerWidth===g&&p.containerHeight===w?p:{containerWidth:g,containerHeight:w}})},[]),d=b.useCallback(h=>{if(typeof t=="function"&&t(h),h!=null){var m=h.getBoundingClientRect(),p=m.width,g=m.height;u(p,g)}},[t,u]);return b.createElement(b.Fragment,null,b.createElement(Ph,{width:s.containerWidth,height:s.containerHeight}),b.createElement("div",zs({ref:d},e)))}),Pke=b.forwardRef((e,t)=>{var n=e.width,r=e.height;return b.createElement(b.Fragment,null,b.createElement(Ph,{width:n,height:r}),b.createElement("div",zs({ref:t},e)))}),Dke=b.forwardRef((e,t)=>{var n=e.width,r=e.height;return typeof n=="string"||typeof r=="string"?b.createElement(Rke,zs({},e,{ref:t})):typeof n=="number"&&typeof r=="number"?b.createElement(Pke,zs({},e,{width:n,height:r,ref:t})):b.createElement(b.Fragment,null,b.createElement(Ph,{width:n,height:r}),b.createElement("div",zs({ref:t},e)))});function jke(e){return e?Ike:Dke}var Lke=b.forwardRef((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,s=e.onContextMenu,l=e.onDoubleClick,u=e.onMouseDown,d=e.onMouseEnter,h=e.onMouseLeave,m=e.onMouseMove,p=e.onMouseUp,g=e.onTouchEnd,w=e.onTouchMove,x=e.onTouchStart,E=e.style,_=e.width,k=e.responsive,O=e.dispatchTouchEvents,N=O===void 0?!0:O,T=b.useRef(null),C=jt(),M=b.useState(null),D=Mv(M,2),j=D[0],R=D[1],H=b.useState(null),P=Mv(H,2),G=P[0],q=P[1],X=Eke(),U=n_(),K=(U==null?void 0:U.width)>0?U.width:_,F=(U==null?void 0:U.height)>0?U.height:i,V=b.useCallback(Ae=>{X(Ae),typeof t=="function"&&t(Ae),R(Ae),q(Ae),Ae!=null&&(T.current=Ae)},[X,t,R,q]),$=b.useCallback(Ae=>{C(X6(Ae)),C(_i({handler:a,reactEvent:Ae}))},[C,a]),L=b.useCallback(Ae=>{C(vE(Ae)),C(_i({handler:d,reactEvent:Ae}))},[C,d]),W=b.useCallback(Ae=>{C(OU()),C(_i({handler:h,reactEvent:Ae}))},[C,h]),z=b.useCallback(Ae=>{C(vE(Ae)),C(_i({handler:m,reactEvent:Ae}))},[C,m]),ie=b.useCallback(()=>{C(n8())},[C]),he=b.useCallback(()=>{C(r8())},[C]),ge=b.useCallback(Ae=>{C(t8(Ae.key))},[C]),Se=b.useCallback(Ae=>{C(_i({handler:s,reactEvent:Ae}))},[C,s]),$e=b.useCallback(Ae=>{C(_i({handler:l,reactEvent:Ae}))},[C,l]),fe=b.useCallback(Ae=>{C(_i({handler:u,reactEvent:Ae}))},[C,u]),Ee=b.useCallback(Ae=>{C(_i({handler:p,reactEvent:Ae}))},[C,p]),Te=b.useCallback(Ae=>{C(_i({handler:x,reactEvent:Ae}))},[C,x]),de=b.useCallback(Ae=>{N&&C(o8(Ae)),C(_i({handler:w,reactEvent:Ae}))},[C,N,w]),nt=b.useCallback(Ae=>{C(_i({handler:g,reactEvent:Ae}))},[C,g]),He=jke(k);return b.createElement(YU.Provider,{value:j},b.createElement(Z$.Provider,{value:G},b.createElement(He,{width:K??(E==null?void 0:E.width),height:F??(E==null?void 0:E.height),className:gt("recharts-wrapper",r),style:Ske({position:"relative",cursor:"default",width:K,height:F},E),onClick:$,onContextMenu:Se,onDoubleClick:$e,onFocus:ie,onBlur:he,onKeyDown:ge,onMouseDown:fe,onMouseEnter:L,onMouseLeave:W,onMouseMove:z,onMouseUp:Ee,onTouchEnd:nt,onTouchMove:de,onTouchStart:Te,ref:V},b.createElement(Mke,null),n)))}),zke=["width","height","responsive","children","className","style","compact","title","desc"];function $ke(e,t){if(e==null)return{};var n,r,i=Bke(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Bke(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var h8=b.forwardRef((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,s=e.className,l=e.style,u=e.compact,d=e.title,h=e.desc,m=$ke(e,zke),p=si(m);return u?b.createElement(b.Fragment,null,b.createElement(Ph,{width:n,height:r}),b.createElement(xD,{otherAttributes:p,title:d,desc:h},a)):b.createElement(Lke,{className:s,style:l,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},b.createElement(xD,{otherAttributes:p,title:d,desc:h,ref:t},b.createElement(REe,null,a)))});function yE(){return yE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},yE.apply(null,arguments)}function _D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Uke(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?_D(Object(n),!0).forEach(function(r){Fke(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_D(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Fke(e,t,n){return(t=Hke(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Hke(e){var t=Kke(e,"string");return typeof t=="symbol"?t:t+""}function Kke(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var qke={top:5,right:5,bottom:5,left:5},Gke=Uke({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:qke,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},VA),m8=b.forwardRef(function(t,n){var r,i=zn(t.categoricalChartProps,Gke),a=t.chartName,s=t.defaultTooltipEventType,l=t.validateTooltipEventTypes,u=t.tooltipPayloadSearcher,d=t.categoricalChartProps,h={chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:l,tooltipPayloadSearcher:u,eventEmitter:void 0};return b.createElement(c8,{preloadedState:{options:h},reduxStoreName:(r=d.id)!==null&&r!==void 0?r:a},b.createElement(N6,{chartData:d.data}),b.createElement(u8,{layout:i.layout,margin:i.margin}),b.createElement(f8,{throttleDelay:i.throttleDelay,throttledEvents:i.throttledEvents}),b.createElement(d8,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),b.createElement(h8,yE({},i,{ref:n})))}),Vke=["axis"],Wke=b.forwardRef((e,t)=>b.createElement(m8,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Vke,tooltipPayloadSearcher:yA,categoricalChartProps:e,ref:t})),Yke=["axis","item"],Xke=b.forwardRef((e,t)=>b.createElement(m8,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Yke,tooltipPayloadSearcher:yA,categoricalChartProps:e,ref:t}));function Zke(e){var t=jt();return b.useEffect(()=>{t(tke(e))},[t,e]),null}var Qke=["layout"];function bE(){return bE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bE.apply(null,arguments)}function Jke(e,t){if(e==null)return{};var n,r,i=eOe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function eOe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function AD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function tOe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?AD(Object(n),!0).forEach(function(r){nOe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):AD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function nOe(e,t,n){return(t=rOe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rOe(e){var t=iOe(e,"string");return typeof t=="symbol"?t:t+""}function iOe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var aOe={top:5,right:5,bottom:5,left:5},p8=tOe({accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:aOe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},VA),oOe=b.forwardRef(function(t,n){var r,i=zn(t.categoricalChartProps,p8),a=i.layout,s=Jke(i,Qke),l=t.chartName,u=t.defaultTooltipEventType,d=t.validateTooltipEventTypes,h=t.tooltipPayloadSearcher,m={chartName:l,defaultTooltipEventType:u,validateTooltipEventTypes:d,tooltipPayloadSearcher:h,eventEmitter:void 0};return b.createElement(c8,{preloadedState:{options:m},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},b.createElement(N6,{chartData:i.data}),b.createElement(u8,{layout:a,margin:i.margin}),b.createElement(f8,{throttleDelay:i.throttleDelay,throttledEvents:i.throttledEvents}),b.createElement(d8,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),b.createElement(Zke,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),b.createElement(h8,bE({},s,{ref:n})))});function kD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function OD(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?kD(Object(n),!0).forEach(function(r){sOe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function sOe(e,t,n){return(t=lOe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lOe(e){var t=cOe(e,"string");return typeof t=="symbol"?t:t+""}function cOe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var uOe=["item"],dOe=OD(OD({},p8),{},{layout:"centric",startAngle:0,endAngle:360}),fOe=b.forwardRef((e,t)=>{var n=zn(e,dOe);return b.createElement(oOe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:uOe,tooltipPayloadSearcher:yA,categoricalChartProps:n,ref:t})});const fu=["#6366f1","#f59e0b","#10b981","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function hOe(e){const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;try{return JSON.parse(t)}catch{return null}}function mOe(e){var s;const t=((s=e.data)==null?void 0:s.values)??e.values??e.series;if(!t||typeof t!="object")return null;const n=t,r=Object.keys(n);if(r.length===0)return null;const i=n[r[0]];return!i||typeof i!="object"?null:Object.keys(i).map(l=>{var d;const u={label:l};for(const h of r)u[h]=((d=n[h])==null?void 0:d[l])??0;return u})}function pOe(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return"file"in t&&"sizeBytes"in t}function gOe(e){if(pOe(e))return null;if(Array.isArray(e))return e.length===0?null:typeof e[0]=="object"&&e[0]!==null?e:null;if(typeof e=="object"&&e!==null){const t=mOe(e);if(t)return t}return null}function vOe(e,t,n){return n.length===0?"table":n.length===1&&e.length<=8?"pie":e.map(a=>String(a[t]??"")).some(a=>/^\d{4}-\d{2}/.test(a))||e.length>20?"line":"bar"}function yOe(e){const t=[...new Set(e.flatMap(Object.keys))],n=[];let r="";for(const i of t){const a=e.map(l=>l[i]).filter(l=>l!=null);a.filter(l=>typeof l=="number").length>a.length*.5?n.push(i):r||(r=i)}return r||(r=t[0]??"label"),{labelKey:r,numericKeys:n}}function bOe({data:e}){const{rows:t,labelKey:n,numericKeys:r,chartType:i}=b.useMemo(()=>{const a=gOe(e);if(!a||a.length===0)return{rows:null,labelKey:"",numericKeys:[],chartType:"table"};const{labelKey:s,numericKeys:l}=yOe(a),u=vOe(a,s,l);return{rows:a,labelKey:s,numericKeys:l,chartType:u}},[e]);return t?i==="table"?y.jsx(ND,{rows:t}):y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"h-64 w-full",children:y.jsx(Tde,{width:"100%",height:"100%",children:i==="pie"?y.jsxs(fOe,{children:[y.jsx(A6,{data:t,dataKey:r[0],nameKey:n,cx:"50%",cy:"50%",outerRadius:80,label:!0,children:t.map((a,s)=>y.jsx(Xh,{fill:fu[s%fu.length]},s))}),y.jsx(ww,{}),y.jsx(fg,{})]}):i==="line"?y.jsxs(Wke,{data:t,children:[y.jsx(lE,{strokeDasharray:"3 3",className:"opacity-30"}),y.jsx(hE,{dataKey:n,tick:{fontSize:11}}),y.jsx(gE,{tick:{fontSize:11}}),y.jsx(ww,{}),r.length>1&&y.jsx(fg,{}),r.map((a,s)=>y.jsx(H6,{type:"monotone",dataKey:a,stroke:fu[s%fu.length],strokeWidth:2,dot:!1},a))]}):y.jsxs(Xke,{data:t,children:[y.jsx(lE,{strokeDasharray:"3 3",className:"opacity-30"}),y.jsx(hE,{dataKey:n,tick:{fontSize:11}}),y.jsx(gE,{tick:{fontSize:11}}),y.jsx(ww,{}),r.length>1&&y.jsx(fg,{}),r.map((a,s)=>y.jsx(W6,{dataKey:a,fill:fu[s%fu.length],radius:[3,3,0,0]},a))]})})}),y.jsx(ND,{rows:t})]}):y.jsx("pre",{className:"text-xs whitespace-pre-wrap break-words",children:JSON.stringify(e,null,2)})}function ND({rows:e}){const t=[...new Set(e.flatMap(Object.keys))];return y.jsx("div",{className:"overflow-auto max-h-96 rounded border text-xs",children:y.jsxs("table",{className:"w-full text-left",children:[y.jsx("thead",{className:"bg-muted sticky top-0",children:y.jsx("tr",{children:t.map(n=>y.jsx("th",{className:"px-2 py-1 font-medium",children:n},n))})}),y.jsx("tbody",{children:e.map((n,r)=>y.jsx("tr",{className:"border-t",children:t.map(i=>{const a=n[i],s=a==null?"":typeof a=="object"?JSON.stringify(a,null,2):String(a);return y.jsx("td",{className:"px-2 py-1 max-w-[400px] whitespace-pre-wrap break-words align-top",title:s,children:s},i)})},r))})]})})}const xE=/^\/uploads\//;function WA({src:e,alt:t,className:n,onClick:r}){const{getToken:i}=$E(),[a,s]=b.useState(xE.test(e)?null:e);return b.useEffect(()=>{if(!xE.test(e)){s(e);return}let l=null,u=!1;return s(null),(async()=>{try{const d=await i(),h=await fetch(e,{headers:d?{Authorization:`Bearer ${d}`}:{}});if(!h.ok)throw new Error(`${h.status} ${h.statusText}`);l=URL.createObjectURL(await h.blob()),u?URL.revokeObjectURL(l):s(l)}catch(d){console.error("[authed-image] load failed:",e,d)}})(),()=>{u=!0,l&&URL.revokeObjectURL(l)}},[e,i]),a?y.jsx("img",{src:a,alt:t??"",className:n,onClick:()=>r==null?void 0:r(a)}):y.jsx("div",{className:n,"aria-busy":"true"})}function xOe({src:e,name:t,className:n}){const{getToken:r}=$E(),i=async a=>{if(xE.test(e)){a.preventDefault();try{const s=await r(),l=await fetch(e,{headers:s?{Authorization:`Bearer ${s}`}:{}});if(!l.ok)throw new Error(`${l.status} ${l.statusText}`);const u=URL.createObjectURL(await l.blob()),d=document.createElement("a");d.href=u,d.download=t,d.click(),setTimeout(()=>URL.revokeObjectURL(u),1e4)}catch(s){console.error("[authed-file] open failed:",e,s)}}};return y.jsxs("a",{href:e,onClick:i,target:"_blank",rel:"noopener noreferrer",className:n,children:[y.jsx(UE,{className:"w-4 h-4 shrink-0"}),y.jsx("span",{className:"truncate max-w-[200px]",children:t})]})}const wE=1,g8=10,$f={scale:1,tx:0,ty:0},CD=e=>Math.min(g8,Math.max(wE,e));function wOe({src:e,alt:t=""}){const n=b.useRef(null),r=b.useRef(null),[i,a]=b.useState($f),[s,l]=b.useState(!1),u=(_,k)=>{var N;const O=(N=n.current)==null?void 0:N.getBoundingClientRect();return O?{cx:_-O.left-O.width/2,cy:k-O.top-O.height/2}:{cx:0,cy:0}},d=b.useCallback((_,k,O)=>{a(N=>{const T=CD(_);if(T===N.scale)return N;if(T<=wE)return $f;const C=T/N.scale;return{scale:T,tx:k-C*(k-N.tx),ty:O-C*(O-N.ty)}})},[]),h=_=>{_.preventDefault();const{cx:k,cy:O}=u(_.clientX,_.clientY),N=_.deltaY<0?1.15:1/1.15;a(T=>{const C=CD(T.scale*N);if(C===T.scale)return T;if(C<=wE)return $f;const M=C/T.scale;return{scale:C,tx:k-M*(k-T.tx),ty:O-M*(O-T.ty)}})},m=_=>{i.scale<=1||(_.currentTarget.setPointerCapture(_.pointerId),r.current={x:_.clientX,y:_.clientY,tx:i.tx,ty:i.ty},l(!0))},p=_=>{const k=r.current;k&&a(O=>({...O,tx:k.tx+(_.clientX-k.x),ty:k.ty+(_.clientY-k.y)}))},g=()=>{r.current=null,l(!1)},w=_=>{const{cx:k,cy:O}=u(_.clientX,_.clientY);i.scale>1?a($f):d(2.5,k,O)},x=_=>d(i.scale*_,0,0),E=i.scale>1;return y.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[y.jsx("div",{ref:n,className:"w-full h-full overflow-hidden flex items-center justify-center",onWheel:h,onPointerDown:m,onPointerMove:p,onPointerUp:g,onPointerCancel:g,onDoubleClick:w,style:{cursor:E?s?"grabbing":"grab":"zoom-in",touchAction:"none"},children:y.jsx("img",{src:e,alt:t,draggable:!1,className:"max-w-full max-h-[85vh] object-contain rounded-lg select-none",style:{transform:`translate(${i.tx}px, ${i.ty}px) scale(${i.scale})`,transition:s?"none":"transform 0.08s ease-out",transformOrigin:"center center"}})}),y.jsxs("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1 rounded-full bg-background/90 border shadow-sm px-1.5 py-1 backdrop-blur",children:[y.jsx("button",{type:"button",onClick:()=>x(1/1.4),title:"Zoom out",className:"p-1.5 rounded-full hover:bg-muted transition-colors disabled:opacity-40",disabled:!E,children:y.jsx(_V,{className:"w-4 h-4"})}),y.jsxs("span",{className:"text-xs tabular-nums w-11 text-center text-muted-foreground select-none",children:[Math.round(i.scale*100),"%"]}),y.jsx("button",{type:"button",onClick:()=>x(1.4),title:"Zoom in",className:"p-1.5 rounded-full hover:bg-muted transition-colors disabled:opacity-40",disabled:i.scale>=g8,children:y.jsx(SV,{className:"w-4 h-4"})}),y.jsx("button",{type:"button",onClick:()=>a($f),title:"Reset",className:"p-1.5 rounded-full hover:bg-muted transition-colors disabled:opacity-40",disabled:!E,children:y.jsx(FE,{className:"w-4 h-4"})})]})]})}const EOe=new Set(["p","li","h1","h2","h3","h4","h5","h6","blockquote","td","th"]),SOe=()=>e=>{const t=n=>{for(const r of n.children??[])r.type==="element"&&(EOe.has(r.tagName)&&(r.properties??(r.properties={}),r.properties.dir="auto"),t(r))};t(e)};var ZD,QD;const _Oe=typeof window<"u"&&!!((QD=(ZD=window.webkit)==null?void 0:ZD.messageHandlers)!=null&&QD.appwrap);function AOe({text:e,onImageClick:t}){const n=e.replace(/\[Image #\d+\]\s*/g,"").trim();return _Oe?y.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert break-words min-w-0 whitespace-pre-wrap",children:n}):y.jsx(d3,{remarkPlugins:[D3],rehypePlugins:[rz,SOe],className:"prose prose-sm max-w-none dark:prose-invert prose-pre:bg-muted prose-pre:border prose-code:before:content-none prose-code:after:content-none break-words min-w-0",components:{pre:({children:r,...i})=>y.jsx(BOe,{...i,children:r}),a:({href:r,children:i})=>y.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:i}),img:({src:r,alt:i})=>y.jsx(WA,{src:r??"",alt:i??"",className:"max-h-[80vh] max-w-full rounded-xl border object-contain cursor-pointer hover:opacity-80 transition-opacity",onClick:a=>t==null?void 0:t(a)})},children:n})}function TD(e){const t=new Date(e),n=new Date,r=t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(t.toDateString()===n.toDateString())return r;const i=t.getFullYear()===n.getFullYear();return`${t.toLocaleDateString([],{month:"short",day:"numeric",...!i&&{year:"numeric"}})}, ${r}`}const MD="shraga:showDetails",ID=150;function kOe({messages:e,busy:t,connectionStatus:n,onPermissionRespond:r,onQuestionRespond:i,onReplay:a,onEdit:s,onFork:l,multiParticipant:u,statusItems:d}){var W;const h=za(),m=b.useRef(null),p=b.useRef(null),g=b.useRef(!0),[w,x]=b.useState(()=>localStorage.getItem(MD)==="true"),[E,_]=b.useState(null),k=b.useRef({onPermissionRespond:r,onQuestionRespond:i,onReplay:a,onEdit:s,onFork:l});k.current={onPermissionRespond:r,onQuestionRespond:i,onReplay:a,onEdit:s,onFork:l};const O=b.useCallback((z,ie,he)=>{var ge,Se;return(Se=(ge=k.current).onPermissionRespond)==null?void 0:Se.call(ge,z,ie,he)},[]),N=b.useCallback((z,ie)=>{var he,ge;return(ge=(he=k.current).onQuestionRespond)==null?void 0:ge.call(he,z,ie)},[]),T=b.useCallback((z,ie,he)=>{var ge,Se;return(Se=(ge=k.current).onReplay)==null?void 0:Se.call(ge,z,ie,he)},[]),C=b.useCallback((z,ie,he)=>{var ge,Se;return(Se=(ge=k.current).onEdit)==null?void 0:Se.call(ge,z,ie,he)},[]),M=b.useCallback(z=>{var ie,he;return(he=(ie=k.current).onFork)==null?void 0:he.call(ie,z)},[]),D=()=>{const z=p.current;z&&(g.current=z.scrollHeight-z.scrollTop-z.clientHeight<80)},j=b.useRef(new Map),R=b.useRef(new WeakSet),H=b.useRef(0),P=b.useMemo(()=>(ROe(j.current,R.current,e)&&H.current++,H.current),[e]),G=j.current,[q,X]=b.useState(ID),U=Math.max(0,e.length-q),K=U>0?e.slice(U):e,F=b.useCallback(()=>X(z=>z+ID),[]),V=b.useRef(null),$=b.useRef(null);if(b.useEffect(()=>{const z=$.current;if(!z||U===0)return;const ie=new IntersectionObserver(he=>{if(!he.some($e=>$e.isIntersecting)||g.current)return;const ge=p.current,Se=(ge==null?void 0:ge.scrollHeight)??0;V.current={box:ge,before:Se},F()},{rootMargin:"400px"});return ie.observe(z),()=>ie.disconnect()},[U,q,F]),b.useEffect(()=>{const z=V.current;z!=null&&z.box&&(V.current=null,z.box.scrollTop+=z.box.scrollHeight-z.before)},[q]),b.useEffect(()=>{var z;g.current&&((z=m.current)==null||z.scrollIntoView({behavior:t?"auto":"smooth"}))},[e,t]),e.length===0&&!t)return y.jsx("div",{className:"flex-1 flex items-center justify-center",children:y.jsxs("div",{className:"text-center space-y-3 max-w-md px-4",children:[y.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-muted flex items-center justify-center",children:y.jsx(Nu,{className:"w-6 h-6 text-muted-foreground"})}),y.jsx("h2",{className:"text-lg font-medium",children:"How can I help?"}),y.jsx("p",{className:"text-sm text-muted-foreground",children:"I can read files, edit code, run commands, search the web, and use any configured MCP tools on the remote machine."})]})});const L=()=>{x(z=>(localStorage.setItem(MD,String(!z)),!z))};return y.jsxs("div",{ref:p,onScroll:D,className:"flex-1 overflow-y-auto overflow-x-hidden",children:[y.jsxs("div",{className:"max-w-3xl mx-auto px-2 sm:px-4 py-4 sm:py-6 space-y-1",children:[y.jsx("div",{className:"flex justify-end mb-2",children:y.jsxs("button",{onClick:L,className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:w?"Hide tool details":"Show tool details",children:[w?y.jsx(ZG,{className:"w-3.5 h-3.5"}):y.jsx(XG,{className:"w-3.5 h-3.5"}),"Details"]})}),U>0&&y.jsxs("div",{ref:$,className:"py-3 text-center text-[11px] text-muted-foreground/60",children:[U," earlier message",U===1?"":"s"," · scroll up to load"]}),K.map((z,ie)=>{const he=U+ie;return y.jsx(OOe,{message:z,messageIndex:he,isLast:he===e.length-1,showDetails:w,onPermissionRespond:O,onQuestionRespond:N,onReplay:T,onEdit:C,onFork:M,onImageClick:_,busy:t&&he===e.length-1,screenMap:G,screenVersion:P,multiParticipant:u},z.id)}),t&&((W=e[e.length-1])==null?void 0:W.role)!=="assistant"&&y.jsxs("div",{className:"flex gap-3 py-4",children:[y.jsx("div",{className:"w-7 h-7 rounded-full bg-muted flex items-center justify-center shrink-0 mt-0.5",children:y.jsx(Nu,{className:"w-4 h-4 text-muted-foreground"})}),y.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:y.jsxs("span",{className:"inline-flex gap-1",children:[y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground animate-bounce",style:{animationDelay:"0ms"}}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground animate-bounce",style:{animationDelay:"150ms"}}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground animate-bounce",style:{animationDelay:"300ms"}})]})})]}),!!(d!=null&&d.length)&&h.statusChips&&y.jsxs("div",{className:"flex gap-3 py-2",children:[y.jsx("div",{className:"w-7 h-7 rounded-full bg-muted flex items-center justify-center shrink-0 mt-0.5",children:y.jsx(Nu,{className:"w-4 h-4 text-muted-foreground"})}),y.jsx("div",{className:"flex-1 min-w-0 pt-1",children:h.statusChips(d)})]}),n&&n!=="update_available"&&y.jsx("div",{className:ze("text-center text-xs py-1.5 rounded-md transition-opacity",n==="reconnected"?"text-green-600 dark:text-green-400":"text-amber-600 dark:text-amber-400"),children:n==="server_restarting"?"Server updating — reconnecting automatically…":n==="disconnected"?"Connection lost — reconnecting...":"Reconnected."}),y.jsx("div",{ref:m})]}),y.jsx(Oo,{open:!!E,onOpenChange:z=>{z||_(null)},children:y.jsx(Na,{className:"max-w-[90vw] max-h-[90vh] w-[90vw] h-[90vh] p-2 flex items-center justify-center bg-background/95",children:E&&y.jsx(wOe,{src:E})})})]})}const OOe=b.memo(function({message:t,messageIndex:n,isLast:r,showDetails:i,onPermissionRespond:a,onQuestionRespond:s,onReplay:l,onEdit:u,onFork:d,onImageClick:h,busy:m,screenMap:p,multiParticipant:g}){var H;const w=t.blocks.find(P=>P.type==="compact_marker");if(w&&w.type==="compact_marker")return y.jsx(NOe,{summary:w.summary,compactedCount:w.compactedCount});const x=t.role==="user",E=x?((H=t.blocks.find(P=>P.type==="text"))==null?void 0:H.text)??"":"",_=x?t.blocks.filter(P=>P.type==="image"||P.type==="file").map(P=>P.type==="image"?{url:P.src,name:P.src.split("/").pop()??"image",mimeType:"image/png",path:P.src}:{url:P.src,name:P.name,mimeType:P.mimeType,path:P.src}):void 0,[k,O]=b.useState(!1),[N,T]=b.useState(""),[C,M]=b.useState(!1),D=b.useRef(null),j=()=>{T(E),O(!0),setTimeout(()=>{const P=D.current;P&&(P.style.height="auto",P.style.height=P.scrollHeight+"px",P.focus(),P.setSelectionRange(P.value.length,P.value.length))},0)},R=()=>{const P=N.trim();P&&(O(!1),u==null||u(t.id,P,_!=null&&_.length?_:void 0))};return y.jsxs("div",{className:ze("flex gap-3 py-4 group/row",x&&"flex-row-reverse"),onTouchStart:P=>{P.target.closest("button")||M(G=>!G)},children:[!x&&y.jsx("div",{className:"w-7 h-7 rounded-full bg-primary/10 flex items-center justify-center shrink-0 mt-0.5",children:y.jsx(Nu,{className:"w-4 h-4 text-primary"})}),x&&y.jsx("div",{className:"w-7 h-7 rounded-full bg-muted flex items-center justify-center shrink-0 mt-0.5",children:y.jsx(xV,{className:"w-4 h-4 text-muted-foreground"})}),y.jsxs("div",{className:ze("min-w-0 max-w-[92%] sm:max-w-[85%] space-y-2"),children:[g&&x&&t.senderName&&y.jsx("div",{className:"text-[11px] font-medium text-muted-foreground text-right px-1",children:t.senderName}),k?y.jsxs("div",{className:"inline-block text-left w-full",children:[y.jsx("textarea",{ref:D,value:N,onChange:P=>{T(P.target.value),P.target.style.height="auto",P.target.style.height=P.target.scrollHeight+"px"},onKeyDown:P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),R()),P.key==="Escape"&&O(!1)},className:"w-full rounded-xl border bg-muted/50 px-4 py-2.5 text-sm resize-none outline-none focus:ring-1 focus:ring-primary min-h-[40px]"}),y.jsxs("div",{className:"flex gap-1 justify-end mt-1",children:[y.jsx("button",{onClick:()=>O(!1),className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Cancel",children:y.jsx(Bs,{className:"w-3.5 h-3.5"})}),y.jsx("button",{onClick:R,className:"p-1 rounded-md text-primary hover:bg-primary/10 transition-colors",title:"Send",children:y.jsx(Ag,{className:"w-3.5 h-3.5"})})]})]}):y.jsxs(y.Fragment,{children:[t.blocks.filter(P=>i?!0:P.type==="tool_use"&&P.tool==="AskUserQuestion"?t.blocks.some(G=>G.type==="tool_result"&&G.toolUseId===P.toolUseId):P.type!=="tool_use"&&P.type!=="tool_result"&&P.type!=="thinking").filter(P=>P.type!=="tool_result"?!0:!t.blocks.some(G=>G.type==="tool_use"&&G.toolUseId===P.toolUseId)).map((P,G,q)=>{const X=P.type==="tool_use"?t.blocks.find(U=>U.type==="tool_result"&&U.toolUseId===P.toolUseId):void 0;return y.jsx(COe,{block:P,isUser:x,ts:t.ts,onPermissionRespond:a,onQuestionRespond:s,pairedResult:X,onImageClick:h,busy:m,screenMap:p},G)}),x&&E&&y.jsxs("div",{className:ze("flex gap-1 items-center justify-end transition-opacity",C?"opacity-100":"opacity-0 group-hover/row:opacity-100"),children:[t.ts&&y.jsx("span",{className:"text-[10px] text-muted-foreground/50 select-none mr-1",children:TD(t.ts)}),y.jsx("button",{onClick:()=>l==null?void 0:l(t.id,E,_!=null&&_.length?_:void 0),className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Replay",children:y.jsx(dV,{className:"w-3.5 h-3.5"})}),y.jsx("button",{onClick:j,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Edit & resend",children:y.jsx(KE,{className:"w-3.5 h-3.5"})})]}),!x&&!(m&&r)&&y.jsxs("div",{className:ze("flex gap-1 items-center transition-opacity",C?"opacity-100":"opacity-0 group-hover/row:opacity-100"),children:[t.ts&&y.jsx("span",{className:"text-[10px] text-muted-foreground/40 select-none mr-1",children:TD(t.ts)}),y.jsx("button",{onClick:()=>d==null?void 0:d(n),className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"Fork from here",children:y.jsx(cL,{className:"w-3.5 h-3.5"})})]})]})]})]})});function NOe({summary:e,compactedCount:t}){const[n,r]=b.useState(!1);return y.jsxs("div",{className:"py-3",children:[y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsx("div",{className:"flex-1 border-t border-amber-500/30"}),y.jsxs("button",{onClick:()=>r(!n),className:"flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 hover:bg-amber-500/20 transition-colors",children:[y.jsx(HE,{className:"w-3 h-3"}),"Compacted · ",t," messages",y.jsx(Xs,{className:ze("w-3 h-3 transition-transform",n&&"rotate-90")})]}),y.jsx("div",{className:"flex-1 border-t border-amber-500/30"})]}),n&&y.jsx("div",{className:"mt-2 mx-auto max-w-2xl px-4 py-3 rounded-lg border border-amber-500/20 bg-amber-500/5 text-xs text-muted-foreground whitespace-pre-wrap",children:e})]})}function COe({block:e,isUser:t,ts:n,onPermissionRespond:r,onQuestionRespond:i,pairedResult:a,onImageClick:s,busy:l,screenMap:u}){var h;const d=za();return e.type==="image"?y.jsx(WA,{src:e.src,className:"max-h-[80vh] max-w-full rounded-xl border object-contain cursor-pointer hover:opacity-80 transition-opacity",onClick:m=>s==null?void 0:s(m)}):e.type==="file"?y.jsx("div",{children:y.jsx(xOe,{src:e.src,name:e.name,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border bg-muted/50 text-sm text-muted-foreground hover:bg-muted transition-colors"})}):e.type==="context"?y.jsx(MOe,{label:e.label,text:e.text}):e.type==="thinking"?y.jsx(IOe,{text:e.text}):e.type==="error"?y.jsx(TOe,{text:e.text,ts:n}):e.type==="text"?t?y.jsx("div",{dir:"auto",className:"inline-block bg-primary text-primary-foreground rounded-2xl rounded-tr-sm px-4 py-2.5 text-sm break-words min-w-0 max-w-full whitespace-pre-wrap",children:e.text}):y.jsx("div",{className:"text-sm",dir:"auto",children:y.jsx(AOe,{text:e.text,onImageClick:s})}):e.type==="tool_use"?e.tool==="AskUserQuestion"&&(a!=null&&a.output)?y.jsx(DOe,{input:e.input,result:a.output}):y.jsx(jOe,{block:e,tool:e.tool,input:e.input,result:a==null?void 0:a.output,busy:l,screenMap:u}):e.type==="tool_result"?y.jsx(LOe,{output:e.output}):e.type==="permission_request"?y.jsx(zOe,{id:e.id,tool:e.tool,input:e.input,onRespond:r}):e.type==="question_request"?y.jsx($Oe,{id:e.id,questions:e.questions,onRespond:i}):((h=d.extensionBlocks)==null?void 0:h.call(d,{block:e,onImageClick:s}))??null}function TOe({text:e,ts:t}){const n=Hre(e,t??Date.now());return y.jsxs("div",{dir:"auto",className:"border border-destructive/40 rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive break-words",children:[y.jsx("span",{className:"font-medium",children:"⚠️ Run failed"}),y.jsx("div",{className:"mt-1 text-xs opacity-90 whitespace-pre-wrap font-mono",children:n})]})}function MOe({label:e,text:t}){const[n,r]=b.useState(!1);return y.jsxs("div",{className:"border border-blue-500/20 rounded-lg overflow-hidden text-xs bg-blue-500/5",children:[y.jsxs("button",{onClick:()=>r(!n),className:"flex items-center gap-1.5 w-full px-3 py-2 hover:bg-blue-500/10 transition-colors text-left",children:[y.jsx(rV,{className:"w-3.5 h-3.5 text-blue-400 shrink-0"}),y.jsx("span",{className:"text-blue-300 font-medium",children:e}),y.jsx(Xs,{className:ze("w-3.5 h-3.5 text-muted-foreground transition-transform shrink-0 ml-auto",n&&"rotate-90")})]}),n&&y.jsx("div",{className:"px-3 py-2 border-t border-blue-500/20 text-muted-foreground whitespace-pre-wrap",children:t})]})}function IOe({text:e}){const[t,n]=b.useState(!1),r=e.slice(0,120).replace(/\n/g," ");return y.jsxs("div",{className:"border border-violet-500/20 rounded-lg overflow-hidden text-xs bg-violet-500/5",children:[y.jsxs("button",{onClick:()=>n(!t),className:"flex items-center gap-1.5 w-full px-3 py-2 hover:bg-violet-500/10 transition-colors text-left",children:[y.jsx(GG,{className:"w-3.5 h-3.5 text-violet-400 shrink-0"}),y.jsx("span",{className:"text-violet-300 font-medium",children:"Thinking"}),y.jsx("span",{className:"text-muted-foreground truncate",children:r}),y.jsx(Xs,{className:ze("w-3.5 h-3.5 text-muted-foreground transition-transform shrink-0 ml-auto",t&&"rotate-90")})]}),t&&y.jsx("div",{className:"px-3 py-2 border-t border-violet-500/20 text-muted-foreground whitespace-pre-wrap",children:e})]})}function ROe(e,t,n){let r=!1;for(const i of n)for(const a of i.blocks)if(!(a.type!=="tool_result"||!a.output)&&!t.has(a)&&(t.add(a),!!a.output.includes('"screen"')))try{const s=JSON.parse(a.output);typeof(s==null?void 0:s.sessionId)=="string"&&Array.isArray(s==null?void 0:s.screen)&&(e.set(s.sessionId,s.screen),r=!0)}catch{}return r}function POe(e){const t={},n=/"([^"]+)"="([^"]+)"/g;let r;for(;(r=n.exec(e))!==null;)t[r[1]]=r[2];return t}function DOe({input:e,result:t}){const n=e,r=(n==null?void 0:n.questions)??[],i=POe(t);return!r.length||!Object.keys(i).length?null:y.jsxs("div",{className:"border rounded-lg overflow-hidden text-xs bg-blue-500/5 border-blue-500/20",children:[y.jsxs("div",{className:"flex items-center gap-1.5 px-2 sm:px-3 py-2 bg-blue-50 dark:bg-blue-950/40",children:[y.jsx(qE,{className:"w-3.5 h-3.5 text-blue-400 shrink-0"}),y.jsx("span",{className:"font-medium text-blue-300",children:"Questions answered"})]}),y.jsx("div",{className:"px-2 sm:px-3 py-2 space-y-2",children:r.map((a,s)=>{const l=i[a.question];return l?y.jsxs("div",{className:"space-y-0.5",children:[y.jsxs("div",{className:"text-muted-foreground",children:[a.header?`${a.header}: `:"",a.question]}),y.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-300 font-medium",children:[y.jsx(Wi,{className:"w-2.5 h-2.5"}),l]})]},s):null})})]})}function jOe({block:e,tool:t,input:n,result:r,busy:i,screenMap:a}){var E;const s=za(),[l,u]=b.useState(!1),d=typeof n=="string"?n:JSON.stringify(n,null,2),h=typeof n=="object"&&n!==null&&Object.keys(n).length===0,m=h?"":Qoe(n),p=r!=null?v8(r.trim().replace(/\[Image #\d+\]\s*/g,"").trim()):void 0,g=r!=null,w=p?/^(Error|ERROR)|"status"\s*:\s*[45]\d\d|ENOENT|EACCES|Permission denied|command not found|No such file/i.test(p):!1,x=g?w?y.jsx(_g,{className:"w-3 h-3 text-red-400 shrink-0"}):y.jsx(Wi,{className:"w-3 h-3 text-green-400 shrink-0"}):null;return y.jsxs("div",{className:"text-xs min-w-0 space-y-2",children:[y.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[y.jsxs("button",{onClick:()=>u(!l),className:"flex items-center gap-1.5 w-full px-2 sm:px-3 py-2 bg-muted/50 hover:bg-muted transition-colors text-left min-w-0",children:[y.jsx(EV,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),y.jsx("span",{className:"font-medium text-foreground shrink-0",children:t}),!h&&y.jsx("span",{className:"text-muted-foreground truncate min-w-0",children:m}),g?x:i?y.jsx(Yi,{className:"w-3 h-3 text-muted-foreground animate-spin shrink-0"}):y.jsx("span",{title:"Interrupted",children:y.jsx(_g,{className:"w-3 h-3 text-amber-400 shrink-0"})}),y.jsx(Xs,{className:ze("w-3.5 h-3.5 text-muted-foreground transition-transform shrink-0 ml-auto",l&&"rotate-90")})]}),l&&y.jsxs("div",{className:"border-t",children:[!h&&y.jsx("pre",{className:"p-3 overflow-auto max-h-64 text-xs bg-background whitespace-pre-wrap break-all",children:d}),p&&y.jsx("pre",{className:ze("p-3 overflow-auto max-h-64 text-xs whitespace-pre-wrap break-words",!h&&"border-t",w?"bg-red-50 dark:bg-red-950/20 text-red-700 dark:text-red-300":"bg-muted/30 text-foreground/80"),children:p})]})]}),(E=s.toolRenderers)==null?void 0:E.call(s,{block:e,result:r,screens:a})]})}function v8(e){const t=e.split(`
|
|
2003
2003
|
`);return t.length<2||!t.filter(r=>r.length>0).every(r=>/^\s*\d+\t/.test(r))?e:t.map(r=>r.replace(/^\s*\d+\t/,"")).join(`
|
|
2004
2004
|
`)}function LOe({output:e}){const[t,n]=b.useState(!1),{trimmed:r,isError:i,chartData:a,isLong:s,preview:l}=b.useMemo(()=>{const p=e.trim().replace(/\[Image #\d+\]\s*/g,"").trim(),g=v8(p),w=/^(Error|ERROR)|"status"\s*:\s*[45]\d\d|ENOENT|EACCES|Permission denied|command not found|No such file/i.test(g);return{trimmed:g,isError:w,chartData:w?null:hOe(g),isLong:g.length>200,preview:g.slice(0,120).replace(/\n/g," ")}},[e]);if(!r)return null;const u=i?_g:Wi,d=i?"border-red-200 dark:border-red-900":"border-green-200 dark:border-green-900",h=i?"bg-red-50 dark:bg-red-950/30 hover:bg-red-100 dark:hover:bg-red-950/50":"bg-green-50 dark:bg-green-950/30 hover:bg-green-100 dark:hover:bg-green-950/50",m=i?"text-red-600 dark:text-red-400":"text-green-600 dark:text-green-400";return y.jsxs("div",{className:ze("border rounded-lg overflow-hidden text-xs min-w-0",d),children:[y.jsxs("button",{onClick:()=>n(!t),className:ze("flex items-center gap-1.5 w-full px-2 sm:px-3 py-2 transition-colors text-left min-w-0",h),children:[y.jsx(u,{className:ze("w-3.5 h-3.5 shrink-0",m)}),y.jsx("span",{className:"text-muted-foreground truncate flex-1 min-w-0",children:s?l+"…":l}),y.jsx(Xs,{className:ze("w-3.5 h-3.5 text-muted-foreground transition-transform shrink-0",t&&"rotate-90")})]}),t&&y.jsx("div",{className:"p-3 bg-background border-t",children:a?y.jsx(bOe,{data:a}):y.jsx("pre",{className:"overflow-auto max-h-96 text-xs whitespace-pre-wrap break-words",children:r})})]})}function zOe({id:e,tool:t,input:n,onRespond:r}){const[i,a]=b.useState(!1),s=JSON.stringify(n,null,2),l=Object.keys(n).join(", ");return y.jsxs("div",{className:"border-2 rounded-lg overflow-hidden text-xs border-amber-300 dark:border-amber-700 animate-in fade-in slide-in-from-bottom-2 min-w-0",children:[y.jsxs("div",{className:"flex items-center gap-1.5 px-2 sm:px-3 py-2 bg-amber-50 dark:bg-amber-950/40 min-w-0",children:[y.jsx(qE,{className:"w-4 h-4 text-amber-600 dark:text-amber-400 shrink-0"}),y.jsx("span",{className:"font-medium text-foreground shrink-0",children:t}),y.jsxs("button",{onClick:()=>a(!i),className:"text-muted-foreground truncate min-w-0 text-left hover:text-foreground transition-colors",children:[l,y.jsx(Xs,{className:ze("w-3.5 h-3.5 inline ml-1 transition-transform",i&&"rotate-90")})]})]}),i&&y.jsx("pre",{className:"p-3 overflow-auto max-h-48 text-xs bg-background border-t border-amber-200 dark:border-amber-800 whitespace-pre-wrap break-all",children:s}),y.jsxs("div",{className:"flex flex-wrap gap-2 px-2 sm:px-3 py-2 bg-amber-50/50 dark:bg-amber-950/20 border-t border-amber-200 dark:border-amber-800",children:[y.jsxs("button",{onClick:()=>r==null?void 0:r(e,!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-green-600 text-white hover:bg-green-700 transition-colors",children:[y.jsx(vT,{className:"w-3.5 h-3.5"}),"Allow"]}),y.jsxs("button",{onClick:()=>r==null?void 0:r(e,!0,!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border border-green-600 text-green-700 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-950/30 transition-colors",children:[y.jsx(vT,{className:"w-3.5 h-3.5"}),"Always Allow"]}),y.jsxs("button",{onClick:()=>r==null?void 0:r(e,!1),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-red-600 text-white hover:bg-red-700 transition-colors",children:[y.jsx(_g,{className:"w-3.5 h-3.5"}),"Deny"]})]})]})}function $Oe({id:e,questions:t,onRespond:n}){const[r,i]=b.useState({}),[a,s]=b.useState({}),[l,u]=b.useState(!1),d=za();b.useEffect(()=>{var x;return(x=d.onCardInteraction)==null?void 0:x.call(d,{id:e,questions:t,onAnswers:E=>{i(()=>{const _={};return t.forEach((k,O)=>{const N=E[k.question];N!=null&&(_[O]=new Set(Array.isArray(N)?N:[N]))}),_})}})},[e,t,d]);const h=(x,E,_)=>{i(k=>{const O=new Set(k[x]??[]);return _?O.has(E)?O.delete(E):O.add(E):(O.clear(),O.add(E)),{...k,[x]:O}})},m="__other__",p=t.filter((x,E)=>{var k;const _=r[E];return!(!_||_.size===0||_.has(m)&&!((k=a[E])!=null&&k.trim()))}).length,g=p===t.length,w=()=>{if(!g||l)return;const x={};t.forEach((E,_)=>{const k=[...r[_]??[]].map(O=>O===m?a[_].trim():O);x[E.question]=E.multiSelect?k:k[0]}),u(!0),n==null||n(e,x)};return y.jsxs("div",{className:"border-2 rounded-lg overflow-hidden text-xs border-blue-300 dark:border-blue-700 animate-in fade-in slide-in-from-bottom-2 min-w-0",children:[y.jsxs("div",{className:"flex items-center gap-1.5 px-2 sm:px-3 py-2 bg-blue-50 dark:bg-blue-950/40",children:[y.jsx(qE,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 shrink-0"}),y.jsx("span",{className:"font-medium text-foreground",children:"Questions for you"})]}),y.jsx("div",{className:"px-2 sm:px-3 py-2 space-y-4 bg-background",children:t.map((x,E)=>{const _=!!x.multiSelect,k=r[E]??new Set;return y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("div",{className:"font-medium text-foreground",children:x.question}),y.jsxs("div",{className:"space-y-1",children:[x.options.map(O=>y.jsxs("button",{disabled:l,onClick:()=>h(E,O.label,_),className:ze("flex items-start gap-2 w-full text-left px-2 py-1.5 rounded-md border transition-colors",k.has(O.label)?"border-blue-500 bg-blue-50 dark:bg-blue-950/40":"border-border hover:bg-muted/50"),children:[y.jsx("span",{className:ze("mt-0.5 w-3.5 h-3.5 shrink-0 border flex items-center justify-center",_?"rounded-sm":"rounded-full",k.has(O.label)?"bg-blue-500 border-blue-500":"border-muted-foreground"),children:k.has(O.label)&&y.jsx(Wi,{className:"w-2.5 h-2.5 text-white"})}),y.jsxs("span",{className:"min-w-0",children:[y.jsx("span",{className:"font-medium text-foreground",children:O.label}),O.description&&y.jsxs("span",{className:"text-muted-foreground",children:[" — ",O.description]})]})]},O.label)),y.jsxs("div",{className:ze("flex items-center gap-2 px-2 py-1.5 rounded-md border",k.has(m)?"border-blue-500 bg-blue-50 dark:bg-blue-950/40":"border-border"),children:[y.jsx("button",{disabled:l,onClick:()=>h(E,m,_),className:ze("w-3.5 h-3.5 shrink-0 border flex items-center justify-center",_?"rounded-sm":"rounded-full",k.has(m)?"bg-blue-500 border-blue-500":"border-muted-foreground"),children:k.has(m)&&y.jsx(Wi,{className:"w-2.5 h-2.5 text-white"})}),y.jsx("input",{type:"text",disabled:l,value:a[E]??"",placeholder:"Other…",onChange:O=>{s(N=>({...N,[E]:O.target.value})),O.target.value&&!k.has(m)&&h(E,m,_)},className:"flex-1 bg-transparent outline-none text-foreground placeholder:text-muted-foreground"})]})]})]},E)})}),y.jsxs("div",{className:"flex items-center gap-2 px-2 sm:px-3 py-2 bg-blue-50/50 dark:bg-blue-950/20 border-t border-blue-200 dark:border-blue-800",children:[y.jsxs("button",{onClick:w,disabled:!g||l,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-blue-600 text-white hover:bg-blue-700 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(Ag,{className:"w-3.5 h-3.5"}),l?"Sent":"Submit"]}),y.jsxs("span",{className:"text-muted-foreground",children:[p,"/",t.length," answered"]})]})]})}function BOe({children:e,...t}){const n=b.useRef(null);return y.jsxs("div",{className:"relative group",children:[y.jsx("pre",{ref:n,...t,className:"rounded-lg border bg-muted p-4 overflow-x-auto text-xs text-foreground",children:e}),y.jsx(UOe,{getText:()=>{var r;return((r=n.current)==null?void 0:r.textContent)||""}})]})}function UOe({getText:e}){const[t,n]=b.useState(!1);return y.jsx("button",{onClick:()=>{navigator.clipboard.writeText(e()),n(!0),setTimeout(()=>n(!1),2e3)},className:"absolute top-2 right-2 p-1.5 rounded-md bg-background/80 border opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy",children:t?y.jsx(Wi,{className:"w-3 h-3"}):y.jsx(Uv,{className:"w-3 h-3"})})}const y8=b.forwardRef(function({value:t,onChange:n,onKeyDown:r,onPaste:i,skills:a=[],workspaceFiles:s=[],placeholder:l,className:u,rows:d=1,disabled:h,autoResize:m=!0,maxHeight:p=200},g){const w=b.useRef(null),[x,E]=b.useState(null),[_,k]=b.useState(0);b.useImperativeHandle(g,()=>({focus:()=>{var D;return(D=w.current)==null?void 0:D.focus()},setValue:D=>{n(D),m&&N()}}));const O=x?[...a.filter(D=>D.toLowerCase().includes(x.query.toLowerCase())).map(D=>({kind:"skill",value:D})),...x.kind==="mention"?s.filter(D=>D.toLowerCase().includes(x.query.toLowerCase())).map(D=>({kind:"workspace",value:D})):[]]:[];function N(){setTimeout(()=>{const D=w.current;D&&(D.style.height="auto",D.style.height=Math.min(D.scrollHeight,p)+"px")},0)}const T=D=>{if(!x)return;const j=x.kind==="command"?"/":"@",R=t.slice(0,x.start),H=t.slice(x.start+x.query.length+1),P=`${R}${j}${D} ${H}`;n(P),E(null),setTimeout(()=>{const G=w.current;if(!G)return;m&&(G.style.height="auto",G.style.height=Math.min(G.scrollHeight,p)+"px");const q=R.length+D.length+2;G.setSelectionRange(q,q),G.focus()},0)},C=D=>{if(x&&O.length>0){if(D.key==="ArrowDown"){D.preventDefault(),k(j=>(j+1)%O.length);return}if(D.key==="ArrowUp"){D.preventDefault(),k(j=>(j-1+O.length)%O.length);return}if(D.key==="Enter"||D.key==="Tab"){D.preventDefault(),T(O[_].value);return}if(D.key==="Escape"){E(null);return}}r==null||r(D)},M=D=>{const j=D.target.value;n(j);const R=D.target;m&&(R.style.height="auto",R.style.height=Math.min(R.scrollHeight,p)+"px");const H=R.selectionStart??j.length,P=j.slice(0,H),G=P.match(/(?:^|\n)\/([\w-]*)$/),q=P.match(/@([\w\-./]*)$/);G?(E({query:G[1],start:G.index+(P[G.index]===`
|
|
2005
|
-
`?1:0),kind:"command"}),k(0)):q?(E({query:q[1],start:q.index,kind:"mention"}),k(0)):E(null)};return b.useEffect(()=>{const D=()=>E(null);return x&&document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[x]),y.jsxs("div",{className:"relative flex-1 min-w-0",children:[x&&O.length>0&&y.jsx("div",{className:"absolute bottom-full mb-1 left-0 z-50 bg-background border rounded-lg shadow-lg overflow-hidden min-w-[220px] max-h-64 overflow-y-auto",children:O.map((D,j)=>y.jsxs("button",{onMouseDown:R=>{R.preventDefault(),T(D.value)},className:`w-full text-left px-3 py-1.5 text-sm hover:bg-accent transition-colors flex items-center gap-2 ${j===_?"bg-accent":""}`,children:[y.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground shrink-0 w-14",children:(x==null?void 0:x.kind)==="command"?"cmd":D.kind==="skill"?"skill":"file"}),y.jsxs("span",{className:"truncate",children:[y.jsx("span",{className:"text-muted-foreground",children:(x==null?void 0:x.kind)==="command"?"/":"@"}),D.value]})]},`${D.kind}:${D.value}`))}),y.jsx("textarea",{ref:w,value:t,onChange:M,onKeyDown:C,onPaste:i,placeholder:l,disabled:h,rows:d,dir:"auto",className:u})]})}),YA="shraga:draft:";function Tw(e,t){const n=YA+(e??"new");t.trim()?localStorage.setItem(n,t):localStorage.removeItem(n)}function RD(e){return localStorage.getItem(YA+(e??"new"))??""}function PD(e){localStorage.removeItem(YA+(e??"new"))}const FOe=b.forwardRef(function({onSend:t,onSteer:n,onQueue:r,onRemoveQueued:i,queue:a,onUpload:s,onCancel:l,disabled:u,busy:d,skills:h=[],workspaceFiles:m=[],sessionId:p,inputCtx:g},w){var U,K;const x=za(),[E,_]=b.useState(()=>RD(p)),[k,O]=b.useState([]),[N,T]=b.useState(!1),C=b.useRef(null),M=b.useRef(null),D=b.useRef(p);b.useEffect(()=>{var $;if(D.current===p)return;const F=D.current;if(D.current=p,!p){PD(F),Tw(void 0,E);return}Tw(F,E);const V=RD(p);_(V),($=M.current)==null||$.setValue(V)},[p]);const j=b.useCallback(F=>{_(F),Tw(D.current,F)},[]);b.useImperativeHandle(w,()=>({prefill(F){var V,$;j(F),(V=M.current)==null||V.setValue(F),($=M.current)==null||$.focus()},setText(F){var V;j(F),(V=M.current)==null||V.setValue(F)},focus(){var F;(F=M.current)==null||F.focus()}}));const R=(F="send")=>{var $;const V=E.trim();!V&&k.length===0||(F==="steer"?n(V):F==="queue"?r(V):t(V,k.length>0?k:void 0),_(""),PD(D.current),O([]),($=M.current)==null||$.setValue(""))},H=typeof window<"u"&&((U=window.matchMedia)==null?void 0:U.call(window,"(pointer: coarse)").matches),P=F=>{if(F.key==="Enter"&&!F.shiftKey&&(!H||F.metaKey||F.ctrlKey)){F.preventDefault(),R(d?"steer":"send");return}if(F.key==="Tab"&&d&&E.trim()){F.preventDefault(),R("queue");return}},G=b.useCallback(async F=>{T(!0);try{const V=await s(F);V&&O($=>[...$,V])}finally{T(!1)}},[s]),q=b.useCallback(F=>{const V=Array.from(F.clipboardData.items);for(const $ of V)if($.type.startsWith("image/")||$.type==="application/pdf"){const L=$.getAsFile();L&&G(L)}},[G]),X=F=>{var $;const V=($=F.target.files)==null?void 0:$[0];V&&(G(V),F.target.value="")};return y.jsx("div",{className:"border-t bg-background",style:{paddingBottom:"env(safe-area-inset-bottom)"},children:y.jsxs("div",{className:"max-w-3xl mx-auto px-2 sm:px-4 py-3",children:[(k.length>0||N)&&y.jsxs("div",{className:"flex gap-2 mb-2 flex-wrap items-center",children:[k.map((F,V)=>y.jsxs("div",{className:"relative group",children:[F.mimeType.startsWith("image/")?y.jsx(WA,{src:F.url,alt:F.name,className:"h-16 w-16 object-cover rounded-lg border"}):y.jsxs("div",{className:"h-16 px-3 flex items-center gap-2 rounded-lg border bg-muted/50 text-xs text-muted-foreground",children:[y.jsx(UE,{className:"w-4 h-4 shrink-0"}),y.jsx("span",{className:"truncate max-w-[120px]",children:F.name})]}),y.jsx("button",{onClick:()=>O($=>$.filter((L,W)=>W!==V)),className:"absolute -top-1.5 -right-1.5 bg-destructive text-destructive-foreground rounded-full w-5 h-5 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity shadow-sm",children:y.jsx(Bs,{className:"w-3 h-3"})})]},V)),N&&y.jsx("span",{className:"text-xs text-muted-foreground animate-pulse",children:"Uploading…"})]}),y.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-xl border px-3 py-2",children:[y.jsx(we,{variant:"ghost",size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0",onClick:()=>{var F;return(F=C.current)==null?void 0:F.click()},disabled:u,title:"Attach file or image",children:y.jsx(lV,{className:"w-4 h-4"})}),y.jsx("input",{ref:C,type:"file",className:"hidden",onChange:X}),y.jsx(y8,{ref:M,value:E,onChange:j,onKeyDown:P,onPaste:q,skills:h,workspaceFiles:m,placeholder:d?"Steer or queue…":"Message Claude…",disabled:u,rows:1,className:"w-full bg-transparent border-none outline-none resize-none text-sm py-1.5 placeholder:text-muted-foreground min-h-[28px] max-h-[200px]"}),(K=x.inputAdornments)==null?void 0:K.call(x,g),d?y.jsxs("div",{className:"flex items-center gap-2",children:[E.trim()&&y.jsx(we,{size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>R("steer"),title:"Steer (inject into current turn)",children:y.jsx(Ag,{className:"w-4 h-4"})}),y.jsx(we,{variant:"destructive",size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>l(),title:"Stop generation",children:y.jsx(fL,{className:"w-3.5 h-3.5"})})]}):y.jsx(we,{size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>R(),disabled:u||N||!E.trim()&&k.length===0,children:y.jsx(Ag,{className:"w-4 h-4"})})]}),a.length>0&&y.jsx("div",{className:"flex gap-1.5 flex-wrap mt-2",children:a.map((F,V)=>y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-blue-50 dark:bg-blue-950/40 px-2.5 py-1 text-xs text-blue-700 dark:text-blue-300 ring-1 ring-inset ring-blue-600/20 dark:ring-blue-400/30",children:[y.jsx("span",{className:"truncate max-w-[200px]",children:F}),y.jsx("button",{onClick:()=>i(V),className:"hover:text-blue-900 dark:hover:text-blue-100",children:y.jsx(Bs,{className:"w-3 h-3"})})]},V))}),y.jsx("p",{className:"text-[10px] text-muted-foreground text-center mt-2",children:d?"Enter to steer (redirect) · Tab to queue (after done) · Shift+Enter for newline":"Enter to send · Shift+Enter for newline · @ for skills · / for commands"})]})})}),HOe={"fb-feed":[1080,1080],"fb-story":[1080,1920],"fb-landscape":[1200,628],"ig-square":[1080,1080],"ig-story":[1080,1920],"ig-landscape":[1080,566],"banner-leaderboard":[728,90],"banner-medium":[300,250]};function KOe({artifacts:e,selectedId:t,sessionId:n,getToken:r,onSelect:i,onClose:a}){var M;const[s,l]=b.useState(!1),[u,d]=b.useState(!1),[h,m]=b.useState(!1),[p,g]=b.useState(1),w=b.useRef(null),x=e.find(D=>D.id===t),E=b.useCallback(()=>{if(!w.current||!x)return;const{clientWidth:D,clientHeight:j}=w.current,R=32,H=D-R,P=j-R,[G,q]=x.dimensions;g(Math.min(H/G,P/q,1))},[x]);b.useEffect(()=>{let D=!0;return r().then(j=>fetch("/api/features",{headers:j?{Authorization:`Bearer ${j}`}:{}})).then(j=>j.json()).then(j=>{D&&m(!!j.artifactPngExport)}).catch(j=>console.error("[artifact] features fetch failed:",j)),()=>{D=!1}},[r]),b.useEffect(()=>{E();const D=w.current;if(!D)return;const j=new ResizeObserver(E);return j.observe(D),()=>j.disconnect()},[E]);const _=async()=>{if(x){d(!0);try{const D=await r(),j=await fetch(`/api/artifacts/${n}/${x.id}/export`,{method:"POST",headers:{"Content-Type":"application/json",...D?{Authorization:`Bearer ${D}`}:{}},body:JSON.stringify({dimensions:x.dimensions})});if(!j.ok)throw new Error(await j.text());const R=await j.blob(),H=URL.createObjectURL(R),P=document.createElement("a");P.href=H,P.download=`${x.title.replace(/\s+/g,"-").toLowerCase()}.png`,P.click(),URL.revokeObjectURL(H)}catch(D){console.error("[artifact] export failed:",D)}finally{d(!1)}}},k=x?(M=Object.entries(HOe).find(([,D])=>D[0]===x.dimensions[0]&&D[1]===x.dimensions[1]))==null?void 0:M[0]:null,[O,N]=(x==null?void 0:x.dimensions)??[0,0],T=O*p,C=N*p;return y.jsxs("div",{className:ze("flex flex-col border-l bg-background transition-all",s?"fixed inset-0 z-50":"fixed inset-0 z-50 sm:relative sm:inset-auto sm:z-auto sm:w-[480px] sm:shrink-0"),children:[y.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 border-b bg-muted/30",children:[y.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7 sm:hidden shrink-0",onClick:a,title:"Back to chat",children:y.jsx(oL,{className:"w-4 h-4"})}),e.length>1&&y.jsx("select",{className:"text-xs bg-transparent border rounded px-1 py-0.5 max-w-[160px] truncate",value:t??"",onChange:D=>i(D.target.value),children:e.map(D=>y.jsx("option",{value:D.id,children:D.title},D.id))}),e.length<=1&&x&&y.jsx("span",{className:"text-xs font-medium truncate max-w-[160px]",children:x.title}),x&&y.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[k??`${O}×${N}`,p<1&&` · ${Math.round(p*100)}%`]}),y.jsx("div",{className:"flex-1"}),h&&y.jsx(we,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:_,disabled:!x||u,title:"Export PNG",children:u?y.jsx("span",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):y.jsx(nV,{className:"w-3.5 h-3.5"})}),y.jsx(we,{variant:"ghost",size:"icon",className:"h-6 w-6 hidden sm:inline-flex",onClick:()=>l(!s),title:s?"Minimize":"Maximize",children:s?y.jsx(HE,{className:"w-3.5 h-3.5"}):y.jsx(FE,{className:"w-3.5 h-3.5"})}),y.jsx(we,{variant:"ghost",size:"icon",className:"h-6 w-6 hidden sm:inline-flex",onClick:a,title:"Close",children:y.jsx(Bs,{className:"w-3.5 h-3.5"})})]}),y.jsx("div",{ref:w,className:"flex-1 overflow-hidden flex items-center justify-center bg-muted/10",children:x?y.jsx("div",{style:{width:T,height:C},children:y.jsx("iframe",{src:`/api/artifacts/${n}/${x.id}`,sandbox:"allow-scripts",className:"border shadow-sm bg-white origin-top-left",style:{width:O,height:N,transform:`scale(${p})`},title:x.title})}):y.jsx("p",{className:"text-sm text-muted-foreground",children:"No artifact selected"})})]})}const Wy=b.forwardRef(({className:e,...t},n)=>y.jsx("textarea",{className:ze("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none",e),ref:n,...t}));Wy.displayName="Textarea";const b8="claude-sonnet-5",qOe="cursor/composer-2.5",EE={fable:"claude-fable-5-1","fable-5-1":"claude-fable-5-1","fable-5":"claude-fable-5",opus:"claude-opus-5","opus-5":"claude-opus-5","opus-4-8":"claude-opus-4-8","opus-4-7":"claude-opus-4-7","opus-4-6":"claude-opus-4-6",sonnet:"claude-sonnet-5","sonnet-5":"claude-sonnet-5","sonnet-4-6":"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"},GOe=/^\s*\[([^\]]*)\]\s*([\s\S]*)/,x8=["model","turns","thinking","think","effort","engine","resume"],SE=e=>/^[a-z0-9._-]+\/[a-z0-9./_-]+$/.test(e);let Yl=null;function VOe(e){Yl=e}function _E(e){const t=e.trim().toLowerCase();return EE[t]?{model:EE[t]}:(Yl==null?void 0:Yl(t))??null}function w8(e,t){const n=_E(t);return n?(e.model=n.model,n.engine&&!e.engine&&(e.engine=n.engine),!0):!1}function WOe(e){const t=e.split(",").map(n=>n.trim()).filter(Boolean);return t.length?t.every(n=>{const r=n.indexOf(":");if(r!==-1)return x8.includes(n.slice(0,r).trim().toLowerCase());const i=n.toLowerCase();return!!EE[i]||!!(Yl!=null&&Yl(i))||/^\d+$/.test(i)||["think","adaptive","nothink","nothinking"].includes(i)}):!1}function XA(e,t){let n=e;const r=[];for(;;){const i=n.match(GOe);if(!i)break;const a=i[1].trim();if((r.length||t!=null&&t.strict)&&a&&!WOe(a))break;r.push(a),n=i[2]}return{groups:r,body:n}}function YOe(e){const{groups:t,body:n}=XA(e);if(!t.length)return{prompt:e,directives:{}};const r=t.filter(Boolean).join(","),i=n.trim();if(!r)return{prompt:i,directives:{}};const a={};let s=0,l;const u=r.split(","),d=u.some(h=>{const m=h.indexOf(":");return m!==-1&&x8.includes(h.slice(0,m).trim().toLowerCase())});for(const h of u){const m=h.trim();if(!m)continue;const p=m.indexOf(":");if(p!==-1){const g=m.slice(0,p).trim().toLowerCase(),w=m.slice(p+1).trim().toLowerCase();l=XOe(a,g,w)??l}else{const g=m.toLowerCase();s===0&&w8(a,g)||(s<=1&&/^\d+$/.test(g)?a.turns=parseInt(g,10):["think","adaptive"].includes(g)?a.thinking="adaptive":["nothink","nothinking"].includes(g)?a.thinking="disabled":s===0&&(d&&!SE(g)&&(l??(l=m)),console.warn(SE(g)?`[directives] Provider-qualified model needs key form: "[model:${m}]"`:`[directives] Unknown model alias: "${m}"`))),s++}}return{prompt:i,directives:a,unresolvedModel:l}}function XOe(e,t,n){switch(t){case"model":if(w8(e,n))break;if(SE(n)){e.model=n;break}return n;case"turns":/^\d+$/.test(n)?e.turns=parseInt(n,10):console.warn(`[directives] Invalid turns value: "${n}"`);break;case"thinking":case"think":["adaptive","enabled","disabled"].includes(n)?e.thinking=n:console.warn(`[directives] Invalid thinking value: "${n}"`);break;case"effort":["low","medium","high","max"].includes(n)?e.effort=n:console.warn(`[directives] Invalid effort value: "${n}"`);break;case"engine":e.engine=n;break;case"resume":["on","true","1"].includes(n)?e.resume=!0:["off","false","0"].includes(n)?e.resume=!1:console.warn(`[directives] Invalid resume value: "${n}"`);break;default:console.warn(`[directives] Unknown directive key: "${t}"`)}}function ZOe(e){return t=>{const n=t.toLowerCase(),r=[];for(const{name:i,models:a}of e())for(const s of a){if(!s.value)continue;const l=s.value.toLowerCase();if(l===n)return{model:s.value,engine:i};l.slice(l.lastIndexOf("/")+1)===n&&r.push({model:s.value,engine:i})}return r.length===1?r[0]:(r.length>1&&console.warn(`[directives] Ambiguous model "${t}" (${r.map(i=>`${i.engine}:${i.model}`).join(", ")}) — use the full id`),null)}}let pg=[];VOe(ZOe(()=>pg));function E8(e,t=!0){const[n,r]=b.useState(pg),[i,a]=b.useState(!1);return b.useEffect(()=>{if(!t)return;let s=!0;return e().then(l=>{!l||!s||fetch("/api/engines",{headers:{Authorization:`Bearer ${l}`}}).then(u=>u.json()).then(u=>{s&&(pg=u.engines??[],r(pg),a(u.multiEngine??!1))}).catch(u=>console.warn("[engines] load failed",u))}),()=>{s=!1}},[t,e]),{engines:n,multiEngine:i}}async function Ti(e,t,n){const r=await t();let i;try{i=await fetch(e,{...n,headers:{Authorization:`Bearer ${r??""}`,"Content-Type":"application/json",...n==null?void 0:n.headers}})}catch(a){throw Bv(e,a),a}if($v(e,i,n==null?void 0:n.expect),!i.ok){const a=await i.json().catch(()=>({}));throw Object.assign(new Error(a.error||`${i.status} ${i.statusText}`),{status:i.status})}return i.json()}function QOe({getToken:e}){var O;const[t,n]=b.useState(null),[r,i]=b.useState(null),[a,s]=b.useState(""),[l,u]=b.useState(!1),[d,h]=b.useState(null),m=b.useCallback(()=>{Ti("/api/claude-account",e).then(n).catch(N=>{console.warn("[ClaudeAccountSection] status failed",N),h(N.message)})},[e]);b.useEffect(m,[m]);const p=async N=>{u(!0),h(null);try{await N()}catch(T){h(T.message)}finally{u(!1)}},g=N=>p(async()=>{const T=window.open("about:blank","_blank");try{const{url:C}=await Ti(`/api/claude-account/${N}/login`,e,{method:"POST"});T&&(T.location.href=C),i({target:N,url:C}),s("")}catch(C){throw T==null||T.close(),C}}),w=()=>p(async()=>{r&&(await Ti(`/api/claude-account/${r.target}/login/code`,e,{method:"POST",body:JSON.stringify({code:a})}),i(null),s(""),m())}),x=N=>p(async()=>{await Ti(`/api/claude-account/${N}`,e,{method:"DELETE"}),m()}),E=N=>p(async()=>{await Ti("/api/claude-account/me/use-shared",e,{method:"PUT",body:JSON.stringify({on:N})}),m()}),_=N=>{var T,C;return N==="global"?!((T=t==null?void 0:t.me)!=null&&T.connected)||!!t.me.useShared:!!((C=t==null?void 0:t.me)!=null&&C.connected)&&!t.me.useShared},k=(N,T,C,M=!0)=>{var R;const D=((R=t==null?void 0:t.usage)==null?void 0:R[N])??null,j=C!=null&&C.connected?[C.account??"Connected",C.subscriptionType].filter(Boolean).join(" · "):N==="me"||M?"Not connected":null;return y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsxs("div",{className:"min-w-0 space-y-0.5",children:[y.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[T,_(N)&&y.jsx("span",{className:"rounded-full bg-emerald-500/15 px-1.5 py-px text-[10px] font-medium text-emerald-500",children:"Active"})]}),y.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground min-w-0",children:[j&&y.jsx("span",{className:"truncate",children:j}),j&&D&&y.jsx("span",{"aria-hidden":!0,children:"·"}),y.jsx(q$,{usage:D,compact:!0})]})]}),M&&y.jsxs("div",{className:"flex shrink-0 gap-2",children:[N==="me"&&(C==null?void 0:C.connected)&&y.jsxs(y.Fragment,{children:[y.jsx(we,{size:"sm",variant:"outline",disabled:l,onClick:()=>E(!C.useShared),children:C.useShared?"Use mine":"Use shared"}),y.jsx(we,{size:"sm",variant:"outline",disabled:l,onClick:()=>x(N),children:"Sign out"})]}),y.jsx(we,{size:"sm",variant:"outline",disabled:l,onClick:()=>g(N),children:C!=null&&C.connected?"Replace":"Connect"})]})]})};return t?y.jsxs("div",{className:"space-y-4",children:[y.jsx("label",{className:"text-sm font-medium block",children:"Claude subscription"}),t.me?k("me","Your subscription",t.me):y.jsx("p",{className:"text-xs text-muted-foreground",children:"Personal subscription unavailable: you are not a contact on this agent."}),t.global?k("global","Shared subscription",t.global):((O=t.usage)==null?void 0:O.global)&&k("global","Shared subscription",null,!1),r&&y.jsxs("div",{className:"rounded-md bg-muted/50 px-3 py-2 space-y-2 text-xs",children:[y.jsxs("p",{children:["Sign in on the ",y.jsx("a",{className:"underline",href:r.url,target:"_blank",rel:"noreferrer",children:"Claude login page"}),", then paste the code it shows."]}),y.jsxs("div",{className:"flex gap-2",children:[y.jsx(ft,{value:a,onChange:N=>s(N.target.value),placeholder:"Paste code"}),y.jsx(we,{size:"sm",disabled:l||!a.trim(),onClick:w,children:"Submit"}),y.jsx(we,{size:"sm",variant:"ghost",disabled:l,onClick:()=>i(null),children:"Cancel"})]})]}),d&&y.jsx("p",{className:"text-xs text-destructive",children:d})]}):d?y.jsx("p",{className:"text-xs text-destructive",children:d}):null}const JOe=[{value:"",label:`Default (${b8})`},{value:"claude-fable-5-1",label:"Fable 5.1 — frontier, most capable"},{value:"claude-fable-5",label:"Fable 5"},{value:"claude-opus-5",label:"Opus 5 — most capable, best for complex/agentic tasks"},{value:"claude-opus-4-8",label:"Opus 4.8"},{value:"claude-opus-4-7",label:"Opus 4.7"},{value:"claude-opus-4-6",label:"Opus 4.6"},{value:"claude-sonnet-5",label:"Sonnet 5 — balanced speed & intelligence"},{value:"claude-sonnet-4-6",label:"Sonnet 4.6"},{value:"claude-haiku-4-5",label:"Haiku 4.5 — fastest"}],eNe=[{value:"acceptEdits",label:"Accept Edits (auto-approve file changes)"},{value:"plan",label:"Plan (read-only, suggest changes)"},{value:"bypassPermissions",label:"Bypass All (dangerous — no prompts)"}],tNe=(e,t)=>[...new Set([...Object.keys(e),...Object.keys(t)])].some(n=>JSON.stringify(e[n])!==JSON.stringify(t[n]));function nNe({getToken:e,onSaved:t,trigger:n,sessionId:r,sessionDirectives:i,onDirectivesSaved:a}){var U;const s=za(),[l,u]=b.useState({}),[d,h]=b.useState(!1),[m,p]=b.useState(!1),{engines:g,multiEngine:w}=E8(e,d),x=b.useRef({}),[E,_]=b.useState(!1),[k,O]=b.useState(null),[N,T]=b.useState(),C=N===!0,M=C||!!r;b.useEffect(()=>{d&&(_(!1),O(null),e().then(K=>{K&&fetch("/api/config",{headers:{Authorization:`Bearer ${K}`}}).then(F=>F.json()).then(({isOwner:F,...V})=>{T(!!F),x.current=V;const $=r?i:void 0;u({...V,...($==null?void 0:$.engine)!==void 0?{engine:$.engine}:{},...($==null?void 0:$.model)!==void 0?{model:$.model}:{},...($==null?void 0:$.turns)!==void 0?{maxTurns:$.turns}:{},...($==null?void 0:$.thinking)!==void 0?{thinking:$.thinking}:{}})}).catch(()=>{})}))},[d,e,r,i]);const D=async(K,F,V)=>{const $=await fetch(K,{method:"PUT",headers:V,body:JSON.stringify(F)}),L=await $.json().catch(W=>(console.warn("[config] response not JSON",K,$.status,W),{}));if(!$.ok)throw new Error(L.error||`HTTP ${$.status}`);return L},j=async()=>{p(!0),O(null);const F={Authorization:`Bearer ${await e()??""}`,"Content-Type":"application/json"};try{if(r){const V=E?{engine:"",model:"",turns:null,thinking:""}:{engine:l.engine,model:l.model,turns:l.maxTurns,thinking:l.thinking},$=await D(`/api/sessions/${r}/directives`,V,F);$!=null&&$.directives&&(a==null||a($.directives));const L=E?l:{...l,engine:x.current.engine,model:x.current.model,maxTurns:x.current.maxTurns,thinking:x.current.thinking};tNe(x.current,L)&&(await D("/api/config",L,F),t==null||t(L))}else await D("/api/config",l,F),t==null||t(l);h(!1)}catch(V){console.warn("[config] save failed",V),O(V.message||"Save failed")}finally{p(!1)}},R=l.engine||"claude-code",H=g.find(K=>K.name===R),P=(H==null?void 0:H.models)??JOe;b.useEffect(()=>{!H||!P.length||P.some(K=>(K.value||"")===(l.model??""))||u(K=>({...K,model:P[0].value||void 0}))},[H,P,l.model]);const q=P.some(K=>K.provider)?Array.from(P.reduce((K,F)=>{const V=F.provider||"default";return K.has(V)||K.set(V,[]),K.get(V).push(F),K},new Map)):null,X="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2";return y.jsxs(Oo,{open:d,onOpenChange:h,children:[y.jsx(rd,{asChild:!0,children:n||y.jsx(we,{variant:"ghost",size:"icon",title:"Agent Config",children:y.jsx(pV,{className:"w-4 h-4"})})}),y.jsxs(Na,{className:"max-w-lg",children:[y.jsx(Us,{children:y.jsx(No,{children:"Agent Configuration"})}),y.jsxs(Cz,{className:"space-y-4",children:[r&&y.jsxs("div",{className:"text-xs text-muted-foreground rounded-md bg-muted/50 px-3 py-2 space-y-2",children:[y.jsxs("p",{children:["Engine, Model, Max Turns & Thinking apply to"," ",y.jsx("strong",{children:E?"every conversation":"this conversation"}),". Other settings are always global defaults."]}),C&&y.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[y.jsx("input",{type:"checkbox",checked:E,onChange:K=>_(K.target.checked)}),y.jsx("span",{children:"Apply globally — also the default for Slack, email & scheduled runs"})]})]}),w&&y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Engine"}),y.jsx("select",{disabled:!M,value:l.engine??"",onChange:K=>{const F=K.target.value||void 0;u(V=>({...V,engine:F,model:void 0}))},className:X,children:g.map(K=>y.jsx("option",{value:K.name,children:K.name==="claude-code"?"Claude Code (default)":K.name},K.name))})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Model"}),y.jsx("select",{disabled:!M,value:l.model??"",onChange:K=>u(F=>({...F,model:K.target.value||void 0})),className:X,children:q?q.map(([K,F])=>y.jsx("optgroup",{label:K.charAt(0).toUpperCase()+K.slice(1),children:F.map(V=>y.jsx("option",{value:V.value,children:V.label},V.value))},K)):P.map(K=>y.jsx("option",{value:K.value,children:K.label},K.value))})]}),(U=s.settingsSections)==null?void 0:U.call(s,{getToken:e,sessionId:r}),y.jsx(QOe,{getToken:e}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Permission Mode"}),y.jsx("select",{disabled:!C,value:l.permissionMode??"acceptEdits",onChange:K=>u(F=>({...F,permissionMode:K.target.value})),className:X,children:eNe.map(K=>y.jsx("option",{value:K.value,children:K.label},K.value))})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Max Turns"}),y.jsx(ft,{type:"number",min:1,max:200,disabled:!M,value:l.maxTurns??50,onChange:K=>u(F=>({...F,maxTurns:Number(K.target.value)||50}))})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Thinking"}),y.jsxs("select",{disabled:!M,value:l.thinking??"",onChange:K=>u(F=>({...F,thinking:K.target.value||void 0})),className:X,children:[y.jsx("option",{value:"",children:"Default (off)"}),y.jsx("option",{value:"adaptive",children:"Adaptive (Claude decides)"}),y.jsx("option",{value:"enabled",children:"Enabled (always think)"}),y.jsx("option",{value:"disabled",children:"Disabled"})]})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Effort"}),y.jsxs("select",{disabled:!C,value:l.effort??"",onChange:K=>u(F=>({...F,effort:K.target.value||void 0})),className:X,children:[y.jsx("option",{value:"",children:"Default"}),y.jsx("option",{value:"low",children:"Low — fast"}),y.jsx("option",{value:"medium",children:"Medium"}),y.jsx("option",{value:"high",children:"High"}),y.jsx("option",{value:"max",children:"Max"})]})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Allowed Tools"}),y.jsx(ft,{placeholder:"Read, Edit, Bash, WebSearch, Glob, LS",disabled:!C,value:(l.allowedTools??[]).join(", "),onChange:K=>u(F=>({...F,allowedTools:K.target.value.split(",").map(V=>V.trim()).filter(Boolean)}))}),y.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Comma-separated list of tools Claude can use"})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium",children:"Skill Discovery"}),y.jsx("p",{className:"text-xs text-muted-foreground",children:"Index all skills + auto-inject on trigger match"})]}),y.jsx("button",{type:"button",role:"switch",disabled:!C,"aria-checked":l.skillDiscovery!==!1,onClick:()=>u(K=>({...K,skillDiscovery:K.skillDiscovery===!1})),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${l.skillDiscovery!==!1?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${l.skillDiscovery!==!1?"translate-x-5":"translate-x-0"}`})})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"pr-4",children:[y.jsx("label",{className:"text-sm font-medium",children:"Reply to untrusted senders"}),y.jsx("p",{className:"text-xs text-muted-foreground",children:"Off: inbound messages from unverified or unknown senders are still processed and escalated to owners, but the agent sends them no automatic reply."})]}),y.jsx("button",{type:"button",role:"switch",disabled:!C,"aria-checked":l.allowUntrustedReplies===!0,"aria-label":"Reply to untrusted senders",onClick:()=>u(K=>({...K,allowUntrustedReplies:K.allowUntrustedReplies!==!0})),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${l.allowUntrustedReplies===!0?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${l.allowUntrustedReplies===!0?"translate-x-5":"translate-x-0"}`})})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"System Prompt (optional)"}),y.jsx(Wy,{placeholder:"Additional instructions appended to Claude's system prompt…",disabled:!C,value:l.systemPrompt??"",onChange:K=>u(F=>({...F,systemPrompt:K.target.value||void 0})),rows:4})]})]}),y.jsxs(Tz,{className:"flex-col items-stretch gap-2",children:[k&&y.jsx("p",{className:"text-sm text-destructive",children:k}),N===!1&&y.jsx("p",{className:"text-xs text-muted-foreground",children:r?"Only an owner can change the global defaults — runtime knobs apply to this conversation.":"Read-only — only an owner can change the agent config."}),M&&y.jsx(we,{onClick:j,disabled:m,children:m?"Saving…":"Save Configuration"})]})]})]})}function rNe(e){const t=e.requestedEngine||"claude-code",n=e.actualEngine?"ran":e.actualModel?"ran-model":"pending",r=n==="ran"?e.actualEngine:n==="pending"?t:void 0,i=e.actualModel||e.requestedModel||(t==="cursor"?qOe:b8),a=n==="ran"&&r!==t?t:void 0,s=r==="claude-code"||r==="cursor",l=i.includes("/")?i.split("/")[0]:r==="claude-code"?"anthropic":r;return{provenance:n,engine:r,engineIsNative:s,engineMismatch:a,rawModel:i,billingProvider:l}}function iNe(e){const t=e.email.split("@")[0]||e.email,n=e.personal?"personal login":"shared login",r=`Claude.ai subscription (OAuth login) — no API key in use
|
|
2005
|
+
`?1:0),kind:"command"}),k(0)):q?(E({query:q[1],start:q.index,kind:"mention"}),k(0)):E(null)};return b.useEffect(()=>{const D=()=>E(null);return x&&document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[x]),y.jsxs("div",{className:"relative flex-1 min-w-0",children:[x&&O.length>0&&y.jsx("div",{className:"absolute bottom-full mb-1 left-0 z-50 bg-background border rounded-lg shadow-lg overflow-hidden min-w-[220px] max-h-64 overflow-y-auto",children:O.map((D,j)=>y.jsxs("button",{onMouseDown:R=>{R.preventDefault(),T(D.value)},className:`w-full text-left px-3 py-1.5 text-sm hover:bg-accent transition-colors flex items-center gap-2 ${j===_?"bg-accent":""}`,children:[y.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground shrink-0 w-14",children:(x==null?void 0:x.kind)==="command"?"cmd":D.kind==="skill"?"skill":"file"}),y.jsxs("span",{className:"truncate",children:[y.jsx("span",{className:"text-muted-foreground",children:(x==null?void 0:x.kind)==="command"?"/":"@"}),D.value]})]},`${D.kind}:${D.value}`))}),y.jsx("textarea",{ref:w,value:t,onChange:M,onKeyDown:C,onPaste:i,placeholder:l,disabled:h,rows:d,dir:"auto",className:u})]})}),YA="shraga:draft:";function Tw(e,t){const n=YA+(e??"new");t.trim()?localStorage.setItem(n,t):localStorage.removeItem(n)}function RD(e){return localStorage.getItem(YA+(e??"new"))??""}function PD(e){localStorage.removeItem(YA+(e??"new"))}const FOe=b.forwardRef(function({onSend:t,onSteer:n,onQueue:r,onRemoveQueued:i,queue:a,onUpload:s,onCancel:l,disabled:u,busy:d,skills:h=[],workspaceFiles:m=[],sessionId:p,inputCtx:g},w){var U,K;const x=za(),[E,_]=b.useState(()=>RD(p)),[k,O]=b.useState([]),[N,T]=b.useState(!1),C=b.useRef(null),M=b.useRef(null),D=b.useRef(p);b.useEffect(()=>{var $;if(D.current===p)return;const F=D.current;if(D.current=p,!p){PD(F),Tw(void 0,E);return}Tw(F,E);const V=RD(p);_(V),($=M.current)==null||$.setValue(V)},[p]);const j=b.useCallback(F=>{_(F),Tw(D.current,F)},[]);b.useImperativeHandle(w,()=>({prefill(F){var V,$;j(F),(V=M.current)==null||V.setValue(F),($=M.current)==null||$.focus()},setText(F){var V;j(F),(V=M.current)==null||V.setValue(F)},focus(){var F;(F=M.current)==null||F.focus()}}));const R=(F="send")=>{var $;const V=E.trim();!V&&k.length===0||(F==="steer"?n(V):F==="queue"?r(V):t(V,k.length>0?k:void 0),_(""),PD(D.current),O([]),($=M.current)==null||$.setValue(""))},H=typeof window<"u"&&((U=window.matchMedia)==null?void 0:U.call(window,"(pointer: coarse)").matches),P=F=>{if(F.key==="Enter"&&!F.shiftKey&&(!H||F.metaKey||F.ctrlKey)){F.preventDefault(),R(d?"steer":"send");return}if(F.key==="Tab"&&d&&E.trim()){F.preventDefault(),R("queue");return}},G=b.useCallback(async F=>{T(!0);try{const V=await s(F);V&&O($=>[...$,V])}finally{T(!1)}},[s]),q=b.useCallback(F=>{const V=Array.from(F.clipboardData.items);for(const $ of V)if($.type.startsWith("image/")||$.type==="application/pdf"){const L=$.getAsFile();L&&G(L)}},[G]),X=F=>{var $;const V=($=F.target.files)==null?void 0:$[0];V&&(G(V),F.target.value="")};return y.jsx("div",{className:"border-t bg-background",style:{paddingBottom:"env(safe-area-inset-bottom)"},children:y.jsxs("div",{className:"max-w-3xl mx-auto px-2 sm:px-4 py-3",children:[(k.length>0||N)&&y.jsxs("div",{className:"flex gap-2 mb-2 flex-wrap items-center",children:[k.map((F,V)=>y.jsxs("div",{className:"relative group",children:[F.mimeType.startsWith("image/")?y.jsx(WA,{src:F.url,alt:F.name,className:"h-16 w-16 object-cover rounded-lg border"}):y.jsxs("div",{className:"h-16 px-3 flex items-center gap-2 rounded-lg border bg-muted/50 text-xs text-muted-foreground",children:[y.jsx(UE,{className:"w-4 h-4 shrink-0"}),y.jsx("span",{className:"truncate max-w-[120px]",children:F.name})]}),y.jsx("button",{onClick:()=>O($=>$.filter((L,W)=>W!==V)),className:"absolute -top-1.5 -right-1.5 bg-destructive text-destructive-foreground rounded-full w-5 h-5 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity shadow-sm",children:y.jsx(Bs,{className:"w-3 h-3"})})]},V)),N&&y.jsx("span",{className:"text-xs text-muted-foreground animate-pulse",children:"Uploading…"})]}),y.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-xl border px-3 py-2",children:[y.jsx(we,{variant:"ghost",size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0",onClick:()=>{var F;return(F=C.current)==null?void 0:F.click()},disabled:u,title:"Attach file or image",children:y.jsx(lV,{className:"w-4 h-4"})}),y.jsx("input",{ref:C,type:"file",className:"hidden",onChange:X}),y.jsx(y8,{ref:M,value:E,onChange:j,onKeyDown:P,onPaste:q,skills:h,workspaceFiles:m,placeholder:d?"Steer or queue…":"Message Claude…",disabled:u,rows:1,className:"w-full bg-transparent border-none outline-none resize-none text-sm py-1.5 placeholder:text-muted-foreground min-h-[28px] max-h-[200px]"}),(K=x.inputAdornments)==null?void 0:K.call(x,g),d?y.jsxs("div",{className:"flex items-center gap-2",children:[E.trim()&&y.jsx(we,{size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>R("steer"),title:"Steer (inject into current turn)",children:y.jsx(Ag,{className:"w-4 h-4"})}),y.jsx(we,{variant:"destructive",size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>l(),title:"Stop generation",children:y.jsx(fL,{className:"w-3.5 h-3.5"})})]}):y.jsx(we,{size:"icon",className:"h-9 w-9 sm:h-8 sm:w-8 shrink-0 rounded-lg",onClick:()=>R(),disabled:u||N||!E.trim()&&k.length===0,children:y.jsx(Ag,{className:"w-4 h-4"})})]}),a.length>0&&y.jsx("div",{className:"flex gap-1.5 flex-wrap mt-2",children:a.map((F,V)=>y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-blue-50 dark:bg-blue-950/40 px-2.5 py-1 text-xs text-blue-700 dark:text-blue-300 ring-1 ring-inset ring-blue-600/20 dark:ring-blue-400/30",children:[y.jsx("span",{className:"truncate max-w-[200px]",children:F}),y.jsx("button",{onClick:()=>i(V),className:"hover:text-blue-900 dark:hover:text-blue-100",children:y.jsx(Bs,{className:"w-3 h-3"})})]},V))}),y.jsx("p",{className:"text-[10px] text-muted-foreground text-center mt-2",children:d?"Enter to steer (redirect) · Tab to queue (after done) · Shift+Enter for newline":"Enter to send · Shift+Enter for newline · @ for skills · / for commands"})]})})}),HOe={"fb-feed":[1080,1080],"fb-story":[1080,1920],"fb-landscape":[1200,628],"ig-square":[1080,1080],"ig-story":[1080,1920],"ig-landscape":[1080,566],"banner-leaderboard":[728,90],"banner-medium":[300,250]};function KOe({artifacts:e,selectedId:t,sessionId:n,getToken:r,onSelect:i,onClose:a}){var M;const[s,l]=b.useState(!1),[u,d]=b.useState(!1),[h,m]=b.useState(!1),[p,g]=b.useState(1),w=b.useRef(null),x=e.find(D=>D.id===t),E=b.useCallback(()=>{if(!w.current||!x)return;const{clientWidth:D,clientHeight:j}=w.current,R=32,H=D-R,P=j-R,[G,q]=x.dimensions;g(Math.min(H/G,P/q,1))},[x]);b.useEffect(()=>{let D=!0;return r().then(j=>fetch("/api/features",{headers:j?{Authorization:`Bearer ${j}`}:{}})).then(j=>j.json()).then(j=>{D&&m(!!j.artifactPngExport)}).catch(j=>console.error("[artifact] features fetch failed:",j)),()=>{D=!1}},[r]),b.useEffect(()=>{E();const D=w.current;if(!D)return;const j=new ResizeObserver(E);return j.observe(D),()=>j.disconnect()},[E]);const _=async()=>{if(x){d(!0);try{const D=await r(),j=await fetch(`/api/artifacts/${n}/${x.id}/export`,{method:"POST",headers:{"Content-Type":"application/json",...D?{Authorization:`Bearer ${D}`}:{}},body:JSON.stringify({dimensions:x.dimensions})});if(!j.ok)throw new Error(await j.text());const R=await j.blob(),H=URL.createObjectURL(R),P=document.createElement("a");P.href=H,P.download=`${x.title.replace(/\s+/g,"-").toLowerCase()}.png`,P.click(),URL.revokeObjectURL(H)}catch(D){console.error("[artifact] export failed:",D)}finally{d(!1)}}},k=x?(M=Object.entries(HOe).find(([,D])=>D[0]===x.dimensions[0]&&D[1]===x.dimensions[1]))==null?void 0:M[0]:null,[O,N]=(x==null?void 0:x.dimensions)??[0,0],T=O*p,C=N*p;return y.jsxs("div",{className:ze("flex flex-col border-l bg-background transition-all",s?"fixed inset-0 z-50":"fixed inset-0 z-50 sm:relative sm:inset-auto sm:z-auto sm:w-[480px] sm:shrink-0"),children:[y.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 border-b bg-muted/30",children:[y.jsx(we,{variant:"ghost",size:"icon",className:"h-7 w-7 sm:hidden shrink-0",onClick:a,title:"Back to chat",children:y.jsx(oL,{className:"w-4 h-4"})}),e.length>1&&y.jsx("select",{className:"text-xs bg-transparent border rounded px-1 py-0.5 max-w-[160px] truncate",value:t??"",onChange:D=>i(D.target.value),children:e.map(D=>y.jsx("option",{value:D.id,children:D.title},D.id))}),e.length<=1&&x&&y.jsx("span",{className:"text-xs font-medium truncate max-w-[160px]",children:x.title}),x&&y.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[k??`${O}×${N}`,p<1&&` · ${Math.round(p*100)}%`]}),y.jsx("div",{className:"flex-1"}),h&&y.jsx(we,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:_,disabled:!x||u,title:"Export PNG",children:u?y.jsx("span",{className:"w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):y.jsx(nV,{className:"w-3.5 h-3.5"})}),y.jsx(we,{variant:"ghost",size:"icon",className:"h-6 w-6 hidden sm:inline-flex",onClick:()=>l(!s),title:s?"Minimize":"Maximize",children:s?y.jsx(HE,{className:"w-3.5 h-3.5"}):y.jsx(FE,{className:"w-3.5 h-3.5"})}),y.jsx(we,{variant:"ghost",size:"icon",className:"h-6 w-6 hidden sm:inline-flex",onClick:a,title:"Close",children:y.jsx(Bs,{className:"w-3.5 h-3.5"})})]}),y.jsx("div",{ref:w,className:"flex-1 overflow-hidden flex items-center justify-center bg-muted/10",children:x?y.jsx("div",{style:{width:T,height:C},children:y.jsx("iframe",{src:`/api/artifacts/${n}/${x.id}`,sandbox:"allow-scripts",className:"border shadow-sm bg-white origin-top-left",style:{width:O,height:N,transform:`scale(${p})`},title:x.title})}):y.jsx("p",{className:"text-sm text-muted-foreground",children:"No artifact selected"})})]})}const Wy=b.forwardRef(({className:e,...t},n)=>y.jsx("textarea",{className:ze("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none",e),ref:n,...t}));Wy.displayName="Textarea";const b8="claude-sonnet-5",qOe="cursor/composer-2.5",EE={fable:"claude-fable-5-1","fable-5-1":"claude-fable-5-1","fable-5":"claude-fable-5",opus:"claude-opus-5-5","opus-5-5":"claude-opus-5-5","opus-5":"claude-opus-5","opus-4-8":"claude-opus-4-8","opus-4-7":"claude-opus-4-7","opus-4-6":"claude-opus-4-6",sonnet:"claude-sonnet-5","sonnet-5":"claude-sonnet-5","sonnet-4-6":"claude-sonnet-4-6",haiku:"claude-haiku-4-5-20251001"},GOe=/^\s*\[([^\]]*)\]\s*([\s\S]*)/,x8=["model","turns","thinking","think","effort","engine","resume"],SE=e=>/^[a-z0-9._-]+\/[a-z0-9./_-]+$/.test(e);let Yl=null;function VOe(e){Yl=e}function _E(e){const t=e.trim().toLowerCase();return EE[t]?{model:EE[t]}:(Yl==null?void 0:Yl(t))??null}function w8(e,t){const n=_E(t);return n?(e.model=n.model,n.engine&&!e.engine&&(e.engine=n.engine),!0):!1}function WOe(e){const t=e.split(",").map(n=>n.trim()).filter(Boolean);return t.length?t.every(n=>{const r=n.indexOf(":");if(r!==-1)return x8.includes(n.slice(0,r).trim().toLowerCase());const i=n.toLowerCase();return!!EE[i]||!!(Yl!=null&&Yl(i))||/^\d+$/.test(i)||["think","adaptive","nothink","nothinking"].includes(i)}):!1}function XA(e,t){let n=e;const r=[];for(;;){const i=n.match(GOe);if(!i)break;const a=i[1].trim();if((r.length||t!=null&&t.strict)&&a&&!WOe(a))break;r.push(a),n=i[2]}return{groups:r,body:n}}function YOe(e){const{groups:t,body:n}=XA(e);if(!t.length)return{prompt:e,directives:{}};const r=t.filter(Boolean).join(","),i=n.trim();if(!r)return{prompt:i,directives:{}};const a={};let s=0,l;const u=r.split(","),d=u.some(h=>{const m=h.indexOf(":");return m!==-1&&x8.includes(h.slice(0,m).trim().toLowerCase())});for(const h of u){const m=h.trim();if(!m)continue;const p=m.indexOf(":");if(p!==-1){const g=m.slice(0,p).trim().toLowerCase(),w=m.slice(p+1).trim().toLowerCase();l=XOe(a,g,w)??l}else{const g=m.toLowerCase();s===0&&w8(a,g)||(s<=1&&/^\d+$/.test(g)?a.turns=parseInt(g,10):["think","adaptive"].includes(g)?a.thinking="adaptive":["nothink","nothinking"].includes(g)?a.thinking="disabled":s===0&&(d&&!SE(g)&&(l??(l=m)),console.warn(SE(g)?`[directives] Provider-qualified model needs key form: "[model:${m}]"`:`[directives] Unknown model alias: "${m}"`))),s++}}return{prompt:i,directives:a,unresolvedModel:l}}function XOe(e,t,n){switch(t){case"model":if(w8(e,n))break;if(SE(n)){e.model=n;break}return n;case"turns":/^\d+$/.test(n)?e.turns=parseInt(n,10):console.warn(`[directives] Invalid turns value: "${n}"`);break;case"thinking":case"think":["adaptive","enabled","disabled"].includes(n)?e.thinking=n:console.warn(`[directives] Invalid thinking value: "${n}"`);break;case"effort":["low","medium","high","max"].includes(n)?e.effort=n:console.warn(`[directives] Invalid effort value: "${n}"`);break;case"engine":e.engine=n;break;case"resume":["on","true","1"].includes(n)?e.resume=!0:["off","false","0"].includes(n)?e.resume=!1:console.warn(`[directives] Invalid resume value: "${n}"`);break;default:console.warn(`[directives] Unknown directive key: "${t}"`)}}function ZOe(e){return t=>{const n=t.toLowerCase(),r=[];for(const{name:i,models:a}of e())for(const s of a){if(!s.value)continue;const l=s.value.toLowerCase();if(l===n)return{model:s.value,engine:i};l.slice(l.lastIndexOf("/")+1)===n&&r.push({model:s.value,engine:i})}return r.length===1?r[0]:(r.length>1&&console.warn(`[directives] Ambiguous model "${t}" (${r.map(i=>`${i.engine}:${i.model}`).join(", ")}) — use the full id`),null)}}let pg=[];VOe(ZOe(()=>pg));function E8(e,t=!0){const[n,r]=b.useState(pg),[i,a]=b.useState(!1);return b.useEffect(()=>{if(!t)return;let s=!0;return e().then(l=>{!l||!s||fetch("/api/engines",{headers:{Authorization:`Bearer ${l}`}}).then(u=>u.json()).then(u=>{s&&(pg=u.engines??[],r(pg),a(u.multiEngine??!1))}).catch(u=>console.warn("[engines] load failed",u))}),()=>{s=!1}},[t,e]),{engines:n,multiEngine:i}}async function Ti(e,t,n){const r=await t();let i;try{i=await fetch(e,{...n,headers:{Authorization:`Bearer ${r??""}`,"Content-Type":"application/json",...n==null?void 0:n.headers}})}catch(a){throw Bv(e,a),a}if($v(e,i,n==null?void 0:n.expect),!i.ok){const a=await i.json().catch(()=>({}));throw Object.assign(new Error(a.error||`${i.status} ${i.statusText}`),{status:i.status})}return i.json()}function QOe({getToken:e}){var O;const[t,n]=b.useState(null),[r,i]=b.useState(null),[a,s]=b.useState(""),[l,u]=b.useState(!1),[d,h]=b.useState(null),m=b.useCallback(()=>{Ti("/api/claude-account",e).then(n).catch(N=>{console.warn("[ClaudeAccountSection] status failed",N),h(N.message)})},[e]);b.useEffect(m,[m]);const p=async N=>{u(!0),h(null);try{await N()}catch(T){h(T.message)}finally{u(!1)}},g=N=>p(async()=>{const T=window.open("about:blank","_blank");try{const{url:C}=await Ti(`/api/claude-account/${N}/login`,e,{method:"POST"});T&&(T.location.href=C),i({target:N,url:C}),s("")}catch(C){throw T==null||T.close(),C}}),w=()=>p(async()=>{r&&(await Ti(`/api/claude-account/${r.target}/login/code`,e,{method:"POST",body:JSON.stringify({code:a})}),i(null),s(""),m())}),x=N=>p(async()=>{await Ti(`/api/claude-account/${N}`,e,{method:"DELETE"}),m()}),E=N=>p(async()=>{await Ti("/api/claude-account/me/use-shared",e,{method:"PUT",body:JSON.stringify({on:N})}),m()}),_=N=>{var T,C;return N==="global"?!((T=t==null?void 0:t.me)!=null&&T.connected)||!!t.me.useShared:!!((C=t==null?void 0:t.me)!=null&&C.connected)&&!t.me.useShared},k=(N,T,C,M=!0)=>{var R;const D=((R=t==null?void 0:t.usage)==null?void 0:R[N])??null,j=C!=null&&C.connected?[C.account??"Connected",C.subscriptionType].filter(Boolean).join(" · "):N==="me"||M?"Not connected":null;return y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsxs("div",{className:"min-w-0 space-y-0.5",children:[y.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[T,_(N)&&y.jsx("span",{className:"rounded-full bg-emerald-500/15 px-1.5 py-px text-[10px] font-medium text-emerald-500",children:"Active"})]}),y.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground min-w-0",children:[j&&y.jsx("span",{className:"truncate",children:j}),j&&D&&y.jsx("span",{"aria-hidden":!0,children:"·"}),y.jsx(q$,{usage:D,compact:!0})]})]}),M&&y.jsxs("div",{className:"flex shrink-0 gap-2",children:[N==="me"&&(C==null?void 0:C.connected)&&y.jsxs(y.Fragment,{children:[y.jsx(we,{size:"sm",variant:"outline",disabled:l,onClick:()=>E(!C.useShared),children:C.useShared?"Use mine":"Use shared"}),y.jsx(we,{size:"sm",variant:"outline",disabled:l,onClick:()=>x(N),children:"Sign out"})]}),y.jsx(we,{size:"sm",variant:"outline",disabled:l,onClick:()=>g(N),children:C!=null&&C.connected?"Replace":"Connect"})]})]})};return t?y.jsxs("div",{className:"space-y-4",children:[y.jsx("label",{className:"text-sm font-medium block",children:"Claude subscription"}),t.me?k("me","Your subscription",t.me):y.jsx("p",{className:"text-xs text-muted-foreground",children:"Personal subscription unavailable: you are not a contact on this agent."}),t.global?k("global","Shared subscription",t.global):((O=t.usage)==null?void 0:O.global)&&k("global","Shared subscription",null,!1),r&&y.jsxs("div",{className:"rounded-md bg-muted/50 px-3 py-2 space-y-2 text-xs",children:[y.jsxs("p",{children:["Sign in on the ",y.jsx("a",{className:"underline",href:r.url,target:"_blank",rel:"noreferrer",children:"Claude login page"}),", then paste the code it shows."]}),y.jsxs("div",{className:"flex gap-2",children:[y.jsx(ft,{value:a,onChange:N=>s(N.target.value),placeholder:"Paste code"}),y.jsx(we,{size:"sm",disabled:l||!a.trim(),onClick:w,children:"Submit"}),y.jsx(we,{size:"sm",variant:"ghost",disabled:l,onClick:()=>i(null),children:"Cancel"})]})]}),d&&y.jsx("p",{className:"text-xs text-destructive",children:d})]}):d?y.jsx("p",{className:"text-xs text-destructive",children:d}):null}const JOe=[{value:"",label:`Default (${b8})`},{value:"claude-fable-5-1",label:"Fable 5.1 — frontier, most capable"},{value:"claude-fable-5",label:"Fable 5"},{value:"claude-opus-5-5",label:"Opus 5.5 — most capable, best for complex/agentic tasks"},{value:"claude-opus-5",label:"Opus 5"},{value:"claude-opus-4-8",label:"Opus 4.8"},{value:"claude-opus-4-7",label:"Opus 4.7"},{value:"claude-opus-4-6",label:"Opus 4.6"},{value:"claude-sonnet-5",label:"Sonnet 5 — balanced speed & intelligence"},{value:"claude-sonnet-4-6",label:"Sonnet 4.6"},{value:"claude-haiku-4-5",label:"Haiku 4.5 — fastest"}],eNe=[{value:"acceptEdits",label:"Accept Edits (auto-approve file changes)"},{value:"plan",label:"Plan (read-only, suggest changes)"},{value:"bypassPermissions",label:"Bypass All (dangerous — no prompts)"}],tNe=(e,t)=>[...new Set([...Object.keys(e),...Object.keys(t)])].some(n=>JSON.stringify(e[n])!==JSON.stringify(t[n]));function nNe({getToken:e,onSaved:t,trigger:n,sessionId:r,sessionDirectives:i,onDirectivesSaved:a}){var U;const s=za(),[l,u]=b.useState({}),[d,h]=b.useState(!1),[m,p]=b.useState(!1),{engines:g,multiEngine:w}=E8(e,d),x=b.useRef({}),[E,_]=b.useState(!1),[k,O]=b.useState(null),[N,T]=b.useState(),C=N===!0,M=C||!!r;b.useEffect(()=>{d&&(_(!1),O(null),e().then(K=>{K&&fetch("/api/config",{headers:{Authorization:`Bearer ${K}`}}).then(F=>F.json()).then(({isOwner:F,...V})=>{T(!!F),x.current=V;const $=r?i:void 0;u({...V,...($==null?void 0:$.engine)!==void 0?{engine:$.engine}:{},...($==null?void 0:$.model)!==void 0?{model:$.model}:{},...($==null?void 0:$.turns)!==void 0?{maxTurns:$.turns}:{},...($==null?void 0:$.thinking)!==void 0?{thinking:$.thinking}:{}})}).catch(()=>{})}))},[d,e,r,i]);const D=async(K,F,V)=>{const $=await fetch(K,{method:"PUT",headers:V,body:JSON.stringify(F)}),L=await $.json().catch(W=>(console.warn("[config] response not JSON",K,$.status,W),{}));if(!$.ok)throw new Error(L.error||`HTTP ${$.status}`);return L},j=async()=>{p(!0),O(null);const F={Authorization:`Bearer ${await e()??""}`,"Content-Type":"application/json"};try{if(r){const V=E?{engine:"",model:"",turns:null,thinking:""}:{engine:l.engine,model:l.model,turns:l.maxTurns,thinking:l.thinking},$=await D(`/api/sessions/${r}/directives`,V,F);$!=null&&$.directives&&(a==null||a($.directives));const L=E?l:{...l,engine:x.current.engine,model:x.current.model,maxTurns:x.current.maxTurns,thinking:x.current.thinking};tNe(x.current,L)&&(await D("/api/config",L,F),t==null||t(L))}else await D("/api/config",l,F),t==null||t(l);h(!1)}catch(V){console.warn("[config] save failed",V),O(V.message||"Save failed")}finally{p(!1)}},R=l.engine||"claude-code",H=g.find(K=>K.name===R),P=(H==null?void 0:H.models)??JOe;b.useEffect(()=>{!H||!P.length||P.some(K=>(K.value||"")===(l.model??""))||u(K=>({...K,model:P[0].value||void 0}))},[H,P,l.model]);const q=P.some(K=>K.provider)?Array.from(P.reduce((K,F)=>{const V=F.provider||"default";return K.has(V)||K.set(V,[]),K.get(V).push(F),K},new Map)):null,X="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2";return y.jsxs(Oo,{open:d,onOpenChange:h,children:[y.jsx(rd,{asChild:!0,children:n||y.jsx(we,{variant:"ghost",size:"icon",title:"Agent Config",children:y.jsx(pV,{className:"w-4 h-4"})})}),y.jsxs(Na,{className:"max-w-lg",children:[y.jsx(Us,{children:y.jsx(No,{children:"Agent Configuration"})}),y.jsxs(Cz,{className:"space-y-4",children:[r&&y.jsxs("div",{className:"text-xs text-muted-foreground rounded-md bg-muted/50 px-3 py-2 space-y-2",children:[y.jsxs("p",{children:["Engine, Model, Max Turns & Thinking apply to"," ",y.jsx("strong",{children:E?"every conversation":"this conversation"}),". Other settings are always global defaults."]}),C&&y.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[y.jsx("input",{type:"checkbox",checked:E,onChange:K=>_(K.target.checked)}),y.jsx("span",{children:"Apply globally — also the default for Slack, email & scheduled runs"})]})]}),w&&y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Engine"}),y.jsx("select",{disabled:!M,value:l.engine??"",onChange:K=>{const F=K.target.value||void 0;u(V=>({...V,engine:F,model:void 0}))},className:X,children:g.map(K=>y.jsx("option",{value:K.name,children:K.name==="claude-code"?"Claude Code (default)":K.name},K.name))})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Model"}),y.jsx("select",{disabled:!M,value:l.model??"",onChange:K=>u(F=>({...F,model:K.target.value||void 0})),className:X,children:q?q.map(([K,F])=>y.jsx("optgroup",{label:K.charAt(0).toUpperCase()+K.slice(1),children:F.map(V=>y.jsx("option",{value:V.value,children:V.label},V.value))},K)):P.map(K=>y.jsx("option",{value:K.value,children:K.label},K.value))})]}),(U=s.settingsSections)==null?void 0:U.call(s,{getToken:e,sessionId:r}),y.jsx(QOe,{getToken:e}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Permission Mode"}),y.jsx("select",{disabled:!C,value:l.permissionMode??"acceptEdits",onChange:K=>u(F=>({...F,permissionMode:K.target.value})),className:X,children:eNe.map(K=>y.jsx("option",{value:K.value,children:K.label},K.value))})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Max Turns"}),y.jsx(ft,{type:"number",min:1,max:200,disabled:!M,value:l.maxTurns??50,onChange:K=>u(F=>({...F,maxTurns:Number(K.target.value)||50}))})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Thinking"}),y.jsxs("select",{disabled:!M,value:l.thinking??"",onChange:K=>u(F=>({...F,thinking:K.target.value||void 0})),className:X,children:[y.jsx("option",{value:"",children:"Default (off)"}),y.jsx("option",{value:"adaptive",children:"Adaptive (Claude decides)"}),y.jsx("option",{value:"enabled",children:"Enabled (always think)"}),y.jsx("option",{value:"disabled",children:"Disabled"})]})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Effort"}),y.jsxs("select",{disabled:!C,value:l.effort??"",onChange:K=>u(F=>({...F,effort:K.target.value||void 0})),className:X,children:[y.jsx("option",{value:"",children:"Default"}),y.jsx("option",{value:"low",children:"Low — fast"}),y.jsx("option",{value:"medium",children:"Medium"}),y.jsx("option",{value:"high",children:"High"}),y.jsx("option",{value:"max",children:"Max"})]})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"Allowed Tools"}),y.jsx(ft,{placeholder:"Read, Edit, Bash, WebSearch, Glob, LS",disabled:!C,value:(l.allowedTools??[]).join(", "),onChange:K=>u(F=>({...F,allowedTools:K.target.value.split(",").map(V=>V.trim()).filter(Boolean)}))}),y.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Comma-separated list of tools Claude can use"})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium",children:"Skill Discovery"}),y.jsx("p",{className:"text-xs text-muted-foreground",children:"Index all skills + auto-inject on trigger match"})]}),y.jsx("button",{type:"button",role:"switch",disabled:!C,"aria-checked":l.skillDiscovery!==!1,onClick:()=>u(K=>({...K,skillDiscovery:K.skillDiscovery===!1})),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${l.skillDiscovery!==!1?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${l.skillDiscovery!==!1?"translate-x-5":"translate-x-0"}`})})]}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("div",{className:"pr-4",children:[y.jsx("label",{className:"text-sm font-medium",children:"Reply to untrusted senders"}),y.jsx("p",{className:"text-xs text-muted-foreground",children:"Off: inbound messages from unverified or unknown senders are still processed and escalated to owners, but the agent sends them no automatic reply."})]}),y.jsx("button",{type:"button",role:"switch",disabled:!C,"aria-checked":l.allowUntrustedReplies===!0,"aria-label":"Reply to untrusted senders",onClick:()=>u(K=>({...K,allowUntrustedReplies:K.allowUntrustedReplies!==!0})),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ${l.allowUntrustedReplies===!0?"bg-primary":"bg-muted"}`,children:y.jsx("span",{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${l.allowUntrustedReplies===!0?"translate-x-5":"translate-x-0"}`})})]}),y.jsxs("div",{children:[y.jsx("label",{className:"text-sm font-medium mb-1.5 block",children:"System Prompt (optional)"}),y.jsx(Wy,{placeholder:"Additional instructions appended to Claude's system prompt…",disabled:!C,value:l.systemPrompt??"",onChange:K=>u(F=>({...F,systemPrompt:K.target.value||void 0})),rows:4})]})]}),y.jsxs(Tz,{className:"flex-col items-stretch gap-2",children:[k&&y.jsx("p",{className:"text-sm text-destructive",children:k}),N===!1&&y.jsx("p",{className:"text-xs text-muted-foreground",children:r?"Only an owner can change the global defaults — runtime knobs apply to this conversation.":"Read-only — only an owner can change the agent config."}),M&&y.jsx(we,{onClick:j,disabled:m,children:m?"Saving…":"Save Configuration"})]})]})]})}function rNe(e){const t=e.requestedEngine||"claude-code",n=e.actualEngine?"ran":e.actualModel?"ran-model":"pending",r=n==="ran"?e.actualEngine:n==="pending"?t:void 0,i=e.actualModel||e.requestedModel||(t==="cursor"?qOe:b8),a=n==="ran"&&r!==t?t:void 0,s=r==="claude-code"||r==="cursor",l=i.includes("/")?i.split("/")[0]:r==="claude-code"?"anthropic":r;return{provenance:n,engine:r,engineIsNative:s,engineMismatch:a,rawModel:i,billingProvider:l}}function iNe(e){const t=e.email.split("@")[0]||e.email,n=e.personal?"personal login":"shared login",r=`Claude.ai subscription (OAuth login) — no API key in use
|
|
2006
2006
|
Account: ${e.email}${e.plan?`
|
|
2007
2007
|
Plan: ${e.plan}`:""}
|
|
2008
2008
|
${n==="personal login"?"Personal login (routed to this user)":"Shared login (the agent box account)"}`;return{localPart:t,plan:e.plan,kind:n,title:r}}function aNe({sessionId:e,config:t,sessionDirectives:n,actualModel:r,actualEngine:i,actualAccount:a,scheduleId:s,onScheduleClick:l}){const[u,d]=b.useState(!1),{provenance:h,engine:m,engineIsNative:p,engineMismatch:g,rawModel:w,billingProvider:x}=rNe({requestedEngine:(n==null?void 0:n.engine)||t.engine,requestedModel:(n==null?void 0:n.model)||t.model,actualEngine:i,actualModel:r}),E=w.replace("claude-",""),_=m&&!p?`${m} · ${E}`:E,k=h==="pending",O=k?" border border-dashed border-current/40 opacity-80":"",N=k?"Nothing has run in this conversation yet — this is what the next turn is set to use.":h==="ran-model"?"Model recorded from the last turn. The engine that ran it was not recorded (this conversation predates engine tracking), so it is not named here.":"Engine and model that actually ran the last turn.",T=!k&&m==="claude-code"?a:void 0,C=m==="claude-code"&&(!!T||t.claudeAuthSource==="subscription"),M=T?iNe(T):void 0,D=x?C?"sub":x==="cursor"?"plan":"metered":"unknown",j=D==="unknown"?"bg-muted text-muted-foreground ring-border":D==="sub"?"bg-emerald-50 text-emerald-700 ring-emerald-600/20 dark:bg-emerald-950/50 dark:text-emerald-300 dark:ring-emerald-400/30":D==="plan"?"bg-amber-50 text-amber-700 ring-amber-600/20 dark:bg-amber-950/50 dark:text-amber-300 dark:ring-amber-400/30":"bg-rose-50 text-rose-700 ring-rose-600/20 dark:bg-rose-950/50 dark:text-rose-300 dark:ring-rose-400/30",R=D==="unknown"?"The engine that ran this turn was not recorded and the model id carries no provider prefix — the billed provider cannot be named from what was stored.":D==="sub"?(M==null?void 0:M.title)??"Claude.ai subscription (OAuth login) — no API key in use":D==="plan"?`Runs on your ${x} API key — usage may draw on your ${x} plan/subscription`:`Runs on your ${x} API key — metered per-token billing`,H=t.permissionMode||"acceptEdits",P=H==="bypassPermissions"?"bypass":H==="plan"?"plan":H==="default"?"prompt":"edits",G=(n==null?void 0:n.thinking)||t.thinking,q=()=>{e&&(navigator.clipboard.writeText(e),d(!0),setTimeout(()=>d(!1),1500))};return y.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[y.jsx("span",{title:N,className:`inline-flex items-center rounded-md bg-blue-50 px-1.5 py-0.5 text-[10px] font-medium text-blue-700 ring-1 ring-inset ring-blue-600/20 dark:bg-blue-950/50 dark:text-blue-300 dark:ring-blue-400/30${O}`,children:k?`→ ${_}`:_}),y.jsxs("span",{title:k?`${N} ${R}`:R,"data-account":M?T.email:void 0,className:`inline-flex min-w-0 items-center whitespace-nowrap rounded-md px-1.5 py-0.5 text-[10px] font-medium ring-1 ring-inset ${j}${O}`,children:[D==="unknown"?"API·?":C?"sub":`API·${x}`,D==="sub"&&M&&y.jsxs(y.Fragment,{children:[y.jsx("span",{"aria-hidden":"true",children:" · "}),y.jsx("span",{className:"max-w-[4.5rem] truncate sm:max-w-[10rem]",children:M.localPart}),M.plan&&y.jsxs("span",{className:"hidden sm:inline",children:[" · ",M.plan]})]})]}),g&&y.jsxs("span",{title:`This session requests the "${g}" engine, but the last turn actually ran on "${m}" — so the chips above report ${m}, and that provider was billed.`,className:"inline-flex items-center rounded-md bg-rose-50 px-1.5 py-0.5 text-[10px] font-medium text-rose-700 ring-1 ring-inset ring-rose-600/20 dark:bg-rose-950/50 dark:text-rose-300 dark:ring-rose-400/30",children:["≠ ",g]}),y.jsx("span",{className:"inline-flex items-center rounded-md bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 ring-1 ring-inset ring-amber-600/20 dark:bg-amber-950/50 dark:text-amber-300 dark:ring-amber-400/30",children:P}),y.jsxs("span",{className:"inline-flex items-center rounded-md bg-green-50 px-1.5 py-0.5 text-[10px] font-medium text-green-700 ring-1 ring-inset ring-green-600/20 dark:bg-green-950/50 dark:text-green-300 dark:ring-green-400/30",children:[(n==null?void 0:n.turns)??t.maxTurns??50," steps"]}),G&&G!=="disabled"&&y.jsx("span",{className:"inline-flex items-center rounded-md bg-violet-50 px-1.5 py-0.5 text-[10px] font-medium text-violet-700 ring-1 ring-inset ring-violet-600/20 dark:bg-violet-950/50 dark:text-violet-300 dark:ring-violet-400/30",children:"think"}),e&&y.jsxs("button",{onClick:q,className:"inline-flex items-center gap-0.5 rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground ring-1 ring-inset ring-border hover:bg-accent transition-colors",title:`Session: ${e}
|
package/dist/client/index.html
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
14
14
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
15
15
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet" />
|
|
16
|
-
<script type="module" crossorigin src="/assets/index-
|
|
16
|
+
<script type="module" crossorigin src="/assets/index-C1weaEkP.js"></script>
|
|
17
17
|
<link rel="stylesheet" crossorigin href="/assets/index-BLAQpfJ9.css">
|
|
18
18
|
</head>
|
|
19
19
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shraga",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.138",
|
|
4
4
|
"description": "The teammate you delegate coding to — a self-hostable, multi-user AI coding agent web UI (Claude Code, with a pluggable engine seam).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"prepublishOnly": "bun run guard:publish && bun run build"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@anthropic-ai/claude-agent-sdk": "^0.3.
|
|
58
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.280",
|
|
59
59
|
"@livx.cc/mcp-firebase": "^0.1.14",
|
|
60
60
|
"@radix-ui/react-accordion": "^1.2.2",
|
|
61
61
|
"@radix-ui/react-dialog": "^1.1.4",
|
|
@@ -26,7 +26,8 @@ const FALLBACK_MODELS: EngineModel[] = [
|
|
|
26
26
|
{ value: '', label: `Default (${DEFAULT_MODEL})` },
|
|
27
27
|
{ value: 'claude-fable-5-1', label: 'Fable 5.1 — frontier, most capable' },
|
|
28
28
|
{ value: 'claude-fable-5', label: 'Fable 5' },
|
|
29
|
-
{ value: 'claude-opus-5', label: 'Opus 5 — most capable, best for complex/agentic tasks' },
|
|
29
|
+
{ value: 'claude-opus-5-5', label: 'Opus 5.5 — most capable, best for complex/agentic tasks' },
|
|
30
|
+
{ value: 'claude-opus-5', label: 'Opus 5' },
|
|
30
31
|
{ value: 'claude-opus-4-8', label: 'Opus 4.8' },
|
|
31
32
|
{ value: 'claude-opus-4-7', label: 'Opus 4.7' },
|
|
32
33
|
{ value: 'claude-opus-4-6', label: 'Opus 4.6' },
|
|
@@ -255,7 +255,8 @@ export class ClaudeCodeEngine implements AgentEngine {
|
|
|
255
255
|
{ value: '', label: `Default (${DEFAULT_MODEL})` },
|
|
256
256
|
{ value: 'claude-fable-5-1', label: 'Fable 5.1 — frontier, most capable' },
|
|
257
257
|
{ value: 'claude-fable-5', label: 'Fable 5' },
|
|
258
|
-
{ value: 'claude-opus-5', label: 'Opus 5 — most capable' },
|
|
258
|
+
{ value: 'claude-opus-5-5', label: 'Opus 5.5 — most capable' },
|
|
259
|
+
{ value: 'claude-opus-5', label: 'Opus 5' },
|
|
259
260
|
{ value: 'claude-opus-4-8', label: 'Opus 4.8' },
|
|
260
261
|
{ value: 'claude-opus-4-7', label: 'Opus 4.7' },
|
|
261
262
|
{ value: 'claude-opus-4-6', label: 'Opus 4.6' },
|
|
@@ -11,7 +11,8 @@ export const MODEL_ALIASES: Record<string, string> = {
|
|
|
11
11
|
fable: 'claude-fable-5-1',
|
|
12
12
|
'fable-5-1': 'claude-fable-5-1',
|
|
13
13
|
'fable-5': 'claude-fable-5',
|
|
14
|
-
opus: 'claude-opus-5',
|
|
14
|
+
opus: 'claude-opus-5-5',
|
|
15
|
+
'opus-5-5': 'claude-opus-5-5',
|
|
15
16
|
'opus-5': 'claude-opus-5',
|
|
16
17
|
'opus-4-8': 'claude-opus-4-8',
|
|
17
18
|
'opus-4-7': 'claude-opus-4-7',
|