@cortex-agent/server 2026.9.9 → 2026.9.10

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.
@@ -427,7 +427,7 @@ ${s}`:n.push(s)}return{fields:t,desc:n.length>0?n.join(`
427
427
  **${t.title}**${n}
428
428
  `+(t.body?`${t.body}
429
429
  `:"")+`
430
- 该条目已从 ISSUES.md 移除并交由本会话处理。请调查并解决上述问题;如需持久记录结论,写入项目上下文相应文件。`}const sc="'IBM Plex Mono',monospace";function M2e(e){const t=O(),{entries:n,selectedId:r,armed:o,pending:s}=e,a=n.length,l=a>0,c=n.find(u=>u.id===r)??n[0]??null,d=c?D$(c):null;return i.jsxs(i.Fragment,{children:[i.jsx("div",{onClick:e.onClose,style:{position:"fixed",inset:0,background:"var(--overlay-scrim-soft)",zIndex:60,animation:"cxfade .18s ease"}}),i.jsxs("div",{"data-issue-center":"","data-issue-selected":(c==null?void 0:c.id)??"",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:1150,maxWidth:"94vw",height:730,maxHeight:"90vh",background:"var(--proto-card)",borderRadius:14,boxShadow:"var(--shadow-overlay-strong)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[i.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:9,padding:"12px 20px",borderBottom:"1px solid var(--proto-line)"},children:[i.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:t.issuesTitle}),l&&i.jsx("span",{style:{font:`600 10.5px ${sc}`,color:"var(--proto-muted)",background:"var(--proto-line-2)",padding:"2px 9px",borderRadius:999,marginLeft:2},children:a}),i.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${sc}`,color:"var(--proto-muted-3)"},children:e.projectId?`${e.projectId}/ISSUES.md`:"ISSUES.md"}),i.jsx("span",{onClick:e.onClose,style:{font:`500 9.5px ${sc}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),i.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[!l&&i.jsx(I2e,{}),l&&i.jsxs(i.Fragment,{children:[i.jsx(A2e,{entries:n,selectedId:(c==null?void 0:c.id)??null,count:a,onSelect:e.onSelect}),d&&i.jsx(D2e,{detail:d,armed:o,pending:s,onArm:e.onArm,onCancelArm:e.onCancelArm,onDelete:e.onDelete,onHandle:e.onHandle})]})]})]})]})}function I2e(){const e=O();return i.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:9,background:"var(--proto-rail)"},children:[i.jsx("span",{style:{width:34,height:34,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:15,fontWeight:700},children:"✓"}),i.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--proto-ink)"},children:e.isEmptyTitle}),i.jsx("div",{style:{fontSize:11,color:"var(--proto-muted-2)"},children:e.isEmptyDesc})]})}function A2e({entries:e,selectedId:t,count:n,onSelect:r}){const o=O();return i.jsxs("div",{style:{width:400,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{padding:"14px 18px 9px",fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)",flex:"none"},children:[o.isListLabel," · ",n]}),i.jsx("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"0 12px",display:"flex",flexDirection:"column",gap:8},children:e.map(s=>{const a=R2e(s),l=s.id===t;return i.jsxs("div",{"data-issue-id":s.id,onClick:()=>r(s.id),style:{background:"var(--proto-card)",border:`1px solid ${l?"var(--proto-accent-border)":"var(--proto-line-2)"}`,borderRadius:10,padding:"11px 13px",boxShadow:l?"var(--focus-ring-accent)":"none",cursor:"pointer",flex:"none"},children:[i.jsx("div",{style:{fontSize:12.5,fontWeight:600,color:l?"var(--proto-ink)":"var(--proto-ink-2)",lineHeight:1.35},children:a.title}),a.date&&i.jsx("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:6},children:i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${sc}`,color:"var(--proto-faint)"},children:a.date})})]},s.id)})}),i.jsx("div",{style:{marginTop:"auto",padding:"12px 18px",borderTop:"1px solid var(--proto-line-2)",font:`400 9.5px ${sc}`,color:"var(--proto-faint)",lineHeight:1.7,flex:"none"},children:o.isNoStatusNote})]})}const N$={fontSize:10,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",paddingTop:2};function D2e({detail:e,armed:t,pending:n,onArm:r,onCancelArm:o,onDelete:s,onHandle:a}){const l=O();return i.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"18px 24px 0"},children:[i.jsx("div",{style:{fontSize:16,fontWeight:650,color:"var(--proto-ink)",lineHeight:1.35},children:e.title}),e.date&&i.jsx("div",{style:{display:"flex",alignItems:"center",gap:14,marginTop:8,font:`400 10.5px ${sc}`,color:"var(--proto-muted-3)"},children:i.jsxs("span",{children:[l.isRecorded," ",e.date]})}),i.jsxs("div",{style:{margin:"16px 0 14px",display:"grid",gridTemplateColumns:"76px 1fr",rowGap:10,columnGap:14,fontSize:12,lineHeight:1.6},children:[e.desc&&i.jsxs(i.Fragment,{children:[i.jsx("span",{style:N$,children:l.isDescLabel}),i.jsx("span",{style:{color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e.desc})]}),e.fields.map((c,d)=>i.jsx(L2e,{label:c.label,text:c.text},`${c.label}-${d}`))]})]}),i.jsxs("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"14px 22px",display:"flex",alignItems:"center",gap:10},children:[i.jsx("span",{style:{font:`400 10px ${sc}`,color:"var(--proto-faint)",lineHeight:1.6,flex:1,minWidth:0},children:l.isFootNote}),!t&&i.jsxs(i.Fragment,{children:[i.jsx(Mm,{"data-action":"arm-delete",onClick:n?void 0:()=>r(),base:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-danger-bg)",borderRadius:8,padding:"7px 16px",color:"var(--proto-danger)",background:"var(--proto-card)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-danger-bg)"},children:l.isDelete}),i.jsx(Mm,{"data-action":"handle",onClick:n?void 0:()=>a(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 22px",color:"var(--ink-solid-fg)",background:"var(--proto-accent)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-accent-strong)"},children:l.isHandle})]}),t&&i.jsxs(i.Fragment,{children:[i.jsx(Mm,{"data-action":"cancel-delete",onClick:n?void 0:()=>o(),base:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"7px 16px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-alt)"},children:l.cancel}),i.jsx(Mm,{"data-action":"confirm-delete",onClick:n?void 0:()=>s(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 20px",color:"var(--ink-solid-fg)",background:"var(--proto-danger)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{opacity:.88},children:l.isConfirmDelete})]})]})]})}function L2e({label:e,text:t}){return i.jsxs(i.Fragment,{children:[i.jsx("span",{style:N$,children:e}),i.jsx("span",{style:{color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})]})}function Mm({base:e,hover:t,onClick:n,children:r,...o}){const[s,a]=f.useState(!1);return i.jsx("span",{...o,onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:s?{...e,...t}:e,children:r})}function O2e({open:e,initialId:t,onClose:n}){const r=O(),o=he(),s=Ve(),a=Xe(),{toast:l}=Fn(),{currentProjectId:c}=zt(),{setSelectedSession:d}=Vi(),u=ae({...o.issues.list.queryOptions({projectId:c??""}),enabled:e&&!!c}),p=f.useMemo(()=>u.data??[],[u.data]),[h,m]=f.useState(null),[x,v]=f.useState(!1),S=L$(p,h??t),b=()=>s.invalidateQueries(o.issues.list.queryFilter()),g=Re(o.issues.delete.mutationOptions({onSettled:()=>{v(!1),b()}})),w=g.isPending;return f.useEffect(()=>{e||(v(!1),m(null))},[e]),f.useEffect(()=>{v(!1)},[S]),f.useEffect(()=>{if(!e)return;const k=C=>{C.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e,n]),e?i.jsx(M2e,{entries:p,selectedId:S,projectId:c,armed:x,pending:w,onSelect:m,onClose:n,onArm:()=>v(!0),onCancelArm:()=>v(!1),onDelete:k=>{c&&g.mutate({projectId:c,id:k},{onSuccess:()=>l({title:r.isToastDeleted,tone:"done"})})},onHandle:k=>{if(!c)return;const C=p.find(R=>R.id===k);if(!C)return;const T=O$(c,C),P=xh({isDraft:!0,projectId:c});ws(P,{text:T,attachments:[]}),d(nl),n(),a("/workbench"),g.mutate({projectId:c,id:k},{onSuccess:()=>l({title:r.isToastHandled,tone:"done"})})}}):null}const F$=f.createContext(null);function N2e({children:e}){const[t,n]=f.useState(!1),[r,o]=f.useState(null),s=f.useCallback(c=>{o(c??null),n(!0)},[]),a=f.useCallback(()=>{n(!1),o(null)},[]),l=f.useMemo(()=>({open:s,close:a}),[s,a]);return i.jsxs(F$.Provider,{value:l,children:[e,i.jsx(O2e,{open:t,initialId:r,onClose:a})]})}function F2e(){const e=f.useContext(F$);if(!e)throw new Error("useIssues must be used within an IssuesProvider");return e}const z2e=96;function z$(e,t=z2e){const n=(e??"").replace(/\s+/g," ").trim();return n.length<=t?n:n.slice(0,t-1).trimEnd()+"…"}function B2e(e){const t=(e.sessionName??"").trim();return{id:e.id,level:e.level??"info",title:t||"New message",meta:z$(e.text),ts:e.ts??new Date().toISOString(),sessionId:e.sessionId,projectId:e.projectId}}function $2e(e){const t=(e.title??"").trim();return{id:e.id,level:e.level??"info",title:t||"System notice",meta:z$(e.text),ts:e.ts??new Date().toISOString(),sessionId:"",projectId:null}}function _2e(e){return e==="info"}const W2e=3,bT=50;function H2e(e,t){return e.sessionId===t.sessionId&&e.meta===t.meta}function U2e(e,t){const n=e[e.length-1];if(n&&H2e(n,t))return e;const r=[...e,t];return r.length>bT?r.slice(r.length-bT):r}function V2e(e,t){return e.filter(n=>n.id!==t)}function B$(e,t=W2e){return e.length<=t?{visible:e,overflow:0}:{visible:e.slice(e.length-t),overflow:e.length-t}}const q2e={info:"bg-proto-accent-bg text-proto-accent",warning:"bg-pill-waiting-bg text-pill-waiting-fg",error:"bg-pill-failed-bg text-pill-failed-fg"},K2e={info:"i",warning:"!",error:"✕"};function G2e(e,t=Date.now()){const n=Date.parse(e);if(Number.isNaN(n))return"now";const r=Math.max(0,Math.floor((t-n)/1e3));if(r<45)return"now";const o=Math.floor(r/60);if(o<60)return`${o}m`;const s=Math.floor(o/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function Y2e({item:e,onDismiss:t,onActivate:n}){const r=_2e(e.level);return i.jsxs("div",{role:"status",onClick:()=>n(e),className:"group relative w-[380px] cursor-pointer overflow-hidden rounded-[11px] border border-proto-line bg-surface-card px-[13px] pb-[12px] pt-[11px] shadow-toast animate-toast-in motion-reduce:animate-none",children:[i.jsxs("div",{className:"flex items-start gap-[10px]",children:[i.jsx("span",{className:["flex h-[24px] w-[24px] flex-none items-center justify-center rounded-[7px] text-[11px] font-bold",q2e[e.level]].join(" "),"aria-hidden":!0,children:K2e[e.level]}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-baseline gap-[8px]",children:[i.jsx("span",{className:"text-[12.5px] font-semibold text-proto-ink",children:e.title}),i.jsx("span",{className:"ml-auto font-mono text-[10px] text-proto-faint",children:G2e(e.ts)}),i.jsx("button",{type:"button","aria-label":"Dismiss",onClick:o=>{o.stopPropagation(),t(e.id)},className:"flex-none text-[12px] leading-none text-proto-faint transition-colors hover:text-proto-muted",children:"✕"})]}),i.jsx("div",{className:"mt-[3px] truncate font-mono text-[10.5px] text-proto-muted-2",children:e.meta})]})]}),r?i.jsx("div",{className:"absolute bottom-0 left-0 h-[2px] bg-proto-accent opacity-40 animate-toastbar group-hover:[animation-play-state:paused]",onAnimationEnd:o=>{o.animationName==="toastbar"&&t(e.id)}}):null]})}function Q2e({items:e,onDismiss:t,onActivate:n}){const[r,o]=f.useState(!1);if(e.length===0)return null;const{visible:s,overflow:a}=B$(e),l=r?e:s;return i.jsxs("div",{className:"pointer-events-none fixed bottom-0 right-0 z-50 m-2g flex w-[380px] max-w-[calc(100vw-2rem)] flex-col items-end gap-[10px]",children:[l.map(c=>i.jsx("div",{className:"pointer-events-auto w-full",children:i.jsx(Y2e,{item:c,onDismiss:t,onActivate:n})},c.id)),a>0&&!r?i.jsxs("button",{type:"button",onClick:()=>o(!0),className:"pointer-events-auto flex items-center gap-[7px] rounded-full border border-proto-line bg-surface-card px-[12px] py-[5px] shadow-toast-pill",children:[i.jsxs("span",{className:"font-mono text-[10.5px] font-semibold text-proto-muted",children:["+",a]}),i.jsx("span",{className:"text-[11px] text-proto-muted-2",children:"more · click to expand"})]}):null]})}function X2e(e,t,n){e.set(t,n)}function W5(e,t){const n=e.get(t)??null;return e.delete(t),n}const Z2e=["session.message","session.status"];function J2e({onMessage:e,onTurnEnd:t}){qs(Z2e,n=>{if(n.type==="session.message"){const r=n.payload;if(!r||r.role!=="assistant")return;const o=(r.text??"").trim();if(!o||!r.sessionId)return;e({sessionId:r.sessionId,channel:r.channel??null,text:o,ts:r.ts??null});return}if(n.type==="session.status"){const r=n.payload;if(!r||!r.sessionId||r.running!==!1)return;t(r.sessionId)}})}function e4e(e){qs(t$,t=>{if(t.type!=="system.notice")return;const n=t.payload,r=((n==null?void 0:n.text)??"").trim();r&&e({level:(n==null?void 0:n.level)??"info",text:r,title:(n==null?void 0:n.title)??null,ts:(n==null?void 0:n.ts)??null})})}function wT(e){const t=new Map;for(const n of e??[])t.set(n.sessionId,{name:n.label??n.name,projectId:n.projectId});return t}function t4e(){const e=he(),t=ae(e.sessions.list.queryOptions({origin:"direct"})),n=f.useMemo(()=>wT(t.data),[t.data]),r=f.useCallback(async()=>{const o=await t.refetch();return o.isError?null:wT(o.data)},[t.refetch]);return{map:n,refresh:r}}function n4e(){const e=f.useRef(!1);return f.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function r4e(e,t){const n=n4e();return f.useCallback(r=>{(async()=>{try{if(t&&await t(r))return}catch{}n.current&&e(o=>U2e(o,r))})()},[t,n,e])}function o4e(e,t,n,r,o){if(!e.has(o))return{consumed:!0,item:null};if(n(o))return W5(e,o),{consumed:!0,item:null};const s=t.get(o);if(!s)return{consumed:!1,item:null};const a=W5(e,o);return{consumed:!0,item:B2e({id:r("dmn"),sessionId:o,sessionName:s.name,projectId:s.projectId,text:a.text,ts:a.ts})}}function i4e(e,t,n,r){const o=f.useRef(new Map),s=f.useRef(new Set),a=f.useCallback((d,u=e.map)=>{const p=o4e(o.current,u,t,n,d);return p.consumed?(s.current.delete(d),p.item&&r(p.item),!0):!1},[r,t,e.map,n]),l=f.useCallback(d=>{X2e(o.current,d.sessionId,{text:d.text,ts:d.ts??new Date().toISOString()})},[]),c=f.useCallback(d=>{!o.current.has(d)||a(d)||(s.current.add(d),e.refresh().then(u=>{!u||a(d,u)||(W5(o.current,d),s.current.delete(d))}).catch(()=>{}))},[a,e]);f.useEffect(()=>{s.current.forEach(d=>{a(d)})},[a]),J2e({onMessage:l,onTurnEnd:c})}function s4e(e,t){const n=f.useCallback(r=>{t($2e({id:e("sysn"),level:r.level,text:r.text,title:r.title??void 0,ts:r.ts??void 0}))},[t,e]);e4e(n)}function $$({isSessionOpen:e,externalDelivery:t}){const[n,r]=f.useState([]),o=f.useRef(0),s=t4e(),a=r4e(r,t),l=f.useCallback(d=>`${d}-${o.current++}`,[]);i4e(s,e,l,a),s4e(l,a);const c=f.useCallback(d=>{r(u=>V2e(u,d))},[]);return{items:n,dismiss:c}}function a4e(){const e=Xe(),t=fo(),{selectedSessionId:n,setSelectedSession:r}=Vi(),{setCurrentProject:o}=zt(),s=f.useCallback(d=>t.pathname.startsWith("/workbench")&&n===d,[t.pathname,n]),{items:a,dismiss:l}=$$({isSessionOpen:s}),c=f.useCallback(d=>{d.sessionId&&(d.projectId&&o(d.projectId),r(d.sessionId),e("/workbench")),l(d.id)},[l,e,o,r]);return i.jsx(Q2e,{items:a,onDismiss:l,onActivate:c})}const l4e="fixed inset-0 z-40 bg-state-ink/[0.44] data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none",c4e="fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2 w-[420px] max-w-[calc(100vw-32px)] box-border rounded-[14px] bg-surface-card p-5 pb-4 shadow-overlay-strong focus:outline-none data-[state=open]:animate-zoom-in data-[state=closed]:animate-zoom-out motion-reduce:animate-none";function d4e(e){return i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"flex h-9 w-9 flex-none items-center justify-center rounded-card bg-proto-accent-bg text-state-run",children:i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),i.jsx("path",{d:"M3.5 16.5h13"})]})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx(fl,{className:"text-body font-semibold text-state-ink",children:e.title}),i.jsx("div",{className:"mt-[3px] font-mono text-[10.5px] font-medium text-proto-muted-3",children:e.summary})]})]})}function _$(e){return i.jsx(ul,{open:!0,onOpenChange:t=>{t||e.onDismiss()},children:i.jsxs(pl,{children:[i.jsx(Ms,{className:l4e}),i.jsxs($s,{className:c4e,"aria-describedby":e.descriptionId,children:[i.jsx(d4e,{title:e.title,summary:e.summary}),i.jsx(Z0,{id:e.descriptionId,className:"mb-4 mt-3 text-[12.5px] leading-[1.65] text-proto-muted",children:e.description}),e.children]})]})})}const u4e="frontend-update-staged";function ST(e){return e.slice(0,8)}function p4e(e){const t=ST(e.version),n=e.fromVersion?ST(e.fromVersion):"";return n&&n!==t?`${n} → ${t}`:t}function W$(e){if(!e||e<=0)return null;const t=e>=1024*1024?1:0;return K3(e,{fractionDigits:t,maxUnit:"MB"})}function H$(e){const t=W$(e.size),n=[p4e(e)];return t&&n.push(t),n.push("已下载"),n.join(" · ")}function LS(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.version!="string"||!t.version?null:{version:t.version,fromVersion:typeof t.fromVersion=="string"&&t.fromVersion?t.fromVersion:void 0,size:typeof t.size=="number"?t.size:void 0}}async function f4e(e){return dr()?x1(u4e,t=>{const n=LS(t);n&&e(n)}):()=>{}}async function h4e(){if(!dr())return null;const e=await bt("get_staged_update");return e.ok?LS(e.value):null}async function m4e(){dr()&&await bt("apply_frontend_update")}const g4e="app-update-available";function H5(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.version!="string"||!t.version||typeof t.kind!="string"||!t.kind)return null;const n={version:t.version,kind:t.kind};return typeof t.releaseUrl=="string"&&t.releaseUrl&&(n.releaseUrl=t.releaseUrl),typeof t.notes=="string"&&t.notes&&(n.notes=t.notes),typeof t.size=="number"&&t.size>0&&(n.size=t.size),n}function U$(e){const t=[`Cortex ${e.version}`],n=W$(e.size);return n&&t.push(n),t.push("已下载"),t.join(" · ")}function V$(e){switch(e){case"appimage":return"重启更新";case"nsis":return"运行安装程序";case"apk":return"安装";case"dmg":case"deb":case"rpm":return"打开安装包";default:return"更新"}}function q$(e){switch(e){case"appimage":return"新版本已在后台下载并校验完成,点击后自动替换并重启。运行中的线程在服务端继续执行,不受影响。";case"nsis":return"新版本已在后台下载并校验完成。点击后将退出 App 并启动安装程序,按提示完成安装后重新打开即可。";case"apk":return"新版本已在后台下载并校验完成。点击安装后按系统提示完成升级,运行中的线程在服务端继续执行。";case"dmg":return"新版本已在后台下载并校验完成。将打开磁盘映像,把 Cortex 拖入 Applications 即完成升级。";case"deb":case"rpm":return"新版本已在后台下载并校验完成。将打开安装包,用系统安装器完成升级后重新打开 App。";default:return"新版本已在后台下载并校验完成。"}}let K$=null;const U5=new Set;function w0(e){K$=e;for(const t of U5)t()}function v4e(e){return U5.add(e),()=>U5.delete(e)}function x4e(){return K$}async function y4e(){if(!dr())return()=>{};const e=await x1(g4e,n=>{const r=H5(n);r&&w0(r)}),t=await bt("get_app_update");if(t.ok){const n=H5(t.value);n&&w0(n)}return e}async function b4e(){if(!dr())return null;const e=await bt("install_app_update");if(e.ok)return typeof e.value=="string"?e.value:null;if(e.reason==="failed"&&typeof e.error=="string"&&e.error)throw new Error(e.error);return null}async function w4e(){w0(null),dr()&&await bt("skip_app_update")}const kT="box-border flex h-9 items-center rounded-[9px] border border-proto-line px-4 text-[12.5px] font-semibold text-proto-muted transition-colors hover:bg-surface-canvas-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40";function S4e(e){return i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:e.onSkip,className:kT,children:"跳过此版本"}),i.jsx("button",{type:"button",onClick:e.onDismiss,className:kT,children:"稍后"}),i.jsx("button",{type:"button",onClick:e.onInstall,disabled:e.busy,className:"box-border flex h-9 items-center rounded-[9px] bg-state-ink px-4 text-[12.5px] font-semibold text-surface-card transition-opacity hover:opacity-90 disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:e.busy?"正在处理…":V$(e.update.kind)})]})}function k4e(e){return i.jsxs(_$,{title:"App 新版本已就绪",summary:U$(e.update),descriptionId:"app-update-desc",description:q$(e.update.kind),onDismiss:e.onDismiss,children:[e.error?i.jsxs("div",{className:"mb-3 text-[11.5px] leading-snug text-state-fail",children:["安装失败:",e.error]}):null,i.jsx(S4e,{...e})]})}function j4e(e){return i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:e.onDismiss,className:"box-border flex h-9 items-center rounded-[9px] border border-proto-line px-4 text-[12.5px] font-semibold text-proto-muted transition-colors hover:bg-surface-canvas-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"忽略"}),i.jsx("button",{type:"button",onClick:e.onApply,className:"box-border flex h-9 items-center rounded-[9px] bg-state-ink px-4 text-[12.5px] font-semibold text-surface-card transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"重启 App"})]})}function C4e(e){return i.jsx(_$,{title:"新版本已就绪",summary:H$(e.update),descriptionId:"hot-update-desc",description:"热更新已在后台下载完成,重启 App 后生效。运行中的线程在服务端继续执行,不受重启影响;未发送的草稿会保留。",onDismiss:e.onDismiss,children:i.jsx(j4e,{onApply:e.onApply,onDismiss:e.onDismiss})})}const Dv=new Set,V5=new Set;let od=null;const q5=()=>od!==null;function G$(e){return Dv.add(e),()=>{Dv.delete(e)}}function Y$(e){return V5.add(e),()=>{V5.delete(e)}}function kb(e){return{ui:{status:"error",reason:e},shell:{status:"error",reason:e}}}function T4e(e){if(!e||typeof e!="object")return null;const t=e;return!["available","current","skipped","error"].includes(t.status)||t.reason!==void 0&&typeof t.reason!="string"?null:t}function jT(e,t){const n=T4e(e);if(!n)return null;const r=n.update===void 0?void 0:t(n.update);return r===null||n.status==="available"&&!r||n.status==="current"&&r?null:{status:n.status,...r?{update:r}:{},...n.reason!==void 0?{reason:n.reason}:{}}}async function P4e(){var r,o;const e=await bt("check_for_updates");if(hh(e))return kb("unsupported_shell");if(!e.ok)return kb("check_failed");const t=jT((r=e.value)==null?void 0:r.ui,LS),n=jT((o=e.value)==null?void 0:o.shell,H5);return t&&n?{ui:t,shell:n}:kb("invalid_report")}function E4e(){if(od)return od;od=P4e().then(e=>{for(const t of V5)t(e);return e}).finally(()=>{od=null;for(const e of Dv)e()});for(const e of Dv)e();return od}const R4e=["button","checkbox","radio","submit","reset","file","range","color"];function M4e(e){return e?e.tagName==="TEXTAREA"?!0:e.tagName==="INPUT"?!R4e.includes(e.type):e.isContentEditable===!0:!1}function I4e(){return typeof document<"u"&&M4e(document.activeElement)}function Q$(e){const[t,n]=f.useState(null);return f.useEffect(()=>{if(e===null){n(null);return}const r=()=>{I4e()||n(e)};if(r(),typeof document>"u")return;const o=()=>window.setTimeout(r,0);return document.addEventListener("focusout",o),()=>document.removeEventListener("focusout",o)},[e]),e===t?t:null}function A4e(){f.useEffect(()=>{let e=!1,t=()=>{};return y4e().then(n=>{e?n():t=n}),()=>{e=!0,t()}},[])}function D4e(e,t){const[n,r]=f.useState(!1),[o,s]=f.useState(null),a=f.useCallback(()=>{r(!0),s(null),b4e().then(l=>{r(!1),t(e),l!==null&&w0(null)}).catch(l=>{r(!1),s(l.message)})},[t,e]);return{busy:n,error:o,install:a}}function L4e(){const e=f.useSyncExternalStore(v4e,x4e),[t,n]=f.useState(null),r=(e==null?void 0:e.version)===t?null:e,o=Q$(r),s=D4e((e==null?void 0:e.version)??(o==null?void 0:o.version)??null,n);A4e(),f.useEffect(()=>Y$(({shell:c})=>{c.update&&(n(null),w0(c.update))}),[]);const a=f.useCallback(()=>{w4e()},[]),l=f.useCallback(()=>{n((e==null?void 0:e.version)??(o==null?void 0:o.version)??null)},[e,o]);return{pending:e,update:o,...s,skip:a,dismiss:l}}function O4e(e){const[t,n]=f.useState(null);return f.useEffect(()=>{let r=!1,o=()=>{};const s=l=>{!r&&!e.current&&n(l)};f4e(s).then(l=>{r?l():o=l}),h4e().then(l=>{l&&s(l)});const a=Y$(({ui:l})=>{l.update&&(e.current=!1,n(l.update))});return()=>{r=!0,o(),a()}},[e]),[t,n]}function N4e(){const e=f.useRef(!1),[t,n]=O4e(e),r=Q$(t),o=f.useCallback(()=>{m4e()},[]),s=f.useCallback(()=>{e.current=!0,n(null)},[n]);return{staged:r,apply:o,dismiss:s}}function X$(){const e=L4e(),t=N4e();return f.useSyncExternalStore(G$,q5)?null:e.update?{kind:"app",update:e.update,busy:e.busy,error:e.error,install:e.install,skip:e.skip,dismiss:e.dismiss}:!e.pending&&t.staged?{kind:"hot",update:t.staged,apply:t.apply,dismiss:t.dismiss}:null}function F4e(){const e=X$();return e?e.kind==="hot"?i.jsx(C4e,{update:e.update,onApply:e.apply,onDismiss:e.dismiss}):i.jsx(k4e,{update:e.update,busy:e.busy,error:e.error,onInstall:e.install,onSkip:e.skip,onDismiss:e.dismiss}):null}function z4e(e,t){return e==="pending"?"connected":e==="connecting"?t?"reconnecting":"connecting":t?"disconnected":"connecting"}function Z$(e){switch(e){case"connected":return{color:"var(--proto-success)",pulse:!1};case"connecting":case"reconnecting":return{color:"var(--proto-amber)",pulse:!0};case"disconnected":return{color:"var(--proto-danger)",pulse:!1}}}function J$(e){switch(e){case"connected":return"connConnected";case"connecting":return"connConnecting";case"reconnecting":return"connReconnecting";case"disconnected":return"connDisconnected"}}const e_=f.createContext("connecting");function t_({children:e}){const{connState:t,hasConnected:n}=ES(),r=z4e(t,n);return i.jsx(e_.Provider,{value:r,children:e})}function OS(){return f.useContext(e_)}function NS(e){var t;return e.claimThreadId?e.claimThreadId:(t=e.claimedBy)!=null&&t.startsWith("thr_")?e.claimedBy:null}function n_(e){return e.status==="done"?"done":e.blockedBy!=null?"blocked":e.claimedBy!=null?"in-progress":e.approvalNeeded===!0?"approval-needed":e.actionable?"actionable":"waiting"}function B4e(e){const t=e.claimedBy!=null,n=t&&e.claimedBy!=="task-dispatcher"?e.claimedBy:null,r=t?NS(e):null;return{claimed:t,id:n,threadId:r,displayId:r??n}}function CT(e){const t=Date.parse(e.startedAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t}function $4e(e){return e.map((t,n)=>({dispatch:t,index:n})).sort((t,n)=>CT(n.dispatch)-CT(t.dispatch)||t.index-n.index).map(({dispatch:t})=>t)}function r_(e){const t=e.evidence.completingExecutionId,n=$4e(e.dispatches).map(o=>({dispatch:o,isCompleting:t!=null&&o.executionId===t})),r=e.evidence;return{evidence:r,hasEvidence:r.completed&&(r.completedNote!=null||r.completingOutput!=null||r.completedAt!=null),dispatches:n,newestDispatch:n[0]??null,completingExecution:n.find(o=>o.isCompleting)??null}}function TT(e,t,n){return{relation:e,id:t,known:n!=null,task:n??null,statusKind:n?n_(n):null}}function _4e(e,t){const n=new Map(t.map(s=>[s.id,s])),r=e.dependsOn.map(s=>TT("upstream",s,n.get(s))),o=t.filter(s=>s.id!==e.id&&s.dependsOn.includes(e.id)).map(s=>TT("downstream",s.id,s));return{upstream:r,downstream:o}}function o_(e,t,n){const r=n?r_(n):null,o=_4e(e,t);return{task:e,statusKind:n_(e),claim:B4e(e),completedAt:(r==null?void 0:r.evidence.completedAt)??e.completedAt??null,...o,verification:r}}function Im(e){return String(e).padStart(2,"0")}function k1(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:`${`${t.getFullYear()}-${Im(t.getMonth()+1)}-${Im(t.getDate())}`} ${Im(t.getHours())}:${Im(t.getMinutes())}`}const W4e={done:{bg:"var(--pill-done-bg)",fg:"var(--pill-done-fg)",text:"✓ done"},blocked:{bg:"var(--pill-failed-bg)",fg:"var(--pill-failed-fg)",text:"blocked"},"approval-needed":{bg:"var(--pill-waiting-bg)",fg:"var(--pill-waiting-fg)",text:"approval-needed"},actionable:{bg:"var(--pill-running-bg)",fg:"var(--pill-running-fg)",text:"actionable"},waiting:{bg:"var(--pill-cancelled-bg)",fg:"var(--pill-cancelled-fg)",text:"waiting on deps"}};function H4e(e){return e.statusKind!=="in-progress"?W4e[e.statusKind]:{bg:"var(--pill-running-bg)",fg:"var(--pill-running-fg)",text:`● in-progress${e.claim.displayId?` · ${e.claim.displayId}`:""}`}}function U4e(e){return e==="high"?"var(--state-fail)":e==="medium"?"var(--proto-amber)":"var(--proto-faint)"}function V4e(e){return e?e.status==="done"?"var(--state-done)":e.blockedBy!=null?"var(--state-fail)":"var(--state-run)":"var(--proto-faint)"}function q4e(e){const t=e.approvalNeeded;return[{k:"approval-needed",v:t==null?"—":String(t),vColor:t===!0?"var(--pill-waiting-fg)":"var(--proto-ink)"},{k:"approved-at",v:e.approvedAt??"—",vColor:e.approvedAt?"var(--state-done)":"var(--proto-faint)"}]}function K4e(e,t){const n=t.claim.displayId,r=k1(t.completedAt);return[{k:"priority",v:e.priority,vColor:e.priority==="high"?"var(--state-fail)":"var(--proto-ink)"},{k:"status",v:e.status,vColor:"var(--proto-ink)"},...q4e(e),{k:"completed-at",v:r??"—",vColor:r?"var(--state-done)":"var(--proto-faint)"},{k:"template",v:e.template,vColor:"var(--proto-ink)"},{k:"gpu",v:"—",vColor:"var(--proto-faint)"},{k:"claimed-by",v:n??"—",vColor:n?"var(--state-run)":"var(--proto-faint)"}]}function G4e(e){var n;const t=e.statusKind==="done";return{id:e.id,name:((n=e.task)==null?void 0:n.text)??"—",dotColor:V4e(e.task??void 0),idColor:"var(--state-run)",label:e.relation==="upstream"&&t?"upstream · done":e.relation,bg:"var(--proto-rail)",border:"var(--proto-line-2)"}}function Y4e(e,t,n=null){const r=o_(e,t,n),o=[...r.upstream,...r.downstream].map(G4e),s=e.status!=="done"&&e.blockedBy==null;return{id:e.id,title:e.text,pill:H4e(r),priColor:U4e(e.priority),fields:K4e(e,r),deps:o,hasDependencies:o.length>0,canUnblock:e.blockedBy!=null,completable:s,completeBg:s?"var(--proto-accent)":"var(--proto-faint)",completeLabel:e.status==="done"?"Completed":"Complete"}}function Q4e(e){switch(e){case"completed":return"var(--state-done)";case"failed":return"var(--state-fail)";case"running":return"var(--state-run)";case"stale":return"var(--proto-amber)";default:return"var(--proto-muted-2)"}}function X4e(e){if(e==null||!Number.isFinite(e)||e<0)return"—";const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t%60);return`${n}m ${r}s`}function Z4e(e){return e==null||!Number.isFinite(e)?"—":yn(e)}function J4e(e){if(!e)return"—";const t=Date.parse(e);if(Number.isNaN(t))return"—";const n=new Date(t),r=o=>String(o).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}`}function e5e(e){const t=r_(e),n=t.evidence,r=t.dispatches.map(({dispatch:o,isCompleting:s})=>({executionId:o.executionId,type:o.type,status:o.status,statusColor:Q4e(o.status),machine:o.machine??"—",threadId:o.threadId,when:J4e(o.startedAt),duration:X4e(o.durationMs),cost:Z4e(o.cost),isCompleting:s}));return{completed:n.completed,doneWhen:n.doneWhen,completedAt:n.completedAt,completedNote:n.completedNote,completingExecutionId:n.completingExecutionId,completingOutput:n.completingOutput,hasEvidence:t.hasEvidence,dispatches:r,hasDispatches:r.length>0}}const id={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"var(--shadow-card-subtle)"},jb={display:"flex",alignItems:"center",padding:"10px 15px",borderBottom:"1px solid var(--proto-line-2)"},Cb={fontSize:11.5,fontWeight:650,color:"var(--proto-ink)"};function Vc({children:e}){return i.jsx("span",{style:{fontStyle:"italic",color:"var(--proto-faint)"},children:e})}function t5e({label:e,reason:t}){return t==null?null:i.jsxs("div",{"data-task-blocker-card":"true",style:{...id,padding:"10px 15px",background:"var(--proto-danger-bg)"},children:[i.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-danger)"},children:e}),i.jsx("div",{style:{marginTop:5,fontSize:11.5,lineHeight:1.6,color:"var(--proto-danger)",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:t})]})}function n5e({vv:e}){return i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.dispatches.map(t=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 9px",background:t.isCompleting?"var(--proto-accent-bg)":"var(--proto-rail)",border:`1px solid ${t.isCompleting?"var(--proto-accent-bg)":"var(--proto-line-2)"}`,borderRadius:7},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:t.statusColor,flex:"none"}}),i.jsx("span",{style:{font:"600 10px 'IBM Plex Mono',monospace",color:"var(--proto-accent)"},children:t.executionId}),i.jsx("span",{style:{fontSize:9.5,color:"var(--proto-muted-2)"},children:t.machine}),i.jsxs("span",{style:{marginLeft:"auto",font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",flex:"none"},children:[t.when," · ",t.duration," · ",t.cost]})]},t.executionId))})}function r5e({task:e,allTasks:t,pending:n,onClose:r,onComplete:o,onUnblock:s}){const a=O(),l=he(),c=ae(l.tasks.verification.queryOptions({projectId:e.project,taskId:e.id})),d=c.data??null,u=Y4e(e,t,d),p=d?e5e(d):null;return i.jsxs(ur,{chrome:"bare",size:"custom",open:!0,showClose:!1,title:`${u.id} · ${u.title}`,description:e.why??e.doneWhen??u.title,onOpenChange:h=>{h||r()},contentDataAttributes:{"data-task-modal-id":e.id},bodyStyle:{display:"contents"},contentStyle:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:760,maxHeight:"84vh",background:"var(--proto-alt)",borderRadius:14,boxShadow:"var(--shadow-overlay-strong)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[i.jsxs("div",{style:{flex:"none",background:"var(--proto-card)",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"12px 18px"},children:[i.jsx("span",{style:{font:"600 12.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:u.id}),i.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 8px",borderRadius:999,background:u.pill.bg,color:u.pill.fg},children:u.pill.text}),i.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginLeft:4},children:"TASKS.yaml"}),i.jsx("span",{onClick:r,style:{marginLeft:"auto",font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),i.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"14px 18px",display:"grid",gridTemplateColumns:"1.5fr 1fr",gap:12,alignContent:"start"},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,minWidth:0},children:[i.jsxs("div",{style:{...id,padding:"13px 16px"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:u.priColor,flex:"none",marginTop:5}}),i.jsx("div",{style:{fontSize:13.5,fontWeight:650,color:"var(--proto-ink)",lineHeight:1.4},children:u.title})]}),i.jsxs("div",{style:{fontSize:11.5,lineHeight:1.6,color:"var(--proto-muted)",marginTop:7},children:[i.jsx("span",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginRight:7},children:a.tkWhy}),e.why!=null?i.jsx("span",{children:e.why}):i.jsxs(Vc,{children:["— ",a.tkNoWhy]})]}),i.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",margin:"11px 0 5px"},children:a.tkDoneWhen}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:i.jsxs("div",{style:{display:"flex",gap:8,fontSize:11.5,lineHeight:1.5,color:"var(--proto-ink-2)",background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:7,padding:"6px 10px"},children:[i.jsx("span",{style:{width:12,height:12,borderRadius:4,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",boxSizing:"border-box",flex:"none",marginTop:1.5}}),e.doneWhen!=null?i.jsx("span",{children:e.doneWhen}):i.jsxs(Vc,{children:["— ",a.tkNoDoneWhen]})]})})]}),i.jsx(t5e,{label:a.mBlockedPill,reason:e.blockedBy}),i.jsxs("div",{style:id,children:[i.jsxs("div",{style:jb,children:[i.jsx("span",{style:Cb,children:a.tkDispatchHistory}),p&&p.hasDispatches&&i.jsxs("span",{style:{marginLeft:"auto",font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:[p.dispatches.length," run",p.dispatches.length===1?"":"s"]})]}),i.jsx("div",{style:{padding:"10px 15px",fontSize:11,lineHeight:1.55},children:c.isPending?i.jsxs(Vc,{children:["— ",a.tkLoadingDispatch]}):c.isError||!p?i.jsxs(Vc,{children:["— ",a.tkDispatchFailed]}):p.hasDispatches?i.jsx(n5e,{vv:p}):i.jsxs(Vc,{children:["— ",a.tkNoDispatches]})})]})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,minWidth:0},children:[i.jsxs("div",{style:id,children:[i.jsx("div",{style:jb,children:i.jsx("span",{style:Cb,children:a.tkFields})}),i.jsx("div",{style:{padding:"8px 15px 10px",font:"400 10px/2 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:u.fields.map(h=>i.jsxs("div",{style:{display:"flex"},children:[i.jsx("span",{style:{color:"var(--proto-muted-3)"},children:h.k}),i.jsx("span",{style:{marginLeft:"auto",color:h.vColor,textAlign:"right"},children:h.v})]},h.k))})]}),i.jsxs("div",{style:id,children:[i.jsx("div",{style:jb,children:i.jsx("span",{style:Cb,children:a.tkDependencies})}),i.jsx("div",{style:{padding:"10px 15px",display:"flex",flexDirection:"column",gap:5},children:u.hasDependencies?u.deps.map(h=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 9px",background:h.bg,border:`1px solid ${h.border}`,borderRadius:7},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:h.dotColor,flex:"none"}}),i.jsx("span",{style:{font:"600 10.5px 'IBM Plex Mono',monospace",color:h.idColor},children:h.id}),i.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:h.name}),i.jsx("span",{style:{marginLeft:"auto",font:"400 8.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",flex:"none"},children:h.label})]},`${h.label}:${h.id}`)):i.jsxs(Vc,{children:["— ",a.tkNoDependencies]})})]}),i.jsxs("div",{style:{...id,padding:"11px 14px",display:"flex",gap:8},children:[u.canUnblock&&i.jsx("span",{onClick:()=>!n&&s(e),style:{flex:1,textAlign:"center",fontSize:11,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"6px 0",color:"var(--proto-ink)",cursor:n?"not-allowed":"pointer",opacity:n?.5:1},children:a.mUnblock}),i.jsx("span",{"data-complete-task-id":e.id,onClick:()=>u.completable&&!n&&o(e),style:{flex:1.3,textAlign:"center",fontSize:11,fontWeight:600,borderRadius:8,padding:"7px 0",color:"var(--ink-solid-fg)",background:u.completeBg,cursor:u.completable&&!n?"pointer":"not-allowed",opacity:n?.6:1},children:u.completeLabel})]})]})]})]})}function o5e(e,t){return t.type==="open"?{projectId:t.projectId,taskId:t.taskId}:null}const i_=f.createContext(null);function i5e(e){const t=he(),n=Ve(),r=()=>n.invalidateQueries(t.tasks.list.queryFilter()),o=Re(t.tasks.complete.mutationOptions({onSettled:()=>{e(),r()}})),s=Re(t.tasks.unblock.mutationOptions({onSettled:()=>void r()}));return{completeTask:c=>o.mutate({projectId:c.project,taskId:c.id,note:"completed via Web UI"}),unblockTask:c=>s.mutate({projectId:c.project,taskId:c.id}),pending:o.isPending||s.isPending}}function s5e({selection:e,onClose:t}){const n=he(),r=ae(n.tasks.list.queryOptions({projectId:e.projectId})),o=i5e(t),s=r.data??[],a=s.find(l=>l.id===e.taskId);return a?i.jsx(r5e,{task:a,allTasks:s,pending:o.pending,onClose:t,onComplete:o.completeTask,onUnblock:o.unblockTask}):null}function a5e({children:e}){const[t,n]=f.useReducer(o5e,null),r=f.useCallback((a,l)=>{n({type:"open",projectId:a,taskId:l})},[]),o=f.useCallback(()=>n({type:"close"}),[]),s=f.useMemo(()=>({openTask:r,closeTask:o}),[r,o]);return i.jsxs(i_.Provider,{value:s,children:[e,t&&i.jsx(s5e,{selection:t,onClose:o})]})}function s_(){const e=f.useContext(i_);if(!e)throw new Error("useTaskModal must be used within a TaskModalProvider");return e}const a_=f.createContext(null);function l5e({alt:e,src:t}){const n=f.useContext(a_),[r,o]=f.useState(null),[s,a]=f.useState(!1);return f.useEffect(()=>{if(!n)return;let l=!1,c=null;return o(null),a(!1),n(t).then(d=>{if(l){URL.revokeObjectURL(d);return}c=d,o(d)}).catch(()=>{l||a(!0)}),()=>{l=!0,c&&URL.revokeObjectURL(c)}},[n,t]),!n||s||!r?i.jsx("span",{style:{color:"var(--proto-muted-3)"},children:e||t}):i.jsx("img",{src:r,alt:e,style:{maxWidth:"100%",borderRadius:6,display:"block",margin:"8px 0"}})}const Lv="'IBM Plex Mono',monospace";function qc(e){return e.map((t,n)=>{switch(t.type){case"bold":return i.jsx("span",{style:{fontWeight:650,color:"var(--proto-ink-2)"},children:t.text},n);case"italic":return i.jsx("em",{style:{fontStyle:"italic"},children:t.text},n);case"code":return i.jsx("code",{style:{font:`400 .92em ${Lv}`,background:"var(--proto-gray)",color:"var(--proto-accent-strong)",padding:"1px 4px",borderRadius:4},children:t.text},n);case"link":return i.jsx("a",{href:t.href,style:{color:"var(--proto-accent)",textDecoration:"none"},children:t.text},n);case"image":return i.jsx(l5e,{alt:t.alt,src:t.src},n);default:return i.jsx(f.Fragment,{children:t.text},n)}})}const c5e={fontSize:12.5,fontWeight:650,color:"var(--proto-ink)",margin:"15px 0 5px"},d5e={fontSize:11.5,lineHeight:1.65,color:"var(--proto-ink-3)",margin:"4px 0 0"};function u5e(e,t){switch(e.type){case"heading":return i.jsx("div",{style:{...c5e,fontSize:e.level>=3?11.5:12.5},children:qc(e.inline)},t);case"paragraph":return i.jsx("div",{style:d5e,children:qc(e.inline)},t);case"list":return i.jsx("div",{style:{fontSize:11.5,lineHeight:1.75,color:"var(--proto-ink-3)",margin:"4px 0 0"},children:e.items.map((n,r)=>i.jsxs("div",{style:{display:"flex",gap:9},children:[i.jsx("span",{style:{color:"var(--proto-faint)",flex:"none"},children:e.ordered?`${r+1}.`:"·"}),i.jsx("span",{children:qc(n)})]},r))},t);case"table":{const n=Math.max(e.header.length,...e.rows.map(o=>o.length),1),r=`repeat(${n}, minmax(0,1fr))`;return i.jsxs("div",{style:{border:"1px solid var(--proto-line-2)",borderRadius:8,overflow:"hidden",fontSize:11,margin:"7px 0 0"},children:[i.jsx("div",{style:{display:"grid",gridTemplateColumns:r,padding:"6px 12px",background:"var(--proto-rail)",borderBottom:"1px solid var(--proto-line-2)",fontSize:9,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},children:e.header.map((o,s)=>i.jsx("span",{children:qc(o)},s))}),e.rows.map((o,s)=>i.jsx("div",{style:{display:"grid",gridTemplateColumns:r,padding:"6px 12px",borderBottom:"1px solid var(--proto-alt)",color:"var(--proto-ink-3)"},children:Array.from({length:n}).map((a,l)=>i.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:o[l]?qc(o[l]):null},l))},s))]},t)}case"code":return i.jsx("pre",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,padding:"10px 13px",font:`400 10.5px ${Lv}`,color:"var(--proto-ink-2)",overflow:"auto",margin:"7px 0 0",whiteSpace:"pre"},children:e.text},t);case"blockquote":return i.jsx("div",{style:{borderLeft:"2px solid var(--proto-line-3)",padding:"2px 0 2px 9px",margin:"7px 0 0",fontSize:11.5,lineHeight:1.65,color:"var(--proto-muted)"},children:qc(e.inline)},t);case"hr":return i.jsx("div",{style:{height:1,background:"var(--proto-line-2)",margin:"12px 0"}},t);default:return null}}function l_({content:e,resolveImage:t}){const n=O(),{frontmatter:r,body:o}=Age(e),s=iB(o);return i.jsx(a_.Provider,{value:t??null,children:i.jsxs("div",{children:[r&&(r.entries.length>0||r.summary)&&i.jsxs("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,padding:"10px 13px"},children:[i.jsx("div",{style:{display:"flex",alignItems:"center",gap:13,font:`400 10px ${Lv}`,color:"var(--proto-muted)",flexWrap:"wrap"},children:r.entries.map((a,l)=>i.jsxs("span",{children:[i.jsx("span",{style:{color:"var(--proto-muted-3)"},children:a.key})," ",a.value]},l))}),r.summary&&i.jsxs("div",{style:{fontSize:11,color:"var(--proto-ink-2)",marginTop:6},children:[i.jsx("span",{style:{font:`400 10px ${Lv}`,color:"var(--proto-muted-3)"},children:n.memSummary}),"  ",r.summary]})]}),s.map((a,l)=>u5e(a,l))]})})}const Xp="'IBM Plex Mono',monospace";function p5e({status:e}){const t=O(),n=e==="active"?t.wbCommissionActive:e==="done"?t.wbCommissionDone:t.wbCommissionAbandoned,r=e==="active"?"var(--proto-accent)":"var(--proto-muted-2)",o=e==="active"?"var(--proto-accent-bg)":"var(--proto-gray)";return i.jsx("span",{style:{font:`500 9.5px ${Xp}`,color:r,background:o,borderRadius:5,padding:"2px 6px",flex:"none"},children:n})}function PT({active:e,label:t,onClick:n}){return i.jsx("button",{type:"button",onClick:n,style:{border:0,borderRadius:6,padding:"3px 9px",cursor:"pointer",fontSize:11.5,fontWeight:e?600:400,background:e?"var(--proto-card)":"transparent",color:e?"var(--proto-ink)":"var(--proto-muted-2)",boxShadow:e?"var(--shadow-raised, none)":"none"},children:t})}function Am({label:e,tone:t,disabled:n,onClick:r}){const[o,s]=f.useState(!1);return i.jsx("button",{type:"button",disabled:n,onClick:r,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{border:"1px solid var(--proto-line-2)",borderRadius:7,padding:"4px 11px",fontSize:12,cursor:n?"default":"pointer",opacity:n?.5:1,background:o&&!n?"var(--proto-gray)":"transparent",color:t==="danger"?"var(--proto-amber)":"var(--proto-ink-2)"},children:e})}function f5e(e){const t=O(),{projectId:n,slug:r}=e.commission,o=f.useCallback(v=>{if(/^[a-z]+:\/\//i.test(v)||v.startsWith("data:"))return Promise.resolve(v);const S=v.replace(/^\.\//,""),b=S.startsWith("commissions/")?S:`commissions/${r}/${S}`;return Sve(n,b)},[n,r]),[s,a]=f.useState("ledger"),[l,c]=f.useState(null),[d,u]=f.useState(""),{commission:p}=e,h=p.status==="active",m=s==="ledger"?e.ledger:e.contract,x=s==="ledger"?t.wbCommissionNoLedger:t.wbCommissionMissing;return i.jsxs(ur,{chrome:"bare",size:"custom",open:!0,showClose:!1,title:p.title,description:p.slug,onOpenChange:v=>{v||e.onDismiss()},contentDataAttributes:{"data-modal":"commission-board"},overlayDataAttributes:{"data-backdrop":"commission-board"},bodyStyle:{display:"contents"},contentStyle:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:1120,maxWidth:"94vw",height:700,maxHeight:"90vh",background:"var(--proto-card)",borderRadius:14,boxShadow:"var(--shadow-overlay-strong)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"15px 18px 12px",borderBottom:"1px solid var(--proto-line)",flex:"none"},children:[i.jsxs("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:1.6,strokeLinejoin:"round",strokeLinecap:"round",style:{flex:"none"},children:[i.jsx("path",{d:"M3.7 1.9v10.2"}),i.jsx("path",{d:"M3.7 2.7h6.8L9.1 5l1.4 2.3H3.7z"})]}),i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:14,fontWeight:650,color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.title}),i.jsx("div",{style:{font:`400 10px ${Xp}`,color:"var(--proto-muted-3)",marginTop:2},children:p.slug})]}),i.jsx(p5e,{status:p.status}),h&&i.jsxs(i.Fragment,{children:[i.jsx(Am,{label:t.wbCommissionComplete,tone:"neutral",disabled:e.pending,onClick:()=>{c("done"),u("")}}),i.jsx(Am,{label:t.wbCommissionAbandon,tone:"danger",disabled:e.pending,onClick:()=>{c("abandoned"),u("")}})]})]}),l&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"10px 18px",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-rail)",flex:"none"},children:[i.jsx("span",{style:{fontSize:12.5,color:"var(--proto-ink-2)",flex:"none"},children:l==="done"?t.wbCommissionCompleteTitle:t.wbCommissionAbandonTitle}),i.jsx("input",{value:d,onChange:v=>u(v.target.value),placeholder:t.wbCommissionCloseNote,style:{flex:1,minWidth:0,height:26,padding:"0 8px",borderRadius:6,border:"1px solid var(--proto-line-2)",background:"var(--proto-card)",color:"var(--proto-ink)",fontSize:12}}),i.jsx(Am,{label:l==="done"?t.wbCommissionComplete:t.wbCommissionAbandon,tone:l==="done"?"neutral":"danger",disabled:e.pending,onClick:()=>e.onClose(l,d.trim())}),i.jsx(Am,{label:t.cancel,tone:"neutral",onClick:()=>c(null)})]}),i.jsxs("div",{style:{flex:1,minHeight:0,display:"flex"},children:[i.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",borderRight:"1px solid var(--proto-line)"},children:[i.jsx("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"9px 16px",flex:"none",borderBottom:"1px solid var(--proto-line)"},children:i.jsxs("div",{style:{display:"flex",gap:2,background:"var(--proto-gray)",borderRadius:7,padding:2},children:[i.jsx(PT,{active:s==="ledger",label:t.wbCommissionLedger,onClick:()=>a("ledger")}),i.jsx(PT,{active:s==="contract",label:t.wbCommissionContract,onClick:()=>a("contract")})]})}),i.jsx("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:"14px 18px 24px"},children:m?i.jsx(l_,{content:m,resolveImage:o}):i.jsx("div",{style:{color:"var(--proto-faint)",fontSize:12.5,padding:"18px 0"},children:x})})]}),i.jsxs("div",{style:{width:380,flex:"none",display:"flex",flexDirection:"column",minHeight:0},children:[i.jsxs("div",{style:{padding:"11px 16px 8px",flex:"none",borderBottom:"1px solid var(--proto-line)"},children:[i.jsx("div",{style:{font:`600 10px ${Xp}`,color:"var(--proto-muted-2)",letterSpacing:.4},children:t.wbCommissionGates}),e.gates.length===0?i.jsx("div",{style:{color:"var(--proto-faint)",fontSize:12,marginTop:6},children:t.wbCommissionNoGates}):i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3,marginTop:6},children:e.gates.map(v=>i.jsxs("div",{onClick:()=>e.onOpenSession(v),style:{display:"flex",alignItems:"center",gap:7,cursor:"pointer",padding:"5px 7px",borderRadius:6,fontSize:12.5,background:"var(--proto-amber-bg, var(--proto-gray))",color:"var(--proto-ink)"},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-amber)",flex:"none"}}),i.jsx("span",{style:{flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.label??v.name??v.sessionId})]},v.sessionId))})]}),i.jsxs("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:"11px 16px 20px"},children:[i.jsx("div",{style:{font:`600 10px ${Xp}`,color:"var(--proto-muted-2)",letterSpacing:.4},children:t.wbCommissionDecisions}),e.decisions.length===0?i.jsx("div",{style:{color:"var(--proto-faint)",fontSize:12,marginTop:6},children:t.wbCommissionNoDecisions}):i.jsx("div",{style:{display:"flex",flexDirection:"column"},children:e.decisions.map((v,S)=>i.jsxs("div",{children:[i.jsx("div",{style:{font:`400 9.5px ${Xp}`,color:"var(--proto-muted-3)",marginTop:10},children:e.sessionLabel(v.sessionId)}),i.jsx(qB,{decisions:[v.item]})]},`${v.ts}:${v.item.id}:${S}`))})]})]})]}),p.closeNote&&i.jsxs("div",{style:{flex:"none",padding:"8px 18px",borderTop:"1px solid var(--proto-line)",fontSize:12,color:"var(--proto-muted)"},children:[i.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[t.wbCommissionClosedNote,": "]}),p.closeNote]})]})}function h5e(e,t){return t.type==="open"?t.commissionId:null}const c_=f.createContext(null);function ET(e,t,n){const r=he(),o=!!e&&!!t;return ae({...r.memory.file.queryOptions({projectId:e,path:`commissions/${t}/${n}`}),enabled:o,retry:!1})}function m5e({commissionId:e,onClose:t}){var b,g;const n=he(),r=Ve(),o=Xe(),{setCurrentProject:s}=zt(),{setSelectedSession:a}=Vi(),l=ae(n.commissions.get.queryOptions({commissionId:e})),c=ae(n.commissions.decisions.queryOptions({commissionId:e})),d=wc("direct"),u=l.data??null,p=ET((u==null?void 0:u.projectId)??"",(u==null?void 0:u.slug)??"","ledger.md"),h=ET((u==null?void 0:u.projectId)??"",(u==null?void 0:u.slug)??"","contract.md"),m=Re(n.commissions.close.mutationOptions({onSettled:()=>{r.invalidateQueries(n.commissions.list.queryFilter()),r.invalidateQueries(n.commissions.get.queryFilter())}})),x=f.useMemo(()=>(d.data??[]).filter(w=>w.commissionId===e&&!!w.awaitingInput),[d.data,e]),v=w=>{const k=(d.data??[]).find(C=>C.sessionId===w);return(k==null?void 0:k.label)??(k==null?void 0:k.name)??w};if(!u)return null;const S=w=>{s(w.projectId),a(w.sessionId),o("/workbench"),t()};return i.jsx(f5e,{commission:u,ledger:((b=p.data)==null?void 0:b.content)??null,contract:((g=h.data)==null?void 0:g.content)??null,decisions:c.data??[],gates:x,sessionLabel:v,pending:m.isPending,onOpenSession:S,onClose:(w,k)=>{m.mutate({commissionId:e,status:w,note:k||void 0})},onDismiss:t})}function g5e({children:e}){const[t,n]=f.useReducer(h5e,null),r=f.useCallback(a=>n({type:"open",commissionId:a}),[]),o=f.useCallback(()=>n({type:"close"}),[]),s=f.useMemo(()=>({openCommission:r,closeCommission:o}),[r,o]);return i.jsxs(c_.Provider,{value:s,children:[e,t&&i.jsx(m5e,{commissionId:t,onClose:o})]})}function d_(){const e=f.useContext(c_);if(!e)throw new Error("useCommissionBoard must be used within a CommissionBoardModalProvider");return e}const FS={en:{title:"Notes",inputPlaceholder:"Note something to do…",quickPlaceholder:"Quick note…",todo:"TO DO",completed:"Completed",clear:"Clear",handoff:"Hand to agent",edit:"Edit",save:"Save",cancel:"Cancel",delete:"Delete",viewAll:"View all",empty:"No open notes",privateHint:"Private reminder · agents do not read this file",enter:"↵",escape:"esc"},zh:{title:"笔记",inputPlaceholder:"记一条要干什么…",quickPlaceholder:"快速记一条…",todo:"待办",completed:"已完成",clear:"清除",handoff:"交给 agent",edit:"编辑",save:"保存",cancel:"取消",delete:"删除",viewAll:"查看全部",empty:"没有未完成笔记",privateHint:"私人备忘 · agent 不读取此文件",enter:"↵",escape:"esc"}};function v5e(e,t){return e===1?t==="zh"?"昨天":"yesterday":t==="zh"?`${Math.max(2,e)} 天前`:`${Math.max(2,e)}d`}function x5e(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function y5e(e){const t=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0");return`${t}:${n}`}function b5e(e,t,n){const r=Date.parse(e);if(Number.isNaN(r))return"—";const o=new Date(r);if(x5e(o,new Date(t)))return y5e(o);const s=Math.max(1,Math.floor((t-r)/864e5));return v5e(s,n)}function w5e(e,t,n){return{...e,timeLabel:b5e(e.createdAt,t,n)}}function u_(e,t,n){const r=e.map(a=>w5e(a,t,n)),o=r.filter(a=>!a.completed),s=r.filter(a=>a.completed);return{active:o,completed:s,previews:o.slice(0,3),activeCount:o.length,completedCount:s.length}}function S5e(e){return(e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="n"}function k5e(e){if(!e)return null;if(e instanceof Error)return e;const t=typeof e=="object"&&"message"in e?String(e.message):String(e);return new Error(t)}function zS(e){const t=he(),n=Ve(),r=f.useRef(e);r.current=e;const o=h=>n.invalidateQueries(t.notes.list.queryFilter({projectId:h})),s=(h,m,x)=>o(x.projectId),a=ae({...t.notes.list.queryOptions({projectId:e}),enabled:!!e}),l=Re(t.notes.add.mutationOptions({onSettled:s})),c=Re(t.notes.update.mutationOptions({onSettled:s})),d=Re(t.notes.setCompleted.mutationOptions({onSettled:s})),u=Re(t.notes.delete.mutationOptions({onSettled:s})),p=Re(t.notes.clearCompleted.mutationOptions({onSettled:s}));return{notes:a.data??[],loading:a.isLoading,busy:l.isPending||c.isPending||d.isPending||u.isPending||p.isPending,error:k5e(a.error??l.error??c.error??d.error??u.error??p.error),add:h=>l.mutateAsync({projectId:r.current,text:h}),update:(h,m)=>c.mutateAsync({projectId:r.current,id:h,text:m}),setCompleted:(h,m)=>d.mutateAsync({projectId:r.current,id:h,completed:m}),delete:async h=>{await u.mutateAsync({projectId:r.current,id:h})},clearCompleted:async()=>{await p.mutateAsync({projectId:r.current})}}}const p_=f.createContext(null);function j5e(e){const[t,n]=f.useState(!1),[r,o]=f.useState(null),s=f.useCallback(l=>{o(l??null),n(!0)},[]),a=f.useCallback(()=>{n(!1),o(null)},[]);return f.useEffect(()=>a(),[e,a]),f.useEffect(()=>{const l=c=>{S5e(c)&&(c.preventDefault(),o(null),n(d=>!d))};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),{isOpen:t,targetId:r,open:s,close:a}}function C5e({children:e}){const t=ht(),{currentProjectId:n}=zt(),{prefillDraft:r}=Vi(),o=n??"",s=j5e(o),a=zS(o),l=f.useMemo(()=>u_(a.notes,Date.now(),t),[a.notes,t]),c=f.useMemo(()=>({copy:FS[t],vm:l,...s,busy:a.busy,add:a.add,update:a.update,setCompleted:a.setCompleted,remove:a.delete,clearCompleted:a.clearCompleted,handoff:d=>{r(d),s.close()}}),[t,l,s,a,r]);return i.jsx(p_.Provider,{value:c,children:e})}function j1(){const e=f.useContext(p_);if(!e)throw new Error("useNotes must be used within NotesProvider");return e}const T5e="cortex:left-rail-collapsed",P5e="cortex:right-panel-collapsed";function RT(e){const[t,n]=f.useState(()=>{try{return window.localStorage.getItem(e)==="true"}catch{return!1}});return f.useEffect(()=>{try{window.localStorage.setItem(e,String(t))}catch{}},[e,t]),[t,n]}const f_=f.createContext(null);function E5e({children:e}){const[t,n]=RT(T5e),[r,o]=RT(P5e),s=f.useCallback(u=>n(u),[n]),a=f.useCallback(()=>n(u=>!u),[n]),l=f.useCallback(u=>o(u),[o]),c=f.useCallback(()=>o(u=>!u),[o]),d=f.useMemo(()=>({railCollapsed:t,setRailCollapsed:s,toggleRail:a,panelCollapsed:r,setPanelCollapsed:l,togglePanel:c}),[t,s,a,r,l,c]);return i.jsx(f_.Provider,{value:d,children:e})}function C1(){const e=f.useContext(f_);if(!e)throw new Error("usePaneState must be used within a PaneStateProvider");return e}function h_(e,t){return!e||!t?!1:e.route===t.route&&e.projectId===t.projectId&&e.sessionId===t.sessionId}function R5e(e,t){return e?e.route===t.route&&e.projectId===t.projectId&&e.sessionId===null&&t.sessionId!==null:!1}function M5e(e,t){const n=e.entries[e.index];if(h_(n,t))return e;if(R5e(n,t)){const o=e.entries.slice();return o[e.index]=t,{entries:o,index:e.index}}const r=e.entries.slice(0,e.index+1);return r.push(t),{entries:r,index:r.length-1}}function MT(e){return e.index>0}function IT(e){return e.index<e.entries.length-1}const I5e=1500,m_=f.createContext(null);function A5e({children:e}){const t=Xe(),{pathname:n}=fo(),{currentProjectId:r,setCurrentProject:o}=zt(),{selectedSessionId:s,setSelectedSession:a}=Vi(),[l,c]=f.useState(()=>({entries:[{route:n,projectId:r,sessionId:s}],index:0})),d=f.useRef(null),u=f.useRef(null),p=f.useRef(l);p.current=l;const h=f.useCallback(()=>{d.current=null,u.current&&(clearTimeout(u.current),u.current=null)},[]);f.useEffect(()=>()=>h(),[h]),f.useEffect(()=>{const g={route:n,projectId:r,sessionId:s};if(d.current){h_(d.current,g)&&h();return}c(w=>M5e(w,g))},[n,r,s,h]);const m=f.useCallback(g=>{d.current=g,u.current&&clearTimeout(u.current),u.current=setTimeout(h,I5e),g.projectId&&g.projectId!==r&&o(g.projectId),g.sessionId&&g.sessionId!==s&&a(g.sessionId),g.route!==n&&t(g.route)},[r,s,n,t,o,a,h]),x=f.useCallback(g=>{const w=p.current;if(g===-1?!MT(w):!IT(w))return;const k=w.index+g;m(w.entries[k]),c({...w,index:k})},[m]),v=f.useCallback(()=>x(-1),[x]),S=f.useCallback(()=>x(1),[x]),b=f.useMemo(()=>({canBack:MT(l),canForward:IT(l),back:v,forward:S}),[l,v,S]);return i.jsx(m_.Provider,{value:b,children:e})}function D5e(){const e=f.useContext(m_);if(!e)throw new Error("useNavigationHistory must be used within a NavigationHistoryProvider");return e}const L5e="context/projects/",O5e="nimbus";function BS(e){return e.trim().length>0}function N5e(e){const t=e&&typeof e=="object"&&"message"in e?e.message:void 0;return typeof t=="string"&&t.trim().length>0?t:"Could not create project."}function g_({onCreated:e}={}){const t=he(),n=Ve(),[r,o]=f.useState(null),s=Re(t.projects.create.mutationOptions({})),a=f.useCallback(()=>o(null),[]);return{createProject:f.useCallback(async c=>{if(!BS(c)||s.isPending)return null;o(null);let d;try{d=await s.mutateAsync({name:c.trim()})}catch(u){return o(N5e(u)),null}return await n.invalidateQueries(t.projects.list.queryFilter()),await(e==null?void 0:e(d.id)),d.id},[s,e,n,t.projects.list]),clearError:a,error:r,isPending:s.isPending}}const Tb="'IBM Plex Mono',monospace";function F5e({onClose:e}){const t=O(),[n,r]=f.useState(""),[o,s]=f.useState(!1),a=f.useRef(null),{createProject:l,clearError:c,error:d,isPending:u}=g_({onCreated:e}),p=()=>{l(n)},h=BS(n);return i.jsxs(ur,{chrome:"bare",size:"custom",open:!0,showClose:!1,title:t.newProject,description:t.npHint,onOpenChange:m=>{m||e()},contentDataAttributes:{"data-modal":"newproj"},bodyStyle:{display:"contents"},contentStyle:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:540,background:"var(--proto-card)",borderRadius:14,boxShadow:"var(--shadow-overlay-strong)",zIndex:61,overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 20px 0"},children:[i.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:t.newProject}),i.jsx("span",{style:{font:`400 10px ${Tb}`,color:"var(--proto-muted-3)",marginLeft:10},children:L5e}),i.jsx("span",{onClick:e,style:{marginLeft:"auto",font:`500 9.5px ${Tb}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),i.jsxs("div",{style:{padding:"16px 20px 0"},children:[i.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginBottom:6},children:t.npProjectName}),i.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1.5px solid var(--proto-accent-border)",borderRadius:9,padding:"9px 12px"},children:i.jsx("input",{ref:a,value:n,onChange:m=>{r(m.target.value),d&&c()},onKeyDown:m=>{m.key==="Enter"&&p()},autoFocus:!0,placeholder:O5e,style:{flex:1,font:`500 13px ${Tb}`,color:"var(--proto-ink)"}})}),i.jsx("div",{style:{fontSize:10.5,color:d?"var(--proto-danger)":"var(--proto-muted-3)",marginTop:8,lineHeight:1.6},children:d??t.npHint})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"16px 20px 16px",justifyContent:"flex-end"},children:[i.jsx("span",{onClick:e,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"6px 13px",color:"var(--proto-ink)",cursor:"pointer",background:o?"var(--proto-alt)":"transparent"},children:t.cancel}),i.jsx("span",{onClick:p,style:{fontSize:11.5,fontWeight:600,borderRadius:8,padding:"7px 15px",color:"var(--ink-solid-fg)",background:h?"var(--proto-accent)":"var(--proto-accent-border)",cursor:h&&!u?"pointer":"default"},children:t.npCreate})]})]})}function v_(e){return e==="running"?"done":e==="stopped"?"failed":"cancelled"}function z5e(e){const t=e.extras?Object.entries(e.extras).map(([n,r])=>({key:n,value:r})):[];return{...e,tone:v_(e.status),extras:t}}function x_(e){return e?{processes:e.processes.map(z5e),lastRestart:e.lastRestart}:{processes:[],lastRestart:null}}const B5e=5e3;function $5e(e){return e==="pending"?"pending":e==="success"?"success":e==="error"?"error":"idle"}function AT(e){if(!e)return null;if(e instanceof Error)return e;const t=typeof e=="object"&&"message"in e?String(e.message):String(e);return new Error(t)}function y_(e={}){const t=he(),n=Ve(),r=e.enabled??!0,o=t.system.daemonStatus.queryOptions({}),s=ae({...o,enabled:r,refetchInterval:r?B5e:!1}),a=Re(t.system.restart.mutationOptions({onSuccess:async()=>{await n.invalidateQueries({queryKey:o.queryKey,exact:!0}),await n.invalidateQueries(t.threads.list.queryFilter())}}));return{daemon:s.data??null,facts:x_(s.data),loading:s.isLoading,error:AT(s.error),restart:l=>a.mutate({kind:l}),restartState:$5e(a.status),restartError:AT(a.error)}}const _5e="connect.html";async function W5e(e){var t;try{await((t=e.invoke)==null?void 0:t.call(e,"disconnect"))}catch{}finally{e.navigate(_5e)}}async function H5e(){const e=await bt("disconnect");if(!e.ok&&e.reason==="failed")throw e.error}async function b_(){dr()&&await W5e({invoke:H5e,navigate:e=>{window.location.href=e}})}const $S="0909-0516·b1a2e21";function DT(e){return e==="done"?"var(--proto-success)":e==="failed"?"var(--proto-danger)":"var(--pill-cancelled-fg)"}function U5e(e){return e==="done"?"var(--proto-success-bg)":e==="failed"?"var(--proto-danger-bg)":"var(--pill-cancelled-bg)"}function V5e({open:e,onClose:t}){const n=O(),[r,o]=f.useState(!1),s=y_({enabled:e}),{processes:a,lastRestart:l}=s.facts;f.useEffect(()=>{(s.restartState==="success"||s.restartState==="error")&&o(!1)},[s.restartState]);const c=()=>s.restart("soft"),d=()=>s.restart("hard");return e?i.jsxs(i.Fragment,{children:[i.jsx("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:40,background:"var(--overlay-scrim-medium)"}}),i.jsxs("div",{style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",zIndex:50,width:470,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:14,boxShadow:"var(--shadow-panel)",overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"16px 20px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[i.jsx("div",{"aria-label":"Cortex",style:{width:28,height:28,borderRadius:8,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsxs("svg",{width:20,height:20,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[i.jsx("circle",{cx:33,cy:32,r:6,fill:"var(--brand-badge-core)"}),i.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"}),i.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"})]})}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:n.dmDaemon}),i.jsxs("div",{style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginTop:1},children:["local · build ",$S]})]}),i.jsx("span",{onClick:t,style:{marginLeft:"auto",font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),i.jsxs("div",{style:{padding:"14px 20px",display:"flex",flexDirection:"column",gap:10},children:[s.loading&&i.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-3)",textAlign:"center",padding:20},children:"Loading…"}),s.error&&i.jsx("div",{style:{fontSize:12,color:"var(--proto-danger)",textAlign:"center",padding:20},children:"Failed to load daemon status"}),a.map(u=>{const p=u.status;return i.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:10,padding:"11px 14px"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:DT(u.tone),flex:"none"}}),i.jsx("span",{style:{font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:u.name}),i.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:u.label}),i.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:U5e(u.tone),color:DT(u.tone)},children:p})]}),i.jsxs("div",{style:{display:"flex",gap:14,marginTop:8,font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",flexWrap:"wrap"},children:[u.uptime&&i.jsxs("span",{children:[i.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[n.dmUp," "]}),u.uptime]}),u.pid!=null&&i.jsxs("span",{children:[i.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[n.dmPid," "]}),u.pid]}),u.port!=null&&i.jsxs("span",{children:[i.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[n.dmPort," "]}),":",u.port]}),u.extras.map(h=>i.jsxs("span",{children:[i.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[h.key," "]}),h.value]},h.key))]})]},u.name)}),(l==null?void 0:l.at)&&i.jsxs("div",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",padding:"0 2px"},children:[n.dmLastRestart," ",new Date(l.at).toLocaleDateString()," ",new Date(l.at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),l.reason?` · ${n.dmReason}: ${l.reason}`:""]})]}),!r&&i.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",flexDirection:"column",gap:8},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:n.dmSoftRestart}),i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:n.dmSoftRestartDesc})]}),i.jsx("span",{onClick:c,style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:s.restartState==="pending"?"default":"pointer",opacity:s.restartState==="pending"?.5:1},children:n.dmSoftRestart})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-danger)"},children:n.dmHardRestart}),i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:n.dmHardRestartDesc})]}),i.jsx("span",{onClick:()=>o(!0),style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-danger)",border:"1px solid var(--proto-danger-bg)",background:"var(--proto-danger-bg)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:n.dmHardRestart})]})]}),r&&i.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",flexDirection:"column",gap:10},children:[i.jsxs("div",{style:{border:"1px solid var(--proto-amber-border)",background:"var(--proto-amber-bg)",borderRadius:9,padding:"10px 14px"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-amber-fg)"},children:n.dmHardConfirm}),i.jsx("div",{style:{fontSize:11.5,color:"var(--proto-muted)",marginTop:4,lineHeight:1.5},children:n.dmHardConfirmDetail})]}),i.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[i.jsx("span",{onClick:()=>o(!1),style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:n.dmConfirmCancel}),i.jsx("span",{onClick:d,style:{fontSize:11.5,fontWeight:600,color:"var(--ink-solid-fg)",background:"var(--proto-danger)",borderRadius:8,padding:"6px 14px",cursor:s.restartState==="pending"?"default":"pointer",opacity:s.restartState==="pending"?.5:1},children:s.restartState==="pending"?"...":n.dmConfirmProceed})]})]}),s.restartState==="success"&&i.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 20px",fontSize:11.5,color:"var(--proto-success)",fontWeight:600},children:n.dmRestartSent}),s.restartState==="error"&&i.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 20px",fontSize:11.5,color:"var(--proto-danger)",fontWeight:600},children:n.dmRestartFailed}),dr()&&i.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",alignItems:"center",gap:10},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:n.dmDisconnect}),i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:n.dmDisconnectDesc})]}),i.jsx("span",{onClick:()=>void b_(),style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:n.dmDisconnect})]})]})]}):null}function w_(e){return globalThis[e]}function _S(){const e=w_("__CORTEX_PLATFORM__");return e==="macos"||e==="windows"||e==="linux"?e:null}function WS(){const e=w_("__CORTEX_TITLEBAR__");return e==="custom"||e==="overlay"?e:"native"}function S_(){var t,n;const e=_S();return e?e==="macos":/Mac|iPhone|iPad/i.test(((t=globalThis.navigator)==null?void 0:t.platform)??((n=globalThis.navigator)==null?void 0:n.userAgent)??"")}function k_(){return WS()==="overlay"?78:0}function HS(e){const t=e.toLowerCase().split("+");return{key:t[t.length-1]??"",mod:t.includes("mod"),shift:t.includes("shift"),alt:t.includes("alt")}}const q5e={arrowleft:"←",arrowright:"→","=":"+",",":","};function j_(e,t){const{key:n,mod:r,shift:o,alt:s}=HS(e),a=[];r&&a.push(t?"⌘":"Ctrl"),o&&a.push(t?"⇧":"Shift"),s&&a.push(t?"⌥":"Alt");const l=q5e[n]??(n.length===1?n.toUpperCase():n.replace(/^f(\d+)$/,"F$1"));return a.push(l),t?a.join(""):a.join("+")}function K5e(e,t){const{key:n,mod:r,shift:o,alt:s}=HS(t);return r!==(e.metaKey||e.ctrlKey)||o!==e.shiftKey||s!==e.altKey?!1:e.key.toLowerCase()===n}function C_(e){const t=[],n=r=>{for(const o of r)o.kind==="item"?t.push(o):o.kind==="submenu"&&n(o.items)};return n(e.flatMap(r=>r.items)),t}function T_(e){return C_(e).filter(t=>typeof t.accel=="string")}const LT={"=":"Equal","-":"Minus",",":"Comma",".":"Period","/":"Slash"};function G5e(e){return LT[e]?LT[e]:/^[a-z]$/.test(e)?`Key${e.toUpperCase()}`:/^[0-9]$/.test(e)?`Digit${e}`:(/^f\d+$/.test(e),e.toUpperCase())}function Y5e(e){const{key:t,mod:n,shift:r,alt:o}=HS(e),s=[];return n&&s.push("CmdOrCtrl"),r&&s.push("Shift"),o&&s.push("Alt"),s.push(G5e(t)),s.join("+")}function Q5e(e,t){const n={unsupported_shell:t.updateCheckUnsupported,invalid_report:t.updateCheckInvalid,no_credentials:t.updateCheckCredentials,"disabled by CORTEX_APP_UPDATE_DISABLE":t.updateCheckDisabled,"dev mode (CORTEX_FRONTEND_DIR is set)":t.updateCheckDev,dev_version:t.updateCheckDev,version_skipped:t.updateCheckSkippedVersion,no_matching_asset:t.updateCheckNoAsset,update_in_progress:t.updateCheckInProgress,restart_or_install_pending:t.updateCheckRestartPending,not_scheduled:t.updateCheckNotScheduled};return e!=null&&e.startsWith("dev version ")?t.updateCheckDev:e?n[e]:void 0}function OT(e,t,n){const o=[{available:n.updateCheckAvailable,current:n.updateCheckCurrent,skipped:n.updateCheckSkipped,error:n.updateCheckError}[t.status],Q5e(t.reason,n)];return t.update&&t.status!=="available"&&o.push(n.updateCheckCached),{title:e,description:o.filter(Boolean).join(" "),duration:12e3,tone:t.status==="error"?"failed":t.status==="skipped"?"waiting":"done"}}function X5e(e,t){return[OT(t.updateCheckUi,e.ui,t),OT(t.updateCheckShell,e.shell,t)]}function Z5e(){const e=O(),t=zx(),n=f.useSyncExternalStore(G$,q5),r=f.useRef(!1),o=f.useRef();f.useEffect(()=>(r.current=!0,()=>{r.current=!1,o.current&&(t==null||t.dismiss(o.current))}),[t]);const s=f.useCallback(async()=>{if(q5())return;o.current=t==null?void 0:t.toast({title:e.updateCheckBusy,description:e.updateCheckProgress,tone:"running",duration:1/0});const a=await E4e();r.current&&(o.current&&(t==null||t.dismiss(o.current)),o.current=void 0,X5e(a,e).forEach(l=>t==null?void 0:t.toast(l)))},[e,t]);return{busy:n,check:s}}const US={label:"main"};function Tu(e){if(!e.ok)throw new Error("native_window_action_failed");return e.value}async function K5(e){return Tu(await bt(`plugin:window|${e}`,US))}async function P_(e,t){for(let n=0;n<20;n++){if(await K5(e)===t)return;await new Promise(r=>setTimeout(r,50))}throw new Error("native_window_transition_timed_out")}async function Pb(e){Tu(await bt("plugin:window|set_fullscreen",{...US,value:e})),await P_("is_fullscreen",e)}async function Eb(e){Tu(await bt(e?"plugin:window|maximize":"plugin:window|unmaximize",US)),await P_("is_maximized",e)}function J5e(e){let t=!1,n=!1;async function r(){n=e==="windows"&&await K5("is_maximized"),n&&await Eb(!1);try{await Pb(!0)}catch(a){throw await Pb(!1).catch(()=>{}),n&&await Eb(!0).catch(()=>{}),a}}async function o(){await Pb(!1),n&&await Eb(!0),n=!1}async function s(a=!1){if(!t){t=!0;try{await K5("is_fullscreen")?await o():a||await r()}finally{t=!1}}}return{toggle:()=>s(),exit:()=>s(!0)}}const S0={label:"main"},E_="cortex:webview-zoom",Zp=[.7,.8,.9,1,1.1,1.25,1.5,1.75,2],k0=1;let ewe;function NT(){try{const e=Number(window.localStorage.getItem(E_));return Zp.includes(e)?e:k0}catch{return k0}}function FT(e,t){const n=Zp.indexOf(e),r=n===-1?Zp.indexOf(k0):n;return Zp[Math.min(Zp.length-1,Math.max(0,r+t))]}function twe(){const[e,t]=f.useState({isMaximized:!1,isFullscreen:!1}),n=f.useRef(!1),r=f.useCallback(async()=>{const[o,s]=await Promise.all([bt("plugin:window|is_maximized",S0),bt("plugin:window|is_fullscreen",S0)]);n.current&&t(a=>({isMaximized:o.ok?o.value:a.isMaximized,isFullscreen:s.ok?s.value:a.isFullscreen}))},[]);return f.useEffect(()=>(n.current=!0,r(),window.addEventListener("resize",r),window.addEventListener("focus",r),()=>{n.current=!1,window.removeEventListener("resize",r),window.removeEventListener("focus",r)}),[r]),{...e,sync:r}}function nwe(e){const[t,n]=f.useState(NT),r=f.useRef(!1),o=f.useCallback(async s=>{if(!r.current){r.current=!0;try{Tu(await bt("plugin:webview|set_webview_zoom",{...S0,value:s})),n(s);try{window.localStorage.setItem(E_,String(s))}catch{}}catch{e()}finally{r.current=!1}}},[e]);return f.useEffect(()=>{const s=NT();s!==k0&&o(s)},[o]),{zoom:t,zoomIn:()=>void o(FT(t,1)),zoomOut:()=>void o(FT(t,-1)),zoomReset:()=>void o(k0)}}function rwe(e){return e.key!=="Escape"||e.repeat||e.defaultPrevented?!1:!document.querySelector('[role="dialog"], [role="menu"], [role="alertdialog"]')}function owe(e,t,n){const r=ewe??(ewe=J5e(_S())),o=f.useCallback(async(s=!1)=>{try{await(s?r.exit():r.toggle())}catch{n()}finally{await t()}},[r,n,t]);return f.useEffect(()=>{const s=a=>{!e||!rwe(a)||(a.preventDefault(),o(!0))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,o]),()=>void o()}function R_(){const e=O(),t=zx(),n=f.useCallback(()=>{t==null||t.toast({title:e.windowActionFailed,description:e.windowActionFailedHint,tone:"failed"})},[e,t]),{sync:r,...o}=twe(),s=owe(o.isFullscreen,r,n),a=nwe(n),l=c=>{bt(`plugin:window|${c}`,S0).then(Tu).catch(n)};return{...o,...a,toggleFullscreen:s,minimize:()=>l("minimize"),toggleMaximize:()=>l("toggle_maximize"),close:()=>l("close"),startDragging:()=>l("start_dragging"),toggleDevTools:()=>{bt("plugin:webview|internal_toggle_devtools",S0).then(Tu).catch(()=>t==null?void 0:t.toast({title:e.windowDevtoolsFailed,description:e.windowDevtoolsFailedHint,tone:"failed"}))}}}const iwe="https://fangxm233.github.io/cortex-agent/";function Tp(e){try{document.execCommand(e)}catch{}}async function swe(){try{const e=await navigator.clipboard.readText();document.execCommand("insertText",!1,e)}catch{}}const mi={kind:"separator"};function M_(){const e=O(),t=Xe(),n=zx(),r=t1(),o=AS(),s=VS(),a=C1(),l=Ic(),c=nh(),d=Wx(),{currentProjectId:u}=zt(),{selectedSessionId:p,setSelectedSession:h}=Vi(),m=R_(),x=vx(),{busy:v,check:S}=Z5e();return{menus:f.useMemo(()=>{const g=p&&p!==nl?p:null,w={id:"file",label:e.menuFile,items:[{kind:"item",id:"file.newSession",label:e.mFileNewSession,accel:"mod+n",run:()=>{h(nl),t("/workbench")}},{kind:"item",id:"file.newProject",label:e.mFileNewProject,run:s.openNewProject},{kind:"item",id:"file.newSchedule",label:e.mFileNewSchedule,run:()=>o.open(u?{projectId:u}:void 0)},mi,{kind:"item",id:"file.settings",label:e.mFileSettings,accel:"mod+,",run:r.open},mi,{kind:"item",id:"file.disconnect",label:e.mFileDisconnect,disabled:!x,run:()=>void bt("disconnect")},{kind:"item",id:"file.quit",label:e.mFileQuit,accel:"mod+q",disabled:!x,run:m.close}]},k={id:"edit",label:e.menuEdit,items:[{kind:"item",id:"edit.undo",accelDisplayOnly:!0,role:"undo",label:e.mEditUndo,accel:"mod+z",run:()=>Tp("undo")},{kind:"item",id:"edit.redo",accelDisplayOnly:!0,role:"redo",label:e.mEditRedo,accel:"mod+shift+z",run:()=>Tp("redo")},mi,{kind:"item",id:"edit.cut",accelDisplayOnly:!0,role:"cut",label:e.mEditCut,accel:"mod+x",run:()=>Tp("cut")},{kind:"item",id:"edit.copy",accelDisplayOnly:!0,role:"copy",label:e.mEditCopy,accel:"mod+c",run:()=>Tp("copy")},{kind:"item",id:"edit.paste",accelDisplayOnly:!0,role:"paste",label:e.mEditPaste,accel:"mod+v",run:()=>void swe()},{kind:"item",id:"edit.selectAll",accelDisplayOnly:!0,role:"selectAll",label:e.mEditSelectAll,accel:"mod+a",run:()=>Tp("selectAll")},mi,{kind:"item",id:"edit.palette",accelDisplayOnly:!0,label:e.mEditPalette,accel:"mod+k",run:()=>window.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,ctrlKey:!0,bubbles:!0}))},{kind:"item",id:"edit.copySessionId",label:e.mEditCopySessionId,disabled:!g,run:()=>{var P;g&&((P=navigator.clipboard)==null||P.writeText(g).catch(()=>{}),n==null||n.toast({title:e.mEditCopySessionId,tone:"done"}))}}]},C={id:"view",label:e.menuView,items:[{kind:"item",id:"view.leftRail",label:e.mViewLeftRail,accel:"mod+b",checked:!a.railCollapsed,run:a.toggleRail},{kind:"item",id:"view.rightPanel",label:e.mViewRightPanel,accel:"mod+alt+b",checked:!a.panelCollapsed,run:a.togglePanel},{kind:"item",id:"view.dock",label:e.mViewDock,accel:"mod+j",checked:l.open,disabled:!l.canDock,run:l.toggleDock},mi,{kind:"item",id:"view.workbench",label:e.mViewWorkbench,run:()=>t("/workbench")},{kind:"item",id:"view.overview",label:e.mViewOverview,run:()=>t("/overview")},{kind:"item",id:"view.memory",label:e.mViewMemory,run:()=>t("/memory")},mi,{kind:"submenu",id:"view.appearance",label:e.mViewAppearance,items:[{kind:"item",id:"view.theme.light",label:e.mViewThemeLight,checked:c==="light",run:()=>d("light")},{kind:"item",id:"view.theme.dark",label:e.mViewThemeDark,checked:c==="dark",run:()=>d("dark")},{kind:"item",id:"view.theme.system",label:e.mViewThemeSystem,checked:c==="system",run:()=>d("system")}]},mi,{kind:"item",id:"view.zoomIn",label:e.mViewZoomIn,accel:"mod+=",disabled:!x,run:m.zoomIn},{kind:"item",id:"view.zoomOut",label:e.mViewZoomOut,accel:"mod+-",disabled:!x,run:m.zoomOut},{kind:"item",id:"view.zoomReset",label:e.mViewZoomReset,accel:"mod+0",disabled:!x,run:m.zoomReset},mi,{kind:"item",id:"view.fullscreen",role:"fullscreen",label:m.isFullscreen?e.windowExitFullscreen:e.mViewFullScreen,checked:m.isFullscreen,accel:"f11",disabled:!x,run:m.toggleFullscreen}]},T={id:"help",label:e.menuHelp,items:[{kind:"item",id:"help.docs",label:e.mHelpDocs,run:()=>void rh(iwe).catch(()=>{})},mi,{kind:"item",id:"help.daemon",label:e.mHelpDaemon,run:s.openDaemonStatus},{kind:"item",id:"help.updates",label:v?e.updateCheckBusy:e.mHelpUpdates,disabled:!x||v,run:()=>void S()},{kind:"item",id:"help.devtools",label:e.mHelpDevTools,disabled:!x,run:m.toggleDevTools},mi,{kind:"item",id:"help.about",label:e.mHelpAbout,run:s.openAbout}]};return[w,k,C,T]},[e,t,n,r,o,s,a,l,c,d,u,p,h,m,x,v,S]),windowActions:m}}const zT="'IBM Plex Mono',monospace";function awe({onClose:e}){const t=O(),{menus:n}=M_(),r=S_(),o=n.map(s=>({label:s.label,items:T_([s])})).filter(s=>s.items.length>0);return i.jsx(ur,{open:!0,title:t.shortcutsTitle,description:t.shortcutsHint,size:"custom",onOpenChange:s=>{s||e()},contentStyle:{width:480},children:i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:o.map(s=>i.jsxs("div",{children:[i.jsx("div",{style:{font:`600 10px ${zT}`,letterSpacing:".08em",textTransform:"uppercase",color:"var(--proto-muted-3)",marginBottom:6},children:s.label}),s.items.map(a=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 0",fontSize:12.5,color:"var(--proto-ink)"},children:[i.jsx("span",{children:a.label}),i.jsx("span",{style:{marginLeft:"auto",font:`500 11px ${zT}`,color:"var(--proto-muted-2)"},children:j_(a.accel,r)})]},a.id))]},s.label))})})}const lwe="https://fangxm233.github.io/cortex-agent/",cwe="https://github.com/fangxm233/cortex-agent";function dwe(){const[e,t]=f.useState(null);return f.useEffect(()=>{let n=!0;return bt("plugin:app|version").then(r=>{n&&t(r)}),()=>{n=!1}},[]),e}function uwe(){const e=O();return i.jsxs("header",{className:"about-brand",children:[i.jsx("img",{src:"/apple-touch-icon.png",alt:"",width:72,height:72}),i.jsx("h2",{children:"Cortex"}),i.jsx("p",{children:e.aboutDescription})]})}function pwe(){const e=O(),t=dwe(),n={unavailable:e.aboutShellBrowser,failed:e.aboutShellFailed},r=t!=null&&t.ok?t.value:t?n[t.reason]:e.aboutShellLoading;return i.jsxs("dl",{className:"about-versions",children:[i.jsxs("div",{className:"about-version-row",children:[i.jsx("dt",{children:e.aboutFrontend}),i.jsx("dd",{className:"about-version-value",children:$S})]}),i.jsxs("div",{className:"about-version-row",children:[i.jsx("dt",{children:e.aboutShell}),i.jsx("dd",{className:t!=null&&t.ok?"about-version-value":"about-version-status",children:i.jsx("span",{role:"status","aria-busy":!t,children:r})})]})]})}function fwe(){return i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M4 12 12 4M4 4h8v8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function hwe(){const e=O(),[t,n]=f.useState(!1),r=[[lwe,e.aboutDocs],[cwe,e.aboutProject]];return i.jsxs("footer",{className:"about-footer",children:[i.jsx("div",{className:"about-links",children:r.map(([o,s])=>i.jsxs("a",{href:o,onClick:a=>{a.preventDefault(),n(!1),rh(o).catch(()=>n(!0))},children:[s,i.jsx(fwe,{})]},o))}),t&&i.jsx("p",{className:"about-link-error",role:"alert",children:e.aboutLinkError})]})}function mwe({onClose:e}){const t=O();return i.jsxs(ur,{open:!0,chrome:"bare",title:t.aboutTitle,description:t.aboutDescription,showClose:!1,contentDataAttributes:{"data-about-dialog":!0},onOpenChange:n=>{n||e()},children:[i.jsx(aL,{className:"about-close","aria-label":t.winClose,children:i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"m4 4 8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),i.jsx(uwe,{}),i.jsx(pwe,{}),i.jsx(hwe,{})]})}const I_=f.createContext(null);function gwe({children:e}){const[t,n]=f.useState(!1),[r,o]=f.useState(!1),[s,a]=f.useState(!1),[l,c]=f.useState(!1),[d,u]=f.useState(!1),p=f.useMemo(()=>({openNewProject:()=>n(!0),openDaemonStatus:()=>o(!0),openShortcuts:()=>a(!0),openAbout:()=>c(!0),sessionIdOpen:d,openSessionId:()=>u(!0),closeSessionId:()=>u(!1)}),[d]);return i.jsxs(I_.Provider,{value:p,children:[e,t&&i.jsx(F5e,{onClose:()=>n(!1)}),i.jsx(V5e,{open:r,onClose:()=>o(!1)}),s&&i.jsx(awe,{onClose:()=>a(!1)}),l&&i.jsx(mwe,{onClose:()=>c(!1)})]})}function VS(){const e=f.useContext(I_);if(!e)throw new Error("useShellModals must be used within a ShellModalsProvider");return e}function vwe(){const{open:e,setOpen:t}=cbe();return i.jsx(o$,{children:i.jsx(t_,{children:i.jsx(T$,{children:i.jsx(T2e,{children:i.jsx(A5e,{children:i.jsx(E5e,{children:i.jsx(gwe,{children:i.jsx(C5e,{children:i.jsx(Rbe,{children:i.jsx(s2e,{children:i.jsx(g2e,{children:i.jsx(Kfe,{children:i.jsx(N2e,{children:i.jsx(zye,{children:i.jsx(a5e,{children:i.jsx(g5e,{children:i.jsx(Zve,{children:i.jsx(SB,{children:i.jsxs(IB,{children:[i.jsx(Pse,{}),i.jsx(lbe,{open:e,onOpenChange:t}),i.jsx(a4e,{}),i.jsx(F4e,{})]})})})})})})})})})})})})})})})})})})})}function xwe({title:e}){const t=O();return i.jsxs("section",{className:"flex h-full flex-col p-2g",children:[i.jsx("h1",{className:"mb-2g text-body font-medium text-state-ink",children:e}),i.jsx(fg,{title:t.shNothingHere,className:"flex-1"})]})}function A_(){return vx()&&hS("invoke")}function ywe(e,t){if(e.ok)return e.value;throw e.reason==="failed"?e.error:t}async function bwe(e){const t=await bt("forward_start",{port:e});return ywe(t,new Error("Port forwarding needs the desktop app."))}async function wwe(){var n;const e=await fetch(`${Pc()}/api/forward/ports`,{headers:Oi()});if(!e.ok)throw new Error(`Could not list server ports (${e.status})`);return((n=(await e.json()).data)==null?void 0:n.ports)??[]}async function qS(e,t){const n=await fetch(`${Pc()}${e}`,{...t,headers:{...Oi(),...t!=null&&t.body?{"Content-Type":"application/json"}:{}}}),r=await n.json().catch(()=>({}));if(!n.ok||!r.ok)throw new Error(r.error??`Request failed (${n.status})`);return r.data}async function KS(){return(await qS("/api/forward/devices")).devices??[]}async function Swe(e){return(await qS(`/api/forward/device-ports?device=${encodeURIComponent(e)}`)).ports??[]}async function kwe(e,t){return qS("/api/forward/device-port",{method:"POST",body:JSON.stringify({device:e,port:t})})}const jwe="__cortexBrowserTitle:v1",Cwe=160;function Twe(e,t){if(typeof e!="object"||e===null)return null;const n=e;if(n.type!==jwe||typeof n.title!="string"||typeof n.href!="string"||typeof n.timeOrigin!="number"||!Number.isFinite(n.timeOrigin)||n.timeOrigin<0||!["load","restore","update"].includes(String(n.phase)))return null;let r;try{r=new URL(n.href)}catch{return null}if(!["http:","https:"].includes(r.protocol)||r.origin!==t)return null;const o=n.title.replace(/\s+/g," ").trim().slice(0,Cwe);return{title:o===""?null:o,href:r.toString(),timeOrigin:n.timeOrigin,phase:n.phase}}function Pwe(e,t,n,r){const o=[...e].find(([,a])=>a.contentWindow===t);if(!o)return null;const s=Twe(n,r);return s?{tabId:o[0],title:s.title,timeOrigin:s.timeOrigin,phase:s.phase}:null}const di="'IBM Plex Mono',monospace",Ewe="Enter a port or a URL. Remote dev servers appear here once forwarded.",BT="Not a previewable address — use http(s), a host:port, or a bare port.",$T="Refused: that is this app’s own origin. Previewing it would hand the page your session.",Rwe={open:!1,ports:null,error:null,device:"",devices:[]};function Mwe({tab:e,active:t,onUpdate:n}){const[r,o]=f.useState(Rwe),s=f.useRef(null),a=f.useRef(null),l=f.useRef(1),c=f.useRef(0),d=el(e.history),u=f.useMemo(()=>[typeof window>"u"?"":window.location.origin,Pc()],[]),p=k=>{const C=K9(k);if(C===null)return n(T=>_T(T,BT));if(G9(C,u))return n(T=>_T(T,$T));c.current=0,n(T=>Iwe(T,C))};f.useEffect(()=>{if(typeof window>"u")return;const k=C=>{const T=a.current;if(!T)return;const P=Pwe(new Map([[e.id,T]]),C.source,C.data,C.origin);P&&n(R=>zve(R,P.title,P.timeOrigin,P.phase))};return window.addEventListener("message",k),()=>window.removeEventListener("message",k)},[e.id,n]),f.useEffect(()=>{var k;t&&d===null&&((k=s.current)==null||k.focus())},[t,d]);const h=k=>{c.current=0,n(C=>{const T=k==="back"?Dve(C.history):Lve(C.history);return Ov(C,{history:T,draft:el(T)??""})})},m=()=>{c.current=0,n(k=>Ov(k,{reloadNonce:k.reloadNonce+1}))},x=()=>{var T;let k=!1;try{k=!!((T=a.current)!=null&&T.contentDocument)}catch{k=!1}const C=Mve({documentReachable:k});n(P=>({...P,refused:C}))},v=k=>{o(T=>({...T,ports:null,error:null})),(k===""?wwe():Swe(k)).then(T=>o(P=>P.device===k?{...P,ports:T}:P)).catch(T=>o(P=>P.device===k?{...P,error:T.message}:P))},S=k=>{o(C=>({...C,device:k})),v(k)},b=()=>{if(r.open)return o(k=>({...k,open:!1}));o(k=>({...k,open:!0})),KS().then(k=>{const C=r.device===""||k.some(T=>T.device===r.device)?r.device:"";o(T=>({...T,devices:k,device:C})),v(C)}).catch(()=>{o(k=>({...k,devices:[],device:""})),v("")})},g=async k=>{const C=r.device,T=l.current++;c.current=T,o(P=>({...P,open:!1})),n(P=>({...P,pageTitle:null,forward:{status:"connecting",operationId:T,device:C,originalPort:k},rejected:null}));try{const P=C===""?k:(await kwe(C,k)).localPort;if(c.current!==T)return;const R=A_()?(await bwe(P)).url:`http://127.0.0.1:${P}/`;if(c.current!==T)return;const D=K9(R);if(!D)throw new Error(BT);if(G9(D,u))throw new Error($T);c.current=0,n(I=>Awe(I,T,C,k,D))}catch(P){if(c.current!==T)return;c.current=0,n(R=>Dwe(R,T,P.message))}},w=N5.find(k=>k.id===e.viewportId)??N5[0];return i.jsxs("div",{"data-browser-workspace":e.id,style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[i.jsx(Lwe,{tab:e,url:d,inputRef:s,portsOpen:r.open,onStep:h,onReload:m,onDraft:k=>n(C=>({...C,draft:k})),onNavigate:()=>p(e.draft),onResetDraft:()=>n(k=>({...k,draft:d??""})),onViewport:k=>n(C=>({...C,viewportId:k})),onTogglePorts:b}),r.open&&i.jsx(Owe,{state:r,onDevice:S,onPort:g}),i.jsx(Nwe,{tab:e,url:d}),i.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:"var(--proto-gray)",display:"flex",justifyContent:"center"},children:d===null?i.jsx("div",{style:qwe,children:Ewe}):i.jsx("iframe",{ref:k=>{a.current=k},"data-browser-frame":e.id,onLoad:x,src:d,title:lB(d),sandbox:Rve,style:{border:"none",width:w.width??"100%",flex:w.width?"none":1,minHeight:"100%",background:"var(--proto-card)"}},`${e.documentGeneration}:${e.reloadNonce}`)})]})}function Ov(e,t,n=(r=>(r=e.forward)==null?void 0:r.status)()==="ready"?e.forward:null){return{...e,...t,documentGeneration:e.documentGeneration+1,pageTitle:null,titleTimeOrigin:0,forward:n,refused:!1}}function Iwe(e,t){var o;const n=cB(e.history,t),r={history:n,draft:t,rejected:null};if(n===e.history){const s=((o=e.forward)==null?void 0:o.status)==="ready"?e.forward:null;return{...e,...r,forward:s}}return Ov(e,r)}function _T(e,t){return{...e,rejected:t}}function Awe(e,t,n,r,o){var l;if(((l=e.forward)==null?void 0:l.status)!=="connecting"||e.forward.operationId!==t)return e;const s=cB(e.history,o);return Ov(e,{history:s,draft:o,rejected:null},{status:"ready",device:n,originalPort:r,targetUrl:o})}function Dwe(e,t,n){var r;return((r=e.forward)==null?void 0:r.status)!=="connecting"||e.forward.operationId!==t?e:{...e,forward:null,rejected:n}}function Lwe({tab:e,url:t,inputRef:n,portsOpen:r,onStep:o,onReload:s,onDraft:a,onNavigate:l,onResetDraft:c,onViewport:d,onTogglePorts:u}){const p=mS(e);return i.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:6,padding:"6px 8px",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-card)"},children:[i.jsx(Lm,{title:"Back",disabled:!dB(e.history),onClick:()=>o("back"),children:"‹"}),i.jsx(Lm,{title:"Forward",disabled:!uB(e.history),onClick:()=>o("forward"),children:"›"}),i.jsx(Lm,{title:"Reload",disabled:t===null,onClick:s,children:"⟳"}),i.jsxs("div",{style:zwe,children:[p&&i.jsxs("span",{"data-forward-origin":p,title:`Forwarded from ${p}`,style:Bwe,children:[p,i.jsx("span",{style:{opacity:.65},children:"→"})]}),i.jsx("input",{ref:n,value:e.draft,spellCheck:!1,placeholder:"Port or http://host:port",onChange:h=>a(h.target.value),onKeyDown:h=>{h.key==="Enter"&&l(),h.key==="Escape"&&c()},style:{flex:1,minWidth:0,height:"100%",padding:0,border:"none",background:"transparent",color:"var(--proto-ink)",font:`500 11px ${di}`,outline:"none"}})]}),i.jsx("select",{title:"Viewport width",value:e.viewportId,onChange:h=>d(h.target.value),style:_we,children:N5.map(h=>i.jsx("option",{value:h.id,children:h.label},h.id))}),i.jsx("button",{type:"button",title:"Ports listening on the server or a connected device",onClick:u,style:{...Wwe,border:r?"1.5px solid var(--proto-accent)":"1px solid var(--proto-line)",background:r?"var(--proto-accent-bg)":"var(--proto-card)",color:r?"var(--proto-accent)":"var(--proto-muted)"},children:"Ports"}),i.jsx(Lm,{title:"Open in system browser",disabled:t===null,onClick:()=>{t&&rh(t)},children:"↗"})]})}function Owe({state:e,onDevice:t,onPort:n}){return i.jsxs("div",{style:{flex:"none",maxHeight:190,overflow:"auto",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-card)"},children:[e.devices.length>0&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--proto-line)"},children:[i.jsx(WT,{active:e.device==="",onClick:()=>t(""),children:"server"}),e.devices.map(r=>i.jsx(WT,{active:e.device===r.device,onClick:()=>t(r.device),children:r.device},r.device))]}),e.error?i.jsx(Dm,{children:e.error}):e.ports===null?i.jsx(Dm,{children:"Loading…"}):e.ports.length===0?i.jsxs(Dm,{children:["Nothing is listening on ",e.device===""?"the server’s":`${e.device}’s`," loopback."]}):e.ports.map(r=>i.jsx(Fwe,{port:r,onClick:()=>void n(r.port)},`${e.device}:${r.port}`)),!A_()&&i.jsx(Dm,{children:"Forwarding needs the desktop app — these open as plain localhost here."})]})}function Nwe({tab:e,url:t}){return e.refused&&t?i.jsxs("div",{style:HT,children:[i.jsx("span",{children:Ive}),i.jsx("button",{type:"button","data-action":"open-external",onClick:()=>void rh(t),style:Vwe,children:"↗"})]}):e.rejected?i.jsx("div",{style:{...HT,color:"var(--proto-danger)"},children:e.rejected}):null}function Fwe({port:e,onClick:t}){return i.jsxs("button",{type:"button",onClick:t,style:Uwe,children:[i.jsx("span",{style:{flex:"none",width:54,color:"var(--proto-accent)"},children:e.port}),i.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--proto-muted)"},children:e.process??""}),i.jsx("span",{style:{flex:"none",color:"var(--proto-muted-2)"},children:e.address})]})}function WT({children:e,active:t,onClick:n}){return i.jsx("button",{type:"button",onClick:n,style:{...Hwe,border:t?"1.5px solid var(--proto-accent)":"1px solid var(--proto-line)",background:t?"var(--proto-accent-bg)":"var(--proto-card)",color:t?"var(--proto-accent)":"var(--proto-muted)"},children:e})}function Dm({children:e}){return i.jsx("div",{style:{padding:"10px 12px",color:"var(--proto-muted-2)",font:`500 10.5px ${di}`},children:e})}function Lm({children:e,title:t,disabled:n,onClick:r}){return i.jsx("button",{type:"button",title:t,disabled:n,onClick:r,style:{...$we,opacity:n?.4:1,cursor:n?"default":"pointer"},children:e})}const zwe={flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,height:26,padding:"0 8px",borderRadius:7,border:"1px solid var(--proto-line)",background:"var(--proto-gray)"},Bwe={display:"inline-flex",alignItems:"center",gap:4,flex:"none",maxWidth:"45%",height:16,padding:"0 6px",borderRadius:5,background:"var(--proto-accent-bg)",color:"var(--proto-accent)",font:`600 9px ${di}`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},$we={width:26,height:26,flex:"none",borderRadius:7,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",font:`500 13px ${di}`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0},_we={height:26,borderRadius:7,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",font:`500 10.5px ${di}`,cursor:"pointer"},Wwe={height:26,flex:"none",padding:"0 8px",borderRadius:7,font:`600 10.5px ${di}`,cursor:"pointer"},Hwe={height:22,padding:"0 8px",borderRadius:6,font:`600 10px ${di}`,cursor:"pointer"},Uwe={display:"flex",width:"100%",alignItems:"center",gap:10,padding:"6px 12px",border:"none",borderBottom:"1px solid var(--proto-line)",background:"transparent",color:"var(--proto-ink)",font:`500 11px ${di}`,cursor:"pointer",textAlign:"left"},HT={flex:"none",display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-gray)",color:"var(--proto-muted-2)",font:`500 10.5px ${di}`},Vwe={border:"1px solid var(--proto-line)",borderRadius:6,background:"transparent",color:"var(--proto-accent)",font:`600 10.5px ${di}`,padding:"1px 7px",cursor:"pointer"},qwe={margin:"auto",padding:"32px 24px",textAlign:"center",color:"var(--proto-muted-2)",font:`500 11.5px ${di}`,maxWidth:320},D_="'IBM Plex Mono',monospace";function Kwe({path:e,onDownload:t,children:n}){return i.jsxs("div",{style:Ywe,children:[i.jsx("span",{"data-file-path":e,title:e,style:Qwe,children:e}),n,t&&i.jsx("span",{role:"button","data-file-download":"",title:"Download",onClick:t,style:Xwe,children:"↓"})]})}function Gwe({on:e,label:t,title:n,onClick:r,...o}){return i.jsx("span",{role:"button","aria-pressed":e,title:n,onClick:r,...o,style:{...Zwe,borderColor:e?"var(--proto-accent)":"var(--proto-line)",background:e?"var(--proto-accent-bg)":"var(--proto-card)",color:e?"var(--proto-accent)":"var(--proto-muted)"},children:t})}const Ywe={flex:"none",display:"flex",alignItems:"center",gap:6,padding:"7px 10px",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-rail)"},Qwe={flex:1,minWidth:0,direction:"rtl",textAlign:"left",unicodeBidi:"plaintext",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",font:`500 10.5px ${D_}`,color:"var(--proto-muted-2)"},Xwe={width:28,height:28,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,cursor:"pointer",flex:"none",userSelect:"none"},Zwe={height:22,padding:"0 8px",borderRadius:6,border:"1px solid var(--proto-line)",display:"inline-flex",alignItems:"center",font:`600 10px ${D_}`,cursor:"pointer",flex:"none",userSelect:"none",whiteSpace:"nowrap"},Jwe="'IBM Plex Mono',monospace";function e6e({item:e}){const t=Mc(),[n,r]=f.useState(!1),o=e.path,s=o?()=>t(o,e.name):void 0,a=Yp(e)&&e.kind==="text"&&kB(e.name);return Yp(e)&&e.kind==="pdf"?i.jsx("div",{style:Rb.pdf,children:i.jsx(MB,{item:e,actions:s&&i.jsx("span",{role:"button","data-file-download":"",title:"Download",onClick:s,style:r6e,children:"↓"})})}):i.jsxs(i.Fragment,{children:[o&&i.jsx(Kwe,{path:o,onDownload:s,children:a&&i.jsx(Gwe,{on:n,label:n?"Rendered":"Source",title:n?"Show the rendered Markdown":"Show the unrendered Markdown source",onClick:()=>r(l=>!l),"data-file-source-toggle":""})}),i.jsx("div",{style:Yp(e)&&e.kind==="text"?Rb.text:Rb.fill,children:Yp(e)?e.kind==="html"?i.jsx(w1,{item:e,mode:"expanded"}):i.jsx(RB,{item:e,source:n}):i.jsx(t6e,{item:e})})]})}function t6e({item:e}){const{src:t,failed:n}=bB(e),{containerRef:r,contentRef:o,style:s}=vS({mode:"transform",minScale:1,maxScale:8});return n?i.jsxs(G5,{failed:!0,children:["Failed to load ",e.name]}):t?i.jsx("div",{ref:r,style:{flex:1,minHeight:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",padding:12,boxSizing:"border-box"},children:e.kind==="video"?i.jsx("video",{src:t,controls:!0,playsInline:!0,style:{maxWidth:"100%",maxHeight:"100%",borderRadius:8,background:"var(--media-stage-bg)"}}):i.jsx("div",{ref:o,style:{...s,display:"inline-block",maxWidth:"100%",maxHeight:"100%"},children:i.jsx("img",{src:t,alt:e.name,draggable:!1,style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",display:"block"}})})}):i.jsx(G5,{children:"Loading…"})}function G5({children:e,failed:t}){return i.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"32px 20px",textAlign:"center",color:t?"var(--proto-faint)":"var(--proto-muted-2)",font:`500 12px ${Jwe}`},children:e})}function n6e(e){return Yp(e)&&e.kind==="pdf"?"var(--proto-gray)":"var(--proto-card)"}const Rb={text:{flex:1,minHeight:0,overflow:"auto"},fill:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},pdf:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"}},r6e={width:28,height:28,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,cursor:"pointer",flex:"none",userSelect:"none"},GS=f.createContext({});function yl(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const o6e=typeof window<"u",j0=o6e?f.useLayoutEffect:f.useEffect,yh=f.createContext(null);function YS(e,t){e.indexOf(t)===-1&&e.push(t)}function Nv(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}function UT([...e],t,n){const r=t<0?e.length+t:t;if(r>=0&&r<e.length){const o=n<0?e.length+n:n,[s]=e.splice(t,1);e.splice(o,0,s)}return e}const Fi=(e,t,n)=>n>t?t:n<e?e:n;let T1=()=>{};const rl={},L_=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),O_=e=>typeof e=="object"&&e!==null,N_=e=>/^0[^.\s]+$/u.test(e);function F_(e){let t;return()=>(t===void 0&&(t=e()),t)}const Mo=e=>e,bh=(...e)=>e.reduce((t,n)=>r=>n(t(r))),C0=(e,t,n)=>{const r=t-e;return r?(n-e)/r:1};class QS{constructor(){this.subscriptions=[]}add(t){return YS(this.subscriptions,t),()=>Nv(this.subscriptions,t)}notify(t,n,r){const o=this.subscriptions.length;if(o)if(o===1)this.subscriptions[0](t,n,r);else for(let s=0;s<o;s++){const a=this.subscriptions[s];a&&a(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const so=e=>e*1e3,Co=e=>e/1e3,z_=(e,t)=>t?e*(1e3/t):0,B_=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,i6e=1e-7,s6e=12;function a6e(e,t,n,r,o){let s,a,l=0;do a=t+(n-t)/2,s=B_(a,r,o)-e,s>0?n=a:t=a;while(Math.abs(s)>i6e&&++l<s6e);return a}function wh(e,t,n,r){if(e===t&&n===r)return Mo;const o=s=>a6e(s,0,1,e,n);return s=>s===0||s===1?s:B_(o(s),t,r)}const $_=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,__=e=>t=>1-e(1-t),W_=wh(.33,1.53,.69,.99),XS=__(W_),H_=$_(XS),U_=e=>e>=1?1:(e*=2)<1?.5*XS(e):.5*(2-Math.pow(2,-10*(e-1))),ZS=e=>1-Math.sin(Math.acos(e)),V_=__(ZS),q_=$_(ZS),l6e=wh(.42,0,1,1),c6e=wh(0,0,.58,1),K_=wh(.42,0,.58,1),d6e=e=>Array.isArray(e)&&typeof e[0]!="number",G_=e=>Array.isArray(e)&&typeof e[0]=="number",u6e={linear:Mo,easeIn:l6e,easeInOut:K_,easeOut:c6e,circIn:ZS,circInOut:q_,circOut:V_,backIn:XS,backInOut:H_,backOut:W_,anticipate:U_},p6e=e=>typeof e=="string",VT=e=>{if(G_(e)){T1(e.length===4);const[t,n,r,o]=e;return wh(t,n,r,o)}else if(p6e(e))return u6e[e];return e},Om=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function f6e(e){let t=new Set,n=new Set,r=!1,o=!1;const s=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(d){s.has(d)&&(c.schedule(d),e()),d(a)}const c={schedule:(d,u=!1,p=!1)=>{const m=p&&r?t:n;return u&&s.add(d),m.add(d),d},cancel:d=>{n.delete(d),s.delete(d)},process:d=>{if(a=d,r){o=!0;return}r=!0;const u=t;t=n,n=u,t.forEach(l),t.clear(),r=!1,o&&(o=!1,c.process(d))}};return c}const h6e=40;function Y_(e,t){let n=!1,r=!0;const o={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,a=Om.reduce((w,k)=>(w[k]=f6e(s),w),{}),{setup:l,read:c,resolveKeyframes:d,preUpdate:u,update:p,preRender:h,render:m,postRender:x}=a,v=()=>{const w=rl.useManualTiming,k=w?o.timestamp:performance.now();n=!1,w||(o.delta=r?1e3/60:Math.max(Math.min(k-o.timestamp,h6e),1)),o.timestamp=k,o.isProcessing=!0,l.process(o),c.process(o),d.process(o),u.process(o),p.process(o),h.process(o),m.process(o),x.process(o),o.isProcessing=!1,n&&t&&(r=!1,e(v))},S=()=>{n=!0,r=!0,o.isProcessing||e(v)};return{schedule:Om.reduce((w,k)=>{const C=a[k];return w[k]=(T,P=!1,R=!1)=>(n||S(),C.schedule(T,P,R)),w},{}),cancel:w=>{for(let k=0;k<Om.length;k++)a[Om[k]].cancel(w)},state:o,steps:a}}const{schedule:Et,cancel:Ls,state:Hn,steps:Mb}=Y_(typeof requestAnimationFrame<"u"?requestAnimationFrame:Mo,!0);let Pg;function m6e(){Pg=void 0}const Sr={now:()=>(Pg===void 0&&Sr.set(Hn.isProcessing||rl.useManualTiming?Hn.timestamp:performance.now()),Pg),set:e=>{Pg=e,queueMicrotask(m6e)}},Q_=e=>t=>typeof t=="string"&&t.startsWith(e),X_=Q_("--"),g6e=Q_("var(--"),JS=e=>g6e(e)?v6e.test(e.split("/*")[0].trim()):!1,v6e=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function qT(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const op={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},T0={...op,transform:e=>Fi(0,1,e)},Nm={...op,default:1},jf=e=>Math.round(e*1e5)/1e5,ek=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function x6e(e){return e==null}const y6e=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,tk=(e,t)=>n=>!!(typeof n=="string"&&y6e.test(n)&&n.startsWith(e)||t&&!x6e(n)&&Object.prototype.hasOwnProperty.call(n,t)),Z_=(e,t,n)=>r=>{if(typeof r!="string")return r;const[o,s,a,l]=r.match(ek);return{[e]:parseFloat(o),[t]:parseFloat(s),[n]:parseFloat(a),alpha:l!==void 0?parseFloat(l):1}},b6e=e=>Fi(0,255,e),Ib={...op,transform:e=>Math.round(b6e(e))},Vl={test:tk("rgb","red"),parse:Z_("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+Ib.transform(e)+", "+Ib.transform(t)+", "+Ib.transform(n)+", "+jf(T0.transform(r))+")"};function w6e(e){let t="",n="",r="",o="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),o=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),o=e.substring(4,5),t+=t,n+=n,r+=r,o+=o),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:o?parseInt(o,16)/255:1}}const Y5={test:tk("#"),parse:w6e,transform:Vl.transform},Sh=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ts=Sh("deg"),Ii=Sh("%"),De=Sh("px"),S6e=Sh("vh"),k6e=Sh("vw"),KT={...Ii,parse:e=>Ii.parse(e)/100,transform:e=>Ii.transform(e*100)},Sd={test:tk("hsl","hue"),parse:Z_("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+Ii.transform(jf(t))+", "+Ii.transform(jf(n))+", "+jf(T0.transform(r))+")"},hn={test:e=>Vl.test(e)||Y5.test(e)||Sd.test(e),parse:e=>Vl.test(e)?Vl.parse(e):Sd.test(e)?Sd.parse(e):Y5.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Vl.transform(e):Sd.transform(e),getAnimatableNone:e=>{const t=hn.parse(e);return t.alpha=0,hn.transform(t)}},j6e=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function C6e(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(ek))==null?void 0:t.length)||0)+(((n=e.match(j6e))==null?void 0:n.length)||0)>0}const J_="number",eW="color",T6e="var",P6e="var(",GT="${}",E6e=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Pu(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},o=[];let s=0;const l=t.replace(E6e,c=>(hn.test(c)?(r.color.push(s),o.push(eW),n.push(hn.parse(c))):c.startsWith(P6e)?(r.var.push(s),o.push(T6e),n.push(c)):(r.number.push(s),o.push(J_),n.push(parseFloat(c))),++s,GT)).split(GT);return{values:n,split:l,indexes:r,types:o}}function R6e(e){return Pu(e).values}function tW({split:e,types:t}){const n=e.length;return r=>{let o="";for(let s=0;s<n;s++)if(o+=e[s],r[s]!==void 0){const a=t[s];a===J_?o+=jf(r[s]):a===eW?o+=hn.transform(r[s]):o+=r[s]}return o}}function M6e(e){return tW(Pu(e))}const I6e=e=>typeof e=="number"?0:hn.test(e)?hn.getAnimatableNone(e):e,A6e=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:I6e(e);function D6e(e){const t=Pu(e);return tW(t)(t.values.map((r,o)=>A6e(r,t.split[o])))}const Jo={test:C6e,parse:R6e,createTransformer:M6e,getAnimatableNone:D6e};function Ab(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function L6e({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let o=0,s=0,a=0;if(!t)o=s=a=n;else{const l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;o=Ab(c,l,e+1/3),s=Ab(c,l,e),a=Ab(c,l,e-1/3)}return{red:Math.round(o*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:r}}function Fv(e,t){return n=>n>0?t:e}const vt=(e,t,n)=>e+(t-e)*n,Db=(e,t,n)=>{const r=e*e,o=n*(t*t-r)+r;return o<0?0:Math.sqrt(o)},O6e=[Y5,Vl,Sd],N6e=e=>O6e.find(t=>t.test(e));function YT(e){const t=N6e(e);if(!t)return!1;let n=t.parse(e);return t===Sd&&(n=L6e(n)),n}const QT=(e,t)=>{const n=YT(e),r=YT(t);if(!n||!r)return Fv(e,t);const o={...n};return s=>(o.red=Db(n.red,r.red,s),o.green=Db(n.green,r.green,s),o.blue=Db(n.blue,r.blue,s),o.alpha=vt(n.alpha,r.alpha,s),Vl.transform(o))},Q5=new Set(["none","hidden"]);function F6e(e,t){return Q5.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function z6e(e,t){return n=>vt(e,t,n)}function nk(e){return typeof e=="number"?z6e:typeof e=="string"?JS(e)?Fv:hn.test(e)?QT:_6e:Array.isArray(e)?nW:typeof e=="object"?hn.test(e)?QT:B6e:Fv}function nW(e,t){const n=[...e],r=n.length,o=e.map((s,a)=>nk(s)(s,t[a]));return s=>{for(let a=0;a<r;a++)n[a]=o[a](s);return n}}function B6e(e,t){const n={...e,...t},r={};for(const o in n)e[o]!==void 0&&t[o]!==void 0&&(r[o]=nk(e[o])(e[o],t[o]));return o=>{for(const s in r)n[s]=r[s](o);return n}}function $6e(e,t){const n=[],r={color:0,var:0,number:0};for(let o=0;o<t.values.length;o++){const s=t.types[o],a=e.indexes[s][r[s]],l=e.values[a]??0;n[o]=l,r[s]++}return n}const _6e=(e,t)=>{const n=Jo.createTransformer(t),r=Pu(e),o=Pu(t);return r.indexes.var.length===o.indexes.var.length&&r.indexes.color.length===o.indexes.color.length&&r.indexes.number.length>=o.indexes.number.length?Q5.has(e)&&!o.values.length||Q5.has(t)&&!r.values.length?F6e(e,t):bh(nW($6e(r,o),o.values),n):Fv(e,t)};function rW(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?vt(e,t,n):nk(e)(e,t)}const W6e=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>Et.update(t,n),stop:()=>Ls(t),now:()=>Hn.isProcessing?Hn.timestamp:Sr.now()}},oW=(e,t,n=10)=>{let r="";const o=Math.max(Math.round(t/n),2);for(let s=0;s<o;s++)r+=Math.round(e(s/(o-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},zv=2e4;function rk(e){let t=0;const n=50;let r=e.next(t);for(;!r.done&&t<zv;)t+=n,r=e.next(t);return t>=zv?1/0:t}function H6e(e,t=100,n){const r=n({...e,keyframes:[0,t]}),o=Math.min(rk(r),zv);return{type:"keyframes",ease:s=>r.next(o*s).value/t,duration:Co(o)}}const rn={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function X5(e,t){return e*Math.sqrt(1-t*t)}const U6e=12;function V6e(e,t,n){let r=n;for(let o=1;o<U6e;o++)r=r-e(r)/t(r);return r}const Lb=.001;function q6e({duration:e=rn.duration,bounce:t=rn.bounce,velocity:n=rn.velocity,mass:r=rn.mass}){let o,s,a=1-t;a=Fi(rn.minDamping,rn.maxDamping,a),e=Fi(rn.minDuration,rn.maxDuration,Co(e)),a<1?(o=d=>{const u=d*a,p=u*e,h=u-n,m=X5(d,a),x=Math.exp(-p);return Lb-h/m*x},s=d=>{const p=d*a*e,h=p*n+n,m=Math.pow(a,2)*Math.pow(d,2)*e,x=Math.exp(-p),v=X5(Math.pow(d,2),a);return(-o(d)+Lb>0?-1:1)*((h-m)*x)/v}):(o=d=>{const u=Math.exp(-d*e),p=(d-n)*e+1;return-Lb+u*p},s=d=>{const u=Math.exp(-d*e),p=(n-d)*(e*e);return u*p});const l=5/e,c=V6e(o,s,l);if(e=so(e),isNaN(c))return{stiffness:rn.stiffness,damping:rn.damping,duration:e};{const d=Math.pow(c,2)*r;return{stiffness:d,damping:a*2*Math.sqrt(r*d),duration:e}}}const K6e=["duration","bounce"],G6e=["stiffness","damping","mass"];function XT(e,t){return t.some(n=>e[n]!==void 0)}function Y6e(e){let t={velocity:rn.velocity,stiffness:rn.stiffness,damping:rn.damping,mass:rn.mass,isResolvedFromDuration:!1,...e};if(!XT(e,G6e)&&XT(e,K6e))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),o=r*r,s=2*Fi(.05,1,1-(e.bounce||0))*Math.sqrt(o);t={...t,mass:rn.mass,stiffness:o,damping:s}}else{const n=q6e({...e,velocity:0});t={...t,...n,mass:rn.mass},t.isResolvedFromDuration=!0}return t}function Bv(e=rn.visualDuration,t=rn.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:o}=n;const s=n.keyframes[0],a=n.keyframes[n.keyframes.length-1],l={done:!1,value:s},{stiffness:c,damping:d,mass:u,duration:p,velocity:h,isResolvedFromDuration:m}=Y6e({...n,velocity:-Co(n.velocity||0)}),x=h||0,v=d/(2*Math.sqrt(c*u)),S=a-s,b=Co(Math.sqrt(c/u)),g=Math.abs(S)<5;r||(r=g?rn.restSpeed.granular:rn.restSpeed.default),o||(o=g?rn.restDelta.granular:rn.restDelta.default);let w,k,C,T,P,R;if(v<1)C=X5(b,v),T=(x+v*b*S)/C,w=I=>{const L=Math.exp(-v*b*I);return a-L*(T*Math.sin(C*I)+S*Math.cos(C*I))},P=v*b*T+S*C,R=v*b*S-T*C,k=I=>Math.exp(-v*b*I)*(P*Math.sin(C*I)+R*Math.cos(C*I));else if(v===1){w=L=>a-Math.exp(-b*L)*(S+(x+b*S)*L);const I=x+b*S;k=L=>Math.exp(-b*L)*(b*I*L-x)}else{const I=b*Math.sqrt(v*v-1);w=V=>{const X=Math.exp(-v*b*V),K=Math.min(I*V,300);return a-X*((x+v*b*S)*Math.sinh(K)+I*S*Math.cosh(K))/I};const L=(x+v*b*S)/I,W=v*b*L-S*I,ee=v*b*S-L*I;k=V=>{const X=Math.exp(-v*b*V),K=Math.min(I*V,300);return X*(W*Math.sinh(K)+ee*Math.cosh(K))}}const D={calculatedDuration:m&&p||null,velocity:I=>so(k(I)),next:I=>{if(!m&&v<1){const W=Math.exp(-v*b*I),ee=Math.sin(C*I),V=Math.cos(C*I),X=a-W*(T*ee+S*V),K=so(W*(P*ee+R*V));return l.done=Math.abs(K)<=r&&Math.abs(a-X)<=o,l.value=l.done?a:X,l}const L=w(I);if(m)l.done=I>=p;else{const W=so(k(I));l.done=Math.abs(W)<=r&&Math.abs(a-L)<=o}return l.value=l.done?a:L,l},toString:()=>{const I=Math.min(rk(D),zv),L=oW(W=>D.next(I*W).value,I,30);return I+"ms "+L},toTransition:()=>{}};return D}Bv.applyToOptions=e=>{const t=H6e(e,100,Bv);return e.ease=t.ease,e.duration=so(t.duration),e.type="keyframes",e};const Q6e=5;function iW(e,t,n){const r=Math.max(t-Q6e,0);return z_(n-e(r),t-r)}function Z5({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:o=10,bounceStiffness:s=500,modifyTarget:a,min:l,max:c,restDelta:d=.5,restSpeed:u}){const p=e[0],h={done:!1,value:p},m=R=>l!==void 0&&R<l||c!==void 0&&R>c,x=R=>l===void 0?c:c===void 0||Math.abs(l-R)<Math.abs(c-R)?l:c;let v=n*t;const S=p+v,b=a===void 0?S:a(S);b!==S&&(v=b-p);const g=R=>-v*Math.exp(-R/r),w=R=>b+g(R),k=R=>{const D=g(R),I=w(R);h.done=Math.abs(D)<=d,h.value=h.done?b:I};let C,T;const P=R=>{m(h.value)&&(C=R,T=Bv({keyframes:[h.value,x(h.value)],velocity:iW(w,R,h.value),damping:o,stiffness:s,restDelta:d,restSpeed:u}))};return P(0),{calculatedDuration:null,next:R=>{let D=!1;return!T&&C===void 0&&(D=!0,k(R),P(R)),C!==void 0&&R>=C?T.next(R-C):(!D&&k(R),h)}}}function X6e(e,t,n){const r=[],o=n||rl.mix||rW,s=e.length-1;for(let a=0;a<s;a++){let l=o(e[a],e[a+1]);if(t){const c=Array.isArray(t)?t[a]||Mo:t;l=bh(c,l)}r.push(l)}return r}function sW(e,t,{clamp:n=!0,ease:r,mixer:o}={}){const s=e.length;if(T1(s===t.length),s===1)return()=>t[0];if(s===2&&t[0]===t[1])return()=>t[1];const a=e[0]===e[1];e[0]>e[s-1]&&(e=[...e].reverse(),t=[...t].reverse());const l=X6e(t,r,o),c=l.length,d=u=>{if(a&&u<e[0])return t[0];let p=0;if(c>1)for(;p<e.length-2&&!(u<e[p+1]);p++);const h=C0(e[p],e[p+1],u);return l[p](h)};return n?u=>d(Fi(e[0],e[s-1],u)):d}function Z6e(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const o=C0(0,t,r);e.push(vt(n,1,o))}}function J6e(e){const t=[0];return Z6e(t,e.length-1),t}function e3e(e,t){return e.map(n=>n*t)}function t3e(e,t){return e.map(()=>t||K_).splice(0,e.length-1)}function Cf({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const o=d6e(r)?r.map(VT):VT(r),s={done:!1,value:t[0]},a=e3e(n&&n.length===t.length?n:J6e(t),e),l=sW(a,t,{ease:Array.isArray(o)?o:t3e(t,o)});return{calculatedDuration:e,next:c=>(s.value=l(c),s.done=c>=e,s)}}const n3e=e=>e!==null;function P1(e,{repeat:t,repeatType:n="loop"},r,o=1){const s=e.filter(n3e),l=o<0||t&&n!=="loop"&&t%2===1?0:s.length-1;return!l||r===void 0?s[l]:r}const r3e={decay:Z5,inertia:Z5,tween:Cf,keyframes:Cf,spring:Bv};function aW(e){typeof e.type=="string"&&(e.type=r3e[e.type])}class ok{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const o3e=e=>e/100;class $v extends ok{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var r,o;const{motionValue:n}=this.options;n&&n.updatedAt!==Sr.now()&&this.tick(Sr.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(o=(r=this.options).onStop)==null||o.call(r))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;aW(t);const{type:n=Cf,repeat:r=0,repeatDelay:o=0,repeatType:s,velocity:a=0}=t;let{keyframes:l}=t;const c=n||Cf;c!==Cf&&typeof l[0]!="number"&&(this.mixKeyframes=bh(o3e,rW(l[0],l[1])),l=[0,100]);const d=c({...t,keyframes:l});s==="mirror"&&(this.mirroredGenerator=c({...t,keyframes:[...l].reverse(),velocity:-a})),d.calculatedDuration===null&&(d.calculatedDuration=rk(d));const{calculatedDuration:u}=d;this.calculatedDuration=u,this.resolvedDuration=u+o,this.totalDuration=this.resolvedDuration*(r+1)-o,this.generator=d}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:r,totalDuration:o,mixKeyframes:s,mirroredGenerator:a,resolvedDuration:l,calculatedDuration:c}=this;if(this.startTime===null)return r.next(0);const{delay:d=0,keyframes:u,repeat:p,repeatType:h,repeatDelay:m,type:x,onUpdate:v,finalKeyframe:S}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-o/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const b=this.currentTime-d*(this.playbackSpeed>=0?1:-1),g=this.playbackSpeed>=0?b<0:b>o;this.currentTime=Math.max(b,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=o);let w=this.currentTime,k=r;if(p){const R=Math.min(this.currentTime,o)/l;let D=Math.floor(R),I=R%1;!I&&R>=1&&(I=1),I===1&&D--,D=Math.min(D,p+1),!!(D%2)&&(h==="reverse"?(I=1-I,m&&(I-=m/l)):h==="mirror"&&(k=a)),w=Fi(0,1,I)*l}let C;g?(this.delayState.value=u[0],C=this.delayState):C=k.next(w),s&&!g&&(C.value=s(C.value));let{done:T}=C;!g&&c!==null&&(T=this.playbackSpeed>=0?this.currentTime>=o:this.currentTime<=0);const P=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&T);return P&&x!==Z5&&(C.value=P1(u,this.options,S,this.speed)),v&&v(C.value),P&&this.finish(),C}then(t,n){return this.finished.then(t,n)}get duration(){return Co(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Co(t)}get time(){return Co(this.currentTime)}set time(t){t=so(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return iW(r=>this.generator.next(r).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime(Sr.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=Co(this.currentTime))}play(){var o,s;if(this.isStopped)return;const{driver:t=W6e,startTime:n}=this.options;this.driver||(this.driver=t(a=>this.tick(a))),(s=(o=this.options).onPlay)==null||s.call(o);const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Sr.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function i3e(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const ql=e=>e*180/Math.PI,J5=e=>{const t=ql(Math.atan2(e[1],e[0]));return ew(t)},s3e={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:J5,rotateZ:J5,skewX:e=>ql(Math.atan(e[1])),skewY:e=>ql(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},ew=e=>(e=e%360,e<0&&(e+=360),e),ZT=J5,JT=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),eP=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),a3e={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:JT,scaleY:eP,scale:e=>(JT(e)+eP(e))/2,rotateX:e=>ew(ql(Math.atan2(e[6],e[5]))),rotateY:e=>ew(ql(Math.atan2(-e[2],e[0]))),rotateZ:ZT,rotate:ZT,skewX:e=>ql(Math.atan(e[4])),skewY:e=>ql(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function tw(e){return e.includes("scale")?1:0}function nw(e,t){if(!e||e==="none")return tw(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,o;if(n)r=a3e,o=n;else{const l=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=s3e,o=l}if(!o)return tw(t);const s=r[t],a=o[1].split(",").map(c3e);return typeof s=="function"?s(a):a[s]}const l3e=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return nw(n,t)};function c3e(e){return parseFloat(e.trim())}const ip=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],sp=new Set([...ip,"pathRotation"]),tP=e=>e===op||e===De,d3e=new Set(["x","y","z"]),u3e=ip.filter(e=>!d3e.has(e));function p3e(e){const t=[];return u3e.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const Pa={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:r})=>{const o=e.max-e.min;return r==="border-box"?o:o-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:r})=>{const o=e.max-e.min;return r==="border-box"?o:o-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>nw(t,"x"),y:(e,{transform:t})=>nw(t,"y")};Pa.translateX=Pa.x;Pa.translateY=Pa.y;const ac=new Set;let rw=!1,ow=!1,iw=!1;function lW(){if(ow){const e=Array.from(ac).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const o=p3e(r);o.length&&(n.set(r,o),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const o=n.get(r);o&&o.forEach(([s,a])=>{var l;(l=r.getValue(s))==null||l.set(a)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}ow=!1,rw=!1,ac.forEach(e=>e.complete(iw)),ac.clear()}function cW(){ac.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(ow=!0)})}function f3e(){iw=!0,cW(),lW(),iw=!1}class ik{constructor(t,n,r,o,s,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=o,this.element=s,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(ac.add(this),rw||(rw=!0,Et.read(cW),Et.resolveKeyframes(lW))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:o}=this;if(t[0]===null){const s=o==null?void 0:o.get(),a=t[t.length-1];if(s!==void 0)t[0]=s;else if(r&&n){const l=r.readValue(n,a);l!=null&&(t[0]=l)}t[0]===void 0&&(t[0]=a),o&&s===void 0&&o.set(t[0])}i3e(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),ac.delete(this)}cancel(){this.state==="scheduled"&&(ac.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const h3e=e=>e.startsWith("--");function dW(e,t,n){h3e(t)?e.style.setProperty(t,n):e.style[t]=n}const m3e={};function uW(e,t){const n=F_(e);return()=>m3e[t]??n()}const g3e=uW(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),pW=uW(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Jp=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,nP={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Jp([0,.65,.55,1]),circOut:Jp([.55,0,1,.45]),backIn:Jp([.31,.01,.66,-.59]),backOut:Jp([.33,1.53,.69,.99])};function fW(e,t){if(e)return typeof e=="function"?pW()?oW(e,t):"ease-out":G_(e)?Jp(e):Array.isArray(e)?e.map(n=>fW(n,t)||nP.easeOut):nP[e]}function v3e(e,t,n,{delay:r=0,duration:o=300,repeat:s=0,repeatType:a="loop",ease:l="easeOut",times:c}={},d=void 0){const u={[t]:n};c&&(u.offset=c);const p=fW(l,o);Array.isArray(p)&&(u.easing=p);const h={delay:r,duration:o,easing:Array.isArray(p)?"linear":p,fill:"both",iterations:s+1,direction:a==="reverse"?"alternate":"normal"};return d&&(h.pseudoElement=d),e.animate(u,h)}function hW(e){return typeof e=="function"&&"applyToOptions"in e}function x3e({type:e,...t}){return hW(e)&&pW()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class mW extends ok{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:r,keyframes:o,pseudoElement:s,allowFlatten:a=!1,finalKeyframe:l,onComplete:c}=t;this.isPseudoElement=!!s,this.allowFlatten=a,this.options=t,T1(typeof t.type!="string");const d=x3e(t);this.animation=v3e(n,r,o,d,s),d.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const u=P1(o,this.options,l,this.speed);this.updateMotionValue&&this.updateMotionValue(u),dW(n,r,u),this.animation.cancel()}c==null||c(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var n,r,o;const t=(n=this.options)==null?void 0:n.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((o=(r=this.animation).commitStyles)==null||o.call(r))}get duration(){var n,r;const t=((r=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:r.call(n).duration)||0;return Co(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Co(t)}get time(){return Co(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=so(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:r,observe:o}){var s;return this.allowFlatten&&((s=this.animation.effect)==null||s.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&g3e()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),Mo):o(this)}}const gW={anticipate:U_,backInOut:H_,circInOut:q_};function y3e(e){return e in gW}function b3e(e){typeof e.ease=="string"&&y3e(e.ease)&&(e.ease=gW[e.ease])}const Ob=10;class w3e extends mW{constructor(t){b3e(t),aW(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:r,onComplete:o,element:s,...a}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const l=new $v({...a,autoplay:!1}),c=Math.max(Ob,Sr.now()-this.startTime),d=Fi(0,Ob,c-Ob),u=l.sample(c).value,{name:p}=this.options;s&&p&&dW(s,p,u),n.setWithVelocity(l.sample(Math.max(0,c-d)).value,u,d),l.stop()}}const rP=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Jo.test(e)||e==="0")&&!e.startsWith("url("));function S3e(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function k3e(e,t,n,r){const o=e[0];if(o===null)return!1;if(t==="display"||t==="visibility")return!0;const s=e[e.length-1],a=rP(o,t),l=rP(s,t);return!a||!l?!1:S3e(e)||(n==="spring"||hW(n))&&r}function sw(e){e.duration=0,e.type="keyframes"}const vW=new Set(["opacity","clipPath","filter","transform","backgroundColor"]),j3e=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function C3e(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&j3e.test(e[t]))return!0;return!1}const T3e=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),P3e=F_(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function E3e(e){var p;const{motionValue:t,name:n,repeatDelay:r,repeatType:o,damping:s,type:a,keyframes:l}=e,c=(p=t==null?void 0:t.owner)==null?void 0:p.current;if(!(c instanceof HTMLElement)&&!(c instanceof SVGElement))return!1;const{onUpdate:d,transformTemplate:u}=t.owner.getProps();return P3e()&&n&&(vW.has(n)||T3e.has(n)&&C3e(l))&&(n!=="transform"||!u)&&!d&&!r&&o!=="mirror"&&s!==0&&a!=="inertia"}const R3e=40;class M3e extends ok{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:o=0,repeatDelay:s=0,repeatType:a="loop",keyframes:l,name:c,motionValue:d,element:u,...p}){var x;super(),this.stop=()=>{var v,S;this._animation&&(this._animation.stop(),(v=this.stopTimeline)==null||v.call(this)),(S=this.keyframeResolver)==null||S.cancel()},this.createdAt=Sr.now();const h={autoplay:t,delay:n,type:r,repeat:o,repeatDelay:s,repeatType:a,name:c,motionValue:d,element:u,...p},m=(u==null?void 0:u.KeyframeResolver)||ik;this.keyframeResolver=new m(l,(v,S,b)=>this.onKeyframesResolved(v,S,h,!b),c,d,u),(x=this.keyframeResolver)==null||x.scheduleResolve()}onKeyframesResolved(t,n,r,o){var b,g;this.keyframeResolver=void 0;const{name:s,type:a,velocity:l,delay:c,isHandoff:d,onUpdate:u}=r;this.resolvedAt=Sr.now();let p=!0;k3e(t,s,a,l)||(p=!1,(rl.instantAnimations||!c)&&(u==null||u(P1(t,r,n))),t[0]=t[t.length-1],sw(r),r.repeat=0);const m={startTime:o?this.resolvedAt?this.resolvedAt-this.createdAt>R3e?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:t},x=p&&!d&&E3e(m),v=(g=(b=m.motionValue)==null?void 0:b.owner)==null?void 0:g.current;let S;if(x)try{S=new w3e({...m,element:v})}catch{S=new $v(m)}else S=new $v(m);S.finished.then(()=>{this.notifyFinished()}).catch(Mo),this.pendingTimeline&&(this.stopTimeline=S.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=S}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),f3e()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function xW(e,t,n,r=0,o=1){const s=Array.from(e).sort((d,u)=>d.sortNodePosition(u)).indexOf(t),a=e.size,l=(a-1)*r;return typeof n=="function"?n(s,a):o===1?s*r:l-s*r}const oP=30,I3e=e=>!isNaN(parseFloat(e)),Tf={current:void 0};class A3e{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{var s;const o=Sr.now();if(this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&((s=this.events.change)==null||s.notify(this.current),this.dependents))for(const a of this.dependents)a.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Sr.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=I3e(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new QS);const r=this.events[t].add(n);return t==="change"?()=>{r(),Et.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return Tf.current&&Tf.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const t=Sr.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>oP)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,oP);return z_(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Sc(e,t){return new A3e(e,t)}function sk(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...r}=e;return{...t,...r}}return e}function ak(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?sk(n,e):n}const D3e={type:"spring",stiffness:500,damping:25,restSpeed:10},L3e=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),O3e={type:"keyframes",duration:.8},N3e={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},F3e=(e,{keyframes:t})=>t.length>2?O3e:sp.has(e)?e.startsWith("scale")?L3e(t[1]):D3e:N3e,z3e=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function B3e(e){for(const t in e)if(!z3e.has(t))return!0;return!1}const lk=(e,t,n,r={},o,s)=>a=>{const l=ak(r,e)||{},c=l.delay||r.delay||0;let{elapsed:d=0}=r;d=d-so(c);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...l,delay:-d,onUpdate:h=>{t.set(h),l.onUpdate&&l.onUpdate(h)},onComplete:()=>{a(),l.onComplete&&l.onComplete()},name:e,motionValue:t,element:s?void 0:o};B3e(l)||Object.assign(u,F3e(e,u)),u.duration&&(u.duration=so(u.duration)),u.repeatDelay&&(u.repeatDelay=so(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let p=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(sw(u),u.delay===0&&(p=!0)),(rl.instantAnimations||rl.skipAnimations||o!=null&&o.shouldSkipAnimations||l.skipAnimations)&&(p=!0,sw(u),u.delay=0),u.allowFlatten=!l.type&&!l.ease,p&&!s&&t.get()!==void 0){const h=P1(u.keyframes,l);if(h!==void 0){Et.update(()=>{u.onUpdate(h),u.onComplete()});return}}return l.isSync?new $v(u):new M3e(u)},$3e=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function _3e(e){const t=$3e.exec(e);if(!t)return[,];const[,n,r,o]=t;return[`--${n??r}`,o]}function yW(e,t,n=1){const[r,o]=_3e(e);if(!r)return;const s=window.getComputedStyle(t).getPropertyValue(r);if(s){const a=s.trim();return L_(a)?parseFloat(a):a}return JS(o)?yW(o,t,n+1):o}function iP(e){const t=[{},{}];return e==null||e.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function ck(e,t,n,r){if(typeof t=="function"){const[o,s]=iP(r);t=t(n!==void 0?n:e.custom,o,s)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[o,s]=iP(r);t=t(n!==void 0?n:e.custom,o,s)}return t}function lc(e,t,n){const r=e.getProps();return ck(r,t,n!==void 0?n:r.custom,e)}const bW=new Set(["width","height","top","left","right","bottom",...ip]),aw=e=>Array.isArray(e);function W3e(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Sc(n))}function H3e(e){return aw(e)?e[e.length-1]||0:e}function U3e(e,t){const n=lc(e,t);let{transitionEnd:r={},transition:o={},...s}=n||{};s={...s,...r};for(const a in s){const l=H3e(s[a]);W3e(e,a,l)}}const On=e=>!!(e&&e.getVelocity);function V3e(e){return!!(On(e)&&e.add)}function lw(e,t){const n=e.getValue("willChange");if(V3e(n))return n.add(t);if(!n&&rl.WillChange){const r=new rl.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function dk(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const q3e="framerAppearId",wW="data-"+dk(q3e);function SW(e){return e.props[wW]}const K3e=typeof window<"u";function G3e({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function kW(e,t,{delay:n=0,transitionOverride:r,type:o}={}){let{transition:s,transitionEnd:a,...l}=t;const c=e.getDefaultTransition();s=s?sk(s,c):c;const d=s==null?void 0:s.reduceMotion,u=s==null?void 0:s.skipAnimations;r&&(s=r);const p=[],h=o&&e.animationState&&e.animationState.getState()[o],m=s==null?void 0:s.path;m&&m.animateVisualElement(e,l,s,n,p);for(const x in l){const v=e.getValue(x,e.latestValues[x]??null),S=l[x];if(S===void 0||h&&G3e(h,x))continue;const b={delay:n,...ak(s||{},x)};u&&(b.skipAnimations=!0);const g=v.get();if(g!==void 0&&!v.isAnimating()&&!Array.isArray(S)&&S===g&&!b.velocity){Et.update(()=>v.set(S));continue}let w=!1;if(K3e&&window.MotionHandoffAnimation){const T=SW(e);if(T){const P=window.MotionHandoffAnimation(T,x,Et);P!==null&&(b.startTime=P,w=!0)}}lw(e,x);const k=d??e.shouldReduceMotion;v.start(lk(x,v,S,k&&bW.has(x)?{type:!1}:b,e,w));const C=v.animation;C&&p.push(C)}if(a){const x=()=>Et.update(()=>{a&&U3e(e,a)});p.length?Promise.all(p).then(x):x()}return p}function cw(e,t,n={}){var c;const r=lc(e,t,n.type==="exit"?(c=e.presenceContext)==null?void 0:c.custom:void 0);let{transition:o=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(o=n.transitionOverride);const s=r?()=>Promise.all(kW(e,r,n)):()=>Promise.resolve(),a=e.variantChildren&&e.variantChildren.size?(d=0)=>{const{delayChildren:u=0,staggerChildren:p,staggerDirection:h}=o;return Y3e(e,t,d,u,p,h,n)}:()=>Promise.resolve(),{when:l}=o;if(l){const[d,u]=l==="beforeChildren"?[s,a]:[a,s];return d().then(()=>u())}else return Promise.all([s(),a(n.delay)])}function Y3e(e,t,n=0,r=0,o=0,s=1,a){const l=[];for(const c of e.variantChildren)c.notify("AnimationStart",t),l.push(cw(c,t,{...a,delay:n+(typeof r=="function"?0:r)+xW(e.variantChildren,c,r,o,s)}).then(()=>c.notify("AnimationComplete",t)));return Promise.all(l)}function Q3e(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const o=t.map(s=>cw(e,s,n));r=Promise.all(o)}else if(typeof t=="string")r=cw(e,t,n);else{const o=typeof t=="function"?lc(e,t,n.custom):t;r=Promise.all(kW(e,o,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}const X3e={test:e=>e==="auto",parse:e=>e},jW=e=>t=>t.test(e),CW=[op,De,Ii,ts,k6e,S6e,X3e],sP=e=>CW.find(jW(e));function Z3e(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||N_(e):!0}const J3e=new Set(["brightness","contrast","saturate","opacity"]);function eSe(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(ek)||[];if(!r)return e;const o=n.replace(r,"");let s=J3e.has(t)?1:0;return r!==n&&(s*=100),t+"("+s+o+")"}const tSe=/\b([a-z-]*)\(.*?\)/gu,dw={...Jo,getAnimatableNone:e=>{const t=e.match(tSe);return t?t.map(eSe).join(" "):e}},uw={...Jo,getAnimatableNone:e=>{const t=Jo.parse(e);return Jo.createTransformer(e)(t.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},aP={...op,transform:Math.round},nSe={rotate:ts,pathRotation:ts,rotateX:ts,rotateY:ts,rotateZ:ts,scale:Nm,scaleX:Nm,scaleY:Nm,scaleZ:Nm,skew:ts,skewX:ts,skewY:ts,distance:De,translateX:De,translateY:De,translateZ:De,x:De,y:De,z:De,perspective:De,transformPerspective:De,opacity:T0,originX:KT,originY:KT,originZ:De},_v={borderWidth:De,borderTopWidth:De,borderRightWidth:De,borderBottomWidth:De,borderLeftWidth:De,borderRadius:De,borderTopLeftRadius:De,borderTopRightRadius:De,borderBottomRightRadius:De,borderBottomLeftRadius:De,width:De,maxWidth:De,height:De,maxHeight:De,top:De,right:De,bottom:De,left:De,inset:De,insetBlock:De,insetBlockStart:De,insetBlockEnd:De,insetInline:De,insetInlineStart:De,insetInlineEnd:De,padding:De,paddingTop:De,paddingRight:De,paddingBottom:De,paddingLeft:De,paddingBlock:De,paddingBlockStart:De,paddingBlockEnd:De,paddingInline:De,paddingInlineStart:De,paddingInlineEnd:De,margin:De,marginTop:De,marginRight:De,marginBottom:De,marginLeft:De,marginBlock:De,marginBlockStart:De,marginBlockEnd:De,marginInline:De,marginInlineStart:De,marginInlineEnd:De,fontSize:De,backgroundPositionX:De,backgroundPositionY:De,...nSe,zIndex:aP,fillOpacity:T0,strokeOpacity:T0,numOctaves:aP},rSe={..._v,color:hn,backgroundColor:hn,outlineColor:hn,fill:hn,stroke:hn,borderColor:hn,borderTopColor:hn,borderRightColor:hn,borderBottomColor:hn,borderLeftColor:hn,filter:dw,WebkitFilter:dw,mask:uw,WebkitMask:uw},TW=e=>rSe[e],oSe=new Set([dw,uw]);function PW(e,t){let n=TW(e);return oSe.has(n)||(n=Jo),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const iSe=new Set(["auto","none","0"]);function sSe(e,t,n){let r=0,o;for(;r<e.length&&!o;){const s=e[r];typeof s=="string"&&!iSe.has(s)&&Pu(s).values.length&&(o=e[r]),r++}if(o&&n)for(const s of t)e[s]=PW(n,o)}class aSe extends ik{constructor(t,n,r,o,s){super(t,n,r,o,s,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let u=0;u<t.length;u++){let p=t[u];if(typeof p=="string"&&(p=p.trim(),JS(p))){const h=yW(p,n.current);h!==void 0&&(t[u]=h),u===t.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!bW.has(r)||t.length!==2)return;const[o,s]=t,a=sP(o),l=sP(s),c=qT(o),d=qT(s);if(c!==d&&Pa[r]){this.needsMeasurement=!0;return}if(a!==l)if(tP(a)&&tP(l))for(let u=0;u<t.length;u++){const p=t[u];typeof p=="string"&&(t[u]=parseFloat(p))}else Pa[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,r=[];for(let o=0;o<t.length;o++)(t[o]===null||Z3e(t[o]))&&r.push(o);r.length&&sSe(t,r,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Pa[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const o=n[n.length-1];o!==void 0&&t.getValue(r,o).jump(o,!1)}measureEndState(){var l;const{element:t,name:n,unresolvedKeyframes:r}=this;if(!t||!t.current)return;const o=t.getValue(n);o&&o.jump(this.measuredOrigin,!1);const s=r.length-1,a=r[s];r[s]=Pa[n](t.measureViewportBox(),window.getComputedStyle(t.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),(l=this.removedTransforms)!=null&&l.length&&this.removedTransforms.forEach(([c,d])=>{t.getValue(c).set(d)}),this.resolveNoneKeyframes()}}const uk=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function EW(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;const o=(n==null?void 0:n[e])??r.querySelectorAll(e);return o?Array.from(o):[]}return Array.from(e).filter(r=>r!=null)}const pw=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function Eg(e){return O_(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:pk}=Y_(queueMicrotask,!1),Wo={x:!1,y:!1};function RW(){return Wo.x||Wo.y}function lSe(e){return e==="x"||e==="y"?Wo[e]?null:(Wo[e]=!0,()=>{Wo[e]=!1}):Wo.x||Wo.y?null:(Wo.x=Wo.y=!0,()=>{Wo.x=Wo.y=!1})}function MW(e,t){const n=EW(e),r=new AbortController,o={passive:!0,...t,signal:r.signal};return[n,o,()=>r.abort()]}function cSe(e){return!(e.pointerType==="touch"||RW())}function dSe(e,t,n={}){const[r,o,s]=MW(e,n);return r.forEach(a=>{let l=!1,c=!1,d;const u=()=>{a.removeEventListener("pointerleave",x)},p=S=>{d&&(d(S),d=void 0),u()},h=S=>{l=!1,window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),c&&(c=!1,p(S))},m=()=>{l=!0,window.addEventListener("pointerup",h,o),window.addEventListener("pointercancel",h,o)},x=S=>{if(S.pointerType!=="touch"){if(l){c=!0;return}p(S)}},v=S=>{if(!cSe(S))return;c=!1;const b=t(a,S);typeof b=="function"&&(d=b,a.addEventListener("pointerleave",x,o))};a.addEventListener("pointerenter",v,o),a.addEventListener("pointerdown",m,o)}),s}const IW=(e,t)=>t?e===t?!0:IW(e,t.parentElement):!1,fk=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,uSe=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function pSe(e){return uSe.has(e.tagName)||e.isContentEditable===!0}const fSe=new Set(["INPUT","SELECT","TEXTAREA"]);function hSe(e){return fSe.has(e.tagName)||e.isContentEditable===!0}const Rg=new WeakSet;function lP(e){return t=>{t.key==="Enter"&&e(t)}}function Nb(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const mSe=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=lP(()=>{if(Rg.has(n))return;Nb(n,"down");const o=lP(()=>{Nb(n,"up")}),s=()=>Nb(n,"cancel");n.addEventListener("keyup",o,t),n.addEventListener("blur",s,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function cP(e){return fk(e)&&!RW()}const dP=new WeakSet;function gSe(e,t,n={}){const[r,o,s]=MW(e,n),a=l=>{const c=l.currentTarget;if(!cP(l)||dP.has(l))return;Rg.add(c),n.stopPropagation&&dP.add(l);const d=t(c,l),u={...o,capture:!0},p=(x,v)=>{window.removeEventListener("pointerup",h,u),window.removeEventListener("pointercancel",m,u),Rg.has(c)&&Rg.delete(c),cP(x)&&typeof d=="function"&&d(x,{success:v})},h=x=>{p(x,c===window||c===document||n.useGlobalTarget||IW(c,x.target))},m=x=>{p(x,!1)};window.addEventListener("pointerup",h,u),window.addEventListener("pointercancel",m,u)};return r.forEach(l=>{(n.useGlobalTarget?window:l).addEventListener("pointerdown",a,o),Eg(l)&&(l.addEventListener("focus",d=>mSe(d,o)),!pSe(l)&&!l.hasAttribute("tabindex")&&(l.tabIndex=0))}),s}function hk(e){return O_(e)&&"ownerSVGElement"in e}const Mg=new WeakMap;let oa;const AW=(e,t,n)=>(r,o)=>o&&o[0]?o[0][e+"Size"]:hk(r)&&"getBBox"in r?r.getBBox()[t]:r[n],vSe=AW("inline","width","offsetWidth"),xSe=AW("block","height","offsetHeight");function ySe({target:e,borderBoxSize:t}){var n;(n=Mg.get(e))==null||n.forEach(r=>{r(e,{get width(){return vSe(e,t)},get height(){return xSe(e,t)}})})}function bSe(e){e.forEach(ySe)}function wSe(){typeof ResizeObserver>"u"||(oa=new ResizeObserver(bSe))}function SSe(e,t){oa||wSe();const n=EW(e);return n.forEach(r=>{let o=Mg.get(r);o||(o=new Set,Mg.set(r,o)),o.add(t),oa==null||oa.observe(r)}),()=>{n.forEach(r=>{const o=Mg.get(r);o==null||o.delete(t),o!=null&&o.size||oa==null||oa.unobserve(r)})}}const Ig=new Set;let kd;function kSe(){kd=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Ig.forEach(t=>t(e))},window.addEventListener("resize",kd)}function jSe(e){return Ig.add(e),kd||kSe(),()=>{Ig.delete(e),!Ig.size&&typeof kd=="function"&&(window.removeEventListener("resize",kd),kd=void 0)}}function uP(e,t){return typeof e=="function"?jSe(e):SSe(e,t)}function CSe(e){return hk(e)&&e.tagName==="svg"}function TSe(...e){const t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],o=e[1+n],s=e[2+n],a=e[3+n],l=sW(o,s,a);return t?l(r):l}const PSe=[...CW,hn,Jo],ESe=e=>PSe.find(jW(e)),pP=()=>({translate:0,scale:1,origin:0,originPoint:0}),jd=()=>({x:pP(),y:pP()}),fP=()=>({min:0,max:0}),jn=()=>({x:fP(),y:fP()}),RSe=new WeakMap;function E1(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function P0(e){return typeof e=="string"||Array.isArray(e)}const mk=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],gk=["initial",...mk];function R1(e){return E1(e.animate)||gk.some(t=>P0(e[t]))}function DW(e){return!!(R1(e)||e.variants)}function MSe(e,t,n){for(const r in t){const o=t[r],s=n[r];if(On(o))e.addValue(r,o);else if(On(s))e.addValue(r,Sc(o,{owner:e}));else if(s!==o)if(e.hasValue(r)){const a=e.getValue(r);a.liveStyle===!0?a.jump(o):a.hasAnimated||a.set(o)}else{const a=e.getStaticValue(r);e.addValue(r,Sc(a!==void 0?a:o,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const Wv={current:null},vk={current:!1},ISe=typeof window<"u";function LW(){if(vk.current=!0,!!ISe)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Wv.current=e.matches;e.addEventListener("change",t),t()}else Wv.current=!1}const hP=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Hv={};function OW(e){Hv=e}function ASe(){return Hv}class DSe{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:o,skipAnimations:s,blockInitialAnimation:a,visualState:l},c={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=ik,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=Sr.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,Et.render(this.render,!1,!0))};const{latestValues:d,renderState:u}=l;this.latestValues=d,this.baseTarget={...d},this.initialValues=n.initial?{...d}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=o,this.skipAnimationsConfig=s,this.options=c,this.blockInitialAnimation=!!a,this.isControllingVariants=R1(n),this.isVariantNode=DW(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:p,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in h){const x=h[m];d[m]!==void 0&&On(x)&&x.set(d[m])}}mount(t){var n,r;if(this.hasBeenMounted)for(const o in this.initialValues)(n=this.values.get(o))==null||n.jump(this.initialValues[o]),this.latestValues[o]=this.initialValues[o];this.current=t,RSe.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((o,s)=>this.bindToMotionValue(s,o)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(vk.current||LW(),this.shouldReduceMotion=Wv.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(r=this.parent)==null||r.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),Ls(this.notifyUpdate),Ls(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const r=this.features[n];r&&(r.unmount(),r.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&vW.has(t)&&this.current instanceof HTMLElement){const{factory:a,keyframes:l,times:c,ease:d,duration:u}=n.accelerate,p=new mW({element:this.current,name:t,keyframes:l,times:c,ease:d,duration:so(u)}),h=a(p);this.valueSubscriptions.set(t,()=>{h(),p.cancel()});return}const r=sp.has(t);r&&this.onBindTransform&&this.onBindTransform();const o=n.on("change",a=>{this.latestValues[t]=a,this.props.onUpdate&&Et.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let s;typeof window<"u"&&window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{o(),s&&s()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Hv){const n=Hv[t];if(!n)continue;const{isEnabled:r,Feature:o}=n;if(!this.features[t]&&o&&r(this.props)&&(this.features[t]=new o(this)),this.features[t]){const s=this.features[t];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):jn()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<hP.length;r++){const o=hP[r];this.propEventSubscriptions[o]&&(this.propEventSubscriptions[o](),delete this.propEventSubscriptions[o]);const s="on"+o,a=t[s];a&&(this.propEventSubscriptions[o]=this.on(o,a))}this.prevMotionValues=MSe(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=Sc(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(L_(r)||N_(r))?r=parseFloat(r):!ESe(r)&&Jo.test(n)&&(r=PW(t,n)),this.setBaseTarget(t,On(r)?r.get():r)),On(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var s;const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const a=ck(this.props,n,(s=this.presenceContext)==null?void 0:s.custom);a&&(r=a[t])}if(n&&r!==void 0)return r;const o=this.getBaseTargetFromProps(this.props,t);return o!==void 0&&!On(o)?o:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new QS),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){pk.render(this.render)}}class NW extends DSe{constructor(){super(...arguments),this.KeyframeResolver=aSe}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const r=t.style;return r?r[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;On(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class bl{constructor(t){this.isMounted=!1,this.node=t}update(){}}function FW({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function LSe({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function OSe(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Fb(e){return e===void 0||e===1}function fw({scale:e,scaleX:t,scaleY:n}){return!Fb(e)||!Fb(t)||!Fb(n)}function Dl(e){return fw(e)||zW(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function zW(e){return mP(e.x)||mP(e.y)}function mP(e){return e&&e!=="0%"}function Uv(e,t,n){const r=e-n,o=t*r;return n+o}function gP(e,t,n,r,o){return o!==void 0&&(e=Uv(e,o,r)),Uv(e,n,r)+t}function hw(e,t=0,n=1,r,o){e.min=gP(e.min,t,n,r,o),e.max=gP(e.max,t,n,r,o)}function BW(e,{x:t,y:n}){hw(e.x,t.translate,t.scale,t.originPoint),hw(e.y,n.translate,n.scale,n.originPoint)}const vP=.999999999999,xP=1.0000000000001;function NSe(e,t,n,r=!1){var l;const o=n.length;if(!o)return;t.x=t.y=1;let s,a;for(let c=0;c<o;c++){s=n[c],a=s.projectionDelta;const{visualElement:d}=s.options;d&&d.props.style&&d.props.style.display==="contents"||(r&&s.options.layoutScroll&&s.scroll&&s!==s.root&&(Si(e.x,-s.scroll.offset.x),Si(e.y,-s.scroll.offset.y)),a&&(t.x*=a.x.scale,t.y*=a.y.scale,BW(e,a)),r&&Dl(s.latestValues)&&Ag(e,s.latestValues,(l=s.layout)==null?void 0:l.layoutBox))}t.x<xP&&t.x>vP&&(t.x=1),t.y<xP&&t.y>vP&&(t.y=1)}function Si(e,t){e.min+=t,e.max+=t}function yP(e,t,n,r,o=.5){const s=vt(e.min,e.max,o);hw(e,t,n,s,r)}function bP(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Ag(e,t,n){const r=n??e;yP(e.x,bP(t.x,r.x),t.scaleX,t.scale,t.originX),yP(e.y,bP(t.y,r.y),t.scaleY,t.scale,t.originY)}function $W(e,t){return FW(OSe(e.getBoundingClientRect(),t))}function FSe(e,t,n){const r=$W(e,n),{scroll:o}=t;return o&&(Si(r.x,o.offset.x),Si(r.y,o.offset.y)),r}const zSe={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},BSe=ip.length;function $Se(e,t,n){let r="",o=!0;for(let a=0;a<BSe;a++){const l=ip[a],c=e[l];if(c===void 0)continue;let d=!0;if(typeof c=="number")d=c===(l.startsWith("scale")?1:0);else{const u=parseFloat(c);d=l.startsWith("scale")?u===1:u===0}if(!d||n){const u=pw(c,_v[l]);if(!d){o=!1;const p=zSe[l]||l;r+=`${p}(${u}) `}n&&(t[l]=u)}}const s=e.pathRotation;return s&&(o=!1,r+=`rotate(${pw(s,_v.pathRotation)}) `),r=r.trim(),n?r=n(t,o?"":r):o&&(r="none"),r}function xk(e,t,n){const{style:r,vars:o,transformOrigin:s}=e;let a=!1,l=!1;for(const c in t){const d=t[c];if(sp.has(c)){a=!0;continue}else if(X_(c)){o[c]=d;continue}else{const u=pw(d,_v[c]);c.startsWith("origin")?(l=!0,s[c]=u):r[c]=u}}if(t.transform||(a||n?r.transform=$Se(t,e.transform,n):r.transform&&(r.transform="none")),l){const{originX:c="50%",originY:d="50%",originZ:u=0}=s;r.transformOrigin=`${c} ${d} ${u}`}}function _W(e,{style:t,vars:n},r,o){const s=e.style;let a;for(a in t)s[a]=t[a];o==null||o.applyProjectionStyles(s,r);for(a in n)s.setProperty(a,n[a])}function wP(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Pp={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(De.test(e))e=parseFloat(e);else return e;const n=wP(e,t.target.x),r=wP(e,t.target.y);return`${n}% ${r}%`}},_Se={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,o=Jo.parse(e);if(o.length>5)return r;const s=Jo.createTransformer(e),a=typeof o[0]!="number"?1:0,l=n.x.scale*t.x,c=n.y.scale*t.y;o[0+a]/=l,o[1+a]/=c;const d=vt(l,c,.5);return typeof o[2+a]=="number"&&(o[2+a]/=d),typeof o[3+a]=="number"&&(o[3+a]/=d),s(o)}},mw={borderRadius:{...Pp,applyTo:[...uk]},borderTopLeftRadius:Pp,borderTopRightRadius:Pp,borderBottomLeftRadius:Pp,borderBottomRightRadius:Pp,boxShadow:_Se};function WW(e,{layout:t,layoutId:n}){return sp.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!mw[e]||e==="opacity")}function yk(e,t,n){var a;const r=e.style,o=t==null?void 0:t.style,s={};if(!r)return s;for(const l in r)(On(r[l])||o&&On(o[l])||WW(l,e)||((a=n==null?void 0:n.getValue(l))==null?void 0:a.liveStyle)!==void 0)&&(s[l]=r[l]);return s}function WSe(e){return window.getComputedStyle(e)}class HSe extends NW{constructor(){super(...arguments),this.type="html",this.renderInstance=_W}mount(t){T1(!!t.style),super.mount(t)}readValueFromInstance(t,n){var r;if(sp.has(n))return(r=this.projection)!=null&&r.isProjecting?tw(n):l3e(t,n);{const o=WSe(t),s=(X_(n)?o.getPropertyValue(n):o[n])||0;return typeof s=="string"?s.trim():s}}measureInstanceViewportBox(t,{transformPagePoint:n}){return $W(t,n)}build(t,n,r){xk(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return yk(t,n,r)}}const USe={offset:"stroke-dashoffset",array:"stroke-dasharray"},VSe={offset:"strokeDashoffset",array:"strokeDasharray"};function qSe(e,t,n=1,r=0,o=!0){e.pathLength=1;const s=o?USe:VSe;e[s.offset]=`${-r}`,e[s.array]=`${t} ${n}`}const HW=["transform","opacity","offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function UW(e,{attrX:t,attrY:n,attrScale:r,pathLength:o,pathSpacing:s=1,pathOffset:a=0,...l},c,d,u){if(xk(e,l,d),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:p,style:h}=e;for(const m of HW)p[m]!==void 0&&(h[m]=p[m],delete p[m]);(h.transform||p.transformOrigin)&&(h.transformOrigin=p.transformOrigin??"50% 50%",delete p.transformOrigin),h.transform&&(h.transformBox=(u==null?void 0:u.transformBox)??"fill-box",delete p.transformBox),t!==void 0&&(p.x=t),n!==void 0&&(p.y=n),r!==void 0&&(p.scale=r),o!==void 0&&qSe(p,o,s,a,!1)}const VW=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),qW=e=>typeof e=="string"&&e.toLowerCase()==="svg";function KSe(e,t,n,r){_W(e,t,void 0,r);for(const o in t.attrs)e.setAttribute(VW.has(o)?o:dk(o),t.attrs[o])}function KW(e,t,n){const r=yk(e,t,n);for(const o in e)if(On(e[o])||On(t[o])){const s=ip.indexOf(o)!==-1?"attr"+o.charAt(0).toUpperCase()+o.substring(1):o;r[s]=e[o]}return r}class GSe extends NW{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=jn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(sp.has(n)){const r=TW(n);return r&&r.default||0}if(HW.includes(n)){const o=getComputedStyle(t)[n];if(typeof o=="string"&&o)return o.trim()}return n=VW.has(n)?n:dk(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return KW(t,n,r)}build(t,n,r){UW(t,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(t,n,r,o){KSe(t,n,r,o)}mount(t){this.isSVGTag=qW(t.tagName),super.mount(t)}}const YSe=gk.length;function GW(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?GW(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<YSe;n++){const r=gk[n],o=e.props[r];(P0(o)||o===!1)&&(t[r]=o)}return t}function YW(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}const QSe=[...mk].reverse(),XSe=mk.length;function ZSe(e){return t=>Promise.all(t.map(({animation:n,options:r})=>Q3e(e,n,r)))}function JSe(e){let t=ZSe(e),n=SP(),r=!0,o=!1;const s=d=>(u,p)=>{var m;const h=lc(e,p,d==="exit"?(m=e.presenceContext)==null?void 0:m.custom:void 0);if(h){const{transition:x,transitionEnd:v,...S}=h;u={...u,...S,...v}}return u};function a(d){t=d(e)}function l(d){const{props:u}=e,p=GW(e.parent)||{},h=[],m=new Set;let x={},v=1/0;for(let b=0;b<XSe;b++){const g=QSe[b],w=n[g],k=u[g]!==void 0?u[g]:p[g],C=P0(k),T=g===d?w.isActive:null;T===!1&&(v=b);let P=k===p[g]&&k!==u[g]&&C;if(P&&(r||o)&&e.manuallyAnimateOnMount&&(P=!1),w.protectedKeys={...x},!w.isActive&&T===null||!k&&!w.prevProp||E1(k)||typeof k=="boolean")continue;if(g==="exit"&&w.isActive&&T!==!0){w.prevResolvedValues&&(x={...x,...w.prevResolvedValues});continue}const R=eke(w.prevProp,k);let D=R||g===d&&w.isActive&&!P&&C||b>v&&C,I=!1;const L=Array.isArray(k)?k:[k];let W=L.reduce(s(g),{});T===!1&&(W={});const{prevResolvedValues:ee={}}=w,V={...ee,...W},X=B=>{D=!0,m.has(B)&&(I=!0,m.delete(B)),w.needsAnimating[B]=!0;const G=e.getValue(B);G&&(G.liveStyle=!1)};for(const B in V){const G=W[B],ne=ee[B];if(x.hasOwnProperty(B))continue;let le=!1;aw(G)&&aw(ne)?le=!YW(G,ne)||R:le=G!==ne,le?G!=null?X(B):m.add(B):G!==void 0&&m.has(B)?X(B):w.protectedKeys[B]=!0}w.prevProp=k,w.prevResolvedValues=W,w.isActive&&(x={...x,...W}),(r||o)&&e.blockInitialAnimation&&(D=!1);const K=P&&R;D&&(!K||I)&&h.push(...L.map(B=>{const G={type:g};if(typeof B=="string"&&(r||o)&&!K&&e.manuallyAnimateOnMount&&e.parent){const{parent:ne}=e,le=lc(ne,B);if(ne.enteringChildren&&le){const{delayChildren:_}=le.transition||{};G.delay=xW(ne.enteringChildren,e,_)}}return{animation:B,options:G}}))}if(m.size){const b={};if(typeof u.initial!="boolean"){const g=lc(e,Array.isArray(u.initial)?u.initial[0]:u.initial);g&&g.transition&&(b.transition=g.transition)}m.forEach(g=>{const w=e.getBaseTarget(g),k=e.getValue(g);k&&(k.liveStyle=!0),b[g]=w??null}),h.push({animation:b})}let S=!!h.length;return r&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(S=!1),r=!1,o=!1,S?t(h):Promise.resolve()}function c(d,u){var h;if(n[d].isActive===u)return Promise.resolve();(h=e.variantChildren)==null||h.forEach(m=>{var x;return(x=m.animationState)==null?void 0:x.setActive(d,u)}),n[d].isActive=u;const p=l(d);for(const m in n)n[m].protectedKeys={};return p}return{animateChanges:l,setActive:c,setAnimateFunction:a,getState:()=>n,reset:()=>{n=SP(),o=!0}}}function eke(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!YW(t,e):!1}function El(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function SP(){return{animate:El(!0),whileInView:El(),whileHover:El(),whileTap:El(),whileDrag:El(),whileFocus:El(),exit:El()}}function gw(e,t){e.min=t.min,e.max=t.max}function Bo(e,t){gw(e.x,t.x),gw(e.y,t.y)}function kP(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const QW=1e-4,tke=1-QW,nke=1+QW,XW=.01,rke=0-XW,oke=0+XW;function kr(e){return e.max-e.min}function ike(e,t,n){return Math.abs(e-t)<=n}function jP(e,t,n,r=.5){e.origin=r,e.originPoint=vt(t.min,t.max,e.origin),e.scale=kr(n)/kr(t),e.translate=vt(n.min,n.max,e.origin)-e.originPoint,(e.scale>=tke&&e.scale<=nke||isNaN(e.scale))&&(e.scale=1),(e.translate>=rke&&e.translate<=oke||isNaN(e.translate))&&(e.translate=0)}function Pf(e,t,n,r){jP(e.x,t.x,n.x,r?r.originX:void 0),jP(e.y,t.y,n.y,r?r.originY:void 0)}function CP(e,t,n,r=0){const o=r?vt(n.min,n.max,r):n.min;e.min=o+t.min,e.max=e.min+kr(t)}function ske(e,t,n,r){CP(e.x,t.x,n.x,r==null?void 0:r.x),CP(e.y,t.y,n.y,r==null?void 0:r.y)}function TP(e,t,n,r=0){const o=r?vt(n.min,n.max,r):n.min;e.min=t.min-o,e.max=e.min+kr(t)}function Vv(e,t,n,r){TP(e.x,t.x,n.x,r==null?void 0:r.x),TP(e.y,t.y,n.y,r==null?void 0:r.y)}function PP(e,t,n,r,o){return e-=t,e=Uv(e,1/n,r),o!==void 0&&(e=Uv(e,1/o,r)),e}function ake(e,t=0,n=1,r=.5,o,s=e,a=e){if(Ii.test(t)&&(t=parseFloat(t),t=vt(a.min,a.max,t/100)-a.min),typeof t!="number")return;let l=vt(s.min,s.max,r);e===s&&(l-=t),e.min=PP(e.min,t,n,l,o),e.max=PP(e.max,t,n,l,o)}function EP(e,t,[n,r,o],s,a){ake(e,t[n],t[r],t[o],t.scale,s,a)}const lke=["x","scaleX","originX"],cke=["y","scaleY","originY"];function RP(e,t,n,r){EP(e.x,t,lke,n?n.x:void 0,r?r.x:void 0),EP(e.y,t,cke,n?n.y:void 0,r?r.y:void 0)}function MP(e){return e.translate===0&&e.scale===1}function ZW(e){return MP(e.x)&&MP(e.y)}function IP(e,t){return e.min===t.min&&e.max===t.max}function dke(e,t){return IP(e.x,t.x)&&IP(e.y,t.y)}function AP(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function JW(e,t){return AP(e.x,t.x)&&AP(e.y,t.y)}function DP(e){return kr(e.x)/kr(e.y)}function LP(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function vi(e){return[e("x"),e("y")]}function uke(e,t,n){let r="";const o=e.x.translate/t.x,s=e.y.translate/t.y,a=(n==null?void 0:n.z)||0;if((o||s||a)&&(r=`translate3d(${o}px, ${s}px, ${a}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:d,rotate:u,pathRotation:p,rotateX:h,rotateY:m,skewX:x,skewY:v}=n;d&&(r=`perspective(${d}px) ${r}`),u&&(r+=`rotate(${u}deg) `),p&&(r+=`rotate(${p}deg) `),h&&(r+=`rotateX(${h}deg) `),m&&(r+=`rotateY(${m}deg) `),x&&(r+=`skewX(${x}deg) `),v&&(r+=`skewY(${v}deg) `)}const l=e.x.scale*t.x,c=e.y.scale*t.y;return(l!==1||c!==1)&&(r+=`scale(${l}, ${c})`),r||"none"}const pke=uk.length,OP=e=>typeof e=="string"?parseFloat(e):e,NP=e=>typeof e=="number"||De.test(e);function fke(e,t,n,r,o,s){o?(e.opacity=vt(0,n.opacity??1,hke(r)),e.opacityExit=vt(t.opacity??1,0,mke(r))):s&&(e.opacity=vt(t.opacity??1,n.opacity??1,r));for(let a=0;a<pke;a++){const l=uk[a];let c=FP(t,l),d=FP(n,l);if(c===void 0&&d===void 0)continue;c||(c=0),d||(d=0),c===0||d===0||NP(c)===NP(d)?(e[l]=Math.max(vt(OP(c),OP(d),r),0),(Ii.test(d)||Ii.test(c))&&(e[l]+="%")):e[l]=d}(t.rotate||n.rotate)&&(e.rotate=vt(t.rotate||0,n.rotate||0,r))}function FP(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const hke=eH(0,.5,V_),mke=eH(.5,.95,Mo);function eH(e,t,n){return r=>r<e?0:r>t?1:n(C0(e,t,r))}function gke(e,t,n){const r=On(e)?e:Sc(e);return r.start(lk("",r,t,n)),r.animation}function E0(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}const vke=(e,t)=>e.depth-t.depth;class xke{constructor(){this.children=[],this.isDirty=!1}add(t){YS(this.children,t),this.isDirty=!0}remove(t){Nv(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(vke),this.isDirty=!1,this.children.forEach(t)}}function yke(e,t){const n=Sr.now(),r=({timestamp:o})=>{const s=o-n;s>=t&&(Ls(r),e(s-t))};return Et.setup(r,!0),()=>Ls(r)}function Dg(e){return On(e)?e.get():e}class bke{constructor(){this.members=[]}add(t){YS(this.members,t);for(let n=this.members.length-1;n>=0;n--){const r=this.members[n];if(r===t||r===this.lead||r===this.prevLead)continue;const o=r.instance;(!o||o.isConnected===!1)&&!r.snapshot&&(Nv(this.members,r),r.unmount())}t.scheduleRender()}remove(t){if(Nv(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){var n;for(let r=this.members.indexOf(t)-1;r>=0;r--){const o=this.members[r];if(o.isPresent!==!1&&((n=o.instance)==null?void 0:n.isConnected)!==!1)return this.promote(o),!0}return!1}promote(t,n){var o;const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.updateSnapshot(),t.scheduleRender();const{layoutDependency:s}=r.options,{layoutDependency:a}=t.options;(s===void 0||s!==a)&&(t.resumeFrom=r,n&&(r.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),(o=t.root)!=null&&o.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var n,r,o,s,a;(r=(n=t.options).onExitComplete)==null||r.call(n),(a=(o=t.resumingFrom)==null?void 0:(s=o.options).onExitComplete)==null||a.call(s)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const Lg={hasAnimatedSinceResize:!0,hasEverUpdated:!1},zb=["","X","Y","Z"],wke=1e3;let Ske=0;function Bb(e,t,n,r){const{latestValues:o}=t;o[e]&&(n[e]=o[e],t.setStaticValue(e,0),r&&(r[e]=0))}function tH(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=SW(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:o,layoutId:s}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Et,!(o||s))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&tH(r)}function nH({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:o}){return class{constructor(a={},l=t==null?void 0:t()){this.id=Ske++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Cke),this.nodes.forEach(Ike),this.nodes.forEach(Ake),this.nodes.forEach(Tke)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new xke)}addEventListener(a,l){return this.eventHandlers.has(a)||this.eventHandlers.set(a,new QS),this.eventHandlers.get(a).add(l)}notifyListeners(a,...l){const c=this.eventHandlers.get(a);c&&c.notify(...l)}hasListeners(a){return this.eventHandlers.has(a)}mount(a){if(this.instance)return;this.isSVG=hk(a)&&!CSe(a),this.instance=a;const{layoutId:l,layout:c,visualElement:d}=this.options;if(d&&!d.current&&d.mount(a),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||l)&&(this.isLayoutDirty=!0),e){let u,p=0;const h=()=>this.root.updateBlockedByResize=!1;Et.read(()=>{p=window.innerWidth}),e(a,()=>{const m=window.innerWidth;m!==p&&(p=m,this.root.updateBlockedByResize=!0,u&&u(),u=yke(h,250),Lg.hasAnimatedSinceResize&&(Lg.hasAnimatedSinceResize=!1,this.nodes.forEach($P)))})}l&&this.root.registerSharedNode(l,this),this.options.animate!==!1&&d&&(l||c)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p,hasRelativeLayoutChanged:h,layout:m})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||d.getDefaultTransition()||Fke,{onLayoutAnimationStart:v,onLayoutAnimationComplete:S}=d.getProps(),b=!this.targetLayout||!JW(this.targetLayout,m),g=!p&&h;if(this.options.layoutRoot||this.resumeFrom||g||p&&(b||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...ak(x,"layout"),onPlay:v,onComplete:S};(d.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(u,g,w.path)}else p||$P(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=m})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Ls(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Dke),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&tH(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const p=this.path[u];p.shouldResetTransform=!0,(typeof p.latestValues.x=="string"||typeof p.latestValues.y=="string")&&(p.isLayoutDirty=!0),p.updateScroll("snapshot"),p.options.layoutRoot&&p.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const d=this.getTransformTemplate();this.prevTransformTemplateValue=d?d(this.latestValues,""):void 0,this.updateSnapshot(),a&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const c=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),c&&this.nodes.forEach(Eke),this.nodes.forEach(zP);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(BP);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Rke),this.nodes.forEach(Mke),this.nodes.forEach(kke),this.nodes.forEach(jke)):this.nodes.forEach(BP),this.clearAllSnapshots();const l=Sr.now();Hn.delta=Fi(0,1e3/60,l-Hn.timestamp),Hn.timestamp=l,Hn.isProcessing=!0,Mb.update.process(Hn),Mb.preRender.process(Hn),Mb.render.process(Hn),Hn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,pk.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Pke),this.sharedNodes.forEach(Lke)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Et.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Et.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!kr(this.snapshot.measuredBox.x)&&!kr(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const a=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=jn()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,a?a.layoutBox:void 0)}updateScroll(a="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===a&&(l=!1),l&&this.instance){const c=r(this.instance);this.scroll={animationId:this.root.animationId,phase:a,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!o)return;const a=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!ZW(this.projectionDelta),c=this.getTransformTemplate(),d=c?c(this.latestValues,""):void 0,u=d!==this.prevTransformTemplateValue;a&&this.instance&&(l||Dl(this.latestValues)||u)&&(o(this.instance,d),this.shouldResetTransform=!1,this.scheduleRender())}measure(a=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return a&&(c=this.removeTransform(c)),zke(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var d;const{visualElement:a}=this.options;if(!a)return jn();const l=a.measureViewportBox();if(!(((d=this.scroll)==null?void 0:d.wasRoot)||this.path.some(Bke))){const{scroll:u}=this.root;u&&(Si(l.x,u.offset.x),Si(l.y,u.offset.y))}return l}removeElementScroll(a){var c;const l=jn();if(Bo(l,a),(c=this.scroll)!=null&&c.wasRoot)return l;for(let d=0;d<this.path.length;d++){const u=this.path[d],{scroll:p,options:h}=u;u!==this.root&&p&&h.layoutScroll&&(p.wasRoot&&Bo(l,a),Si(l.x,p.offset.x),Si(l.y,p.offset.y))}return l}applyTransform(a,l=!1,c){var u,p;const d=c||jn();Bo(d,a);for(let h=0;h<this.path.length;h++){const m=this.path[h];!l&&m.options.layoutScroll&&m.scroll&&m!==m.root&&(Si(d.x,-m.scroll.offset.x),Si(d.y,-m.scroll.offset.y)),Dl(m.latestValues)&&Ag(d,m.latestValues,(u=m.layout)==null?void 0:u.layoutBox)}return Dl(this.latestValues)&&Ag(d,this.latestValues,(p=this.layout)==null?void 0:p.layoutBox),d}removeTransform(a){var c;const l=jn();Bo(l,a);for(let d=0;d<this.path.length;d++){const u=this.path[d];if(!Dl(u.latestValues))continue;let p;u.instance&&(fw(u.latestValues)&&u.updateSnapshot(),p=jn(),Bo(p,u.measurePageBox())),RP(l,u.latestValues,(c=u.snapshot)==null?void 0:c.layoutBox,p)}return Dl(this.latestValues)&&RP(l,this.latestValues),l}setTargetDelta(a){this.targetDelta=a,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(a){this.options={...this.options,...a,crossfade:a.crossfade!==void 0?a.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Hn.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(a=!1){var m;const l=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=l.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=l.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=l.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==l;if(!(a||c&&this.isSharedProjectionDirty||this.isProjectionDirty||(m=this.parent)!=null&&m.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:p}=this.options;if(!this.layout||!(u||p))return;this.resolvedRelativeTargetAt=Hn.timestamp;const h=this.getClosestProjectingParent();h&&this.linkedParentVersion!==h.layoutVersion&&!h.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&h&&h.layout?this.createRelativeTarget(h,this.layout.layoutBox,h.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=jn(),this.targetWithTransforms=jn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),ske(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Bo(this.target,this.layout.layoutBox),BW(this.target,this.targetDelta)):Bo(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&h&&!!h.resumingFrom==!!this.resumingFrom&&!h.options.layoutScroll&&h.target&&this.animationProgress!==1?this.createRelativeTarget(h,this.target,h.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||fw(this.parent.latestValues)||zW(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(a,l,c){this.relativeParent=a,this.linkedParentVersion=a.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=jn(),this.relativeTargetOrigin=jn(),Vv(this.relativeTargetOrigin,l,c,this.options.layoutAnchor||void 0),Bo(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var x;const a=this.getLead(),l=!!this.resumingFrom||this!==a;let c=!0;if((this.isProjectionDirty||(x=this.parent)!=null&&x.isProjectionDirty)&&(c=!1),l&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===Hn.timestamp&&(c=!1),c)return;const{layout:d,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(d||u))return;Bo(this.layoutCorrected,this.layout.layoutBox);const p=this.treeScale.x,h=this.treeScale.y;NSe(this.layoutCorrected,this.treeScale,this.path,l),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=jn());const{target:m}=a;if(!m){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(kP(this.prevProjectionDelta.x,this.projectionDelta.x),kP(this.prevProjectionDelta.y,this.projectionDelta.y)),Pf(this.projectionDelta,this.layoutCorrected,m,this.latestValues),(this.treeScale.x!==p||this.treeScale.y!==h||!LP(this.projectionDelta.x,this.prevProjectionDelta.x)||!LP(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",m))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(a=!0){var l;if((l=this.options.visualElement)==null||l.scheduleRender(),a){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=jd(),this.projectionDelta=jd(),this.projectionDeltaWithTransform=jd()}setAnimationOrigin(a,l=!1,c){const d=this.snapshot,u=d?d.latestValues:{},p={...this.latestValues},h=jd();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const m=jn(),x=d?d.source:void 0,v=this.layout?this.layout.source:void 0,S=x!==v,b=this.getStack(),g=!b||b.members.length<=1,w=!!(S&&!g&&this.options.crossfade===!0&&!this.path.some(Nke));this.animationProgress=0;let k;const C=c==null?void 0:c.interpolateProjection(a);this.mixTargetDelta=T=>{const P=T/1e3,R=C==null?void 0:C(P);R?(h.x.translate=R.x,h.x.scale=vt(a.x.scale,1,P),h.x.origin=a.x.origin,h.x.originPoint=a.x.originPoint,h.y.translate=R.y,h.y.scale=vt(a.y.scale,1,P),h.y.origin=a.y.origin,h.y.originPoint=a.y.originPoint):(_P(h.x,a.x,P),_P(h.y,a.y,P)),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Vv(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Oke(this.relativeTarget,this.relativeTargetOrigin,m,P),k&&dke(this.relativeTarget,k)&&(this.isProjectionDirty=!1),k||(k=jn()),Bo(k,this.relativeTarget)),S&&(this.animationValues=p,fke(p,u,this.latestValues,P,w,g)),R&&R.rotate!==void 0&&(this.animationValues||(this.animationValues=p),this.animationValues.pathRotation=R.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){var l,c,d;this.notifyListeners("animationStart"),(l=this.currentAnimation)==null||l.stop(),(d=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||d.stop(),this.pendingAnimation&&(Ls(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Et.update(()=>{Lg.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Sc(0)),this.motionValue.jump(0,!1),this.currentAnimation=gke(this.motionValue,[0,1e3],{...a,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),a.onUpdate&&a.onUpdate(u)},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(wke),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:l,target:c,layout:d,latestValues:u}=a;if(!(!l||!c||!d)){if(this!==a&&this.layout&&d&&rH(this.options.animationType,this.layout.layoutBox,d.layoutBox)){c=this.target||jn();const p=kr(this.layout.layoutBox.x);c.x.min=a.target.x.min,c.x.max=c.x.min+p;const h=kr(this.layout.layoutBox.y);c.y.min=a.target.y.min,c.y.max=c.y.min+h}Bo(l,c),Ag(l,u),Pf(this.projectionDeltaWithTransform,this.layoutCorrected,l,u)}}registerSharedNode(a,l){this.sharedNodes.has(a)||this.sharedNodes.set(a,new bke),this.sharedNodes.get(a).add(l);const d=l.options.initialPromotionConfig;l.promote({transition:d?d.transition:void 0,preserveFollowOpacity:d&&d.shouldPreserveFollowOpacity?d.shouldPreserveFollowOpacity(l):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var l;const{layoutId:a}=this.options;return a?((l=this.getStack())==null?void 0:l.lead)||this:this}getPrevLead(){var l;const{layoutId:a}=this.options;return a?(l=this.getStack())==null?void 0:l.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:l,preserveFollowOpacity:c}={}){const d=this.getStack();d&&d.promote(this,c),a&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let l=!1;const{latestValues:c}=a;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const d={};c.z&&Bb("z",a,d,this.animationValues);for(let u=0;u<zb.length;u++)Bb(`rotate${zb[u]}`,a,d,this.animationValues),Bb(`skew${zb[u]}`,a,d,this.animationValues);a.render();for(const u in d)a.setStaticValue(u,d[u]),this.animationValues&&(this.animationValues[u]=d[u]);a.scheduleRender()}applyProjectionStyles(a,l){if(!this.instance||this.isSVG)return;if(!this.isVisible){a.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,a.visibility="",a.opacity="",a.pointerEvents=Dg(l==null?void 0:l.pointerEvents)||"",a.transform=c?c(this.latestValues,""):"none";return}const d=this.getLead();if(!this.projectionDelta||!this.layout||!d.target){this.options.layoutId&&(a.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,a.pointerEvents=Dg(l==null?void 0:l.pointerEvents)||""),this.hasProjected&&!Dl(this.latestValues)&&(a.transform=c?c({},""):"none",this.hasProjected=!1);return}a.visibility="";const u=d.animationValues||d.latestValues;this.applyTransformsToTarget();let p=uke(this.projectionDeltaWithTransform,this.treeScale,u);c&&(p=c(u,p)),a.transform=p;const{x:h,y:m}=this.projectionDelta;a.transformOrigin=`${h.origin*100}% ${m.origin*100}% 0`,d.animationValues?a.opacity=d===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:a.opacity=d===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const x in mw){if(u[x]===void 0)continue;const{correct:v,applyTo:S,isCSSVariable:b}=mw[x],g=p==="none"?u[x]:v(u[x],d);if(S){const w=S.length;for(let k=0;k<w;k++)a[S[k]]=g}else b?this.options.visualElement.renderState.vars[x]=g:a[x]=g}this.options.layoutId&&(a.pointerEvents=d===this?Dg(l==null?void 0:l.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(a=>{var l;return(l=a.currentAnimation)==null?void 0:l.stop()}),this.root.nodes.forEach(zP),this.root.sharedNodes.clear()}}}function kke(e){e.updateLayout()}function jke(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:o}=e.layout,{animationType:s}=e.options,a=t.source!==e.layout.source;if(s==="size")vi(p=>{const h=a?t.measuredBox[p]:t.layoutBox[p],m=kr(h);h.min=r[p].min,h.max=h.min+m});else if(s==="x"||s==="y"){const p=s==="x"?"y":"x";gw(a?t.measuredBox[p]:t.layoutBox[p],r[p])}else rH(s,t.layoutBox,r)&&vi(p=>{const h=a?t.measuredBox[p]:t.layoutBox[p],m=kr(r[p]);h.max=h.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[p].max=e.relativeTarget[p].min+m)});const l=jd();Pf(l,r,t.layoutBox);const c=jd();a?Pf(c,e.applyTransform(o,!0),t.measuredBox):Pf(c,r,t.layoutBox);const d=!ZW(l);let u=!1;if(!e.resumeFrom){const p=e.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:h,layout:m}=p;if(h&&m){const x=e.options.layoutAnchor||void 0,v=jn();Vv(v,t.layoutBox,h.layoutBox,x);const S=jn();Vv(S,r,m.layoutBox,x),JW(v,S)||(u=!0),p.options.layoutRoot&&(e.relativeTarget=S,e.relativeTargetOrigin=v,e.relativeParent=p)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:t,delta:c,layoutDelta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:r}=e.options;r&&r()}e.options.transition=void 0}function Cke(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function Tke(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Pke(e){e.clearSnapshot()}function zP(e){e.clearMeasurements()}function Eke(e){e.isLayoutDirty=!0,e.updateLayout()}function BP(e){e.isLayoutDirty=!1}function Rke(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Mke(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function $P(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Ike(e){e.resolveTargetDelta()}function Ake(e){e.calcProjection()}function Dke(e){e.resetSkewAndRotation()}function Lke(e){e.removeLeadSnapshot()}function _P(e,t,n){e.translate=vt(t.translate,0,n),e.scale=vt(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function WP(e,t,n,r){e.min=vt(t.min,n.min,r),e.max=vt(t.max,n.max,r)}function Oke(e,t,n,r){WP(e.x,t.x,n.x,r),WP(e.y,t.y,n.y,r)}function Nke(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Fke={duration:.45,ease:[.4,0,.1,1]},HP=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),UP=HP("applewebkit/")&&!HP("chrome/")?Math.round:Mo;function VP(e){e.min=UP(e.min),e.max=UP(e.max)}function zke(e){VP(e.x),VP(e.y)}function rH(e,t,n){return e==="position"||e==="preserve-aspect"&&!ike(DP(t),DP(n),.2)}function Bke(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const $ke=nH({attachResizeListener:(e,t)=>E0(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),$b={current:void 0},oH=nH({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!$b.current){const e=new $ke({});e.mount(window),e.setOptions({layoutScroll:!0}),$b.current=e}return $b.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Eu=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function qP(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function _ke(...e){return t=>{let n=!1;const r=e.map(o=>{const s=qP(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():qP(e[o],null)}}}}function Wke(...e){return f.useCallback(_ke(...e),e)}class Hke extends f.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(Eg(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const r=n.offsetParent,o=Eg(r)&&r.offsetWidth||0,s=Eg(r)&&r.offsetHeight||0,a=getComputedStyle(n),l=this.props.sizeRef.current;l.height=parseFloat(a.height),l.width=parseFloat(a.width),l.top=n.offsetTop,l.left=n.offsetLeft,l.right=o-l.width-l.left,l.bottom=s-l.height-l.top,l.direction=a.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Uke({children:e,isPresent:t,anchorX:n,anchorY:r,root:o,pop:s}){var h;const a=f.useId(),l=f.useRef(null),c=f.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:d}=f.useContext(Eu),u=s!==!1?((h=e.props)==null?void 0:h.ref)??(e==null?void 0:e.ref):void 0,p=Wke(l,u);return f.useInsertionEffect(()=>{const{width:m,height:x,top:v,left:S,right:b,bottom:g,direction:w}=c.current;if(t||s===!1||!l.current||!m||!x)return;const k=w==="rtl",C=n==="left"?k?`right: ${b}`:`left: ${S}`:k?`left: ${S}`:`right: ${b}`,T=r==="bottom"?`bottom: ${g}`:`top: ${v}`;l.current.dataset.motionPopId=a;const P=document.createElement("style");d&&(P.nonce=d);const R=o??document.head;return R.appendChild(P),P.sheet&&P.sheet.insertRule(`
430
+ 该条目已从 ISSUES.md 移除并交由本会话处理。请调查并解决上述问题;如需持久记录结论,写入项目上下文相应文件。`}const sc="'IBM Plex Mono',monospace";function M2e(e){const t=O(),{entries:n,selectedId:r,armed:o,pending:s}=e,a=n.length,l=a>0,c=n.find(u=>u.id===r)??n[0]??null,d=c?D$(c):null;return i.jsxs(i.Fragment,{children:[i.jsx("div",{onClick:e.onClose,style:{position:"fixed",inset:0,background:"var(--overlay-scrim-soft)",zIndex:60,animation:"cxfade .18s ease"}}),i.jsxs("div",{"data-issue-center":"","data-issue-selected":(c==null?void 0:c.id)??"",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:1150,maxWidth:"94vw",height:730,maxHeight:"90vh",background:"var(--proto-card)",borderRadius:14,boxShadow:"var(--shadow-overlay-strong)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[i.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:9,padding:"12px 20px",borderBottom:"1px solid var(--proto-line)"},children:[i.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:t.issuesTitle}),l&&i.jsx("span",{style:{font:`600 10.5px ${sc}`,color:"var(--proto-muted)",background:"var(--proto-line-2)",padding:"2px 9px",borderRadius:999,marginLeft:2},children:a}),i.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${sc}`,color:"var(--proto-muted-3)"},children:e.projectId?`${e.projectId}/ISSUES.md`:"ISSUES.md"}),i.jsx("span",{onClick:e.onClose,style:{font:`500 9.5px ${sc}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),i.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[!l&&i.jsx(I2e,{}),l&&i.jsxs(i.Fragment,{children:[i.jsx(A2e,{entries:n,selectedId:(c==null?void 0:c.id)??null,count:a,onSelect:e.onSelect}),d&&i.jsx(D2e,{detail:d,armed:o,pending:s,onArm:e.onArm,onCancelArm:e.onCancelArm,onDelete:e.onDelete,onHandle:e.onHandle})]})]})]})]})}function I2e(){const e=O();return i.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:9,background:"var(--proto-rail)"},children:[i.jsx("span",{style:{width:34,height:34,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:15,fontWeight:700},children:"✓"}),i.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--proto-ink)"},children:e.isEmptyTitle}),i.jsx("div",{style:{fontSize:11,color:"var(--proto-muted-2)"},children:e.isEmptyDesc})]})}function A2e({entries:e,selectedId:t,count:n,onSelect:r}){const o=O();return i.jsxs("div",{style:{width:400,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{padding:"14px 18px 9px",fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)",flex:"none"},children:[o.isListLabel," · ",n]}),i.jsx("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"0 12px",display:"flex",flexDirection:"column",gap:8},children:e.map(s=>{const a=R2e(s),l=s.id===t;return i.jsxs("div",{"data-issue-id":s.id,onClick:()=>r(s.id),style:{background:"var(--proto-card)",border:`1px solid ${l?"var(--proto-accent-border)":"var(--proto-line-2)"}`,borderRadius:10,padding:"11px 13px",boxShadow:l?"var(--focus-ring-accent)":"none",cursor:"pointer",flex:"none"},children:[i.jsx("div",{style:{fontSize:12.5,fontWeight:600,color:l?"var(--proto-ink)":"var(--proto-ink-2)",lineHeight:1.35},children:a.title}),a.date&&i.jsx("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:6},children:i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${sc}`,color:"var(--proto-faint)"},children:a.date})})]},s.id)})}),i.jsx("div",{style:{marginTop:"auto",padding:"12px 18px",borderTop:"1px solid var(--proto-line-2)",font:`400 9.5px ${sc}`,color:"var(--proto-faint)",lineHeight:1.7,flex:"none"},children:o.isNoStatusNote})]})}const N$={fontSize:10,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",paddingTop:2};function D2e({detail:e,armed:t,pending:n,onArm:r,onCancelArm:o,onDelete:s,onHandle:a}){const l=O();return i.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"18px 24px 0"},children:[i.jsx("div",{style:{fontSize:16,fontWeight:650,color:"var(--proto-ink)",lineHeight:1.35},children:e.title}),e.date&&i.jsx("div",{style:{display:"flex",alignItems:"center",gap:14,marginTop:8,font:`400 10.5px ${sc}`,color:"var(--proto-muted-3)"},children:i.jsxs("span",{children:[l.isRecorded," ",e.date]})}),i.jsxs("div",{style:{margin:"16px 0 14px",display:"grid",gridTemplateColumns:"76px 1fr",rowGap:10,columnGap:14,fontSize:12,lineHeight:1.6},children:[e.desc&&i.jsxs(i.Fragment,{children:[i.jsx("span",{style:N$,children:l.isDescLabel}),i.jsx("span",{style:{color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e.desc})]}),e.fields.map((c,d)=>i.jsx(L2e,{label:c.label,text:c.text},`${c.label}-${d}`))]})]}),i.jsxs("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"14px 22px",display:"flex",alignItems:"center",gap:10},children:[i.jsx("span",{style:{font:`400 10px ${sc}`,color:"var(--proto-faint)",lineHeight:1.6,flex:1,minWidth:0},children:l.isFootNote}),!t&&i.jsxs(i.Fragment,{children:[i.jsx(Mm,{"data-action":"arm-delete",onClick:n?void 0:()=>r(),base:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-danger-bg)",borderRadius:8,padding:"7px 16px",color:"var(--proto-danger)",background:"var(--proto-card)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-danger-bg)"},children:l.isDelete}),i.jsx(Mm,{"data-action":"handle",onClick:n?void 0:()=>a(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 22px",color:"var(--ink-solid-fg)",background:"var(--proto-accent)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-accent-strong)"},children:l.isHandle})]}),t&&i.jsxs(i.Fragment,{children:[i.jsx(Mm,{"data-action":"cancel-delete",onClick:n?void 0:()=>o(),base:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"7px 16px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-alt)"},children:l.cancel}),i.jsx(Mm,{"data-action":"confirm-delete",onClick:n?void 0:()=>s(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 20px",color:"var(--ink-solid-fg)",background:"var(--proto-danger)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{opacity:.88},children:l.isConfirmDelete})]})]})]})}function L2e({label:e,text:t}){return i.jsxs(i.Fragment,{children:[i.jsx("span",{style:N$,children:e}),i.jsx("span",{style:{color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})]})}function Mm({base:e,hover:t,onClick:n,children:r,...o}){const[s,a]=f.useState(!1);return i.jsx("span",{...o,onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:s?{...e,...t}:e,children:r})}function O2e({open:e,initialId:t,onClose:n}){const r=O(),o=he(),s=Ve(),a=Xe(),{toast:l}=Fn(),{currentProjectId:c}=zt(),{setSelectedSession:d}=Vi(),u=ae({...o.issues.list.queryOptions({projectId:c??""}),enabled:e&&!!c}),p=f.useMemo(()=>u.data??[],[u.data]),[h,m]=f.useState(null),[x,v]=f.useState(!1),S=L$(p,h??t),b=()=>s.invalidateQueries(o.issues.list.queryFilter()),g=Re(o.issues.delete.mutationOptions({onSettled:()=>{v(!1),b()}})),w=g.isPending;return f.useEffect(()=>{e||(v(!1),m(null))},[e]),f.useEffect(()=>{v(!1)},[S]),f.useEffect(()=>{if(!e)return;const k=C=>{C.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e,n]),e?i.jsx(M2e,{entries:p,selectedId:S,projectId:c,armed:x,pending:w,onSelect:m,onClose:n,onArm:()=>v(!0),onCancelArm:()=>v(!1),onDelete:k=>{c&&g.mutate({projectId:c,id:k},{onSuccess:()=>l({title:r.isToastDeleted,tone:"done"})})},onHandle:k=>{if(!c)return;const C=p.find(R=>R.id===k);if(!C)return;const T=O$(c,C),P=xh({isDraft:!0,projectId:c});ws(P,{text:T,attachments:[]}),d(nl),n(),a("/workbench"),g.mutate({projectId:c,id:k},{onSuccess:()=>l({title:r.isToastHandled,tone:"done"})})}}):null}const F$=f.createContext(null);function N2e({children:e}){const[t,n]=f.useState(!1),[r,o]=f.useState(null),s=f.useCallback(c=>{o(c??null),n(!0)},[]),a=f.useCallback(()=>{n(!1),o(null)},[]),l=f.useMemo(()=>({open:s,close:a}),[s,a]);return i.jsxs(F$.Provider,{value:l,children:[e,i.jsx(O2e,{open:t,initialId:r,onClose:a})]})}function F2e(){const e=f.useContext(F$);if(!e)throw new Error("useIssues must be used within an IssuesProvider");return e}const z2e=96;function z$(e,t=z2e){const n=(e??"").replace(/\s+/g," ").trim();return n.length<=t?n:n.slice(0,t-1).trimEnd()+"…"}function B2e(e){const t=(e.sessionName??"").trim();return{id:e.id,level:e.level??"info",title:t||"New message",meta:z$(e.text),ts:e.ts??new Date().toISOString(),sessionId:e.sessionId,projectId:e.projectId}}function $2e(e){const t=(e.title??"").trim();return{id:e.id,level:e.level??"info",title:t||"System notice",meta:z$(e.text),ts:e.ts??new Date().toISOString(),sessionId:"",projectId:null}}function _2e(e){return e==="info"}const W2e=3,bT=50;function H2e(e,t){return e.sessionId===t.sessionId&&e.meta===t.meta}function U2e(e,t){const n=e[e.length-1];if(n&&H2e(n,t))return e;const r=[...e,t];return r.length>bT?r.slice(r.length-bT):r}function V2e(e,t){return e.filter(n=>n.id!==t)}function B$(e,t=W2e){return e.length<=t?{visible:e,overflow:0}:{visible:e.slice(e.length-t),overflow:e.length-t}}const q2e={info:"bg-proto-accent-bg text-proto-accent",warning:"bg-pill-waiting-bg text-pill-waiting-fg",error:"bg-pill-failed-bg text-pill-failed-fg"},K2e={info:"i",warning:"!",error:"✕"};function G2e(e,t=Date.now()){const n=Date.parse(e);if(Number.isNaN(n))return"now";const r=Math.max(0,Math.floor((t-n)/1e3));if(r<45)return"now";const o=Math.floor(r/60);if(o<60)return`${o}m`;const s=Math.floor(o/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function Y2e({item:e,onDismiss:t,onActivate:n}){const r=_2e(e.level);return i.jsxs("div",{role:"status",onClick:()=>n(e),className:"group relative w-[380px] cursor-pointer overflow-hidden rounded-[11px] border border-proto-line bg-surface-card px-[13px] pb-[12px] pt-[11px] shadow-toast animate-toast-in motion-reduce:animate-none",children:[i.jsxs("div",{className:"flex items-start gap-[10px]",children:[i.jsx("span",{className:["flex h-[24px] w-[24px] flex-none items-center justify-center rounded-[7px] text-[11px] font-bold",q2e[e.level]].join(" "),"aria-hidden":!0,children:K2e[e.level]}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-baseline gap-[8px]",children:[i.jsx("span",{className:"text-[12.5px] font-semibold text-proto-ink",children:e.title}),i.jsx("span",{className:"ml-auto font-mono text-[10px] text-proto-faint",children:G2e(e.ts)}),i.jsx("button",{type:"button","aria-label":"Dismiss",onClick:o=>{o.stopPropagation(),t(e.id)},className:"flex-none text-[12px] leading-none text-proto-faint transition-colors hover:text-proto-muted",children:"✕"})]}),i.jsx("div",{className:"mt-[3px] truncate font-mono text-[10.5px] text-proto-muted-2",children:e.meta})]})]}),r?i.jsx("div",{className:"absolute bottom-0 left-0 h-[2px] bg-proto-accent opacity-40 animate-toastbar group-hover:[animation-play-state:paused]",onAnimationEnd:o=>{o.animationName==="toastbar"&&t(e.id)}}):null]})}function Q2e({items:e,onDismiss:t,onActivate:n}){const[r,o]=f.useState(!1);if(e.length===0)return null;const{visible:s,overflow:a}=B$(e),l=r?e:s;return i.jsxs("div",{className:"pointer-events-none fixed bottom-0 right-0 z-50 m-2g flex w-[380px] max-w-[calc(100vw-2rem)] flex-col items-end gap-[10px]",children:[l.map(c=>i.jsx("div",{className:"pointer-events-auto w-full",children:i.jsx(Y2e,{item:c,onDismiss:t,onActivate:n})},c.id)),a>0&&!r?i.jsxs("button",{type:"button",onClick:()=>o(!0),className:"pointer-events-auto flex items-center gap-[7px] rounded-full border border-proto-line bg-surface-card px-[12px] py-[5px] shadow-toast-pill",children:[i.jsxs("span",{className:"font-mono text-[10.5px] font-semibold text-proto-muted",children:["+",a]}),i.jsx("span",{className:"text-[11px] text-proto-muted-2",children:"more · click to expand"})]}):null]})}function X2e(e,t,n){e.set(t,n)}function W5(e,t){const n=e.get(t)??null;return e.delete(t),n}const Z2e=["session.message","session.status"];function J2e({onMessage:e,onTurnEnd:t}){qs(Z2e,n=>{if(n.type==="session.message"){const r=n.payload;if(!r||r.role!=="assistant")return;const o=(r.text??"").trim();if(!o||!r.sessionId)return;e({sessionId:r.sessionId,channel:r.channel??null,text:o,ts:r.ts??null});return}if(n.type==="session.status"){const r=n.payload;if(!r||!r.sessionId||r.running!==!1)return;t(r.sessionId)}})}function e4e(e){qs(t$,t=>{if(t.type!=="system.notice")return;const n=t.payload,r=((n==null?void 0:n.text)??"").trim();r&&e({level:(n==null?void 0:n.level)??"info",text:r,title:(n==null?void 0:n.title)??null,ts:(n==null?void 0:n.ts)??null})})}function wT(e){const t=new Map;for(const n of e??[])t.set(n.sessionId,{name:n.label??n.name,projectId:n.projectId});return t}function t4e(){const e=he(),t=ae(e.sessions.list.queryOptions({origin:"direct"})),n=f.useMemo(()=>wT(t.data),[t.data]),r=f.useCallback(async()=>{const o=await t.refetch();return o.isError?null:wT(o.data)},[t.refetch]);return{map:n,refresh:r}}function n4e(){const e=f.useRef(!1);return f.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function r4e(e,t){const n=n4e();return f.useCallback(r=>{(async()=>{try{if(t&&await t(r))return}catch{}n.current&&e(o=>U2e(o,r))})()},[t,n,e])}function o4e(e,t,n,r,o){if(!e.has(o))return{consumed:!0,item:null};if(n(o))return W5(e,o),{consumed:!0,item:null};const s=t.get(o);if(!s)return{consumed:!1,item:null};const a=W5(e,o);return{consumed:!0,item:B2e({id:r("dmn"),sessionId:o,sessionName:s.name,projectId:s.projectId,text:a.text,ts:a.ts})}}function i4e(e,t,n,r){const o=f.useRef(new Map),s=f.useRef(new Set),a=f.useCallback((d,u=e.map)=>{const p=o4e(o.current,u,t,n,d);return p.consumed?(s.current.delete(d),p.item&&r(p.item),!0):!1},[r,t,e.map,n]),l=f.useCallback(d=>{X2e(o.current,d.sessionId,{text:d.text,ts:d.ts??new Date().toISOString()})},[]),c=f.useCallback(d=>{!o.current.has(d)||a(d)||(s.current.add(d),e.refresh().then(u=>{!u||a(d,u)||(W5(o.current,d),s.current.delete(d))}).catch(()=>{}))},[a,e]);f.useEffect(()=>{s.current.forEach(d=>{a(d)})},[a]),J2e({onMessage:l,onTurnEnd:c})}function s4e(e,t){const n=f.useCallback(r=>{t($2e({id:e("sysn"),level:r.level,text:r.text,title:r.title??void 0,ts:r.ts??void 0}))},[t,e]);e4e(n)}function $$({isSessionOpen:e,externalDelivery:t}){const[n,r]=f.useState([]),o=f.useRef(0),s=t4e(),a=r4e(r,t),l=f.useCallback(d=>`${d}-${o.current++}`,[]);i4e(s,e,l,a),s4e(l,a);const c=f.useCallback(d=>{r(u=>V2e(u,d))},[]);return{items:n,dismiss:c}}function a4e(){const e=Xe(),t=fo(),{selectedSessionId:n,setSelectedSession:r}=Vi(),{setCurrentProject:o}=zt(),s=f.useCallback(d=>t.pathname.startsWith("/workbench")&&n===d,[t.pathname,n]),{items:a,dismiss:l}=$$({isSessionOpen:s}),c=f.useCallback(d=>{d.sessionId&&(d.projectId&&o(d.projectId),r(d.sessionId),e("/workbench")),l(d.id)},[l,e,o,r]);return i.jsx(Q2e,{items:a,onDismiss:l,onActivate:c})}const l4e="fixed inset-0 z-40 bg-state-ink/[0.44] data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none",c4e="fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2 w-[420px] max-w-[calc(100vw-32px)] box-border rounded-[14px] bg-surface-card p-5 pb-4 shadow-overlay-strong focus:outline-none data-[state=open]:animate-zoom-in data-[state=closed]:animate-zoom-out motion-reduce:animate-none";function d4e(e){return i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"flex h-9 w-9 flex-none items-center justify-center rounded-card bg-proto-accent-bg text-state-run",children:i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[i.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),i.jsx("path",{d:"M3.5 16.5h13"})]})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx(fl,{className:"text-body font-semibold text-state-ink",children:e.title}),i.jsx("div",{className:"mt-[3px] font-mono text-[10.5px] font-medium text-proto-muted-3",children:e.summary})]})]})}function _$(e){return i.jsx(ul,{open:!0,onOpenChange:t=>{t||e.onDismiss()},children:i.jsxs(pl,{children:[i.jsx(Ms,{className:l4e}),i.jsxs($s,{className:c4e,"aria-describedby":e.descriptionId,children:[i.jsx(d4e,{title:e.title,summary:e.summary}),i.jsx(Z0,{id:e.descriptionId,className:"mb-4 mt-3 text-[12.5px] leading-[1.65] text-proto-muted",children:e.description}),e.children]})]})})}const u4e="frontend-update-staged";function ST(e){return e.slice(0,8)}function p4e(e){const t=ST(e.version),n=e.fromVersion?ST(e.fromVersion):"";return n&&n!==t?`${n} → ${t}`:t}function W$(e){if(!e||e<=0)return null;const t=e>=1024*1024?1:0;return K3(e,{fractionDigits:t,maxUnit:"MB"})}function H$(e){const t=W$(e.size),n=[p4e(e)];return t&&n.push(t),n.push("已下载"),n.join(" · ")}function LS(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.version!="string"||!t.version?null:{version:t.version,fromVersion:typeof t.fromVersion=="string"&&t.fromVersion?t.fromVersion:void 0,size:typeof t.size=="number"?t.size:void 0}}async function f4e(e){return dr()?x1(u4e,t=>{const n=LS(t);n&&e(n)}):()=>{}}async function h4e(){if(!dr())return null;const e=await bt("get_staged_update");return e.ok?LS(e.value):null}async function m4e(){dr()&&await bt("apply_frontend_update")}const g4e="app-update-available";function H5(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.version!="string"||!t.version||typeof t.kind!="string"||!t.kind)return null;const n={version:t.version,kind:t.kind};return typeof t.releaseUrl=="string"&&t.releaseUrl&&(n.releaseUrl=t.releaseUrl),typeof t.notes=="string"&&t.notes&&(n.notes=t.notes),typeof t.size=="number"&&t.size>0&&(n.size=t.size),n}function U$(e){const t=[`Cortex ${e.version}`],n=W$(e.size);return n&&t.push(n),t.push("已下载"),t.join(" · ")}function V$(e){switch(e){case"appimage":return"重启更新";case"nsis":return"运行安装程序";case"apk":return"安装";case"dmg":case"deb":case"rpm":return"打开安装包";default:return"更新"}}function q$(e){switch(e){case"appimage":return"新版本已在后台下载并校验完成,点击后自动替换并重启。运行中的线程在服务端继续执行,不受影响。";case"nsis":return"新版本已在后台下载并校验完成。点击后将退出 App 并启动安装程序,按提示完成安装后重新打开即可。";case"apk":return"新版本已在后台下载并校验完成。点击安装后按系统提示完成升级,运行中的线程在服务端继续执行。";case"dmg":return"新版本已在后台下载并校验完成。将打开磁盘映像,把 Cortex 拖入 Applications 即完成升级。";case"deb":case"rpm":return"新版本已在后台下载并校验完成。将打开安装包,用系统安装器完成升级后重新打开 App。";default:return"新版本已在后台下载并校验完成。"}}let K$=null;const U5=new Set;function w0(e){K$=e;for(const t of U5)t()}function v4e(e){return U5.add(e),()=>U5.delete(e)}function x4e(){return K$}async function y4e(){if(!dr())return()=>{};const e=await x1(g4e,n=>{const r=H5(n);r&&w0(r)}),t=await bt("get_app_update");if(t.ok){const n=H5(t.value);n&&w0(n)}return e}async function b4e(){if(!dr())return null;const e=await bt("install_app_update");if(e.ok)return typeof e.value=="string"?e.value:null;if(e.reason==="failed"&&typeof e.error=="string"&&e.error)throw new Error(e.error);return null}async function w4e(){w0(null),dr()&&await bt("skip_app_update")}const kT="box-border flex h-9 items-center rounded-[9px] border border-proto-line px-4 text-[12.5px] font-semibold text-proto-muted transition-colors hover:bg-surface-canvas-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40";function S4e(e){return i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:e.onSkip,className:kT,children:"跳过此版本"}),i.jsx("button",{type:"button",onClick:e.onDismiss,className:kT,children:"稍后"}),i.jsx("button",{type:"button",onClick:e.onInstall,disabled:e.busy,className:"box-border flex h-9 items-center rounded-[9px] bg-state-ink px-4 text-[12.5px] font-semibold text-surface-card transition-opacity hover:opacity-90 disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:e.busy?"正在处理…":V$(e.update.kind)})]})}function k4e(e){return i.jsxs(_$,{title:"App 新版本已就绪",summary:U$(e.update),descriptionId:"app-update-desc",description:q$(e.update.kind),onDismiss:e.onDismiss,children:[e.error?i.jsxs("div",{className:"mb-3 text-[11.5px] leading-snug text-state-fail",children:["安装失败:",e.error]}):null,i.jsx(S4e,{...e})]})}function j4e(e){return i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:e.onDismiss,className:"box-border flex h-9 items-center rounded-[9px] border border-proto-line px-4 text-[12.5px] font-semibold text-proto-muted transition-colors hover:bg-surface-canvas-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"忽略"}),i.jsx("button",{type:"button",onClick:e.onApply,className:"box-border flex h-9 items-center rounded-[9px] bg-state-ink px-4 text-[12.5px] font-semibold text-surface-card transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"重启 App"})]})}function C4e(e){return i.jsx(_$,{title:"新版本已就绪",summary:H$(e.update),descriptionId:"hot-update-desc",description:"热更新已在后台下载完成,重启 App 后生效。运行中的线程在服务端继续执行,不受重启影响;未发送的草稿会保留。",onDismiss:e.onDismiss,children:i.jsx(j4e,{onApply:e.onApply,onDismiss:e.onDismiss})})}const Dv=new Set,V5=new Set;let od=null;const q5=()=>od!==null;function G$(e){return Dv.add(e),()=>{Dv.delete(e)}}function Y$(e){return V5.add(e),()=>{V5.delete(e)}}function kb(e){return{ui:{status:"error",reason:e},shell:{status:"error",reason:e}}}function T4e(e){if(!e||typeof e!="object")return null;const t=e;return!["available","current","skipped","error"].includes(t.status)||t.reason!==void 0&&typeof t.reason!="string"?null:t}function jT(e,t){const n=T4e(e);if(!n)return null;const r=n.update===void 0?void 0:t(n.update);return r===null||n.status==="available"&&!r||n.status==="current"&&r?null:{status:n.status,...r?{update:r}:{},...n.reason!==void 0?{reason:n.reason}:{}}}async function P4e(){var r,o;const e=await bt("check_for_updates");if(hh(e))return kb("unsupported_shell");if(!e.ok)return kb("check_failed");const t=jT((r=e.value)==null?void 0:r.ui,LS),n=jT((o=e.value)==null?void 0:o.shell,H5);return t&&n?{ui:t,shell:n}:kb("invalid_report")}function E4e(){if(od)return od;od=P4e().then(e=>{for(const t of V5)t(e);return e}).finally(()=>{od=null;for(const e of Dv)e()});for(const e of Dv)e();return od}const R4e=["button","checkbox","radio","submit","reset","file","range","color"];function M4e(e){return e?e.tagName==="TEXTAREA"?!0:e.tagName==="INPUT"?!R4e.includes(e.type):e.isContentEditable===!0:!1}function I4e(){return typeof document<"u"&&M4e(document.activeElement)}function Q$(e){const[t,n]=f.useState(null);return f.useEffect(()=>{if(e===null){n(null);return}const r=()=>{I4e()||n(e)};if(r(),typeof document>"u")return;const o=()=>window.setTimeout(r,0);return document.addEventListener("focusout",o),()=>document.removeEventListener("focusout",o)},[e]),e===t?t:null}function A4e(){f.useEffect(()=>{let e=!1,t=()=>{};return y4e().then(n=>{e?n():t=n}),()=>{e=!0,t()}},[])}function D4e(e,t){const[n,r]=f.useState(!1),[o,s]=f.useState(null),a=f.useCallback(()=>{r(!0),s(null),b4e().then(l=>{r(!1),t(e),l!==null&&w0(null)}).catch(l=>{r(!1),s(l.message)})},[t,e]);return{busy:n,error:o,install:a}}function L4e(){const e=f.useSyncExternalStore(v4e,x4e),[t,n]=f.useState(null),r=(e==null?void 0:e.version)===t?null:e,o=Q$(r),s=D4e((e==null?void 0:e.version)??(o==null?void 0:o.version)??null,n);A4e(),f.useEffect(()=>Y$(({shell:c})=>{c.update&&(n(null),w0(c.update))}),[]);const a=f.useCallback(()=>{w4e()},[]),l=f.useCallback(()=>{n((e==null?void 0:e.version)??(o==null?void 0:o.version)??null)},[e,o]);return{pending:e,update:o,...s,skip:a,dismiss:l}}function O4e(e){const[t,n]=f.useState(null);return f.useEffect(()=>{let r=!1,o=()=>{};const s=l=>{!r&&!e.current&&n(l)};f4e(s).then(l=>{r?l():o=l}),h4e().then(l=>{l&&s(l)});const a=Y$(({ui:l})=>{l.update&&(e.current=!1,n(l.update))});return()=>{r=!0,o(),a()}},[e]),[t,n]}function N4e(){const e=f.useRef(!1),[t,n]=O4e(e),r=Q$(t),o=f.useCallback(()=>{m4e()},[]),s=f.useCallback(()=>{e.current=!0,n(null)},[n]);return{staged:r,apply:o,dismiss:s}}function X$(){const e=L4e(),t=N4e();return f.useSyncExternalStore(G$,q5)?null:e.update?{kind:"app",update:e.update,busy:e.busy,error:e.error,install:e.install,skip:e.skip,dismiss:e.dismiss}:!e.pending&&t.staged?{kind:"hot",update:t.staged,apply:t.apply,dismiss:t.dismiss}:null}function F4e(){const e=X$();return e?e.kind==="hot"?i.jsx(C4e,{update:e.update,onApply:e.apply,onDismiss:e.dismiss}):i.jsx(k4e,{update:e.update,busy:e.busy,error:e.error,onInstall:e.install,onSkip:e.skip,onDismiss:e.dismiss}):null}function z4e(e,t){return e==="pending"?"connected":e==="connecting"?t?"reconnecting":"connecting":t?"disconnected":"connecting"}function Z$(e){switch(e){case"connected":return{color:"var(--proto-success)",pulse:!1};case"connecting":case"reconnecting":return{color:"var(--proto-amber)",pulse:!0};case"disconnected":return{color:"var(--proto-danger)",pulse:!1}}}function J$(e){switch(e){case"connected":return"connConnected";case"connecting":return"connConnecting";case"reconnecting":return"connReconnecting";case"disconnected":return"connDisconnected"}}const e_=f.createContext("connecting");function t_({children:e}){const{connState:t,hasConnected:n}=ES(),r=z4e(t,n);return i.jsx(e_.Provider,{value:r,children:e})}function OS(){return f.useContext(e_)}function NS(e){var t;return e.claimThreadId?e.claimThreadId:(t=e.claimedBy)!=null&&t.startsWith("thr_")?e.claimedBy:null}function n_(e){return e.status==="done"?"done":e.blockedBy!=null?"blocked":e.claimedBy!=null?"in-progress":e.approvalNeeded===!0?"approval-needed":e.actionable?"actionable":"waiting"}function B4e(e){const t=e.claimedBy!=null,n=t&&e.claimedBy!=="task-dispatcher"?e.claimedBy:null,r=t?NS(e):null;return{claimed:t,id:n,threadId:r,displayId:r??n}}function CT(e){const t=Date.parse(e.startedAt);return Number.isNaN(t)?Number.NEGATIVE_INFINITY:t}function $4e(e){return e.map((t,n)=>({dispatch:t,index:n})).sort((t,n)=>CT(n.dispatch)-CT(t.dispatch)||t.index-n.index).map(({dispatch:t})=>t)}function r_(e){const t=e.evidence.completingExecutionId,n=$4e(e.dispatches).map(o=>({dispatch:o,isCompleting:t!=null&&o.executionId===t})),r=e.evidence;return{evidence:r,hasEvidence:r.completed&&(r.completedNote!=null||r.completingOutput!=null||r.completedAt!=null),dispatches:n,newestDispatch:n[0]??null,completingExecution:n.find(o=>o.isCompleting)??null}}function TT(e,t,n){return{relation:e,id:t,known:n!=null,task:n??null,statusKind:n?n_(n):null}}function _4e(e,t){const n=new Map(t.map(s=>[s.id,s])),r=e.dependsOn.map(s=>TT("upstream",s,n.get(s))),o=t.filter(s=>s.id!==e.id&&s.dependsOn.includes(e.id)).map(s=>TT("downstream",s.id,s));return{upstream:r,downstream:o}}function o_(e,t,n){const r=n?r_(n):null,o=_4e(e,t);return{task:e,statusKind:n_(e),claim:B4e(e),completedAt:(r==null?void 0:r.evidence.completedAt)??e.completedAt??null,...o,verification:r}}function Im(e){return String(e).padStart(2,"0")}function k1(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:`${`${t.getFullYear()}-${Im(t.getMonth()+1)}-${Im(t.getDate())}`} ${Im(t.getHours())}:${Im(t.getMinutes())}`}const W4e={done:{bg:"var(--pill-done-bg)",fg:"var(--pill-done-fg)",text:"✓ done"},blocked:{bg:"var(--pill-failed-bg)",fg:"var(--pill-failed-fg)",text:"blocked"},"approval-needed":{bg:"var(--pill-waiting-bg)",fg:"var(--pill-waiting-fg)",text:"approval-needed"},actionable:{bg:"var(--pill-running-bg)",fg:"var(--pill-running-fg)",text:"actionable"},waiting:{bg:"var(--pill-cancelled-bg)",fg:"var(--pill-cancelled-fg)",text:"waiting on deps"}};function H4e(e){return e.statusKind!=="in-progress"?W4e[e.statusKind]:{bg:"var(--pill-running-bg)",fg:"var(--pill-running-fg)",text:`● in-progress${e.claim.displayId?` · ${e.claim.displayId}`:""}`}}function U4e(e){return e==="high"?"var(--state-fail)":e==="medium"?"var(--proto-amber)":"var(--proto-faint)"}function V4e(e){return e?e.status==="done"?"var(--state-done)":e.blockedBy!=null?"var(--state-fail)":"var(--state-run)":"var(--proto-faint)"}function q4e(e){const t=e.approvalNeeded;return[{k:"approval-needed",v:t==null?"—":String(t),vColor:t===!0?"var(--pill-waiting-fg)":"var(--proto-ink)"},{k:"approved-at",v:e.approvedAt??"—",vColor:e.approvedAt?"var(--state-done)":"var(--proto-faint)"}]}function K4e(e,t){const n=t.claim.displayId,r=k1(t.completedAt);return[{k:"priority",v:e.priority,vColor:e.priority==="high"?"var(--state-fail)":"var(--proto-ink)"},{k:"status",v:e.status,vColor:"var(--proto-ink)"},...q4e(e),{k:"completed-at",v:r??"—",vColor:r?"var(--state-done)":"var(--proto-faint)"},{k:"template",v:e.template,vColor:"var(--proto-ink)"},{k:"gpu",v:"—",vColor:"var(--proto-faint)"},{k:"claimed-by",v:n??"—",vColor:n?"var(--state-run)":"var(--proto-faint)"}]}function G4e(e){var n;const t=e.statusKind==="done";return{id:e.id,name:((n=e.task)==null?void 0:n.text)??"—",dotColor:V4e(e.task??void 0),idColor:"var(--state-run)",label:e.relation==="upstream"&&t?"upstream · done":e.relation,bg:"var(--proto-rail)",border:"var(--proto-line-2)"}}function Y4e(e,t,n=null){const r=o_(e,t,n),o=[...r.upstream,...r.downstream].map(G4e),s=e.status!=="done"&&e.blockedBy==null;return{id:e.id,title:e.text,pill:H4e(r),priColor:U4e(e.priority),fields:K4e(e,r),deps:o,hasDependencies:o.length>0,canUnblock:e.blockedBy!=null,completable:s,completeBg:s?"var(--proto-accent)":"var(--proto-faint)",completeLabel:e.status==="done"?"Completed":"Complete"}}function Q4e(e){switch(e){case"completed":return"var(--state-done)";case"failed":return"var(--state-fail)";case"running":return"var(--state-run)";case"stale":return"var(--proto-amber)";default:return"var(--proto-muted-2)"}}function X4e(e){if(e==null||!Number.isFinite(e)||e<0)return"—";const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t%60);return`${n}m ${r}s`}function Z4e(e){return e==null||!Number.isFinite(e)?"—":yn(e)}function J4e(e){if(!e)return"—";const t=Date.parse(e);if(Number.isNaN(t))return"—";const n=new Date(t),r=o=>String(o).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}`}function e5e(e){const t=r_(e),n=t.evidence,r=t.dispatches.map(({dispatch:o,isCompleting:s})=>({executionId:o.executionId,type:o.type,status:o.status,statusColor:Q4e(o.status),machine:o.machine??"—",threadId:o.threadId,when:J4e(o.startedAt),duration:X4e(o.durationMs),cost:Z4e(o.cost),isCompleting:s}));return{completed:n.completed,doneWhen:n.doneWhen,completedAt:n.completedAt,completedNote:n.completedNote,completingExecutionId:n.completingExecutionId,completingOutput:n.completingOutput,hasEvidence:t.hasEvidence,dispatches:r,hasDispatches:r.length>0}}const id={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"var(--shadow-card-subtle)"},jb={display:"flex",alignItems:"center",padding:"10px 15px",borderBottom:"1px solid var(--proto-line-2)"},Cb={fontSize:11.5,fontWeight:650,color:"var(--proto-ink)"};function Vc({children:e}){return i.jsx("span",{style:{fontStyle:"italic",color:"var(--proto-faint)"},children:e})}function t5e({label:e,reason:t}){return t==null?null:i.jsxs("div",{"data-task-blocker-card":"true",style:{...id,padding:"10px 15px",background:"var(--proto-danger-bg)"},children:[i.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-danger)"},children:e}),i.jsx("div",{style:{marginTop:5,fontSize:11.5,lineHeight:1.6,color:"var(--proto-danger)",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:t})]})}function n5e({vv:e}){return i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.dispatches.map(t=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 9px",background:t.isCompleting?"var(--proto-accent-bg)":"var(--proto-rail)",border:`1px solid ${t.isCompleting?"var(--proto-accent-bg)":"var(--proto-line-2)"}`,borderRadius:7},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:t.statusColor,flex:"none"}}),i.jsx("span",{style:{font:"600 10px 'IBM Plex Mono',monospace",color:"var(--proto-accent)"},children:t.executionId}),i.jsx("span",{style:{fontSize:9.5,color:"var(--proto-muted-2)"},children:t.machine}),i.jsxs("span",{style:{marginLeft:"auto",font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",flex:"none"},children:[t.when," · ",t.duration," · ",t.cost]})]},t.executionId))})}function r5e({task:e,allTasks:t,pending:n,onClose:r,onComplete:o,onUnblock:s}){const a=O(),l=he(),c=ae(l.tasks.verification.queryOptions({projectId:e.project,taskId:e.id})),d=c.data??null,u=Y4e(e,t,d),p=d?e5e(d):null;return i.jsxs(ur,{chrome:"bare",size:"custom",open:!0,showClose:!1,title:`${u.id} · ${u.title}`,description:e.why??e.doneWhen??u.title,onOpenChange:h=>{h||r()},contentDataAttributes:{"data-task-modal-id":e.id},bodyStyle:{display:"contents"},contentStyle:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:760,maxHeight:"84vh",background:"var(--proto-alt)",borderRadius:14,boxShadow:"var(--shadow-overlay-strong)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[i.jsxs("div",{style:{flex:"none",background:"var(--proto-card)",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"12px 18px"},children:[i.jsx("span",{style:{font:"600 12.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:u.id}),i.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 8px",borderRadius:999,background:u.pill.bg,color:u.pill.fg},children:u.pill.text}),i.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginLeft:4},children:"TASKS.yaml"}),i.jsx("span",{onClick:r,style:{marginLeft:"auto",font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),i.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"14px 18px",display:"grid",gridTemplateColumns:"1.5fr 1fr",gap:12,alignContent:"start"},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,minWidth:0},children:[i.jsxs("div",{style:{...id,padding:"13px 16px"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:u.priColor,flex:"none",marginTop:5}}),i.jsx("div",{style:{fontSize:13.5,fontWeight:650,color:"var(--proto-ink)",lineHeight:1.4},children:u.title})]}),i.jsxs("div",{style:{fontSize:11.5,lineHeight:1.6,color:"var(--proto-muted)",marginTop:7},children:[i.jsx("span",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginRight:7},children:a.tkWhy}),e.why!=null?i.jsx("span",{children:e.why}):i.jsxs(Vc,{children:["— ",a.tkNoWhy]})]}),i.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",margin:"11px 0 5px"},children:a.tkDoneWhen}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:i.jsxs("div",{style:{display:"flex",gap:8,fontSize:11.5,lineHeight:1.5,color:"var(--proto-ink-2)",background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:7,padding:"6px 10px"},children:[i.jsx("span",{style:{width:12,height:12,borderRadius:4,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",boxSizing:"border-box",flex:"none",marginTop:1.5}}),e.doneWhen!=null?i.jsx("span",{children:e.doneWhen}):i.jsxs(Vc,{children:["— ",a.tkNoDoneWhen]})]})})]}),i.jsx(t5e,{label:a.mBlockedPill,reason:e.blockedBy}),i.jsxs("div",{style:id,children:[i.jsxs("div",{style:jb,children:[i.jsx("span",{style:Cb,children:a.tkDispatchHistory}),p&&p.hasDispatches&&i.jsxs("span",{style:{marginLeft:"auto",font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:[p.dispatches.length," run",p.dispatches.length===1?"":"s"]})]}),i.jsx("div",{style:{padding:"10px 15px",fontSize:11,lineHeight:1.55},children:c.isPending?i.jsxs(Vc,{children:["— ",a.tkLoadingDispatch]}):c.isError||!p?i.jsxs(Vc,{children:["— ",a.tkDispatchFailed]}):p.hasDispatches?i.jsx(n5e,{vv:p}):i.jsxs(Vc,{children:["— ",a.tkNoDispatches]})})]})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,minWidth:0},children:[i.jsxs("div",{style:id,children:[i.jsx("div",{style:jb,children:i.jsx("span",{style:Cb,children:a.tkFields})}),i.jsx("div",{style:{padding:"8px 15px 10px",font:"400 10px/2 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:u.fields.map(h=>i.jsxs("div",{style:{display:"flex"},children:[i.jsx("span",{style:{color:"var(--proto-muted-3)"},children:h.k}),i.jsx("span",{style:{marginLeft:"auto",color:h.vColor,textAlign:"right"},children:h.v})]},h.k))})]}),i.jsxs("div",{style:id,children:[i.jsx("div",{style:jb,children:i.jsx("span",{style:Cb,children:a.tkDependencies})}),i.jsx("div",{style:{padding:"10px 15px",display:"flex",flexDirection:"column",gap:5},children:u.hasDependencies?u.deps.map(h=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 9px",background:h.bg,border:`1px solid ${h.border}`,borderRadius:7},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:h.dotColor,flex:"none"}}),i.jsx("span",{style:{font:"600 10.5px 'IBM Plex Mono',monospace",color:h.idColor},children:h.id}),i.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:h.name}),i.jsx("span",{style:{marginLeft:"auto",font:"400 8.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",flex:"none"},children:h.label})]},`${h.label}:${h.id}`)):i.jsxs(Vc,{children:["— ",a.tkNoDependencies]})})]}),i.jsxs("div",{style:{...id,padding:"11px 14px",display:"flex",gap:8},children:[u.canUnblock&&i.jsx("span",{onClick:()=>!n&&s(e),style:{flex:1,textAlign:"center",fontSize:11,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"6px 0",color:"var(--proto-ink)",cursor:n?"not-allowed":"pointer",opacity:n?.5:1},children:a.mUnblock}),i.jsx("span",{"data-complete-task-id":e.id,onClick:()=>u.completable&&!n&&o(e),style:{flex:1.3,textAlign:"center",fontSize:11,fontWeight:600,borderRadius:8,padding:"7px 0",color:"var(--ink-solid-fg)",background:u.completeBg,cursor:u.completable&&!n?"pointer":"not-allowed",opacity:n?.6:1},children:u.completeLabel})]})]})]})]})}function o5e(e,t){return t.type==="open"?{projectId:t.projectId,taskId:t.taskId}:null}const i_=f.createContext(null);function i5e(e){const t=he(),n=Ve(),r=()=>n.invalidateQueries(t.tasks.list.queryFilter()),o=Re(t.tasks.complete.mutationOptions({onSettled:()=>{e(),r()}})),s=Re(t.tasks.unblock.mutationOptions({onSettled:()=>void r()}));return{completeTask:c=>o.mutate({projectId:c.project,taskId:c.id,note:"completed via Web UI"}),unblockTask:c=>s.mutate({projectId:c.project,taskId:c.id}),pending:o.isPending||s.isPending}}function s5e({selection:e,onClose:t}){const n=he(),r=ae(n.tasks.list.queryOptions({projectId:e.projectId})),o=i5e(t),s=r.data??[],a=s.find(l=>l.id===e.taskId);return a?i.jsx(r5e,{task:a,allTasks:s,pending:o.pending,onClose:t,onComplete:o.completeTask,onUnblock:o.unblockTask}):null}function a5e({children:e}){const[t,n]=f.useReducer(o5e,null),r=f.useCallback((a,l)=>{n({type:"open",projectId:a,taskId:l})},[]),o=f.useCallback(()=>n({type:"close"}),[]),s=f.useMemo(()=>({openTask:r,closeTask:o}),[r,o]);return i.jsxs(i_.Provider,{value:s,children:[e,t&&i.jsx(s5e,{selection:t,onClose:o})]})}function s_(){const e=f.useContext(i_);if(!e)throw new Error("useTaskModal must be used within a TaskModalProvider");return e}const a_=f.createContext(null);function l5e({alt:e,src:t}){const n=f.useContext(a_),[r,o]=f.useState(null),[s,a]=f.useState(!1);return f.useEffect(()=>{if(!n)return;let l=!1,c=null;return o(null),a(!1),n(t).then(d=>{if(l){URL.revokeObjectURL(d);return}c=d,o(d)}).catch(()=>{l||a(!0)}),()=>{l=!0,c&&URL.revokeObjectURL(c)}},[n,t]),!n||s||!r?i.jsx("span",{style:{color:"var(--proto-muted-3)"},children:e||t}):i.jsx("img",{src:r,alt:e,style:{maxWidth:"100%",borderRadius:6,display:"block",margin:"8px 0"}})}const Lv="'IBM Plex Mono',monospace";function qc(e){return e.map((t,n)=>{switch(t.type){case"bold":return i.jsx("span",{style:{fontWeight:650,color:"var(--proto-ink-2)"},children:t.text},n);case"italic":return i.jsx("em",{style:{fontStyle:"italic"},children:t.text},n);case"code":return i.jsx("code",{style:{font:`400 .92em ${Lv}`,background:"var(--proto-gray)",color:"var(--proto-accent-strong)",padding:"1px 4px",borderRadius:4},children:t.text},n);case"link":return i.jsx("a",{href:t.href,style:{color:"var(--proto-accent)",textDecoration:"none"},children:t.text},n);case"image":return i.jsx(l5e,{alt:t.alt,src:t.src},n);default:return i.jsx(f.Fragment,{children:t.text},n)}})}const c5e={fontSize:12.5,fontWeight:650,color:"var(--proto-ink)",margin:"15px 0 5px"},d5e={fontSize:11.5,lineHeight:1.65,color:"var(--proto-ink-3)",margin:"4px 0 0"};function u5e(e,t){switch(e.type){case"heading":return i.jsx("div",{style:{...c5e,fontSize:e.level>=3?11.5:12.5},children:qc(e.inline)},t);case"paragraph":return i.jsx("div",{style:d5e,children:qc(e.inline)},t);case"list":return i.jsx("div",{style:{fontSize:11.5,lineHeight:1.75,color:"var(--proto-ink-3)",margin:"4px 0 0"},children:e.items.map((n,r)=>i.jsxs("div",{style:{display:"flex",gap:9},children:[i.jsx("span",{style:{color:"var(--proto-faint)",flex:"none"},children:e.ordered?`${r+1}.`:"·"}),i.jsx("span",{children:qc(n)})]},r))},t);case"table":{const n=Math.max(e.header.length,...e.rows.map(o=>o.length),1),r=`repeat(${n}, minmax(0,1fr))`;return i.jsxs("div",{style:{border:"1px solid var(--proto-line-2)",borderRadius:8,overflow:"hidden",fontSize:11,margin:"7px 0 0"},children:[i.jsx("div",{style:{display:"grid",gridTemplateColumns:r,padding:"6px 12px",background:"var(--proto-rail)",borderBottom:"1px solid var(--proto-line-2)",fontSize:9,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},children:e.header.map((o,s)=>i.jsx("span",{children:qc(o)},s))}),e.rows.map((o,s)=>i.jsx("div",{style:{display:"grid",gridTemplateColumns:r,padding:"6px 12px",borderBottom:"1px solid var(--proto-alt)",color:"var(--proto-ink-3)"},children:Array.from({length:n}).map((a,l)=>i.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:o[l]?qc(o[l]):null},l))},s))]},t)}case"code":return i.jsx("pre",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,padding:"10px 13px",font:`400 10.5px ${Lv}`,color:"var(--proto-ink-2)",overflow:"auto",margin:"7px 0 0",whiteSpace:"pre"},children:e.text},t);case"blockquote":return i.jsx("div",{style:{borderLeft:"2px solid var(--proto-line-3)",padding:"2px 0 2px 9px",margin:"7px 0 0",fontSize:11.5,lineHeight:1.65,color:"var(--proto-muted)"},children:qc(e.inline)},t);case"hr":return i.jsx("div",{style:{height:1,background:"var(--proto-line-2)",margin:"12px 0"}},t);default:return null}}function l_({content:e,resolveImage:t}){const n=O(),{frontmatter:r,body:o}=Age(e),s=iB(o);return i.jsx(a_.Provider,{value:t??null,children:i.jsxs("div",{children:[r&&(r.entries.length>0||r.summary)&&i.jsxs("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,padding:"10px 13px"},children:[i.jsx("div",{style:{display:"flex",alignItems:"center",gap:13,font:`400 10px ${Lv}`,color:"var(--proto-muted)",flexWrap:"wrap"},children:r.entries.map((a,l)=>i.jsxs("span",{children:[i.jsx("span",{style:{color:"var(--proto-muted-3)"},children:a.key})," ",a.value]},l))}),r.summary&&i.jsxs("div",{style:{fontSize:11,color:"var(--proto-ink-2)",marginTop:6},children:[i.jsx("span",{style:{font:`400 10px ${Lv}`,color:"var(--proto-muted-3)"},children:n.memSummary}),"  ",r.summary]})]}),s.map((a,l)=>u5e(a,l))]})})}const Xp="'IBM Plex Mono',monospace";function p5e({status:e}){const t=O(),n=e==="active"?t.wbCommissionActive:e==="done"?t.wbCommissionDone:t.wbCommissionAbandoned,r=e==="active"?"var(--proto-accent)":"var(--proto-muted-2)",o=e==="active"?"var(--proto-accent-bg)":"var(--proto-gray)";return i.jsx("span",{style:{font:`500 9.5px ${Xp}`,color:r,background:o,borderRadius:5,padding:"2px 6px",flex:"none"},children:n})}function PT({active:e,label:t,onClick:n}){return i.jsx("button",{type:"button",onClick:n,style:{border:0,borderRadius:6,padding:"3px 9px",cursor:"pointer",fontSize:11.5,fontWeight:e?600:400,background:e?"var(--proto-card)":"transparent",color:e?"var(--proto-ink)":"var(--proto-muted-2)",boxShadow:e?"var(--shadow-raised, none)":"none"},children:t})}function Am({label:e,tone:t,disabled:n,onClick:r}){const[o,s]=f.useState(!1);return i.jsx("button",{type:"button",disabled:n,onClick:r,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{border:"1px solid var(--proto-line-2)",borderRadius:7,padding:"4px 11px",fontSize:12,cursor:n?"default":"pointer",opacity:n?.5:1,background:o&&!n?"var(--proto-gray)":"transparent",color:t==="danger"?"var(--proto-amber)":"var(--proto-ink-2)"},children:e})}function f5e(e){const t=O(),{projectId:n,slug:r}=e.commission,o=f.useCallback(v=>{if(/^[a-z]+:\/\//i.test(v)||v.startsWith("data:"))return Promise.resolve(v);const S=v.replace(/^\.\//,""),b=S.startsWith("commissions/")?S:`commissions/${r}/${S}`;return Sve(n,b)},[n,r]),[s,a]=f.useState("ledger"),[l,c]=f.useState(null),[d,u]=f.useState(""),{commission:p}=e,h=p.status==="active",m=s==="ledger"?e.ledger:e.contract,x=s==="ledger"?t.wbCommissionNoLedger:t.wbCommissionMissing;return i.jsxs(ur,{chrome:"bare",size:"custom",open:!0,showClose:!1,title:p.title,description:p.slug,onOpenChange:v=>{v||e.onDismiss()},contentDataAttributes:{"data-modal":"commission-board"},overlayDataAttributes:{"data-backdrop":"commission-board"},bodyStyle:{display:"contents"},contentStyle:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:1120,maxWidth:"94vw",height:700,maxHeight:"90vh",background:"var(--proto-card)",borderRadius:14,boxShadow:"var(--shadow-overlay-strong)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"15px 18px 12px",borderBottom:"1px solid var(--proto-line)",flex:"none"},children:[i.jsxs("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:1.6,strokeLinejoin:"round",strokeLinecap:"round",style:{flex:"none"},children:[i.jsx("path",{d:"M3.7 1.9v10.2"}),i.jsx("path",{d:"M3.7 2.7h6.8L9.1 5l1.4 2.3H3.7z"})]}),i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:14,fontWeight:650,color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.title}),i.jsx("div",{style:{font:`400 10px ${Xp}`,color:"var(--proto-muted-3)",marginTop:2},children:p.slug})]}),i.jsx(p5e,{status:p.status}),h&&i.jsxs(i.Fragment,{children:[i.jsx(Am,{label:t.wbCommissionComplete,tone:"neutral",disabled:e.pending,onClick:()=>{c("done"),u("")}}),i.jsx(Am,{label:t.wbCommissionAbandon,tone:"danger",disabled:e.pending,onClick:()=>{c("abandoned"),u("")}})]})]}),l&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"10px 18px",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-rail)",flex:"none"},children:[i.jsx("span",{style:{fontSize:12.5,color:"var(--proto-ink-2)",flex:"none"},children:l==="done"?t.wbCommissionCompleteTitle:t.wbCommissionAbandonTitle}),i.jsx("input",{value:d,onChange:v=>u(v.target.value),placeholder:t.wbCommissionCloseNote,style:{flex:1,minWidth:0,height:26,padding:"0 8px",borderRadius:6,border:"1px solid var(--proto-line-2)",background:"var(--proto-card)",color:"var(--proto-ink)",fontSize:12}}),i.jsx(Am,{label:l==="done"?t.wbCommissionComplete:t.wbCommissionAbandon,tone:l==="done"?"neutral":"danger",disabled:e.pending,onClick:()=>e.onClose(l,d.trim())}),i.jsx(Am,{label:t.cancel,tone:"neutral",onClick:()=>c(null)})]}),i.jsxs("div",{style:{flex:1,minHeight:0,display:"flex"},children:[i.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",borderRight:"1px solid var(--proto-line)"},children:[i.jsx("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"9px 16px",flex:"none",borderBottom:"1px solid var(--proto-line)"},children:i.jsxs("div",{style:{display:"flex",gap:2,background:"var(--proto-gray)",borderRadius:7,padding:2},children:[i.jsx(PT,{active:s==="ledger",label:t.wbCommissionLedger,onClick:()=>a("ledger")}),i.jsx(PT,{active:s==="contract",label:t.wbCommissionContract,onClick:()=>a("contract")})]})}),i.jsx("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:"14px 18px 24px"},children:m?i.jsx(l_,{content:m,resolveImage:o}):i.jsx("div",{style:{color:"var(--proto-faint)",fontSize:12.5,padding:"18px 0"},children:x})})]}),i.jsxs("div",{style:{width:380,flex:"none",display:"flex",flexDirection:"column",minHeight:0},children:[i.jsxs("div",{style:{padding:"11px 16px 8px",flex:"none",borderBottom:"1px solid var(--proto-line)"},children:[i.jsx("div",{style:{font:`600 10px ${Xp}`,color:"var(--proto-muted-2)",letterSpacing:.4},children:t.wbCommissionGates}),e.gates.length===0?i.jsx("div",{style:{color:"var(--proto-faint)",fontSize:12,marginTop:6},children:t.wbCommissionNoGates}):i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3,marginTop:6},children:e.gates.map(v=>i.jsxs("div",{onClick:()=>e.onOpenSession(v),style:{display:"flex",alignItems:"center",gap:7,cursor:"pointer",padding:"5px 7px",borderRadius:6,fontSize:12.5,background:"var(--proto-amber-bg, var(--proto-gray))",color:"var(--proto-ink)"},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-amber)",flex:"none"}}),i.jsx("span",{style:{flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.label??v.name??v.sessionId})]},v.sessionId))})]}),i.jsxs("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:"11px 16px 20px"},children:[i.jsx("div",{style:{font:`600 10px ${Xp}`,color:"var(--proto-muted-2)",letterSpacing:.4},children:t.wbCommissionDecisions}),e.decisions.length===0?i.jsx("div",{style:{color:"var(--proto-faint)",fontSize:12,marginTop:6},children:t.wbCommissionNoDecisions}):i.jsx("div",{style:{display:"flex",flexDirection:"column"},children:e.decisions.map((v,S)=>i.jsxs("div",{children:[i.jsx("div",{style:{font:`400 9.5px ${Xp}`,color:"var(--proto-muted-3)",marginTop:10},children:e.sessionLabel(v.sessionId)}),i.jsx(qB,{decisions:[v.item]})]},`${v.ts}:${v.item.id}:${S}`))})]})]})]}),p.closeNote&&i.jsxs("div",{style:{flex:"none",padding:"8px 18px",borderTop:"1px solid var(--proto-line)",fontSize:12,color:"var(--proto-muted)"},children:[i.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[t.wbCommissionClosedNote,": "]}),p.closeNote]})]})}function h5e(e,t){return t.type==="open"?t.commissionId:null}const c_=f.createContext(null);function ET(e,t,n){const r=he(),o=!!e&&!!t;return ae({...r.memory.file.queryOptions({projectId:e,path:`commissions/${t}/${n}`}),enabled:o,retry:!1})}function m5e({commissionId:e,onClose:t}){var b,g;const n=he(),r=Ve(),o=Xe(),{setCurrentProject:s}=zt(),{setSelectedSession:a}=Vi(),l=ae(n.commissions.get.queryOptions({commissionId:e})),c=ae(n.commissions.decisions.queryOptions({commissionId:e})),d=wc("direct"),u=l.data??null,p=ET((u==null?void 0:u.projectId)??"",(u==null?void 0:u.slug)??"","ledger.md"),h=ET((u==null?void 0:u.projectId)??"",(u==null?void 0:u.slug)??"","contract.md"),m=Re(n.commissions.close.mutationOptions({onSettled:()=>{r.invalidateQueries(n.commissions.list.queryFilter()),r.invalidateQueries(n.commissions.get.queryFilter())}})),x=f.useMemo(()=>(d.data??[]).filter(w=>w.commissionId===e&&!!w.awaitingInput),[d.data,e]),v=w=>{const k=(d.data??[]).find(C=>C.sessionId===w);return(k==null?void 0:k.label)??(k==null?void 0:k.name)??w};if(!u)return null;const S=w=>{s(w.projectId),a(w.sessionId),o("/workbench"),t()};return i.jsx(f5e,{commission:u,ledger:((b=p.data)==null?void 0:b.content)??null,contract:((g=h.data)==null?void 0:g.content)??null,decisions:c.data??[],gates:x,sessionLabel:v,pending:m.isPending,onOpenSession:S,onClose:(w,k)=>{m.mutate({commissionId:e,status:w,note:k||void 0})},onDismiss:t})}function g5e({children:e}){const[t,n]=f.useReducer(h5e,null),r=f.useCallback(a=>n({type:"open",commissionId:a}),[]),o=f.useCallback(()=>n({type:"close"}),[]),s=f.useMemo(()=>({openCommission:r,closeCommission:o}),[r,o]);return i.jsxs(c_.Provider,{value:s,children:[e,t&&i.jsx(m5e,{commissionId:t,onClose:o})]})}function d_(){const e=f.useContext(c_);if(!e)throw new Error("useCommissionBoard must be used within a CommissionBoardModalProvider");return e}const FS={en:{title:"Notes",inputPlaceholder:"Note something to do…",quickPlaceholder:"Quick note…",todo:"TO DO",completed:"Completed",clear:"Clear",handoff:"Hand to agent",edit:"Edit",save:"Save",cancel:"Cancel",delete:"Delete",viewAll:"View all",empty:"No open notes",privateHint:"Private reminder · agents do not read this file",enter:"↵",escape:"esc"},zh:{title:"笔记",inputPlaceholder:"记一条要干什么…",quickPlaceholder:"快速记一条…",todo:"待办",completed:"已完成",clear:"清除",handoff:"交给 agent",edit:"编辑",save:"保存",cancel:"取消",delete:"删除",viewAll:"查看全部",empty:"没有未完成笔记",privateHint:"私人备忘 · agent 不读取此文件",enter:"↵",escape:"esc"}};function v5e(e,t){return e===1?t==="zh"?"昨天":"yesterday":t==="zh"?`${Math.max(2,e)} 天前`:`${Math.max(2,e)}d`}function x5e(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function y5e(e){const t=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0");return`${t}:${n}`}function b5e(e,t,n){const r=Date.parse(e);if(Number.isNaN(r))return"—";const o=new Date(r);if(x5e(o,new Date(t)))return y5e(o);const s=Math.max(1,Math.floor((t-r)/864e5));return v5e(s,n)}function w5e(e,t,n){return{...e,timeLabel:b5e(e.createdAt,t,n)}}function u_(e,t,n){const r=e.map(a=>w5e(a,t,n)),o=r.filter(a=>!a.completed),s=r.filter(a=>a.completed);return{active:o,completed:s,previews:o.slice(0,3),activeCount:o.length,completedCount:s.length}}function S5e(e){return(e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="n"}function k5e(e){if(!e)return null;if(e instanceof Error)return e;const t=typeof e=="object"&&"message"in e?String(e.message):String(e);return new Error(t)}function zS(e){const t=he(),n=Ve(),r=f.useRef(e);r.current=e;const o=h=>n.invalidateQueries(t.notes.list.queryFilter({projectId:h})),s=(h,m,x)=>o(x.projectId),a=ae({...t.notes.list.queryOptions({projectId:e}),enabled:!!e}),l=Re(t.notes.add.mutationOptions({onSettled:s})),c=Re(t.notes.update.mutationOptions({onSettled:s})),d=Re(t.notes.setCompleted.mutationOptions({onSettled:s})),u=Re(t.notes.delete.mutationOptions({onSettled:s})),p=Re(t.notes.clearCompleted.mutationOptions({onSettled:s}));return{notes:a.data??[],loading:a.isLoading,busy:l.isPending||c.isPending||d.isPending||u.isPending||p.isPending,error:k5e(a.error??l.error??c.error??d.error??u.error??p.error),add:h=>l.mutateAsync({projectId:r.current,text:h}),update:(h,m)=>c.mutateAsync({projectId:r.current,id:h,text:m}),setCompleted:(h,m)=>d.mutateAsync({projectId:r.current,id:h,completed:m}),delete:async h=>{await u.mutateAsync({projectId:r.current,id:h})},clearCompleted:async()=>{await p.mutateAsync({projectId:r.current})}}}const p_=f.createContext(null);function j5e(e){const[t,n]=f.useState(!1),[r,o]=f.useState(null),s=f.useCallback(l=>{o(l??null),n(!0)},[]),a=f.useCallback(()=>{n(!1),o(null)},[]);return f.useEffect(()=>a(),[e,a]),f.useEffect(()=>{const l=c=>{S5e(c)&&(c.preventDefault(),o(null),n(d=>!d))};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),{isOpen:t,targetId:r,open:s,close:a}}function C5e({children:e}){const t=ht(),{currentProjectId:n}=zt(),{prefillDraft:r}=Vi(),o=n??"",s=j5e(o),a=zS(o),l=f.useMemo(()=>u_(a.notes,Date.now(),t),[a.notes,t]),c=f.useMemo(()=>({copy:FS[t],vm:l,...s,busy:a.busy,add:a.add,update:a.update,setCompleted:a.setCompleted,remove:a.delete,clearCompleted:a.clearCompleted,handoff:d=>{r(d),s.close()}}),[t,l,s,a,r]);return i.jsx(p_.Provider,{value:c,children:e})}function j1(){const e=f.useContext(p_);if(!e)throw new Error("useNotes must be used within NotesProvider");return e}const T5e="cortex:left-rail-collapsed",P5e="cortex:right-panel-collapsed";function RT(e){const[t,n]=f.useState(()=>{try{return window.localStorage.getItem(e)==="true"}catch{return!1}});return f.useEffect(()=>{try{window.localStorage.setItem(e,String(t))}catch{}},[e,t]),[t,n]}const f_=f.createContext(null);function E5e({children:e}){const[t,n]=RT(T5e),[r,o]=RT(P5e),s=f.useCallback(u=>n(u),[n]),a=f.useCallback(()=>n(u=>!u),[n]),l=f.useCallback(u=>o(u),[o]),c=f.useCallback(()=>o(u=>!u),[o]),d=f.useMemo(()=>({railCollapsed:t,setRailCollapsed:s,toggleRail:a,panelCollapsed:r,setPanelCollapsed:l,togglePanel:c}),[t,s,a,r,l,c]);return i.jsx(f_.Provider,{value:d,children:e})}function C1(){const e=f.useContext(f_);if(!e)throw new Error("usePaneState must be used within a PaneStateProvider");return e}function h_(e,t){return!e||!t?!1:e.route===t.route&&e.projectId===t.projectId&&e.sessionId===t.sessionId}function R5e(e,t){return e?e.route===t.route&&e.projectId===t.projectId&&e.sessionId===null&&t.sessionId!==null:!1}function M5e(e,t){const n=e.entries[e.index];if(h_(n,t))return e;if(R5e(n,t)){const o=e.entries.slice();return o[e.index]=t,{entries:o,index:e.index}}const r=e.entries.slice(0,e.index+1);return r.push(t),{entries:r,index:r.length-1}}function MT(e){return e.index>0}function IT(e){return e.index<e.entries.length-1}const I5e=1500,m_=f.createContext(null);function A5e({children:e}){const t=Xe(),{pathname:n}=fo(),{currentProjectId:r,setCurrentProject:o}=zt(),{selectedSessionId:s,setSelectedSession:a}=Vi(),[l,c]=f.useState(()=>({entries:[{route:n,projectId:r,sessionId:s}],index:0})),d=f.useRef(null),u=f.useRef(null),p=f.useRef(l);p.current=l;const h=f.useCallback(()=>{d.current=null,u.current&&(clearTimeout(u.current),u.current=null)},[]);f.useEffect(()=>()=>h(),[h]),f.useEffect(()=>{const g={route:n,projectId:r,sessionId:s};if(d.current){h_(d.current,g)&&h();return}c(w=>M5e(w,g))},[n,r,s,h]);const m=f.useCallback(g=>{d.current=g,u.current&&clearTimeout(u.current),u.current=setTimeout(h,I5e),g.projectId&&g.projectId!==r&&o(g.projectId),g.sessionId&&g.sessionId!==s&&a(g.sessionId),g.route!==n&&t(g.route)},[r,s,n,t,o,a,h]),x=f.useCallback(g=>{const w=p.current;if(g===-1?!MT(w):!IT(w))return;const k=w.index+g;m(w.entries[k]),c({...w,index:k})},[m]),v=f.useCallback(()=>x(-1),[x]),S=f.useCallback(()=>x(1),[x]),b=f.useMemo(()=>({canBack:MT(l),canForward:IT(l),back:v,forward:S}),[l,v,S]);return i.jsx(m_.Provider,{value:b,children:e})}function D5e(){const e=f.useContext(m_);if(!e)throw new Error("useNavigationHistory must be used within a NavigationHistoryProvider");return e}const L5e="context/projects/",O5e="nimbus";function BS(e){return e.trim().length>0}function N5e(e){const t=e&&typeof e=="object"&&"message"in e?e.message:void 0;return typeof t=="string"&&t.trim().length>0?t:"Could not create project."}function g_({onCreated:e}={}){const t=he(),n=Ve(),[r,o]=f.useState(null),s=Re(t.projects.create.mutationOptions({})),a=f.useCallback(()=>o(null),[]);return{createProject:f.useCallback(async c=>{if(!BS(c)||s.isPending)return null;o(null);let d;try{d=await s.mutateAsync({name:c.trim()})}catch(u){return o(N5e(u)),null}return await n.invalidateQueries(t.projects.list.queryFilter()),await(e==null?void 0:e(d.id)),d.id},[s,e,n,t.projects.list]),clearError:a,error:r,isPending:s.isPending}}const Tb="'IBM Plex Mono',monospace";function F5e({onClose:e}){const t=O(),[n,r]=f.useState(""),[o,s]=f.useState(!1),a=f.useRef(null),{createProject:l,clearError:c,error:d,isPending:u}=g_({onCreated:e}),p=()=>{l(n)},h=BS(n);return i.jsxs(ur,{chrome:"bare",size:"custom",open:!0,showClose:!1,title:t.newProject,description:t.npHint,onOpenChange:m=>{m||e()},contentDataAttributes:{"data-modal":"newproj"},bodyStyle:{display:"contents"},contentStyle:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:540,background:"var(--proto-card)",borderRadius:14,boxShadow:"var(--shadow-overlay-strong)",zIndex:61,overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 20px 0"},children:[i.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:t.newProject}),i.jsx("span",{style:{font:`400 10px ${Tb}`,color:"var(--proto-muted-3)",marginLeft:10},children:L5e}),i.jsx("span",{onClick:e,style:{marginLeft:"auto",font:`500 9.5px ${Tb}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),i.jsxs("div",{style:{padding:"16px 20px 0"},children:[i.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginBottom:6},children:t.npProjectName}),i.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1.5px solid var(--proto-accent-border)",borderRadius:9,padding:"9px 12px"},children:i.jsx("input",{ref:a,value:n,onChange:m=>{r(m.target.value),d&&c()},onKeyDown:m=>{m.key==="Enter"&&p()},autoFocus:!0,placeholder:O5e,style:{flex:1,font:`500 13px ${Tb}`,color:"var(--proto-ink)"}})}),i.jsx("div",{style:{fontSize:10.5,color:d?"var(--proto-danger)":"var(--proto-muted-3)",marginTop:8,lineHeight:1.6},children:d??t.npHint})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"16px 20px 16px",justifyContent:"flex-end"},children:[i.jsx("span",{onClick:e,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"6px 13px",color:"var(--proto-ink)",cursor:"pointer",background:o?"var(--proto-alt)":"transparent"},children:t.cancel}),i.jsx("span",{onClick:p,style:{fontSize:11.5,fontWeight:600,borderRadius:8,padding:"7px 15px",color:"var(--ink-solid-fg)",background:h?"var(--proto-accent)":"var(--proto-accent-border)",cursor:h&&!u?"pointer":"default"},children:t.npCreate})]})]})}function v_(e){return e==="running"?"done":e==="stopped"?"failed":"cancelled"}function z5e(e){const t=e.extras?Object.entries(e.extras).map(([n,r])=>({key:n,value:r})):[];return{...e,tone:v_(e.status),extras:t}}function x_(e){return e?{processes:e.processes.map(z5e),lastRestart:e.lastRestart}:{processes:[],lastRestart:null}}const B5e=5e3;function $5e(e){return e==="pending"?"pending":e==="success"?"success":e==="error"?"error":"idle"}function AT(e){if(!e)return null;if(e instanceof Error)return e;const t=typeof e=="object"&&"message"in e?String(e.message):String(e);return new Error(t)}function y_(e={}){const t=he(),n=Ve(),r=e.enabled??!0,o=t.system.daemonStatus.queryOptions({}),s=ae({...o,enabled:r,refetchInterval:r?B5e:!1}),a=Re(t.system.restart.mutationOptions({onSuccess:async()=>{await n.invalidateQueries({queryKey:o.queryKey,exact:!0}),await n.invalidateQueries(t.threads.list.queryFilter())}}));return{daemon:s.data??null,facts:x_(s.data),loading:s.isLoading,error:AT(s.error),restart:l=>a.mutate({kind:l}),restartState:$5e(a.status),restartError:AT(a.error)}}const _5e="connect.html";async function W5e(e){var t;try{await((t=e.invoke)==null?void 0:t.call(e,"disconnect"))}catch{}finally{e.navigate(_5e)}}async function H5e(){const e=await bt("disconnect");if(!e.ok&&e.reason==="failed")throw e.error}async function b_(){dr()&&await W5e({invoke:H5e,navigate:e=>{window.location.href=e}})}const $S="0909-1517·0956df8";function DT(e){return e==="done"?"var(--proto-success)":e==="failed"?"var(--proto-danger)":"var(--pill-cancelled-fg)"}function U5e(e){return e==="done"?"var(--proto-success-bg)":e==="failed"?"var(--proto-danger-bg)":"var(--pill-cancelled-bg)"}function V5e({open:e,onClose:t}){const n=O(),[r,o]=f.useState(!1),s=y_({enabled:e}),{processes:a,lastRestart:l}=s.facts;f.useEffect(()=>{(s.restartState==="success"||s.restartState==="error")&&o(!1)},[s.restartState]);const c=()=>s.restart("soft"),d=()=>s.restart("hard");return e?i.jsxs(i.Fragment,{children:[i.jsx("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:40,background:"var(--overlay-scrim-medium)"}}),i.jsxs("div",{style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",zIndex:50,width:470,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:14,boxShadow:"var(--shadow-panel)",overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"16px 20px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[i.jsx("div",{"aria-label":"Cortex",style:{width:28,height:28,borderRadius:8,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center"},children:i.jsxs("svg",{width:20,height:20,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[i.jsx("circle",{cx:33,cy:32,r:6,fill:"var(--brand-badge-core)"}),i.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"}),i.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"})]})}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:n.dmDaemon}),i.jsxs("div",{style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginTop:1},children:["local · build ",$S]})]}),i.jsx("span",{onClick:t,style:{marginLeft:"auto",font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),i.jsxs("div",{style:{padding:"14px 20px",display:"flex",flexDirection:"column",gap:10},children:[s.loading&&i.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-3)",textAlign:"center",padding:20},children:"Loading…"}),s.error&&i.jsx("div",{style:{fontSize:12,color:"var(--proto-danger)",textAlign:"center",padding:20},children:"Failed to load daemon status"}),a.map(u=>{const p=u.status;return i.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:10,padding:"11px 14px"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:DT(u.tone),flex:"none"}}),i.jsx("span",{style:{font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:u.name}),i.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:u.label}),i.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:U5e(u.tone),color:DT(u.tone)},children:p})]}),i.jsxs("div",{style:{display:"flex",gap:14,marginTop:8,font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",flexWrap:"wrap"},children:[u.uptime&&i.jsxs("span",{children:[i.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[n.dmUp," "]}),u.uptime]}),u.pid!=null&&i.jsxs("span",{children:[i.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[n.dmPid," "]}),u.pid]}),u.port!=null&&i.jsxs("span",{children:[i.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[n.dmPort," "]}),":",u.port]}),u.extras.map(h=>i.jsxs("span",{children:[i.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[h.key," "]}),h.value]},h.key))]})]},u.name)}),(l==null?void 0:l.at)&&i.jsxs("div",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",padding:"0 2px"},children:[n.dmLastRestart," ",new Date(l.at).toLocaleDateString()," ",new Date(l.at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),l.reason?` · ${n.dmReason}: ${l.reason}`:""]})]}),!r&&i.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",flexDirection:"column",gap:8},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:n.dmSoftRestart}),i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:n.dmSoftRestartDesc})]}),i.jsx("span",{onClick:c,style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:s.restartState==="pending"?"default":"pointer",opacity:s.restartState==="pending"?.5:1},children:n.dmSoftRestart})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-danger)"},children:n.dmHardRestart}),i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:n.dmHardRestartDesc})]}),i.jsx("span",{onClick:()=>o(!0),style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-danger)",border:"1px solid var(--proto-danger-bg)",background:"var(--proto-danger-bg)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:n.dmHardRestart})]})]}),r&&i.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",flexDirection:"column",gap:10},children:[i.jsxs("div",{style:{border:"1px solid var(--proto-amber-border)",background:"var(--proto-amber-bg)",borderRadius:9,padding:"10px 14px"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-amber-fg)"},children:n.dmHardConfirm}),i.jsx("div",{style:{fontSize:11.5,color:"var(--proto-muted)",marginTop:4,lineHeight:1.5},children:n.dmHardConfirmDetail})]}),i.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[i.jsx("span",{onClick:()=>o(!1),style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:n.dmConfirmCancel}),i.jsx("span",{onClick:d,style:{fontSize:11.5,fontWeight:600,color:"var(--ink-solid-fg)",background:"var(--proto-danger)",borderRadius:8,padding:"6px 14px",cursor:s.restartState==="pending"?"default":"pointer",opacity:s.restartState==="pending"?.5:1},children:s.restartState==="pending"?"...":n.dmConfirmProceed})]})]}),s.restartState==="success"&&i.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 20px",fontSize:11.5,color:"var(--proto-success)",fontWeight:600},children:n.dmRestartSent}),s.restartState==="error"&&i.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 20px",fontSize:11.5,color:"var(--proto-danger)",fontWeight:600},children:n.dmRestartFailed}),dr()&&i.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",alignItems:"center",gap:10},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:n.dmDisconnect}),i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:n.dmDisconnectDesc})]}),i.jsx("span",{onClick:()=>void b_(),style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:n.dmDisconnect})]})]})]}):null}function w_(e){return globalThis[e]}function _S(){const e=w_("__CORTEX_PLATFORM__");return e==="macos"||e==="windows"||e==="linux"?e:null}function WS(){const e=w_("__CORTEX_TITLEBAR__");return e==="custom"||e==="overlay"?e:"native"}function S_(){var t,n;const e=_S();return e?e==="macos":/Mac|iPhone|iPad/i.test(((t=globalThis.navigator)==null?void 0:t.platform)??((n=globalThis.navigator)==null?void 0:n.userAgent)??"")}function k_(){return WS()==="overlay"?78:0}function HS(e){const t=e.toLowerCase().split("+");return{key:t[t.length-1]??"",mod:t.includes("mod"),shift:t.includes("shift"),alt:t.includes("alt")}}const q5e={arrowleft:"←",arrowright:"→","=":"+",",":","};function j_(e,t){const{key:n,mod:r,shift:o,alt:s}=HS(e),a=[];r&&a.push(t?"⌘":"Ctrl"),o&&a.push(t?"⇧":"Shift"),s&&a.push(t?"⌥":"Alt");const l=q5e[n]??(n.length===1?n.toUpperCase():n.replace(/^f(\d+)$/,"F$1"));return a.push(l),t?a.join(""):a.join("+")}function K5e(e,t){const{key:n,mod:r,shift:o,alt:s}=HS(t);return r!==(e.metaKey||e.ctrlKey)||o!==e.shiftKey||s!==e.altKey?!1:e.key.toLowerCase()===n}function C_(e){const t=[],n=r=>{for(const o of r)o.kind==="item"?t.push(o):o.kind==="submenu"&&n(o.items)};return n(e.flatMap(r=>r.items)),t}function T_(e){return C_(e).filter(t=>typeof t.accel=="string")}const LT={"=":"Equal","-":"Minus",",":"Comma",".":"Period","/":"Slash"};function G5e(e){return LT[e]?LT[e]:/^[a-z]$/.test(e)?`Key${e.toUpperCase()}`:/^[0-9]$/.test(e)?`Digit${e}`:(/^f\d+$/.test(e),e.toUpperCase())}function Y5e(e){const{key:t,mod:n,shift:r,alt:o}=HS(e),s=[];return n&&s.push("CmdOrCtrl"),r&&s.push("Shift"),o&&s.push("Alt"),s.push(G5e(t)),s.join("+")}function Q5e(e,t){const n={unsupported_shell:t.updateCheckUnsupported,invalid_report:t.updateCheckInvalid,no_credentials:t.updateCheckCredentials,"disabled by CORTEX_APP_UPDATE_DISABLE":t.updateCheckDisabled,"dev mode (CORTEX_FRONTEND_DIR is set)":t.updateCheckDev,dev_version:t.updateCheckDev,version_skipped:t.updateCheckSkippedVersion,no_matching_asset:t.updateCheckNoAsset,update_in_progress:t.updateCheckInProgress,restart_or_install_pending:t.updateCheckRestartPending,not_scheduled:t.updateCheckNotScheduled};return e!=null&&e.startsWith("dev version ")?t.updateCheckDev:e?n[e]:void 0}function OT(e,t,n){const o=[{available:n.updateCheckAvailable,current:n.updateCheckCurrent,skipped:n.updateCheckSkipped,error:n.updateCheckError}[t.status],Q5e(t.reason,n)];return t.update&&t.status!=="available"&&o.push(n.updateCheckCached),{title:e,description:o.filter(Boolean).join(" "),duration:12e3,tone:t.status==="error"?"failed":t.status==="skipped"?"waiting":"done"}}function X5e(e,t){return[OT(t.updateCheckUi,e.ui,t),OT(t.updateCheckShell,e.shell,t)]}function Z5e(){const e=O(),t=zx(),n=f.useSyncExternalStore(G$,q5),r=f.useRef(!1),o=f.useRef();f.useEffect(()=>(r.current=!0,()=>{r.current=!1,o.current&&(t==null||t.dismiss(o.current))}),[t]);const s=f.useCallback(async()=>{if(q5())return;o.current=t==null?void 0:t.toast({title:e.updateCheckBusy,description:e.updateCheckProgress,tone:"running",duration:1/0});const a=await E4e();r.current&&(o.current&&(t==null||t.dismiss(o.current)),o.current=void 0,X5e(a,e).forEach(l=>t==null?void 0:t.toast(l)))},[e,t]);return{busy:n,check:s}}const US={label:"main"};function Tu(e){if(!e.ok)throw new Error("native_window_action_failed");return e.value}async function K5(e){return Tu(await bt(`plugin:window|${e}`,US))}async function P_(e,t){for(let n=0;n<20;n++){if(await K5(e)===t)return;await new Promise(r=>setTimeout(r,50))}throw new Error("native_window_transition_timed_out")}async function Pb(e){Tu(await bt("plugin:window|set_fullscreen",{...US,value:e})),await P_("is_fullscreen",e)}async function Eb(e){Tu(await bt(e?"plugin:window|maximize":"plugin:window|unmaximize",US)),await P_("is_maximized",e)}function J5e(e){let t=!1,n=!1;async function r(){n=e==="windows"&&await K5("is_maximized"),n&&await Eb(!1);try{await Pb(!0)}catch(a){throw await Pb(!1).catch(()=>{}),n&&await Eb(!0).catch(()=>{}),a}}async function o(){await Pb(!1),n&&await Eb(!0),n=!1}async function s(a=!1){if(!t){t=!0;try{await K5("is_fullscreen")?await o():a||await r()}finally{t=!1}}}return{toggle:()=>s(),exit:()=>s(!0)}}const S0={label:"main"},E_="cortex:webview-zoom",Zp=[.7,.8,.9,1,1.1,1.25,1.5,1.75,2],k0=1;let ewe;function NT(){try{const e=Number(window.localStorage.getItem(E_));return Zp.includes(e)?e:k0}catch{return k0}}function FT(e,t){const n=Zp.indexOf(e),r=n===-1?Zp.indexOf(k0):n;return Zp[Math.min(Zp.length-1,Math.max(0,r+t))]}function twe(){const[e,t]=f.useState({isMaximized:!1,isFullscreen:!1}),n=f.useRef(!1),r=f.useCallback(async()=>{const[o,s]=await Promise.all([bt("plugin:window|is_maximized",S0),bt("plugin:window|is_fullscreen",S0)]);n.current&&t(a=>({isMaximized:o.ok?o.value:a.isMaximized,isFullscreen:s.ok?s.value:a.isFullscreen}))},[]);return f.useEffect(()=>(n.current=!0,r(),window.addEventListener("resize",r),window.addEventListener("focus",r),()=>{n.current=!1,window.removeEventListener("resize",r),window.removeEventListener("focus",r)}),[r]),{...e,sync:r}}function nwe(e){const[t,n]=f.useState(NT),r=f.useRef(!1),o=f.useCallback(async s=>{if(!r.current){r.current=!0;try{Tu(await bt("plugin:webview|set_webview_zoom",{...S0,value:s})),n(s);try{window.localStorage.setItem(E_,String(s))}catch{}}catch{e()}finally{r.current=!1}}},[e]);return f.useEffect(()=>{const s=NT();s!==k0&&o(s)},[o]),{zoom:t,zoomIn:()=>void o(FT(t,1)),zoomOut:()=>void o(FT(t,-1)),zoomReset:()=>void o(k0)}}function rwe(e){return e.key!=="Escape"||e.repeat||e.defaultPrevented?!1:!document.querySelector('[role="dialog"], [role="menu"], [role="alertdialog"]')}function owe(e,t,n){const r=ewe??(ewe=J5e(_S())),o=f.useCallback(async(s=!1)=>{try{await(s?r.exit():r.toggle())}catch{n()}finally{await t()}},[r,n,t]);return f.useEffect(()=>{const s=a=>{!e||!rwe(a)||(a.preventDefault(),o(!0))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,o]),()=>void o()}function R_(){const e=O(),t=zx(),n=f.useCallback(()=>{t==null||t.toast({title:e.windowActionFailed,description:e.windowActionFailedHint,tone:"failed"})},[e,t]),{sync:r,...o}=twe(),s=owe(o.isFullscreen,r,n),a=nwe(n),l=c=>{bt(`plugin:window|${c}`,S0).then(Tu).catch(n)};return{...o,...a,toggleFullscreen:s,minimize:()=>l("minimize"),toggleMaximize:()=>l("toggle_maximize"),close:()=>l("close"),startDragging:()=>l("start_dragging"),toggleDevTools:()=>{bt("plugin:webview|internal_toggle_devtools",S0).then(Tu).catch(()=>t==null?void 0:t.toast({title:e.windowDevtoolsFailed,description:e.windowDevtoolsFailedHint,tone:"failed"}))}}}const iwe="https://fangxm233.github.io/cortex-agent/";function Tp(e){try{document.execCommand(e)}catch{}}async function swe(){try{const e=await navigator.clipboard.readText();document.execCommand("insertText",!1,e)}catch{}}const mi={kind:"separator"};function M_(){const e=O(),t=Xe(),n=zx(),r=t1(),o=AS(),s=VS(),a=C1(),l=Ic(),c=nh(),d=Wx(),{currentProjectId:u}=zt(),{selectedSessionId:p,setSelectedSession:h}=Vi(),m=R_(),x=vx(),{busy:v,check:S}=Z5e();return{menus:f.useMemo(()=>{const g=p&&p!==nl?p:null,w={id:"file",label:e.menuFile,items:[{kind:"item",id:"file.newSession",label:e.mFileNewSession,accel:"mod+n",run:()=>{h(nl),t("/workbench")}},{kind:"item",id:"file.newProject",label:e.mFileNewProject,run:s.openNewProject},{kind:"item",id:"file.newSchedule",label:e.mFileNewSchedule,run:()=>o.open(u?{projectId:u}:void 0)},mi,{kind:"item",id:"file.settings",label:e.mFileSettings,accel:"mod+,",run:r.open},mi,{kind:"item",id:"file.disconnect",label:e.mFileDisconnect,disabled:!x,run:()=>void bt("disconnect")},{kind:"item",id:"file.quit",label:e.mFileQuit,accel:"mod+q",disabled:!x,run:m.close}]},k={id:"edit",label:e.menuEdit,items:[{kind:"item",id:"edit.undo",accelDisplayOnly:!0,role:"undo",label:e.mEditUndo,accel:"mod+z",run:()=>Tp("undo")},{kind:"item",id:"edit.redo",accelDisplayOnly:!0,role:"redo",label:e.mEditRedo,accel:"mod+shift+z",run:()=>Tp("redo")},mi,{kind:"item",id:"edit.cut",accelDisplayOnly:!0,role:"cut",label:e.mEditCut,accel:"mod+x",run:()=>Tp("cut")},{kind:"item",id:"edit.copy",accelDisplayOnly:!0,role:"copy",label:e.mEditCopy,accel:"mod+c",run:()=>Tp("copy")},{kind:"item",id:"edit.paste",accelDisplayOnly:!0,role:"paste",label:e.mEditPaste,accel:"mod+v",run:()=>void swe()},{kind:"item",id:"edit.selectAll",accelDisplayOnly:!0,role:"selectAll",label:e.mEditSelectAll,accel:"mod+a",run:()=>Tp("selectAll")},mi,{kind:"item",id:"edit.palette",accelDisplayOnly:!0,label:e.mEditPalette,accel:"mod+k",run:()=>window.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,ctrlKey:!0,bubbles:!0}))},{kind:"item",id:"edit.copySessionId",label:e.mEditCopySessionId,disabled:!g,run:()=>{var P;g&&((P=navigator.clipboard)==null||P.writeText(g).catch(()=>{}),n==null||n.toast({title:e.mEditCopySessionId,tone:"done"}))}}]},C={id:"view",label:e.menuView,items:[{kind:"item",id:"view.leftRail",label:e.mViewLeftRail,accel:"mod+b",checked:!a.railCollapsed,run:a.toggleRail},{kind:"item",id:"view.rightPanel",label:e.mViewRightPanel,accel:"mod+alt+b",checked:!a.panelCollapsed,run:a.togglePanel},{kind:"item",id:"view.dock",label:e.mViewDock,accel:"mod+j",checked:l.open,disabled:!l.canDock,run:l.toggleDock},mi,{kind:"item",id:"view.workbench",label:e.mViewWorkbench,run:()=>t("/workbench")},{kind:"item",id:"view.overview",label:e.mViewOverview,run:()=>t("/overview")},{kind:"item",id:"view.memory",label:e.mViewMemory,run:()=>t("/memory")},mi,{kind:"submenu",id:"view.appearance",label:e.mViewAppearance,items:[{kind:"item",id:"view.theme.light",label:e.mViewThemeLight,checked:c==="light",run:()=>d("light")},{kind:"item",id:"view.theme.dark",label:e.mViewThemeDark,checked:c==="dark",run:()=>d("dark")},{kind:"item",id:"view.theme.system",label:e.mViewThemeSystem,checked:c==="system",run:()=>d("system")}]},mi,{kind:"item",id:"view.zoomIn",label:e.mViewZoomIn,accel:"mod+=",disabled:!x,run:m.zoomIn},{kind:"item",id:"view.zoomOut",label:e.mViewZoomOut,accel:"mod+-",disabled:!x,run:m.zoomOut},{kind:"item",id:"view.zoomReset",label:e.mViewZoomReset,accel:"mod+0",disabled:!x,run:m.zoomReset},mi,{kind:"item",id:"view.fullscreen",role:"fullscreen",label:m.isFullscreen?e.windowExitFullscreen:e.mViewFullScreen,checked:m.isFullscreen,accel:"f11",disabled:!x,run:m.toggleFullscreen}]},T={id:"help",label:e.menuHelp,items:[{kind:"item",id:"help.docs",label:e.mHelpDocs,run:()=>void rh(iwe).catch(()=>{})},mi,{kind:"item",id:"help.daemon",label:e.mHelpDaemon,run:s.openDaemonStatus},{kind:"item",id:"help.updates",label:v?e.updateCheckBusy:e.mHelpUpdates,disabled:!x||v,run:()=>void S()},{kind:"item",id:"help.devtools",label:e.mHelpDevTools,disabled:!x,run:m.toggleDevTools},mi,{kind:"item",id:"help.about",label:e.mHelpAbout,run:s.openAbout}]};return[w,k,C,T]},[e,t,n,r,o,s,a,l,c,d,u,p,h,m,x,v,S]),windowActions:m}}const zT="'IBM Plex Mono',monospace";function awe({onClose:e}){const t=O(),{menus:n}=M_(),r=S_(),o=n.map(s=>({label:s.label,items:T_([s])})).filter(s=>s.items.length>0);return i.jsx(ur,{open:!0,title:t.shortcutsTitle,description:t.shortcutsHint,size:"custom",onOpenChange:s=>{s||e()},contentStyle:{width:480},children:i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:o.map(s=>i.jsxs("div",{children:[i.jsx("div",{style:{font:`600 10px ${zT}`,letterSpacing:".08em",textTransform:"uppercase",color:"var(--proto-muted-3)",marginBottom:6},children:s.label}),s.items.map(a=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"4px 0",fontSize:12.5,color:"var(--proto-ink)"},children:[i.jsx("span",{children:a.label}),i.jsx("span",{style:{marginLeft:"auto",font:`500 11px ${zT}`,color:"var(--proto-muted-2)"},children:j_(a.accel,r)})]},a.id))]},s.label))})})}const lwe="https://fangxm233.github.io/cortex-agent/",cwe="https://github.com/fangxm233/cortex-agent";function dwe(){const[e,t]=f.useState(null);return f.useEffect(()=>{let n=!0;return bt("plugin:app|version").then(r=>{n&&t(r)}),()=>{n=!1}},[]),e}function uwe(){const e=O();return i.jsxs("header",{className:"about-brand",children:[i.jsx("img",{src:"/apple-touch-icon.png",alt:"",width:72,height:72}),i.jsx("h2",{children:"Cortex"}),i.jsx("p",{children:e.aboutDescription})]})}function pwe(){const e=O(),t=dwe(),n={unavailable:e.aboutShellBrowser,failed:e.aboutShellFailed},r=t!=null&&t.ok?t.value:t?n[t.reason]:e.aboutShellLoading;return i.jsxs("dl",{className:"about-versions",children:[i.jsxs("div",{className:"about-version-row",children:[i.jsx("dt",{children:e.aboutFrontend}),i.jsx("dd",{className:"about-version-value",children:$S})]}),i.jsxs("div",{className:"about-version-row",children:[i.jsx("dt",{children:e.aboutShell}),i.jsx("dd",{className:t!=null&&t.ok?"about-version-value":"about-version-status",children:i.jsx("span",{role:"status","aria-busy":!t,children:r})})]})]})}function fwe(){return i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M4 12 12 4M4 4h8v8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function hwe(){const e=O(),[t,n]=f.useState(!1),r=[[lwe,e.aboutDocs],[cwe,e.aboutProject]];return i.jsxs("footer",{className:"about-footer",children:[i.jsx("div",{className:"about-links",children:r.map(([o,s])=>i.jsxs("a",{href:o,onClick:a=>{a.preventDefault(),n(!1),rh(o).catch(()=>n(!0))},children:[s,i.jsx(fwe,{})]},o))}),t&&i.jsx("p",{className:"about-link-error",role:"alert",children:e.aboutLinkError})]})}function mwe({onClose:e}){const t=O();return i.jsxs(ur,{open:!0,chrome:"bare",title:t.aboutTitle,description:t.aboutDescription,showClose:!1,contentDataAttributes:{"data-about-dialog":!0},onOpenChange:n=>{n||e()},children:[i.jsx(aL,{className:"about-close","aria-label":t.winClose,children:i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"m4 4 8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),i.jsx(uwe,{}),i.jsx(pwe,{}),i.jsx(hwe,{})]})}const I_=f.createContext(null);function gwe({children:e}){const[t,n]=f.useState(!1),[r,o]=f.useState(!1),[s,a]=f.useState(!1),[l,c]=f.useState(!1),[d,u]=f.useState(!1),p=f.useMemo(()=>({openNewProject:()=>n(!0),openDaemonStatus:()=>o(!0),openShortcuts:()=>a(!0),openAbout:()=>c(!0),sessionIdOpen:d,openSessionId:()=>u(!0),closeSessionId:()=>u(!1)}),[d]);return i.jsxs(I_.Provider,{value:p,children:[e,t&&i.jsx(F5e,{onClose:()=>n(!1)}),i.jsx(V5e,{open:r,onClose:()=>o(!1)}),s&&i.jsx(awe,{onClose:()=>a(!1)}),l&&i.jsx(mwe,{onClose:()=>c(!1)})]})}function VS(){const e=f.useContext(I_);if(!e)throw new Error("useShellModals must be used within a ShellModalsProvider");return e}function vwe(){const{open:e,setOpen:t}=cbe();return i.jsx(o$,{children:i.jsx(t_,{children:i.jsx(T$,{children:i.jsx(T2e,{children:i.jsx(A5e,{children:i.jsx(E5e,{children:i.jsx(gwe,{children:i.jsx(C5e,{children:i.jsx(Rbe,{children:i.jsx(s2e,{children:i.jsx(g2e,{children:i.jsx(Kfe,{children:i.jsx(N2e,{children:i.jsx(zye,{children:i.jsx(a5e,{children:i.jsx(g5e,{children:i.jsx(Zve,{children:i.jsx(SB,{children:i.jsxs(IB,{children:[i.jsx(Pse,{}),i.jsx(lbe,{open:e,onOpenChange:t}),i.jsx(a4e,{}),i.jsx(F4e,{})]})})})})})})})})})})})})})})})})})})})}function xwe({title:e}){const t=O();return i.jsxs("section",{className:"flex h-full flex-col p-2g",children:[i.jsx("h1",{className:"mb-2g text-body font-medium text-state-ink",children:e}),i.jsx(fg,{title:t.shNothingHere,className:"flex-1"})]})}function A_(){return vx()&&hS("invoke")}function ywe(e,t){if(e.ok)return e.value;throw e.reason==="failed"?e.error:t}async function bwe(e){const t=await bt("forward_start",{port:e});return ywe(t,new Error("Port forwarding needs the desktop app."))}async function wwe(){var n;const e=await fetch(`${Pc()}/api/forward/ports`,{headers:Oi()});if(!e.ok)throw new Error(`Could not list server ports (${e.status})`);return((n=(await e.json()).data)==null?void 0:n.ports)??[]}async function qS(e,t){const n=await fetch(`${Pc()}${e}`,{...t,headers:{...Oi(),...t!=null&&t.body?{"Content-Type":"application/json"}:{}}}),r=await n.json().catch(()=>({}));if(!n.ok||!r.ok)throw new Error(r.error??`Request failed (${n.status})`);return r.data}async function KS(){return(await qS("/api/forward/devices")).devices??[]}async function Swe(e){return(await qS(`/api/forward/device-ports?device=${encodeURIComponent(e)}`)).ports??[]}async function kwe(e,t){return qS("/api/forward/device-port",{method:"POST",body:JSON.stringify({device:e,port:t})})}const jwe="__cortexBrowserTitle:v1",Cwe=160;function Twe(e,t){if(typeof e!="object"||e===null)return null;const n=e;if(n.type!==jwe||typeof n.title!="string"||typeof n.href!="string"||typeof n.timeOrigin!="number"||!Number.isFinite(n.timeOrigin)||n.timeOrigin<0||!["load","restore","update"].includes(String(n.phase)))return null;let r;try{r=new URL(n.href)}catch{return null}if(!["http:","https:"].includes(r.protocol)||r.origin!==t)return null;const o=n.title.replace(/\s+/g," ").trim().slice(0,Cwe);return{title:o===""?null:o,href:r.toString(),timeOrigin:n.timeOrigin,phase:n.phase}}function Pwe(e,t,n,r){const o=[...e].find(([,a])=>a.contentWindow===t);if(!o)return null;const s=Twe(n,r);return s?{tabId:o[0],title:s.title,timeOrigin:s.timeOrigin,phase:s.phase}:null}const di="'IBM Plex Mono',monospace",Ewe="Enter a port or a URL. Remote dev servers appear here once forwarded.",BT="Not a previewable address — use http(s), a host:port, or a bare port.",$T="Refused: that is this app’s own origin. Previewing it would hand the page your session.",Rwe={open:!1,ports:null,error:null,device:"",devices:[]};function Mwe({tab:e,active:t,onUpdate:n}){const[r,o]=f.useState(Rwe),s=f.useRef(null),a=f.useRef(null),l=f.useRef(1),c=f.useRef(0),d=el(e.history),u=f.useMemo(()=>[typeof window>"u"?"":window.location.origin,Pc()],[]),p=k=>{const C=K9(k);if(C===null)return n(T=>_T(T,BT));if(G9(C,u))return n(T=>_T(T,$T));c.current=0,n(T=>Iwe(T,C))};f.useEffect(()=>{if(typeof window>"u")return;const k=C=>{const T=a.current;if(!T)return;const P=Pwe(new Map([[e.id,T]]),C.source,C.data,C.origin);P&&n(R=>zve(R,P.title,P.timeOrigin,P.phase))};return window.addEventListener("message",k),()=>window.removeEventListener("message",k)},[e.id,n]),f.useEffect(()=>{var k;t&&d===null&&((k=s.current)==null||k.focus())},[t,d]);const h=k=>{c.current=0,n(C=>{const T=k==="back"?Dve(C.history):Lve(C.history);return Ov(C,{history:T,draft:el(T)??""})})},m=()=>{c.current=0,n(k=>Ov(k,{reloadNonce:k.reloadNonce+1}))},x=()=>{var T;let k=!1;try{k=!!((T=a.current)!=null&&T.contentDocument)}catch{k=!1}const C=Mve({documentReachable:k});n(P=>({...P,refused:C}))},v=k=>{o(T=>({...T,ports:null,error:null})),(k===""?wwe():Swe(k)).then(T=>o(P=>P.device===k?{...P,ports:T}:P)).catch(T=>o(P=>P.device===k?{...P,error:T.message}:P))},S=k=>{o(C=>({...C,device:k})),v(k)},b=()=>{if(r.open)return o(k=>({...k,open:!1}));o(k=>({...k,open:!0})),KS().then(k=>{const C=r.device===""||k.some(T=>T.device===r.device)?r.device:"";o(T=>({...T,devices:k,device:C})),v(C)}).catch(()=>{o(k=>({...k,devices:[],device:""})),v("")})},g=async k=>{const C=r.device,T=l.current++;c.current=T,o(P=>({...P,open:!1})),n(P=>({...P,pageTitle:null,forward:{status:"connecting",operationId:T,device:C,originalPort:k},rejected:null}));try{const P=C===""?k:(await kwe(C,k)).localPort;if(c.current!==T)return;const R=A_()?(await bwe(P)).url:`http://127.0.0.1:${P}/`;if(c.current!==T)return;const D=K9(R);if(!D)throw new Error(BT);if(G9(D,u))throw new Error($T);c.current=0,n(I=>Awe(I,T,C,k,D))}catch(P){if(c.current!==T)return;c.current=0,n(R=>Dwe(R,T,P.message))}},w=N5.find(k=>k.id===e.viewportId)??N5[0];return i.jsxs("div",{"data-browser-workspace":e.id,style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[i.jsx(Lwe,{tab:e,url:d,inputRef:s,portsOpen:r.open,onStep:h,onReload:m,onDraft:k=>n(C=>({...C,draft:k})),onNavigate:()=>p(e.draft),onResetDraft:()=>n(k=>({...k,draft:d??""})),onViewport:k=>n(C=>({...C,viewportId:k})),onTogglePorts:b}),r.open&&i.jsx(Owe,{state:r,onDevice:S,onPort:g}),i.jsx(Nwe,{tab:e,url:d}),i.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:"var(--proto-gray)",display:"flex",justifyContent:"center"},children:d===null?i.jsx("div",{style:qwe,children:Ewe}):i.jsx("iframe",{ref:k=>{a.current=k},"data-browser-frame":e.id,onLoad:x,src:d,title:lB(d),sandbox:Rve,style:{border:"none",width:w.width??"100%",flex:w.width?"none":1,minHeight:"100%",background:"var(--proto-card)"}},`${e.documentGeneration}:${e.reloadNonce}`)})]})}function Ov(e,t,n=(r=>(r=e.forward)==null?void 0:r.status)()==="ready"?e.forward:null){return{...e,...t,documentGeneration:e.documentGeneration+1,pageTitle:null,titleTimeOrigin:0,forward:n,refused:!1}}function Iwe(e,t){var o;const n=cB(e.history,t),r={history:n,draft:t,rejected:null};if(n===e.history){const s=((o=e.forward)==null?void 0:o.status)==="ready"?e.forward:null;return{...e,...r,forward:s}}return Ov(e,r)}function _T(e,t){return{...e,rejected:t}}function Awe(e,t,n,r,o){var l;if(((l=e.forward)==null?void 0:l.status)!=="connecting"||e.forward.operationId!==t)return e;const s=cB(e.history,o);return Ov(e,{history:s,draft:o,rejected:null},{status:"ready",device:n,originalPort:r,targetUrl:o})}function Dwe(e,t,n){var r;return((r=e.forward)==null?void 0:r.status)!=="connecting"||e.forward.operationId!==t?e:{...e,forward:null,rejected:n}}function Lwe({tab:e,url:t,inputRef:n,portsOpen:r,onStep:o,onReload:s,onDraft:a,onNavigate:l,onResetDraft:c,onViewport:d,onTogglePorts:u}){const p=mS(e);return i.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:6,padding:"6px 8px",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-card)"},children:[i.jsx(Lm,{title:"Back",disabled:!dB(e.history),onClick:()=>o("back"),children:"‹"}),i.jsx(Lm,{title:"Forward",disabled:!uB(e.history),onClick:()=>o("forward"),children:"›"}),i.jsx(Lm,{title:"Reload",disabled:t===null,onClick:s,children:"⟳"}),i.jsxs("div",{style:zwe,children:[p&&i.jsxs("span",{"data-forward-origin":p,title:`Forwarded from ${p}`,style:Bwe,children:[p,i.jsx("span",{style:{opacity:.65},children:"→"})]}),i.jsx("input",{ref:n,value:e.draft,spellCheck:!1,placeholder:"Port or http://host:port",onChange:h=>a(h.target.value),onKeyDown:h=>{h.key==="Enter"&&l(),h.key==="Escape"&&c()},style:{flex:1,minWidth:0,height:"100%",padding:0,border:"none",background:"transparent",color:"var(--proto-ink)",font:`500 11px ${di}`,outline:"none"}})]}),i.jsx("select",{title:"Viewport width",value:e.viewportId,onChange:h=>d(h.target.value),style:_we,children:N5.map(h=>i.jsx("option",{value:h.id,children:h.label},h.id))}),i.jsx("button",{type:"button",title:"Ports listening on the server or a connected device",onClick:u,style:{...Wwe,border:r?"1.5px solid var(--proto-accent)":"1px solid var(--proto-line)",background:r?"var(--proto-accent-bg)":"var(--proto-card)",color:r?"var(--proto-accent)":"var(--proto-muted)"},children:"Ports"}),i.jsx(Lm,{title:"Open in system browser",disabled:t===null,onClick:()=>{t&&rh(t)},children:"↗"})]})}function Owe({state:e,onDevice:t,onPort:n}){return i.jsxs("div",{style:{flex:"none",maxHeight:190,overflow:"auto",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-card)"},children:[e.devices.length>0&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--proto-line)"},children:[i.jsx(WT,{active:e.device==="",onClick:()=>t(""),children:"server"}),e.devices.map(r=>i.jsx(WT,{active:e.device===r.device,onClick:()=>t(r.device),children:r.device},r.device))]}),e.error?i.jsx(Dm,{children:e.error}):e.ports===null?i.jsx(Dm,{children:"Loading…"}):e.ports.length===0?i.jsxs(Dm,{children:["Nothing is listening on ",e.device===""?"the server’s":`${e.device}’s`," loopback."]}):e.ports.map(r=>i.jsx(Fwe,{port:r,onClick:()=>void n(r.port)},`${e.device}:${r.port}`)),!A_()&&i.jsx(Dm,{children:"Forwarding needs the desktop app — these open as plain localhost here."})]})}function Nwe({tab:e,url:t}){return e.refused&&t?i.jsxs("div",{style:HT,children:[i.jsx("span",{children:Ive}),i.jsx("button",{type:"button","data-action":"open-external",onClick:()=>void rh(t),style:Vwe,children:"↗"})]}):e.rejected?i.jsx("div",{style:{...HT,color:"var(--proto-danger)"},children:e.rejected}):null}function Fwe({port:e,onClick:t}){return i.jsxs("button",{type:"button",onClick:t,style:Uwe,children:[i.jsx("span",{style:{flex:"none",width:54,color:"var(--proto-accent)"},children:e.port}),i.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--proto-muted)"},children:e.process??""}),i.jsx("span",{style:{flex:"none",color:"var(--proto-muted-2)"},children:e.address})]})}function WT({children:e,active:t,onClick:n}){return i.jsx("button",{type:"button",onClick:n,style:{...Hwe,border:t?"1.5px solid var(--proto-accent)":"1px solid var(--proto-line)",background:t?"var(--proto-accent-bg)":"var(--proto-card)",color:t?"var(--proto-accent)":"var(--proto-muted)"},children:e})}function Dm({children:e}){return i.jsx("div",{style:{padding:"10px 12px",color:"var(--proto-muted-2)",font:`500 10.5px ${di}`},children:e})}function Lm({children:e,title:t,disabled:n,onClick:r}){return i.jsx("button",{type:"button",title:t,disabled:n,onClick:r,style:{...$we,opacity:n?.4:1,cursor:n?"default":"pointer"},children:e})}const zwe={flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,height:26,padding:"0 8px",borderRadius:7,border:"1px solid var(--proto-line)",background:"var(--proto-gray)"},Bwe={display:"inline-flex",alignItems:"center",gap:4,flex:"none",maxWidth:"45%",height:16,padding:"0 6px",borderRadius:5,background:"var(--proto-accent-bg)",color:"var(--proto-accent)",font:`600 9px ${di}`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},$we={width:26,height:26,flex:"none",borderRadius:7,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",font:`500 13px ${di}`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0},_we={height:26,borderRadius:7,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",font:`500 10.5px ${di}`,cursor:"pointer"},Wwe={height:26,flex:"none",padding:"0 8px",borderRadius:7,font:`600 10.5px ${di}`,cursor:"pointer"},Hwe={height:22,padding:"0 8px",borderRadius:6,font:`600 10px ${di}`,cursor:"pointer"},Uwe={display:"flex",width:"100%",alignItems:"center",gap:10,padding:"6px 12px",border:"none",borderBottom:"1px solid var(--proto-line)",background:"transparent",color:"var(--proto-ink)",font:`500 11px ${di}`,cursor:"pointer",textAlign:"left"},HT={flex:"none",display:"flex",alignItems:"center",gap:8,padding:"6px 10px",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-gray)",color:"var(--proto-muted-2)",font:`500 10.5px ${di}`},Vwe={border:"1px solid var(--proto-line)",borderRadius:6,background:"transparent",color:"var(--proto-accent)",font:`600 10.5px ${di}`,padding:"1px 7px",cursor:"pointer"},qwe={margin:"auto",padding:"32px 24px",textAlign:"center",color:"var(--proto-muted-2)",font:`500 11.5px ${di}`,maxWidth:320},D_="'IBM Plex Mono',monospace";function Kwe({path:e,onDownload:t,children:n}){return i.jsxs("div",{style:Ywe,children:[i.jsx("span",{"data-file-path":e,title:e,style:Qwe,children:e}),n,t&&i.jsx("span",{role:"button","data-file-download":"",title:"Download",onClick:t,style:Xwe,children:"↓"})]})}function Gwe({on:e,label:t,title:n,onClick:r,...o}){return i.jsx("span",{role:"button","aria-pressed":e,title:n,onClick:r,...o,style:{...Zwe,borderColor:e?"var(--proto-accent)":"var(--proto-line)",background:e?"var(--proto-accent-bg)":"var(--proto-card)",color:e?"var(--proto-accent)":"var(--proto-muted)"},children:t})}const Ywe={flex:"none",display:"flex",alignItems:"center",gap:6,padding:"7px 10px",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-rail)"},Qwe={flex:1,minWidth:0,direction:"rtl",textAlign:"left",unicodeBidi:"plaintext",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",font:`500 10.5px ${D_}`,color:"var(--proto-muted-2)"},Xwe={width:28,height:28,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,cursor:"pointer",flex:"none",userSelect:"none"},Zwe={height:22,padding:"0 8px",borderRadius:6,border:"1px solid var(--proto-line)",display:"inline-flex",alignItems:"center",font:`600 10px ${D_}`,cursor:"pointer",flex:"none",userSelect:"none",whiteSpace:"nowrap"},Jwe="'IBM Plex Mono',monospace";function e6e({item:e}){const t=Mc(),[n,r]=f.useState(!1),o=e.path,s=o?()=>t(o,e.name):void 0,a=Yp(e)&&e.kind==="text"&&kB(e.name);return Yp(e)&&e.kind==="pdf"?i.jsx("div",{style:Rb.pdf,children:i.jsx(MB,{item:e,actions:s&&i.jsx("span",{role:"button","data-file-download":"",title:"Download",onClick:s,style:r6e,children:"↓"})})}):i.jsxs(i.Fragment,{children:[o&&i.jsx(Kwe,{path:o,onDownload:s,children:a&&i.jsx(Gwe,{on:n,label:n?"Rendered":"Source",title:n?"Show the rendered Markdown":"Show the unrendered Markdown source",onClick:()=>r(l=>!l),"data-file-source-toggle":""})}),i.jsx("div",{style:Yp(e)&&e.kind==="text"?Rb.text:Rb.fill,children:Yp(e)?e.kind==="html"?i.jsx(w1,{item:e,mode:"expanded"}):i.jsx(RB,{item:e,source:n}):i.jsx(t6e,{item:e})})]})}function t6e({item:e}){const{src:t,failed:n}=bB(e),{containerRef:r,contentRef:o,style:s}=vS({mode:"transform",minScale:1,maxScale:8});return n?i.jsxs(G5,{failed:!0,children:["Failed to load ",e.name]}):t?i.jsx("div",{ref:r,style:{flex:1,minHeight:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",padding:12,boxSizing:"border-box"},children:e.kind==="video"?i.jsx("video",{src:t,controls:!0,playsInline:!0,style:{maxWidth:"100%",maxHeight:"100%",borderRadius:8,background:"var(--media-stage-bg)"}}):i.jsx("div",{ref:o,style:{...s,display:"inline-block",maxWidth:"100%",maxHeight:"100%"},children:i.jsx("img",{src:t,alt:e.name,draggable:!1,style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",display:"block"}})})}):i.jsx(G5,{children:"Loading…"})}function G5({children:e,failed:t}){return i.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"32px 20px",textAlign:"center",color:t?"var(--proto-faint)":"var(--proto-muted-2)",font:`500 12px ${Jwe}`},children:e})}function n6e(e){return Yp(e)&&e.kind==="pdf"?"var(--proto-gray)":"var(--proto-card)"}const Rb={text:{flex:1,minHeight:0,overflow:"auto"},fill:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},pdf:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"}},r6e={width:28,height:28,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,cursor:"pointer",flex:"none",userSelect:"none"},GS=f.createContext({});function yl(e){const t=f.useRef(null);return t.current===null&&(t.current=e()),t.current}const o6e=typeof window<"u",j0=o6e?f.useLayoutEffect:f.useEffect,yh=f.createContext(null);function YS(e,t){e.indexOf(t)===-1&&e.push(t)}function Nv(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}function UT([...e],t,n){const r=t<0?e.length+t:t;if(r>=0&&r<e.length){const o=n<0?e.length+n:n,[s]=e.splice(t,1);e.splice(o,0,s)}return e}const Fi=(e,t,n)=>n>t?t:n<e?e:n;let T1=()=>{};const rl={},L_=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),O_=e=>typeof e=="object"&&e!==null,N_=e=>/^0[^.\s]+$/u.test(e);function F_(e){let t;return()=>(t===void 0&&(t=e()),t)}const Mo=e=>e,bh=(...e)=>e.reduce((t,n)=>r=>n(t(r))),C0=(e,t,n)=>{const r=t-e;return r?(n-e)/r:1};class QS{constructor(){this.subscriptions=[]}add(t){return YS(this.subscriptions,t),()=>Nv(this.subscriptions,t)}notify(t,n,r){const o=this.subscriptions.length;if(o)if(o===1)this.subscriptions[0](t,n,r);else for(let s=0;s<o;s++){const a=this.subscriptions[s];a&&a(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const so=e=>e*1e3,Co=e=>e/1e3,z_=(e,t)=>t?e*(1e3/t):0,B_=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,i6e=1e-7,s6e=12;function a6e(e,t,n,r,o){let s,a,l=0;do a=t+(n-t)/2,s=B_(a,r,o)-e,s>0?n=a:t=a;while(Math.abs(s)>i6e&&++l<s6e);return a}function wh(e,t,n,r){if(e===t&&n===r)return Mo;const o=s=>a6e(s,0,1,e,n);return s=>s===0||s===1?s:B_(o(s),t,r)}const $_=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,__=e=>t=>1-e(1-t),W_=wh(.33,1.53,.69,.99),XS=__(W_),H_=$_(XS),U_=e=>e>=1?1:(e*=2)<1?.5*XS(e):.5*(2-Math.pow(2,-10*(e-1))),ZS=e=>1-Math.sin(Math.acos(e)),V_=__(ZS),q_=$_(ZS),l6e=wh(.42,0,1,1),c6e=wh(0,0,.58,1),K_=wh(.42,0,.58,1),d6e=e=>Array.isArray(e)&&typeof e[0]!="number",G_=e=>Array.isArray(e)&&typeof e[0]=="number",u6e={linear:Mo,easeIn:l6e,easeInOut:K_,easeOut:c6e,circIn:ZS,circInOut:q_,circOut:V_,backIn:XS,backInOut:H_,backOut:W_,anticipate:U_},p6e=e=>typeof e=="string",VT=e=>{if(G_(e)){T1(e.length===4);const[t,n,r,o]=e;return wh(t,n,r,o)}else if(p6e(e))return u6e[e];return e},Om=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function f6e(e){let t=new Set,n=new Set,r=!1,o=!1;const s=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(d){s.has(d)&&(c.schedule(d),e()),d(a)}const c={schedule:(d,u=!1,p=!1)=>{const m=p&&r?t:n;return u&&s.add(d),m.add(d),d},cancel:d=>{n.delete(d),s.delete(d)},process:d=>{if(a=d,r){o=!0;return}r=!0;const u=t;t=n,n=u,t.forEach(l),t.clear(),r=!1,o&&(o=!1,c.process(d))}};return c}const h6e=40;function Y_(e,t){let n=!1,r=!0;const o={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,a=Om.reduce((w,k)=>(w[k]=f6e(s),w),{}),{setup:l,read:c,resolveKeyframes:d,preUpdate:u,update:p,preRender:h,render:m,postRender:x}=a,v=()=>{const w=rl.useManualTiming,k=w?o.timestamp:performance.now();n=!1,w||(o.delta=r?1e3/60:Math.max(Math.min(k-o.timestamp,h6e),1)),o.timestamp=k,o.isProcessing=!0,l.process(o),c.process(o),d.process(o),u.process(o),p.process(o),h.process(o),m.process(o),x.process(o),o.isProcessing=!1,n&&t&&(r=!1,e(v))},S=()=>{n=!0,r=!0,o.isProcessing||e(v)};return{schedule:Om.reduce((w,k)=>{const C=a[k];return w[k]=(T,P=!1,R=!1)=>(n||S(),C.schedule(T,P,R)),w},{}),cancel:w=>{for(let k=0;k<Om.length;k++)a[Om[k]].cancel(w)},state:o,steps:a}}const{schedule:Et,cancel:Ls,state:Hn,steps:Mb}=Y_(typeof requestAnimationFrame<"u"?requestAnimationFrame:Mo,!0);let Pg;function m6e(){Pg=void 0}const Sr={now:()=>(Pg===void 0&&Sr.set(Hn.isProcessing||rl.useManualTiming?Hn.timestamp:performance.now()),Pg),set:e=>{Pg=e,queueMicrotask(m6e)}},Q_=e=>t=>typeof t=="string"&&t.startsWith(e),X_=Q_("--"),g6e=Q_("var(--"),JS=e=>g6e(e)?v6e.test(e.split("/*")[0].trim()):!1,v6e=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function qT(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const op={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},T0={...op,transform:e=>Fi(0,1,e)},Nm={...op,default:1},jf=e=>Math.round(e*1e5)/1e5,ek=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function x6e(e){return e==null}const y6e=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,tk=(e,t)=>n=>!!(typeof n=="string"&&y6e.test(n)&&n.startsWith(e)||t&&!x6e(n)&&Object.prototype.hasOwnProperty.call(n,t)),Z_=(e,t,n)=>r=>{if(typeof r!="string")return r;const[o,s,a,l]=r.match(ek);return{[e]:parseFloat(o),[t]:parseFloat(s),[n]:parseFloat(a),alpha:l!==void 0?parseFloat(l):1}},b6e=e=>Fi(0,255,e),Ib={...op,transform:e=>Math.round(b6e(e))},Vl={test:tk("rgb","red"),parse:Z_("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+Ib.transform(e)+", "+Ib.transform(t)+", "+Ib.transform(n)+", "+jf(T0.transform(r))+")"};function w6e(e){let t="",n="",r="",o="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),o=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),o=e.substring(4,5),t+=t,n+=n,r+=r,o+=o),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:o?parseInt(o,16)/255:1}}const Y5={test:tk("#"),parse:w6e,transform:Vl.transform},Sh=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ts=Sh("deg"),Ii=Sh("%"),De=Sh("px"),S6e=Sh("vh"),k6e=Sh("vw"),KT={...Ii,parse:e=>Ii.parse(e)/100,transform:e=>Ii.transform(e*100)},Sd={test:tk("hsl","hue"),parse:Z_("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+Ii.transform(jf(t))+", "+Ii.transform(jf(n))+", "+jf(T0.transform(r))+")"},hn={test:e=>Vl.test(e)||Y5.test(e)||Sd.test(e),parse:e=>Vl.test(e)?Vl.parse(e):Sd.test(e)?Sd.parse(e):Y5.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Vl.transform(e):Sd.transform(e),getAnimatableNone:e=>{const t=hn.parse(e);return t.alpha=0,hn.transform(t)}},j6e=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function C6e(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(ek))==null?void 0:t.length)||0)+(((n=e.match(j6e))==null?void 0:n.length)||0)>0}const J_="number",eW="color",T6e="var",P6e="var(",GT="${}",E6e=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Pu(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},o=[];let s=0;const l=t.replace(E6e,c=>(hn.test(c)?(r.color.push(s),o.push(eW),n.push(hn.parse(c))):c.startsWith(P6e)?(r.var.push(s),o.push(T6e),n.push(c)):(r.number.push(s),o.push(J_),n.push(parseFloat(c))),++s,GT)).split(GT);return{values:n,split:l,indexes:r,types:o}}function R6e(e){return Pu(e).values}function tW({split:e,types:t}){const n=e.length;return r=>{let o="";for(let s=0;s<n;s++)if(o+=e[s],r[s]!==void 0){const a=t[s];a===J_?o+=jf(r[s]):a===eW?o+=hn.transform(r[s]):o+=r[s]}return o}}function M6e(e){return tW(Pu(e))}const I6e=e=>typeof e=="number"?0:hn.test(e)?hn.getAnimatableNone(e):e,A6e=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:I6e(e);function D6e(e){const t=Pu(e);return tW(t)(t.values.map((r,o)=>A6e(r,t.split[o])))}const Jo={test:C6e,parse:R6e,createTransformer:M6e,getAnimatableNone:D6e};function Ab(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function L6e({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let o=0,s=0,a=0;if(!t)o=s=a=n;else{const l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;o=Ab(c,l,e+1/3),s=Ab(c,l,e),a=Ab(c,l,e-1/3)}return{red:Math.round(o*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:r}}function Fv(e,t){return n=>n>0?t:e}const vt=(e,t,n)=>e+(t-e)*n,Db=(e,t,n)=>{const r=e*e,o=n*(t*t-r)+r;return o<0?0:Math.sqrt(o)},O6e=[Y5,Vl,Sd],N6e=e=>O6e.find(t=>t.test(e));function YT(e){const t=N6e(e);if(!t)return!1;let n=t.parse(e);return t===Sd&&(n=L6e(n)),n}const QT=(e,t)=>{const n=YT(e),r=YT(t);if(!n||!r)return Fv(e,t);const o={...n};return s=>(o.red=Db(n.red,r.red,s),o.green=Db(n.green,r.green,s),o.blue=Db(n.blue,r.blue,s),o.alpha=vt(n.alpha,r.alpha,s),Vl.transform(o))},Q5=new Set(["none","hidden"]);function F6e(e,t){return Q5.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function z6e(e,t){return n=>vt(e,t,n)}function nk(e){return typeof e=="number"?z6e:typeof e=="string"?JS(e)?Fv:hn.test(e)?QT:_6e:Array.isArray(e)?nW:typeof e=="object"?hn.test(e)?QT:B6e:Fv}function nW(e,t){const n=[...e],r=n.length,o=e.map((s,a)=>nk(s)(s,t[a]));return s=>{for(let a=0;a<r;a++)n[a]=o[a](s);return n}}function B6e(e,t){const n={...e,...t},r={};for(const o in n)e[o]!==void 0&&t[o]!==void 0&&(r[o]=nk(e[o])(e[o],t[o]));return o=>{for(const s in r)n[s]=r[s](o);return n}}function $6e(e,t){const n=[],r={color:0,var:0,number:0};for(let o=0;o<t.values.length;o++){const s=t.types[o],a=e.indexes[s][r[s]],l=e.values[a]??0;n[o]=l,r[s]++}return n}const _6e=(e,t)=>{const n=Jo.createTransformer(t),r=Pu(e),o=Pu(t);return r.indexes.var.length===o.indexes.var.length&&r.indexes.color.length===o.indexes.color.length&&r.indexes.number.length>=o.indexes.number.length?Q5.has(e)&&!o.values.length||Q5.has(t)&&!r.values.length?F6e(e,t):bh(nW($6e(r,o),o.values),n):Fv(e,t)};function rW(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?vt(e,t,n):nk(e)(e,t)}const W6e=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>Et.update(t,n),stop:()=>Ls(t),now:()=>Hn.isProcessing?Hn.timestamp:Sr.now()}},oW=(e,t,n=10)=>{let r="";const o=Math.max(Math.round(t/n),2);for(let s=0;s<o;s++)r+=Math.round(e(s/(o-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},zv=2e4;function rk(e){let t=0;const n=50;let r=e.next(t);for(;!r.done&&t<zv;)t+=n,r=e.next(t);return t>=zv?1/0:t}function H6e(e,t=100,n){const r=n({...e,keyframes:[0,t]}),o=Math.min(rk(r),zv);return{type:"keyframes",ease:s=>r.next(o*s).value/t,duration:Co(o)}}const rn={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function X5(e,t){return e*Math.sqrt(1-t*t)}const U6e=12;function V6e(e,t,n){let r=n;for(let o=1;o<U6e;o++)r=r-e(r)/t(r);return r}const Lb=.001;function q6e({duration:e=rn.duration,bounce:t=rn.bounce,velocity:n=rn.velocity,mass:r=rn.mass}){let o,s,a=1-t;a=Fi(rn.minDamping,rn.maxDamping,a),e=Fi(rn.minDuration,rn.maxDuration,Co(e)),a<1?(o=d=>{const u=d*a,p=u*e,h=u-n,m=X5(d,a),x=Math.exp(-p);return Lb-h/m*x},s=d=>{const p=d*a*e,h=p*n+n,m=Math.pow(a,2)*Math.pow(d,2)*e,x=Math.exp(-p),v=X5(Math.pow(d,2),a);return(-o(d)+Lb>0?-1:1)*((h-m)*x)/v}):(o=d=>{const u=Math.exp(-d*e),p=(d-n)*e+1;return-Lb+u*p},s=d=>{const u=Math.exp(-d*e),p=(n-d)*(e*e);return u*p});const l=5/e,c=V6e(o,s,l);if(e=so(e),isNaN(c))return{stiffness:rn.stiffness,damping:rn.damping,duration:e};{const d=Math.pow(c,2)*r;return{stiffness:d,damping:a*2*Math.sqrt(r*d),duration:e}}}const K6e=["duration","bounce"],G6e=["stiffness","damping","mass"];function XT(e,t){return t.some(n=>e[n]!==void 0)}function Y6e(e){let t={velocity:rn.velocity,stiffness:rn.stiffness,damping:rn.damping,mass:rn.mass,isResolvedFromDuration:!1,...e};if(!XT(e,G6e)&&XT(e,K6e))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),o=r*r,s=2*Fi(.05,1,1-(e.bounce||0))*Math.sqrt(o);t={...t,mass:rn.mass,stiffness:o,damping:s}}else{const n=q6e({...e,velocity:0});t={...t,...n,mass:rn.mass},t.isResolvedFromDuration=!0}return t}function Bv(e=rn.visualDuration,t=rn.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:o}=n;const s=n.keyframes[0],a=n.keyframes[n.keyframes.length-1],l={done:!1,value:s},{stiffness:c,damping:d,mass:u,duration:p,velocity:h,isResolvedFromDuration:m}=Y6e({...n,velocity:-Co(n.velocity||0)}),x=h||0,v=d/(2*Math.sqrt(c*u)),S=a-s,b=Co(Math.sqrt(c/u)),g=Math.abs(S)<5;r||(r=g?rn.restSpeed.granular:rn.restSpeed.default),o||(o=g?rn.restDelta.granular:rn.restDelta.default);let w,k,C,T,P,R;if(v<1)C=X5(b,v),T=(x+v*b*S)/C,w=I=>{const L=Math.exp(-v*b*I);return a-L*(T*Math.sin(C*I)+S*Math.cos(C*I))},P=v*b*T+S*C,R=v*b*S-T*C,k=I=>Math.exp(-v*b*I)*(P*Math.sin(C*I)+R*Math.cos(C*I));else if(v===1){w=L=>a-Math.exp(-b*L)*(S+(x+b*S)*L);const I=x+b*S;k=L=>Math.exp(-b*L)*(b*I*L-x)}else{const I=b*Math.sqrt(v*v-1);w=V=>{const X=Math.exp(-v*b*V),K=Math.min(I*V,300);return a-X*((x+v*b*S)*Math.sinh(K)+I*S*Math.cosh(K))/I};const L=(x+v*b*S)/I,W=v*b*L-S*I,ee=v*b*S-L*I;k=V=>{const X=Math.exp(-v*b*V),K=Math.min(I*V,300);return X*(W*Math.sinh(K)+ee*Math.cosh(K))}}const D={calculatedDuration:m&&p||null,velocity:I=>so(k(I)),next:I=>{if(!m&&v<1){const W=Math.exp(-v*b*I),ee=Math.sin(C*I),V=Math.cos(C*I),X=a-W*(T*ee+S*V),K=so(W*(P*ee+R*V));return l.done=Math.abs(K)<=r&&Math.abs(a-X)<=o,l.value=l.done?a:X,l}const L=w(I);if(m)l.done=I>=p;else{const W=so(k(I));l.done=Math.abs(W)<=r&&Math.abs(a-L)<=o}return l.value=l.done?a:L,l},toString:()=>{const I=Math.min(rk(D),zv),L=oW(W=>D.next(I*W).value,I,30);return I+"ms "+L},toTransition:()=>{}};return D}Bv.applyToOptions=e=>{const t=H6e(e,100,Bv);return e.ease=t.ease,e.duration=so(t.duration),e.type="keyframes",e};const Q6e=5;function iW(e,t,n){const r=Math.max(t-Q6e,0);return z_(n-e(r),t-r)}function Z5({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:o=10,bounceStiffness:s=500,modifyTarget:a,min:l,max:c,restDelta:d=.5,restSpeed:u}){const p=e[0],h={done:!1,value:p},m=R=>l!==void 0&&R<l||c!==void 0&&R>c,x=R=>l===void 0?c:c===void 0||Math.abs(l-R)<Math.abs(c-R)?l:c;let v=n*t;const S=p+v,b=a===void 0?S:a(S);b!==S&&(v=b-p);const g=R=>-v*Math.exp(-R/r),w=R=>b+g(R),k=R=>{const D=g(R),I=w(R);h.done=Math.abs(D)<=d,h.value=h.done?b:I};let C,T;const P=R=>{m(h.value)&&(C=R,T=Bv({keyframes:[h.value,x(h.value)],velocity:iW(w,R,h.value),damping:o,stiffness:s,restDelta:d,restSpeed:u}))};return P(0),{calculatedDuration:null,next:R=>{let D=!1;return!T&&C===void 0&&(D=!0,k(R),P(R)),C!==void 0&&R>=C?T.next(R-C):(!D&&k(R),h)}}}function X6e(e,t,n){const r=[],o=n||rl.mix||rW,s=e.length-1;for(let a=0;a<s;a++){let l=o(e[a],e[a+1]);if(t){const c=Array.isArray(t)?t[a]||Mo:t;l=bh(c,l)}r.push(l)}return r}function sW(e,t,{clamp:n=!0,ease:r,mixer:o}={}){const s=e.length;if(T1(s===t.length),s===1)return()=>t[0];if(s===2&&t[0]===t[1])return()=>t[1];const a=e[0]===e[1];e[0]>e[s-1]&&(e=[...e].reverse(),t=[...t].reverse());const l=X6e(t,r,o),c=l.length,d=u=>{if(a&&u<e[0])return t[0];let p=0;if(c>1)for(;p<e.length-2&&!(u<e[p+1]);p++);const h=C0(e[p],e[p+1],u);return l[p](h)};return n?u=>d(Fi(e[0],e[s-1],u)):d}function Z6e(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const o=C0(0,t,r);e.push(vt(n,1,o))}}function J6e(e){const t=[0];return Z6e(t,e.length-1),t}function e3e(e,t){return e.map(n=>n*t)}function t3e(e,t){return e.map(()=>t||K_).splice(0,e.length-1)}function Cf({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const o=d6e(r)?r.map(VT):VT(r),s={done:!1,value:t[0]},a=e3e(n&&n.length===t.length?n:J6e(t),e),l=sW(a,t,{ease:Array.isArray(o)?o:t3e(t,o)});return{calculatedDuration:e,next:c=>(s.value=l(c),s.done=c>=e,s)}}const n3e=e=>e!==null;function P1(e,{repeat:t,repeatType:n="loop"},r,o=1){const s=e.filter(n3e),l=o<0||t&&n!=="loop"&&t%2===1?0:s.length-1;return!l||r===void 0?s[l]:r}const r3e={decay:Z5,inertia:Z5,tween:Cf,keyframes:Cf,spring:Bv};function aW(e){typeof e.type=="string"&&(e.type=r3e[e.type])}class ok{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const o3e=e=>e/100;class $v extends ok{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var r,o;const{motionValue:n}=this.options;n&&n.updatedAt!==Sr.now()&&this.tick(Sr.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(o=(r=this.options).onStop)==null||o.call(r))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;aW(t);const{type:n=Cf,repeat:r=0,repeatDelay:o=0,repeatType:s,velocity:a=0}=t;let{keyframes:l}=t;const c=n||Cf;c!==Cf&&typeof l[0]!="number"&&(this.mixKeyframes=bh(o3e,rW(l[0],l[1])),l=[0,100]);const d=c({...t,keyframes:l});s==="mirror"&&(this.mirroredGenerator=c({...t,keyframes:[...l].reverse(),velocity:-a})),d.calculatedDuration===null&&(d.calculatedDuration=rk(d));const{calculatedDuration:u}=d;this.calculatedDuration=u,this.resolvedDuration=u+o,this.totalDuration=this.resolvedDuration*(r+1)-o,this.generator=d}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:r,totalDuration:o,mixKeyframes:s,mirroredGenerator:a,resolvedDuration:l,calculatedDuration:c}=this;if(this.startTime===null)return r.next(0);const{delay:d=0,keyframes:u,repeat:p,repeatType:h,repeatDelay:m,type:x,onUpdate:v,finalKeyframe:S}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-o/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const b=this.currentTime-d*(this.playbackSpeed>=0?1:-1),g=this.playbackSpeed>=0?b<0:b>o;this.currentTime=Math.max(b,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=o);let w=this.currentTime,k=r;if(p){const R=Math.min(this.currentTime,o)/l;let D=Math.floor(R),I=R%1;!I&&R>=1&&(I=1),I===1&&D--,D=Math.min(D,p+1),!!(D%2)&&(h==="reverse"?(I=1-I,m&&(I-=m/l)):h==="mirror"&&(k=a)),w=Fi(0,1,I)*l}let C;g?(this.delayState.value=u[0],C=this.delayState):C=k.next(w),s&&!g&&(C.value=s(C.value));let{done:T}=C;!g&&c!==null&&(T=this.playbackSpeed>=0?this.currentTime>=o:this.currentTime<=0);const P=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&T);return P&&x!==Z5&&(C.value=P1(u,this.options,S,this.speed)),v&&v(C.value),P&&this.finish(),C}then(t,n){return this.finished.then(t,n)}get duration(){return Co(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Co(t)}get time(){return Co(this.currentTime)}set time(t){t=so(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return iW(r=>this.generator.next(r).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime(Sr.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=Co(this.currentTime))}play(){var o,s;if(this.isStopped)return;const{driver:t=W6e,startTime:n}=this.options;this.driver||(this.driver=t(a=>this.tick(a))),(s=(o=this.options).onPlay)==null||s.call(o);const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Sr.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function i3e(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const ql=e=>e*180/Math.PI,J5=e=>{const t=ql(Math.atan2(e[1],e[0]));return ew(t)},s3e={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:J5,rotateZ:J5,skewX:e=>ql(Math.atan(e[1])),skewY:e=>ql(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},ew=e=>(e=e%360,e<0&&(e+=360),e),ZT=J5,JT=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),eP=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),a3e={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:JT,scaleY:eP,scale:e=>(JT(e)+eP(e))/2,rotateX:e=>ew(ql(Math.atan2(e[6],e[5]))),rotateY:e=>ew(ql(Math.atan2(-e[2],e[0]))),rotateZ:ZT,rotate:ZT,skewX:e=>ql(Math.atan(e[4])),skewY:e=>ql(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function tw(e){return e.includes("scale")?1:0}function nw(e,t){if(!e||e==="none")return tw(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,o;if(n)r=a3e,o=n;else{const l=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=s3e,o=l}if(!o)return tw(t);const s=r[t],a=o[1].split(",").map(c3e);return typeof s=="function"?s(a):a[s]}const l3e=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return nw(n,t)};function c3e(e){return parseFloat(e.trim())}const ip=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],sp=new Set([...ip,"pathRotation"]),tP=e=>e===op||e===De,d3e=new Set(["x","y","z"]),u3e=ip.filter(e=>!d3e.has(e));function p3e(e){const t=[];return u3e.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const Pa={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:r})=>{const o=e.max-e.min;return r==="border-box"?o:o-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:r})=>{const o=e.max-e.min;return r==="border-box"?o:o-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>nw(t,"x"),y:(e,{transform:t})=>nw(t,"y")};Pa.translateX=Pa.x;Pa.translateY=Pa.y;const ac=new Set;let rw=!1,ow=!1,iw=!1;function lW(){if(ow){const e=Array.from(ac).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const o=p3e(r);o.length&&(n.set(r,o),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const o=n.get(r);o&&o.forEach(([s,a])=>{var l;(l=r.getValue(s))==null||l.set(a)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}ow=!1,rw=!1,ac.forEach(e=>e.complete(iw)),ac.clear()}function cW(){ac.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(ow=!0)})}function f3e(){iw=!0,cW(),lW(),iw=!1}class ik{constructor(t,n,r,o,s,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=o,this.element=s,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(ac.add(this),rw||(rw=!0,Et.read(cW),Et.resolveKeyframes(lW))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:o}=this;if(t[0]===null){const s=o==null?void 0:o.get(),a=t[t.length-1];if(s!==void 0)t[0]=s;else if(r&&n){const l=r.readValue(n,a);l!=null&&(t[0]=l)}t[0]===void 0&&(t[0]=a),o&&s===void 0&&o.set(t[0])}i3e(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),ac.delete(this)}cancel(){this.state==="scheduled"&&(ac.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const h3e=e=>e.startsWith("--");function dW(e,t,n){h3e(t)?e.style.setProperty(t,n):e.style[t]=n}const m3e={};function uW(e,t){const n=F_(e);return()=>m3e[t]??n()}const g3e=uW(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),pW=uW(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Jp=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,nP={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Jp([0,.65,.55,1]),circOut:Jp([.55,0,1,.45]),backIn:Jp([.31,.01,.66,-.59]),backOut:Jp([.33,1.53,.69,.99])};function fW(e,t){if(e)return typeof e=="function"?pW()?oW(e,t):"ease-out":G_(e)?Jp(e):Array.isArray(e)?e.map(n=>fW(n,t)||nP.easeOut):nP[e]}function v3e(e,t,n,{delay:r=0,duration:o=300,repeat:s=0,repeatType:a="loop",ease:l="easeOut",times:c}={},d=void 0){const u={[t]:n};c&&(u.offset=c);const p=fW(l,o);Array.isArray(p)&&(u.easing=p);const h={delay:r,duration:o,easing:Array.isArray(p)?"linear":p,fill:"both",iterations:s+1,direction:a==="reverse"?"alternate":"normal"};return d&&(h.pseudoElement=d),e.animate(u,h)}function hW(e){return typeof e=="function"&&"applyToOptions"in e}function x3e({type:e,...t}){return hW(e)&&pW()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class mW extends ok{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:r,keyframes:o,pseudoElement:s,allowFlatten:a=!1,finalKeyframe:l,onComplete:c}=t;this.isPseudoElement=!!s,this.allowFlatten=a,this.options=t,T1(typeof t.type!="string");const d=x3e(t);this.animation=v3e(n,r,o,d,s),d.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const u=P1(o,this.options,l,this.speed);this.updateMotionValue&&this.updateMotionValue(u),dW(n,r,u),this.animation.cancel()}c==null||c(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var n,r,o;const t=(n=this.options)==null?void 0:n.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((o=(r=this.animation).commitStyles)==null||o.call(r))}get duration(){var n,r;const t=((r=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:r.call(n).duration)||0;return Co(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Co(t)}get time(){return Co(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=so(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:r,observe:o}){var s;return this.allowFlatten&&((s=this.animation.effect)==null||s.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&g3e()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),r&&(this.animation.rangeEnd=r),Mo):o(this)}}const gW={anticipate:U_,backInOut:H_,circInOut:q_};function y3e(e){return e in gW}function b3e(e){typeof e.ease=="string"&&y3e(e.ease)&&(e.ease=gW[e.ease])}const Ob=10;class w3e extends mW{constructor(t){b3e(t),aW(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:r,onComplete:o,element:s,...a}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const l=new $v({...a,autoplay:!1}),c=Math.max(Ob,Sr.now()-this.startTime),d=Fi(0,Ob,c-Ob),u=l.sample(c).value,{name:p}=this.options;s&&p&&dW(s,p,u),n.setWithVelocity(l.sample(Math.max(0,c-d)).value,u,d),l.stop()}}const rP=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Jo.test(e)||e==="0")&&!e.startsWith("url("));function S3e(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function k3e(e,t,n,r){const o=e[0];if(o===null)return!1;if(t==="display"||t==="visibility")return!0;const s=e[e.length-1],a=rP(o,t),l=rP(s,t);return!a||!l?!1:S3e(e)||(n==="spring"||hW(n))&&r}function sw(e){e.duration=0,e.type="keyframes"}const vW=new Set(["opacity","clipPath","filter","transform","backgroundColor"]),j3e=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function C3e(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&j3e.test(e[t]))return!0;return!1}const T3e=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),P3e=F_(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function E3e(e){var p;const{motionValue:t,name:n,repeatDelay:r,repeatType:o,damping:s,type:a,keyframes:l}=e,c=(p=t==null?void 0:t.owner)==null?void 0:p.current;if(!(c instanceof HTMLElement)&&!(c instanceof SVGElement))return!1;const{onUpdate:d,transformTemplate:u}=t.owner.getProps();return P3e()&&n&&(vW.has(n)||T3e.has(n)&&C3e(l))&&(n!=="transform"||!u)&&!d&&!r&&o!=="mirror"&&s!==0&&a!=="inertia"}const R3e=40;class M3e extends ok{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:o=0,repeatDelay:s=0,repeatType:a="loop",keyframes:l,name:c,motionValue:d,element:u,...p}){var x;super(),this.stop=()=>{var v,S;this._animation&&(this._animation.stop(),(v=this.stopTimeline)==null||v.call(this)),(S=this.keyframeResolver)==null||S.cancel()},this.createdAt=Sr.now();const h={autoplay:t,delay:n,type:r,repeat:o,repeatDelay:s,repeatType:a,name:c,motionValue:d,element:u,...p},m=(u==null?void 0:u.KeyframeResolver)||ik;this.keyframeResolver=new m(l,(v,S,b)=>this.onKeyframesResolved(v,S,h,!b),c,d,u),(x=this.keyframeResolver)==null||x.scheduleResolve()}onKeyframesResolved(t,n,r,o){var b,g;this.keyframeResolver=void 0;const{name:s,type:a,velocity:l,delay:c,isHandoff:d,onUpdate:u}=r;this.resolvedAt=Sr.now();let p=!0;k3e(t,s,a,l)||(p=!1,(rl.instantAnimations||!c)&&(u==null||u(P1(t,r,n))),t[0]=t[t.length-1],sw(r),r.repeat=0);const m={startTime:o?this.resolvedAt?this.resolvedAt-this.createdAt>R3e?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:t},x=p&&!d&&E3e(m),v=(g=(b=m.motionValue)==null?void 0:b.owner)==null?void 0:g.current;let S;if(x)try{S=new w3e({...m,element:v})}catch{S=new $v(m)}else S=new $v(m);S.finished.then(()=>{this.notifyFinished()}).catch(Mo),this.pendingTimeline&&(this.stopTimeline=S.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=S}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),f3e()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function xW(e,t,n,r=0,o=1){const s=Array.from(e).sort((d,u)=>d.sortNodePosition(u)).indexOf(t),a=e.size,l=(a-1)*r;return typeof n=="function"?n(s,a):o===1?s*r:l-s*r}const oP=30,I3e=e=>!isNaN(parseFloat(e)),Tf={current:void 0};class A3e{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{var s;const o=Sr.now();if(this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&((s=this.events.change)==null||s.notify(this.current),this.dependents))for(const a of this.dependents)a.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Sr.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=I3e(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new QS);const r=this.events[t].add(n);return t==="change"?()=>{r(),Et.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return Tf.current&&Tf.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const t=Sr.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>oP)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,oP);return z_(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Sc(e,t){return new A3e(e,t)}function sk(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...r}=e;return{...t,...r}}return e}function ak(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?sk(n,e):n}const D3e={type:"spring",stiffness:500,damping:25,restSpeed:10},L3e=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),O3e={type:"keyframes",duration:.8},N3e={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},F3e=(e,{keyframes:t})=>t.length>2?O3e:sp.has(e)?e.startsWith("scale")?L3e(t[1]):D3e:N3e,z3e=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function B3e(e){for(const t in e)if(!z3e.has(t))return!0;return!1}const lk=(e,t,n,r={},o,s)=>a=>{const l=ak(r,e)||{},c=l.delay||r.delay||0;let{elapsed:d=0}=r;d=d-so(c);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...l,delay:-d,onUpdate:h=>{t.set(h),l.onUpdate&&l.onUpdate(h)},onComplete:()=>{a(),l.onComplete&&l.onComplete()},name:e,motionValue:t,element:s?void 0:o};B3e(l)||Object.assign(u,F3e(e,u)),u.duration&&(u.duration=so(u.duration)),u.repeatDelay&&(u.repeatDelay=so(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let p=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(sw(u),u.delay===0&&(p=!0)),(rl.instantAnimations||rl.skipAnimations||o!=null&&o.shouldSkipAnimations||l.skipAnimations)&&(p=!0,sw(u),u.delay=0),u.allowFlatten=!l.type&&!l.ease,p&&!s&&t.get()!==void 0){const h=P1(u.keyframes,l);if(h!==void 0){Et.update(()=>{u.onUpdate(h),u.onComplete()});return}}return l.isSync?new $v(u):new M3e(u)},$3e=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function _3e(e){const t=$3e.exec(e);if(!t)return[,];const[,n,r,o]=t;return[`--${n??r}`,o]}function yW(e,t,n=1){const[r,o]=_3e(e);if(!r)return;const s=window.getComputedStyle(t).getPropertyValue(r);if(s){const a=s.trim();return L_(a)?parseFloat(a):a}return JS(o)?yW(o,t,n+1):o}function iP(e){const t=[{},{}];return e==null||e.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function ck(e,t,n,r){if(typeof t=="function"){const[o,s]=iP(r);t=t(n!==void 0?n:e.custom,o,s)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[o,s]=iP(r);t=t(n!==void 0?n:e.custom,o,s)}return t}function lc(e,t,n){const r=e.getProps();return ck(r,t,n!==void 0?n:r.custom,e)}const bW=new Set(["width","height","top","left","right","bottom",...ip]),aw=e=>Array.isArray(e);function W3e(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Sc(n))}function H3e(e){return aw(e)?e[e.length-1]||0:e}function U3e(e,t){const n=lc(e,t);let{transitionEnd:r={},transition:o={},...s}=n||{};s={...s,...r};for(const a in s){const l=H3e(s[a]);W3e(e,a,l)}}const On=e=>!!(e&&e.getVelocity);function V3e(e){return!!(On(e)&&e.add)}function lw(e,t){const n=e.getValue("willChange");if(V3e(n))return n.add(t);if(!n&&rl.WillChange){const r=new rl.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function dk(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const q3e="framerAppearId",wW="data-"+dk(q3e);function SW(e){return e.props[wW]}const K3e=typeof window<"u";function G3e({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function kW(e,t,{delay:n=0,transitionOverride:r,type:o}={}){let{transition:s,transitionEnd:a,...l}=t;const c=e.getDefaultTransition();s=s?sk(s,c):c;const d=s==null?void 0:s.reduceMotion,u=s==null?void 0:s.skipAnimations;r&&(s=r);const p=[],h=o&&e.animationState&&e.animationState.getState()[o],m=s==null?void 0:s.path;m&&m.animateVisualElement(e,l,s,n,p);for(const x in l){const v=e.getValue(x,e.latestValues[x]??null),S=l[x];if(S===void 0||h&&G3e(h,x))continue;const b={delay:n,...ak(s||{},x)};u&&(b.skipAnimations=!0);const g=v.get();if(g!==void 0&&!v.isAnimating()&&!Array.isArray(S)&&S===g&&!b.velocity){Et.update(()=>v.set(S));continue}let w=!1;if(K3e&&window.MotionHandoffAnimation){const T=SW(e);if(T){const P=window.MotionHandoffAnimation(T,x,Et);P!==null&&(b.startTime=P,w=!0)}}lw(e,x);const k=d??e.shouldReduceMotion;v.start(lk(x,v,S,k&&bW.has(x)?{type:!1}:b,e,w));const C=v.animation;C&&p.push(C)}if(a){const x=()=>Et.update(()=>{a&&U3e(e,a)});p.length?Promise.all(p).then(x):x()}return p}function cw(e,t,n={}){var c;const r=lc(e,t,n.type==="exit"?(c=e.presenceContext)==null?void 0:c.custom:void 0);let{transition:o=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(o=n.transitionOverride);const s=r?()=>Promise.all(kW(e,r,n)):()=>Promise.resolve(),a=e.variantChildren&&e.variantChildren.size?(d=0)=>{const{delayChildren:u=0,staggerChildren:p,staggerDirection:h}=o;return Y3e(e,t,d,u,p,h,n)}:()=>Promise.resolve(),{when:l}=o;if(l){const[d,u]=l==="beforeChildren"?[s,a]:[a,s];return d().then(()=>u())}else return Promise.all([s(),a(n.delay)])}function Y3e(e,t,n=0,r=0,o=0,s=1,a){const l=[];for(const c of e.variantChildren)c.notify("AnimationStart",t),l.push(cw(c,t,{...a,delay:n+(typeof r=="function"?0:r)+xW(e.variantChildren,c,r,o,s)}).then(()=>c.notify("AnimationComplete",t)));return Promise.all(l)}function Q3e(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const o=t.map(s=>cw(e,s,n));r=Promise.all(o)}else if(typeof t=="string")r=cw(e,t,n);else{const o=typeof t=="function"?lc(e,t,n.custom):t;r=Promise.all(kW(e,o,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}const X3e={test:e=>e==="auto",parse:e=>e},jW=e=>t=>t.test(e),CW=[op,De,Ii,ts,k6e,S6e,X3e],sP=e=>CW.find(jW(e));function Z3e(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||N_(e):!0}const J3e=new Set(["brightness","contrast","saturate","opacity"]);function eSe(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(ek)||[];if(!r)return e;const o=n.replace(r,"");let s=J3e.has(t)?1:0;return r!==n&&(s*=100),t+"("+s+o+")"}const tSe=/\b([a-z-]*)\(.*?\)/gu,dw={...Jo,getAnimatableNone:e=>{const t=e.match(tSe);return t?t.map(eSe).join(" "):e}},uw={...Jo,getAnimatableNone:e=>{const t=Jo.parse(e);return Jo.createTransformer(e)(t.map(r=>typeof r=="number"?0:typeof r=="object"?{...r,alpha:1}:r))}},aP={...op,transform:Math.round},nSe={rotate:ts,pathRotation:ts,rotateX:ts,rotateY:ts,rotateZ:ts,scale:Nm,scaleX:Nm,scaleY:Nm,scaleZ:Nm,skew:ts,skewX:ts,skewY:ts,distance:De,translateX:De,translateY:De,translateZ:De,x:De,y:De,z:De,perspective:De,transformPerspective:De,opacity:T0,originX:KT,originY:KT,originZ:De},_v={borderWidth:De,borderTopWidth:De,borderRightWidth:De,borderBottomWidth:De,borderLeftWidth:De,borderRadius:De,borderTopLeftRadius:De,borderTopRightRadius:De,borderBottomRightRadius:De,borderBottomLeftRadius:De,width:De,maxWidth:De,height:De,maxHeight:De,top:De,right:De,bottom:De,left:De,inset:De,insetBlock:De,insetBlockStart:De,insetBlockEnd:De,insetInline:De,insetInlineStart:De,insetInlineEnd:De,padding:De,paddingTop:De,paddingRight:De,paddingBottom:De,paddingLeft:De,paddingBlock:De,paddingBlockStart:De,paddingBlockEnd:De,paddingInline:De,paddingInlineStart:De,paddingInlineEnd:De,margin:De,marginTop:De,marginRight:De,marginBottom:De,marginLeft:De,marginBlock:De,marginBlockStart:De,marginBlockEnd:De,marginInline:De,marginInlineStart:De,marginInlineEnd:De,fontSize:De,backgroundPositionX:De,backgroundPositionY:De,...nSe,zIndex:aP,fillOpacity:T0,strokeOpacity:T0,numOctaves:aP},rSe={..._v,color:hn,backgroundColor:hn,outlineColor:hn,fill:hn,stroke:hn,borderColor:hn,borderTopColor:hn,borderRightColor:hn,borderBottomColor:hn,borderLeftColor:hn,filter:dw,WebkitFilter:dw,mask:uw,WebkitMask:uw},TW=e=>rSe[e],oSe=new Set([dw,uw]);function PW(e,t){let n=TW(e);return oSe.has(n)||(n=Jo),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const iSe=new Set(["auto","none","0"]);function sSe(e,t,n){let r=0,o;for(;r<e.length&&!o;){const s=e[r];typeof s=="string"&&!iSe.has(s)&&Pu(s).values.length&&(o=e[r]),r++}if(o&&n)for(const s of t)e[s]=PW(n,o)}class aSe extends ik{constructor(t,n,r,o,s){super(t,n,r,o,s,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let u=0;u<t.length;u++){let p=t[u];if(typeof p=="string"&&(p=p.trim(),JS(p))){const h=yW(p,n.current);h!==void 0&&(t[u]=h),u===t.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!bW.has(r)||t.length!==2)return;const[o,s]=t,a=sP(o),l=sP(s),c=qT(o),d=qT(s);if(c!==d&&Pa[r]){this.needsMeasurement=!0;return}if(a!==l)if(tP(a)&&tP(l))for(let u=0;u<t.length;u++){const p=t[u];typeof p=="string"&&(t[u]=parseFloat(p))}else Pa[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,r=[];for(let o=0;o<t.length;o++)(t[o]===null||Z3e(t[o]))&&r.push(o);r.length&&sSe(t,r,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Pa[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const o=n[n.length-1];o!==void 0&&t.getValue(r,o).jump(o,!1)}measureEndState(){var l;const{element:t,name:n,unresolvedKeyframes:r}=this;if(!t||!t.current)return;const o=t.getValue(n);o&&o.jump(this.measuredOrigin,!1);const s=r.length-1,a=r[s];r[s]=Pa[n](t.measureViewportBox(),window.getComputedStyle(t.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),(l=this.removedTransforms)!=null&&l.length&&this.removedTransforms.forEach(([c,d])=>{t.getValue(c).set(d)}),this.resolveNoneKeyframes()}}const uk=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function EW(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;const o=(n==null?void 0:n[e])??r.querySelectorAll(e);return o?Array.from(o):[]}return Array.from(e).filter(r=>r!=null)}const pw=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function Eg(e){return O_(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:pk}=Y_(queueMicrotask,!1),Wo={x:!1,y:!1};function RW(){return Wo.x||Wo.y}function lSe(e){return e==="x"||e==="y"?Wo[e]?null:(Wo[e]=!0,()=>{Wo[e]=!1}):Wo.x||Wo.y?null:(Wo.x=Wo.y=!0,()=>{Wo.x=Wo.y=!1})}function MW(e,t){const n=EW(e),r=new AbortController,o={passive:!0,...t,signal:r.signal};return[n,o,()=>r.abort()]}function cSe(e){return!(e.pointerType==="touch"||RW())}function dSe(e,t,n={}){const[r,o,s]=MW(e,n);return r.forEach(a=>{let l=!1,c=!1,d;const u=()=>{a.removeEventListener("pointerleave",x)},p=S=>{d&&(d(S),d=void 0),u()},h=S=>{l=!1,window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),c&&(c=!1,p(S))},m=()=>{l=!0,window.addEventListener("pointerup",h,o),window.addEventListener("pointercancel",h,o)},x=S=>{if(S.pointerType!=="touch"){if(l){c=!0;return}p(S)}},v=S=>{if(!cSe(S))return;c=!1;const b=t(a,S);typeof b=="function"&&(d=b,a.addEventListener("pointerleave",x,o))};a.addEventListener("pointerenter",v,o),a.addEventListener("pointerdown",m,o)}),s}const IW=(e,t)=>t?e===t?!0:IW(e,t.parentElement):!1,fk=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,uSe=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function pSe(e){return uSe.has(e.tagName)||e.isContentEditable===!0}const fSe=new Set(["INPUT","SELECT","TEXTAREA"]);function hSe(e){return fSe.has(e.tagName)||e.isContentEditable===!0}const Rg=new WeakSet;function lP(e){return t=>{t.key==="Enter"&&e(t)}}function Nb(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const mSe=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=lP(()=>{if(Rg.has(n))return;Nb(n,"down");const o=lP(()=>{Nb(n,"up")}),s=()=>Nb(n,"cancel");n.addEventListener("keyup",o,t),n.addEventListener("blur",s,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function cP(e){return fk(e)&&!RW()}const dP=new WeakSet;function gSe(e,t,n={}){const[r,o,s]=MW(e,n),a=l=>{const c=l.currentTarget;if(!cP(l)||dP.has(l))return;Rg.add(c),n.stopPropagation&&dP.add(l);const d=t(c,l),u={...o,capture:!0},p=(x,v)=>{window.removeEventListener("pointerup",h,u),window.removeEventListener("pointercancel",m,u),Rg.has(c)&&Rg.delete(c),cP(x)&&typeof d=="function"&&d(x,{success:v})},h=x=>{p(x,c===window||c===document||n.useGlobalTarget||IW(c,x.target))},m=x=>{p(x,!1)};window.addEventListener("pointerup",h,u),window.addEventListener("pointercancel",m,u)};return r.forEach(l=>{(n.useGlobalTarget?window:l).addEventListener("pointerdown",a,o),Eg(l)&&(l.addEventListener("focus",d=>mSe(d,o)),!pSe(l)&&!l.hasAttribute("tabindex")&&(l.tabIndex=0))}),s}function hk(e){return O_(e)&&"ownerSVGElement"in e}const Mg=new WeakMap;let oa;const AW=(e,t,n)=>(r,o)=>o&&o[0]?o[0][e+"Size"]:hk(r)&&"getBBox"in r?r.getBBox()[t]:r[n],vSe=AW("inline","width","offsetWidth"),xSe=AW("block","height","offsetHeight");function ySe({target:e,borderBoxSize:t}){var n;(n=Mg.get(e))==null||n.forEach(r=>{r(e,{get width(){return vSe(e,t)},get height(){return xSe(e,t)}})})}function bSe(e){e.forEach(ySe)}function wSe(){typeof ResizeObserver>"u"||(oa=new ResizeObserver(bSe))}function SSe(e,t){oa||wSe();const n=EW(e);return n.forEach(r=>{let o=Mg.get(r);o||(o=new Set,Mg.set(r,o)),o.add(t),oa==null||oa.observe(r)}),()=>{n.forEach(r=>{const o=Mg.get(r);o==null||o.delete(t),o!=null&&o.size||oa==null||oa.unobserve(r)})}}const Ig=new Set;let kd;function kSe(){kd=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Ig.forEach(t=>t(e))},window.addEventListener("resize",kd)}function jSe(e){return Ig.add(e),kd||kSe(),()=>{Ig.delete(e),!Ig.size&&typeof kd=="function"&&(window.removeEventListener("resize",kd),kd=void 0)}}function uP(e,t){return typeof e=="function"?jSe(e):SSe(e,t)}function CSe(e){return hk(e)&&e.tagName==="svg"}function TSe(...e){const t=!Array.isArray(e[0]),n=t?0:-1,r=e[0+n],o=e[1+n],s=e[2+n],a=e[3+n],l=sW(o,s,a);return t?l(r):l}const PSe=[...CW,hn,Jo],ESe=e=>PSe.find(jW(e)),pP=()=>({translate:0,scale:1,origin:0,originPoint:0}),jd=()=>({x:pP(),y:pP()}),fP=()=>({min:0,max:0}),jn=()=>({x:fP(),y:fP()}),RSe=new WeakMap;function E1(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function P0(e){return typeof e=="string"||Array.isArray(e)}const mk=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],gk=["initial",...mk];function R1(e){return E1(e.animate)||gk.some(t=>P0(e[t]))}function DW(e){return!!(R1(e)||e.variants)}function MSe(e,t,n){for(const r in t){const o=t[r],s=n[r];if(On(o))e.addValue(r,o);else if(On(s))e.addValue(r,Sc(o,{owner:e}));else if(s!==o)if(e.hasValue(r)){const a=e.getValue(r);a.liveStyle===!0?a.jump(o):a.hasAnimated||a.set(o)}else{const a=e.getStaticValue(r);e.addValue(r,Sc(a!==void 0?a:o,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const Wv={current:null},vk={current:!1},ISe=typeof window<"u";function LW(){if(vk.current=!0,!!ISe)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Wv.current=e.matches;e.addEventListener("change",t),t()}else Wv.current=!1}const hP=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Hv={};function OW(e){Hv=e}function ASe(){return Hv}class DSe{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:o,skipAnimations:s,blockInitialAnimation:a,visualState:l},c={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=ik,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const m=Sr.now();this.renderScheduledAt<m&&(this.renderScheduledAt=m,Et.render(this.render,!1,!0))};const{latestValues:d,renderState:u}=l;this.latestValues=d,this.baseTarget={...d},this.initialValues=n.initial?{...d}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=o,this.skipAnimationsConfig=s,this.options=c,this.blockInitialAnimation=!!a,this.isControllingVariants=R1(n),this.isVariantNode=DW(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:p,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const m in h){const x=h[m];d[m]!==void 0&&On(x)&&x.set(d[m])}}mount(t){var n,r;if(this.hasBeenMounted)for(const o in this.initialValues)(n=this.values.get(o))==null||n.jump(this.initialValues[o]),this.latestValues[o]=this.initialValues[o];this.current=t,RSe.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((o,s)=>this.bindToMotionValue(s,o)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(vk.current||LW(),this.shouldReduceMotion=Wv.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(r=this.parent)==null||r.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),Ls(this.notifyUpdate),Ls(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const r=this.features[n];r&&(r.unmount(),r.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&vW.has(t)&&this.current instanceof HTMLElement){const{factory:a,keyframes:l,times:c,ease:d,duration:u}=n.accelerate,p=new mW({element:this.current,name:t,keyframes:l,times:c,ease:d,duration:so(u)}),h=a(p);this.valueSubscriptions.set(t,()=>{h(),p.cancel()});return}const r=sp.has(t);r&&this.onBindTransform&&this.onBindTransform();const o=n.on("change",a=>{this.latestValues[t]=a,this.props.onUpdate&&Et.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let s;typeof window<"u"&&window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{o(),s&&s()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Hv){const n=Hv[t];if(!n)continue;const{isEnabled:r,Feature:o}=n;if(!this.features[t]&&o&&r(this.props)&&(this.features[t]=new o(this)),this.features[t]){const s=this.features[t];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):jn()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<hP.length;r++){const o=hP[r];this.propEventSubscriptions[o]&&(this.propEventSubscriptions[o](),delete this.propEventSubscriptions[o]);const s="on"+o,a=t[s];a&&(this.propEventSubscriptions[o]=this.on(o,a))}this.prevMotionValues=MSe(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=Sc(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(L_(r)||N_(r))?r=parseFloat(r):!ESe(r)&&Jo.test(n)&&(r=PW(t,n)),this.setBaseTarget(t,On(r)?r.get():r)),On(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var s;const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const a=ck(this.props,n,(s=this.presenceContext)==null?void 0:s.custom);a&&(r=a[t])}if(n&&r!==void 0)return r;const o=this.getBaseTargetFromProps(this.props,t);return o!==void 0&&!On(o)?o:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new QS),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){pk.render(this.render)}}class NW extends DSe{constructor(){super(...arguments),this.KeyframeResolver=aSe}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const r=t.style;return r?r[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;On(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class bl{constructor(t){this.isMounted=!1,this.node=t}update(){}}function FW({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function LSe({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function OSe(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Fb(e){return e===void 0||e===1}function fw({scale:e,scaleX:t,scaleY:n}){return!Fb(e)||!Fb(t)||!Fb(n)}function Dl(e){return fw(e)||zW(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function zW(e){return mP(e.x)||mP(e.y)}function mP(e){return e&&e!=="0%"}function Uv(e,t,n){const r=e-n,o=t*r;return n+o}function gP(e,t,n,r,o){return o!==void 0&&(e=Uv(e,o,r)),Uv(e,n,r)+t}function hw(e,t=0,n=1,r,o){e.min=gP(e.min,t,n,r,o),e.max=gP(e.max,t,n,r,o)}function BW(e,{x:t,y:n}){hw(e.x,t.translate,t.scale,t.originPoint),hw(e.y,n.translate,n.scale,n.originPoint)}const vP=.999999999999,xP=1.0000000000001;function NSe(e,t,n,r=!1){var l;const o=n.length;if(!o)return;t.x=t.y=1;let s,a;for(let c=0;c<o;c++){s=n[c],a=s.projectionDelta;const{visualElement:d}=s.options;d&&d.props.style&&d.props.style.display==="contents"||(r&&s.options.layoutScroll&&s.scroll&&s!==s.root&&(Si(e.x,-s.scroll.offset.x),Si(e.y,-s.scroll.offset.y)),a&&(t.x*=a.x.scale,t.y*=a.y.scale,BW(e,a)),r&&Dl(s.latestValues)&&Ag(e,s.latestValues,(l=s.layout)==null?void 0:l.layoutBox))}t.x<xP&&t.x>vP&&(t.x=1),t.y<xP&&t.y>vP&&(t.y=1)}function Si(e,t){e.min+=t,e.max+=t}function yP(e,t,n,r,o=.5){const s=vt(e.min,e.max,o);hw(e,t,n,s,r)}function bP(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Ag(e,t,n){const r=n??e;yP(e.x,bP(t.x,r.x),t.scaleX,t.scale,t.originX),yP(e.y,bP(t.y,r.y),t.scaleY,t.scale,t.originY)}function $W(e,t){return FW(OSe(e.getBoundingClientRect(),t))}function FSe(e,t,n){const r=$W(e,n),{scroll:o}=t;return o&&(Si(r.x,o.offset.x),Si(r.y,o.offset.y)),r}const zSe={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},BSe=ip.length;function $Se(e,t,n){let r="",o=!0;for(let a=0;a<BSe;a++){const l=ip[a],c=e[l];if(c===void 0)continue;let d=!0;if(typeof c=="number")d=c===(l.startsWith("scale")?1:0);else{const u=parseFloat(c);d=l.startsWith("scale")?u===1:u===0}if(!d||n){const u=pw(c,_v[l]);if(!d){o=!1;const p=zSe[l]||l;r+=`${p}(${u}) `}n&&(t[l]=u)}}const s=e.pathRotation;return s&&(o=!1,r+=`rotate(${pw(s,_v.pathRotation)}) `),r=r.trim(),n?r=n(t,o?"":r):o&&(r="none"),r}function xk(e,t,n){const{style:r,vars:o,transformOrigin:s}=e;let a=!1,l=!1;for(const c in t){const d=t[c];if(sp.has(c)){a=!0;continue}else if(X_(c)){o[c]=d;continue}else{const u=pw(d,_v[c]);c.startsWith("origin")?(l=!0,s[c]=u):r[c]=u}}if(t.transform||(a||n?r.transform=$Se(t,e.transform,n):r.transform&&(r.transform="none")),l){const{originX:c="50%",originY:d="50%",originZ:u=0}=s;r.transformOrigin=`${c} ${d} ${u}`}}function _W(e,{style:t,vars:n},r,o){const s=e.style;let a;for(a in t)s[a]=t[a];o==null||o.applyProjectionStyles(s,r);for(a in n)s.setProperty(a,n[a])}function wP(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Pp={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(De.test(e))e=parseFloat(e);else return e;const n=wP(e,t.target.x),r=wP(e,t.target.y);return`${n}% ${r}%`}},_Se={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,o=Jo.parse(e);if(o.length>5)return r;const s=Jo.createTransformer(e),a=typeof o[0]!="number"?1:0,l=n.x.scale*t.x,c=n.y.scale*t.y;o[0+a]/=l,o[1+a]/=c;const d=vt(l,c,.5);return typeof o[2+a]=="number"&&(o[2+a]/=d),typeof o[3+a]=="number"&&(o[3+a]/=d),s(o)}},mw={borderRadius:{...Pp,applyTo:[...uk]},borderTopLeftRadius:Pp,borderTopRightRadius:Pp,borderBottomLeftRadius:Pp,borderBottomRightRadius:Pp,boxShadow:_Se};function WW(e,{layout:t,layoutId:n}){return sp.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!mw[e]||e==="opacity")}function yk(e,t,n){var a;const r=e.style,o=t==null?void 0:t.style,s={};if(!r)return s;for(const l in r)(On(r[l])||o&&On(o[l])||WW(l,e)||((a=n==null?void 0:n.getValue(l))==null?void 0:a.liveStyle)!==void 0)&&(s[l]=r[l]);return s}function WSe(e){return window.getComputedStyle(e)}class HSe extends NW{constructor(){super(...arguments),this.type="html",this.renderInstance=_W}mount(t){T1(!!t.style),super.mount(t)}readValueFromInstance(t,n){var r;if(sp.has(n))return(r=this.projection)!=null&&r.isProjecting?tw(n):l3e(t,n);{const o=WSe(t),s=(X_(n)?o.getPropertyValue(n):o[n])||0;return typeof s=="string"?s.trim():s}}measureInstanceViewportBox(t,{transformPagePoint:n}){return $W(t,n)}build(t,n,r){xk(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return yk(t,n,r)}}const USe={offset:"stroke-dashoffset",array:"stroke-dasharray"},VSe={offset:"strokeDashoffset",array:"strokeDasharray"};function qSe(e,t,n=1,r=0,o=!0){e.pathLength=1;const s=o?USe:VSe;e[s.offset]=`${-r}`,e[s.array]=`${t} ${n}`}const HW=["transform","opacity","offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function UW(e,{attrX:t,attrY:n,attrScale:r,pathLength:o,pathSpacing:s=1,pathOffset:a=0,...l},c,d,u){if(xk(e,l,d),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:p,style:h}=e;for(const m of HW)p[m]!==void 0&&(h[m]=p[m],delete p[m]);(h.transform||p.transformOrigin)&&(h.transformOrigin=p.transformOrigin??"50% 50%",delete p.transformOrigin),h.transform&&(h.transformBox=(u==null?void 0:u.transformBox)??"fill-box",delete p.transformBox),t!==void 0&&(p.x=t),n!==void 0&&(p.y=n),r!==void 0&&(p.scale=r),o!==void 0&&qSe(p,o,s,a,!1)}const VW=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),qW=e=>typeof e=="string"&&e.toLowerCase()==="svg";function KSe(e,t,n,r){_W(e,t,void 0,r);for(const o in t.attrs)e.setAttribute(VW.has(o)?o:dk(o),t.attrs[o])}function KW(e,t,n){const r=yk(e,t,n);for(const o in e)if(On(e[o])||On(t[o])){const s=ip.indexOf(o)!==-1?"attr"+o.charAt(0).toUpperCase()+o.substring(1):o;r[s]=e[o]}return r}class GSe extends NW{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=jn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(sp.has(n)){const r=TW(n);return r&&r.default||0}if(HW.includes(n)){const o=getComputedStyle(t)[n];if(typeof o=="string"&&o)return o.trim()}return n=VW.has(n)?n:dk(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return KW(t,n,r)}build(t,n,r){UW(t,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(t,n,r,o){KSe(t,n,r,o)}mount(t){this.isSVGTag=qW(t.tagName),super.mount(t)}}const YSe=gk.length;function GW(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?GW(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<YSe;n++){const r=gk[n],o=e.props[r];(P0(o)||o===!1)&&(t[r]=o)}return t}function YW(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}const QSe=[...mk].reverse(),XSe=mk.length;function ZSe(e){return t=>Promise.all(t.map(({animation:n,options:r})=>Q3e(e,n,r)))}function JSe(e){let t=ZSe(e),n=SP(),r=!0,o=!1;const s=d=>(u,p)=>{var m;const h=lc(e,p,d==="exit"?(m=e.presenceContext)==null?void 0:m.custom:void 0);if(h){const{transition:x,transitionEnd:v,...S}=h;u={...u,...S,...v}}return u};function a(d){t=d(e)}function l(d){const{props:u}=e,p=GW(e.parent)||{},h=[],m=new Set;let x={},v=1/0;for(let b=0;b<XSe;b++){const g=QSe[b],w=n[g],k=u[g]!==void 0?u[g]:p[g],C=P0(k),T=g===d?w.isActive:null;T===!1&&(v=b);let P=k===p[g]&&k!==u[g]&&C;if(P&&(r||o)&&e.manuallyAnimateOnMount&&(P=!1),w.protectedKeys={...x},!w.isActive&&T===null||!k&&!w.prevProp||E1(k)||typeof k=="boolean")continue;if(g==="exit"&&w.isActive&&T!==!0){w.prevResolvedValues&&(x={...x,...w.prevResolvedValues});continue}const R=eke(w.prevProp,k);let D=R||g===d&&w.isActive&&!P&&C||b>v&&C,I=!1;const L=Array.isArray(k)?k:[k];let W=L.reduce(s(g),{});T===!1&&(W={});const{prevResolvedValues:ee={}}=w,V={...ee,...W},X=B=>{D=!0,m.has(B)&&(I=!0,m.delete(B)),w.needsAnimating[B]=!0;const G=e.getValue(B);G&&(G.liveStyle=!1)};for(const B in V){const G=W[B],ne=ee[B];if(x.hasOwnProperty(B))continue;let le=!1;aw(G)&&aw(ne)?le=!YW(G,ne)||R:le=G!==ne,le?G!=null?X(B):m.add(B):G!==void 0&&m.has(B)?X(B):w.protectedKeys[B]=!0}w.prevProp=k,w.prevResolvedValues=W,w.isActive&&(x={...x,...W}),(r||o)&&e.blockInitialAnimation&&(D=!1);const K=P&&R;D&&(!K||I)&&h.push(...L.map(B=>{const G={type:g};if(typeof B=="string"&&(r||o)&&!K&&e.manuallyAnimateOnMount&&e.parent){const{parent:ne}=e,le=lc(ne,B);if(ne.enteringChildren&&le){const{delayChildren:_}=le.transition||{};G.delay=xW(ne.enteringChildren,e,_)}}return{animation:B,options:G}}))}if(m.size){const b={};if(typeof u.initial!="boolean"){const g=lc(e,Array.isArray(u.initial)?u.initial[0]:u.initial);g&&g.transition&&(b.transition=g.transition)}m.forEach(g=>{const w=e.getBaseTarget(g),k=e.getValue(g);k&&(k.liveStyle=!0),b[g]=w??null}),h.push({animation:b})}let S=!!h.length;return r&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(S=!1),r=!1,o=!1,S?t(h):Promise.resolve()}function c(d,u){var h;if(n[d].isActive===u)return Promise.resolve();(h=e.variantChildren)==null||h.forEach(m=>{var x;return(x=m.animationState)==null?void 0:x.setActive(d,u)}),n[d].isActive=u;const p=l(d);for(const m in n)n[m].protectedKeys={};return p}return{animateChanges:l,setActive:c,setAnimateFunction:a,getState:()=>n,reset:()=>{n=SP(),o=!0}}}function eke(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!YW(t,e):!1}function El(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function SP(){return{animate:El(!0),whileInView:El(),whileHover:El(),whileTap:El(),whileDrag:El(),whileFocus:El(),exit:El()}}function gw(e,t){e.min=t.min,e.max=t.max}function Bo(e,t){gw(e.x,t.x),gw(e.y,t.y)}function kP(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const QW=1e-4,tke=1-QW,nke=1+QW,XW=.01,rke=0-XW,oke=0+XW;function kr(e){return e.max-e.min}function ike(e,t,n){return Math.abs(e-t)<=n}function jP(e,t,n,r=.5){e.origin=r,e.originPoint=vt(t.min,t.max,e.origin),e.scale=kr(n)/kr(t),e.translate=vt(n.min,n.max,e.origin)-e.originPoint,(e.scale>=tke&&e.scale<=nke||isNaN(e.scale))&&(e.scale=1),(e.translate>=rke&&e.translate<=oke||isNaN(e.translate))&&(e.translate=0)}function Pf(e,t,n,r){jP(e.x,t.x,n.x,r?r.originX:void 0),jP(e.y,t.y,n.y,r?r.originY:void 0)}function CP(e,t,n,r=0){const o=r?vt(n.min,n.max,r):n.min;e.min=o+t.min,e.max=e.min+kr(t)}function ske(e,t,n,r){CP(e.x,t.x,n.x,r==null?void 0:r.x),CP(e.y,t.y,n.y,r==null?void 0:r.y)}function TP(e,t,n,r=0){const o=r?vt(n.min,n.max,r):n.min;e.min=t.min-o,e.max=e.min+kr(t)}function Vv(e,t,n,r){TP(e.x,t.x,n.x,r==null?void 0:r.x),TP(e.y,t.y,n.y,r==null?void 0:r.y)}function PP(e,t,n,r,o){return e-=t,e=Uv(e,1/n,r),o!==void 0&&(e=Uv(e,1/o,r)),e}function ake(e,t=0,n=1,r=.5,o,s=e,a=e){if(Ii.test(t)&&(t=parseFloat(t),t=vt(a.min,a.max,t/100)-a.min),typeof t!="number")return;let l=vt(s.min,s.max,r);e===s&&(l-=t),e.min=PP(e.min,t,n,l,o),e.max=PP(e.max,t,n,l,o)}function EP(e,t,[n,r,o],s,a){ake(e,t[n],t[r],t[o],t.scale,s,a)}const lke=["x","scaleX","originX"],cke=["y","scaleY","originY"];function RP(e,t,n,r){EP(e.x,t,lke,n?n.x:void 0,r?r.x:void 0),EP(e.y,t,cke,n?n.y:void 0,r?r.y:void 0)}function MP(e){return e.translate===0&&e.scale===1}function ZW(e){return MP(e.x)&&MP(e.y)}function IP(e,t){return e.min===t.min&&e.max===t.max}function dke(e,t){return IP(e.x,t.x)&&IP(e.y,t.y)}function AP(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function JW(e,t){return AP(e.x,t.x)&&AP(e.y,t.y)}function DP(e){return kr(e.x)/kr(e.y)}function LP(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function vi(e){return[e("x"),e("y")]}function uke(e,t,n){let r="";const o=e.x.translate/t.x,s=e.y.translate/t.y,a=(n==null?void 0:n.z)||0;if((o||s||a)&&(r=`translate3d(${o}px, ${s}px, ${a}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:d,rotate:u,pathRotation:p,rotateX:h,rotateY:m,skewX:x,skewY:v}=n;d&&(r=`perspective(${d}px) ${r}`),u&&(r+=`rotate(${u}deg) `),p&&(r+=`rotate(${p}deg) `),h&&(r+=`rotateX(${h}deg) `),m&&(r+=`rotateY(${m}deg) `),x&&(r+=`skewX(${x}deg) `),v&&(r+=`skewY(${v}deg) `)}const l=e.x.scale*t.x,c=e.y.scale*t.y;return(l!==1||c!==1)&&(r+=`scale(${l}, ${c})`),r||"none"}const pke=uk.length,OP=e=>typeof e=="string"?parseFloat(e):e,NP=e=>typeof e=="number"||De.test(e);function fke(e,t,n,r,o,s){o?(e.opacity=vt(0,n.opacity??1,hke(r)),e.opacityExit=vt(t.opacity??1,0,mke(r))):s&&(e.opacity=vt(t.opacity??1,n.opacity??1,r));for(let a=0;a<pke;a++){const l=uk[a];let c=FP(t,l),d=FP(n,l);if(c===void 0&&d===void 0)continue;c||(c=0),d||(d=0),c===0||d===0||NP(c)===NP(d)?(e[l]=Math.max(vt(OP(c),OP(d),r),0),(Ii.test(d)||Ii.test(c))&&(e[l]+="%")):e[l]=d}(t.rotate||n.rotate)&&(e.rotate=vt(t.rotate||0,n.rotate||0,r))}function FP(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const hke=eH(0,.5,V_),mke=eH(.5,.95,Mo);function eH(e,t,n){return r=>r<e?0:r>t?1:n(C0(e,t,r))}function gke(e,t,n){const r=On(e)?e:Sc(e);return r.start(lk("",r,t,n)),r.animation}function E0(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}const vke=(e,t)=>e.depth-t.depth;class xke{constructor(){this.children=[],this.isDirty=!1}add(t){YS(this.children,t),this.isDirty=!0}remove(t){Nv(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(vke),this.isDirty=!1,this.children.forEach(t)}}function yke(e,t){const n=Sr.now(),r=({timestamp:o})=>{const s=o-n;s>=t&&(Ls(r),e(s-t))};return Et.setup(r,!0),()=>Ls(r)}function Dg(e){return On(e)?e.get():e}class bke{constructor(){this.members=[]}add(t){YS(this.members,t);for(let n=this.members.length-1;n>=0;n--){const r=this.members[n];if(r===t||r===this.lead||r===this.prevLead)continue;const o=r.instance;(!o||o.isConnected===!1)&&!r.snapshot&&(Nv(this.members,r),r.unmount())}t.scheduleRender()}remove(t){if(Nv(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){var n;for(let r=this.members.indexOf(t)-1;r>=0;r--){const o=this.members[r];if(o.isPresent!==!1&&((n=o.instance)==null?void 0:n.isConnected)!==!1)return this.promote(o),!0}return!1}promote(t,n){var o;const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.updateSnapshot(),t.scheduleRender();const{layoutDependency:s}=r.options,{layoutDependency:a}=t.options;(s===void 0||s!==a)&&(t.resumeFrom=r,n&&(r.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),(o=t.root)!=null&&o.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var n,r,o,s,a;(r=(n=t.options).onExitComplete)==null||r.call(n),(a=(o=t.resumingFrom)==null?void 0:(s=o.options).onExitComplete)==null||a.call(s)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const Lg={hasAnimatedSinceResize:!0,hasEverUpdated:!1},zb=["","X","Y","Z"],wke=1e3;let Ske=0;function Bb(e,t,n,r){const{latestValues:o}=t;o[e]&&(n[e]=o[e],t.setStaticValue(e,0),r&&(r[e]=0))}function tH(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=SW(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:o,layoutId:s}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Et,!(o||s))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&tH(r)}function nH({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:o}){return class{constructor(a={},l=t==null?void 0:t()){this.id=Ske++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Cke),this.nodes.forEach(Ike),this.nodes.forEach(Ake),this.nodes.forEach(Tke)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new xke)}addEventListener(a,l){return this.eventHandlers.has(a)||this.eventHandlers.set(a,new QS),this.eventHandlers.get(a).add(l)}notifyListeners(a,...l){const c=this.eventHandlers.get(a);c&&c.notify(...l)}hasListeners(a){return this.eventHandlers.has(a)}mount(a){if(this.instance)return;this.isSVG=hk(a)&&!CSe(a),this.instance=a;const{layoutId:l,layout:c,visualElement:d}=this.options;if(d&&!d.current&&d.mount(a),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||l)&&(this.isLayoutDirty=!0),e){let u,p=0;const h=()=>this.root.updateBlockedByResize=!1;Et.read(()=>{p=window.innerWidth}),e(a,()=>{const m=window.innerWidth;m!==p&&(p=m,this.root.updateBlockedByResize=!0,u&&u(),u=yke(h,250),Lg.hasAnimatedSinceResize&&(Lg.hasAnimatedSinceResize=!1,this.nodes.forEach($P)))})}l&&this.root.registerSharedNode(l,this),this.options.animate!==!1&&d&&(l||c)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p,hasRelativeLayoutChanged:h,layout:m})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||d.getDefaultTransition()||Fke,{onLayoutAnimationStart:v,onLayoutAnimationComplete:S}=d.getProps(),b=!this.targetLayout||!JW(this.targetLayout,m),g=!p&&h;if(this.options.layoutRoot||this.resumeFrom||g||p&&(b||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const w={...ak(x,"layout"),onPlay:v,onComplete:S};(d.shouldReduceMotion||this.options.layoutRoot)&&(w.delay=0,w.type=!1),this.startAnimation(w),this.setAnimationOrigin(u,g,w.path)}else p||$P(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=m})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Ls(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Dke),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&tH(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const p=this.path[u];p.shouldResetTransform=!0,(typeof p.latestValues.x=="string"||typeof p.latestValues.y=="string")&&(p.isLayoutDirty=!0),p.updateScroll("snapshot"),p.options.layoutRoot&&p.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const d=this.getTransformTemplate();this.prevTransformTemplateValue=d?d(this.latestValues,""):void 0,this.updateSnapshot(),a&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const c=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),c&&this.nodes.forEach(Eke),this.nodes.forEach(zP);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(BP);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Rke),this.nodes.forEach(Mke),this.nodes.forEach(kke),this.nodes.forEach(jke)):this.nodes.forEach(BP),this.clearAllSnapshots();const l=Sr.now();Hn.delta=Fi(0,1e3/60,l-Hn.timestamp),Hn.timestamp=l,Hn.isProcessing=!0,Mb.update.process(Hn),Mb.preRender.process(Hn),Mb.render.process(Hn),Hn.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,pk.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Pke),this.sharedNodes.forEach(Lke)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Et.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Et.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!kr(this.snapshot.measuredBox.x)&&!kr(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const a=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=jn()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,a?a.layoutBox:void 0)}updateScroll(a="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===a&&(l=!1),l&&this.instance){const c=r(this.instance);this.scroll={animationId:this.root.animationId,phase:a,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!o)return;const a=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!ZW(this.projectionDelta),c=this.getTransformTemplate(),d=c?c(this.latestValues,""):void 0,u=d!==this.prevTransformTemplateValue;a&&this.instance&&(l||Dl(this.latestValues)||u)&&(o(this.instance,d),this.shouldResetTransform=!1,this.scheduleRender())}measure(a=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return a&&(c=this.removeTransform(c)),zke(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var d;const{visualElement:a}=this.options;if(!a)return jn();const l=a.measureViewportBox();if(!(((d=this.scroll)==null?void 0:d.wasRoot)||this.path.some(Bke))){const{scroll:u}=this.root;u&&(Si(l.x,u.offset.x),Si(l.y,u.offset.y))}return l}removeElementScroll(a){var c;const l=jn();if(Bo(l,a),(c=this.scroll)!=null&&c.wasRoot)return l;for(let d=0;d<this.path.length;d++){const u=this.path[d],{scroll:p,options:h}=u;u!==this.root&&p&&h.layoutScroll&&(p.wasRoot&&Bo(l,a),Si(l.x,p.offset.x),Si(l.y,p.offset.y))}return l}applyTransform(a,l=!1,c){var u,p;const d=c||jn();Bo(d,a);for(let h=0;h<this.path.length;h++){const m=this.path[h];!l&&m.options.layoutScroll&&m.scroll&&m!==m.root&&(Si(d.x,-m.scroll.offset.x),Si(d.y,-m.scroll.offset.y)),Dl(m.latestValues)&&Ag(d,m.latestValues,(u=m.layout)==null?void 0:u.layoutBox)}return Dl(this.latestValues)&&Ag(d,this.latestValues,(p=this.layout)==null?void 0:p.layoutBox),d}removeTransform(a){var c;const l=jn();Bo(l,a);for(let d=0;d<this.path.length;d++){const u=this.path[d];if(!Dl(u.latestValues))continue;let p;u.instance&&(fw(u.latestValues)&&u.updateSnapshot(),p=jn(),Bo(p,u.measurePageBox())),RP(l,u.latestValues,(c=u.snapshot)==null?void 0:c.layoutBox,p)}return Dl(this.latestValues)&&RP(l,this.latestValues),l}setTargetDelta(a){this.targetDelta=a,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(a){this.options={...this.options,...a,crossfade:a.crossfade!==void 0?a.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Hn.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(a=!1){var m;const l=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=l.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=l.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=l.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==l;if(!(a||c&&this.isSharedProjectionDirty||this.isProjectionDirty||(m=this.parent)!=null&&m.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:p}=this.options;if(!this.layout||!(u||p))return;this.resolvedRelativeTargetAt=Hn.timestamp;const h=this.getClosestProjectingParent();h&&this.linkedParentVersion!==h.layoutVersion&&!h.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&h&&h.layout?this.createRelativeTarget(h,this.layout.layoutBox,h.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=jn(),this.targetWithTransforms=jn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),ske(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Bo(this.target,this.layout.layoutBox),BW(this.target,this.targetDelta)):Bo(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&h&&!!h.resumingFrom==!!this.resumingFrom&&!h.options.layoutScroll&&h.target&&this.animationProgress!==1?this.createRelativeTarget(h,this.target,h.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||fw(this.parent.latestValues)||zW(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(a,l,c){this.relativeParent=a,this.linkedParentVersion=a.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=jn(),this.relativeTargetOrigin=jn(),Vv(this.relativeTargetOrigin,l,c,this.options.layoutAnchor||void 0),Bo(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var x;const a=this.getLead(),l=!!this.resumingFrom||this!==a;let c=!0;if((this.isProjectionDirty||(x=this.parent)!=null&&x.isProjectionDirty)&&(c=!1),l&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===Hn.timestamp&&(c=!1),c)return;const{layout:d,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(d||u))return;Bo(this.layoutCorrected,this.layout.layoutBox);const p=this.treeScale.x,h=this.treeScale.y;NSe(this.layoutCorrected,this.treeScale,this.path,l),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=jn());const{target:m}=a;if(!m){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(kP(this.prevProjectionDelta.x,this.projectionDelta.x),kP(this.prevProjectionDelta.y,this.projectionDelta.y)),Pf(this.projectionDelta,this.layoutCorrected,m,this.latestValues),(this.treeScale.x!==p||this.treeScale.y!==h||!LP(this.projectionDelta.x,this.prevProjectionDelta.x)||!LP(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",m))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(a=!0){var l;if((l=this.options.visualElement)==null||l.scheduleRender(),a){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=jd(),this.projectionDelta=jd(),this.projectionDeltaWithTransform=jd()}setAnimationOrigin(a,l=!1,c){const d=this.snapshot,u=d?d.latestValues:{},p={...this.latestValues},h=jd();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const m=jn(),x=d?d.source:void 0,v=this.layout?this.layout.source:void 0,S=x!==v,b=this.getStack(),g=!b||b.members.length<=1,w=!!(S&&!g&&this.options.crossfade===!0&&!this.path.some(Nke));this.animationProgress=0;let k;const C=c==null?void 0:c.interpolateProjection(a);this.mixTargetDelta=T=>{const P=T/1e3,R=C==null?void 0:C(P);R?(h.x.translate=R.x,h.x.scale=vt(a.x.scale,1,P),h.x.origin=a.x.origin,h.x.originPoint=a.x.originPoint,h.y.translate=R.y,h.y.scale=vt(a.y.scale,1,P),h.y.origin=a.y.origin,h.y.originPoint=a.y.originPoint):(_P(h.x,a.x,P),_P(h.y,a.y,P)),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Vv(m,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Oke(this.relativeTarget,this.relativeTargetOrigin,m,P),k&&dke(this.relativeTarget,k)&&(this.isProjectionDirty=!1),k||(k=jn()),Bo(k,this.relativeTarget)),S&&(this.animationValues=p,fke(p,u,this.latestValues,P,w,g)),R&&R.rotate!==void 0&&(this.animationValues||(this.animationValues=p),this.animationValues.pathRotation=R.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){var l,c,d;this.notifyListeners("animationStart"),(l=this.currentAnimation)==null||l.stop(),(d=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||d.stop(),this.pendingAnimation&&(Ls(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Et.update(()=>{Lg.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Sc(0)),this.motionValue.jump(0,!1),this.currentAnimation=gke(this.motionValue,[0,1e3],{...a,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),a.onUpdate&&a.onUpdate(u)},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(wke),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:l,target:c,layout:d,latestValues:u}=a;if(!(!l||!c||!d)){if(this!==a&&this.layout&&d&&rH(this.options.animationType,this.layout.layoutBox,d.layoutBox)){c=this.target||jn();const p=kr(this.layout.layoutBox.x);c.x.min=a.target.x.min,c.x.max=c.x.min+p;const h=kr(this.layout.layoutBox.y);c.y.min=a.target.y.min,c.y.max=c.y.min+h}Bo(l,c),Ag(l,u),Pf(this.projectionDeltaWithTransform,this.layoutCorrected,l,u)}}registerSharedNode(a,l){this.sharedNodes.has(a)||this.sharedNodes.set(a,new bke),this.sharedNodes.get(a).add(l);const d=l.options.initialPromotionConfig;l.promote({transition:d?d.transition:void 0,preserveFollowOpacity:d&&d.shouldPreserveFollowOpacity?d.shouldPreserveFollowOpacity(l):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var l;const{layoutId:a}=this.options;return a?((l=this.getStack())==null?void 0:l.lead)||this:this}getPrevLead(){var l;const{layoutId:a}=this.options;return a?(l=this.getStack())==null?void 0:l.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:l,preserveFollowOpacity:c}={}){const d=this.getStack();d&&d.promote(this,c),a&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let l=!1;const{latestValues:c}=a;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const d={};c.z&&Bb("z",a,d,this.animationValues);for(let u=0;u<zb.length;u++)Bb(`rotate${zb[u]}`,a,d,this.animationValues),Bb(`skew${zb[u]}`,a,d,this.animationValues);a.render();for(const u in d)a.setStaticValue(u,d[u]),this.animationValues&&(this.animationValues[u]=d[u]);a.scheduleRender()}applyProjectionStyles(a,l){if(!this.instance||this.isSVG)return;if(!this.isVisible){a.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,a.visibility="",a.opacity="",a.pointerEvents=Dg(l==null?void 0:l.pointerEvents)||"",a.transform=c?c(this.latestValues,""):"none";return}const d=this.getLead();if(!this.projectionDelta||!this.layout||!d.target){this.options.layoutId&&(a.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,a.pointerEvents=Dg(l==null?void 0:l.pointerEvents)||""),this.hasProjected&&!Dl(this.latestValues)&&(a.transform=c?c({},""):"none",this.hasProjected=!1);return}a.visibility="";const u=d.animationValues||d.latestValues;this.applyTransformsToTarget();let p=uke(this.projectionDeltaWithTransform,this.treeScale,u);c&&(p=c(u,p)),a.transform=p;const{x:h,y:m}=this.projectionDelta;a.transformOrigin=`${h.origin*100}% ${m.origin*100}% 0`,d.animationValues?a.opacity=d===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:a.opacity=d===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const x in mw){if(u[x]===void 0)continue;const{correct:v,applyTo:S,isCSSVariable:b}=mw[x],g=p==="none"?u[x]:v(u[x],d);if(S){const w=S.length;for(let k=0;k<w;k++)a[S[k]]=g}else b?this.options.visualElement.renderState.vars[x]=g:a[x]=g}this.options.layoutId&&(a.pointerEvents=d===this?Dg(l==null?void 0:l.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(a=>{var l;return(l=a.currentAnimation)==null?void 0:l.stop()}),this.root.nodes.forEach(zP),this.root.sharedNodes.clear()}}}function kke(e){e.updateLayout()}function jke(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:o}=e.layout,{animationType:s}=e.options,a=t.source!==e.layout.source;if(s==="size")vi(p=>{const h=a?t.measuredBox[p]:t.layoutBox[p],m=kr(h);h.min=r[p].min,h.max=h.min+m});else if(s==="x"||s==="y"){const p=s==="x"?"y":"x";gw(a?t.measuredBox[p]:t.layoutBox[p],r[p])}else rH(s,t.layoutBox,r)&&vi(p=>{const h=a?t.measuredBox[p]:t.layoutBox[p],m=kr(r[p]);h.max=h.min+m,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[p].max=e.relativeTarget[p].min+m)});const l=jd();Pf(l,r,t.layoutBox);const c=jd();a?Pf(c,e.applyTransform(o,!0),t.measuredBox):Pf(c,r,t.layoutBox);const d=!ZW(l);let u=!1;if(!e.resumeFrom){const p=e.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:h,layout:m}=p;if(h&&m){const x=e.options.layoutAnchor||void 0,v=jn();Vv(v,t.layoutBox,h.layoutBox,x);const S=jn();Vv(S,r,m.layoutBox,x),JW(v,S)||(u=!0),p.options.layoutRoot&&(e.relativeTarget=S,e.relativeTargetOrigin=v,e.relativeParent=p)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:t,delta:c,layoutDelta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:r}=e.options;r&&r()}e.options.transition=void 0}function Cke(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function Tke(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Pke(e){e.clearSnapshot()}function zP(e){e.clearMeasurements()}function Eke(e){e.isLayoutDirty=!0,e.updateLayout()}function BP(e){e.isLayoutDirty=!1}function Rke(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Mke(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function $P(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Ike(e){e.resolveTargetDelta()}function Ake(e){e.calcProjection()}function Dke(e){e.resetSkewAndRotation()}function Lke(e){e.removeLeadSnapshot()}function _P(e,t,n){e.translate=vt(t.translate,0,n),e.scale=vt(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function WP(e,t,n,r){e.min=vt(t.min,n.min,r),e.max=vt(t.max,n.max,r)}function Oke(e,t,n,r){WP(e.x,t.x,n.x,r),WP(e.y,t.y,n.y,r)}function Nke(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Fke={duration:.45,ease:[.4,0,.1,1]},HP=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),UP=HP("applewebkit/")&&!HP("chrome/")?Math.round:Mo;function VP(e){e.min=UP(e.min),e.max=UP(e.max)}function zke(e){VP(e.x),VP(e.y)}function rH(e,t,n){return e==="position"||e==="preserve-aspect"&&!ike(DP(t),DP(n),.2)}function Bke(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const $ke=nH({attachResizeListener:(e,t)=>E0(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),$b={current:void 0},oH=nH({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!$b.current){const e=new $ke({});e.mount(window),e.setOptions({layoutScroll:!0}),$b.current=e}return $b.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Eu=f.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function qP(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function _ke(...e){return t=>{let n=!1;const r=e.map(o=>{const s=qP(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():qP(e[o],null)}}}}function Wke(...e){return f.useCallback(_ke(...e),e)}class Hke extends f.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(Eg(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const r=n.offsetParent,o=Eg(r)&&r.offsetWidth||0,s=Eg(r)&&r.offsetHeight||0,a=getComputedStyle(n),l=this.props.sizeRef.current;l.height=parseFloat(a.height),l.width=parseFloat(a.width),l.top=n.offsetTop,l.left=n.offsetLeft,l.right=o-l.width-l.left,l.bottom=s-l.height-l.top,l.direction=a.direction}return null}componentDidUpdate(){}render(){return this.props.children}}function Uke({children:e,isPresent:t,anchorX:n,anchorY:r,root:o,pop:s}){var h;const a=f.useId(),l=f.useRef(null),c=f.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:"ltr"}),{nonce:d}=f.useContext(Eu),u=s!==!1?((h=e.props)==null?void 0:h.ref)??(e==null?void 0:e.ref):void 0,p=Wke(l,u);return f.useInsertionEffect(()=>{const{width:m,height:x,top:v,left:S,right:b,bottom:g,direction:w}=c.current;if(t||s===!1||!l.current||!m||!x)return;const k=w==="rtl",C=n==="left"?k?`right: ${b}`:`left: ${S}`:k?`left: ${S}`:`right: ${b}`,T=r==="bottom"?`bottom: ${g}`:`top: ${v}`;l.current.dataset.motionPopId=a;const P=document.createElement("style");d&&(P.nonce=d);const R=o??document.head;return R.appendChild(P),P.sheet&&P.sheet.insertRule(`
431
431
  [data-motion-pop-id="${a}"] {
432
432
  position: absolute !important;
433
433
  width: ${m}px !important;
@@ -438,6 +438,6 @@ ${s}`:n.push(s)}return{fields:t,desc:n.length>0?n.join(`
438
438
  `),()=>{var D;(D=l.current)==null||D.removeAttribute("data-motion-pop-id"),R.contains(P)&&R.removeChild(P)}},[t]),i.jsx(Hke,{isPresent:t,childRef:l,sizeRef:c,pop:s,children:s===!1?e:f.cloneElement(e,{ref:p})})}const Vke=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:o,presenceAffectsLayout:s,mode:a,anchorX:l,anchorY:c,root:d})=>{const u=yl(qke),p=f.useId(),h=f.useRef(n),m=f.useRef(r);j0(()=>{h.current=n,m.current=r});let x=!0,v=f.useMemo(()=>(x=!1,{id:p,initial:t,isPresent:n,custom:o,onExitComplete:S=>{u.set(S,!0);for(const b of u.values())if(!b)return;r&&r()},register:S=>(u.set(S,!1),()=>{var b;u.delete(S),!h.current&&!u.size&&((b=m.current)==null||b.call(m))})}),[n,u,r]);return s&&x&&(v={...v}),f.useMemo(()=>{u.forEach((S,b)=>u.set(b,!1))},[n]),f.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=i.jsx(Uke,{pop:a==="popLayout",isPresent:n,anchorX:l,anchorY:c,root:d,children:e}),i.jsx(yh.Provider,{value:v,children:e})};function qke(){return new Map}function iH(e=!0){const t=f.useContext(yh);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:o}=t,s=f.useId();f.useEffect(()=>{if(e)return o(s)},[e]);const a=f.useCallback(()=>e&&r&&r(s),[s,r,e]);return!n&&r?[!1,a]:[!0]}function Kke(){return Gke(f.useContext(yh))}function Gke(e){return e===null?!0:e.isPresent}const Fm=e=>e.key||"";function KP(e){const t=[];return f.Children.forEach(e,n=>{f.isValidElement(n)&&t.push(n)}),t}const Yke=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:o=!0,mode:s="sync",propagate:a=!1,anchorX:l="left",anchorY:c="top",root:d})=>{const[u,p]=iH(a),h=f.useMemo(()=>KP(e),[e]),m=a&&!u?[]:h.map(Fm),x=f.useRef(!0),v=f.useRef(h),S=yl(()=>new Map),b=f.useRef(new Set),[g,w]=f.useState(h),[k,C]=f.useState(h);j0(()=>{a&&!u&&!k.length&&(p==null||p())},[u,a,k.length,p]),j0(()=>{x.current=!1,v.current=h;for(let R=0;R<k.length;R++){const D=Fm(k[R]);m.includes(D)?(S.delete(D),b.current.delete(D)):S.get(D)!==!0&&S.set(D,!1)}},[k,m.length,m.join("-")]);const T=[];if(h!==g){let R=[...h],D=0;for(const I of k){const L=m.indexOf(Fm(I));L===-1?(R.splice(D++,0,I),T.push(I)):D=L+T.length+1}return s==="wait"&&T.length&&(R=T),C(KP(R)),w(h),null}const{forceRender:P}=f.useContext(GS);return i.jsx(i.Fragment,{children:k.map(R=>{const D=Fm(R),I=a&&!u?!1:h===k||m.includes(D),L=()=>{if(b.current.has(D))return;if(S.has(D))b.current.add(D),S.set(D,!0);else return;let W=!0;S.forEach(ee=>{ee||(W=!1)}),W&&(P==null||P(),C(v.current),a&&(p==null||p()),r&&r())};return i.jsx(Vke,{isPresent:I,initial:!x.current||n?void 0:!1,custom:t,presenceAffectsLayout:o,mode:s,root:d,onExitComplete:I?void 0:L,anchorX:l,anchorY:c,children:R},D)})})},sH=f.createContext({strict:!1}),GP={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let YP=!1;function Qke(){if(YP)return;const e={};for(const t in GP)e[t]={isEnabled:n=>GP[t].some(r=>!!n[r])};OW(e),YP=!0}function aH(){return Qke(),ASe()}function Xke(e){const t=aH();for(const n in e)t[n]={...t[n],...e[n]};OW(t)}function Zke({children:e,...t}){const n=f.useContext(Eu);t={...n,...t},t.transition=sk(t.transition,n.transition),t.isStatic=yl(()=>t.isStatic);const r=f.useMemo(()=>t,[JSON.stringify(t.transition),t.transformPagePoint,t.reducedMotion,t.skipAnimations,t.isValidProp]);return i.jsx(Eu.Provider,{value:r,children:e})}const M1=f.createContext({});function Jke(e,t){if(R1(e)){const{initial:n,animate:r}=e;return{initial:n===!1||P0(n)?n:void 0,animate:P0(r)?r:void 0}}return e.inherit!==!1?t:{}}function eje(e){const{initial:t,animate:n}=Jke(e,f.useContext(M1));return f.useMemo(()=>({initial:t,animate:n}),[QP(t),QP(n)])}function QP(e){return Array.isArray(e)?e.join(" "):e}const bk=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function lH(e,t,n){for(const r in t)!On(t[r])&&!WW(r,n)&&(e[r]=t[r])}function tje({transformTemplate:e},t){return f.useMemo(()=>{const n=bk();return xk(n,t,e),Object.assign({},n.vars,n.style)},[t])}function nje(e,t){const n=e.style||{},r={};return lH(r,n,e),Object.assign(r,tje(e,t)),r}function rje(e,t){const n={},r=nje(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}const cH=()=>({...bk(),attrs:{}});function oje(e,t,n,r){const o=f.useMemo(()=>{const s=cH();return UW(s,t,qW(r),e.transformTemplate,e.style),{...s.attrs,style:{...s.style}}},[t]);if(e.style){const s={};lH(s,e.style,e),o.style={...s,...o.style}}return o}const ije=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function qv(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||ije.has(e)}function sje(e,t){return e.startsWith("on")?!qv(e):(t==null?void 0:t(e))??!qv(e)}function aje(e,t,n,r){const o={};for(const s in e)s==="values"&&typeof e.values=="object"||On(e[s])||(sje(s,r)||n===!0&&qv(s)||!t&&!qv(s)||e.draggable&&s.startsWith("onDrag"))&&(o[s]=e[s]);return o}const lje=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function wk(e){return typeof e!="string"||e.includes("-")?!1:!!(lje.indexOf(e)>-1||/[A-Z]/u.test(e))}function cje(e,t,n,{latestValues:r},o,s=!1,a,l){const d=(a??wk(e)?oje:rje)(t,r,o,e),u=aje(t,typeof e=="string",s,l),p=e!==f.Fragment?{...u,...d,ref:n}:{},{children:h}=t,m=f.useMemo(()=>On(h)?h.get():h,[h]);return f.createElement(e,{...p,children:m})}function dje({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,o){return{latestValues:uje(n,r,o,e),renderState:t()}}function uje(e,t,n,r){const o={},s=r(e,{});for(const h in s)o[h]=Dg(s[h]);let{initial:a,animate:l}=e;const c=R1(e),d=DW(e);t&&d&&!c&&e.inherit!==!1&&(a===void 0&&(a=t.initial),l===void 0&&(l=t.animate));let u=n?n.initial===!1:!1;u=u||a===!1;const p=u?l:a;if(p&&typeof p!="boolean"&&!E1(p)){const h=Array.isArray(p)?p:[p];for(let m=0;m<h.length;m++){const x=ck(e,h[m]);if(x){const{transitionEnd:v,transition:S,...b}=x;for(const g in b){let w=b[g];if(Array.isArray(w)){const k=u?w.length-1:0;w=w[k]}w!==null&&(o[g]=w)}for(const g in v)o[g]=v[g]}}}return o}const dH=e=>(t,n)=>{const r=f.useContext(M1),o=f.useContext(yh),s=()=>dje(e,t,r,o);return n?s():yl(s)},pje=dH({scrapeMotionValuesFromProps:yk,createRenderState:bk}),fje=dH({scrapeMotionValuesFromProps:KW,createRenderState:cH}),hje=Symbol.for("motionComponentSymbol");function mje(e,t,n){const r=f.useRef(n);f.useInsertionEffect(()=>{r.current=n});const o=f.useRef(null);return f.useCallback(s=>{var l;s&&((l=e.onMount)==null||l.call(e,s)),t&&(s?t.mount(s):t.unmount());const a=r.current;if(typeof a=="function")if(s){const c=a(s);typeof c=="function"&&(o.current=c)}else o.current?(o.current(),o.current=null):a(s);else a&&(a.current=s)},[t])}const uH=f.createContext({});function sd(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function gje(e,t,n,r,o,s){var w,k;const{visualElement:a}=f.useContext(M1),l=f.useContext(sH),c=f.useContext(yh),d=f.useContext(Eu),u=d.reducedMotion,p=d.skipAnimations,h=f.useRef(null),m=f.useRef(!1);r=r||l.renderer,!h.current&&r&&(h.current=r(e,{visualState:t,parent:a,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:p,isSVG:s}),m.current&&h.current&&(h.current.manuallyAnimateOnMount=!0));const x=h.current,v=f.useContext(uH);x&&!x.projection&&o&&(x.type==="html"||x.type==="svg")&&vje(h.current,n,o,v);const S=f.useRef(!1);f.useInsertionEffect(()=>{x&&S.current&&x.update(n,c)});const b=n[wW],g=f.useRef(!!b&&typeof window<"u"&&!((w=window.MotionHandoffIsComplete)!=null&&w.call(window,b))&&((k=window.MotionHasOptimisedAnimation)==null?void 0:k.call(window,b)));return j0(()=>{m.current=!0,x&&(S.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),g.current&&x.animationState&&x.animationState.animateChanges())}),f.useEffect(()=>{x&&(!g.current&&x.animationState&&x.animationState.animateChanges(),g.current&&(queueMicrotask(()=>{var C;(C=window.MotionHandoffMarkAsComplete)==null||C.call(window,b)}),g.current=!1),x.enteringChildren=void 0)}),x}function vje(e,t,n,r){const{layoutId:o,layout:s,drag:a,dragConstraints:l,layoutScroll:c,layoutRoot:d,layoutAnchor:u,layoutCrossfade:p}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:pH(e.parent)),e.projection.setOptions({layoutId:o,layout:s,alwaysMeasureLayout:!!a||l&&sd(l),visualElement:e,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,crossfade:p,layoutScroll:c,layoutRoot:d,layoutAnchor:u})}function pH(e){if(e)return e.options.allowProjection!==!1?e.projection:pH(e.parent)}function _b(e,{forwardMotionProps:t=!1,type:n}={},r,o){r&&Xke(r);const s=n?n==="svg":wk(e),a=s?fje:pje;function l(d,u){let p;const h={...f.useContext(Eu),...d,layoutId:xje(d)},{isStatic:m,isValidProp:x}=h,v=eje(d),S=a(d,m);if(!m&&typeof window<"u"){yje();const b=bje(h);p=b.MeasureLayout,v.visualElement=gje(e,S,h,o,b.ProjectionNode,s)}return i.jsxs(M1.Provider,{value:v,children:[p&&v.visualElement?i.jsx(p,{visualElement:v.visualElement,...h}):null,cje(e,d,mje(S,v.visualElement,u),S,m,t,s,x)]})}l.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const c=f.forwardRef(l);return c[hje]=e,c}function xje({layoutId:e}){const t=f.useContext(GS).id;return t&&e!==void 0?t+"-"+e:e}function yje(e,t){f.useContext(sH).strict}function bje(e){const t=aH(),{drag:n,layout:r}=t;if(!n&&!r)return{};const o={...n,...r};return{MeasureLayout:n!=null&&n.isEnabled(e)||r!=null&&r.isEnabled(e)?o.MeasureLayout:void 0,ProjectionNode:o.ProjectionNode}}function wje(e,t){if(typeof Proxy>"u")return _b;const n=new Map,r=(s,a)=>_b(s,a,e,t),o=(s,a)=>r(s,a);return new Proxy(o,{get:(s,a)=>a==="create"?r:(n.has(a)||n.set(a,_b(a,void 0,e,t)),n.get(a))})}const Sje=(e,t)=>t.isSVG??wk(e)?new GSe(t):new HSe(t,{allowProjection:e!==f.Fragment});class kje extends bl{constructor(t){super(t),t.animationState||(t.animationState=JSe(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();E1(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let jje=0;class Cje extends bl{constructor(){super(...arguments),this.id=jje++,this.isExitComplete=!1}update(){var s;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;if(t&&r===!1){if(this.isExitComplete){const{initial:a,custom:l}=this.node.getProps();if(typeof a=="string"||typeof a=="object"&&a!==null&&!Array.isArray(a)){const c=lc(this.node,a,l);if(c){const{transition:d,transitionEnd:u,...p}=c;for(const h in p)(s=this.node.getValue(h))==null||s.jump(p[h])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const o=this.node.animationState.setActive("exit",!t);n&&!t&&o.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Tje={animation:{Feature:kje},exit:{Feature:Cje}};function kh(e){return{point:{x:e.pageX,y:e.pageY}}}const Pje=e=>t=>fk(t)&&e(t,kh(t));function Ef(e,t,n,r){return E0(e,t,Pje(n),r)}const fH=({current:e})=>e?e.ownerDocument.defaultView:null,XP=(e,t)=>Math.abs(e-t);function Eje(e,t){const n=XP(e.x,t.x),r=XP(e.y,t.y);return Math.sqrt(n**2+r**2)}const ZP=new Set(["auto","scroll"]);class hH{constructor(t,n,{transformPagePoint:r,contextWindow:o=window,dragSnapToOrigin:s=!1,distanceThreshold:a=3,element:l}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=x=>{this.handleScroll(x.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=zm(this.lastRawMoveEventInfo,this.transformPagePoint));const x=Wb(this.lastMoveEventInfo,this.history),v=this.startEvent!==null,S=Eje(x.offset,{x:0,y:0})>=this.distanceThreshold;if(!v&&!S)return;const{point:b}=x,{timestamp:g}=Hn;this.history.push({...b,timestamp:g});const{onStart:w,onMove:k}=this.handlers;v||(w&&w(this.lastMoveEvent,x),this.startEvent=this.lastMoveEvent),k&&k(this.lastMoveEvent,x)},this.handlePointerMove=(x,v)=>{this.lastMoveEvent=x,this.lastRawMoveEventInfo=v,this.lastMoveEventInfo=zm(v,this.transformPagePoint),Et.update(this.updatePoint,!0)},this.handlePointerUp=(x,v)=>{this.end();const{onEnd:S,onSessionEnd:b,resumeAnimation:g}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const w=Wb(x.type==="pointercancel"?this.lastMoveEventInfo:zm(v,this.transformPagePoint),this.history);this.startEvent&&S&&S(x,w),b&&b(x,w)},!fk(t))return;this.dragSnapToOrigin=s,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=a,this.contextWindow=o||window;const c=kh(t),d=zm(c,this.transformPagePoint),{point:u}=d,{timestamp:p}=Hn;this.history=[{...u,timestamp:p}];const{onSessionStart:h}=n;h&&h(t,Wb(d,this.history));const m={passive:!0,capture:!0};this.removeListeners=bh(Ef(this.contextWindow,"pointermove",this.handlePointerMove,m),Ef(this.contextWindow,"pointerup",this.handlePointerUp,m),Ef(this.contextWindow,"pointercancel",this.handlePointerUp,m)),l&&this.startScrollTracking(l)}startScrollTracking(t){let n=t.parentElement;for(;n;){const r=getComputedStyle(n);(ZP.has(r.overflowX)||ZP.has(r.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const r=t===window,o=r?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},s={x:o.x-n.x,y:o.y-n.y};s.x===0&&s.y===0||(r?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=s.x,this.lastMoveEventInfo.point.y+=s.y):this.history.length>0&&(this.history[0].x-=s.x,this.history[0].y-=s.y),this.scrollPositions.set(t,o),Et.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Ls(this.updatePoint)}}function zm(e,t){return t?{point:t(e.point)}:e}function JP(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Wb({point:e},t){return{point:e,delta:JP(e,mH(t)),offset:JP(e,Rje(t)),velocity:Mje(t,.1)}}function Rje(e){return e[0]}function mH(e){return e[e.length-1]}function Mje(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const o=mH(e);for(;n>=0&&(r=e[n],!(o.timestamp-r.timestamp>so(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&o.timestamp-r.timestamp>so(t)*2&&(r=e[1]);const s=Co(o.timestamp-r.timestamp);if(s===0)return{x:0,y:0};const a={x:(o.x-r.x)/s,y:(o.y-r.y)/s};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function Ije(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?vt(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?vt(n,e,r.max):Math.min(e,n)),e}function eE(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function Aje(e,{top:t,left:n,bottom:r,right:o}){return{x:eE(e.x,n,o),y:eE(e.y,t,r)}}function tE(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function Dje(e,t){return{x:tE(e.x,t.x),y:tE(e.y,t.y)}}function Lje(e,t){let n=.5;const r=kr(e),o=kr(t);return o>r?n=C0(t.min,t.max-r,e.min):r>o&&(n=C0(e.min,e.max-o,t.min)),Fi(0,1,n)}function Oje(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const vw=.35;function Nje(e=vw){return e===!1?e=0:e===!0&&(e=vw),{x:nE(e,"left","right"),y:nE(e,"top","bottom")}}function nE(e,t,n){return{min:rE(e,t),max:rE(e,n)}}function rE(e,t){return typeof e=="number"?e:e[t]||0}const Fje=new WeakMap;class zje{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=jn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const s=p=>{n&&this.snapToCursor(kh(p).point),this.stopAnimation()},a=(p,h)=>{const{drag:m,dragPropagation:x,onDragStart:v}=this.getProps();if(m&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=lSe(m),!this.openDragLock))return;this.latestPointerEvent=p,this.latestPanInfo=h,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),vi(b=>{let g=this.getAxisMotionValue(b).get()||0;if(Ii.test(g)){const{projection:w}=this.visualElement;if(w&&w.layout){const k=w.layout.layoutBox[b];k&&(g=kr(k)*(parseFloat(g)/100))}}this.originPoint[b]=g}),v&&Et.update(()=>v(p,h),!1,!0),lw(this.visualElement,"transform");const{animationState:S}=this.visualElement;S&&S.setActive("whileDrag",!0)},l=(p,h)=>{this.latestPointerEvent=p,this.latestPanInfo=h;const{dragPropagation:m,dragDirectionLock:x,onDirectionLock:v,onDrag:S}=this.getProps();if(!m&&!this.openDragLock)return;const{offset:b}=h;if(x&&this.currentDirection===null){this.currentDirection=$je(b),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",h.point,b),this.updateAxis("y",h.point,b),this.visualElement.render(),S&&Et.update(()=>S(p,h),!1,!0)},c=(p,h)=>{this.latestPointerEvent=p,this.latestPanInfo=h,this.stop(p,h),this.latestPointerEvent=null,this.latestPanInfo=null},d=()=>{const{dragSnapToOrigin:p}=this.getProps();(p||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:u}=this.getProps();this.panSession=new hH(t,{onSessionStart:s,onStart:a,onMove:l,onSessionEnd:c,resumeAnimation:d},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:r,contextWindow:fH(this.visualElement),element:this.visualElement.current})}stop(t,n){const r=t||this.latestPointerEvent,o=n||this.latestPanInfo,s=this.isDragging;if(this.cancel(),!s||!o||!r)return;const{velocity:a}=o;this.startAnimation(a);const{onDragEnd:l}=this.getProps();l&&Et.postRender(()=>l(r,o))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,r){const{drag:o}=this.getProps();if(!r||!Bm(t,o,this.currentDirection))return;const s=this.getAxisMotionValue(t);let a=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(a=Ije(a,this.constraints[t],this.elastic[t])),s.set(a)}resolveConstraints(){var s;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(s=this.visualElement.projection)==null?void 0:s.layout,o=this.constraints;t&&sd(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=Aje(r.layoutBox,t):this.constraints=!1,this.elastic=Nje(n),o!==this.constraints&&!sd(t)&&r&&this.constraints&&!this.hasMutatedConstraints&&vi(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=Oje(r.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!sd(t))return!1;const r=t.current,{projection:o}=this.visualElement;if(!o||!o.layout)return!1;o.root&&(o.root.scroll=void 0,o.root.updateScroll());const s=FSe(r,o.root,this.visualElement.getTransformPagePoint());let a=Dje(o.layout.layoutBox,s);if(n){const l=n(LSe(a));this.hasMutatedConstraints=!!l,l&&(a=FW(l))}return a}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:o,dragTransition:s,dragSnapToOrigin:a,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},d=vi(u=>{if(!Bm(u,n,this.currentDirection))return;let p=c&&c[u]||{};(a===!0||a===u)&&(p={min:0,max:0});const h=o?200:1e6,m=o?40:1e7,x={type:"inertia",velocity:r?t[u]:0,bounceStiffness:h,bounceDamping:m,timeConstant:750,restDelta:1,restSpeed:10,...s,...p};return this.startAxisValueAnimation(u,x)});return Promise.all(d).then(l)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return lw(this.visualElement,t),r.start(lk(t,r,0,n,this.visualElement,!1))}stopAnimation(){vi(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,o=this.visualElement.getProps()[n];return o||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){vi(n=>{const{drag:r}=this.getProps();if(!Bm(n,r,this.currentDirection))return;const{projection:o}=this.visualElement,s=this.getAxisMotionValue(n);if(o&&o.layout){const{min:a,max:l}=o.layout.layoutBox[n],c=s.get()||0;s.set(t[n]-vt(a,l,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!sd(n)||!r||!this.constraints)return;this.stopAnimation();const o={x:0,y:0};vi(a=>{const l=this.getAxisMotionValue(a);if(l&&this.constraints!==!1){const c=l.get();o[a]=Lje({min:c,max:c},this.constraints[a])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.constraints=!1,this.resolveConstraints(),vi(a=>{if(!Bm(a,t,null))return;const l=this.getAxisMotionValue(a),{min:c,max:d}=this.constraints[a];l.set(vt(c,d,o[a]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Fje.set(this.visualElement,this);const t=this.visualElement.current,n=Ef(t,"pointerdown",d=>{const{drag:u,dragListener:p=!0}=this.getProps(),h=d.target,m=h!==t&&hSe(h);u&&p&&!m&&this.start(d)});let r;const o=()=>{const{dragConstraints:d}=this.getProps();sd(d)&&d.current&&(this.constraints=this.resolveRefConstraints(),r||(r=Bje(t,d.current,()=>this.scalePositionWithinConstraints())))},{projection:s}=this.visualElement,a=s.addEventListener("measure",o);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),Et.read(o);const l=E0(window,"resize",()=>this.scalePositionWithinConstraints()),c=s.addEventListener("didUpdate",({delta:d,hasLayoutChanged:u})=>{this.isDragging&&u&&(vi(p=>{const h=this.getAxisMotionValue(p);h&&(this.originPoint[p]+=d[p].translate,h.set(h.get()+d[p].translate))}),this.visualElement.render())});return()=>{l(),n(),a(),c&&c(),r&&r()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:o=!1,dragConstraints:s=!1,dragElastic:a=vw,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:o,dragConstraints:s,dragElastic:a,dragMomentum:l}}}function oE(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Bje(e,t,n){const r=uP(e,oE(n)),o=uP(t,oE(n));return()=>{r(),o()}}function Bm(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function $je(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class _je extends bl{constructor(t){super(t),this.removeGroupControls=Mo,this.removeListeners=Mo,this.controls=new zje(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Mo}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const Hb=e=>(t,n)=>{e&&Et.update(()=>e(t,n),!1,!0)};class Wje extends bl{constructor(){super(...arguments),this.removePointerDownListener=Mo}onPointerDown(t){this.session=new hH(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:fH(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:o}=this.node.getProps();return{onSessionStart:Hb(t),onStart:Hb(n),onMove:Hb(r),onEnd:(s,a)=>{delete this.session,o&&Et.postRender(()=>o(s,a))}}}mount(){this.removePointerDownListener=Ef(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Ub=!1;class Hje extends f.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:o}=this.props,{projection:s}=t;s&&(n.group&&n.group.add(s),r&&r.register&&o&&r.register(s),Ub&&s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Lg.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:o,isPresent:s}=this.props,{projection:a}=r;return a&&(a.isPresent=s,t.layoutDependency!==n&&a.setOptions({...a.options,layoutDependency:n}),Ub=!0,o||t.layoutDependency!==n||n===void 0||t.isPresent!==s?a.willUpdate():this.safeToRemove(),t.isPresent!==s&&(s?a.promote():a.relegate()||Et.postRender(()=>{const l=a.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:r}=t;r&&(r.options.layoutAnchor=n,r.root.didUpdate(),pk.postRender(()=>{!r.currentAnimation&&r.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:o}=t;Ub=!0,o&&(o.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(o),r&&r.deregister&&r.deregister(o))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function gH(e){const[t,n]=iH(),r=f.useContext(GS);return i.jsx(Hje,{...e,layoutGroup:r,switchLayoutGroup:f.useContext(uH),isPresent:t,safeToRemove:n})}const Uje={pan:{Feature:Wje},drag:{Feature:_je,ProjectionNode:oH,MeasureLayout:gH}};function iE(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const o="onHover"+n,s=r[o];s&&Et.postRender(()=>s(t,kh(t)))}class Vje extends bl{mount(){const{current:t}=this.node;t&&(this.unmount=dSe(t,(n,r)=>(iE(this.node,r,"Start"),o=>iE(this.node,o,"End"))))}unmount(){}}class qje extends bl{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=bh(E0(this.node.current,"focus",()=>this.onFocus()),E0(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function sE(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const o="onTap"+(n==="End"?"":n),s=r[o];s&&Et.postRender(()=>s(t,kh(t)))}class Kje extends bl{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:r}=this.node.props;this.unmount=gSe(t,(o,s)=>(sE(this.node,s,"Start"),(a,{success:l})=>sE(this.node,a,l?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(r==null?void 0:r.tap)===!1})}unmount(){}}const xw=new WeakMap,Vb=new WeakMap,Gje=e=>{const t=xw.get(e.target);t&&t(e)},Yje=e=>{e.forEach(Gje)};function Qje({root:e,...t}){const n=e||document;Vb.has(n)||Vb.set(n,{});const r=Vb.get(n),o=JSON.stringify(t);return r[o]||(r[o]=new IntersectionObserver(Yje,{root:e,...t})),r[o]}function Xje(e,t,n){const r=Qje(t);return xw.set(e,n),r.observe(e),()=>{xw.delete(e),r.unobserve(e)}}const Zje={some:0,all:1};class Jje extends bl{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var c;(c=this.stopObserver)==null||c.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:o="some",once:s}=t,a={root:n?n.current:void 0,rootMargin:r,threshold:typeof o=="number"?o:Zje[o]},l=d=>{const{isIntersecting:u}=d;if(this.isInView===u||(this.isInView=u,s&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:p,onViewportLeave:h}=this.node.getProps(),m=u?p:h;m&&m(d)};this.stopObserver=Xje(this.node.current,a,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(e7e(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function e7e({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const t7e={inView:{Feature:Jje},tap:{Feature:Kje},focus:{Feature:qje},hover:{Feature:Vje}},n7e={layout:{ProjectionNode:oH,MeasureLayout:gH}},r7e={...Tje,...t7e,...Uje,...n7e},Sk=wje(r7e,Sje);function vH(e){const t=yl(()=>Sc(e)),{isStatic:n}=f.useContext(Eu);if(n){const[,r]=f.useState(e);f.useEffect(()=>t.on("change",r),[])}return t}function xH(e,t){const n=vH(t()),r=()=>n.set(t());return r(),j0(()=>{const o=()=>Et.preRender(r,!1,!0),s=e.map(a=>a.on("change",o));return()=>{s.forEach(a=>a()),Ls(r)}}),n}function o7e(e){Tf.current=[],e();const t=xH(Tf.current,e);return Tf.current=void 0,t}function i7e(e,t,n,r){if(typeof e=="function")return o7e(e);const s=typeof t=="function"?t:TSe(t,n,r),a=Array.isArray(e)?aE(e,s):aE([e],([c])=>s(c)),l=Array.isArray(e)?void 0:e.accelerate;return l&&!l.isTransformed&&typeof t!="function"&&Array.isArray(n)&&(r==null?void 0:r.clamp)!==!1&&(a.accelerate={...l,times:t,keyframes:n,isTransformed:!0}),a}function aE(e,t){const n=yl(()=>[]);return xH(e,()=>{n.length=0;const r=e.length;for(let o=0;o<r;o++)n[o]=e[o].get();return t(n)})}function s7e(){!vk.current&&LW();const[e]=f.useState(Wv.current);return e}const yH=f.createContext(null);function a7e(e,t,n,r,o,s="ltr"){const a=e.findIndex(m=>m.value===t);if(a===-1)return e;if(o==="xy"){const{layout:m}=e[a],x={x:vt(m.x.min,m.x.max,.5)+n.x,y:vt(m.y.min,m.y.max,.5)+n.y},v=l7e(e),S=v.find(C=>C.items.includes(e[a])),b=v.reduce((C,T)=>lE(x.y,T)<lE(x.y,C)?T:C);if(b!==S)return c7e(e,a,x.x,b,s);const g=cE(x,m);let w=-1,k=g;return e.forEach((C,T)=>{if(T===a)return;const P=cE(x,C.layout);P<k&&(w=T,k=P)}),w===-1?e:UT(e,a,a+Math.sign(w-a))}if(!r[o])return e;const l=r[o]>0?1:-1,c=e[a+l];if(!c)return e;const u=e[a].layout[o],p=c.layout[o],h=vt(p.min,p.max,.5);return l===1&&u.max+n[o]>h||l===-1&&u.min+n[o]<h?UT(e,a,a+l):e}function l7e(e){const t=[];return e.forEach(n=>{const{min:r,max:o}=n.layout.y,s=t[t.length-1];!s||r>=s.max||o<=s.min?t.push({items:[n],min:r,max:o}):(s.items.push(n),s.min=Math.min(s.min,r),s.max=Math.max(s.max,o))}),t}function lE(e,t){return e<t.min?t.min-e:e>t.max?e-t.max:0}function c7e(e,t,n,r,o){const s=e.filter((d,u)=>u!==t),a=r.items.find(d=>{const u=vt(d.layout.x.min,d.layout.x.max,.5);return o==="ltr"?n<u:n>u}),l=a?s.indexOf(a):s.indexOf(r.items[r.items.length-1])+1,c=[...s];return c.splice(l,0,e[t]),c.every((d,u)=>d===e[u])?e:c}function cE(e,t){const n=Math.max(t.x.min-e.x,0,e.x-t.x.max),r=Math.max(t.y.min-e.y,0,e.y-t.y.max);return n*n+r*r}const dE=(e,t)=>e.max<=t.min||t.max<=e.min;function d7e(e){let t=!1,n=!1;for(let r=0;r<e.length;r++)for(let o=r+1;o<e.length;o++)if(t||(t=dE(e[r].x,e[o].x)),n||(n=dE(e[r].y,e[o].y)),t&&n)return"xy";return t?"x":"y"}function u7e({children:e,as:t="ul",axis:n,onReorder:r,values:o,...s},a){const l=yl(()=>Sk[t]),c=f.useRef(new Map),[d,u]=f.useState("y"),p=f.useRef(!1),h=f.useRef(null),m=n||d,x=new Set(o);c.current.forEach((g,w)=>{x.has(w)||c.current.delete(w)});const v={axis:m,groupRef:h,registerItem:(g,w)=>{if(c.current.set(g,w),!n){const k=d7e(o.flatMap(C=>{const T=c.current.get(C);return T?[T]:[]}));k!==d&&u(k)}},updateOrder:(g,w,k)=>{var R,D;if(p.current)return;const C=o.flatMap(I=>{const L=c.current.get(I);return L?[{value:I,layout:L}]:[]}),T=((D=(R=h.current)==null?void 0:R.ownerDocument.defaultView)==null?void 0:D.getComputedStyle(h.current).direction)==="rtl"?"rtl":"ltr",P=a7e(C,g,w,k,m,T);if(C!==P){p.current=!0;const I=[...o],L=C.map(({value:W})=>o.indexOf(W));P.forEach(({value:W},ee)=>{I[L[ee]]=W}),r(I)}}};f.useEffect(()=>{p.current=!1});const S=g=>{h.current=g,typeof a=="function"?a(g):a&&(a.current=g)},b={overflowAnchor:"none",...s.style};return i.jsx(l,{...s,style:b,ref:S,ignoreStrict:!0,children:i.jsx(yH.Provider,{value:v,children:e})})}const p7e=f.forwardRef(u7e),$m=50,uE=25,f7e=new Set(["auto","scroll"]),Rf=new WeakMap,Mf=new WeakMap;let ef=null;function h7e(){if(ef){const e=yw(ef,"y");e&&(Mf.delete(e),Rf.delete(e));const t=yw(ef,"x");t&&t!==e&&(Mf.delete(t),Rf.delete(t)),ef=null}}function m7e(e,t){const n=getComputedStyle(e),r=t==="x"?n.overflowX:n.overflowY,o=e===document.body||e===document.documentElement;return f7e.has(r)||o}function yw(e,t){let n=e==null?void 0:e.parentElement;for(;n;){if(m7e(n,t))return n;n=n.parentElement}return null}function g7e(e,t,n){const r=t.getBoundingClientRect(),o=n==="x"?Math.max(0,r.left):Math.max(0,r.top),s=n==="x"?Math.min(window.innerWidth,r.right):Math.min(window.innerHeight,r.bottom),a=e-o,l=s-e;if(a<$m){const c=1-a/$m;return{amount:-uE*c*c,edge:"start"}}else if(l<$m){const c=1-l/$m;return{amount:uE*c*c,edge:"end"}}return{amount:0,edge:null}}function v7e(e,t,n,r){if(!e)return;ef=e;const o=yw(e,n);if(!o)return;const s=t-(n==="x"?window.scrollX:window.scrollY),{amount:a,edge:l}=g7e(s,o,n);if(l===null){Mf.delete(o),Rf.delete(o);return}const c=Mf.get(o),d=o===document.body||o===document.documentElement;if(c!==l){if(!(l==="start"&&r<0||l==="end"&&r>0))return;Mf.set(o,l);const p=n==="x"?o.scrollWidth-(d?window.innerWidth:o.clientWidth):o.scrollHeight-(d?window.innerHeight:o.clientHeight);Rf.set(o,p)}if(a>0){const u=Rf.get(o);if((n==="x"?d?window.scrollX:o.scrollLeft:d?window.scrollY:o.scrollTop)>=u)return}n==="x"?d?window.scrollBy({left:a}):o.scrollLeft+=a:d?window.scrollBy({top:a}):o.scrollTop+=a}function pE(e,t=0){return On(e)?e:vH(t)}function x7e({children:e,style:t={},value:n,as:r="li",onDrag:o,onDragEnd:s,layout:a=!0,...l},c){const d=yl(()=>Sk[r]),u=f.useContext(yH),p={x:pE(t.x),y:pE(t.y)},h=i7e([p.x,p.y],([g,w])=>g||w?1:"unset"),{axis:m,registerItem:x,updateOrder:v,groupRef:S}=u,b=m==="xy"?!0:m;return i.jsx(d,{drag:b,...l,dragSnapToOrigin:!0,style:{...t,x:p.x,y:p.y,zIndex:h},layout:a,onDrag:(g,w)=>{const{velocity:k,point:C}=w,T={x:p.x.get(),y:p.y.get()};v(n,T,k);const P=m==="xy"?Math.abs(k.x)>Math.abs(k.y)?"x":"y":m;v7e(S.current,C[P],P,k[P]),o&&o(g,w)},onDragEnd:(g,w)=>{h7e(),s&&s(g,w)},onLayoutMeasure:g=>{x(n,g)},ref:c,ignoreStrict:!0,children:e})}const y7e=f.forwardRef(x7e),b7e=Sk,I1="'IBM Plex Mono',monospace";function w7e({state:e,onAdd:t,onSelect:n,onClose:r,onReorder:o,actions:s}){const a=k3(),l=s7e(),c=a==="reduced"||a==="system"&&l===!0,d=(e==null?void 0:e.tabs)??[];return i.jsx(Zke,{reducedMotion:T7e(a),children:i.jsxs("div",{style:P7e,children:[i.jsxs(p7e,{as:"div",axis:"x",values:d.map(u=>u.id),onReorder:o,layoutScroll:!0,style:E7e,children:[i.jsx(Yke,{initial:!1,mode:"popLayout",children:d.map(u=>i.jsx(S7e,{tab:u,active:u.id===(e==null?void 0:e.activeId),draggable:d.length>1,reduceMotion:c,onSelect:n,onClose:r},u.id))}),i.jsx(b7e.button,{layout:!0,type:"button","data-add-tab":"",title:"New tab",onClick:t,style:N7e,children:"+"})]}),s&&i.jsx("div",{style:R7e,children:s})]})})}const S7e=f.forwardRef(function({tab:t,active:n,draggable:r,reduceMotion:o,onSelect:s,onClose:a},l){const c=qve(t),d=Ds(t)?null:mS(t),u=k7e(t),p=j7e(t,c,d),h=Kke();return i.jsxs(y7e,{ref:l,as:"div",value:t.id,dragListener:r&&h,dragElastic:.08,initial:o?!1:{opacity:0,scale:.94},animate:o?void 0:{opacity:1,scale:1},exit:o?void 0:{opacity:0,scale:.94,transition:{duration:.12,ease:"easeIn"}},transition:o?{duration:0}:{type:"spring",stiffness:500,damping:40,opacity:{duration:.12},scale:{duration:.14}},whileDrag:o?void 0:{scale:1.03},style:{...M7e,pointerEvents:h?"auto":"none",borderBottomColor:n?"var(--proto-card)":"var(--proto-line)",background:n?"var(--proto-card)":"var(--proto-gray)"},children:[i.jsxs("button",{type:"button","aria-pressed":n,"data-dock-tab":t.id,"data-tab-kind":t.kind,"data-active":n?"true":"false",onClick:()=>s(t.id),title:p,style:{...I7e,color:n?"var(--proto-ink)":"var(--proto-muted)"},children:[u&&i.jsx(C7e,{chip:u,source:d}),i.jsx("span",{style:A7e,children:c})]}),i.jsx("button",{type:"button",disabled:!h,"data-close-tab":t.id,title:"Close tab","aria-label":"Close tab",onPointerDown:m=>m.stopPropagation(),onClick:()=>a(t.id),style:O7e,children:"×"})]})});function k7e(e){return Ds(e)?{text:n1(e.item.name),kind:"plain"}:pB(e)}function j7e(e,t,n){return Ds(e)?e.item.path??t:n?`${t}
439
439
  Forwarded from ${n}`:el(e.history)??t}function C7e({chip:e,source:t}){const n=e.kind==="forward"&&t!==null;return i.jsx("span",{...n?{"data-forward-source":t}:{},title:n?`Forwarded from ${t}`:void 0,style:n?D7e:L7e,children:e.text})}function T7e(e){return e==="reduced"?"always":e==="full"?"never":"user"}const P7e={height:50,flex:"none",display:"flex",alignItems:"stretch",background:"var(--proto-gray)"},E7e={flex:1,minWidth:0,display:"flex",alignItems:"flex-end",gap:3,padding:"0 0 0 8px",overflowX:"auto",overflowY:"hidden",position:"relative"},R7e={flex:"none",display:"flex",alignItems:"center",gap:6,padding:"0 10px"},M7e={display:"flex",alignItems:"center",flex:"none",minWidth:96,maxWidth:210,height:35,border:"1px solid var(--proto-line)",borderRadius:"7px 7px 0 0",position:"relative",cursor:"grab",overflow:"hidden",transition:"background-color 140ms ease, border-color 140ms ease"},I7e={display:"flex",alignItems:"center",minWidth:0,height:"100%",flex:1,padding:"0 2px 0 7px",border:"none",background:"transparent",font:`500 10px ${I1}`,cursor:"inherit",transition:"color 140ms ease",textAlign:"left"},A7e={overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:"13px"},bH={display:"inline-flex",alignItems:"center",flex:"none",maxWidth:98,height:16,padding:"0 5px",marginRight:6,borderRadius:5,font:`600 9px ${I1}`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},D7e={...bH,background:"var(--proto-accent-bg)",color:"var(--proto-accent)"},L7e={...bH,border:"1px solid var(--proto-line)",color:"var(--proto-muted-2)"},O7e={width:24,height:"100%",flex:"none",border:"none",background:"transparent",color:"var(--proto-muted-2)",font:`500 13px ${I1}`,lineHeight:1,cursor:"pointer",padding:0},N7e={width:26,height:26,flex:"none",marginBottom:4,borderRadius:"7px 7px 0 0",border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",font:`500 13px ${I1}`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0},F7e="Click a file to preview it here, or open a web page with +.";function z7e(){const{open:e,state:t,split:n,closeDock:r,select:o,close:s,reorder:a,openWeb:l,updateWeb:c,setSplit:d,registerHost:u}=Ic(),p=f.useRef(null),h=f.useRef([]);f.useEffect(()=>u(),[u]),h.current=Yve(h.current,(t==null?void 0:t.tabs)??[]);const m=x=>{x.preventDefault();const v=p.current,S=v==null?void 0:v.previousElementSibling;if(!v||!S)return;const b=v.getBoundingClientRect(),g=S.getBoundingClientRect(),w=g.left,k=g.width+b.width;let C=n;const T=R=>{C=_ve(w,k,R.clientX),d(C)},P=()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",P),document.body.style.userSelect="",d(C,!0)};document.body.style.userSelect="none",window.addEventListener("mousemove",T),window.addEventListener("mouseup",P)};return!e&&t===null?null:i.jsxs("div",{ref:p,"data-pane":"dock",style:{...$7e,flexGrow:n,display:e?"flex":"none"},children:[i.jsx("div",{role:"separator","aria-orientation":"vertical",title:"Drag to resize",onMouseDown:m,style:{position:"absolute",left:-3,top:0,bottom:0,width:6,cursor:"col-resize",zIndex:3}}),i.jsx(w7e,{state:t,onAdd:l,onSelect:o,onClose:s,onReorder:a,actions:i.jsx("span",{role:"button","data-close-dock":"",title:"Close the dock",onClick:r,style:_7e,children:"×"})}),i.jsx("div",{style:{flex:1,minHeight:0,position:"relative",overflow:"hidden",background:"var(--proto-card)"},children:t===null?i.jsx(G5,{children:F7e}):h.current.map(x=>i.jsx(B7e,{state:t,id:x,onUpdateWeb:c},x))})]})}function B7e({state:e,id:t,onUpdateWeb:n}){const r=e.tabs.find(l=>l.id===t),o=f.useCallback(l=>n(t,l),[t,n]);if(!r)return null;const s=r.id===e.activeId,a={position:"absolute",inset:0,flexDirection:"column",minHeight:0,overflow:"hidden",background:Ds(r)?n6e(r.item):"var(--proto-card)",display:s?"flex":"none"};return i.jsx("div",{"data-dock-tab-body":r.id,style:a,children:Ds(r)?i.jsx(e6e,{item:r.item}):i.jsx(Mwe,{tab:r,active:s,onUpdate:o})})}const $7e={flexShrink:1,flexBasis:0,minWidth:0,flexDirection:"column",minHeight:0,background:"var(--proto-card)",borderLeft:"1px solid var(--proto-line)",position:"relative"},_7e={width:28,height:28,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,cursor:"pointer",flex:"none",userSelect:"none"},W7e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Kv(e){if(e.type==="daily")return e.time?`daily ${e.time}`:"daily";if(e.type==="weekly"){const t=e.dayOfWeek!=null?W7e[e.dayOfWeek]:null;return t&&e.time?`weekly ${t} ${e.time}`:"weekly"}return e.type==="interval"?e.intervalMs!=null&&e.intervalMs>0?`every ${IS(e.intervalMs)}`:"interval":"once"}function kk(e,t){if(!e)return null;const n=Date.parse(e);return Number.isNaN(n)?null:IS(n-t)}function Og(e){const t=Date.parse(e.lastUsedAt||e.createdAt);return Number.isNaN(t)?0:t}function Gv(e){const t=new Date(e);return Math.floor(new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()/864e5)}function H7e(e,t){const n=typeof t=="number"?t:t.getTime(),r=Gv(n),o={TODAY:[],YESTERDAY:[],EARLIER:[]};for(const a of e){const l=Gv(Og(a)),c=l>=r?"TODAY":l===r-1?"YESTERDAY":"EARLIER";o[c].push(a)}return["TODAY","YESTERDAY","EARLIER"].map(a=>({label:a,items:o[a].sort((l,c)=>+!!c.unread-+!!l.unread||Og(c)-Og(l))})).filter(a=>a.items.length>0)}function _m(e){return e<10?"0"+e:""+e}function jk(e,t=Date.now()){const n=typeof t=="number"?t:t.getTime(),r=Og(e),o=new Date(r),s=_m(o.getHours())+":"+_m(o.getMinutes());return(Gv(r)<Gv(n)-1?(o.getFullYear()===new Date(n).getFullYear()?"":o.getFullYear()+"-")+_m(o.getMonth()+1)+"-"+_m(o.getDate())+" ":"")+s}function jh(e){const t=e.split(/[-_]/).filter(Boolean);return t.length>=2?(t[0][0]+t[1][0]).toUpperCase():t.length===1?t[0].slice(0,2).toUpperCase():"?"}function bw(e){const t=Date.parse(e.lastUsedAt||e.createdAt);return Number.isNaN(t)?0:t}function U7e(e){const t=new Map;for(const n of e){if(n.origin!=="scheduled"||n.scheduleId==null)continue;const r=t.get(n.scheduleId)??[];r.push(n),t.set(n.scheduleId,r)}for(const n of t.values())n.sort((r,o)=>bw(o)-bw(r));return t}function fE(e){var r;if(e.latest)return bw(e.latest);const t=(r=e.schedule)==null?void 0:r.lastRun,n=t?Date.parse(t):NaN;return Number.isNaN(n)?0:n}function wH(e,t,n){var s,a;const r=U7e(t),o=[];for(const l of e){const c=r.get(l.id)??[];r.delete(l.id),o.push({scheduleId:l.id,schedule:l,title:l.message.trim()||(((s=c[0])==null?void 0:s.label)??((a=c[0])==null?void 0:a.name)??l.id),kind:l.type==="once"?"once":"repeat",runs:c,latest:c[0]??null,unread:c.some(d=>d.unread)})}for(const[l,c]of r)o.push({scheduleId:l,schedule:null,title:c[0].label??c[0].name,kind:c.length>1?"repeat":"once",runs:c,latest:c[0],unread:c.some(d=>d.unread)});return o.sort((l,c)=>fE(c)-fE(l))}function Ck(e){const t=[...e].sort((r,o)=>Date.parse(r.createdAt)-Date.parse(o.createdAt)),n=new Map;return t.forEach((r,o)=>n.set(r.sessionId,o+1)),n}function SH(e){if(e.runs.length===0){if(!e.schedule)throw new Error(`Schedule row ${e.scheduleId} has neither a DTO nor a run`);return{type:"edit",schedule:e.schedule}}return e.kind==="once"?{type:"open",sessionId:e.runs[0].sessionId}:{type:"modal"}}function kH(e,t){var r;if((r=e.schedule)!=null&&r.paused)return{kind:"paused",cadence:Kv(e.schedule)};if(e.latest)return{kind:"run",stamp:jk(e.latest,t),cost:e.latest.costUsd!=null?yn(e.latest.costUsd):null};const n=e.schedule;return{kind:"pending",cadence:n?Kv(n):"",nextDelta:n?kk(n.nextRun,t):null}}function jH(e,t,n){if(!e)return null;const r=Ck(t).get(n);return r==null?null:`${e.message} · run #${r}`}function CH(e){return e.filter(t=>t.unread).length}const Kc="'IBM Plex Mono',monospace",hE={display:"grid",gridTemplateColumns:"64px 1fr 76px",gap:10,padding:"9px 18px",alignItems:"center"};function V7e({row:e,selectedSessionId:t,onOpenRun:n,onManage:r,onClose:o}){const s=O(),a=Date.now(),l=Ck(e.runs),c=e.schedule,d=c?kk(c.nextRun,a):null,u=c?Kv(c)+(c.paused?` · ${s.wbSchedPausedPill}`:d?` · ${s.wbSchedNextRun.replace("{d}",d)}`:""):null;return i.jsxs(ur,{chrome:"bare",size:"custom",open:!0,showClose:!1,title:e.title,description:u??s.wbSchedRunListHint,onOpenChange:p=>{p||o()},contentDataAttributes:{"data-modal":"run-list"},overlayDataAttributes:{"data-backdrop":"run-list"},bodyStyle:{display:"contents"},contentStyle:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:400,maxWidth:"calc(100vw - 40px)",background:"var(--proto-card)",borderRadius:14,boxShadow:"var(--shadow-overlay-strong)",zIndex:61,display:"flex",flexDirection:"column",maxHeight:"min(560px, calc(100vh - 80px))"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"15px 18px 12px",borderBottom:"1px solid var(--proto-line)",flex:"none"},children:[i.jsxs("svg",{width:13,height:13,viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:1.6,style:{flex:"none"},children:[i.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),i.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:13.5,fontWeight:650,color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),u&&i.jsx("div",{style:{font:`400 10px ${Kc}`,color:"var(--proto-muted-3)",marginTop:2},children:u})]}),c&&r&&i.jsx("span",{"data-action":"run-list-manage",onClick:r,style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",flex:"none",cursor:"pointer"},children:s.wbSchedManage}),i.jsx("span",{"data-action":"run-list-close",onClick:o,style:{marginLeft:c&&r?0:"auto",fontSize:12,color:"var(--proto-muted-3)",flex:"none",cursor:"pointer",padding:"0 2px"},children:"✕"})]}),i.jsxs("div",{style:{...hE,padding:"8px 18px 6px",font:`600 9.5px ${Kc}`,color:"var(--proto-muted-3)",letterSpacing:".05em",flex:"none"},children:[i.jsx("span",{children:"RUN"}),i.jsx("span",{children:"FIRED"}),i.jsx("span",{style:{textAlign:"right"},children:"COST"})]}),i.jsx("div",{style:{overflowY:"auto",minHeight:0},children:e.runs.map((p,h)=>{const m=p.sessionId===t;return i.jsxs("div",{"data-run-row":p.sessionId,onClick:()=>n(p.sessionId),style:{...hE,cursor:"pointer",background:m?"var(--proto-accent-bg)":"transparent",borderTop:h===0?"none":"1px solid var(--proto-gray)"},children:[i.jsxs("span",{style:{font:`${p.unread?600:400} 11px ${Kc}`,color:p.unread?"var(--proto-ink)":"var(--proto-muted)",display:"flex",alignItems:"center",gap:6},children:["#",l.get(p.sessionId),p.unread&&i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)"}})]}),i.jsx("span",{style:{font:`400 11px ${Kc}`,color:"var(--proto-muted-2)"},children:jk(p,a)}),i.jsx("span",{style:{font:`400 11px ${Kc}`,color:"var(--proto-muted-3)",textAlign:"right"},children:p.costUsd!=null?yn(p.costUsd):"—"})]},p.sessionId)})}),i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 18px 13px",borderTop:"1px solid var(--proto-line)",flex:"none"},children:[i.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--proto-muted-2)"},children:s.wbAllRuns.replace("{n}",String(e.runs.length))}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${Kc}`,color:"var(--proto-muted-3)"},children:s.wbSchedRunListHint})]})]})}function mE(e,t){const n=Math.max(0,t-e);return n<6e4?"now":n<36e5?Math.floor(n/6e4)+"m":n<864e5?Math.floor(n/36e5)+"h":Math.floor(n/864e5)+"d"}function TH(e){const t={};for(const n of e){const r=Date.parse(n.lastUsedAt||n.createdAt);Number.isNaN(r)||(!(n.projectId in t)||r>t[n.projectId])&&(t[n.projectId]=r)}return t}function PH(e,t){const n=r=>typeof t[r]=="number"?t[r]:-1/0;return[...e].sort((r,o)=>{const s=n(r.id),a=n(o.id);return s===a?0:a-s})}function q7e(e){return e.length!==1||e<"1"||e>"9"?null:e.charCodeAt(0)-49}function ww(e){const t=Date.parse(e.lastUsedAt||e.createdAt);return Number.isNaN(t)?0:t}function gE(e){if(e.latest)return ww(e.latest);const t=Date.parse(e.commission.updatedAt||e.commission.createdAt);return Number.isNaN(t)?0:t}function vE(e){return e==="active"?0:1}function K7e(e,t){const n=new Map;for(const o of t){if(!o.commissionId)continue;const s=n.get(o.commissionId)??[];s.push(o),n.set(o.commissionId,s)}for(const o of n.values())o.sort((s,a)=>ww(a)-ww(s));return e.map(o=>{const s=n.get(o.id)??[];return{commissionId:o.id,projectId:o.projectId,commission:o,title:o.title.trim()||o.slug,status:o.status,sessions:s,latest:s[0]??null,unread:s.some(a=>!!a.unread),awaitingInput:s.some(a=>!!a.awaitingInput),running:s.some(a=>!!a.running)}}).sort((o,s)=>vE(o.status)-vE(s.status)||gE(s)-gE(o))}function G7e(e){const t=new Set;for(const n of e)for(const r of n.sessions)t.add(r.sessionId);return t}function Y7e(e){return e.filter(t=>t.unread).length}const Q7e=new Set(["running","waiting"]);function X7e(e){const t={};for(const n of e)Q7e.has(n.status)&&(t[n.projectId]=(t[n.projectId]??0)+1);return t}function EH(e){const t={};for(const n of e)n.unread&&(t[n.projectId]=(t[n.projectId]??0)+1);return t}function RH(e){const t={};for(const n of e)n.awaitingInput&&(t[n.projectId]=(t[n.projectId]??0)+1);return t}function MH(e,t){const n=e+t;return{count:n,tone:t>0?"action":n>0?"unread":null}}const IH="cortex.railSort",AH="cortex.railOrder";function Z7e(e){return e==="activity"||e==="manual"}function J7e(){try{const e=window.localStorage.getItem(IH);return Z7e(e)?e:"activity"}catch{return"activity"}}function e8e(e){try{window.localStorage.setItem(IH,e)}catch{}}function t8e(){try{const e=window.localStorage.getItem(AH);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function n8e(e){try{window.localStorage.setItem(AH,JSON.stringify(e))}catch{}}function Sw(e,t){const n=new Set(t),r=new Set,o=[];for(const a of e)n.has(a)&&!r.has(a)&&(r.add(a),o.push(a));let s=0;for(const a of t){const l=o.indexOf(a);if(l>=0){s=l+1;continue}o.splice(s,0,a),s+=1}return o}function r8e(e,t,n){const r=e.indexOf(t),o=e.indexOf(n);if(r<0||o<0||r===o)return[...e];const s=[...e];return s.splice(r,1),s.splice(o,0,t),s}function o8e(e,t,n,r){return e==="manual"||r?Sw(n,t):[...t]}const i8e=8;function Yv(e){const t=Date.parse(e.lastUsedAt||e.createdAt);return Number.isNaN(t)?0:t}function Wm(e){return e<10?"0"+e:String(e)}function s8e(e){const t=Yv(e);if(!t)return"";const n=new Date(t);return n.getFullYear()+"-"+Wm(n.getMonth()+1)+"-"+Wm(n.getDate())+" "+Wm(n.getHours())+":"+Wm(n.getMinutes())}function DH(e){return e.label??e.name??e.sessionId}function xE(e,t){return t?DH(e).toLowerCase().includes(t.toLowerCase()):!0}function yE(e){return[...e].sort((t,n)=>+!!n.unread-+!!t.unread||Yv(n)-Yv(t))}function bE(e){const t=new Map;for(const n of e){const r=t.get(n.projectId);r?r.push(n):t.set(n.projectId,[n])}return t}function kw(e,t,n){if(!e)return null;const r=t.find(o=>o.sessionId===e)??n.find(o=>o.sessionId===e);return(r==null?void 0:r.projectId)??null}function a8e(e){const{projects:t,directSessions:n,scheduledSessions:r,schedules:o,commissions:s,threads:a,selectedSessionId:l,fallbackProjectId:c,expanded:d,schedulesExpanded:u,commissionsExpanded:p,expandedCommissions:h,showAll:m,sort:x,manualOrder:v,dragged:S,now:b}=e,g=_=>({sessionId:_.sessionId,projectId:_.projectId,title:DH(_),age:mE(Yv(_),b),stamp:s8e(_),running:!!_.running,awaitingInput:!!_.awaitingInput,unread:!!_.unread,selected:_.sessionId===l}),w=e.cap??i8e,k=e.filter.trim(),C=k.length>0,T=X7e(a),P=EH(n),R=RH(n),D=TH([...n,...r]),I=bE(n),L=bE(r),W=new Map;for(const _ of o){const Y=W.get(_.projectId);Y?Y.push(_):W.set(_.projectId,[_])}const ee=new Map;for(const _ of s){const Y=ee.get(_.projectId);Y?Y.push(_):ee.set(_.projectId,[_])}const V=PH(t,D).map(_=>_.id),X=o8e(x,V,v,S),K=new Map(t.map(_=>[_.id,_])),se=X.map(_=>K.get(_)).filter(_=>!!_),B=kw(l,n,r)??c;let G=0,ne=0;const le=se.map(_=>{const Y=I.get(_.id)??[],te=K7e(ee.get(_.id)??[],Y),ie=G7e(te),ye=ie.size?Y.filter(ft=>!ie.has(ft.sessionId)):Y,Z=wH(W.get(_.id)??[],L.get(_.id)??[]),xe=T[_.id]??0,ke=MH(P[_.id]??0,R[_.id]??0),Oe=ke.count,Ie=ye.length===0&&Z.length===0&&te.length===0&&xe===0,Ae=C?ye.filter(ft=>xE(ft,k)):ye;let tt=0;const we=[];for(const ft of te){const Vr=C?ft.sessions.filter(pr=>xE(pr,k)):ft.sessions;C&&(tt+=Vr.length,Vr.length===0)||we.push({commissionId:ft.commissionId,projectId:ft.projectId,title:ft.title,status:ft.status,expanded:C?!0:h.has(ft.commissionId),running:ft.running,unread:ft.unread,awaitingInput:ft.awaitingInput,sessions:yE(Vr).map(g),totalSessions:ft.sessions.length})}C&&(ne+=Ae.length+tt);const lt=yE(Ae),Qe=m.has(_.id),Zt=C||Qe?lt:lt.slice(0,w),wn=D[_.id],Qn=xe>0||Oe>0,qt=!Ie&&G<9?"⌘"+ ++G:null;return{id:_.id,current:_.id===B,expanded:C?Ae.length+tt>0:d.has(_.id),empty:Ie,running:xe,attention:Oe,attentionTone:ke.tone,hotkey:qt,idleAge:!Qn&&typeof wn=="number"?mE(wn,b):null,sessions:Zt.map(g),hiddenSessions:Math.max(0,lt.length-Zt.length),showingAll:Qe&&!C&&lt.length>w,totalSessions:ye.length,schedules:Z,schedulesExpanded:u.has(_.id),scheduleUnread:CH(Z),commissions:we,commissionsExpanded:C?tt>0:p.has(_.id),commissionUnread:Y7e(te),matchCount:C?Ae.length+tt:null}});return{projects:C?le.filter(_=>(_.matchCount??0)>0):le,currentProjectId:B,totalMatches:C?ne:null}}function l8e({open:e,current:t,dim:n,size:r=17}){const o=t?"var(--proto-accent)":n?"var(--proto-faint)":"var(--proto-muted-2)",s=t?{fill:o}:{stroke:o,strokeWidth:1.5};return i.jsx("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",style:{flex:"none",display:"block"},children:e?i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M1.6 12.2V4.4a1.3 1.3 0 0 1 1.3-1.3h2.7l1.3 1.5h5.5a1.3 1.3 0 0 1 1.3 1.3v1.2",stroke:o,strokeWidth:1.5,strokeLinejoin:"round"}),i.jsx("path",{d:"M2.9 13h8.8a1.2 1.2 0 0 0 1.13-.79l1.4-3.9A.6.6 0 0 0 13.66 7.5H5.1a1.2 1.2 0 0 0-1.13.79l-1.63 4.5A.5.5 0 0 0 2.9 13z",strokeLinejoin:"round",...s})]}):i.jsx("path",{d:"M1.6 4.4A1.3 1.3 0 0 1 2.9 3.1h2.7l1.3 1.5h6.2a1.3 1.3 0 0 1 1.3 1.3v5.8a1.3 1.3 0 0 1-1.3 1.3H2.9a1.3 1.3 0 0 1-1.3-1.3z",strokeLinejoin:"round",...s})})}const Ir="'IBM Plex Mono',monospace";function jw(){return i.jsxs("svg",{width:14,height:14,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round","aria-hidden":"true",children:[i.jsx("circle",{cx:"7.2",cy:"7.2",r:"3.9"}),i.jsx("path",{d:"M10.1 10.1 12.9 12.9"})]})}function c8e(){return i.jsxs("svg",{width:14,height:14,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M5.6 12.4V3.6M5.6 3.6 3.4 5.9M5.6 3.6 7.8 5.9"}),i.jsx("path",{d:"M10.4 3.6v8.8M10.4 12.4l2.2-2.3M10.4 12.4l-2.2-2.3"})]})}function LH(){return i.jsxs("svg",{width:14,height:14,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinejoin:"round",strokeLinecap:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M2.2 4.6A1.25 1.25 0 0 1 3.45 3.35h2.4l1.25 1.45h5.45A1.25 1.25 0 0 1 13.8 6.05v5.6a1.25 1.25 0 0 1-1.25 1.25H3.45A1.25 1.25 0 0 1 2.2 11.65z"}),i.jsx("path",{d:"M8 7.5v3.1M6.45 9.05h3.1"})]})}function d8e(){return i.jsxs("svg",{width:13,height:13,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[i.jsx("rect",{x:"1.8",y:"1.8",width:"5.4",height:"5.4",rx:"1.3"}),i.jsx("rect",{x:"8.8",y:"1.8",width:"5.4",height:"5.4",rx:"1.3"}),i.jsx("rect",{x:"1.8",y:"8.8",width:"5.4",height:"5.4",rx:"1.3"}),i.jsx("rect",{x:"8.8",y:"8.8",width:"5.4",height:"5.4",rx:"1.3"})]})}function u8e({size:e=13}){return i.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.7,strokeLinecap:"round","aria-hidden":"true",children:i.jsx("path",{d:"M8 3.2v9.6M3.2 8h9.6"})})}function wE({size:e=11}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:1.6,"aria-hidden":"true",style:{flex:"none"},children:[i.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),i.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]})}function SE({size:e=11}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:[i.jsx("path",{d:"M3.7 1.9v10.2"}),i.jsx("path",{d:"M3.7 2.7h6.8L9.1 5l1.4 2.3H3.7z"})]})}function p8e({open:e,size:t=9}){return i.jsx("svg",{width:t,height:t,viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none",transform:e?"rotate(90deg)":"none",transition:"transform 120ms ease"},children:i.jsx("path",{d:"M4.5 2.5L8.5 6l-4 3.5"})})}function Ep({label:e,active:t,onClick:n,children:r}){const[o,s]=f.useState(!1);return i.jsx("button",{type:"button","aria-label":e,title:e,onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:22,height:22,border:0,borderRadius:6,padding:0,display:"grid",placeItems:"center",cursor:"pointer",flex:"none",position:"relative",background:t?"var(--proto-accent-bg)":o?"var(--proto-gray)":"transparent",color:t?"var(--proto-accent)":o?"var(--proto-ink-2)":"var(--proto-muted-2)"},children:r})}function f8e(e){const t=O(),[n,r]=f.useState(!1),[o,s]=f.useState(null),[a,l]=f.useState(null),[c,d]=f.useState(null),u=f.useRef(null),p=g=>({onMouseEnter:()=>s(g),onMouseLeave:()=>s(w=>w===g?null:w)}),h=g=>o===g,m=()=>e.searchOpen?i.jsx("div",{style:{display:"flex",alignItems:"center",height:28,padding:"0 12px 6px",flex:"none",boxSizing:"content-box"},children:i.jsxs("div",{style:{flex:1,height:28,display:"flex",alignItems:"center",gap:6,padding:"0 8px",borderRadius:7,border:"1px solid var(--proto-accent-border)",background:"var(--proto-card)"},children:[i.jsx("span",{style:{color:"var(--proto-muted-3)",display:"flex"},children:i.jsx(jw,{})}),i.jsx("input",{ref:u,autoFocus:!0,value:e.filter,onChange:g=>e.onFilter(g.target.value),onKeyDown:g=>{g.key==="Escape"&&e.onToggleSearch()},placeholder:t.wbFilterSessions,"aria-label":t.wbFilterSessions,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",color:"var(--proto-ink)",fontSize:12,fontFamily:"inherit"}}),i.jsx("span",{role:"button","aria-label":t.cancel,onClick:e.onToggleSearch,style:{color:"var(--proto-muted-3)",cursor:"pointer",fontSize:13,lineHeight:1},children:"✕"})]})}):i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2,height:28,padding:"0 12px 6px",flex:"none",boxSizing:"content-box"},children:[i.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-faint)"},children:t.wbProjects}),i.jsx("span",{style:{font:`500 9.5px ${Ir}`,color:"var(--proto-line-3)",marginLeft:5,marginRight:"auto"},children:e.projectCount}),i.jsx(Ep,{label:t.wbFilterSessions,onClick:e.onToggleSearch,children:i.jsx(jw,{})}),i.jsxs(Ep,{label:t.wbSortMode,active:n,onClick:g=>{g.stopPropagation(),r(w=>!w)},children:[i.jsx(c8e,{}),n&&i.jsx("span",{onClick:g=>g.stopPropagation(),style:{position:"absolute",top:25,right:0,zIndex:20,minWidth:118,padding:4,borderRadius:9,background:"var(--proto-card)",border:"1px solid var(--proto-line-3)",boxShadow:"var(--shadow-menu)",display:"block",textAlign:"left"},children:["activity","manual"].map(g=>i.jsx("span",{...p("sort:"+g),onClick:()=>{e.onSort(g),r(!1)},style:{display:"block",padding:"6px 9px",borderRadius:6,fontSize:12,whiteSpace:"nowrap",cursor:"pointer",fontWeight:e.sort===g?600:400,color:e.sort===g?"var(--proto-accent)":"var(--proto-muted)",background:h("sort:"+g)?"var(--proto-gray)":"transparent"},children:g==="activity"?t.wbSortActivity:t.wbSortManual},g))})]}),i.jsx(Ep,{label:t.newProject,onClick:e.onNewProject,children:i.jsx(LH,{})})]}),x=(g,w=28)=>{const k="sess:"+g.sessionId;return i.jsxs("div",{...p(k),"data-session-id":g.sessionId,title:g.stamp?`${g.title} · ${g.stamp}`:g.title,onClick:()=>e.onOpenSession(g),style:{position:"relative",display:"flex",alignItems:"center",gap:6,minHeight:28,padding:`5px 8px 5px ${w}px`,borderRadius:7,cursor:"pointer",background:g.selected?"var(--proto-accent-bg)":h(k)?"var(--proto-gray)":"transparent"},children:[g.selected&&i.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:w-16,top:5,bottom:5,width:2,borderRadius:1,background:"var(--proto-accent)"}}),(g.running||g.awaitingInput)&&i.jsx("span",{style:{position:"absolute",left:w-11,width:6,height:6,borderRadius:"50%",background:g.awaitingInput?"var(--proto-amber)":"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}}),i.jsx("span",{style:{flex:1,minWidth:0,fontSize:13,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontWeight:g.selected||g.unread?600:400,color:g.selected||g.unread?"var(--proto-ink)":"var(--proto-muted)"},children:g.title}),i.jsx("span",{style:{font:`400 9.5px ${Ir}`,color:"var(--proto-faint)",flex:"none"},children:g.age})]},g.sessionId)},v=g=>{const w="sched:"+g.scheduleId,k=kH(g,e.now),C=k.kind==="run"?k.stamp+(k.cost?" · "+k.cost:""):k.kind==="paused"?k.cadence+" · "+t.wbSchedPausedPill:k.cadence;return i.jsxs("div",{...p(w),"data-schedule-row":g.scheduleId,title:C,onClick:()=>e.onScheduleRow(g),style:{display:"flex",alignItems:"center",gap:6,minHeight:26,padding:"4px 8px 4px 40px",borderRadius:7,cursor:"pointer",fontSize:12.5,color:g.unread?"var(--proto-ink)":"var(--proto-muted)",fontWeight:g.unread?600:400,background:h(w)?"var(--proto-gray)":"transparent"},children:[i.jsx("span",{style:{color:g.unread?"var(--proto-accent)":"var(--proto-muted-3)",display:"flex",flex:"none"},children:i.jsx(wE,{})}),i.jsx("span",{style:{flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g.title}),i.jsx("span",{style:{font:`500 9px ${Ir}`,color:"var(--proto-muted-3)",flex:"none"},children:g.kind==="repeat"?`×${g.runs.length}`:t.wbSchedOnce})]},w)},S=g=>{const w="comm:"+g.commissionId,k=g.status!=="active";return i.jsxs("div",{children:[i.jsxs("div",{...p(w),"data-commission-row":g.commissionId,title:g.title,onClick:()=>e.onOpenCommission(g.commissionId),style:{display:"flex",alignItems:"center",gap:5,minHeight:26,padding:"4px 8px 4px 28px",borderRadius:7,cursor:"pointer",fontSize:12.5,opacity:k?.6:1,color:g.unread?"var(--proto-ink)":"var(--proto-muted)",fontWeight:g.unread?600:400,background:h(w)?"var(--proto-gray)":"transparent"},children:[i.jsx("span",{role:"button","aria-label":g.expanded?t.wbCommissionCollapse:t.wbCommissionExpand,onClick:C=>{C.stopPropagation(),e.onToggleCommission(g.commissionId)},style:{display:"flex",alignItems:"center",flex:"none",width:12,color:"var(--proto-muted-3)",visibility:g.totalSessions>0?"visible":"hidden"},children:i.jsx(p8e,{open:g.expanded})}),i.jsx("span",{style:{color:g.awaitingInput?"var(--proto-amber)":g.running?"var(--proto-accent)":"var(--proto-muted-3)",display:"flex",flex:"none"},children:i.jsx(SE,{})}),i.jsx("span",{style:{flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g.title}),k?i.jsx("span",{style:{font:`500 9px ${Ir}`,color:"var(--proto-muted-3)",flex:"none"},children:g.status==="done"?t.wbCommissionDone:t.wbCommissionAbandoned}):g.totalSessions>0&&i.jsxs("span",{style:{font:`500 9px ${Ir}`,color:"var(--proto-muted-3)",flex:"none"},children:["×",g.totalSessions]})]}),g.expanded&&g.sessions.map(C=>x(C,52))]},w)},b=g=>{const w="proj:"+g.id,k=h(w);return i.jsxs("div",{draggable:!e.filter,onDragStart:C=>{l(g.id),C.dataTransfer.effectAllowed="move";try{C.dataTransfer.setData("text/plain",g.id)}catch{}},onDragOver:C=>{!a||a===g.id||(C.preventDefault(),d(g.id))},onDrop:C=>{C.preventDefault(),a&&a!==g.id&&e.onReorder(a,g.id),l(null),d(null)},onDragEnd:()=>{l(null),d(null)},children:[i.jsxs("div",{...p(w),"data-project-row":g.id,onClick:()=>e.onToggleProject(g.id),style:{position:a?"relative":"sticky",top:0,zIndex:2,display:"flex",alignItems:"center",gap:7,height:30,boxSizing:"border-box",padding:"0 8px 0 4px",borderRadius:8,cursor:"pointer",opacity:a===g.id?.45:1,boxShadow:c===g.id?"inset 0 2px 0 0 var(--proto-accent)":void 0,background:g.current?"var(--proto-line-2)":k?"var(--proto-gray)":"var(--proto-rail)"},children:[i.jsx("span",{title:e.filter?void 0:t.wbReorderProject,style:{display:"flex",flex:"none",cursor:e.filter?"pointer":"grab"},children:i.jsx(l8e,{open:g.expanded,current:g.current,dim:g.empty})}),i.jsx("span",{title:g.id,style:{flex:1,minWidth:0,fontSize:13,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontWeight:g.current||g.attention>0?600:400,color:g.current||g.attention>0?"var(--proto-ink)":g.empty?"var(--proto-muted-2)":"var(--proto-ink-2)"},children:g.id}),i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,flex:"none"},children:[g.matchCount!==null&&i.jsx("span",{style:{font:`600 9px ${Ir}`,color:"var(--proto-accent)",background:"var(--proto-accent-bg)",borderRadius:4,padding:"1px 4px"},children:g.matchCount}),g.running>0&&i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:3,font:`600 9.5px ${Ir}`,color:"var(--proto-accent)"},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}}),g.running]}),g.attention>0&&i.jsx("span",{"data-project-attention-badge":g.id,style:{minWidth:15,height:15,padding:"0 4px",borderRadius:"50%",background:g.attentionTone==="action"?"var(--proto-amber)":"var(--proto-accent)",color:"var(--ink-solid-fg)",font:`600 9.5px ${Ir}`,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:g.attention}),k?i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:2},children:[i.jsx(Ep,{label:t.wbProjectOverview.replace("{p}",g.id),onClick:C=>{C.stopPropagation(),e.onOverview(g.id)},children:i.jsx(d8e,{})}),i.jsx(Ep,{label:t.wbNewSessionIn.replace("{p}",g.id),onClick:C=>{C.stopPropagation(),e.onNewSessionIn(g.id)},children:i.jsx(u8e,{})})]}):g.idleAge!==null?i.jsx("span",{style:{font:`400 9.5px ${Ir}`,color:"var(--proto-faint)"},children:g.idleAge}):g.hotkey&&i.jsx("span",{style:{font:`400 9px ${Ir}`,color:"var(--proto-line-3)"},children:g.hotkey})]})]}),g.expanded&&i.jsxs("div",{style:{position:"relative"},children:[i.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:12,top:-2,bottom:5,width:1,background:"var(--proto-line)"}}),g.commissions.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{...p("commhead:"+g.id),onClick:C=>{C.stopPropagation(),e.onToggleCommissions(g.id)},style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px 5px 28px",fontSize:11.5,cursor:"pointer",color:h("commhead:"+g.id)?"var(--proto-ink-2)":"var(--proto-muted-2)"},children:[i.jsx(SE,{}),t.wbCommissionGroup,i.jsxs("span",{style:{font:`500 9.5px ${Ir}`,color:"var(--proto-muted-3)"},children:["· ",g.commissions.length]}),g.commissionUnread>0&&!g.commissionsExpanded&&i.jsx("span",{style:{marginLeft:"auto",font:`500 9.5px ${Ir}`,color:"var(--proto-accent)"},children:t.wbSchedUnread.replace("{n}",String(g.commissionUnread))})]}),g.commissionsExpanded&&g.commissions.map(S)]}),g.sessions.map(C=>x(C)),(g.hiddenSessions>0||g.showingAll)&&i.jsx("div",{...p("more:"+g.id),onClick:C=>{C.stopPropagation(),g.showingAll?e.onShowFewer(g.id):e.onShowAll(g.id)},style:{padding:"3px 8px 6px 28px",fontSize:11.5,cursor:"pointer",color:h("more:"+g.id)?"var(--proto-accent)":"var(--proto-muted-2)"},children:g.showingAll?t.wbShowFewerSessions:t.wbShowAllSessions.replace("{n}",String(g.totalSessions))}),g.schedules.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{...p("schedhead:"+g.id),onClick:C=>{C.stopPropagation(),e.onToggleSchedules(g.id)},style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px 5px 28px",fontSize:11.5,cursor:"pointer",color:h("schedhead:"+g.id)?"var(--proto-ink-2)":"var(--proto-muted-2)"},children:[i.jsx(wE,{}),t.wbSchedGroup,i.jsxs("span",{style:{font:`500 9.5px ${Ir}`,color:"var(--proto-muted-3)"},children:["· ",g.schedules.length]}),g.scheduleUnread>0&&!g.schedulesExpanded&&i.jsx("span",{style:{marginLeft:"auto",font:`500 9.5px ${Ir}`,color:"var(--proto-accent)"},children:t.wbSchedUnread.replace("{n}",String(g.scheduleUnread))})]}),g.schedulesExpanded&&g.schedules.map(v)]})]})]},g.id)};return i.jsxs(i.Fragment,{children:[m(),i.jsxs("div",{"data-zone":"tree",style:{flex:1,minHeight:0,overflowY:"auto",padding:"0 8px"},children:[e.nodes.length===0?i.jsx("div",{style:{padding:"26px 16px",textAlign:"center",color:"var(--proto-faint)",fontSize:12},children:t.wbFilterNoMatch}):e.nodes.map(b),i.jsx("div",{style:{height:10}})]})]})}function h8e(){const e=he(),t=Ve();qs(r$,()=>{t.invalidateQueries(e.commissions.list.queryFilter()),t.invalidateQueries(e.commissions.get.queryFilter()),t.invalidateQueries(e.commissions.decisions.queryFilter())})}const m8e=["session.status","session.interaction","session.context-usage","session.context-compacted","session.todos"];function Tk(){const e=he(),t=Ve();qs(m8e,()=>{t.invalidateQueries(e.sessions.list.queryFilter())})}function g8e(e){return e==="five_hour"?"5h":e==="seven_day"||e==="seven_day_overage_included"?"7d":e.replaceAll("_"," ")}function Pk(e){const t=Math.max(1,Math.ceil(e/60)),n=Math.floor(t/1440),r=Math.floor(t%1440/60),o=t%60;return n>0?r>0?`${n}d ${r}h`:`${n}d`:r>0?o>0?`${r}h ${o}m`:`${r}h`:`${o}m`}function v8e(e,t,n){return n==="zh"?`${e} 个会话 · ${t} 个线程等待恢复`:`${e} ${e===1?"session":"sessions"} · ${t} ${t===1?"thread":"threads"} waiting`}function x8e(e,t){return{type:e.type,typeLabel:e.label??g8e(e.type),utilization:e.utilization,resetsAt:e.resetsAt,countdown:Pk(e.resetsAt-t)}}function y8e(e,t,n){const r=e.windows.filter(l=>l.resetsAt>t).sort((l,c)=>l.resetsAt-c.resetsAt||l.type.localeCompare(c.type)||(l.label??"").localeCompare(c.label??"")).map(l=>x8e(l,t));if(r.length===0)return null;const o=Math.max(...r.map(l=>l.resetsAt)),s=e.waitingSessions??0,a=e.waitingThreads??0;return{provider:e.provider,displayName:e.displayName,recoveryAt:o,recoveryCountdown:Pk(o-t),waitingSessions:s,waitingThreads:a,waitingLabel:v8e(s,a,n),windows:r}}function b8e(e){return`${e.displayName} · ${e.recoveryCountdown}`}function w8e(e,t,n){return n==="zh"?`${e} 个 provider 限流 · 首个 ${t}`:`${e} providers limited · first ${t}`}function S8e(e,t,n){const r=((e==null?void 0:e.providers)??[]).map(a=>y8e(a,t,n)).filter(a=>a!==null).sort((a,l)=>a.displayName.localeCompare(l.displayName)||a.provider.localeCompare(l.provider));if(r.length===0)return null;const o=Math.min(...r.map(a=>a.recoveryAt)),s=Pk(o-t);return{lang:n,firstRecoveryAt:o,providers:r,label:r.length===1?b8e(r[0]):w8e(r.length,s,n)}}function qb(){return Math.floor(Date.now()/1e3)}function OH(){var d;const e=he(),t=Ve(),n=ht(),r=ae(e.system.rateLimitStatus.queryOptions({})),{reconnectEpoch:o}=ES(),[s,a]=f.useState(qb),l=()=>{t.invalidateQueries(e.system.rateLimitStatus.queryFilter())};qs(n$,l),f.useEffect(()=>{o>0&&l()},[o]);const c=(((d=r.data)==null?void 0:d.providers.length)??0)>0;return f.useEffect(()=>{if(!c)return;a(qb());const u=window.setInterval(()=>a(qb()),3e4);return()=>window.clearInterval(u)},[c]),S8e(r.data,s,n)}const k8e=f.forwardRef(function({label:t,...n},r){return i.jsxs("button",{ref:r,type:"button",...n,"aria-label":"Rate limit status",title:t,style:{width:"100%",padding:"9px 12px",border:"1px solid var(--pill-waiting-bg)",background:"var(--pill-waiting-bg)",color:"var(--pill-waiting-fg)",borderRadius:9,display:"flex",alignItems:"center",gap:8,cursor:"pointer",textAlign:"left",font:"600 10px 'IBM Plex Mono',monospace"},children:[i.jsx("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:"50%",background:"var(--pill-waiting-fg)",flex:"none",animation:"cxpulse 2s ease-in-out infinite"}}),i.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]})});function j8e({status:e}){return e?i.jsx(yL,{trigger:i.jsx(k8e,{label:e.label}),side:"top",align:"center",children:i.jsx(FH,{status:e})}):null}function C8e({status:e,onOpen:t}){return e?i.jsx("button",{type:"button","aria-label":"Rate limit status",title:e.label,onClick:t,style:{border:`1px solid ${y.amberBorder}`,background:y.amberBg,color:y.amberText,borderRadius:999,padding:"3px 7px",maxWidth:190,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",font:`600 8.5px ${H}`,cursor:"pointer"},children:e.label}):null}function NH(e){return e.lang==="zh"?{title:"限流详情",recovers:"后恢复"}:{title:"Rate limits",recovers:"to reset"}}function T8e(e,t){return e==="zh"?t?"清除中…":"立即清除":t?"Clearing…":"Clear now"}function P8e(e,t){return{border:`1px solid ${e?y.amberBorder:"var(--pill-waiting-bg)"}`,background:"transparent",color:e?y.amberText:"var(--pill-waiting-fg)",borderRadius:999,padding:"2px 8px",font:"600 9px 'IBM Plex Mono',monospace",cursor:t?"progress":"pointer",opacity:t?.6:1}}function E8e({provider:e,lang:t,mobile:n=!1}){const r=he(),o=Ve(),s=Re(r.system.clearRateLimit.mutationOptions({onSuccess:()=>void o.invalidateQueries(r.system.rateLimitStatus.queryFilter())})),a=s.isPending;return i.jsx("button",{type:"button",disabled:a,title:t==="zh"?"立即结束此限流,恢复等待中的工作":"Lift this rate limit now and resume paused work",onClick:()=>s.mutate({provider:e}),style:P8e(n,a),children:T8e(t,a)})}function R8e(e){return e.provider.windows.map(t=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:6,color:e.muted},children:[i.jsx("span",{style:{font:`600 9.5px ${H}`},children:t.typeLabel}),i.jsxs("span",{style:{marginLeft:"auto",font:`500 9.5px ${H}`},children:[t.countdown," ",e.recovers]})]},`${t.type}:${t.typeLabel}:${t.resetsAt}`))}function M8e(e){const{provider:t,index:n,status:r,mobile:o}=e,s=o?y.muted:"var(--proto-muted-2)",a=o?y.hairline:"var(--proto-line)",l=o?y.amberText:"var(--pill-waiting-fg)";return i.jsxs("div",{style:{borderTop:n>0?`1px solid ${a}`:"none",paddingTop:n>0?9:0,marginTop:n>0?9:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[i.jsx("span",{style:{fontSize:11,fontWeight:700},children:t.displayName}),i.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[i.jsx(E8e,{provider:t.provider,lang:r.lang,mobile:o}),i.jsx("span",{style:{font:`600 9px ${H}`,color:l},children:t.recoveryCountdown})]})]}),i.jsx("div",{style:{marginTop:4,color:s,font:`500 9px ${H}`},children:t.waitingLabel}),i.jsx(R8e,{provider:t,recovers:NH(r).recovers,muted:s})]})}function FH({status:e,mobile:t=!1}){const n=NH(e),r=t?y.ink:"var(--proto-ink)";return i.jsxs("div",{style:{minWidth:t?0:230,color:r},children:[i.jsx("div",{style:{fontSize:12,fontWeight:700,marginBottom:8},children:n.title}),e.providers.map((o,s)=>i.jsx(M8e,{provider:o,index:s,status:e,mobile:t},o.provider))]})}function I8e({status:e,onClose:t}){return i.jsx(li,{onClose:t,children:i.jsx("div",{style:{padding:"2px 18px 24px"},children:i.jsx(FH,{status:e,mobile:!0})})})}const kE="'IBM Plex Mono',monospace",jE=340,CE=42,Kb="cortex.railExpanded",TE="cortex.railSchedExpanded",PE="cortex.railCommExpanded",EE="cortex.railCommOpen";function Hm(e){try{const t=window.localStorage.getItem(e);if(!t)return new Set;const n=JSON.parse(t);return new Set(Array.isArray(n)?n.filter(r=>typeof r=="string"):[])}catch{return new Set}}function RE(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function A8e({size:e}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[i.jsx("circle",{cx:33,cy:32,r:6,fill:"var(--brand-badge-core)"}),i.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"}),i.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"})]})}function ME({dot:e,label:t,onClick:n}){return i.jsxs("div",{role:"button","aria-label":t,title:t,onClick:n,style:{position:"relative",width:26,height:26,borderRadius:7,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flex:"none"},children:[i.jsx(A8e,{size:19}),i.jsx("span",{"aria-hidden":"true",style:{position:"absolute",right:-3,bottom:-3,width:9,height:9,borderRadius:"50%",background:e.color,border:"2px solid var(--proto-rail)",...e.pulse?{animation:"cxpulse 1.6s ease-in-out infinite"}:{}}})]})}function IE({size:e=15}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{flex:"none"},children:[i.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),i.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Um({label:e,color:t,onClick:n,onMouseEnter:r,onMouseLeave:o,children:s}){return i.jsx("button",{type:"button","aria-label":e,title:e,onClick:n,onMouseEnter:r,onMouseLeave:o,style:{width:28,height:28,border:0,borderRadius:7,background:"transparent",color:t,display:"grid",placeItems:"center",padding:0,cursor:"pointer",flex:"none"},children:s})}function A1(){var J;const e=Xe(),t=he(),n=nh(),r=Wx(),{open:o}=t1(),s=O(),a=OS(),{railCollapsed:l,setRailCollapsed:c}=C1(),d=VS(),u=OH(),p=Z$(a),h=s[J$(a)],m=ae(t.projects.list.queryOptions({})),x=wc("direct"),v=wc("scheduled"),S=ae(t.schedules.list.queryOptions({})),b=ae(t.commissions.list.queryOptions({})),g=ae(t.threads.list.queryOptions({})),w=AS(),k=d_();Tk(),h8e();const{currentProjectId:C,setCurrentProject:T,setProjectOrder:P}=zt(),{selectedSessionId:R,setSelectedSession:D}=Vi(),I=f.useMemo(()=>m.data??[],[m.data]),L=f.useMemo(()=>x.data??[],[x.data]),W=f.useMemo(()=>v.data??[],[v.data]),[ee,V]=f.useState(()=>Hm(Kb)),[X,K]=f.useState(()=>Hm(TE)),[se,B]=f.useState(()=>Hm(PE)),[G,ne]=f.useState(()=>Hm(EE)),[le,_]=f.useState(()=>new Set),[Y,te]=f.useState(!1),[ie,ye]=f.useState(""),[Z,xe]=f.useState(J7e),[ke,Oe]=f.useState(t8e),[Ie,Ae]=f.useState(!1),[tt,we]=f.useState(null),[lt,Qe]=f.useState(null),Zt=(Q,re)=>ve=>{Q(Ne=>{const be=new Set(Ne);return be.has(ve)?be.delete(ve):be.add(ve),re&&RE(re,be),be})},wn=Q=>{_(re=>{if(!re.has(Q))return re;const ve=new Set(re);return ve.delete(Q),ve})},Qn=Zt(K,TE),qt=Zt(B,PE),ft=Zt(ne,EE),Vr=Zt(V,Kb),pr=Q=>{ee.has(Q)&&wn(Q),Vr(Q)},mt=Q=>{V(re=>{if(re.has(Q))return re;const ve=new Set(re).add(Q);return RE(Kb,ve),ve})},Bt=Date.now(),Ct=f.useMemo(()=>a8e({projects:I,directSessions:L,scheduledSessions:W,schedules:S.data??[],commissions:b.data??[],threads:g.data??[],selectedSessionId:R,fallbackProjectId:C,expanded:ee,schedulesExpanded:X,commissionsExpanded:se,expandedCommissions:G,showAll:le,filter:ie,sort:Z,manualOrder:ke,dragged:Ie,now:Bt}),[I,L,W,S.data,b.data,g.data,R,C,ee,X,se,G,le,ie,Z,ke,Ie]);f.useEffect(()=>{ie.trim()||P(Ct.projects.map(Q=>Q.id))},[ie,Ct.projects,P]),f.useEffect(()=>{Ct.currentProjectId&&Ct.currentProjectId!==C&&T(Ct.currentProjectId)},[Ct.currentProjectId,C,T]);const fr=f.useRef(!1);f.useEffect(()=>{fr.current||!C||(fr.current=!0,ee.size===0&&mt(C))},[C]);const Sn=L.length+":"+W.length+":"+L.reduce((Q,re)=>Math.max(Q,Date.parse(re.lastUsedAt||re.createdAt)||0),0);f.useEffect(()=>{Ae(!1)},[Sn]);const gt=(Q,re)=>{T(Q),D(re),mt(Q),e("/workbench")},go=Q=>gt(Q.projectId,Q.sessionId),In=Q=>{Q&&(T(Q),mt(Q)),D("__draft__"),e("/workbench")},qi=()=>In(null),Er=Q=>{T(Q),e("/overview")},Rr=f.useRef(Ct);Rr.current=Ct;const zn=f.useRef(gt);zn.current=gt,f.useEffect(()=>{const Q=re=>{if(!(re.metaKey||re.ctrlKey)||re.altKey||re.shiftKey)return;const ve=q7e(re.key);if(ve===null)return;const Ne=Rr.current.projects.filter(Se=>!Se.empty)[ve];if(!Ne)return;re.preventDefault();const be=Ne.sessions[0];be?zn.current(be.projectId,be.sessionId):mt(Ne.id)};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[]);const qr=Q=>{Oe(re=>Sw(re,Ct.projects.map(ve=>ve.id))),xe(Q),e8e(Q),Q==="activity"&&Ae(!1)},Fo=(Q,re)=>{const ve=Ct.projects.map(Se=>Se.id),Ne=Sw(ke,ve),be=r8e(Ne,Q,re);Oe(be),n8e(be),Ae(!0)},vo=()=>{c(!1),te(!0)},xo=()=>{te(Q=>(Q&&ye(""),!Q))},hr=f.useMemo(()=>Ct.projects.flatMap(Q=>Q.schedules),[Ct.projects]),An=tt?hr.find(Q=>Q.scheduleId===tt)??null:null,pn=Q=>{const re=SH(Q);if(re.type==="modal")we(Q.scheduleId);else if(re.type==="open"){const ve=kw(re.sessionId,L,W);ve&&gt(ve,re.sessionId)}else w.openEdit(re.schedule)},Ks=v2e(),ui=((J=ae(t.approvals.list.queryOptions({status:"pending"})).data)==null?void 0:J.length)??0,Xn=ui>0,mr=ui+" "+(ui>1?s.approvalsPending:s.approvalPending),Bn=Q=>({onMouseEnter:()=>Qe(Q),onMouseLeave:()=>Qe(re=>re===Q?null:re)}),Kr=Q=>lt===Q,pi=f.useRef(null);f.useEffect(()=>{var re,ve;if(l||!Ct.currentProjectId)return;const Q=`[data-project-row="${CSS.escape(Ct.currentProjectId)}"]`;(ve=(re=pi.current)==null?void 0:re.querySelector(Q))==null||ve.scrollIntoView({block:"nearest"})},[Ct.currentProjectId,Ct.projects.length,l]);const $=i.jsx("div",{"aria-hidden":"true",style:{width:20,height:1,background:"var(--proto-line)",margin:"3px 0",flex:"none"}}),q=()=>i.jsxs("nav",{"aria-label":s.lrRailNavigation,style:{width:CE-1,flex:1,minHeight:0,display:"flex",flexDirection:"column",alignItems:"center",gap:5,padding:"14px 0 12px"},children:[i.jsx(ME,{dot:p,label:`${s.dmDaemon} · ${h}`,onClick:()=>d.openDaemonStatus()}),$,i.jsx("button",{type:"button","aria-label":s.wbNewSession,title:`${s.wbNewSession} · ⌘N`,onClick:qi,...Bn("crail:new"),style:{width:26,height:26,border:0,borderRadius:7,padding:0,cursor:"pointer",flex:"none",display:"grid",placeItems:"center",color:"var(--ink-solid-fg)",background:Kr("crail:new")?"var(--proto-accent-strong)":"var(--proto-accent)"},children:i.jsx(gc,{size:14})}),i.jsx(Um,{label:s.newProject,color:Kr("crail:newproj")?"var(--proto-ink)":"var(--proto-muted-2)",onClick:()=>d.openNewProject(),...Bn("crail:newproj"),children:i.jsx(LH,{})}),i.jsx(Um,{label:s.wbFilterSessions,color:Kr("crail:search")?"var(--proto-ink)":"var(--proto-muted-2)",onClick:vo,...Bn("crail:search"),children:i.jsx(jw,{})}),i.jsx("div",{style:{flex:1,minHeight:8}}),Xn&&i.jsx(Um,{label:mr,color:"var(--proto-amber-fg)",onClick:()=>Ks.open(),children:i.jsx("span",{style:{minWidth:16,height:16,padding:"0 4px",borderRadius:8,background:"var(--proto-amber)",color:"var(--ink-solid-fg)",font:`600 9px ${kE}`,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:ui})}),i.jsx(Um,{label:s.settings,color:Kr("crail:settings")?"var(--proto-ink)":"var(--proto-muted-2)",onClick:o,...Bn("crail:settings"),children:i.jsx(IE,{})})]});return i.jsxs("div",{"data-pane":"left","data-collapsed":l||void 0,style:{width:l?CE:jE,transition:"width 220ms cubic-bezier(0.22, 1, 0.36, 1)",flex:"none",display:"flex",flexDirection:"column",background:"var(--proto-rail)",borderRight:"1px solid var(--proto-line)",minHeight:0,overflow:"hidden"},children:[l&&q(),i.jsxs("div",{ref:pi,style:{display:l?"none":"flex",flexDirection:"column",flex:1,minHeight:0,width:jE},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"16px 16px 10px",flex:"none"},children:[i.jsx(ME,{dot:p,label:`${s.dmDaemon} · ${h}`,onClick:()=>d.openDaemonStatus()}),i.jsx("div",{style:{fontWeight:650,fontSize:14,color:"var(--proto-ink)",letterSpacing:"-.01em"},children:"Cortex"})]}),i.jsxs("div",{...Bn("newsess"),role:"button",onClick:qi,style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",gap:7,height:34,margin:"0 12px 10px",borderRadius:9,flex:"none",cursor:"pointer",fontSize:12.5,fontWeight:600,color:"var(--ink-solid-fg)",background:Kr("newsess")?"var(--proto-accent-strong)":"var(--proto-accent)"},children:[i.jsx(gc,{size:13}),s.wbNewSession,i.jsx("span",{style:{position:"absolute",right:10,font:`500 9.5px ${kE}`,color:"var(--ink-solid-fg-dim)"},children:"⌘N"})]}),i.jsx(f8e,{nodes:Ct.projects,projectCount:I.length,sort:Z,onSort:qr,filter:ie,onFilter:ye,searchOpen:Y,onToggleSearch:xo,onNewProject:()=>d.openNewProject(),onToggleProject:pr,onToggleSchedules:Qn,onToggleCommissions:qt,onToggleCommission:ft,onOpenCommission:k.openCommission,onShowAll:Q=>_(re=>new Set(re).add(Q)),onShowFewer:wn,onOpenSession:go,onNewSessionIn:In,onOverview:Er,onScheduleRow:pn,onReorder:Fo,now:Bt}),(u||Xn)&&i.jsxs("div",{style:{margin:"0 12px 10px",display:"flex",flexDirection:"column",gap:8,flex:"none"},children:[i.jsx(j8e,{status:u}),Xn&&i.jsxs("div",{...Bn("approval"),onClick:()=>Ks.open(),style:{padding:"9px 12px",background:"var(--proto-amber-bg)",border:"1px solid "+(Kr("approval")?"var(--proto-amber)":"var(--proto-amber-border)"),borderRadius:9,display:"flex",alignItems:"center",gap:8,cursor:"pointer",flex:"none"},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-amber)",flex:"none",animation:"cxpulse 2s ease-in-out infinite"}}),i.jsx("div",{style:{fontSize:11.5,color:"var(--proto-amber-fg)",fontWeight:600},children:mr}),i.jsx("div",{style:{marginLeft:"auto",color:"var(--proto-amber-accent)",fontSize:11},children:"→"})]})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 16px 14px",borderTop:"1px solid var(--proto-line-2)",flex:"none"},children:[i.jsxs("div",{style:{display:"flex",border:"1px solid var(--proto-line)",borderRadius:6,overflow:"hidden"},children:[i.jsx("span",{onClick:()=>r("light"),title:s.stThemeLight,"aria-label":s.stThemeLight,style:{fontSize:10,fontWeight:600,padding:"2.5px 7px",cursor:"pointer",background:n==="light"?"var(--ink-solid-bg)":"transparent",color:n==="light"?"var(--ink-solid-fg)":"var(--proto-muted-2)"},children:"☀"}),i.jsx("span",{onClick:()=>r("dark"),title:s.stThemeDark,"aria-label":s.stThemeDark,style:{fontSize:10,fontWeight:600,padding:"2.5px 7px",cursor:"pointer",background:n==="dark"?"var(--ink-solid-bg)":"transparent",color:n==="dark"?"var(--ink-solid-fg)":"var(--proto-muted-2)"},children:"☾"})]}),i.jsx("span",{...Bn("settings"),onClick:o,role:"button",title:s.settings,"aria-label":s.settings,style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:2,cursor:"pointer",color:Kr("settings")?"var(--proto-ink)":"var(--proto-muted-2)"},children:i.jsx(IE,{})})]})]}),An&&i.jsx(V7e,{row:An,selectedSessionId:R??null,onOpenRun:Q=>{we(null);const re=kw(Q,L,W);re&&gt(re,Q)},onManage:An.schedule?()=>{we(null),w.openEdit(An.schedule)}:void 0,onClose:()=>we(null)})]})}const AE="—";function zH(e){var t,n;return[{key:"cortexId",label:e.cortexIdLabel,value:((t=e.cortexId)==null?void 0:t.trim())||AE},{key:"backendUuid",label:e.backendUuidLabel,value:((n=e.backendUuid)==null?void 0:n.trim())||AE}]}const Gb="'IBM Plex Mono',monospace";function D8e({cortexId:e,backendUuid:t,onClose:n}){const r=O(),o=zH({cortexId:e,backendUuid:t,cortexIdLabel:r.wbCortexId,backendUuidLabel:r.wbBackendUuid}),{copiedKey:s,copy:a}=G0(),l=(c,d)=>{d!=="—"&&a(d,c)};return i.jsxs(ur,{chrome:"bare",size:"custom",open:!0,showClose:!1,title:r.wbSessionId,description:r.wbBackendUuid,onOpenChange:c=>{c||n()},contentDataAttributes:{"data-modal":"session-id"},bodyStyle:{display:"contents"},contentStyle:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:480,background:"var(--proto-card)",borderRadius:14,boxShadow:"var(--shadow-overlay-strong)",zIndex:61,overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 20px 0"},children:[i.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:r.wbSessionId}),i.jsx("span",{onClick:n,style:{marginLeft:"auto",font:`500 9.5px ${Gb}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),i.jsx("div",{style:{padding:"14px 20px 18px",display:"flex",flexDirection:"column",gap:12},children:o.map(c=>i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginBottom:6},children:c.label}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1px solid var(--proto-line)",borderRadius:9,padding:"9px 12px",background:"var(--proto-alt)"},children:[i.jsx("span",{style:{flex:1,font:`500 12.5px ${Gb}`,color:"var(--proto-ink)",userSelect:"all",wordBreak:"break-all"},children:c.value}),i.jsx("span",{onClick:()=>l(c.key,c.value),style:{flex:"none",font:`500 9.5px ${Gb}`,color:s===c.key?"var(--proto-accent)":"var(--proto-muted-2)",border:"1px solid var(--proto-line-3)",borderRadius:6,padding:"3px 8px",cursor:c.value==="—"?"default":"pointer",opacity:c.value==="—"?.4:1},children:s===c.key?r.wbCopied:r.wbCopy})]})]},c.key))})]})}function L8e(e){return{display:"inline-flex",alignItems:"center",gap:6,border:e?"1.5px solid var(--proto-accent)":"1px solid var(--proto-line)",borderRadius:7,padding:"4px 9px",background:e?"var(--proto-accent-bg)":"var(--proto-card)",color:e?"var(--proto-accent)":"var(--proto-ink)",fontFamily:"inherit",cursor:"pointer"}}function O8e(){return i.jsx("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:i.jsx("path",{d:"M9.8 1.8l2.4 2.4L4.6 11.8l-3 .6.6-3z"})})}function BH({count:e,active:t,copy:n,onClick:r}){return i.jsxs("button",{type:"button","data-notes-button":"","aria-pressed":t,onClick:r,title:`${n.title} · ⌘⇧N`,style:L8e(t),children:[i.jsx(O8e,{}),i.jsx("span",{style:{fontSize:10.5,fontWeight:600},children:n.title}),i.jsx("span",{style:{font:"600 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-accent)"},children:e})]})}function N8e(e){return{display:"inline-flex",alignItems:"center",gap:6,border:e?"1.5px solid var(--proto-accent)":"1px solid var(--proto-line)",borderRadius:7,padding:"4px 9px",background:e?"var(--proto-accent-bg)":"var(--proto-card)",color:e?"var(--proto-accent)":"var(--proto-ink)",fontFamily:"inherit",cursor:"pointer"}}function F8e(){return i.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[i.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),i.jsx("path",{d:"M1.4 7h11.2M7 1.4c1.6 1.7 2.4 3.6 2.4 5.6S8.6 10.9 7 12.6C5.4 10.9 4.6 9 4.6 7S5.4 3.1 7 1.4z"})]})}function z8e(){const{canDock:e,active:t,activeTab:n,openWeb:r}=Ic();if(!e)return null;const o=t&&(n==null?void 0:n.kind)==="web";return i.jsxs("button",{type:"button","data-browser-button":"","aria-pressed":o,title:"Open a web page in the dock",onClick:r,style:N8e(o),children:[i.jsx(F8e,{}),i.jsx("span",{style:{fontSize:10.5,fontWeight:600},children:"Web"})]})}const B8e="'IBM Plex Mono',monospace";function $8e({title:e,onCmdK:t,backendSessionId:n,sessionName:r}){const o=O(),s=j1(),[a,l]=f.useState(!1),[c,d]=f.useState(!1),[u,p]=f.useState(!1),h=VS();return f.useEffect(()=>{if(!u)return;const m=v=>{v.key==="Escape"&&p(!1)},x=()=>p(!1);return window.addEventListener("keydown",m),window.addEventListener("click",x),()=>{window.removeEventListener("keydown",m),window.removeEventListener("click",x)}},[u]),i.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:10,padding:"0 20px"},children:[i.jsx("div",{style:{fontSize:13.5,fontWeight:600,color:"var(--proto-ink)",maxWidth:320,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e}),i.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:14,color:"var(--proto-muted-2)"},children:[i.jsx("span",{onClick:t,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{font:`500 11px ${B8e}`,cursor:"pointer",color:a?"var(--proto-ink)":void 0},children:"⌘K"}),i.jsx("span",{style:{width:1,height:18,background:"var(--proto-line)",flex:"none"}}),i.jsx(z8e,{}),i.jsx(BH,{count:s.vm.activeCount,active:s.isOpen,copy:s.copy,onClick:()=>s.isOpen?s.close():s.open()}),i.jsxs("span",{style:{position:"relative",display:"inline-flex"},children:[i.jsx("span",{"data-chip":"more","aria-label":"Session menu",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onClick:m=>{m.stopPropagation(),p(x=>!x)},style:{fontSize:15,lineHeight:1,letterSpacing:1,cursor:"pointer",color:c||u?"var(--proto-ink)":void 0},children:"⋯"}),u?i.jsx("span",{onClick:m=>m.stopPropagation(),style:{position:"absolute",right:0,top:24,minWidth:132,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:9,boxShadow:"var(--shadow-menu-strong)",overflow:"hidden",zIndex:40},children:i.jsx("div",{onClick:()=>{p(!1),h.openSessionId()},style:{padding:"9px 13px",fontSize:12.5,color:"var(--proto-ink)",cursor:"pointer",whiteSpace:"nowrap"},children:o.wbSessionId})}):null]})]}),h.sessionIdOpen?i.jsx(D8e,{cortexId:r,backendUuid:n,onClose:h.closeSessionId}):null]})}function Ek(e){switch(e){case"running":return{bg:"var(--pill-running-bg)",color:"var(--pill-running-fg)",text:"Running"};case"waiting":return{bg:"var(--pill-waiting-bg)",color:"var(--pill-waiting-fg)",text:"Waiting"};case"completed":return{bg:"var(--pill-done-bg)",color:"var(--pill-done-fg)",text:"Done"};case"failed":return{bg:"var(--pill-failed-bg)",color:"var(--pill-failed-fg)",text:"Failed"};default:return{bg:"var(--pill-cancelled-bg)",color:"var(--pill-cancelled-fg)",text:"Cancelled"}}}function _8e(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function $H(e){return"L"+(e+2)}function DE(e){const t=[];return e.durationS!=null&&t.push(_8e(e.durationS)),e.costUsd!=null&&t.push(yn(e.costUsd)),t.join(" · ")}function W8e(e){const t=e.children[0];return t?{name:t.templateName??t.id,level:$H(t.depth),running:t.status==="running",meta:t.status==="running"?"running":"done"}:null}function H8e(e){const t=e.status==="running",n=Ek(e.status),r=W8e(e);return{name:e.templateName??e.id,level:$H(e.depth),chev:t?"▾":"▸",border:t?"var(--proto-line-4)":"var(--proto-line-2)",bg:t?"var(--proto-alt)":"var(--proto-rail)",iconColor:t?"var(--proto-accent)":"var(--proto-muted-2)",nameColor:t?"var(--proto-ink)":"var(--proto-muted)",pillBg:n.bg,pillColor:n.color,pillText:t?"Running":n.text,hasLine:r!=null,line:e.activeAgent??"",meta:e.costUsd?yn(e.costUsd):"",nested:r}}function U8e(e){const t=e.steps,n=t.map((s,a)=>{const l=s.status==="completed"?"done":s.status==="running"?"running":"pending",c=l==="running",d=l==="done",u=c?e.children.map(H8e):[],p=a<t.length-1;return{node:l,hasTail:p,padB:p?"8px":"2px",name:s.stage??`Step ${s.stepIndex+1}`,fw:c?600:500,color:c?"var(--proto-ink)":d?"var(--proto-muted)":"var(--proto-faint)",sub:c?e.activeStage??"":s.outputSummary??"",subColor:c?"var(--proto-muted-3)":"var(--proto-faint)",meta:c?DE(s)||"running":d?DE(s):"gated",metaColor:c?"var(--proto-accent)":d?"var(--proto-faint)":"var(--proto-disabled)",chev:d,expanded:c,subs:u}}),r=Ek(e.status),o=e.status==="running"&&e.currentStep?`Step ${e.currentStep.index+1}/${e.totalSteps}`:r.text;return{id:e.id,name:e.templateName,pill:r,pillText:o,meta:yn(e.totalCostUsd),rows:n}}const us="'IBM Plex Mono',monospace";function V8e({row:e}){return i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e.node==="done"&&i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,flex:"none"},children:"✓"}),e.node==="running"&&i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-accent)",flex:"none",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite"}}),e.node==="pending"&&i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),e.hasTail&&i.jsx("span",{style:{flex:1,width:1.5,background:"var(--proto-line-2)",margin:"3px 0"}})]})}function q8e({sub:e,onOpenNested:t}){return i.jsxs("div",{style:{border:"1px solid "+e.border,background:e.bg,borderRadius:8},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"7px 10px"},children:[i.jsx("span",{style:{color:"var(--proto-muted-2)",fontSize:9},children:e.chev}),i.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:e.iconColor,strokeWidth:"1.8",children:[i.jsx("path",{d:"M7 1.5v5M7 6.5 3.5 10M7 6.5l3.5 3.5"}),i.jsx("circle",{cx:"7",cy:"1.5",r:"1.4",fill:e.iconColor,stroke:"none"}),i.jsx("circle",{cx:"3.5",cy:"11",r:"1.4",fill:e.iconColor,stroke:"none"}),i.jsx("circle",{cx:"10.5",cy:"11",r:"1.4",fill:e.iconColor,stroke:"none"})]}),i.jsx("span",{style:{font:`600 11px ${us}`,color:e.nameColor},children:e.name}),i.jsx("span",{style:{font:`400 9px ${us}`,color:"var(--proto-faint)"},children:e.level}),i.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:e.pillBg,color:e.pillColor},children:e.pillText})]}),e.hasLine&&i.jsxs("div",{style:{padding:"0 10px 8px 27px"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"var(--proto-muted)"},children:[i.jsx("span",{children:e.line}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${us}`,color:"var(--proto-muted-3)"},children:e.meta})]}),e.nested&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,border:"1px solid var(--proto-line-2)",background:"var(--proto-card)",borderRadius:7,padding:"5.5px 9px",marginTop:6},children:[i.jsx("span",{style:{color:"var(--proto-faint)",fontSize:9},children:"▸"}),i.jsx("span",{style:{font:`600 10.5px ${us}`,color:"var(--proto-ink-2)"},children:e.nested.name}),i.jsx("span",{style:{font:`400 9px ${us}`,color:"var(--proto-faint)"},children:e.nested.level}),e.nested.running&&i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}}),i.jsx("span",{style:{fontSize:9.5,color:"var(--proto-muted-3)"},children:e.nested.meta}),i.jsx("span",{onClick:t,style:{marginLeft:"auto",fontSize:10,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:"Open ›"})]})]})]})}function K8e({card:e,onOpen:t}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"8px 13px",background:"var(--proto-rail)",borderBottom:"1px solid var(--proto-line-2)"},children:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.6",children:[i.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),i.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),i.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),i.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]}),i.jsx("span",{style:{font:`600 12px ${us}`,color:"var(--proto-ink)"},children:e.name}),i.jsx("span",{style:{font:`400 10.5px ${us}`,color:"var(--proto-muted-3)"},children:e.id}),i.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:e.pill.bg,color:e.pill.color},children:e.pillText}),i.jsx("span",{style:{marginLeft:"auto",font:`400 10.5px ${us}`,color:"var(--proto-muted-3)"},children:e.meta}),i.jsx("span",{onClick:t,style:{fontSize:11.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:"Open →"})]})}function G8e({row:e,onOpenNested:t}){return i.jsxs(f.Fragment,{children:[i.jsx(V8e,{row:e}),i.jsxs("div",{style:{paddingBottom:e.padB},children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:7},children:[i.jsx("span",{style:{fontSize:11.5,fontWeight:e.fw,color:e.color,flex:"none"},children:e.name}),i.jsx("span",{style:{fontSize:9.5,color:e.subColor,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.sub}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${us}`,color:e.metaColor,flex:"none"},children:e.meta}),e.chev&&i.jsx("span",{style:{color:"var(--proto-line-3)",fontSize:8,flex:"none"},children:"▸"})]}),e.expanded&&e.subs.length>0&&i.jsx("div",{style:{marginTop:7,display:"flex",flexDirection:"column",gap:6},children:e.subs.map((n,r)=>i.jsx(q8e,{sub:n,onOpenNested:t},r))})]})]})}function Y8e({card:e,onOpen:t}){return i.jsxs("div",{"data-inline-thread-id":e.id,style:{border:"1px solid var(--proto-line)",borderRadius:10,overflow:"hidden"},children:[i.jsx(K8e,{card:e,onOpen:t}),i.jsx("div",{style:{padding:"10px 14px 6px"},children:i.jsx("div",{style:{display:"grid",gridTemplateColumns:"16px 1fr",columnGap:9},children:e.rows.map((n,r)=>i.jsx(G8e,{row:n,onOpenNested:t},r))})})]})}function Q8e({sessionId:e}){var l;const{openThread:t}=RS(),n=he(),o=ae({...n.threads.list.queryOptions({status:["running","waiting"],sessionId:e}),enabled:!!e}).data??[],s=((l=o.find(c=>c.status==="running")??o[0])==null?void 0:l.id)??"";vh(s);const a=ae({...n.threads.get.queryOptions({threadId:s}),enabled:!!s});return!s||!a.data||a.isError?null:i.jsx(Y8e,{card:U8e(a.data),onOpen:()=>t(s)})}const Cw=[{cmd:"/new",desc:"Start a new session"},{cmd:"/cancel",desc:"Cancel the current run"},{cmd:"/compact",desc:"Compact this session"},{cmd:"/profile",desc:"Switch this session profile"},{cmd:"/settings",desc:"Open settings"}];function _H(e){return{none:null,action:null,invalid:"wbSlashInvalid",incomplete:"wbSlashIncomplete",disabled:"wbSlashDisabled"}[e.kind]}function WH(e){const t=e.trimStart();if(!t.startsWith("/"))return null;const n=t.slice(1),r=n.search(/\s/);return r<0?{command:n.toLowerCase(),args:"",hasArgsSeparator:!1}:{command:n.slice(0,r).toLowerCase(),args:n.slice(r+1).trim(),hasArgsSeparator:!0}}function Tw(e){return{new:{type:"new"},cancel:{type:"cancel"},compact:{type:"compact"},settings:{type:"settings"}}[e]??null}function HH(e,t){return e.type==="profile"?!1:!!t[`${e.type}Disabled`]}function UH(e,t,n={}){const r=WH(e);if(!r)return{kind:"none"};const o=Cw.some(l=>l.cmd===`/${r.command}`),s=Cw.some(l=>l.cmd.slice(1).startsWith(r.command));if(!o)return s&&!r.hasArgsSeparator?{kind:"incomplete"}:{kind:"invalid"};if(r.command==="profile")return X8e(r,t);const a=Tw(r.command);return r.args||!a?{kind:"invalid"}:HH(a,n)?{kind:"disabled"}:{kind:"action",action:a}}function X8e(e,t){if(!e.hasArgsSeparator||!e.args)return{kind:"incomplete"};if(/\s/.test(e.args))return{kind:"invalid"};const n=t.find(r=>r.name.toLowerCase()===e.args.toLowerCase());return n?n.disabled?{kind:"disabled"}:{kind:"action",action:{type:"profile",profileName:n.name}}:{kind:"invalid"}}function Z8e(e,t){return t.filter(n=>n.name.toLowerCase().startsWith(e)).map(n=>({command:`/profile ${n.name}`,description:n.detail??"Switch this session profile",action:{type:"profile",profileName:n.name},disabled:n.disabled??!1}))}function VH(e,t,n={}){const r=WH(e);return r?r.command==="profile"&&r.hasArgsSeparator?Z8e(r.args.toLowerCase(),t):r.hasArgsSeparator?[]:Cw.filter(o=>o.cmd.slice(1).startsWith(r.command)).map(o=>({command:o.cmd,description:o.desc,action:o.cmd==="/profile"?null:Tw(o.cmd.slice(1)),disabled:o.cmd==="/profile"?!1:HH(Tw(o.cmd.slice(1)),n)})):[]}function qH(e,t){if(e.type==="profile"){t.onProfile(e.profileName);return}({new:t.onNew,cancel:t.onCancel,compact:t.onCompact,settings:t.onSettings})[e.type]()}function J8e(e){switch(e){case"running":return{bg:"var(--pill-running-bg)",fg:"var(--pill-running-fg)",text:"Running"};case"waiting":return{bg:"var(--pill-waiting-bg)",fg:"var(--pill-waiting-fg)",text:"Waiting"};case"completed":return{bg:"var(--pill-done-bg)",fg:"var(--pill-done-fg)",text:"Done"};case"failed":return{bg:"var(--pill-failed-bg)",fg:"var(--pill-failed-fg)",text:"Failed"};default:return{bg:"var(--pill-cancelled-bg)",fg:"var(--pill-cancelled-fg)",text:"Cancelled"}}}function eCe(e){return e.status==="completed"?"done":e.status==="running"?"running":"pending"}function Ru(e){return yn(e)}function tCe(e,t){const n=typeof e=="number"?Ru(e):"—";if(t==null||t<=0)return{todayLabel:n,limitLabel:"—",percent:0};const r=Math.max(0,Math.min(100,(e??0)/t*100));return{todayLabel:n,limitLabel:Ru(t),percent:r}}function nCe(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function rCe(e){const t=[];return e.durationS!=null&&t.push(nCe(e.durationS)),e.costUsd!=null&&t.push(Ru(e.costUsd)),t.join(" · ")}function oCe(e){return e.runName?`cortex-run ${e.runName}`:"cortex-run"}function iCe(e){return e==="running"?{label:"Running",tone:"running"}:e==="completed"?{label:"Done",tone:"done"}:e==="failed"||e==="cancelled"?{label:"Failed",tone:"failed"}:{label:e||"Unknown",tone:"idle"}}function sCe(e){return e.status==="done"?{label:"Done",tone:"done"}:e.blockedBy?{label:"Blocked",tone:"failed"}:e.claimedBy?{label:"Running",tone:"running"}:e.actionable?{label:"Open",tone:"idle"}:{label:"Waiting",tone:"idle"}}function KH(e,t){const n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<60)return"just now";const r=Math.floor(n/60);if(r<60)return`${r}m`;const o=Math.floor(r/60);return o<24?`${o}h`:`${Math.floor(o/24)}d`}function aCe(e,t){const n=[e.id];return e.taskId&&n.push(`task ${e.taskId}`),e.currentStep&&n.push(`step ${e.currentStep.index+1}/${e.totalSteps}`),n.push(KH(e.createdAt,t)),n.join(" · ")}function lCe(e){const t=qF(e.children);return{filled:t,total:h0,text:`${t}/${h0}`}}function cCe(e){return e?e.filter(t=>t.online).length:0}function dCe(e){return e?{bg:"var(--pill-done-bg)",fg:"var(--pill-done-fg)",text:"Online"}:{bg:"var(--pill-cancelled-bg)",fg:"var(--pill-cancelled-fg)",text:"Offline"}}function GH(e){var t,n;return((t=e.file)==null?void 0:t.type)??((n=e.meta)==null?void 0:n.mimeType)??""}function LE(e){var t,n;return((t=e.file)==null?void 0:t.name)??((n=e.meta)==null?void 0:n.name)??"file"}function uCe(e){var t,n;return((t=e.file)==null?void 0:t.size)??((n=e.meta)==null?void 0:n.size)??0}function YH(e){const t=GH(e);return t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file"}function Rk(e){return e.flatMap(t=>t.status==="done"&&t.meta?[t.meta]:[])}function QH(e,t){return t.every(r=>r.status==="done")&&(e.trim().length>0||t.some(r=>r.status==="done"))}const pCe="/api/attachments/upload";function fCe(e,t){return{"X-Session-Id":t,"X-File-Name":encodeURIComponent(e.name),"Content-Type":e.type||"application/octet-stream",...Oi()}}function hCe(e){if(e.status===413)return new Error("File too large");const t=e.response;return new Error((t==null?void 0:t.message)||`Upload failed (${e.status})`)}function mCe(e){const t=e.response;if(t!=null&&t.ok&&t.data)return t.data;throw new Error((t==null?void 0:t.message)||`Upload failed (${e.status})`)}function gCe(e,t){e.upload.addEventListener("progress",n=>{!n.lengthComputable||n.total<=0||t(Math.max(0,Math.min(100,Math.round(n.loaded/n.total*100))))})}function vCe(e,t,n,r){gCe(e,n),e.addEventListener("load",()=>{if(e.status<200||e.status>=300)return r(hCe(e));try{r(void 0,mCe(e))}catch(o){r(o)}}),e.addEventListener("error",()=>r(new Error("Network error"))),e.addEventListener("abort",()=>r(new Error("Upload cancelled"))),e.send(t)}function xCe(e,t,n,r){return r.aborted?Promise.reject(new Error("Upload cancelled")):new Promise((o,s)=>{const a=new XMLHttpRequest;let l=!1;const c=(u,p)=>{l||(l=!0,r.removeEventListener("abort",d),u?s(u):o(p))},d=()=>a.abort();a.open("POST",`${Pc()}${pCe}`),Object.entries(fCe(e,t)).forEach(([u,p])=>a.setRequestHeader(u,p)),a.responseType="json",r.addEventListener("abort",d,{once:!0}),vCe(a,e,n,c)})}const yCe=3;let OE=0;function XH(){return OE+=1,`att_${OE}_${Date.now()}`}function ZH(e){return e.startsWith("image/")||e.startsWith("video/")}function bCe(e){return{id:XH(),file:e,status:"queued",progress:0,previewUrl:ZH(e.type)?URL.createObjectURL(e):void 0}}function NE(e){return{id:XH(),status:"done",progress:100,meta:e}}function wCe(e){return b1(e,"inline")}function SCe(e){return e instanceof Error?e.message:"Upload failed"}function kCe(e){return!e.file&&!e.previewUrl&&e.status==="done"&&!!e.meta&&ZH(e.meta.mimeType)}class jCe{constructor(t){Pt(this,"items",[]);Pt(this,"listeners",new Set);Pt(this,"controllers",new Map);Pt(this,"requestedPreviews",new Set);Pt(this,"revoked",new Set);Pt(this,"generation",0);Pt(this,"disposalVersion",0);Pt(this,"options");Pt(this,"getSnapshot",()=>this.items);Pt(this,"subscribe",t=>(this.listeners.add(t),()=>this.listeners.delete(t)));Pt(this,"reset",()=>{this.generation+=1,this.abortAll(),this.requestedPreviews.clear(),this.items.forEach(t=>this.revoke(t.previewUrl)),this.publish([])});Pt(this,"addFiles",t=>{const n=Array.from(t).map(bCe);n.length!==0&&(this.publish([...this.items,...n]),this.pump())});Pt(this,"remove",t=>{const n=this.items.find(o=>o.id===t),r=this.controllers.get(t);this.controllers.delete(t),r==null||r.abort(),this.requestedPreviews.delete(t),this.revoke(n==null?void 0:n.previewUrl),this.publish(this.items.filter(o=>o.id!==t)),this.pump()});Pt(this,"retry",t=>{const n=this.items.find(o=>o.id===t&&o.status==="error");if(!(n!=null&&n.file))return;const r={...n,status:"queued",progress:0,errorMsg:void 0};this.publish([...this.items.filter(o=>o.id!==t),r]),this.pump()});Pt(this,"replaceRestored",t=>{this.generation+=1,this.abortAll(),this.requestedPreviews.clear(),this.items.forEach(n=>this.revoke(n.previewUrl)),this.publish(t.map(NE))});Pt(this,"mergeRestored",t=>{const n=new Set(this.items.flatMap(o=>{var s;return(s=o.meta)!=null&&s.path?[o.meta.path]:[]})),r=t.filter(o=>!n.has(o.path)).map(NE);r.length>0&&this.publish([...r,...this.items])});this.options=this.normalized(t)}normalized(t){return{scope:t.scope,bucket:t.bucket,concurrency:t.concurrency??yCe,transport:t.transport??xCe,fetchPreview:t.fetchPreview??wCe}}bind(t){const n=this.normalized(t),r=n.scope!==this.options.scope||n.bucket!==this.options.bucket;this.options=n,r&&this.reset()}publish(t){this.items=t,this.listeners.forEach(n=>n())}revoke(t){!t||this.revoked.has(t)||(this.revoked.add(t),URL.revokeObjectURL(t))}abortAll(){const t=[...this.controllers.values()];this.controllers.clear(),t.forEach(n=>n.abort())}cancelDisposal(){this.disposalVersion+=1}scheduleDisposal(){const t=++this.disposalVersion;queueMicrotask(()=>{this.disposalVersion===t&&this.reset()})}pump(){const t=Math.max(0,this.options.concurrency-this.controllers.size);this.items.filter(n=>n.status==="queued").slice(0,t).forEach(n=>this.launch(n))}launch(t){if(!t.file||this.controllers.has(t.id))return;const n=new AbortController,r=this.generation;this.controllers.set(t.id,n),this.publish(this.items.map(o=>o.id===t.id?{...o,status:"uploading",progress:0,errorMsg:void 0}:o)),this.options.transport(t.file,this.options.bucket,o=>{this.progress(t.id,r,o)},n.signal).then(o=>{this.finish(t.id,r,o)}).catch(o=>this.finish(t.id,r,void 0,o))}progress(t,n,r){this.generation!==n||!this.controllers.has(t)||this.publish(this.items.map(o=>o.id===t?{...o,progress:r}:o))}finish(t,n,r,o){this.generation!==n||!this.controllers.has(t)||(this.controllers.delete(t),this.publish(this.items.map(s=>s.id!==t?s:r?{...s,status:"done",progress:100,meta:r,errorMsg:void 0}:{...s,status:"error",errorMsg:SCe(o)})),this.pump())}loadPreviews(t){t.filter(kCe).forEach(n=>this.startPreview(n))}startPreview(t){if(this.requestedPreviews.has(t.id))return;this.requestedPreviews.add(t.id);const n=this.generation;this.options.fetchPreview(t.meta.path).then(r=>{this.requestedPreviews.delete(t.id);const o=this.items.some(s=>s.id===t.id&&!s.previewUrl);if(this.generation!==n||!o){this.revoke(r);return}this.publish(this.items.map(s=>s.id===t.id?{...s,previewUrl:r}:s))}).catch(()=>this.requestedPreviews.delete(t.id))}}function JH(e){const t=f.useRef();t.current||(t.current=new jCe(e));const n=t.current,r=f.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return f.useLayoutEffect(()=>n.bind(e),[e.bucket,e.concurrency,e.fetchPreview,e.scope,e.transport,n]),f.useEffect(()=>{n.loadPreviews(r)},[r,n]),f.useEffect(()=>(n.cancelDisposal(),()=>n.scheduleDisposal()),[n]),{items:r,completed:Rk(r),hasNonDone:r.some(o=>o.status!=="done"),addFiles:n.addFiles,remove:n.remove,retry:n.retry,replaceRestored:n.replaceRestored,mergeRestored:n.mergeRestored,reset:n.reset}}const CCe="'IBM Plex Mono',monospace";function TCe({running:e,text:t}){return i.jsx("div",{"data-composer-status-line":"true",style:{display:"flex",alignItems:"center",gap:8,font:`500 11px ${CCe}`,color:e?"var(--proto-muted-2)":"var(--proto-faint)",padding:"8px 2px 10px"},children:i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:e?"var(--proto-accent)":"var(--proto-line-3)",animation:e?"cxpulse 1.6s ease-in-out infinite":void 0,transform:"translateY(0.5px)",flex:"none"}}),i.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t})]})})}const PCe="'IBM Plex Mono',monospace";function ECe({error:e}){const t=O();return i.jsxs("div",{"data-send-error":!0,role:"alert",style:{marginTop:7,padding:"0 2px",font:`500 10.5px ${PCe}`,color:"var(--proto-danger)"},children:[t.wbSendFailed," · ",t.wbDraftRestored,": ",e]})}const ap="'IBM Plex Mono',monospace";function RCe(e){const t=GH(e),n=YH(e);return{mime:t,name:LE(e),ext:n1(LE(e)),isImage:t.startsWith("image/"),isVideo:t.startsWith("video/"),kind:bc(n),canPreview:!!e.previewUrl&&e.status==="done",colors:X3(n)}}const MCe={position:"relative",width:54,height:54,flex:"none"},ICe={position:"absolute",left:4,bottom:3,font:`500 8px ${ap}`,color:"var(--proto-muted-2)",background:"var(--media-label-bg)",padding:"1px 4px",borderRadius:3},ACe={position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:19,height:19,borderRadius:"50%",background:"var(--media-control-bg-strong)",color:"var(--ink-solid-fg)",fontSize:7,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:1.5,boxSizing:"border-box"},Pw={position:"absolute",inset:0,background:"var(--media-label-bg-soft)",display:"flex",alignItems:"center",justifyContent:"center",font:`600 9px ${ap}`,color:"var(--proto-accent)"},DCe={...Pw,cursor:"pointer",font:`600 8px ${ap}`,color:"var(--proto-danger)"},LCe={position:"absolute",top:-5,right:-5,width:16,height:16,borderRadius:"50%",background:"var(--proto-ink)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",border:"1.5px solid var(--proto-card)",boxSizing:"border-box",cursor:"pointer"},FE={position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"};function OCe(e,t){return{position:"absolute",inset:0,borderRadius:8,border:e.status==="error"?"1px solid var(--proto-danger)":"1px solid var(--proto-line)",background:e.previewUrl?"var(--media-stage-bg)":"repeating-linear-gradient(45deg,var(--proto-line),var(--proto-line) 5px,var(--proto-line) 5px,var(--proto-line) 10px)",boxSizing:"border-box",overflow:"hidden",cursor:t?"pointer":"default"}}function eU({id:e,onRemove:t}){const n=r=>{r.stopPropagation(),t(e)};return i.jsx("span",{onClick:n,style:LCe,children:"×"})}function NCe({a:e,model:t}){return i.jsxs(i.Fragment,{children:[e.previewUrl&&t.isImage&&i.jsx("img",{src:e.previewUrl,alt:t.name,style:FE}),e.previewUrl&&t.isVideo&&i.jsx(gh,{src:e.previewUrl,style:FE}),i.jsx("span",{style:ICe,children:t.ext}),t.isVideo&&e.status!=="uploading"&&i.jsx("span",{style:ACe,children:"▶"})]})}function FCe({a:e,onRetry:t}){return e.status==="queued"?i.jsx("span",{style:Pw,children:"queued"}):e.status==="uploading"?i.jsxs(i.Fragment,{children:[i.jsxs("span",{style:Pw,children:[e.progress,"%"]}),i.jsx("span",{style:{position:"absolute",left:0,bottom:0,height:3,width:`${e.progress}%`,background:"var(--proto-accent)"}})]}):e.status!=="error"?null:i.jsx("span",{onClick:n=>{n.stopPropagation(),t(e.id)},style:DCe,children:"retry"})}function zCe({a:e,model:t,onRetry:n,onRemove:r,onOpen:o}){return i.jsxs("div",{style:MCe,children:[i.jsxs("div",{role:t.canPreview?"button":void 0,title:t.canPreview?t.name:void 0,onClick:o,style:OCe(e,t.canPreview),children:[i.jsx(NCe,{a:e,model:t}),i.jsx(FCe,{a:e,onRetry:n})]}),i.jsx(eU,{id:e.id,onRemove:r})]})}const BCe={position:"relative",display:"flex",alignItems:"center",gap:8,height:54,background:"var(--proto-rail)",borderRadius:8,padding:"0 12px 0 8px",flex:"none",boxSizing:"border-box"},$Ce={font:`500 10.5px ${ap}`,color:"var(--proto-ink)",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function _Ce(e,t){return{...BCe,border:e.status==="error"?"1px solid var(--proto-danger)":"1px solid var(--proto-line)",cursor:t?"pointer":"default"}}function WCe({model:e}){const t={width:26,height:32,borderRadius:5,background:e.colors.bg,color:e.colors.fg,display:"flex",alignItems:"center",justifyContent:"center",font:`700 8px ${ap}`,flex:"none"};return i.jsx("span",{style:t,children:e.ext})}function HCe(e){return e.status==="queued"?"Queued":e.status==="uploading"?`${e.progress}%`:e.status==="error"?e.errorMsg||"Failed":Q3(uCe(e))}function UCe({a:e,model:t,onRetry:n,onRemove:r,onOpen:o}){const s=e.status==="uploading"?"var(--proto-accent)":e.status==="error"?"var(--proto-danger)":"var(--proto-muted-3)";return i.jsxs("div",{role:o?"button":void 0,title:o?t.name:void 0,onClick:o,style:_Ce(e,!!o),children:[i.jsx(WCe,{model:t}),i.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2},children:[i.jsx("span",{style:$Ce,children:t.name}),i.jsx("span",{role:e.status==="error"?"button":void 0,onClick:e.status==="error"?a=>{a.stopPropagation(),n(e.id)}:void 0,style:{font:`400 9px ${ap}`,color:s,cursor:e.status==="error"?"pointer":void 0},children:HCe(e)})]}),i.jsx(eU,{id:e.id,onRemove:r})]})}function VCe({attachment:e,onRetry:t,onRemove:n}){var c;const{openMedia:r}=mh(),{openDoc:o}=Ac(),s=RCe(e);if(s.isImage||s.isVideo){const d=s.canPreview&&s.kind?()=>r({kind:s.kind,name:s.name,url:e.previewUrl}):void 0;return i.jsx(zCe,{a:e,model:s,onRetry:t,onRemove:n,onOpen:d})}const a=xS(s.name,s.mime),l=a&&e.status==="done"&&((c=e.meta)!=null&&c.path)?()=>o({kind:a,name:s.name,path:e.meta.path,mimeType:s.mime}):void 0;return i.jsx(UCe,{a:e,model:s,onRetry:t,onRemove:n,onOpen:l})}function tU(e){return e.running&&!e.backgroundRunning&&e.device!==null&&!e.turnProgressStarted}function nU(e,t){return t.replace("{device}",e)}const qCe="'IBM Plex Mono',monospace",KCe="40vh",GCe={en:{label:"Task list",empty:"No active task"},zh:{label:"任务清单",empty:"暂无进行中的任务"}};function zE(e){return`cortex.todoRailOpen.${e}`}function YCe(e){const[t,n]=f.useState(!1);f.useEffect(()=>{try{n(window.localStorage.getItem(zE(e))==="1")}catch{n(!1)}},[e]);const r=f.useCallback(()=>{n(o=>{const s=!o;try{window.localStorage.setItem(zE(e),s?"1":"0")}catch{}return s})},[e]);return[t,r]}function rU({status:e,allDone:t}){const n={width:14,height:14,borderRadius:"50%",flex:"none",boxSizing:"border-box"};return e==="completed"?i.jsx("span",{style:{...n,background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700},children:"✓"}):e==="in_progress"?i.jsx("span",{style:{...n,background:t?"var(--proto-success)":"var(--proto-accent)",boxShadow:`0 0 0 3px ${t?"var(--proto-success-bg)":"var(--proto-accent-bg)"}`,animation:"cxpulse 1.6s ease-in-out infinite"}}):i.jsx("span",{style:{...n,border:"1.5px solid var(--proto-line-3)"}})}function QCe({row:e}){const t=e.status==="completed",n=e.status==="in_progress";return i.jsxs("div",{style:{display:"flex",gap:9,alignItems:"stretch"},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[i.jsx(rU,{status:e.status,allDone:!1}),e.hasTail&&i.jsx("span",{style:{flex:1,width:1.5,background:"var(--proto-line-2)",margin:"3px 0"}})]}),i.jsx("span",{style:{fontSize:12.5,lineHeight:"15px",paddingBottom:e.hasTail?9:0,fontWeight:n?600:400,color:t?"var(--proto-muted-2)":n?"var(--proto-ink)":"var(--proto-muted)",textDecoration:t?"line-through":void 0},children:e.text})]})}function oU({sessionId:e,todos:t,lang:n}){const[r,o]=YCe(e),s=rye(t);if(!s)return null;const a=GCe[n],l=s.allDone?"var(--proto-success)":"var(--proto-accent)",c=d=>{d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),o())};return i.jsxs("div",{"data-todo-rail":r?"expanded":"collapsed",onClick:r?o:void 0,onKeyDown:r?c:void 0,role:r?"button":void 0,tabIndex:r?0:void 0,"aria-expanded":r?!0:void 0,"aria-label":r?a.label:void 0,style:{border:"1px solid var(--proto-line)",borderRadius:8,background:"var(--proto-alt)",marginBottom:8,overflow:"hidden",cursor:r?"pointer":void 0,animation:"cxmsg .34s cubic-bezier(.22,1,.36,1) both"},children:[!r&&i.jsxs("button",{type:"button",onClick:o,"aria-expanded":!1,"aria-label":a.label,style:{display:"flex",alignItems:"center",gap:8,width:"100%",minHeight:29,padding:"0 10px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",font:"inherit",color:"inherit"},children:[i.jsx(rU,{status:s.allDone?"completed":"in_progress",allDone:s.allDone}),i.jsx("span",{style:{font:`600 10.5px ${qCe}`,color:l,flex:"none"},children:s.counts}),i.jsx("span",{style:{fontSize:12,color:s.activeLabel?"var(--proto-muted-2)":"var(--proto-faint)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:s.activeLabel??a.empty}),i.jsx("span",{style:{marginLeft:"auto",flex:"none",fontSize:9,color:"var(--proto-muted-2)"},children:"▸"})]}),r&&i.jsx("div",{style:{maxHeight:KCe,overflowY:"auto",padding:"12px 12px 11px"},children:s.rows.map(d=>i.jsx(QCe,{row:d},d.key))})]})}const Qv="server";function iU(e){const t=O(),[n,r]=f.useState([]);return f.useEffect(()=>{if(!e)return;let o=!0;return KS().then(s=>{o&&r(s)}).catch(()=>{o&&r([])}),()=>{o=!1}},[e]),[{device:null,label:t.wbBrowserOffOption,sub:""},{device:Qv,label:Qv,sub:t.wbBrowserThisHost},...n.map(o=>({device:o.device,label:o.device,sub:o.platform}))]}function sU(){var n,r;const e=he();return((r=(n=ae(e.config.get.queryOptions({})).data)==null?void 0:n.settings)==null?void 0:r.some(o=>o.key==="commissionEnabled"&&o.value===!0))??!1}function Xv(e){return e===null?null:e==="new"?{mode:"new"}:{mode:"join",commissionId:e}}function Mk(e){const t=he(),n=O(),r=ae({...t.commissions.list.queryOptions({status:"active"}),enabled:e});return[{value:null,label:n.wbCommissionOffOption,sub:""},{value:"new",label:n.wbCommissionNewOption,sub:n.wbCommissionNewSub},...(r.data??[]).map(o=>({value:o.id,label:o.title,sub:n.wbCommissionJoinSub}))]}function aU(e){var o;const t=he(),n=(e==null?void 0:e.commissionId)??null,r=ae({...t.commissions.get.queryOptions({commissionId:n??""}),enabled:!!n});return n?{value:n,label:((o=r.data)==null?void 0:o.title)??null}:e!=null&&e.commissionDraft?{value:"new",label:null}:null}const To="'IBM Plex Mono',monospace";function XCe({suggestions:e,onPick:t}){const n=O(),[r,o]=f.useState(null);return e.length===0?null:i.jsxs("div",{"data-menu":"slash",style:{position:"absolute",left:32,right:32,bottom:"100%",marginBottom:-2,border:"1px solid var(--proto-line)",borderRadius:12,boxShadow:"var(--shadow-menu-soft)",background:"var(--proto-card)",overflow:"hidden",zIndex:10},children:[e.map((s,a)=>i.jsxs("div",{"data-slash-command":s.command,onMouseEnter:()=>o(a),onMouseLeave:()=>o(l=>l===a?null:l),onClick:()=>{s.disabled||t(s)},style:{display:"flex",alignItems:"center",padding:"8px 14px",opacity:s.disabled?.45:1,background:r===a||a===0?"var(--proto-accent-bg)":"var(--proto-card)",cursor:s.disabled?"default":"pointer"},children:[i.jsx("span",{style:{font:`600 12px ${To}`,color:a===0?"var(--proto-accent)":"var(--proto-muted)"},children:s.command}),i.jsx("span",{style:{fontSize:11.5,color:"var(--proto-muted-2)",marginLeft:12},children:s.description})]},s.command)),i.jsx("div",{style:{display:"flex",alignItems:"center",padding:"7px 14px",borderTop:"1px solid var(--proto-alt)",background:"var(--proto-rail)"},children:i.jsxs("span",{style:{font:`400 10px ${To}`,color:"var(--proto-faint)"},children:["↑↓ ",n.wbNavigate," · ⏎ ",n.wbRun," · ",n.wbEscDismiss]})})]})}function Ik(e,t){f.useEffect(()=>{if(!e||typeof window>"u")return;const n=r=>{r.key==="Escape"&&t()};return window.addEventListener("keydown",n),window.addEventListener("click",t),()=>{window.removeEventListener("keydown",n),window.removeEventListener("click",t)}},[e,t])}const la={display:"flex",alignItems:"center",gap:9,minHeight:32,padding:"0 13px",cursor:"pointer",fontSize:12,color:"var(--proto-ink)"};function Cd({kind:e,size:t=14,color:n="var(--proto-muted-2)"}){const r={width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:n,style:{flex:"none"}};return e==="attach"?i.jsx("svg",{...r,strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M14.29 7.37l-6.13 6.13a4 4 0 0 1-5.66-5.66l5.71-5.71A2.67 2.67 0 1 1 12 5.89l-5.73 5.71a1.33 1.33 0 0 1-1.89-1.89l5.66-5.65"})}):e==="browser"?i.jsxs("svg",{...r,strokeWidth:1.4,children:[i.jsx("circle",{cx:"8",cy:"8",r:"6.3"}),i.jsx("path",{d:"M1.7 8h12.6M8 1.7c-1.8 1.8-2.7 4-2.7 6.3s.9 4.5 2.7 6.3c1.8-1.8 2.7-4 2.7-6.3S9.8 3.5 8 1.7z"})]}):e==="commission"?i.jsxs("svg",{...r,strokeWidth:1.4,strokeLinejoin:"round",strokeLinecap:"round",children:[i.jsx("path",{d:"M4.2 2.2v11.6"}),i.jsx("path",{d:"M4.2 3.1h7.8L10.4 5.7l1.6 2.6H4.2z"})]}):i.jsx("svg",{...r,strokeWidth:1.6,strokeLinecap:"round",children:i.jsx("path",{d:"M10.3 2.6 5.7 13.4"})})}function lU({options:e,current:t,onPick:n}){return i.jsx(i.Fragment,{children:e.map(r=>i.jsxs("span",{"data-device":r.device??"__off__",onClick:o=>{o.stopPropagation(),n(r.device)},style:{...la,gap:5,background:r.device===t?"var(--proto-accent-bg)":"transparent"},children:[i.jsx("span",{style:{font:`600 10.5px ${To}`,color:"var(--proto-ink)"},children:r.label}),i.jsx("span",{style:{font:`400 9px ${To}`,color:"var(--proto-muted-3)"},children:r.sub}),r.device===t&&i.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-accent)",fontSize:9,fontWeight:700},children:"✓"})]},r.device??"__off__"))})}function cU({options:e,current:t,onPick:n}){return i.jsx(i.Fragment,{children:e.map(r=>i.jsxs("span",{"data-commission-option":r.value??"__off__",onClick:o=>{o.stopPropagation(),n(r.value)},style:{...la,gap:5,background:r.value===t?"var(--proto-accent-bg)":"transparent"},children:[i.jsx("span",{style:{font:`600 10.5px ${To}`,color:"var(--proto-ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:150},children:r.label}),i.jsx("span",{style:{font:`400 9px ${To}`,color:"var(--proto-muted-3)"},children:r.sub}),r.value===t&&i.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-accent)",fontSize:9,fontWeight:700},children:"✓"})]},r.value??"__off__"))})}function ZCe({browser:e}){const t=O(),[n,r]=f.useState(!1),[o,s]=f.useState(!1),a=f.useCallback(()=>r(!1),[]);Ik(n,a);const l=iU(n),c=e.device,d=!!e.onChange;if(c===null)return null;const u=n||o;return i.jsxs("span",{style:{position:"relative",flex:"none",display:"inline-flex"},children:[i.jsxs("button",{type:"button","data-chip":"browser","data-browser-device":c,"data-editable":d?"true":"false","aria-label":`${t.wbBrowser} · ${c}`,"aria-expanded":d?n:void 0,onClick:d?p=>{p.stopPropagation(),r(h=>!h)}:void 0,onMouseEnter:()=>{d&&s(!0)},onMouseLeave:()=>s(!1),style:{display:"inline-flex",alignItems:"center",gap:5,flex:"none",height:30,maxWidth:160,padding:"0 10px",boxSizing:"border-box",borderRadius:999,border:`1.5px solid ${u?"var(--proto-accent)":"var(--proto-accent-border)"}`,background:"var(--proto-accent-bg)",color:"var(--proto-accent)",font:`500 10.5px ${To}`,cursor:d?"pointer":"default"},children:[i.jsx(Cd,{kind:"browser",size:12,color:"currentColor"}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c}),d&&i.jsx("span",{style:{fontSize:7.5,opacity:.75},children:"▾"})]}),n&&d&&i.jsx("span",{"data-menu":"browser",style:{position:"absolute",left:0,bottom:36,minWidth:170,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"var(--shadow-menu)",zIndex:59,overflow:"hidden",display:"block"},children:i.jsx(lU,{options:l,current:c,onPick:p=>{a(),e.onChange(p)}})})]})}function JCe({commission:e}){const t=O(),[n,r]=f.useState(!1),[o,s]=f.useState(!1),a=f.useCallback(()=>r(!1),[]);Ik(n,a);const l=Mk(n),c=e.value,d=!!e.onChange;if(c===null)return null;const u=n||o,p=e.label||(c==="new"?t.wbCommissionNewOption:t.wbCommissionUnnamed);return i.jsxs("span",{style:{position:"relative",flex:"none",display:"inline-flex"},children:[i.jsxs("button",{type:"button","data-chip":"commission","data-commission-value":c,"data-editable":d?"true":"false","aria-label":`${t.wbCommissionMode} · ${p}`,"aria-expanded":d?n:void 0,onClick:d?h=>{h.stopPropagation(),r(m=>!m)}:void 0,onMouseEnter:()=>{d&&s(!0)},onMouseLeave:()=>s(!1),style:{display:"inline-flex",alignItems:"center",gap:5,flex:"none",height:30,maxWidth:180,padding:"0 10px",boxSizing:"border-box",borderRadius:999,border:`1.5px solid ${u?"var(--proto-accent)":"var(--proto-accent-border)"}`,background:"var(--proto-accent-bg)",color:"var(--proto-accent)",font:`500 10.5px ${To}`,cursor:d?"pointer":"default"},children:[i.jsx(Cd,{kind:"commission",size:12,color:"currentColor"}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),d&&i.jsx("span",{style:{fontSize:7.5,opacity:.75},children:"▾"})]}),n&&d&&i.jsx("span",{"data-menu":"commission",style:{position:"absolute",left:0,bottom:36,minWidth:190,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"var(--shadow-menu)",zIndex:59,overflow:"hidden",display:"block"},children:i.jsx(cU,{options:l,current:c,onPick:h=>{a(),e.onChange(h)}})})]})}function e9e({browser:e,commission:t,onAttach:n,onCommands:r}){const o=O(),[s,a]=f.useState(!1),[l,c]=f.useState("root"),[d,u]=f.useState(!1),p=f.useCallback(()=>{a(!1),c("root")},[]);Ik(s,p);const h=!!(e!=null&&e.onChange),m=!!(t!=null&&t.onChange),x=iU(s&&l==="browser"),v=Mk(s&&l==="commission"),S=s||d,b=(t==null?void 0:t.label)||((t==null?void 0:t.value)==="new"?o.wbCommissionNewOption:null)||(t!=null&&t.value?o.wbCommissionUnnamed:o.wbCommissionOffOption);return i.jsxs("span",{style:{position:"relative",flex:"none",display:"inline-flex"},children:[i.jsx("button",{type:"button","data-chip":"plus","aria-label":o.wbPlusMenu,"aria-expanded":s,onClick:g=>{g.stopPropagation(),s?p():a(!0)},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{width:30,height:30,borderRadius:"50%",boxSizing:"border-box",padding:0,flex:"none",border:`1.5px solid ${S?"var(--proto-accent-border)":"var(--proto-line-3)"}`,color:S?"var(--proto-accent)":"var(--proto-muted-2)",background:"var(--proto-card)",display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:0,cursor:"pointer"},children:i.jsx(gc,{})}),s&&i.jsx("span",{"data-menu":"plus",style:{position:"absolute",left:0,bottom:36,minWidth:190,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"var(--shadow-menu)",zIndex:59,overflow:"hidden",display:"block"},children:l==="root"?i.jsxs(i.Fragment,{children:[i.jsxs("span",{"data-plus-item":"attach",onClick:g=>{g.stopPropagation(),p(),n()},style:la,children:[i.jsx(Cd,{kind:"attach"}),o.wbAttach,i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${To}`,color:"var(--proto-muted-3)"},children:o.wbAttachHint})]}),e&&i.jsxs("span",{"data-plus-item":"browser","data-editable":h?"true":"false",onClick:h?g=>{g.stopPropagation(),c("browser")}:void 0,style:{...la,cursor:h?"pointer":"default",opacity:h?1:.6},children:[i.jsx(Cd,{kind:"browser"}),o.wbBrowser,i.jsxs("span",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:5,font:`500 10px ${To}`,color:e.device?"var(--proto-accent)":"var(--proto-muted-3)"},children:[e.device??o.wbBrowserOffOption,h&&i.jsx("span",{style:{fontSize:8,color:"var(--proto-muted)"},children:"▸"})]})]}),t&&i.jsxs("span",{"data-plus-item":"commission","data-editable":m?"true":"false",onClick:m?g=>{g.stopPropagation(),c("commission")}:void 0,style:{...la,cursor:m?"pointer":"default",opacity:m?1:.6},children:[i.jsx(Cd,{kind:"commission"}),o.wbCommissionMode,i.jsxs("span",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:5,font:`500 10px ${To}`,color:t.value?"var(--proto-accent)":"var(--proto-muted-3)",overflow:"hidden"},children:[i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:110},children:b}),m?i.jsx("span",{style:{fontSize:8,color:"var(--proto-muted)"},children:"▸"}):i.jsx("span",{style:{font:`400 9px ${To}`,color:"var(--proto-muted-3)"},children:o.wbCommissionModeHint})]})]}),i.jsxs("span",{"data-plus-item":"commands",onClick:g=>{g.stopPropagation(),p(),r()},style:la,children:[i.jsx(Cd,{kind:"commands"}),o.commands]})]}):l==="browser"?i.jsxs(i.Fragment,{children:[i.jsxs("span",{"data-plus-back":!0,onClick:g=>{g.stopPropagation(),c("root")},style:{...la,minHeight:28,borderBottom:"1px solid var(--proto-line-2)",color:"var(--proto-muted)",fontSize:11},children:["‹ ",o.wbBrowser]}),i.jsx(lU,{options:x,current:e.device,onPick:g=>{p(),e.onChange(g)}})]}):i.jsxs(i.Fragment,{children:[i.jsxs("span",{"data-plus-back":!0,onClick:g=>{g.stopPropagation(),c("root")},style:{...la,minHeight:28,borderBottom:"1px solid var(--proto-line-2)",color:"var(--proto-muted)",fontSize:11},children:["‹ ",o.wbCommissionMode]}),i.jsx(cU,{options:v,current:t.value,onPick:g=>{p(),t.onChange(g)}})]})})]})}function t9e({browser:e,commission:t,onAttach:n,onCommands:r,profileControl:o,contextControl:s,sendControl:a}){return i.jsxs("div",{"data-composer-actions":!0,style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[i.jsx(e9e,{browser:e,commission:t,onAttach:n,onCommands:r}),e&&i.jsx(ZCe,{browser:e}),t&&i.jsx(JCe,{commission:t}),i.jsx("span",{style:{marginLeft:"auto"}}),o,s,a]})}function dU(e){return e.backend==null||e.backend==="claude"||e.backend==="pi"}function Zv(e){return e.backend??"claude"}function n9e(e){return[e.model,e.thinking,Zv(e)].filter(Boolean).join(" · ")}function uU(e,t){const n=e.find(r=>r.name===t&&dU(r));return n?Zv(n):null}function pU(e,t,n){return e.filter(dU).map(r=>({name:r.name,sub:n9e(r),active:r.name===t,backend:Zv(r),disabled:n.hasHistory&&n.currentBackend!==null&&Zv(r)!==n.currentBackend}))}const BE="'IBM Plex Mono',monospace";function r9e({options:e,onPick:t,placement:n="below",align:r="left"}){const o=O(),[s,a]=f.useState(null);return i.jsx("div",{"data-menu":"profile",style:{position:"absolute",...r==="right"?{right:0}:{left:0},...n==="above"?{bottom:36}:{top:36},background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:8,boxShadow:"var(--shadow-menu)",zIndex:59,overflow:"hidden",minWidth:160},children:e.map(l=>i.jsxs("div",{onMouseEnter:()=>a(l.name),onMouseLeave:()=>a(c=>c===l.name?null:c),onClick:c=>{c.stopPropagation(),l.disabled||t(l.name)},"data-profile":l.name,"data-disabled":l.disabled?"true":void 0,title:l.disabled?`${o.wbSwitchTo} ${l.backend} ${o.wbNeedsNewSession}`:void 0,style:{display:"flex",alignItems:"center",gap:4,padding:"5px 8px",cursor:l.disabled?"not-allowed":"pointer",opacity:l.disabled?.42:1,background:l.disabled?"transparent":s===l.name?"var(--proto-gray)":l.active?"var(--proto-accent-bg)":"transparent"},children:[i.jsx("span",{style:{font:`600 10px ${BE}`,color:"var(--proto-ink)"},children:l.name}),i.jsx("span",{style:{font:`400 9px ${BE}`,color:"var(--proto-muted-3)"},children:l.sub}),l.active&&i.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-accent)",fontSize:9,fontWeight:700},children:"✓"})]},l.name))})}const o9e="500 11.5px 'IBM Plex Mono',monospace";function i9e(e,t){f.useEffect(()=>{if(!e)return;const n=r=>{r.key==="Escape"&&t()};return window.addEventListener("keydown",n),window.addEventListener("click",t),()=>{window.removeEventListener("keydown",n),window.removeEventListener("click",t)}},[e,t])}function s9e(e,t,n,r,o){return(e?t:n)??r??o??"—"}function a9e(e){var v,S,b,g,w;const t=he(),n=Ve(),r=ae(t.config.get.queryOptions({})),o=((S=(v=r.data)==null?void 0:v.profiles)==null?void 0:S.profiles)??[],s=((g=(b=r.data)==null?void 0:b.profiles)==null?void 0:g.defaultProfile)??null,{draftProfile:a,setDraftProfile:l,pendingCreatedSession:c}=Vi(),d=P$(e.currentProfile,c,e.sessionId),u=s9e(e.isDraft,a,d,s,(w=o[0])==null?void 0:w.name),p=f.useMemo(()=>uU(o,u),[o,u]),h=f.useMemo(()=>pU(o,u,{currentBackend:p,hasHistory:e.isDraft?!1:e.hasHistory}),[o,u,p,e.hasHistory,e.isDraft]),m=Re(t.sessions.setProfile.mutationOptions({onSuccess:()=>n.invalidateQueries(t.sessions.list.queryFilter())}));return{effectiveProfile:u,options:h,pick:k=>{const C=h.find(T=>T.name===k);k===u||!C||C.disabled||(e.isDraft?l(k):e.sessionId&&m.mutate({sessionId:e.sessionId,profileName:k}))}}}function l9e({selection:e}){const t=O(),[n,r]=f.useState(!1),[o,s]=f.useState(!1),a=()=>s(!1);return i9e(o,a),i.jsxs("span",{"data-chip":"profile",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onClick:l=>{l.stopPropagation(),s(c=>!c)},style:{position:"relative",font:o9e,border:`1.5px solid ${n?"var(--proto-accent-border)":"var(--proto-line-3)"}`,color:n?"var(--proto-accent)":"var(--proto-muted)",padding:"0 12px",height:30,borderRadius:999,boxSizing:"border-box",cursor:"pointer",display:"inline-flex",alignItems:"center",flex:"none"},children:[t.wbProfile," · ",e.effectiveProfile,o?i.jsx(r9e,{options:e.options,placement:"above",align:"right",onPick:l=>{a(),e.pick(l)}}):null]})}function c9e(e){return[e.name,e.size,e.mimeType,e.type].join("\0")}function D1(e,t){return JSON.stringify([e,(t??[]).map(c9e)])}function Ak(e){return`${e.ts}\0${e.fingerprint}`}function d9e(e,t,n){const r=Ak(n),o=t.get(r);if(o!==void 0){n.allowClockSkew&&(e[o]={...e[o],allowClockSkew:!0});return}t.set(r,e.length),e.push(n)}function Dk(e,t){const n=[],r=new Map,o=(s,a,l,c)=>{d9e(n,r,{fingerprint:D1(s,a),ts:l,allowClockSkew:c})};if(e.transcript.sessionId===t)for(const s of e.transcript.turns)for(const a of s.messages)a.type==="user"&&o(a.text??"",a.attachments,a.ts,!1);for(const s of e.liveTail)s.sessionId===t&&s.role==="user"&&o(s.text,s.attachments,s.ts,!0);return n}function fU(e,t){const n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(r)?n>=r:e>=t}const u9e=5*60*1e3;function p9e(e,t){const n=Date.parse(e),r=Date.parse(t);return!Number.isFinite(n)||!Number.isFinite(r)?e>=t:n>=r-u9e}function hU(e,t,n){if(e.transcript.sessionId!==t)return[];const r=[...n];return e.pendingUser.filter(o=>{const s=D1(o.text,o.attachments),a=r.findIndex(l=>l.fingerprint===s&&fU(l.ts,o.ts));return a===-1?!0:(r.splice(a,1),!1)})}function mU(e,t){const n=Dk(e,t),r=hU(e,t,n).map(o=>({fingerprint:D1(o.text,o.attachments),ts:o.ts,allowClockSkew:!0}));return[...n,...r]}function f9e(e,t,n){return mU(e,t).filter(r=>r.fingerprint===n)}function h9e(e,t){return e.kind!==t.kind?!1:e.kind==="session"?e.sessionId===t.sessionId:e.projectId===t.projectId}function m9e(e,t,n){const r=D1(e.text,e.attachments),o=e.target.kind==="session"?f9e(n,e.target.sessionId,r):[],s=t.filter(l=>h9e(l.target,e.target)&&l.fingerprint===r),a=Math.max(o.length,...s.map(l=>l.authorityOrdinal),0)+1;return{...e,fingerprint:r,authorityBaselineKeys:o.map(Ak),authorityOrdinal:a,phase:"sending"}}function g9e(e,t){return e==null?void 0:e.map(n=>({...n,path:`attachments/${t}/${n.path.split("/").pop()||n.name}`}))}function gU(e,t){return t?{...e,ts:t}:e}function v9e(e,t,n,r){return e.map(o=>o.clientId===t?gU({...o,target:{kind:"session",sessionId:n},phase:"accepted",attachments:g9e(o.attachments,n)},r):o)}function x9e(e,t,n){return n&&e.target.kind==="draft"&&e.target.projectId===t}function vU(e,t,n){return e.map(r=>r.clientId===t?gU({...r,phase:"accepted"},n):r)}function y9e(e,t){return e.filter(n=>n.clientId!==t)}function b9e(e,t,n){return e.find(o=>o.clientId===t)?Ew(e,n,!1).includes(t)?{messages:vU(e,t),restore:!1}:{messages:y9e(e,t),restore:!0}:{messages:e,restore:!1}}function w9e(e){const t=new Map;for(const n of e){const r=t.get(n.fingerprint)??[];r.push(n),t.set(n.fingerprint,r)}return t}function S9e(e,t,n){const r=e.get(t);if(r)return r;const o=w9e(n(t));return e.set(t,o),o}function k9e(e,t,n){const r=new Set(e.authorityBaselineKeys);return t.findIndex((o,s)=>n.has(s)||r.has(Ak(o))?!1:o.allowClockSkew?p9e(o.ts,e.ts):fU(o.ts,e.ts))}function Ew(e,t,n){const r=new Map,o=new Map,s=[];for(const a of e){if(a.target.kind==="draft")continue;const l=a.target.sessionId,d=S9e(r,l,m=>n?Dk(t,m):mU(t,m)).get(a.fingerprint)??[],u=`${l}\0${a.fingerprint}`,p=o.get(u)??new Set,h=k9e(a,d,p);h!==-1&&(p.add(h),o.set(u,p),s.push(a.clientId))}return s}function j9e(e,t){const n=t.transcript.sessionId,r=Dk(t,n),o=hU(t,n,r),s=Ew(e,t,!1),a=Ew(e,t,!0),l=new Set(s),c=e.filter(d=>!l.has(d.clientId)).map(d=>({id:d.clientId,text:d.text,ts:d.ts,attachments:d.attachments}));return{pendingUser:[...o,...c],matchedClientIds:s,settledClientIds:a}}function C9e(e){return e instanceof Error?e:new Error(String(e))}async function xU(e){e.onEnqueue(e.message);try{const t=await e.mutate();return e.onAccepted(e.message,t),{ok:!0,data:t}}catch(t){const n=C9e(t);return{ok:!1,error:n,restore:e.onRejected(e.message,n)}}}function yU(e){return e.running&&e.backgroundRunning?{phase:"background",active:!0,showMetrics:!0,showCost:!1}:e.running?{phase:"foreground",active:!0,showMetrics:!0,showCost:!1}:e.hasRun?{phase:"idle",active:!1,showMetrics:!0,showCost:!0}:{phase:"fresh",active:!1,showMetrics:!1,showCost:!1}}const T9e="500 11.5px 'IBM Plex Mono',monospace",P9e="'IBM Plex Mono',monospace";function E9e(e,t){const n=new Map(e.map(s=>[s.id,s])),r=t.flatMap(s=>n.get(s)??[]),o=new Set(r.map(s=>s.id));return[...r,...e.filter(s=>!o.has(s.id))]}function R9e({projects:e,current:t,onPick:n}){const[r,o]=f.useState(null);return i.jsx("div",{"data-menu":"project",style:{position:"absolute",left:0,bottom:36,minWidth:200,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:8,boxShadow:"var(--shadow-menu)",zIndex:59,overflow:"hidden"},children:e.map(s=>i.jsxs("div",{"data-project":s.id,onMouseEnter:()=>o(s.id),onMouseLeave:()=>o(a=>a===s.id?null:a),onClick:a=>{a.stopPropagation(),n(s.id)},style:{display:"flex",alignItems:"center",padding:"5px 8px",cursor:"pointer",background:r===s.id?"var(--proto-gray)":s.id===t?"var(--proto-accent-bg)":"transparent"},children:[i.jsx("span",{style:{font:`600 10px ${P9e}`,color:"var(--proto-ink)"},children:s.id}),s.id===t&&i.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-accent)",fontSize:9,fontWeight:700},children:"✓"})]},s.id))})}function M9e({disabled:e=!1}){const t=O(),{currentProjectId:n,projects:r,projectOrder:o,setCurrentProject:s}=zt(),[a,l]=f.useState(!1),[c,d]=f.useState(!1);if(f.useEffect(()=>{if(!c)return;const p=()=>d(!1),h=m=>{m.key==="Escape"&&p()};return window.addEventListener("keydown",h),window.addEventListener("click",p),()=>{window.removeEventListener("keydown",h),window.removeEventListener("click",p)}},[c]),!n)return null;const u=E9e(r,o);return i.jsxs("span",{"data-chip":"project","aria-label":t.switchProject,"aria-disabled":e||void 0,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onClick:p=>{p.stopPropagation(),e||d(h=>!h)},style:{position:"relative",font:T9e,border:`1.5px solid ${a&&!e?"var(--proto-accent-border)":"var(--proto-line-3)"}`,color:a&&!e?"var(--proto-accent)":"var(--proto-muted)",padding:"0 12px",height:30,borderRadius:999,boxSizing:"border-box",cursor:e?"default":"pointer",display:"flex",alignItems:"center",opacity:e?.55:1,margin:"0 auto 10px",width:"fit-content"},children:[t.project," · ",n,c&&i.jsx(R9e,{projects:u,current:n,onPick:p=>{d(!1),s(p)}})]})}function I9e(e){var t;return Array.from(((t=e.dataTransfer)==null?void 0:t.types)??[]).includes("Files")}function $E(e){var t,n;return((t=e.dataTransfer)==null?void 0:t.items.length)||((n=e.dataTransfer)==null?void 0:n.files.length)||0}function Vm(e){return I9e(e)?(e.preventDefault(),e.stopPropagation(),!0):!1}function A9e(e,t,n){return{dragenter:r=>{Vm(r)&&(t.current+=1,n({active:!0,fileCount:$E(r)}))},dragleave:r=>{Vm(r)&&(t.current=Math.max(0,t.current-1),t.current===0&&n({active:!1,fileCount:0}))},dragover:r=>{if(!Vm(r))return;r.dataTransfer&&(r.dataTransfer.dropEffect="copy");const o=$E(r);o>0&&n({active:!0,fileCount:o})},drop:r=>{var o;Vm(r)&&(t.current=0,n({active:!1,fileCount:0}),(o=r.dataTransfer)!=null&&o.files.length&&e.current(r.dataTransfer.files))}}}function D9e(e,t){const n=Object.keys(t);for(const r of n)e.addEventListener(r,t[r]);return()=>{for(const r of n)e.removeEventListener(r,t[r])}}function L9e(e,t){const n=f.useRef(t),r=f.useRef(0),[o,s]=f.useState({active:!1,fileCount:0});return n.current=t,f.useEffect(()=>{const a=e.current;if(a)return D9e(a,A9e(n,r,s))},[e]),o}const qm="'IBM Plex Mono',monospace",_E="—",WE=305;function O9e({sessionId:e,running:t,backgroundRunning:n=!1,turns:r,cost:o,elapsed:s,isDraft:a=!1,sessionBrowser:l=null,sessionCommission:c=null,currentProfile:d,hasHistory:u,draftProfile:p=null,draftReloadToken:h=0,projectId:m="general",prepareOptimistic:x,enqueueOptimistic:v,acceptOptimistic:S,rejectOptimistic:b,showStatus:g=!0,statusStarting:w=!1,turnProgressStarted:k=!1,contextControl:C,todos:T,compactAction:P,dropTargetRef:R,onOpenSettings:D=()=>{}}){var Tt;const I=he(),L=O(),W=ht(),ee=Ve(),{selectCreatedSession:V,setSelectedSession:X}=Vi(),K=a9e({sessionId:e,currentProfile:d,hasHistory:u,isDraft:a}),[se,B]=f.useState(null),[G,ne]=f.useState(null),le=sU(),_=Re(I.sessions.send.mutationOptions()),Y=Re(I.sessions.cancel.mutationOptions()),te=Re(I.sessions.createAndSend.mutationOptions()),[ie,ye]=f.useState(""),[Z,xe]=f.useState(null),[ke,Oe]=f.useState(null),Ie=f.useRef(null),Ae=f.useRef(null),tt=f.useRef(null),we=xh({isDraft:a,sessionId:e,projectId:m}),lt=`${we??""}:${a?h:0}`;f.useEffect(()=>{Oe(null)},[ie,lt]);const Qe=f.useRef(null),Zt=f.useRef(null);Zt.current!==lt&&(Zt.current=lt,Qe.current=a?((Tt=ic(we))==null?void 0:Tt.draftUploadId)??crypto.randomUUID():null);const wn=a?Qe.current??"":e,Qn=Ce=>{Ce&&(Ce.style.height="auto",Ce.style.height=Math.min(Ce.scrollHeight,WE)+"px")};f.useLayoutEffect(()=>{Qn(Ie.current)},[ie]);const[qt,ft]=f.useState(!1),[Vr,pr]=f.useState(!1),mt=JH({scope:lt,bucket:wn}),Bt=mt.items,Ct=f.useRef(ie),fr=f.useRef(Bt);Ct.current=ie,fr.current=Bt;const Sn=Bt.length>0;f.useLayoutEffect(()=>{Qn(Ie.current)},[Sn]);const gt=f.useRef(lt);gt.current=lt;const go=f.useRef(void 0);f.useEffect(()=>{if(go.current!==lt){if(go.current=lt,!we)return;const Ce=ic(we);a&&(Ce!=null&&Ce.draftUploadId)&&(Qe.current=Ce.draftUploadId),ye((Ce==null?void 0:Ce.text)??""),mt.replaceRestored((Ce==null?void 0:Ce.attachments)??[]);return}ws(we,{text:ie,attachments:Bt.filter(Ce=>Ce.status==="done"&&Ce.meta).map(Ce=>Ce.meta),...a&&Qe.current?{draftUploadId:Qe.current}:{}})},[we,lt,ie,Bt,a,mt.replaceRestored]);const In=mt.addFiles,qi=mt.remove,Er=mt.retry,Rr=R??tt,{active:zn,fileCount:qr}=L9e(Rr,In),Fo=Bt.length>0,vo=mt.completed,xo=mt.hasNonDone,hr=QH(ie,Bt)&&(!!e||a)&&!_.isPending&&!te.isPending,An=qt||zn?"var(--proto-accent)":"var(--proto-line-3)",pn=hr?"var(--proto-ink)":"var(--proto-line-3)",Ks=r==null?_E:`${r} ${L.wbTurnsUnit}`,Gs=o==null?_E:Ru(o),ui=!a&&r!=null,Xn=yU({running:t||w,backgroundRunning:n,hasRun:ui}),mr=Xn.phase==="background"?L.pillBackground:Xn.phase==="foreground"?L.pillRunning:L.wbIdle,Bn=[mr,s,Ks,...Xn.showCost?[Gs]:[]],Kr=Xn.showMetrics?Bn.join(" · "):mr,pi=(l==null?void 0:l.device)??se,$=tU({running:Xn.active,backgroundRunning:n,device:pi,turnProgressStarted:k}),q=K.options.map(Ce=>({name:Ce.name,detail:Ce.sub,disabled:Ce.disabled})),J={newDisabled:xo,cancelDisabled:!t||Y.isPending,compactDisabled:!P||P.disabled||P.pending,settingsDisabled:xo},Q=VH(ie,q,J),re=f.useCallback(Ce=>{var an;const rt=(an=Ce.clipboardData)==null?void 0:an.items;if(!rt)return;const Mt=[];for(let Mr=0;Mr<rt.length;Mr++){const Zn=rt[Mr];if(Zn.kind==="file"){const Ot=Zn.getAsFile();Ot&&Mt.push(Ot)}}Mt.length>0&&(Ce.preventDefault(),In(Mt))},[In]),ve=(Ce,rt,Mt,an)=>{const Mr=gt.current===Mt,Zn=Mr?{text:Ct.current,attachments:Rk(fr.current),...Qe.current?{draftUploadId:Qe.current}:{}}:ic(rt)??{text:"",attachments:[]},Ot=R$(Zn,Ce);ws(rt,Ot),Mr&&(Ot.draftUploadId&&(Qe.current=Ot.draftUploadId),ye(Ot.text),mt.mergeRestored(Ce.attachments),xe(an.message))},Ne=()=>{I$(we),ye(""),mt.reset(),ft(!1),Ie.current&&(Ie.current.style.height="auto")},be=Ce=>{const rt=Ce.trim(),Mt=vo;if(!rt&&Mt.length===0||!a&&!e)return;const an={text:rt,attachments:Mt,...a&&Qe.current?{draftUploadId:Qe.current}:{}},Mr=x(rt,Mt),Zn=we,Ot=lt;xe(null);const Ki=xU({message:Mr,mutate:()=>a?te.mutateAsync({projectId:m,profileName:p??void 0,text:rt,...se?{browser:{device:se}}:{},...le&&Xv(G)?{commission:Xv(G)}:{},draftUploadId:an.draftUploadId,...Mt.length>0?{attachments:Mt}:{}}):_.mutateAsync({sessionId:e,text:rt,...Mt.length>0?{attachments:Mt}:{}}),onEnqueue:v,onAccepted:(Jn,Ke)=>{if("sessionId"in Ke){const wt=S(Jn.clientId,{acceptedAt:Ke.acceptedAt,createdSessionId:Ke.sessionId});ee.invalidateQueries(I.sessions.list.queryFilter()),wt&&(Qe.current=null,V(Ke.sessionId))}else S(Jn.clientId,{acceptedAt:Ke.acceptedAt})},onRejected:(Jn,Ke)=>b(Jn.clientId,Ke)});Ne(),Ki.then(Jn=>{!Jn.ok&&Jn.restore&&ve(an,Zn,Ot,Jn.error)})},Se=()=>{!e||Y.isPending||Y.mutate({sessionId:e})},Pe={onNew:()=>X(nl),onCancel:()=>{t&&Se()},onCompact:()=>P==null?void 0:P.onCompact(),onProfile:K.pick,onSettings:D},Le=()=>{ws(we,{text:"",attachments:vo,...a&&Qe.current?{draftUploadId:Qe.current}:{}}),ye(""),ft(!1)},qe=Ce=>{Le(),qH(Ce,Pe)},Ze=Ce=>{const rt=UH(Ce,q,J);return rt.kind==="none"?!1:(rt.kind==="action"&&qe(rt.action),Oe(_H(rt)),!0)},Jt=Ce=>{Ce.disabled||(Ce.action?qe(Ce.action):(ye(`${Ce.command} `),ft(!0)))},nt=()=>{Ze(ie)||hr&&be(ie)},Ye=Ce=>{if(Ce.key==="Enter"&&!Ce.shiftKey)Ce.preventDefault(),nt();else if(Ce.key==="Escape"){if(qt){ft(!1);return}t&&(Ce.preventDefault(),Se())}};return i.jsx("div",{style:{flex:"none"},children:i.jsxs("div",{ref:tt,style:{maxWidth:756,margin:"0 auto",padding:"0 32px 18px",position:"relative"},children:[qt?i.jsx(XCe,{suggestions:Q,onPick:Jt}):null,!a&&i.jsx(oU,{sessionId:e,todos:T??null,lang:W}),a&&i.jsx(M9e,{disabled:te.isPending}),i.jsx("div",{style:{position:"relative",border:zn?"1.5px dashed var(--proto-accent)":"1.5px solid "+An,borderRadius:12,background:zn?"var(--proto-rail)":"var(--proto-card)",boxShadow:zn?"none":"var(--shadow-card-soft)",padding:"10px 12px 10px 14px"},children:zn&&!Fo?i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4,padding:"22px 12px"},children:[i.jsx("span",{style:{font:`600 11.5px ${qm}`,color:"var(--proto-accent)"},children:qr>0?L.wbDropFilesPlural.replace("{n}",String(qr)):L.wbDropFilesSingular}),i.jsx("span",{style:{font:`400 10px ${qm}`,color:"var(--proto-muted-3)"},children:L.wbAttachPath})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{opacity:zn?.4:1,pointerEvents:zn?"none":"auto"},children:[Fo&&i.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,padding:"2px 2px 10px",borderBottom:"1px solid var(--proto-line-2)"},children:Bt.map(Ce=>i.jsx(VCe,{attachment:Ce,onRetry:Er,onRemove:qi},Ce.id))}),i.jsx("textarea",{ref:Ie,"data-composer-input":!0,rows:1,value:ie,onChange:Ce=>{const rt=Ce.target.value;ye(rt),xe(null),ft(rt.startsWith("/"))},onKeyDown:Ye,onPaste:re,placeholder:Fo?L.wbAttachPlaceholder:L.composerPh,style:{width:"100%",fontSize:13.5,lineHeight:1.5,color:"var(--proto-ink)",fontFamily:"inherit",padding:Fo?"11px 2px":"2px 0",border:"none",outline:"none",resize:"none",background:"transparent",maxHeight:WE,overflowY:"auto"}}),i.jsx(t9e,{browser:a?{device:se,onChange:B}:l?{device:l.device}:null,commission:a?le?{value:G,onChange:ne}:null:c?{value:c.value,label:c.label}:null,onAttach:()=>{var Ce;return(Ce=Ae.current)==null?void 0:Ce.click()},onCommands:()=>{ye("/"),ft(!0)},profileControl:i.jsx(l9e,{selection:K}),contextControl:C,sendControl:i.jsxs("span",{style:{flex:"none",display:"inline-flex",alignItems:"center",gap:6},children:[i.jsx("button",{type:"button","data-action":"send","aria-label":L.wbSend,title:`${L.wbSend} · ⏎`,disabled:!hr,onClick:nt,style:{flex:"none",width:t?30:34,height:t?30:34,padding:0,borderRadius:"50%",background:t?"transparent":pn,border:t?`1.5px solid ${hr?"var(--proto-accent-border)":"var(--proto-line)"}`:"none",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",cursor:hr?"pointer":"default"},children:i.jsx("svg",{width:t?12:14,height:t?12:14,viewBox:"0 0 14 14",fill:"none",stroke:t?hr?"var(--proto-accent)":"var(--proto-line-3)":"var(--ink-solid-fg)",strokeWidth:"1.8",children:i.jsx("path",{d:"M7 12V2M3 6l4-4 4 4"})})}),t&&i.jsx("div",{"data-action":"stop",title:`${L.stop} · esc`,onClick:Se,onMouseEnter:()=>pr(!0),onMouseLeave:()=>pr(!1),style:{flex:"none",width:34,height:34,borderRadius:"50%",background:Vr?"var(--ink-solid-hover)":"var(--proto-ink)",display:"flex",alignItems:"center",justifyContent:"center",cursor:Y.isPending?"default":"pointer"},children:i.jsx("span",{style:{width:11,height:11,background:"var(--proto-card)",borderRadius:2}})})]})})]}),zn&&Fo&&i.jsxs("div",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",display:"flex",flexDirection:"column",alignItems:"center",gap:3,background:"var(--panel-translucent-bg)",border:"1px solid var(--proto-accent-border)",borderRadius:10,padding:"10px 18px",boxShadow:"var(--shadow-accent-soft)",zIndex:2},children:[i.jsx("span",{style:{font:`600 11.5px ${qm}`,color:"var(--proto-accent)"},children:qr>0?L.wbDropAddMoreN.replace("{n}",String(qr)):L.wbDropAddMore}),i.jsx("span",{style:{font:`400 10px ${qm}`,color:"var(--proto-muted-3)"},children:L.wbDragOverCount.replace("{n}",String(Bt.length)).replace("{m}",String(Bt.length+qr))})]})]})}),ke&&i.jsx("div",{"data-slash-error":!0,role:"alert",style:{marginTop:7,fontSize:12,color:"var(--proto-danger)"},children:L[ke]}),Z&&i.jsx(ECe,{error:Z}),i.jsx("input",{ref:Ae,type:"file",multiple:!0,onChange:Ce=>{Ce.target.files&&Ce.target.files.length>0&&(In(Ce.target.files),Ce.target.value="")},style:{display:"none"}}),g&&i.jsx(TCe,{running:Xn.active,text:$&&pi?nU(pi,L.wbBrowserStarting):Kr})]})})}const Ch={en:{title:"Context usage",current:"Current context",limit:"Context limit",usage:"Usage",tokens:"tokens",estimate:"The backend reports this value as an estimate.",waiting:"Context usage becomes available after the next turn completes.",compact:"Compact",compacting:"Compacting…",compacted:"Context compacted.",notNeeded:"Nothing to compact.",running:"Stop the current turn before compacting.",noHistory:"No conversation history to compact."},zh:{title:"上下文用量",current:"当前上下文",limit:"上下文上限",usage:"使用率",tokens:"tokens",estimate:"此数值由后端估算。",waiting:"下一次 turn 完成后将显示上下文用量。",compact:"压缩",compacting:"压缩中…",compacted:"上下文已压缩。",notNeeded:"当前没有可压缩内容。",running:"请先停止当前 turn,再压缩上下文。",noHistory:"当前没有可压缩的会话历史。"}};function bU(e){return Ch[e].title}function N9e({usage:e,supported:t,variant:n,lang:r,compactAction:o}){return!t&&e===null?null:i.jsx(ur,{title:bU(r),trigger:i.jsx(wU,{usage:e,variant:n,lang:r,"data-context-compact-enabled":o?"true":void 0}),footer:o?i.jsx(SU,{action:o,lang:r}):void 0,children:i.jsx(kU,{usage:e,lang:r})})}const F9e={border:0,background:"transparent",padding:0,display:"inline-flex",alignItems:"center",color:"var(--proto-muted)",cursor:"pointer",flex:"none"},wU=f.forwardRef(function({usage:t,variant:n,lang:r,style:o,...s},a){const l=Ch[r],c=i$(t),d=n==="desktop"?20:22,u=2.5,p=(d-u)/2,h=2*Math.PI*p,m=h*((c.progress??0)/100),x=`${l.usage}: ${c.percentLabel}`;return i.jsx("button",{...s,ref:a,type:"button","data-context-usage-ring":n,"data-context-usage-presentation":n==="mobile"?"sheet-trigger":"modal-trigger","aria-label":x,title:x,style:{...F9e,...o},children:i.jsx("span",{"data-context-usage-track":n,role:"progressbar","aria-label":l.usage,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":c.progress??void 0,style:{display:"inline-flex"},children:i.jsxs("svg",{width:d,height:d,viewBox:`0 0 ${d} ${d}`,children:[i.jsx("circle",{cx:d/2,cy:d/2,r:p,fill:"none",stroke:"var(--proto-line-3)",strokeWidth:u}),c.progress!=null&&c.progress>0&&i.jsx("circle",{cx:d/2,cy:d/2,r:p,fill:"none",stroke:"var(--proto-accent)",strokeWidth:u,strokeLinecap:"round",strokeDasharray:`${m} ${h}`,transform:`rotate(-90 ${d/2} ${d/2})`})]})})})});function z9e(e,t){const n=Ch[t];return e.error?e.error:e.status==="compacted"?n.compacted:e.status==="not-needed"?n.notNeeded:e.disabledReason==="running"?n.running:e.disabledReason==="no-history"?n.noHistory:null}function SU({action:e,lang:t}){const n=Ch[t];return i.jsxs(i.Fragment,{children:[i.jsx("span",{"aria-live":"polite",style:{marginRight:"auto",color:"var(--proto-muted)",fontSize:12},children:z9e(e,t)}),i.jsx(cn,{"data-context-compact-action":!0,variant:"primary",size:"sm",disabled:e.pending||e.disabled,onClick:e.onCompact,children:e.pending?n.compacting:n.compact})]})}function kU({usage:e,lang:t}){const n=Ch[t],r=i$(e),o=[[n.current,r.current==="—"?r.current:`${r.current} ${n.tokens}`],[n.limit,r.maximum==="—"?r.maximum:`${r.maximum} ${n.tokens}`],[n.usage,r.percentLabel]],s=e?r.estimated?n.estimate:null:n.waiting;return i.jsxs("div",{"data-context-usage-details":!0,style:{display:"grid",gap:10},children:[o.map(([a,l])=>i.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:20,borderBottom:"1px solid var(--proto-line-2)",paddingBottom:8},children:[i.jsx("span",{style:{color:"var(--proto-muted)"},children:a}),i.jsx("span",{style:{font:"600 12px 'IBM Plex Mono', ui-monospace, Menlo, monospace",color:"var(--proto-ink)",textAlign:"right"},children:l})]},a)),s?i.jsx("p",{style:{margin:0,color:"var(--proto-muted)",fontSize:12,lineHeight:1.5},children:s}):null]})}function jU(e,t){const n=he(),r=Ve(),[o,s]=f.useState(null),[a,l]=f.useState(null),c=t.running?"running":t.hasBackendHistory?null:"no-history",d=Re(n.sessions.compact.mutationOptions({onSuccess:p=>{s(p.status),l(null),r.invalidateQueries(n.sessions.list.queryFilter())},onError:p=>{s(null),l(p.message)}}));return f.useEffect(()=>{s(null),l(null)},[e]),{onCompact:f.useCallback(()=>{!e||d.isPending||c||(s(null),l(null),d.mutate({sessionId:e}))},[c,d,e]),pending:d.isPending,disabled:!e||c!==null,status:o,error:a,disabledReason:c}}function Lk(e){const t=he(),n=Ve(),r=Re(t.sessions.answerQuestion.mutationOptions()),o=Re(t.sessions.respondPlan.mutationOptions()),s=Re(t.sessions.cancelResume.mutationOptions()),[a,l]=f.useState(null),c=f.useCallback(()=>{n.invalidateQueries(t.sessions.transcript.queryFilter({sessionId:e})),n.invalidateQueries(t.sessions.pendingInteraction.queryFilter())},[n,t,e]),d=f.useCallback((m,x)=>{r.isPending||r.mutate({requestId:m,answers:x},{onSettled:c})},[r,c]),u=f.useCallback(m=>{o.isPending||o.mutate({requestId:m,approved:!0},{onSettled:c})},[o,c]),p=f.useCallback((m,x)=>{o.isPending||o.mutate({requestId:m,approved:!1,feedback:x??""},{onSettled:c})},[o,c]),h=f.useCallback(()=>{s.isPending||s.mutate({sessionId:e},{onSettled:()=>{l(e),c()}})},[s,c,e]);return{answerQuestion:d,approvePlan:u,rejectPlan:p,cancelResume:h,resumeCancelled:a===e,busy:r.isPending||o.isPending}}const B9e=800;function CU(e,t){const n=he(),r=Ve(),o=Re(n.sessions.markRead.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.sessions.list.queryFilter())}})),s=f.useRef(o.mutate);s.current=o.mutate;const a=f.useRef(null);f.useEffect(()=>{if(!e)return;const l=()=>{document.visibilityState==="visible"&&(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{s.current({sessionId:e})},B9e))};l();const c=()=>{document.visibilityState==="visible"&&l()};return document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c),a.current&&clearTimeout(a.current)}},[e,t])}function TU(e){const{sessionId:t,isDraft:n,projectId:r,transcript:o,liveTail:s,pendingUser:a,getMessageSnapshot:l}=e,[c,d]=f.useState([]),u=f.useRef([]),p=f.useRef(r),h=f.useRef(n);p.current=r,h.current=n;const m=f.useMemo(()=>({transcript:o??{sessionId:t,turns:[],pendingUserMessages:[]},liveTail:s,pendingUser:a}),[o,t,s,a]),x=f.useRef(m);x.current=m;const v=f.useCallback(()=>({...x.current,...l()}),[l]),S=f.useCallback(P=>{d(R=>{const D=P(R);return u.current=D,D})},[]),b=f.useMemo(()=>c.filter(P=>n?P.target.kind==="draft"&&P.target.projectId===r:P.target.kind==="session"&&P.target.sessionId===t),[c,n,r,t]),g=f.useMemo(()=>j9e(b,m),[b,m]);f.useEffect(()=>{if(g.settledClientIds.length===0)return;const P=new Set(g.settledClientIds);S(R=>R.filter(D=>!P.has(D.clientId)))},[g.settledClientIds,S]);const w=f.useCallback((P,R)=>{const D=n?{kind:"draft",projectId:r}:{kind:"session",sessionId:t};return m9e({clientId:crypto.randomUUID(),target:D,text:P,attachments:R,ts:new Date().toISOString()},u.current,v())},[n,r,t,v]),k=f.useCallback(P=>{S(R=>[...R,P])},[S]),C=f.useCallback((P,R)=>{const D=R==null?void 0:R.createdSessionId,I=u.current.find(W=>W.clientId===P),L=!!D&&!!I&&x9e(I,p.current,h.current);return S(W=>D?v9e(W,P,D,R==null?void 0:R.acceptedAt):vU(W,P,R==null?void 0:R.acceptedAt)),D?L:!0},[S]),T=f.useCallback(P=>{const R=b9e(u.current,P,v());return S(()=>R.messages),R.restore},[v,S]);return{pendingUser:g.pendingUser,prepare:w,enqueue:k,accept:C,reject:T}}const Yb="'IBM Plex Mono',monospace";function $9e({commissionId:e}){const t=he(),n=O(),r=d_(),[o,s]=f.useState(!1),a=ae(t.commissions.get.queryOptions({commissionId:e})),l=wc("direct"),c=a.data??null,d=f.useMemo(()=>(l.data??[]).filter(p=>p.commissionId===e&&!!p.awaitingInput).length,[l.data,e]);if(!c)return null;const u=c.status==="active";return i.jsxs("div",{onClick:()=>r.openCommission(e),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),title:n.wbCommissionOpenBoard,"data-commission-banner":e,style:{flex:"none",display:"flex",alignItems:"center",gap:8,margin:"0 24px 8px",padding:"6px 11px",borderRadius:8,cursor:"pointer",border:"1px solid var(--proto-line-2)",background:o?"var(--proto-gray)":"var(--proto-rail)"},children:[i.jsxs("svg",{width:12,height:12,viewBox:"0 0 14 14",fill:"none",strokeWidth:1.6,strokeLinejoin:"round",strokeLinecap:"round",style:{flex:"none"},stroke:d>0?"var(--proto-amber)":u?"var(--proto-accent)":"var(--proto-muted-3)",children:[i.jsx("path",{d:"M3.7 1.9v10.2"}),i.jsx("path",{d:"M3.7 2.7h6.8L9.1 5l1.4 2.3H3.7z"})]}),i.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:c.title}),!u&&i.jsx("span",{style:{font:`500 9px ${Yb}`,color:"var(--proto-muted-3)",flex:"none"},children:c.status==="done"?n.wbCommissionDone:n.wbCommissionAbandoned}),d>0&&i.jsx("span",{style:{font:`500 9.5px ${Yb}`,color:"var(--proto-amber)",flex:"none"},children:n.wbCommissionGateCount.replace("{n}",String(d))}),i.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${Yb}`,color:"var(--proto-muted-3)",flex:"none"},children:n.wbCommissionOpenBoard})]})}const _9e={sessionId:"",turns:[]};function W9e({grow:e=1,onOpenSettings:t}={}){const n=O(),r=ht(),o=he(),s=f.useRef(null),{currentProjectId:a}=zt(),{selectedSessionId:l,isDraft:c,draftProfile:d,draftReloadToken:u}=Vi(),p=tl(a,"direct"),h=tl(a,"scheduled"),m=f.useMemo(()=>[...p.data??[],...h.data??[]].find(Ie=>Ie.sessionId===l)??null,[p.data,h.data,l]),x=aU(m),v=ae({...o.schedules.list.queryOptions({}),enabled:!!(m!=null&&m.scheduleId)}),S=f.useMemo(()=>m!=null&&m.scheduleId?(v.data??[]).find(Oe=>Oe.id===m.scheduleId)??null:null,[v.data,m==null?void 0:m.scheduleId]),b=(m==null?void 0:m.origin)==="scheduled",g=f.useMemo(()=>{if(!b||!(m!=null&&m.scheduleId))return null;const Oe=(h.data??[]).filter(Ie=>Ie.scheduleId===m.scheduleId);return jH(S,Oe,m.sessionId)},[b,m==null?void 0:m.scheduleId,m==null?void 0:m.sessionId,S,h.data]),w=(m==null?void 0:m.sessionId)??(c?"":l??""),k=c?n.wbNewConversation:m?g??m.label??m.name:"No session",C=ae({...o.sessions.transcript.queryOptions({sessionId:w,compactSubagents:!0}),enabled:!!w}),{liveTail:T,getMessageSnapshot:P,streaming:R,running:D,backgroundRunning:I,liveTurns:L,contextUsage:W,todos:ee,streamingText:V,pendingUser:X}=S1(w,m==null?void 0:m.running,m==null?void 0:m.backgroundRunning,{deltas:!0,transcript:C.data??null,contextUsage:(m==null?void 0:m.contextUsage)??null,todos:(m==null?void 0:m.todos)??null}),K=TU({sessionId:w,isDraft:c,projectId:a??"general",transcript:C.data??null,liveTail:T,pendingUser:X,getMessageSnapshot:P}),se=Lk(w);CU(w,`${T.length}:${D}`);const B=C.data??_9e,G=f.useMemo(()=>i1(B,T,{streaming:R,running:D,streamingText:V,pendingUser:K.pendingUser,formatDivider:dz(n),stripScheduledPrefix:!!(m!=null&&m.scheduleId)||b}),[B,T,R,D,V,K.pendingUser,n,m==null?void 0:m.scheduleId,b]),ne=c&&G.length===0,le=ehe(C.data),_=iz(L,(m==null?void 0:m.numTurns)??null),Y=f.useMemo(()=>sz(oz(C.data)),[C.data]),te=le>0||T.length>0,ie=jU(w,{running:D,hasBackendHistory:!!(m!=null&&m.backendSessionId)}),ye=Ve(),Z=Re(o.sessions.rewind.mutationOptions({onSettled:()=>{w&&(ye.invalidateQueries(o.sessions.transcript.queryFilter({sessionId:w})),ye.invalidateQueries(o.sessions.list.queryFilter()),wd(ye,o,w))}})),xe=f.useMemo(()=>{if(w)return{running:D,busy:Z.isPending,onSubmit:(Oe,Ie)=>Z.mutate({sessionId:w,turnIndex:Oe,text:Ie})}},[w,D,Z]),ke=()=>{window.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0}))};return i.jsxs("div",{ref:s,"data-pane":"center",style:{flexGrow:e,flexShrink:1,flexBasis:0,minWidth:0,display:"flex",flexDirection:"column",background:"var(--proto-card)",minHeight:0},children:[i.jsx($8e,{title:k,onCmdK:ke,backendSessionId:(m==null?void 0:m.backendSessionId)??null,sessionName:(m==null?void 0:m.name)??null}),(m==null?void 0:m.commissionId)&&i.jsx($9e,{commissionId:m.commissionId}),i.jsxs("div",{"data-chat-phase":ne?"pre-start":"active",style:{flex:1,minHeight:0,display:"grid",gridTemplateRows:ne?"minmax(0, 1fr) auto minmax(0, 1fr)":"minmax(0, 1fr) auto minmax(0, 0fr)",transition:"grid-template-rows 420ms cubic-bezier(.22,1,.36,1)"},children:[i.jsx(H1e,{rows:G,loading:!!w&&C.isPending,inlineThreadCard:w?i.jsx(Q8e,{sessionId:w}):void 0,interactionActions:se,edit:xe,streamKey:w}),i.jsx(O9e,{sessionId:w,running:D,backgroundRunning:I,turns:_,cost:(m==null?void 0:m.costUsd)??null,elapsed:Y,isDraft:c,currentProfile:(m==null?void 0:m.profileName)??null,sessionBrowser:(m==null?void 0:m.browser)??null,sessionCommission:x,hasHistory:te,draftProfile:d,draftReloadToken:u,projectId:a??"general",prepareOptimistic:K.prepare,enqueueOptimistic:K.enqueue,acceptOptimistic:K.accept,rejectOptimistic:K.reject,showStatus:!ne,statusStarting:K.pendingUser.length>0,turnProgressStarted:L!==null||R,compactAction:m!=null&&m.contextCompactionSupported?ie:void 0,todos:ee,dropTargetRef:s,onOpenSettings:t,contextControl:m!=null&&m.contextCompactionSupported||W!==null?i.jsx(N9e,{usage:W,supported:!!(m!=null&&m.contextCompactionSupported),variant:"desktop",lang:r,compactAction:m!=null&&m.contextCompactionSupported?ie:void 0}):void 0}),i.jsx("div",{"aria-hidden":"true",style:{minHeight:0}})]}),b&&i.jsx("div",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",maxWidth:760,margin:"0 auto",width:"100%",boxSizing:"border-box",padding:"0 24px 10px",flex:"none"},children:n.wbSchedReplyHint})]})}function Ok(e,t){return e.unmetDependencyIds!==void 0?e.unmetDependencyIds:t?e.dependsOn.filter(n=>t.get(n)==="open"):e.dependsOn}const H9e=["in-progress","actionable","approval-needed","waiting-deps","blocked","done"],U9e=[{kind:"done",matches:e=>e.status==="done"},{kind:"blocked",matches:e=>e.blockedBy!=null},{kind:"in-progress",matches:e=>e.claimedBy!=null},{kind:"approval-needed",matches:e=>e.approvalNeeded===!0},{kind:"waiting-deps",matches:(e,t)=>t},{kind:"actionable",matches:e=>e.actionable}];function V9e(e,t){var r;const n=Ok(e,t).length>0;return((r=U9e.find(o=>o.matches(e,n)))==null?void 0:r.kind)??"waiting-deps"}function HE(e){const t=Date.parse(e.completedAt??"");return Number.isNaN(t)?null:t}function q9e(e){return[...e].sort((t,n)=>{const r=HE(t),o=HE(n);return r===null&&o===null?0:r===null?1:o===null?-1:o-r})}function PU(e){const t=new Map(e.map(n=>[n.id,n.status]));return H9e.map(n=>{const r=e.filter(o=>V9e(o,t)===n);return{kind:n,tasks:n==="done"?q9e(r):r}}).filter(n=>n.tasks.length>0)}function K9e(e){return e.filter(t=>t.status==="open").length}const G9e={"in-progress":"var(--proto-danger)",actionable:"var(--proto-amber)","approval-needed":"var(--proto-amber)","waiting-deps":"var(--proto-faint)",blocked:"var(--proto-amber)",done:"var(--proto-success)"},Y9e={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:9,padding:"9px 12px",boxShadow:"var(--shadow-card-subtle)",cursor:"pointer"},Q9e={claim:{color:"var(--proto-accent)",background:"var(--proto-accent-bg)"},approval:{color:"var(--proto-amber-text)",background:"var(--proto-amber-bg)"},blocked:{color:"var(--proto-danger)",background:"var(--proto-danger-bg)"},waiting:{color:"var(--proto-muted-2)",background:"var(--proto-gray)"},done:{color:"var(--proto-success)",background:"var(--proto-success-bg)"}},X9e={boxSizing:"border-box",maxWidth:"100%",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function Z9e(e,t,n){const r=NS(e),o=Ok(e),s=k1(e.completedAt);return[t==="done"&&s?{kind:"done",text:`${n.tkCompletedAt} · ${s}`}:null,t==="blocked"&&e.blockedBy?{kind:"blocked",text:`${n.mBlockedPill} · ${e.blockedBy}`}:null,t==="in-progress"?{kind:"claim",text:r?`claimed · ${r}`:"claimed"}:null,t==="approval-needed"?{kind:"approval",text:n.tkApprovalNeeded}:null,t==="waiting-deps"&&o.length>0?{kind:"waiting",text:`${n.mDependsOn} ${o.join(", ")}`}:null].find(l=>l!=null)??null}function J9e({task:e}){return i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:7,minWidth:0},children:[i.jsx("span",{style:{color:"var(--proto-faint)",fontSize:8.5,flex:"none"},children:"▸"}),i.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:e.id}),i.jsx("span",{style:{fontSize:12,color:"var(--proto-ink-2)",lineHeight:1.45,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:e.text,children:e.text})]})}function eTe({meta:e}){return i.jsx("div",{style:{display:"flex",alignItems:"center",marginTop:5},children:i.jsx("span",{"data-task-blocker":e.kind==="blocked"?"true":void 0,style:{font:"500 9.5px 'IBM Plex Mono',monospace",padding:"1.5px 7px",borderRadius:999,...Q9e[e.kind],...e.kind==="blocked"?X9e:{}},children:e.text})})}function tTe({task:e,kind:t,onOpen:n}){const r=O(),o=Z9e(e,t,r);return i.jsx("div",{"data-task-id":e.id,"data-status":e.status,onClick:()=>n(e),style:Y9e,children:i.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:G9e[t],flex:"none",marginTop:5}}),i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx(J9e,{task:e}),o&&i.jsx(eTe,{meta:o})]})]})})}function Nk(){const e=he(),t=Ve();qs(V1e,()=>{t.invalidateQueries(e.tasks.list.queryFilter())})}const nTe={fontSize:11.5,fontWeight:700,letterSpacing:".06em",textTransform:"uppercase",color:"var(--proto-muted)",padding:"8px 2px 4px"},rTe={borderRadius:10,border:"1px solid var(--proto-line)",background:"var(--proto-danger-bg)",padding:"6px 10px",fontSize:12,color:"var(--proto-danger)"};function oTe({kind:e,tasks:t,onOpen:n}){const r=O(),o={"in-progress":r.tkInProgress,actionable:r.tkActionable,"approval-needed":r.tkApprovalNeeded,"waiting-deps":r.tkWaitingDeps,blocked:r.mBlocked,done:r.tkDone};return i.jsxs("section",{children:[i.jsxs("div",{style:nTe,children:[o[e]," · ",t.length]}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.map(s=>i.jsx(tTe,{task:s,kind:e,onOpen:n},s.id))})]})}function iTe({groups:e,onOpen:t}){const n=O();return e.length===0?i.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-2)",padding:"24px 0",textAlign:"center"},children:n.mNoTasks}):i.jsx(i.Fragment,{children:e.map(r=>i.jsx(oTe,{...r,onOpen:t},r.kind))})}function sTe({tasks:e,groups:t}){var o;const n=O(),r=((o=t.find(s=>s.kind==="done"))==null?void 0:o.tasks.length)??0;return i.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",padding:"8px 2px 0",borderTop:"1px solid var(--proto-line-2)",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:[i.jsxs("span",{children:["TASKS.yaml · ",n.synced]}),i.jsxs("span",{style:{marginLeft:"auto"},children:[e.length," total · ",r," done"]})]})}function EU({projectId:e}){const t=O(),n=he(),{openTask:r}=s_(),o=ae(n.tasks.list.queryOptions(e?{projectId:e}:{}));Nk();const s=o.data??[],a=f.useMemo(()=>PU(s),[s]);return o.isPending?i.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-2)",padding:12},children:t.tkLoading}):o.isError?i.jsxs("div",{style:rTe,children:[t.tkLoadFailed,": ",o.error.message]}):i.jsxs("div",{style:{minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:[i.jsx("div",{style:{flex:1,overflow:"auto",minHeight:0},children:i.jsx(iTe,{groups:a,onOpen:l=>r(l.project,l.id)})}),i.jsx(sTe,{tasks:s,groups:a})]})}function aTe(e){return e?"m15 6-6 6 6 6":"m9 6 6 6-6 6"}function RU({side:e,expanded:t,label:n,onClick:r}){const o=t?e==="left":e==="right";return i.jsx("button",{type:"button","aria-expanded":t,"aria-label":n,title:n,onClick:r,style:{width:28,height:28,border:"1px solid var(--proto-line)",borderRadius:7,background:"transparent",color:"var(--proto-muted-2)",display:"grid",placeItems:"center",padding:0,cursor:"pointer",flex:"none"},children:i.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:aTe(o)})})})}function lTe(e){return e.artifacts.taskProject??e.projectId}const cTe=i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",strokeWidth:"1.6",children:[i.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),i.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),i.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),i.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]});function dTe({kind:e,hasTail:t}){return i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e==="done"&&i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,flex:"none"},children:"✓"}),e==="running"&&i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-accent)",flex:"none",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite"}}),e==="pending"&&i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),t&&i.jsx("span",{style:{flex:1,width:1.5,background:"var(--proto-line-2)",margin:"3px 0"}})]})}const Fk={running:"var(--proto-accent)",done:"var(--proto-success)",failed:"var(--proto-danger)",idle:"var(--proto-faint)"};function MU({tone:e}){return i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:Fk[e],flex:"none",animation:e==="running"?"cxpulse 1.6s ease-in-out infinite":void 0}})}function uTe({run:e,onOpen:t}){const n=iCe(e.status),r=[e.machine,e.taskId?`task ${e.taskId}`:null].filter(Boolean).join(" · ");return i.jsxs("div",{"data-cortex-run":e.runName??"",onClick:()=>t(e.executionId),style:{display:"flex",alignItems:"center",gap:7,border:`1px solid ${n.tone==="running"?"var(--proto-accent-bg)":"var(--proto-line-2)"}`,background:"var(--proto-rail)",borderRadius:8,padding:"7px 10px",cursor:"pointer"},children:[i.jsx(MU,{tone:n.tone}),i.jsx("span",{style:{minWidth:0,font:"600 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:oCe(e)}),r&&i.jsx("span",{style:{flex:"none",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:r}),i.jsx("span",{style:{marginLeft:"auto",flex:"none",font:"500 9.5px 'IBM Plex Mono',monospace",color:Fk[n.tone]},children:e.cost!=null?Ru(e.cost):n.label})]})}function pTe({task:e,onOpen:t}){const n=sCe(e);return i.jsxs("div",{"data-subtask-id":e.id,onClick:()=>t(e.id),style:{display:"flex",alignItems:"center",gap:7,border:"1px solid var(--proto-line-2)",background:"var(--proto-rail)",borderRadius:8,padding:"7px 10px",cursor:"pointer"},children:[i.jsx(MU,{tone:n.tone}),i.jsxs("span",{style:{flex:"none",font:"600 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:["task ",e.id]}),i.jsx("span",{style:{minWidth:0,fontSize:9.5,color:"var(--proto-muted-3)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text}),i.jsx("span",{style:{marginLeft:"auto",flex:"none",fontSize:9.5,fontWeight:600,color:Fk[n.tone]},children:n.label})]})}function fTe({runs:e,subtasks:t,onOpenRun:n,onOpenTask:r}){return e.length===0&&t.length===0?null:i.jsxs("div",{style:{marginTop:7,display:"flex",flexDirection:"column",gap:6},children:[e.map(o=>i.jsx(uTe,{run:o,onOpen:n},o.executionId)),t.map(o=>i.jsx(pTe,{task:o,onOpen:r},o.id))]})}function hTe({label:e,meta:t,active:n,done:r}){const o=n?"var(--proto-ink)":r?"var(--proto-muted)":"var(--proto-faint)";return i.jsxs("div",{style:{display:"flex",alignItems:"baseline"},children:[i.jsx("span",{style:{fontSize:11.5,fontWeight:n?600:500,color:o},children:e}),i.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:n?"var(--proto-accent)":"var(--proto-faint)"},children:t})]})}function mTe({step:e,isLast:t,detail:n,onOpenRun:r,onOpenTask:o}){const s=O(),a=eCe(e),l=a==="running",c=l?KF(n,e):[],d=l?n.subtasks??[]:[],u=c.length>0||d.length>0,p=e.stage??`${s.rpStep} ${e.stepIndex+1}`;return i.jsxs(i.Fragment,{children:[i.jsx(dTe,{kind:a,hasTail:!t}),i.jsxs("div",{style:{minWidth:0,paddingBottom:t?4:9},children:[i.jsx(hTe,{label:p,meta:rCe(e),active:l,done:a==="done"}),u&&i.jsx(fTe,{runs:c,subtasks:d,onOpenRun:r,onOpenTask:o})]})]})}function gTe({threadId:e,cost:t}){const n=O(),r=he(),{openThread:o}=RS(),s=Ve(),a=Re(r.threads.cancel.mutationOptions({onSettled:()=>{s.invalidateQueries(r.threads.list.queryFilter()),s.invalidateQueries(r.threads.get.queryFilter({threadId:e}))}}));return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:13,padding:"8px 14px",borderTop:"1px solid var(--proto-line-2)"},children:[i.jsx("span",{title:"Pause has no backend mutate op yet",style:{fontSize:11.5,fontWeight:600,color:"var(--proto-muted)",cursor:"not-allowed",opacity:.6},children:n.pause}),i.jsx("span",{"data-cancel-thread-id":e,onClick:()=>a.mutate({threadId:e}),style:{fontSize:11.5,fontWeight:600,color:"var(--proto-danger)",cursor:"pointer"},children:n.cancel}),i.jsx("span",{onClick:()=>o(e),style:{fontSize:11.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:n.open}),i.jsxs("span",{style:{marginLeft:"auto",font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:["Σ ",Ru(t)]})]})}function vTe({detail:e,threadId:t}){const{open:n}=p$(),{openTask:r}=s_();return vh(t),i.jsxs(i.Fragment,{children:[e.steps.length>0&&i.jsx("div",{style:{padding:"10px 14px 4px"},children:i.jsx("div",{style:{display:"grid",gridTemplateColumns:"16px 1fr",columnGap:9},children:e.steps.map(o=>i.jsx(mTe,{step:o,isLast:o.stepIndex===e.steps.length-1,detail:e,onOpenRun:n,onOpenTask:s=>r(lTe(e),s)},o.stepIndex))})}),i.jsx(gTe,{threadId:t,cost:e.totalCostUsd})]})}function xTe({thread:e,now:t}){const n=O(),[r,o]=f.useState(e.status==="running"),s=he(),a=ae({...s.threads.get.queryOptions({threadId:e.id}),enabled:r}),l=J8e(e.status),c=e.status==="running"?"var(--proto-accent)":"var(--proto-muted-2)",d=r?a.data:void 0,u=d?lCe(d):null,p=!!u&&u.filled>1;return i.jsxs("div",{style:{background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"var(--shadow-card-subtle)"},children:[i.jsxs("div",{onClick:()=>o(h=>!h),style:{padding:"11px 14px 9px",cursor:"pointer",borderBottom:"1px solid "+(r?"var(--proto-line-soft)":"transparent")},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{style:{display:"inline-flex",color:c,stroke:c},children:cTe}),i.jsx("span",{style:{font:"600 12.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:e.templateName}),i.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:l.bg,color:l.fg},children:l.text})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:5},children:[i.jsx("span",{style:{font:"400 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:aCe(e,t)}),p&&u&&i.jsxs("span",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:3},children:[i.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginRight:2},children:n.rpDepth}),Array.from({length:u.total}).map((h,m)=>i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:m<u.filled?"var(--proto-accent)":"var(--proto-line)"}},m)),i.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",marginLeft:2},children:u.text})]})]})]}),r&&a.isPending&&i.jsx("div",{style:{padding:"10px 14px",fontSize:11,color:"var(--proto-muted-3)"},children:n.rpLoadingThread}),r&&a.isError&&i.jsx("div",{style:{padding:"10px 14px",fontSize:11,color:"var(--proto-danger)"},children:n.rpFailedLoadThread}),r&&d&&i.jsx(vTe,{detail:d,threadId:e.id})]})}const yTe=i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",strokeWidth:"1.6",children:[i.jsx("rect",{x:"1.5",y:"2",width:"11",height:"4",rx:"1",stroke:"currentColor"}),i.jsx("rect",{x:"1.5",y:"8",width:"11",height:"4",rx:"1",stroke:"currentColor"}),i.jsx("circle",{cx:"11",cy:"4",r:"0.9",fill:"currentColor",stroke:"none"}),i.jsx("circle",{cx:"11",cy:"10",r:"0.9",fill:"currentColor",stroke:"none"})]}),L1="'IBM Plex Mono',monospace",vs=`400 10px ${L1}`;function bTe({open:e}){return i.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",style:{transform:e?"rotate(90deg)":"none",transition:"transform .15s",flexShrink:0},children:i.jsx("path",{d:"M3.5 2L6.5 5L3.5 8",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function wTe(e){return e>=90?"var(--proto-danger)":e>=75?"var(--proto-amber)":"var(--proto-accent)"}function IU({percent:e,width:t=46}){return i.jsx("span",{style:{width:t,height:5,borderRadius:3,background:"var(--proto-line-2)",overflow:"hidden",flexShrink:0,display:"inline-block"},children:i.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",background:wTe(e)}})})}function STe({meters:e}){return i.jsx("div",{style:{display:"flex",gap:14,flexWrap:"wrap",padding:"8px 14px"},children:e.map(t=>i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,font:vs,color:"var(--proto-muted-2)"},children:[i.jsx("span",{style:{color:"var(--proto-muted-3)"},children:t.label}),i.jsx(IU,{percent:t.percent,width:34}),i.jsx("span",{style:{color:"var(--proto-muted)"},children:t.text})]},t.key))})}function kTe({gpu:e}){return i.jsxs("div",{style:{padding:"6px 14px",borderTop:"1px solid var(--proto-line-soft)"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,font:vs,color:"var(--proto-muted)"},children:[i.jsx("span",{style:{color:"var(--proto-ink-3)",fontWeight:600},children:e.index}),i.jsx("span",{style:{color:"var(--proto-muted-2)",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),i.jsx(IU,{percent:e.utilPercent,width:34}),i.jsx("span",{style:{width:30,textAlign:"right"},children:e.utilText}),i.jsx("span",{style:{color:"var(--proto-muted-3)"},children:e.memText}),i.jsx("span",{style:{color:"var(--proto-faint)"},children:e.tempText})]}),e.owners.length>0&&i.jsxs("div",{style:{font:vs,color:"var(--proto-accent)",marginTop:3,paddingLeft:14},children:["↳ ",e.owners.join(" · ")]}),e.processes.map(t=>i.jsxs("div",{style:{font:vs,color:"var(--proto-faint)",marginTop:2,paddingLeft:14},children:[t.pid," ",t.name," · ",t.memText]},t.pid)),e.hiddenProcessCount>0&&i.jsxs("div",{style:{font:vs,color:"var(--proto-faint)",marginTop:2,paddingLeft:14},children:["+",e.hiddenProcessCount]})]})}function jTe({run:e}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,font:vs,color:"var(--proto-muted)"},children:[i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--proto-accent)",flexShrink:0,animation:"cxpulse 1.6s ease-in-out infinite"}}),i.jsx("span",{style:{color:"var(--proto-ink-3)",fontWeight:600},children:e.label}),e.gpuText&&i.jsx("span",{style:{color:"var(--proto-muted-3)"},children:e.gpuText}),e.duration&&i.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-faint)"},children:e.duration})]})}function UE({machine:e,uptime:t}){const n=O(),r=[];return e.connectedAt&&r.push(`${n.mConnectedFor} ${wv(e.connectedAt)}`),e.lastHeartbeat&&r.push(`${n.mHeartbeat} ${wv(e.lastHeartbeat)}`),t&&r.push(`${n.mUptime} ${t}`),e.sshConfigured&&r.push(`${n.mSsh} ✓`),e.capabilities.length>0&&r.push(e.capabilities.join(",")),i.jsxs("div",{style:{padding:"7px 14px 9px",borderTop:"1px solid var(--proto-line-soft)"},children:[i.jsx("div",{style:{font:vs,color:"var(--proto-faint)",lineHeight:1.7},children:r.join(" · ")}),e.cortexPath&&i.jsxs("div",{style:{font:vs,color:"var(--proto-faint)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[n.mPath," ",e.cortexPath]})]})}function Rp({text:e,tone:t}){return i.jsx("div",{style:{padding:"8px 14px",font:vs,color:t==="danger"?"var(--proto-danger)":"var(--proto-muted-3)"},children:e})}function CTe({detail:e}){const t=O();if(e.status==="offline")return i.jsxs(i.Fragment,{children:[i.jsx(Rp,{text:t.mOfflineNoTelemetry,tone:"muted"}),i.jsx(UE,{machine:e.machine,uptime:""})]});if(e.status==="probing")return i.jsx(Rp,{text:t.mProbing,tone:"muted"});if(e.status==="error"||!e.facts)return i.jsx(Rp,{text:t.mProbeFailed,tone:"danger"});const n=e.facts;return i.jsxs(i.Fragment,{children:[n.probeError&&i.jsx(Rp,{text:`${t.mProbeFailed}: ${n.probeError}`,tone:"danger"}),n.meters.length>0&&i.jsx(STe,{meters:n.meters}),n.gpus.map(r=>i.jsx(kTe,{gpu:r},r.index)),!n.probeError&&n.gpus.length===0&&i.jsx(Rp,{text:t.mNoGpuReported,tone:"muted"}),n.liveRuns.length>0&&i.jsx("div",{style:{padding:"8px 14px",borderTop:"1px solid var(--proto-line-soft)",display:"flex",flexDirection:"column",gap:5},children:n.liveRuns.map(r=>i.jsx(jTe,{run:r},r.key))}),i.jsx(UE,{machine:e.machine,uptime:e.uptime})]})}function TTe({machine:e,open:t}){const n=dCe(e.online),r=e.online?"var(--proto-accent)":"var(--proto-muted-2)";return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{style:{display:"inline-flex",color:"var(--proto-muted-3)"},children:i.jsx(bTe,{open:t})}),i.jsx("span",{style:{display:"inline-flex",color:r},children:yTe}),i.jsx("span",{style:{font:`600 12.5px ${L1}`,color:"var(--proto-ink)"},children:e.name}),i.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:n.bg,color:n.fg},children:n.text})]})}function PTe({machine:e}){const t=O(),n=[e.gpuCount==null?"":`${t.mGpu} ×${e.gpuCount}`,e.os,e.liveRuns>0?`${e.liveRuns} ${t.mLiveRuns}`:""].filter(Boolean);return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:5},children:[i.jsx("span",{style:{font:`400 10.5px ${L1}`,color:"var(--proto-muted-3)",paddingLeft:17},children:n.join(" · ")}),e.liveRuns>0&&i.jsx("span",{style:{marginLeft:"auto",width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",flexShrink:0,animation:"cxpulse 1.6s ease-in-out infinite"}})]})}function ETe({machine:e,open:t,detail:n,onToggle:r}){return i.jsxs("div",{style:{background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"var(--shadow-card-subtle)"},children:[i.jsxs("div",{role:"button","aria-expanded":t,onClick:r,style:{padding:"11px 14px 9px",cursor:"pointer",borderBottom:`1px solid ${t?"var(--proto-line-soft)":"transparent"}`},children:[i.jsx(TTe,{machine:e,open:t}),i.jsx(PTe,{machine:e})]}),t&&n&&i.jsx(CTe,{detail:n})]})}function RTe({count:e}){const t=O();return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 18px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[i.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted)"},children:t.machines}),i.jsx("span",{style:{marginLeft:"auto",font:`500 10.5px ${L1}`,color:"var(--proto-muted)"},children:e})]})}function MTe({loading:e,error:t,empty:n}){const r=O();return e?i.jsx("div",{style:{textAlign:"center",fontSize:11,color:"var(--proto-muted-3)",padding:"24px 0"},children:r.rpLoadingMachines}):t?i.jsx("div",{style:{textAlign:"center",fontSize:11,color:"var(--proto-danger)",padding:"24px 0"},children:r.rpFailedLoadMachines}):n?i.jsxs("div",{style:{textAlign:"center",padding:"26px 12px",border:"1px dashed var(--proto-line)",borderRadius:10},children:[i.jsx("div",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-muted-2)"},children:r.mNoMachines}),i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",marginTop:4,lineHeight:1.6},children:r.rpNoMachinesHint})]}):null}function ITe(e){const t=!e.loading&&!e.error?String(e.machines.length):"—";return i.jsxs(i.Fragment,{children:[i.jsx(RTe,{count:t}),i.jsxs("div",{style:{flex:1,padding:"12px 16px",display:"flex",flexDirection:"column",gap:10,overflow:"auto",minHeight:0},children:[e.machines.map(n=>i.jsx(ETe,{machine:n,open:e.expanded.has(n.name),detail:e.detailFor(n.name),onToggle:()=>e.onToggle(n.name)},n.name)),i.jsx(MTe,{loading:e.loading,error:e.error,empty:e.machines.length===0})]})]})}function ATe(){const[e,t]=f.useState(()=>new Set),n=lh([...e]),r=o=>t(s=>{const a=new Set(s);return a.has(o)?a.delete(o):a.add(o),a});return i.jsx(ITe,{machines:n.machines,loading:n.loading,error:!!n.error,expanded:e,detailFor:n.detailFor,onToggle:r})}const DTe=["active","history"],LTe=["running","waiting","completed","failed","cancelled","aborted"],AU={running:"active",waiting:"active",completed:"history",failed:"history",cancelled:"history",aborted:"history"};function OTe(e){return LTe.filter(t=>AU[t]===e)}function DU(e){return DTe.map(t=>({kind:t,threads:e.filter(n=>AU[n.status]===t)})).filter(t=>t.threads.length>0)}const NTe=6e4;function FTe(e,t=(r,o)=>window.setInterval(r,o),n=r=>window.clearInterval(r)){const r=t(e,NTe);return()=>n(r)}function LU(e){const[t,n]=f.useState(()=>Date.now());return f.useEffect(()=>{if(e)return n(Date.now()),FTe(()=>n(Date.now()))},[e]),t}function zk(){const e=he(),t=Ve();qs(CS,()=>{t.invalidateQueries(e.threads.list.queryFilter())})}function OU({completed:e,onClick:t,disabled:n}){return i.jsx("button",{type:"button",disabled:n,"aria-label":e?"reopen note":"complete note",onClick:r=>{r.stopPropagation(),t()},style:{width:15,height:15,borderRadius:"50%",border:e?0:"1.5px solid var(--proto-line-3)",background:e?"var(--proto-success)":"transparent",color:"var(--ink-solid-fg)",padding:0,flex:"none",fontSize:9,cursor:"pointer"},children:e?"✓":""})}function zTe({copy:e,busy:t,onAdd:n}){const[r,o]=f.useState(""),s=async a=>{a.preventDefault();const l=r.trim();!l||t||(await n(l),o(""))};return i.jsx("form",{onSubmit:s,style:{margin:"12px 16px 0"},children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,border:"1.5px solid var(--proto-accent)",borderRadius:10,boxShadow:"0 0 0 3px var(--proto-accent-bg)",padding:"9px 12px"},children:[i.jsx("span",{style:{width:15,height:15,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),i.jsx("input",{value:r,onChange:a=>o(a.target.value),placeholder:e.inputPlaceholder,"aria-label":e.inputPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:12.5,color:"var(--proto-ink)"}}),i.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",border:"1px solid var(--proto-line-2)",borderRadius:4,padding:"1px 5px"},children:e.enter})]})})}function BTe({row:e,copy:t,busy:n,actions:r,onCancel:o}){const[s,a]=f.useState(e.text),l=async()=>{const c=s.trim();!c||n||(await r.onUpdate(e.id,c),o())};return i.jsxs("div",{style:{border:"1px solid var(--proto-accent-border)",borderRadius:9,padding:10},children:[i.jsx("input",{value:s,onChange:c=>a(c.target.value),autoFocus:!0,style:{width:"100%",boxSizing:"border-box",border:"1px solid var(--proto-line-3)",borderRadius:7,padding:"7px 9px",fontSize:12.5,outline:0}}),i.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[i.jsx(If,{label:t.save,onClick:l,primary:!0,disabled:n}),i.jsx(If,{label:t.cancel,onClick:o,disabled:n})]})]})}function If({label:e,onClick:t,primary:n=!1,danger:r=!1,disabled:o=!1}){const s=r?"var(--proto-danger)":n?"var(--ink-solid-fg)":"var(--proto-muted)";return i.jsx("button",{type:"button",disabled:o,onClick:a=>{a.stopPropagation(),t()},style:{border:n?0:"1px solid var(--proto-line)",borderRadius:7,padding:"4px 10px",background:n?"var(--proto-accent)":"var(--proto-card)",color:s,fontSize:10.5,fontWeight:600,cursor:o?"not-allowed":"pointer"},children:e})}function $Te({row:e,copy:t,busy:n,actions:r,targeted:o,onSelect:s}){const[a,l]=f.useState(!1);return a?i.jsx(BTe,{row:e,copy:t,busy:n,actions:r,onCancel:()=>l(!1)}):i.jsxs("div",{id:`note-${e.id}`,"data-note-target":e.id,onClick:()=>s(e.id),style:{border:o?"1px solid var(--proto-accent-border)":"1px solid transparent",borderRadius:10,background:o?"var(--proto-accent-bg)":"transparent",padding:"9px 10px",cursor:"pointer"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:9},children:[i.jsx(OU,{completed:!1,disabled:n,onClick:()=>void r.onSetCompleted(e.id,!0)}),i.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:"var(--proto-ink)",lineHeight:1.45,minWidth:0},children:e.text}),i.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.timeLabel})]}),o&&i.jsxs("div",{"data-note-actions":e.id,style:{display:"flex",gap:6,marginTop:8,paddingLeft:24},children:[i.jsx(If,{label:t.handoff,onClick:()=>r.onHandoff(e.text),primary:!0,disabled:n}),i.jsx(If,{label:t.edit,onClick:()=>l(!0),disabled:n}),i.jsx(If,{label:t.delete,onClick:()=>void r.onDelete(e.id),danger:!0,disabled:n})]})]})}function _Te({row:e,busy:t,onReopen:n}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"8px 10px",opacity:.75},children:[i.jsx(OU,{completed:!0,disabled:t,onClick:n}),i.jsx("span",{style:{fontSize:12.5,color:"var(--proto-muted-2)",textDecoration:"line-through",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text}),i.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.timeLabel})]})}function WTe(e,t,n){f.useEffect(()=>{var r;!n||!e||(r=document.getElementById(`note-${e}`))==null||r.scrollIntoView({block:"center"})},[e,n]),f.useEffect(()=>{if(!n)return;const r=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t,n])}function HTe({copy:e,activeCount:t,headerIcon:n,headerAction:r,onClose:o}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 10px 8px 16px",borderBottom:"1px solid var(--proto-line-2)"},children:[n&&i.jsx("span",{"aria-hidden":"true",style:{color:"var(--proto-muted-2)",display:"grid",placeItems:"center"},children:n}),i.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:e.title}),i.jsx("span",{style:{font:"600 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999},children:t}),i.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:"context/NOTES.md"}),r,i.jsx("button",{type:"button",onClick:o,style:{font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",background:"transparent",cursor:"pointer"},children:e.escape})]})}function UTe(e){const[t,n]=f.useState(!0);WTe(e.targetId,e.onClose,e.visible!==!1);const r=e;return i.jsxs("aside",{"data-notes-pane":"",style:{width:"100%",flex:1,background:"var(--proto-card)",boxShadow:"var(--shadow-side-panel)",display:"flex",flexDirection:"column",minHeight:0},children:[i.jsx(HTe,{copy:e.copy,activeCount:e.vm.activeCount,headerIcon:e.headerIcon,headerAction:e.headerAction,onClose:e.onClose}),i.jsx(zTe,{copy:e.copy,busy:e.busy,onAdd:e.onAdd}),i.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"10px 14px 14px"},children:[i.jsxs("div",{style:{padding:"6px 2px 7px",fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)"},children:[e.copy.todo," · ",e.vm.activeCount]}),e.vm.active.map(o=>i.jsx($Te,{row:o,copy:e.copy,busy:e.busy,actions:r,targeted:o.id===e.targetId,onSelect:e.onSelect},o.id)),e.vm.active.length===0&&i.jsx("div",{style:{padding:"14px 10px",fontSize:11,color:"var(--proto-faint)"},children:e.copy.empty}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 2px 7px",borderTop:"1px solid var(--proto-line-2)",marginTop:6},children:[i.jsxs("button",{type:"button",onClick:()=>n(o=>!o),style:{border:0,background:"transparent",padding:0,fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)",cursor:"pointer"},children:[e.copy.completed," · ",e.vm.completedCount," ",t?"▾":"▸"]}),e.vm.completedCount>0&&i.jsx("button",{type:"button",disabled:e.busy,onClick:()=>void e.onClearCompleted(),style:{marginLeft:"auto",border:0,background:"transparent",color:"var(--proto-danger)",fontSize:10.5,fontWeight:600,cursor:"pointer"},children:e.copy.clear})]}),t&&e.vm.completed.map(o=>i.jsx(_Te,{row:o,busy:e.busy,onReopen:()=>void e.onSetCompleted(o.id,!1)},o.id))]}),i.jsx("div",{style:{padding:"9px 16px",borderTop:"1px solid var(--proto-line-2)",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:e.copy.privateHint})]})}function VTe(e={}){const t=j1(),n=Xe();return i.jsx(UTe,{...e,vm:t.vm,copy:t.copy,busy:t.busy,targetId:t.targetId,onSelect:t.open,onClose:t.close,onAdd:t.add,onUpdate:t.update,onSetCompleted:t.setCompleted,onDelete:t.remove,onHandoff:r=>{t.handoff(r),n("/workbench")},onClearCompleted:t.clearCompleted})}const qTe=400,NU=42,KTe={threads:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M8 6h11M8 12h8M8 18h5"}),i.jsx("circle",{cx:"4",cy:"6",r:"1"}),i.jsx("circle",{cx:"4",cy:"12",r:"1"}),i.jsx("circle",{cx:"4",cy:"18",r:"1"})]}),tasks:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"3"}),i.jsx("path",{d:"m8 12 2.5 2.5L16 9"})]}),machines:i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"4",y:"4",width:"16",height:"6",rx:"2"}),i.jsx("rect",{x:"4",y:"14",width:"16",height:"6",rx:"2"}),i.jsx("path",{d:"M8 7h.01M8 17h.01M12 7h5M12 17h5"})]}),notes:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M6 3h9l4 4v14H6z"}),i.jsx("path",{d:"M15 3v5h4M9 12h6M9 16h6"})]})};function Bk({target:e,size:t=14}){return i.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",width:t,height:t,fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:KTe[e]})}function VE({target:e,label:t,active:n,onClick:r}){return i.jsx("button",{type:"button","aria-label":t,"aria-pressed":n,title:t,onClick:r,style:{width:30,height:30,border:`1px solid ${n?"var(--proto-line)":"transparent"}`,borderRadius:7,background:n?"var(--proto-card)":"transparent",boxShadow:n?"inset 2px 0 var(--proto-accent)":"none",color:n?"var(--proto-accent)":"var(--proto-muted-2)",display:"grid",placeItems:"center",padding:0,cursor:"pointer"},children:i.jsx(Bk,{target:e,size:15})})}function GTe({active:e,labels:t,navigationLabel:n,expandLabel:r,onExpand:o,onSelect:s}){const a=["threads","tasks","machines"];return i.jsxs("nav",{"aria-label":n,style:{width:NU-1,flex:1,minHeight:0,display:"flex",flexDirection:"column",alignItems:"center",gap:4,padding:"7px 0 8px"},children:[i.jsx(RU,{side:"right",expanded:!1,label:r,onClick:o}),i.jsx("div",{"aria-hidden":"true",style:{width:20,height:1,background:"var(--proto-line)",margin:"3px 0"}}),a.map(l=>i.jsx(VE,{target:l,label:t[l],active:e===l,onClick:()=>s(l)},l)),i.jsx("div",{style:{marginTop:"auto"},children:i.jsx(VE,{target:"notes",label:t.notes,active:e==="notes",onClick:()=>s("notes")})})]})}function O1(){const e=O(),t=j1(),[n,r]=f.useState("threads"),{panelCollapsed:o,setPanelCollapsed:s}=C1();f.useEffect(()=>{t.isOpen&&s(!1)},[t.isOpen,s]);const a=t.isOpen?"notes":n,l={threads:e.threads,tasks:e.tasks,machines:e.machines,notes:t.copy.title},c=u=>{if(s(!1),u==="notes")return t.open();t.close(),r(u)},d=i.jsx(RU,{side:"right",expanded:!0,label:e.rpCollapsePanel,onClick:()=>s(!0)});return i.jsxs("aside",{"data-pane":"right","data-collapsed":o||void 0,style:{width:o?NU:qTe,transition:"width 220ms cubic-bezier(0.22, 1, 0.36, 1)",flex:"none",background:"var(--proto-rail)",borderLeft:"1px solid var(--proto-line)",display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[o&&i.jsx(GTe,{active:a,labels:l,navigationLabel:e.rpPanelNavigation,expandLabel:e.rpExpandPanel,onExpand:()=>s(!1),onSelect:c}),i.jsx("div",{style:{display:o?"none":"flex",flex:1,minHeight:0,width:"100%"},children:t.isOpen?i.jsx(VTe,{headerIcon:i.jsx(Bk,{target:"notes"}),headerAction:d,visible:!o}):i.jsx(nPe,{tab:n,onTabChange:r,headerAction:d})})]})}function Qb({target:e,label:t,count:n,countColor:r,active:o,dot:s,onClick:a}){return i.jsxs("button",{type:"button","aria-pressed":o,onClick:a,style:{fontFamily:"inherit",fontSize:12,fontWeight:o?600:500,color:o?"var(--proto-ink)":"var(--proto-muted-2)",padding:"13px 0 11px",border:0,borderBottom:"2px solid "+(o?"var(--proto-ink)":"transparent"),marginBottom:-1,background:"transparent",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:5},children:[i.jsx(Bk,{target:e,size:13}),t,s&&i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",display:"inline-block"}}),i.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:r},children:n})]})}const YTe={fontSize:11.5,fontWeight:700,letterSpacing:".06em",textTransform:"uppercase",color:"var(--proto-muted)",padding:"8px 2px 4px"};function QTe({group:e,label:t,now:n}){return i.jsxs("section",{children:[i.jsxs("div",{style:YTe,children:[t," · ",e.threads.length]}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:e.threads.map(r=>i.jsx(xTe,{thread:r,now:n},r.id))})]})}function XTe(e){var u,p,h;const t=he(),{currentProjectId:n}=zt(),r=n??void 0,o=LU(e==="threads");zk();const s=ae({...t.cost.summary.queryOptions({projectId:r}),enabled:!!r}),a=ae(t.threads.list.queryOptions({projectId:r})),l=ae(t.tasks.list.queryOptions({...r?{projectId:r}:{}})),c=lh(),d=DU(a.data??[]);return{projectId:r,now:o,threadGroups:d,threadsReady:a.isSuccess,activeThreadCount:((u=d.find(m=>m.kind==="active"))==null?void 0:u.threads.length)??0,openTaskCount:l.data?K9e(l.data):0,machineCount:cCe(c.machines),budget:tCe((p=s.data)==null?void 0:p.today,(h=s.data)==null?void 0:h.dailyBudget)}}function ZTe({tab:e,counts:t,headerAction:n,onTabChange:r}){const o=O();return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"0 10px 0 18px",borderBottom:"1px solid var(--proto-line)",flex:"none"},children:[i.jsx(Qb,{target:"threads",label:o.threads,count:String(t.threads),countColor:"var(--proto-accent)",active:e==="threads",onClick:()=>r("threads")}),i.jsx(Qb,{target:"tasks",label:o.tasks,count:String(t.tasks),countColor:"var(--proto-muted-2)",active:e==="tasks",onClick:()=>r("tasks")}),i.jsx(Qb,{target:"machines",label:o.machines,count:String(t.machines),countColor:"var(--proto-muted-2)",active:e==="machines",dot:!0,onClick:()=>r("machines")}),i.jsx("div",{style:{marginLeft:"auto"},children:n})]})}function JTe({budget:e}){const t=O();return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 18px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[i.jsx("span",{style:{fontSize:10.5,fontWeight:600,color:"var(--proto-muted-2)"},children:t.today}),i.jsx("div",{style:{flex:1,height:4,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:i.jsx("div",{style:{width:`${e.percent}%`,height:"100%",borderRadius:999,background:"var(--proto-accent)"}})}),i.jsxs("span",{style:{font:"500 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:[e.todayLabel," / ",e.limitLabel]})]})}function ePe({groups:e,ready:t,now:n}){const r=O();return i.jsxs("div",{style:{flex:1,padding:"12px 16px",display:"flex",flexDirection:"column",gap:6,overflow:"auto",minHeight:0},children:[e.map(o=>i.jsx(QTe,{group:o,label:o.kind==="active"?r.active:r.history,now:n},o.kind)),t&&e.length===0&&i.jsxs("div",{style:{textAlign:"center",padding:"26px 12px",border:"1px dashed var(--proto-line)",borderRadius:10},children:[i.jsx("div",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-muted-2)"},children:r.rpNoActiveThreads}),i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",marginTop:4,lineHeight:1.6},children:r.rpNoActiveThreadsHint})]})]})}function tPe({projectId:e}){return i.jsx("div",{style:{flex:1,padding:"12px 16px",display:"flex",flexDirection:"column",gap:6,overflow:"auto",minHeight:0},children:i.jsx(EU,{projectId:e})})}function nPe({tab:e,headerAction:t,onTabChange:n}){const r=XTe(e),o={threads:r.activeThreadCount,tasks:r.openTaskCount,machines:r.machineCount};return i.jsxs("div",{style:{width:"100%",flex:1,background:"var(--proto-rail)",display:"flex",flexDirection:"column",minHeight:0},children:[i.jsx(ZTe,{tab:e,counts:o,headerAction:t,onTabChange:n}),i.jsx(JTe,{budget:r.budget}),e==="threads"&&i.jsx(ePe,{groups:r.threadGroups,ready:r.threadsReady,now:r.now}),e==="tasks"&&i.jsx(tPe,{projectId:r.projectId}),e==="machines"&&i.jsx(ATe,{})]})}const rPe="'IBM Plex Mono',monospace",qE=30;function FU({node:e,onRun:t}){const n=S_(),[r,o]=f.useState(!1),[s,a]=f.useState(!1);return e.kind==="separator"?i.jsx("div",{style:{height:1,background:"var(--proto-line)",margin:"5px 8px"}}):e.kind==="submenu"?i.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[i.jsxs("div",{style:KE(s,!1),children:[i.jsx("span",{style:{width:14}}),i.jsx("span",{children:e.label}),i.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-muted-3)"},children:"›"})]}),s&&i.jsx("div",{style:{...zU,position:"absolute",left:"100%",top:-5,minWidth:168},children:e.items.map((l,c)=>i.jsx(FU,{node:l,onRun:t},l.kind==="item"?l.id:`sep-${c}`))})]}):i.jsxs("div",{role:"menuitem","aria-disabled":e.disabled||void 0,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onClick:l=>{l.stopPropagation(),!e.disabled&&(e.run(),t())},style:KE(r&&!e.disabled,!!e.disabled),children:[i.jsx("span",{style:{width:14,textAlign:"center",color:"inherit"},children:e.checked?"✓":""}),i.jsx("span",{children:e.label}),e.accel&&i.jsx("span",{style:{marginLeft:"auto",font:`500 10px ${rPe}`,opacity:r&&!e.disabled?.8:1,color:r&&!e.disabled?"inherit":"var(--proto-muted-3)"},children:j_(e.accel,n)})]})}function KE(e,t){return{display:"flex",alignItems:"center",gap:10,height:27,padding:"0 9px",borderRadius:6,fontSize:12.5,whiteSpace:"nowrap",cursor:t?"default":"pointer",color:t?"var(--proto-line-3)":e?"var(--ink-solid-fg)":"var(--proto-ink)",background:e?"var(--proto-accent)":"transparent"}}const zU={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"var(--shadow-menu-strong)",padding:5,minWidth:238,zIndex:60};function oPe({menus:e}){const[t,n]=f.useState(null),r=f.useRef(null);return f.useEffect(()=>{if(!t)return;const o=a=>{a.key==="Escape"&&n(null)},s=()=>n(null);return window.addEventListener("keydown",o),window.addEventListener("click",s),()=>{window.removeEventListener("keydown",o),window.removeEventListener("click",s)}},[t]),i.jsx("div",{ref:r,style:{display:"flex",alignItems:"center",gap:2,flex:"none"},children:e.map(o=>{const s=t===o.id;return i.jsxs("div",{style:{position:"relative"},children:[i.jsx("button",{type:"button","aria-haspopup":"menu","aria-expanded":s,onClick:a=>{a.stopPropagation(),n(s?null:o.id)},onMouseEnter:()=>{t&&n(o.id)},style:{height:qE,padding:"0 11px",border:0,borderRadius:7,fontFamily:"inherit",fontSize:13,cursor:"pointer",background:s?"var(--proto-line-2)":"transparent",color:s?"var(--proto-ink)":"var(--proto-muted)"},children:o.label}),s&&i.jsx("div",{role:"menu",onClick:a=>a.stopPropagation(),"data-tauri-drag-region":"false",style:{...zU,position:"absolute",left:0,top:qE+10},children:o.items.map((a,l)=>i.jsx(FU,{node:a,onRun:()=>n(null)},a.kind==="item"||a.kind==="submenu"?a.id:`sep-${l}`))})]},o.id)})})}const iPe=/^(input|textarea)$/i,sPe=new Set(["edit.palette","file.newSession","view.fullscreen"]);function aPe(e){return e instanceof HTMLElement?iPe.test(e.tagName)||e.isContentEditable:!1}function lPe(e,t=!0){f.useEffect(()=>{if(!t)return;const n=T_(e),r=o=>{if(o.repeat)return;const s=aPe(o.target);for(const a of n)if(!(a.disabled||a.accelDisplayOnly)&&!(s&&!sPe.has(a.id))&&K5e(o,a.accel)){o.preventDefault(),a.run();return}};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t])}function BU(e){return e.kind==="separator"?{kind:"separator"}:e.kind==="submenu"?{kind:"submenu",id:e.id,label:e.label,items:e.items.map(BU)}:{kind:"item",id:e.id,label:e.label,accelerator:e.accel?Y5e(e.accel):void 0,role:e.role,checked:e.checked,enabled:!e.disabled}}function cPe(e){const[t,n]=f.useState(!1),r=f.useRef(e);r.current=e;const o=f.useMemo(()=>({menus:e.map(a=>({kind:"submenu",id:a.id,label:a.label,items:a.items.map(BU)}))}),[e]),s=f.useMemo(()=>JSON.stringify(o),[o]);return f.useEffect(()=>{let a=!0;return bt("set_native_menu",{spec:JSON.parse(s)}).then(l=>{a&&l.ok&&n(l.value)}),()=>{a=!1}},[s]),f.useEffect(()=>{let a;return x1("native-menu",l=>{if(typeof l!="string")return;const c=C_(r.current).find(d=>d.id===l);c&&!c.disabled&&c.run()}).then(l=>{a=l}),()=>a==null?void 0:a()},[]),{active:t}}const dPe={minimize:"",maximize:"",restore:"",close:""};function Xb({name:e}){if(_S()==="windows")return i.jsx("span",{style:{fontFamily:"'Segoe Fluent Icons','Segoe MDL2 Assets',sans-serif",fontSize:10},children:dPe[e]});const t={fill:"none",stroke:"currentColor",strokeWidth:1.2};return i.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 12 12","aria-hidden":"true",children:[e==="minimize"&&i.jsx("line",{x1:"1.5",y1:"6",x2:"10.5",y2:"6",...t}),e==="maximize"&&i.jsx("rect",{x:"1.8",y:"1.8",width:"8.4",height:"8.4",...t}),e==="restore"&&i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"1.5",y:"3.4",width:"7",height:"7",...t}),i.jsx("path",{d:"M3.9 3.4V1.5h6.6v6.6H8.6",...t})]}),e==="close"&&i.jsx("path",{d:"M2 2l8 8M10 2l-8 8",...t})]})}function Zb({label:e,danger:t,onClick:n,children:r}){const[o,s]=f.useState(!1);return i.jsx("button",{type:"button","aria-label":e,title:e,onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:46,alignSelf:"stretch",border:0,padding:0,cursor:"default",display:"grid",placeItems:"center",background:o?t?"var(--caption-close-hover)":"var(--caption-hover)":"transparent",color:o&&t?"var(--caption-close-hover-fg)":"var(--proto-ink)"},children:r})}function $U({actions:e}){const t=O();return i.jsxs("div",{style:{display:"flex",flex:"none",alignSelf:"stretch"},children:[i.jsx(Zb,{label:t.winMinimize,onClick:e.minimize,children:i.jsx(Xb,{name:"minimize"})}),i.jsx(Zb,{label:e.isMaximized?t.winRestore:t.winMaximize,onClick:e.toggleMaximize,children:i.jsx(Xb,{name:e.isMaximized?"restore":"maximize"})}),i.jsx(Zb,{label:t.winClose,danger:!0,onClick:e.close,children:i.jsx(Xb,{name:"close"})})]})}const uPe=34;function Jb({label:e,active:t,disabled:n,onClick:r,children:o}){const[s,a]=f.useState(!1),l=n?"var(--proto-line-3)":t||s?"var(--proto-ink)":"var(--proto-muted-2)";return i.jsx("button",{type:"button","aria-label":e,title:e,disabled:n,onClick:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:30,height:30,border:0,borderRadius:7,padding:0,display:"grid",placeItems:"center",cursor:n?"default":"pointer",color:l,background:t&&!n?"var(--proto-line-2)":"transparent",flex:"none"},children:o})}const _U={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"};function pPe(){return i.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24","aria-hidden":"true",..._U,children:[i.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2.5"}),i.jsx("line",{x1:"9.5",y1:"4",x2:"9.5",y2:"20"})]})}function GE({forward:e}){return i.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24","aria-hidden":"true",..._U,children:i.jsx("path",{d:e?"M5 12h14M13 6l6 6-6 6":"M19 12H5M11 6l-6 6 6 6"})})}function fPe(){const e=O(),t=C1(),n=D5e(),{menus:r,windowActions:o}=M_(),s=cPe(r);lPe(r,!s.active);const a=WS(),l={height:uPe,boxSizing:"border-box",flex:"none",display:o.isFullscreen?"none":"flex",alignItems:"center",background:"var(--proto-rail)",borderBottom:"1px solid var(--proto-line)"};return i.jsxs("div",{style:l,"data-app-topbar":!0,"data-tauri-drag-region":"deep",children:[i.jsx("div",{style:{width:k_(),flex:"none"}}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2,flex:"none",paddingLeft:a==="overlay"?0:12},children:[i.jsx(Jb,{label:e.tbToggleRail,active:!t.railCollapsed,onClick:t.toggleRail,children:i.jsx(pPe,{})}),i.jsx(Jb,{label:e.tbBack,disabled:!n.canBack,onClick:n.back,children:i.jsx(GE,{})}),i.jsx(Jb,{label:e.tbForward,disabled:!n.canForward,onClick:n.forward,children:i.jsx(GE,{forward:!0})})]}),!s.active&&i.jsx("div",{style:{marginLeft:14,flex:"none"},children:i.jsx(oPe,{menus:r})}),i.jsx("div",{style:{flex:1,alignSelf:"stretch",minWidth:20}}),a==="custom"&&i.jsx($U,{actions:o})]})}function N1({children:e}){return i.jsxs("div",{style:{height:"100dvh",minHeight:0,minWidth:0,display:"flex",flexDirection:"column",background:"var(--proto-card)",overflow:"hidden"},children:[i.jsx(fPe,{}),i.jsx("div",{"data-app-panes":!0,style:{flex:1,display:"flex",minHeight:0,overflow:"hidden"},children:e})]})}function hPe(){const{active:e,split:t}=Ic(),{open:n}=t1();return i.jsxs(N1,{children:[i.jsx(A1,{}),i.jsx(W9e,{grow:e?1-t:1,onOpenSettings:n}),i.jsx(z7e,{}),i.jsx(O1,{})]})}function mPe(){const e=O();return i.jsxs("section",{className:"flex h-full flex-col p-2g",children:[i.jsx("h1",{className:"mb-2g text-body font-medium text-state-ink",children:e.tasks}),i.jsx(EU,{})]})}function gPe(){return i.jsx(Px,{severity:"waiting",pulse:!0,title:"Rate limit reached — 3 items auto-paused",meta:"resets 14:00 · 2h 08m",children:i.jsxs("div",{className:"flex flex-col gap-1g",children:[i.jsx(e2,{label:"session morning-review — paused",note:"auto-resumes after reset"}),i.jsx(e2,{label:"schedule inbox-sweep — paused",note:"pausedBy: rate-limit"}),i.jsx(e2,{label:"task dispatch — held by guard, queue kept",note:"beforeRunGuard",muted:!0})]})})}function e2({label:e,note:t,muted:n}){return i.jsxs("div",{className:"flex items-center gap-1g rounded-card border border-card px-1.5g py-1g",children:[i.jsx("span",{className:["h-0.5g w-0.5g flex-none rounded-full",n?"bg-state-gray":"bg-state-wait"].join(" ")}),i.jsx("span",{className:"text-ui text-state-ink/80",children:e}),i.jsx(Fr,{muted:!0,className:"ml-auto text-ui",children:t})]})}function vPe(){return i.jsxs(Px,{severity:"info",title:"step 3 · executor:analyze",meta:"fallback chain from profiles.json",children:[i.jsxs("div",{className:"flex flex-col gap-0.5g font-mono text-ui",children:[i.jsxs("div",{className:"flex gap-1g",children:[i.jsx("span",{className:"flex-none text-pill-failed-fg",children:"✕"}),i.jsx("span",{className:"text-state-ink/70",children:"claude · print — transient backend error (exit 1)"})]}),i.jsxs("div",{className:"flex gap-1g",children:[i.jsx("span",{className:"flex-none text-pill-done-fg",children:"→"}),i.jsxs("span",{className:"text-state-ink/80",children:["fallback ",i.jsx("span",{className:"text-pill-running-fg",children:"pi"})," — inherits main profile, step re-run"]})]}),i.jsxs("div",{className:"flex gap-1g",children:[i.jsx("span",{className:"flex-none text-state-ink/30",children:" "}),i.jsx("span",{className:"text-state-ink/40",children:"artifact.md untouched · completed steps not re-run"})]})]}),i.jsx("div",{className:"flex items-center gap-1g",children:i.jsx(dv,{tone:"running",label:"● retrying"})})]})}function xPe(){return i.jsx(Px,{severity:"human",title:i.jsxs("span",{className:"flex items-center gap-1g",children:[i.jsx(Fr,{children:"gpu-01"}),i.jsx(dv,{tone:"failed",label:"offline"})]}),meta:"last seen 09:12 · ws closed",detail:i.jsxs("div",{className:"flex flex-col gap-1g",children:[i.jsxs("div",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g font-mono text-ui text-state-ink/70",children:["exec_31c2 → ",i.jsx("span",{className:"text-pill-failed-fg",children:"lost"})," (3 missed heartbeats) · thread notified"]}),i.jsx("div",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g font-mono text-ui text-state-ink/70",children:"T-045 pending held · 4h no callback auto-clears tracking · reopenable"})]}),actions:i.jsxs(i.Fragment,{children:[i.jsx(cn,{variant:"primary",size:"sm",children:"Reopen task"}),i.jsx("span",{className:"self-center text-ui text-state-ink/50",children:"cortex-client auto-reconnects; run state re-read from state file"})]})})}function yPe(){return i.jsx(Px,{severity:"waiting",pulse:!0,title:"Thread paused — would exceed today's budget",meta:"waiting",detail:i.jsxs("span",{children:["Next dispatch est. ",i.jsx(Fr,{children:"$6.40"}),", remaining today"," ",i.jsx(Fr,{className:"text-pill-failed-fg",children:"$1.10"})," — pre-check held it before dispatch; approval queued ",i.jsx(R4,{value:"APR-0008"})]}),actions:i.jsxs(i.Fragment,{children:[i.jsx(cn,{variant:"primary",size:"sm",children:"Approve once"}),i.jsx(cn,{variant:"secondary",size:"sm",children:"Reject"}),i.jsx(cn,{variant:"secondary",size:"sm",children:"Adjust budget…"})]})})}function bPe(){return i.jsxs("div",{className:"grid grid-cols-1 gap-2g md:grid-cols-2",children:[i.jsx(gPe,{}),i.jsx(vPe,{}),i.jsx(xPe,{}),i.jsx(yPe,{})]})}const wPe=["running","waiting","completed","failed","cancelled","aborted","stale","open","done"],YE=["primary","secondary","ghost","danger"];function Gc({title:e,children:t}){return i.jsxs("section",{className:"flex flex-col gap-2g",children:[i.jsx(ed,{title:e}),i.jsx(M4,{padded:!0,children:i.jsx("div",{className:"flex flex-wrap items-center gap-2g",children:t})})]})}function SPe(){return i.jsxs("div",{className:"flex h-full flex-col gap-4g overflow-auto p-2g pb-6g",children:[i.jsx(ed,{title:"Design Kit",description:"Token-driven core primitives (design §5). All colors from tailwind tokens."}),i.jsx(Gc,{title:"StatusPill — tones",children:cX.map(e=>i.jsx(dv,{tone:e,label:e},e))}),i.jsx(Gc,{title:"StatusPill — contract statuses",children:wPe.map(e=>i.jsx(dv,{status:e},e))}),i.jsxs(Gc,{title:"MonoText & ID",children:[i.jsx(Fr,{children:"mono-text"}),i.jsx(Fr,{muted:!0,children:"mono-text muted"}),i.jsx(R4,{value:"thr_99a13064"}),i.jsx(R4,{value:"e794",copyable:!0})]}),i.jsxs(Gc,{title:"Button — variants × sizes",children:[YE.map(e=>i.jsx(cn,{variant:e,size:"md",children:e},e)),YE.map(e=>i.jsxs(cn,{variant:e,size:"sm",children:[e," sm"]},`${e}-sm`)),i.jsx(cn,{variant:"primary",disabled:!0,children:"disabled"})]}),i.jsx(Gc,{title:"Tooltip",children:i.jsx(eee,{content:"I am a token-styled tooltip",children:i.jsx(cn,{variant:"secondary",children:"Hover me"})})}),i.jsxs("section",{className:"flex flex-col gap-2g",children:[i.jsx(ed,{title:"Card + header/body",count:2}),i.jsxs(M4,{children:[i.jsx(fX,{children:i.jsx(Fr,{children:"card-header"})}),i.jsx(hX,{children:i.jsx("p",{className:"text-ui text-state-ink/70",children:"Card body content sits on the white surface."})})]})]}),i.jsxs("section",{className:"flex flex-col gap-2g",children:[i.jsx(ed,{title:"Tabs"}),i.jsx(M4,{padded:!0,children:i.jsx(sZ,{items:[{value:"one",label:"Overview",content:i.jsx(Fr,{children:"panel one"})},{value:"two",label:"Details",content:i.jsx(Fr,{children:"panel two"})},{value:"three",label:"Logs",content:i.jsx(Fr,{children:"panel three"})}]})})]}),i.jsxs("section",{className:"flex flex-col gap-2g",children:[i.jsx(ed,{title:"Degraded states (10c)",description:"Unified exception language — amber=waiting, red=needs-human, blue=transient note."}),i.jsx(bPe,{})]}),i.jsxs("section",{className:"flex flex-col gap-2g",children:[i.jsx(ed,{title:"Empty states (10d)",description:"Every empty panel points to a next action — no dead wall."}),i.jsxs("div",{className:"grid grid-cols-1 gap-2g md:grid-cols-3",children:[i.jsx(fg,{title:"Give Cortex a mission",description:"Describe a goal and success criteria — planning, dispatch and record-keeping follow.",action:i.jsxs("div",{className:"flex w-full flex-col gap-1g",children:[i.jsx("span",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g text-left text-ui text-state-ink/60",children:'"Scan arXiv sim2real each morning and summarize"'}),i.jsx("span",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g text-left text-ui text-state-ink/60",children:'"Finish the σ ablation and find the seed-variance root cause"'})]})}),i.jsx(fg,{title:"No tasks yet",description:"Set a goal in chat and Cortex decomposes a queue with priority, deps and done-when.",action:i.jsx(cn,{variant:"primary",children:"+ Add task"})}),i.jsx(fg,{title:"No threads yet",description:"Complex work runs as multi-agent relay pipelines here — created on dispatch.",action:i.jsx(Fr,{muted:!0,children:"!thread experiment-pipeline 〈goal〉"})})]})]}),i.jsx(Gc,{title:"Overlays — Modal / Drawer / Toast / Popover (esc closes, focus trapped)",children:i.jsx(kPe,{})})]})}function kPe(){const{toast:e}=Fn();return i.jsxs(i.Fragment,{children:[i.jsx(ur,{title:"Task detail",description:"Radix Dialog: focus is trapped while open, Esc closes, focus returns to the trigger.",trigger:i.jsx(cn,{variant:"primary",children:"Open Modal"}),footer:i.jsx(aL,{asChild:!0,children:i.jsx(cn,{variant:"secondary",children:"Close"})}),children:i.jsx("p",{children:"Body content on the white token surface. Try Tab / Shift-Tab and Esc."})}),i.jsx(fte,{title:"Details drawer",description:"Side sheet on Radix Dialog — slides in from the right, Esc closes.",trigger:i.jsx(cn,{variant:"secondary",children:"Open Drawer"}),footer:i.jsx(hte,{asChild:!0,children:i.jsx(cn,{variant:"secondary",children:"Close"})}),children:i.jsx("p",{children:"Full-height drawer content. Same a11y as Modal."})}),i.jsx(cn,{variant:"secondary",onClick:()=>e({title:"Task completed",description:"c407 moved open → done",tone:"done"}),children:"Fire Toast"}),i.jsx(yL,{trigger:i.jsx(cn,{variant:"secondary",children:"Open Popover"}),children:i.jsxs("div",{className:"flex flex-col gap-1g",children:[i.jsx(Fr,{children:"popover content"}),i.jsx("p",{className:"text-state-ink/70",children:"Positioned by Radix; Esc closes, focus returns."})]})})]})}const jPe=[{name:"base",hex:"var(--surface-base)"},{name:"card",hex:"var(--proto-card)"},{name:"rail",hex:"var(--proto-rail)"},{name:"alt",hex:"var(--proto-alt)"},{name:"gray",hex:"var(--proto-gray)"},{name:"ink",hex:"var(--proto-ink)",dark:!0},{name:"ink-2",hex:"var(--proto-ink-2)",dark:!0},{name:"ink-3",hex:"var(--proto-ink-3)",dark:!0},{name:"muted",hex:"var(--proto-muted)",dark:!0},{name:"muted-2",hex:"var(--proto-muted-2)",dark:!0},{name:"muted-3",hex:"var(--proto-muted-3)",dark:!0},{name:"faint",hex:"var(--proto-faint)"},{name:"line",hex:"var(--proto-line)"},{name:"line-2",hex:"var(--proto-line-2)"},{name:"line-3",hex:"var(--proto-line-3)"},{name:"line-4",hex:"var(--proto-line-4)"},{name:"accent",hex:"var(--proto-accent)",dark:!0},{name:"accent-bg",hex:"var(--proto-accent-bg)"},{name:"accent-border",hex:"var(--proto-accent-border)"},{name:"accent-2",hex:"var(--proto-accent-2)",dark:!0},{name:"accent-strong",hex:"var(--proto-accent-strong)",dark:!0},{name:"amber",hex:"var(--proto-amber)",dark:!0},{name:"amber-fg",hex:"var(--proto-amber-fg)",dark:!0},{name:"amber-bg",hex:"var(--proto-amber-bg)"},{name:"amber-border",hex:"var(--proto-amber-border)"},{name:"amber-accent",hex:"var(--proto-amber-accent)",dark:!0},{name:"success",hex:"var(--proto-success)",dark:!0},{name:"success-bg",hex:"var(--proto-success-bg)"},{name:"danger",hex:"var(--proto-danger)",dark:!0},{name:"danger-bg",hex:"var(--proto-danger-bg)"}],CPe=["cxblink","cxpulse","cxtoast","cxfade","cxmodal","cxcmdk","cxpop","cxpopup","cxpopover","cxdrawer","cxmodalout","cxcmdkout","cxdrawerout","cxfadeout","cxmsg","cxrise"],TPe=["9px","10px","10.5px","11px","12px","15px"];function Km({children:e}){return i.jsx("div",{style:{fontSize:"10px",fontWeight:700,letterSpacing:"0.07em",color:"var(--proto-faint)",textTransform:"uppercase",margin:"28px 0 12px"},children:e})}function PPe(){return i.jsxs("div",{style:{padding:"24px 28px",background:"var(--proto-card)",minHeight:"100%",overflow:"auto"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"9px"},children:[i.jsx("div",{style:{width:26,height:26,borderRadius:7,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",font:"600 12px 'IBM Plex Mono',monospace"},children:"cx"}),i.jsx("div",{style:{fontWeight:650,fontSize:14,color:"var(--proto-ink)",letterSpacing:"-0.01em"},children:"Cortex — base specimen"})]}),i.jsx(Km,{children:"Sans (UI)"}),i.jsxs("div",{style:{fontFamily:"inherit",color:"var(--proto-ink)"},children:[i.jsx("div",{style:{fontSize:14,fontWeight:650,letterSpacing:"-0.01em"},children:"Interface heading — 14px / 650"}),i.jsx("div",{style:{fontSize:13,fontWeight:600,marginTop:4},children:"Section label — 13px / 600"}),i.jsx("div",{style:{fontSize:12.5,fontWeight:400,color:"var(--proto-muted)",marginTop:4},children:"Body copy — 12.5px / 400 · The quick brown fox jumps over the lazy dog. 中文界面文字样张。"})]}),i.jsx(Km,{children:"Mono (data / IDs) — IBM Plex Mono"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:TPe.map(e=>i.jsxs("div",{style:{font:`500 ${e} 'IBM Plex Mono',monospace`,color:"var(--proto-ink)"},children:["thr_502fb888 · 6d21 · $2.64 · 3m 27s — ",e]},e))}),i.jsx(Km,{children:"Palette (audited prototype colors)"}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(120px, 1fr))",gap:8},children:jPe.map(e=>i.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:8,overflow:"hidden"},children:[i.jsx("div",{style:{height:40,background:e.hex,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:5},children:i.jsx("span",{style:{font:"500 8.5px 'IBM Plex Mono',monospace",color:e.dark?"var(--proto-card)":"var(--proto-muted-3)"},children:e.hex})}),i.jsx("div",{style:{padding:"5px 7px",fontSize:11,fontWeight:600,color:"var(--proto-ink-2)",background:"var(--proto-card)"},children:e.name})]},e.name))}),i.jsx(Km,{children:"Animations — running dot · caret · enter set"}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:20,marginBottom:16},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-accent)",display:"inline-block",animation:"cxpulse 1.6s ease-in-out infinite"}}),i.jsx("span",{style:{fontSize:12,color:"var(--proto-accent)",fontWeight:600},children:"running (cxpulse)"})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-amber)",display:"inline-block",animation:"cxpulse 2s ease-in-out infinite"}}),i.jsx("span",{style:{fontSize:12,color:"var(--proto-amber-fg)",fontWeight:600},children:"approval (cxpulse 2s)"})]}),i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:2},children:[i.jsx("span",{style:{font:"500 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:"cortex"}),i.jsx("span",{style:{display:"inline-block",width:7,height:14,background:"var(--proto-ink)",animation:"cxblink 1.1s steps(1) infinite"}}),i.jsx("span",{style:{fontSize:12,color:"var(--proto-muted-3)",marginLeft:6},children:"caret (cxblink)"})]})]}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(110px, 1fr))",gap:8},children:CPe.map(e=>i.jsx("div",{style:{border:"1px solid var(--proto-line)",borderRadius:8,padding:"10px 8px",textAlign:"center",background:"var(--proto-rail)",animation:`${e} 1.6s ease-in-out infinite`},children:i.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:e})},e))})]})}function EPe({copy:e,onAdd:t}){const[n,r]=f.useState(""),o=async s=>{s.preventDefault(),s.stopPropagation();const a=n.trim();a&&(await t(a),r(""))};return i.jsx("form",{onSubmit:o,onClick:s=>s.stopPropagation(),style:{margin:"10px 14px 2px"},children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"7px 10px"},children:[i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),i.jsx("input",{value:n,onChange:s=>r(s.target.value),placeholder:e.inputPlaceholder,"aria-label":e.inputPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:11.5,color:"var(--proto-ink)"}}),i.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",border:"1px solid var(--proto-line-2)",borderRadius:4,padding:"1px 5px"},children:e.enter})]})})}function RPe({row:e,onOpen:t}){return i.jsxs("div",{onClick:n=>{n.stopPropagation(),t(e.id)},style:{display:"flex",alignItems:"center",gap:9,padding:"8px 0",borderBottom:"1px solid var(--proto-alt)",cursor:"pointer"},children:[i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),i.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:e.text}),i.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.timeLabel})]})}function MPe({vm:e,copy:t,onOpen:n,onAdd:r}){return i.jsxs("div",{"data-notes-overview-card":"",onClick:()=>n(),style:{background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"var(--shadow-card-subtle)",cursor:"pointer",minWidth:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[i.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:t.title}),i.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:"context/NOTES.md"})]}),i.jsx(EPe,{copy:t,onAdd:r}),i.jsxs("div",{style:{padding:"2px 14px 6px"},children:[e.previews.map(o=>i.jsx(RPe,{row:o,onOpen:n},o.id)),e.activeCount===0&&i.jsx("div",{style:{padding:"12px 0",color:"var(--proto-faint)",fontSize:10.5},children:t.empty})]}),i.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"9px 14px",display:"flex",alignItems:"center",fontSize:11,fontWeight:600,color:"var(--proto-accent)"},children:[i.jsxs("span",{children:[t.viewAll," ",e.activeCount," ›"]}),i.jsxs("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:[t.completed," ",e.completedCount]})]})]})}function rr(e){return yn(e??0)}const IPe=5;function WU(e,t){if(t==null||t<=0)return null;const n=(e??0)/t*100;return Math.max(0,Math.min(100,n))}function APe(e){return e==null||e<=0?"—":rr(e)}function DPe(e){if(!e||e.length===0)return[];const t=e.reduce((r,o)=>Math.max(r,o.cost),0),n=e.length-1;return e.map((r,o)=>({pct:t>0?r.cost/t*100:0,date:r.date,cost:r.cost,isToday:o===n}))}function LPe(e){return!e||e.length===0?null:e.reduce((n,r)=>n+r.cost,0)/e.length}function OPe(e,t="week"){if(!e)return[];const n=Object.entries(e).map(([o,s])=>({label:o,cost:s[t]})).filter(o=>o.cost>0).sort((o,s)=>s.cost-o.cost).slice(0,IPe),r=n.reduce((o,s)=>o+s.cost,0);return n.map(o=>({label:o.label,cost:o.cost,pct:r>0?o.cost/r*100:0}))}function NPe(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function FPe(e){return(e.type==="daily"||e.type==="weekly")&&e.nextRun?`${e.type} ${NPe(e.nextRun)}`:e.type}function QE(e){return e.profile??""}function HU(e){const t=Math.round(e/6e4);if(t<1)return"<1m";if(t<60)return`${t}m`;const n=Math.round(e/36e5);return n<24?`${n}h`:`${Math.round(e/864e5)}d`}function zPe(e,t){if(!e)return"—";const n=Date.parse(e)-t;return n<=0?"due":`next in ${HU(n)}`}function XE(e,t){if(!e)return"never run";const n=t-Date.parse(e);return`last ${HU(Math.max(0,n))} ago`}function BPe(e,t){return typeof e.durationMs=="number"?e.durationMs:e.startedAt?Math.max(0,t-Date.parse(e.startedAt)):null}function $Pe(e){if(e==null)return"—";if(e>=36e5){const t=Math.floor(e/36e5),n=Math.round(e%36e5/6e4);return`${t}h ${n}m`}return e>=6e4?`${Math.round(e/6e4)}m`:`${Math.round(e/1e3)}s`}function _Pe(e){return e.machine??"local"}function WPe(e){return e==null?"—":yn(e)}function HPe(e){switch(e){case"running":return{text:"running",bg:"var(--pill-running-bg)",color:"var(--pill-running-fg)",dot:!0};case"completed":return{text:"done",bg:"var(--pill-done-bg)",color:"var(--pill-done-fg)",dot:!1};case"failed":return{text:"failed",bg:"var(--pill-failed-bg)",color:"var(--pill-failed-fg)",dot:!1};case"cancelled":return{text:"cancelled",bg:"var(--pill-cancelled-bg)",color:"var(--pill-cancelled-fg)",dot:!1};case"stale":default:return{text:"stale",bg:"var(--pill-cancelled-bg)",color:"var(--pill-cancelled-fg)",dot:!1}}}function UPe(e){return e.taskId?`task ${e.taskId}`:e.sessionId?`session ${e.sessionId}`:`${e.type} execution`}const Yc={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"var(--shadow-card-subtle)",minWidth:0};function Gm({title:e,right:t}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[i.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e}),t!=null&&i.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:t})]})}function VPe(){var I;const e=O(),t=Xe(),n=he(),r=Ve(),{open:o}=p$(),{open:s,openEdit:a}=AS(),{open:l}=F2e(),c=j1(),d=Date.now(),{currentProjectId:u}=zt(),p=u??"—",m=ae({...n.cost.summary.queryOptions({projectId:u??void 0}),enabled:!!u}).data,x=WU(m==null?void 0:m.today,m==null?void 0:m.dailyBudget),v=f.useMemo(()=>DPe(m==null?void 0:m.dailyCost),[m==null?void 0:m.dailyCost]),S=f.useMemo(()=>LPe(m==null?void 0:m.dailyCost),[m==null?void 0:m.dailyCost]),b=f.useMemo(()=>OPe(m==null?void 0:m.byTriggerScoped,"week"),[m==null?void 0:m.byTriggerScoped]),w=ae({...n.schedules.list.queryOptions({projectId:u??void 0}),enabled:!!u}).data??[],k=ae(n.executions.list.queryOptions({limit:50})),C=f.useMemo(()=>{const L=k.data??[];return(u?L.filter(ee=>ee.projectId===u):L).slice(0,6)},[k.data,u]),T=ae({...n.issues.list.queryOptions({projectId:u??""}),enabled:!!u}),P=f.useMemo(()=>T.data??[],[T.data]),R=Re(n.schedules.resume.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.schedules.list.queryFilter())}})),D=Re(n.schedules.remove.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.schedules.list.queryFilter())}}));return i.jsxs("div",{"data-pane":"center",style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",minHeight:0,background:"var(--proto-card)"},children:[i.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"0 20px",background:"var(--proto-card)"},children:[i.jsx("span",{onClick:()=>t("/workbench"),style:{fontSize:14,color:"var(--proto-muted)",cursor:"pointer",padding:"4px 8px 4px 0"},children:"‹"}),i.jsx("span",{style:{font:"500 12px 'IBM Plex Mono',monospace",color:"var(--proto-muted-2)"},children:p}),i.jsx("span",{style:{color:"var(--proto-line-3)"},children:"/"}),i.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:"var(--proto-ink)"},children:e.overview}),i.jsxs("span",{style:{position:"relative",marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:8},children:[P.length>0&&i.jsxs("span",{"data-issues-stat":"",onClick:()=>l(),style:{display:"inline-flex",alignItems:"center",gap:4,font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",padding:"3px 8px",cursor:"pointer"},children:[i.jsx("b",{style:{color:"var(--proto-accent)"},children:P.length})," ",e.issuesStat]}),i.jsx("span",{style:{width:1,height:18,background:"var(--proto-line)",flex:"none"}}),i.jsx(BH,{count:c.vm.activeCount,active:c.isOpen,copy:c.copy,onClick:()=>c.isOpen?c.close():c.open()}),i.jsx("span",{style:{fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:7,padding:"4px 12px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:"pointer"},children:e.adjustBudget}),i.jsx("span",{style:{color:"var(--proto-muted-2)",fontSize:15,letterSpacing:1,padding:"2px 6px",borderRadius:6,cursor:"pointer"},children:"⋯"})]})]}),i.jsxs("div",{style:{flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:30,padding:"12px 20px 14px",background:"var(--proto-card)"},children:[i.jsxs("div",{style:{minWidth:180},children:[i.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.today}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[i.jsx("span",{style:{font:"600 22px 'IBM Plex Mono',monospace",color:"var(--proto-ink)",letterSpacing:"-.02em"},children:rr(m==null?void 0:m.today)}),i.jsx("div",{style:{flex:1,height:5,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden",marginTop:2},children:i.jsx("div",{style:{width:`${x??0}%`,height:"100%",background:"var(--proto-accent)"}})})]})]}),i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.thisWeek}),i.jsx("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:rr(m==null?void 0:m.week)})]}),i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.month}),i.jsx("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:rr(m==null?void 0:m.month)})]}),i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.budgetPerDay}),i.jsxs("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:[APe(m==null?void 0:m.dailyBudget),i.jsxs("span",{style:{fontSize:10,color:"var(--proto-muted-3)",fontWeight:400},children:[" ",e.perDay]})]})]}),i.jsxs("div",{style:{marginLeft:"auto",textAlign:"right"},children:[i.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.forecastToday}),i.jsx("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-amber-text)"},children:rr(m==null?void 0:m.forecastToday)})]})]}),i.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"14px 20px",display:"grid",gridTemplateColumns:"1fr 1fr",gridAutoRows:"min-content",gap:12,background:"var(--proto-alt)",alignContent:"start"},children:[i.jsxs("div",{style:Yc,children:[i.jsx(Gm,{title:e.ovLast14Days,right:`${e.ovAvg} ${S==null?"—":rr(S)}${e.perDay}`}),i.jsxs("div",{style:{padding:"14px 14px 10px"},children:[i.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:5,height:96},children:v.map(L=>L.isToday?i.jsx("div",{title:`${L.date} · ${rr(L.cost)}`,style:{flex:1,position:"relative",background:"var(--proto-accent)",borderRadius:"3px 3px 0 0",height:`${L.pct}%`},children:i.jsx("div",{style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:5,font:"600 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-accent)",whiteSpace:"nowrap"},children:rr(L.cost)})},L.date):i.jsx("div",{title:`${L.date} · ${rr(L.cost)}`,style:{flex:1,background:"var(--proto-line-4)",borderRadius:"3px 3px 0 0",height:`${L.pct}%`}},L.date))}),i.jsxs("div",{style:{display:"flex",alignItems:"center",marginTop:7,font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:[i.jsx("span",{children:((I=v[0])==null?void 0:I.date)??"—"}),i.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-accent)",fontWeight:600},children:e.today})]})]})]}),i.jsxs("div",{style:{...Yc,cursor:"pointer"},onClick:()=>t("/memory"),children:[i.jsx(Gm,{title:e.projectMemory,right:e.ovGitBacked}),i.jsxs("div",{style:{padding:"18px 14px",display:"flex",flexDirection:"column",alignItems:"center",gap:4,textAlign:"center"},children:[i.jsxs("div",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-accent)"},children:[e.ovOpenMemoryViewer," ›"]}),i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",lineHeight:1.5},children:e.ovMemoryDesc})]})]}),i.jsx(MPe,{vm:c.vm,copy:c.copy,onOpen:c.open,onAdd:c.add}),P.length>0&&i.jsxs("div",{style:Yc,"data-issues-card":"",children:[i.jsx(Gm,{title:e.issuesTitle,right:"ISSUES.md"}),i.jsx("div",{style:{padding:"4px 14px 6px"},children:P.slice(0,3).map((L,W)=>i.jsxs("div",{onClick:()=>l(L.id),style:{display:"flex",alignItems:"center",gap:9,padding:"8px 0",borderBottom:W<Math.min(P.length,3)-1?"1px solid var(--proto-alt)":"none",cursor:"pointer"},children:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-muted-2)",strokeWidth:"1.5",style:{flex:"none"},children:[i.jsx("circle",{cx:"7",cy:"7",r:"5.5"}),i.jsx("path",{d:"M7 4.2v3.3"}),i.jsx("circle",{cx:"7",cy:"9.8",r:".4",fill:"var(--proto-muted-2)"})]}),i.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:L.title}),L.date&&i.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:L.date}),i.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--proto-accent)",flex:"none"},children:"↗"})]},L.id))}),i.jsxs("div",{onClick:()=>l(),style:{borderTop:"1px solid var(--proto-line-2)",padding:"9px 14px",fontSize:11,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:[e.isViewAll," ",P.length," ›"]})]}),i.jsxs("div",{style:Yc,children:[i.jsx(Gm,{title:e.ovWhereItGoes,right:e.thisWeek}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"13px 14px 14px"},children:[b.length===0&&i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"2px 0"},children:e.ovNoSpend}),b.map((L,W)=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[i.jsx("span",{title:L.label,style:{fontSize:10.5,color:"var(--proto-muted)",width:56,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:L.label}),i.jsx("div",{style:{flex:1,height:6,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:i.jsx("div",{style:{width:`${L.pct}%`,height:"100%",background:["var(--proto-accent)","var(--proto-accent-2)","var(--proto-accent-bg)"][W%3]}})}),i.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-ink)",width:40,textAlign:"right"},children:rr(L.cost)})]},L.label))]})]}),i.jsxs("div",{style:Yc,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[i.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e.scheduleCard}),i.jsxs("span",{onClick:()=>s({projectId:u}),style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:["+ ",e.newSchedule]})]}),i.jsxs("div",{style:{padding:"9px 14px 11px",display:"flex",flexDirection:"column",gap:9},children:[w.length===0&&i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"4px 0"},children:e.ovNoSchedules}),w.map((L,W)=>i.jsxs("div",{children:[W>0&&i.jsx("div",{style:{height:1,background:"var(--proto-line-soft)",margin:"0 0 9px"}}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[i.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:L.paused?"var(--proto-muted-2)":"var(--proto-muted)",strokeWidth:"1.5",children:[i.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),i.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]}),i.jsx("span",{title:L.message,style:{flex:1,minWidth:0,fontSize:11.5,fontWeight:600,color:L.paused?"var(--proto-muted-2)":"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:L.message}),L.paused&&i.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 6px",borderRadius:999,background:"var(--proto-gray)",color:"var(--proto-muted-2)"},children:e.paused}),i.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:FPe(L)})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",fontSize:10,color:"var(--proto-muted-2)",marginTop:2,paddingLeft:18},children:[i.jsx("span",{children:L.paused?`${XE(L.lastRun,d)}`:`${zPe(L.nextRun,d)} · ${XE(L.lastRun,d)}`}),QE(L)&&i.jsx("span",{title:"profile",style:{marginLeft:7,font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:QE(L)}),i.jsxs("span",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:9},children:[i.jsx("button",{type:"button","data-schedule-edit":L.id,onClick:()=>a(L),style:{padding:0,border:0,background:"none",fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:e.scEditSchedule}),i.jsx("button",{type:"button","data-schedule-delete":L.id,onClick:()=>{!D.isPending&&globalThis.confirm(`${e.delete} "${L.message}"?`)&&D.mutate({scheduleId:L.id})},style:{padding:0,border:0,background:"none",fontSize:10.5,fontWeight:600,color:"var(--proto-danger)",cursor:D.isPending?"not-allowed":"pointer"},children:e.delete}),L.paused&&i.jsx("button",{type:"button","data-schedule-resume":L.id,onClick:()=>!R.isPending&&R.mutate({scheduleId:L.id}),style:{padding:0,border:0,background:"none",fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:e.resume})]})]})]},L.id))]})]}),i.jsxs("div",{style:{...Yc,gridColumn:"span 2",overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[i.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e.execFlow}),i.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginLeft:8},children:e.ovExecSubtitle}),i.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:"executions.json"})]}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"88px 1fr 76px 52px 56px 86px 46px",padding:"6px 14px",borderBottom:"1px solid var(--proto-line-soft)",fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},children:[i.jsx("span",{children:e.ovColId}),i.jsx("span",{children:e.ovColSummary}),i.jsx("span",{children:e.ovColMachine}),i.jsx("span",{children:e.ovColDur}),i.jsx("span",{children:e.ovColCost}),i.jsx("span",{children:e.ovColStatus}),i.jsx("span",{})]}),C.length===0&&i.jsx("div",{style:{padding:"10px 14px",fontSize:10.5,color:"var(--proto-faint)"},children:e.ovNoExecutions}),C.map(L=>{const W=HPe(L.status);return i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"88px 1fr 76px 52px 56px 86px 46px",padding:"7.5px 14px",borderBottom:"1px solid var(--proto-alt)",alignItems:"center",fontSize:11,color:"var(--proto-ink-2)"},children:[i.jsx("span",{title:L.id,style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:L.id}),i.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:12},children:UPe(L)}),i.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace"},children:_Pe(L)}),i.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace"},children:$Pe(BPe(L,d))}),i.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace"},children:WPe(L.cost)}),i.jsx("span",{children:i.jsxs("span",{style:{fontSize:9,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:W.bg,color:W.color},children:[W.dot?"• ":"",W.text]})}),i.jsx("span",{onClick:()=>o(L.id),style:{fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:e.ovLogs})]},L.id)})]})]})]})}function qPe(){return i.jsxs(N1,{children:[i.jsx(A1,{}),i.jsx(VPe,{}),i.jsx(O1,{})]})}function UU(e){var o;if(!e)return{topLevelFiles:[],dirs:[],fileCount:0,firstFile:null};const t=e.files.map(s=>({...s,path:s.name})),n=e.dirs.map(s=>({name:s.name,entryCount:s.entryCount,entries:(s.entries??[]).map(a=>({...a,path:`${s.name}/${a.name}`}))})),r=((o=n.find(s=>s.entries.length>0))==null?void 0:o.entries[0])??null;return{topLevelFiles:t,dirs:n,fileCount:t.length+n.reduce((s,a)=>s+a.entryCount,0),firstFile:t[0]??r}}function KPe(e,t){const n=e.topLevelFiles.map(o=>({name:o.name,kind:"file",path:o.path,depth:0,selectable:!0,selected:o.path===t,right:null})),r=e.dirs.flatMap(o=>[{name:`${o.name}/`,kind:"dir",path:null,depth:0,selectable:!1,selected:!1,right:String(o.entryCount)},...o.entries.map(s=>({name:s.name,kind:"file",path:s.path,depth:1,selectable:!0,selected:s.path===t,right:null}))]);return[...n,...r]}function GPe(e){var t;return((t=e.firstFile)==null?void 0:t.path)??null}function YPe(e,t){if(!e)return"updated —";const n=Date.parse(e);if(Number.isNaN(n))return"updated —";const r=Math.max(0,t-n),o=Math.round(r/6e4);if(o<1)return"updated <1m ago";if(o<60)return`updated ${o}m ago`;const s=Math.round(r/36e5);return s<24?`updated ${s}h ago`:`updated ${Math.round(r/864e5)}d ago`}function QPe(e){return e?{label:"Viewing diff",color:"var(--ink-solid-fg)",bg:"var(--proto-accent)",border:"var(--proto-accent)"}:{label:"Diff hidden",color:"var(--proto-accent)",bg:"var(--proto-card)",border:"var(--proto-accent-border)"}}function XPe(e){return e?{added:`+${e.added}`,removed:`−${e.removed}`}:null}function ZPe(e,t){if(!e)return null;const n=new Map;for(const s of e)n.set(s.line,s);const r=t.split(`
440
440
  `);r.length>1&&r[r.length-1]===""&&r.pop();let o;return r.map((s,a)=>{const l=a+1,c=n.get(l)??null,d=c?c.commit:null,u=d!==o;return o=d,{lineNo:l,text:s,commit:d,taskRef:c?c.taskRef:null,groupStart:u}})}const ss="'IBM Plex Mono',monospace";function JPe({rows:e}){let t=-1;return i.jsx("div",{style:{font:`400 11px ${ss}`,lineHeight:1.55},children:e.map(n=>{n.groupStart&&(t+=1);const r=t%2===0?"var(--proto-rail)":"var(--proto-accent-bg)";return i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10,background:r,borderLeft:n.groupStart?"2px solid var(--proto-accent)":"2px solid transparent",padding:"0 8px"},children:[i.jsx("span",{style:{width:34,flex:"none",textAlign:"right",color:"var(--proto-line)",fontSize:9.5},children:n.lineNo}),i.jsx("span",{style:{width:66,flex:"none",color:"var(--proto-muted-2)",fontSize:9.5},children:n.groupStart&&n.commit?n.commit:""}),i.jsx("span",{style:{width:52,flex:"none"},children:n.groupStart&&n.taskRef&&i.jsx("span",{style:{fontSize:9,fontWeight:600,color:"var(--proto-accent)",background:"var(--proto-accent-bg)",border:"1px solid var(--proto-accent-border)",borderRadius:999,padding:"1px 6px"},children:n.taskRef})}),i.jsx("span",{style:{flex:1,minWidth:0,color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n.text||" "})]},n.lineNo)})})}function eEe({row:e,onPick:t}){const[n,r]=f.useState(!1),o=e.selected?"var(--proto-accent-bg)":n&&e.selectable?"var(--proto-gray)":"transparent",s=e.selected||e.kind==="dir"?600:500,a=e.selected?"var(--proto-accent)":"var(--proto-ink-2)";return i.jsxs("div",{onClick:e.selectable&&e.path?()=>t(e.path):void 0,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:7,padding:`5px 8px 5px ${e.depth===1?22:8}px`,background:o,borderRadius:7,cursor:e.selectable?"pointer":"default"},children:[i.jsx("span",{style:{font:`${s} 10.5px ${ss}`,color:a,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.name}),e.right!=null&&i.jsx("span",{style:{marginLeft:"auto",font:`400 8.5px ${ss}`,color:"var(--proto-faint)",flex:"none"},children:e.right})]})}const tEe={flex:1,minWidth:0,display:"flex",flexDirection:"column",minHeight:0,background:"var(--proto-card)"};function nEe(){const e=Xe(),t=he(),n=O(),r=Date.now(),[o,s]=f.useState(null),[a,l]=f.useState(!0),c=ae(t.projects.list.queryOptions({})),d=ae(t.sessions.list.queryOptions({})),u=c.data??[],p=d.data??[],h=f.useMemo(()=>j$(p,u),[p,u]),m=h??"—",x=ae({...t.memory.tree.queryOptions({projectId:h??""}),enabled:!!h}),v=x.data,S=f.useMemo(()=>UU(v),[v]),b=o??GPe(S),g=ae({...t.memory.file.queryOptions({projectId:h??"",path:b??""}),enabled:!!h&&!!b}),w=g.data,k=KPe(S,b),C=QPe(a),T=XPe(w==null?void 0:w.lineDiff),P=ZPe(w==null?void 0:w.blame,(w==null?void 0:w.content)??"");return i.jsxs("div",{"data-pane":"center",style:tEe,children:[i.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"0 20px",background:"var(--proto-card)"},children:[i.jsx("span",{onClick:()=>e("/overview"),style:{fontSize:14,color:"var(--proto-muted)",cursor:"pointer",padding:"4px 8px 4px 0"},children:"‹"}),i.jsx("span",{onClick:()=>e("/overview"),style:{font:`500 12px ${ss}`,color:"var(--proto-muted-2)",cursor:"pointer"},children:m}),i.jsx("span",{style:{color:"var(--proto-line-3)"},children:"/"}),i.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:"var(--proto-ink)"},children:n.memMemory}),i.jsx("span",{style:{color:"var(--proto-line-3)"},children:"/"}),i.jsx("span",{style:{font:`500 12px ${ss}`,color:"var(--proto-muted)"},children:b??"—"}),i.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${ss}`,color:"var(--proto-muted-3)"},children:n.ovGitBacked})]}),i.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[i.jsxs("div",{style:{width:200,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",padding:"8px 6px",overflow:"auto"},children:[x.isLoading&&i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"6px 8px"},children:n.memLoading}),!x.isLoading&&k.length===0&&i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"6px 8px"},children:n.memNoFiles}),k.map(R=>i.jsx(eEe,{row:R,onPick:s},R.path??`dir:${R.name}`))]}),i.jsxs("div",{style:{flex:1,minWidth:0,background:"var(--proto-card)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[i.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:8,padding:"8px 20px",background:"var(--proto-accent-bg)",borderBottom:"1px solid var(--proto-accent-bg)"},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",flex:"none"}}),i.jsx("span",{style:{fontSize:11,color:"var(--proto-accent-strong)"},children:YPe(w==null?void 0:w.modifiedAt,r)}),T?i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{font:`600 10px ${ss}`,color:"var(--proto-success)"},children:T.added}),i.jsx("span",{style:{font:`600 10px ${ss}`,color:"var(--proto-danger)"},children:T.removed})]}):i.jsx("span",{style:{font:`400 9.5px ${ss}`,color:"var(--proto-muted-3)"},children:n.memDiffUnavailable}),i.jsx("span",{onClick:()=>l(R=>!R),style:{marginLeft:"auto",fontSize:10,fontWeight:600,color:C.color,background:C.bg,border:`1px solid ${C.border}`,borderRadius:999,padding:"2px 10px",cursor:"pointer"},children:C.label})]}),i.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"18px 24px 24px"},children:[a&&i.jsx("div",{style:{fontSize:10.5,color:"var(--proto-amber-fg)",background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",borderRadius:7,padding:"6px 11px",marginBottom:12,lineHeight:1.5},children:P?i.jsxs(i.Fragment,{children:[T?`${T.added} / ${T.removed} ${n.memLinesChanged} `:"",n.memBlameNote]}):i.jsx(i.Fragment,{children:n.memBlameUnavailable})}),g.isLoading&&i.jsx("div",{style:{fontSize:11.5,color:"var(--proto-faint)"},children:n.memLoadingFile}),g.isError&&i.jsx("div",{style:{fontSize:11.5,color:"var(--proto-danger)"},children:n.memReadError}),w&&a&&P?i.jsx(JPe,{rows:P}):w&&i.jsx(l_,{content:w.content}),!g.isLoading&&!g.isError&&!w&&i.jsx("div",{style:{fontSize:11.5,color:"var(--proto-faint)"},children:n.memSelectFile})]})]})]})]})}function rEe(){return i.jsxs(N1,{children:[i.jsx(A1,{}),i.jsx(nEe,{}),i.jsx(O1,{})]})}const Af="'IBM Plex Mono', monospace";function oEe({name:e}){return i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",fontSize:11,fontWeight:500,color:"var(--proto-accent)",background:"var(--proto-accent-bg)",border:"1px solid var(--proto-accent-border)",borderRadius:999,padding:"2px 10px",fontFamily:Af,letterSpacing:.1},children:["/",e]})}function iEe({group:e}){const t=O(),n=e.plugin??t.skUserSkills;return i.jsxs("div",{style:{marginBottom:28},children:[i.jsxs("div",{style:{fontSize:10.5,fontWeight:700,color:"var(--proto-muted-2)",letterSpacing:.8,textTransform:"uppercase",marginBottom:10,fontFamily:Af},children:[n,i.jsxs("span",{style:{marginLeft:8,fontSize:10,fontWeight:500,color:"var(--proto-line)",letterSpacing:0,textTransform:"none"},children:[e.skills.length," ",e.skills.length===1?"skill":"skills"]})]}),i.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:7},children:e.skills.map(r=>i.jsx(oEe,{name:r},r))})]})}function sEe(){const e=he(),t=O(),{data:n,isLoading:r,isError:o}=ae(e.skills.list.queryOptions({})),s=n??[],a=s.reduce((l,c)=>l+c.skills.length,0);return i.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--proto-rail)"},children:[i.jsxs("div",{style:{padding:"20px 28px 16px",borderBottom:"1px solid var(--proto-line-2)",background:"var(--proto-card)",flex:"none"},children:[i.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--proto-ink)",letterSpacing:-.3},children:t.skTitle}),i.jsx("div",{style:{fontSize:11.5,color:"var(--proto-muted-2)",marginTop:3},children:r?t.skScanning:o?t.skLoadError:`${a} skill${a!==1?"s":""} across ${s.length} group${s.length!==1?"s":""}`})]}),i.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px 28px"},children:[r&&i.jsx("div",{style:{fontSize:12,color:"var(--proto-line)",fontFamily:Af},children:t.skLoadingBody}),o&&i.jsx("div",{style:{fontSize:12,color:"var(--proto-danger)",fontFamily:Af},children:t.skFailedBody}),!r&&!o&&s.length===0&&i.jsx("div",{style:{fontSize:12,color:"var(--proto-line)",fontFamily:Af},children:t.skEmpty}),s.map(l=>i.jsx(iEe,{group:l},l.plugin??"__user__"))]})]})}function aEe(){return i.jsxs(N1,{children:[i.jsx(A1,{}),i.jsx(sEe,{}),i.jsx(O1,{})]})}const Df=e=>e==="logged-in"||e==="expiring",Mp=e=>e instanceof Error?e.message:String(e);function lEe(e,t){const n=t.trim().toLowerCase();return e.filter(r=>r.backend==="pi"&&`${r.label} ${r.provider}`.toLowerCase().includes(n)).sort((r,o)=>Number(Df(o.state))-Number(Df(r.state))||r.label.localeCompare(o.label))}function cEe(e,t){const n=e.backend??"claude",r=n==="claude"?"anthropic":e.provider;if(t.backend!==n||t.provider!==r)return!1;const o=e.mode==="api"?"api_key":"oauth";return n==="pi"?Df(t.state):t.authType===o&&Df(t.state)||t.credentials.some(s=>s.authType===o&&Df(s.state))}function dEe(e,t,n,r){return e.filter(o=>{const s=o.backend??"claude";return(s==="pi"?n:s==="claude"&&r===!0)&&!!o.model&&t.some(l=>cEe(o,l))})}class uEe{constructor(t){Pt(this,"state",{status:null,profiles:null,busy:!1,error:null,sync:"idle",claude:null,claudeBusy:!1,claudeError:null});Pt(this,"listeners",new Set);Pt(this,"completed",new Set);Pt(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));Pt(this,"snapshot",()=>this.state);Pt(this,"load",async()=>{await Promise.all([this.scan(!1),this.detectClaude()])});Pt(this,"refresh",()=>this.scan(!0));Pt(this,"loginDone",async t=>{this.completed.has(t)||(this.completed.add(t),this.state.busy&&await new Promise(n=>{const r=this.subscribe(()=>{this.state.busy||(r(),n())})}),await this.refresh())});Pt(this,"select",async t=>{if(!(this.state.busy||!this.available().some(n=>n.name===t))){this.patch({busy:!0,error:null});try{await this.ports.select(t),this.patch({profiles:(await this.ports.config()).profiles})}catch(n){this.patch({error:Mp(n)})}finally{this.patch({busy:!1})}}});Pt(this,"detectClaude",async()=>{if(!(!this.ports.canInstall()||this.state.claudeBusy)){this.patch({claudeBusy:!0,claudeError:null});try{this.patch({claude:await this.ports.claude()})}catch(t){this.patch({claude:null,claudeError:Mp(t)})}finally{this.patch({claudeBusy:!1})}}});Pt(this,"prepareClaude",async()=>{if(!this.ports.canInstall()||this.state.claudeBusy||!this.state.claude)return!1;if(this.state.claude.installed)return!0;this.patch({claudeBusy:!0,claudeError:null});try{const t=await this.ports.install();if(this.patch({claude:t}),!t.installed)throw new Error("installed: false");return!0}catch(t){return this.patch({claudeError:Mp(t)}),!1}finally{this.patch({claudeBusy:!1})}});this.ports=t}patch(t){this.state={...this.state,...t},this.listeners.forEach(n=>n())}available(){var t,n,r,o;return dEe(((t=this.state.profiles)==null?void 0:t.profiles)??[],((n=this.state.status)==null?void 0:n.accounts)??[],((r=this.state.status)==null?void 0:r.piRuntime.available)===!0,((o=this.state.claude)==null?void 0:o.installed)??null)}canContinue(){return!this.state.busy&&!this.state.error&&this.state.sync!=="failed"&&this.available().some(t=>{var n;return t.name===((n=this.state.profiles)==null?void 0:n.defaultProfile)})}async scan(t){if(!this.state.busy){this.patch({busy:!0,error:null});try{this.patch({status:await this.ports.status()}),t&&await this.syncModels(),this.patch({profiles:(await this.ports.config()).profiles})}catch(n){this.patch({error:Mp(n)})}finally{this.patch({busy:!1})}}}async syncModels(){try{const t=await this.ports.sync();this.patch({sync:t.configured?"success":"failed",error:t.configured?null:t.reason??"configured: false"})}catch(t){this.patch({sync:"failed",error:Mp(t)})}}}function pEe(e){if(!e||typeof e!="object"||Reflect.get(e,"run")!=="claude-install")return null;const t=Reflect.get(e,"line");return typeof t=="string"?t.replace(/\x1b\[[0-9;]*m/g,"").slice(-2e3):null}function F1(){var e;if(!vx()||!hS("invoke"))return!1;try{const t=new URL(((e=o0())==null?void 0:e.serverUrl)??"");return["http:","https:"].includes(t.protocol)&&["localhost","127.0.0.1","[::1]"].includes(t.hostname)}catch{return!1}}async function ZE(e){if(!F1())throw new Error("Local desktop setup required");const t=await bt(e?"setup_install_claude":"setup_claude_status");if(!t.ok)throw t.reason==="failed"?t.error:new Error("Native setup unavailable");const n=t.value;if(!n||typeof n.installed!="boolean"||!(n.version===null||typeof n.version=="string"))throw new Error("Invalid Claude installation status");return n}function fEe(){return i.jsx("span",{className:"setup-brand-mark",children:i.jsxs("svg",{width:"19",height:"19",viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[i.jsx("circle",{cx:"33",cy:"32",r:"6",fill:"var(--brand-badge-core)"}),i.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:"6",strokeLinecap:"round"}),i.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:"6",strokeLinecap:"round"})]})})}function hEe(){const e=ht(),t=x3(),n=$re(),r=O();return i.jsxs("div",{className:"setup-header-actions",children:[i.jsx("button",{className:"setup-theme-toggle",type:"button",onClick:n,"aria-label":r.setupToggleTheme,children:i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M20.9 13A9 9 0 0 1 11 3.1 9 9 0 1 0 20.9 13Z"})})}),i.jsx("div",{className:"setup-lang-toggle",role:"group","aria-label":r.setupLanguage,children:["en","zh"].map(o=>i.jsx("button",{type:"button","aria-pressed":e===o,onClick:()=>t(o),children:o==="en"?"EN":"中"},o))})]})}function mEe(){const e=R_();return i.jsx($U,{actions:e})}function gEe(){const e=O(),t=WS();return i.jsxs("header",{className:"setup-header","data-tauri-drag-region":"deep","data-caption":t,style:t==="overlay"?{paddingLeft:k_()+16}:void 0,children:[i.jsxs("div",{className:"setup-brand",children:[i.jsx(fEe,{}),"Cortex"]}),i.jsx("span",{className:"setup-header-label",children:e.setupHeader}),i.jsx(hEe,{}),t==="custom"?i.jsx(mEe,{}):null]})}function Mu({primary:e,className:t="",...n}){return i.jsx("button",{type:"button",className:`setup-button ${e?"setup-primary":""} ${t}`,...n})}function vEe(e,t){return{"logged-in":t.setupConfigured,expiring:t.setupExpiring,"logged-out":t.setupMissing,expired:t.setupExpired,unknown:t.setupUnknown}[e.state]}function VU({account:e,login:t,disabled:n}){const r=O(),o=e.backend==="claude"?"claude-code":e.provider;return i.jsxs("div",{className:"setup-account","data-account-state":e.state,children:[i.jsx("span",{className:"setup-provider-icon",children:i.jsx(Xu,{provider:o,label:e.label,size:20})}),i.jsxs("div",{className:"setup-account-copy",children:[i.jsx("strong",{children:e.label}),i.jsxs("p",{className:"setup-account-status",children:[i.jsx("span",{className:"setup-state-dot"}),vEe(e,r)]})]}),i.jsx("div",{className:"setup-account-actions",children:e.capabilities.map(s=>i.jsx(Mu,{disabled:n,onClick:()=>t({backend:e.backend,provider:e.provider,authType:s}),children:s==="api_key"?r.authLoginApiKey:r.authLoginOAuth},s))})]})}function xEe(){const[e,t]=f.useState("");return f.useEffect(()=>{if(!F1())return;let n=!1,r=()=>{};return x1("setup-log",o=>{const s=pEe(o);!n&&s!==null&&t(a=>`${a}${s}
441
- `.slice(-6e3))}).then(o=>{n?o():r=o}),()=>{n=!0,r()}},[]),e}function yEe({controller:e,account:t,login:n}){const r=O(),o=e.state,s=async a=>{await e.prepareClaude()&&n(a)};return F1()?o.claude===null?i.jsx(Mu,{disabled:o.claudeBusy,onClick:e.detectClaude,children:r.setupRetry}):t?o.claude.installed?i.jsx(VU,{account:t,disabled:o.claudeBusy||o.busy,login:s}):i.jsxs("div",{className:"setup-install-row",children:[i.jsx("p",{className:"setup-hint",children:r.setupCcConsent}),i.jsx(Mu,{disabled:o.claudeBusy||o.busy||!t.capabilities.length,onClick:()=>s({backend:"claude",provider:t.provider,authType:t.capabilities.includes("oauth")?"oauth":t.capabilities[0]}),children:r.setupCcInstall})]}):null:i.jsx("p",{className:"setup-hint",children:r.setupCcLocal})}function bEe({controller:e,login:t}){var a;const n=O(),r=e.state,o=xEe(),s=r.claude===null?n.setupUnknown:r.claude.installed?n.setupCcInstalled:n.setupCcMissing;return i.jsxs("section",{className:"setup-card",children:[i.jsxs("div",{className:"setup-card-header",children:[i.jsx(Xu,{provider:"claude-code",label:"Claude Code",size:20}),i.jsx("h2",{children:"Claude Code"}),i.jsxs("span",{className:"setup-pill",children:[n.setupOptional," · ",s]})]}),i.jsxs("div",{className:"setup-card-body setup-cc-body",children:[i.jsx(yEe,{controller:e,account:(a=r.status)==null?void 0:a.accounts.find(l=>l.backend==="claude"),login:t}),r.claudeBusy?i.jsx("p",{className:"setup-hint",role:"status",children:n.setupWorking}):null,o?i.jsx("pre",{className:"setup-log",children:o}):null,r.claudeError?i.jsx("p",{role:"alert",className:"setup-error",children:r.claudeError}):null]})]})}function wEe({controller:e}){var s;const t=O(),n=e.available(),r=((s=e.state.profiles)==null?void 0:s.defaultProfile)??"",o=n.some(a=>a.name===r);return i.jsxs("section",{className:"setup-card",children:[i.jsxs("div",{className:"setup-card-header",children:[i.jsx("h2",{children:i.jsx("label",{htmlFor:"setup-profile",children:t.setupProfile})}),r?i.jsx("span",{className:"setup-pill",children:r}):null]}),i.jsxs("div",{className:"setup-card-body setup-profile-body",children:[i.jsxs("select",{id:"setup-profile",className:"setup-input",disabled:e.state.busy||!n.length,value:o?r:"",onChange:a=>void e.select(a.target.value),children:[i.jsx("option",{value:"",disabled:!0,children:t.setupChooseProfile}),n.map(a=>i.jsxs("option",{value:a.name,children:[a.name," · ",a.model," · ",a.backend??"claude"]},a.name))]}),o?null:i.jsx("p",{className:"setup-hint",children:n.length?t.setupMismatch:t.setupNoProfiles})]})]})}function SEe({controller:e,leave:t}){const n=O();return i.jsxs("footer",{className:"setup-footer",children:[i.jsxs("div",{className:"setup-footer-actions",children:[i.jsx(Mu,{"data-action":"setup-skip",onClick:t,children:n.setupSkip}),i.jsxs(Mu,{"data-action":"setup-continue",primary:!0,disabled:!e.canContinue(),onClick:()=>{e.canContinue()&&t()},children:[n.setupContinue,i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:i.jsx("path",{d:"m9 5 7 7-7 7"})})]})]}),i.jsx("p",{className:"setup-footnote",children:n.setupSkipWarning}),i.jsx("p",{className:"setup-footnote",children:n.setupHonesty})]})}function kEe({controller:e,login:t}){var a;const n=O(),[r,o]=f.useState(""),s=e.state;return i.jsxs("section",{className:"setup-card",children:[i.jsxs("div",{className:"setup-card-header",children:[i.jsx("h2",{children:"PI"}),i.jsx("span",{className:"setup-pill setup-good",children:n.setupBundled}),i.jsx(Mu,{className:"setup-rescan",disabled:s.busy,onClick:e.refresh,children:s.busy?n.setupWorking:n.setupRescan})]}),s.status&&!s.status.piRuntime.available?i.jsxs("p",{role:"alert",className:"setup-error",children:[n.setupRuntimeError,": ",s.status.piRuntime.error]}):null,i.jsx("div",{className:"setup-search",children:i.jsx("input",{type:"search","aria-label":n.setupSearch,placeholder:n.setupSearch,value:r,onChange:l=>o(l.target.value),className:"setup-input"})}),i.jsx("div",{className:"setup-providers",children:lEe(((a=s.status)==null?void 0:a.accounts)??[],r).map(l=>{var c;return i.jsx(VU,{account:l,disabled:s.busy||!((c=s.status)!=null&&c.piRuntime.available),login:t},l.provider)})})]})}function jEe({controller:e}){const t=O(),n=e.state;return i.jsxs(i.Fragment,{children:[n.sync==="success"?i.jsx("p",{className:"setup-feedback",role:"status",children:t.setupSyncSuccess}):null,n.error?i.jsxs("p",{role:"alert",className:"setup-error",children:[t.setupSyncFailed,": ",n.error]}):null]})}function CEe({controller:e,leave:t}){f.useSyncExternalStore(e.subscribe,e.snapshot);const n=O(),[r,o]=f.useState(null),s=f.useCallback(a=>{a.step==="done"&&e.loginDone(a.flowId)},[e]);return i.jsxs(i.Fragment,{children:[i.jsxs("main",{className:"setup-workspace",children:[i.jsxs("header",{children:[i.jsx("div",{className:"setup-eyebrow",children:n.setupEyebrow}),i.jsx("h1",{children:n.setupTitle}),i.jsx("p",{className:"setup-intro",children:n.setupDescription})]}),i.jsx(kEe,{controller:e,login:o}),i.jsx(jEe,{controller:e}),i.jsx(bEe,{controller:e,login:o}),i.jsx(wEe,{controller:e}),i.jsx(SEe,{controller:e,leave:t})]}),i.jsx(XO,{open:!!r,target:r,onClose:()=>o(null),onFlowStateChange:s})]})}function TEe(){const e=dl(),t=Xe(),n=f.useMemo(()=>new uEe({status:()=>e.auth.status.query({}),config:()=>e.config.get.query({}),sync:()=>e.auth.syncGateway.mutate({}),select:r=>e.config.set.mutate({section:"profiles",value:{defaultProfile:r}}),claude:()=>ZE(!1),install:()=>ZE(!0),canInstall:F1}),[e]);return f.useEffect(()=>{n.load()},[n]),i.jsxs("div",{className:"provider-setup",children:[i.jsx(gEe,{}),i.jsx("div",{className:"setup-scroll",children:i.jsx(CEe,{controller:n,leave:()=>t("/workbench",{replace:!0})})})]})}const PEe=SN([{path:"/setup/providers",element:i.jsx(TEe,{})},{path:"/",element:i.jsx(vwe,{}),children:[{index:!0,element:i.jsx(yN,{to:"/workbench",replace:!0})},{path:"workbench",element:i.jsx(hPe,{})},{path:"tasks",element:i.jsx(mPe,{})},{path:"threads",element:i.jsx(xwe,{title:"Threads"})},{path:"overview",element:i.jsx(qPe,{})},{path:"memory",element:i.jsx(rEe,{})},{path:"skills",element:i.jsx(aEe,{})},{path:"kit",element:i.jsx(SPe,{})},{path:"base",element:i.jsx(PPe,{})}]}]),EEe=[{id:"sessions",path:"/m/sessions",tab:"sessions",tabRoot:!0},{id:"threads",path:"/m/threads",tab:"threads",tabRoot:!0},{id:"tasks",path:"/m/tasks",tab:"tasks",tabRoot:!0},{id:"project",path:"/m/project",tab:"project",tabRoot:!0},{id:"session",path:"/m/session/:sessionId",tab:"sessions",parent:"sessions"},{id:"plan",path:"/m/session/:sessionId/plan/:requestId",tab:"sessions",parent:"session"},{id:"thread",path:"/m/thread/:threadId",tab:"threads",parent:"threads"},{id:"task",path:"/m/task/:taskId",tab:"tasks",parent:"tasks"},{id:"approvals",path:"/m/approvals",tab:"project",parent:"project"},{id:"issues",path:"/m/issues",tab:"project",parent:"project"},{id:"notes",path:"/m/notes",tab:"project",parent:"project"},{id:"memory",path:"/m/memory",tab:"project",parent:"project"},{id:"memoryFile",path:"/m/memory/file",tab:"project",parent:"memory"},{id:"machines",path:"/m/machines",tab:"project",parent:"project"},{id:"settings",path:"/m/settings",tab:"project",parent:"project"},{id:"settingsAccounts",path:"/m/settings/accounts",tab:"project",parent:"settings"},{id:"settingsAppearance",path:"/m/settings/appearance",tab:"project",parent:"settings"},{id:"settingsPlatform",path:"/m/settings/platform",tab:"project",parent:"settings"},{id:"settingsProfiles",path:"/m/settings/profiles",tab:"project",parent:"settings"},{id:"settingsBudget",path:"/m/settings/budget",tab:"project",parent:"settings"},{id:"settingsMcp",path:"/m/settings/mcp",tab:"project",parent:"settings"},{id:"settingsNotifications",path:"/m/settings/notifications",tab:"project",parent:"settings"},{id:"settingsAdvanced",path:"/m/settings/advanced",tab:"project",parent:"settings"},{id:"settingsHooks",path:"/m/settings/hooks",tab:"project",parent:"settings"},{id:"settingsUsage",path:"/m/settings/usage",tab:"project",parent:"settings"},{id:"daemon",path:"/m/daemon",tab:"project",parent:"settings"}],z1=EEe,qU=Object.fromEntries(z1.map(e=>[e.id,e]));function R0(e){return e.length>1?e.replace(/\/+$/,""):e}function $k(e){const t=R0(e);for(const n of z1){const r=X4({path:n.path,end:!0},t);if(r)return{route:n,params:r.params}}}function KU(e,t={}){return rN(qU[e].path,t)}function REe(e){const t=$k(e),n=t==null?void 0:t.route.parent;if(!(!t||!n))return rN(qU[n].path,t.params)}const MEe={sessions:"sessions",threads:"threads",tasks:"tasks",project:"project"},_k=z1.filter(e=>e.tabRoot).map(e=>({id:e.tab,path:e.path,labelKey:MEe[e.tab]}));function GU(e,t){return e===t||e.startsWith(`${t}/`)}function IEe(e){var r;const t=R0(e),n=$k(t);return n?n.route.tab:((r=_k.find(o=>GU(t,o.path)))==null?void 0:r.id)??"sessions"}function zd(e){var t;return((t=$k(e))==null?void 0:t.route.tabRoot)===!0}function AEe(e){const t=R0(e);return _k.some(n=>GU(t,n.path))}function DEe(e,t){return e==="project"&&t.needsYouCount>0?{count:t.needsYouCount}:{}}function LEe(e,t,n,r,o=!1){return n||r?{animate:!1}:o?{animate:!0,dir:"back"}:e==="REPLACE"?{animate:!1}:{animate:!0,dir:e==="POP"?"back":"forward"}}function YU(e,t){return R0(e)===R0(t)}function OEe(e,t,n){return t&&YU(t.key,n.key)?{current:t,retainedTab:null,returningToRetained:!0}:zd(e.key)&&!zd(n.key)?{current:n,retainedTab:e,returningToRetained:!1}:{current:n,retainedTab:zd(n.key)?null:t,returningToRetained:!1}}function NEe(e){return e==="forward"?{incoming:"animate-slide-in-right",outgoing:"animate-slide-out-left"}:{incoming:"animate-slide-in-left",outgoing:"animate-slide-out-right"}}function FEe(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const QU={position:"absolute",inset:0,background:y.canvas,isolation:"isolate"},zEe={...QU,visibility:"hidden",pointerEvents:"none"};function BEe(e,t,n){const[r,o]=f.useState({key:e,element:n}),[s,a]=f.useState(null),[l,c]=f.useState(null),[d,u]=f.useState("forward");return f.useLayoutEffect(()=>{if(YU(e,r.key))return;const h=OEe(r,s,{key:e,element:n}),m=zd(r.key)&&zd(e),x=LEe(t,!1,FEe(),m,h.returningToRetained);a(h.retainedTab),c(x.animate?r:null),x.animate&&u(x.dir),o(h.current)},[e]),{current:r,retainedTab:s,previous:l,dir:d,onSettled:()=>c(null)}}function t2({frame:e,role:t,className:n,hidden:r,onAnimationEnd:o}){return i.jsx("div",{"data-route-layer":t,"data-route-key":e.key,className:n,style:r?zEe:QU,"aria-hidden":t==="current"?void 0:!0,onAnimationEnd:o,children:e.element})}function $Ee({current:e,retainedTab:t,previous:n,dir:r,onSettled:o}){const s=NEe(r),a=t&&t.key!==(n==null?void 0:n.key)&&t.key!==e.key;return i.jsxs("div",{style:{position:"relative",height:"100%",overflow:"hidden"},children:[a&&i.jsx(t2,{frame:t,role:"retained",hidden:!0},t.key),n&&i.jsx(t2,{frame:n,role:"previous",className:s.outgoing},n.key),i.jsx(t2,{frame:e,role:"current",className:n?s.incoming:void 0,onAnimationEnd:n?o:void 0},e.key)]})}function _Ee(){const e=fo(),t=use(),n=mN(),r=BEe(e.pathname,t,n);return i.jsx($Ee,{...r})}const WEe="var(--proto-ink)",HEe="var(--proto-muted-3)";function UEe({id:e,color:t}){switch(e){case"sessions":return i.jsx("svg",{width:"21",height:"21",viewBox:"0 0 22 22",fill:"none",stroke:t,strokeWidth:"1.7",children:i.jsx("path",{d:"M4 4.5h14a1.5 1.5 0 0 1 1.5 1.5v8a1.5 1.5 0 0 1-1.5 1.5H9.5L5.5 19v-3.5H4A1.5 1.5 0 0 1 2.5 14V6A1.5 1.5 0 0 1 4 4.5z"})});case"threads":return i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 14 14",fill:"none",stroke:t,strokeWidth:"1.4",children:[i.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),i.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),i.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),i.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]});case"tasks":return i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:t,strokeWidth:"1.6",children:[i.jsx("path",{d:"M4 5.5l1.5 1.5L8 4.5"}),i.jsx("path",{d:"M4 12.5l1.5 1.5L8 11.5"}),i.jsx("path",{d:"M10.5 6h6M10.5 13h6"})]});case"project":return i.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:t,strokeWidth:"1.6",children:i.jsx("path",{d:"M3 5.5h5l1.5 2H17a1 1 0 0 1 1 1V15a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1z"})})}}function VEe({vocab:e,activeId:t,needsYouCount:n,onNavigate:r}){return i.jsx("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line)",background:"var(--proto-rail)",display:"flex",padding:"8px 6px",paddingBottom:"calc(8px + env(safe-area-inset-bottom))"},children:_k.map(o=>{const s=o.id===t,a=s?WEe:HEe,l=DEe(o.id,{needsYouCount:n});return i.jsxs("button",{type:"button","data-tab-id":o.id,"data-active":s?"true":"false","aria-current":s?"page":void 0,onClick:()=>r(o.path),style:{flex:1,minHeight:44,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:3,border:"none",background:"transparent",padding:0,cursor:"pointer"},children:[i.jsxs("div",{style:{position:"relative"},children:[i.jsx(UEe,{id:o.id,color:a}),l.count!==void 0&&i.jsx("span",{style:{position:"absolute",top:-4,right:-9,background:"var(--proto-amber)",color:"var(--ink-solid-fg)",font:"600 8px 'IBM Plex Mono', monospace",padding:"1px 4.5px",borderRadius:999},children:l.count})]}),i.jsx("span",{style:{fontSize:10,fontWeight:600,color:a},children:e[o.labelKey]})]},o.id)})})}function qEe(e){return REe(e)??KU("sessions")}function KEe(e,t,n=!1){return t?{kind:"history"}:zd(e)?{kind:"exit"}:n?{kind:"history"}:{kind:"navigate",to:qEe(e)}}function GEe(e,t){return e&&typeof(t==null?void 0:t.idx)=="number"&&t.idx>0}async function YEe(e,t,n,r){const o=KEe(e,t,n);if(o.kind==="history")return r.historyBack();if(o.kind==="exit")return void await r.exit();r.navigate(o.to,{replace:!0})}function QEe(e,t){t(e,{replace:!0})}function XEe(e){return!e||typeof e!="object"?!1:Reflect.get(e,"canGoBack")===!0}async function ZEe(){await bt("plugin:app|exit")}function JEe(){const e=window.history.state;return(e==null?void 0:e.__cortexOverlay)===!0}function eRe(e,t){const n=f.useRef({pathname:e,navigate:t});n.current={pathname:e,navigate:t},f.useEffect(()=>xve(r=>{const o=n.current,s=window.history.state,a=GEe(XEe(r),s);YEe(o.pathname,JEe(),a,{historyBack:()=>window.history.back(),exit:ZEe,navigate:o.navigate}).catch(()=>{})}),[])}function tRe(e){return{title:e.title,body:e.meta}}function B1(){return dr()}let Ba=null,Ip;const XU="cortex.mobile.notifications.permission-requested";let Ng=!1;function nRe(){if(!No())return Ng;try{return Ng||localStorage.getItem(XU)==="true"}catch{return Ng}}function rRe(){if(Ng=!0,!!No())try{localStorage.setItem(XU,"true")}catch{}}async function Wk(){if(!B1())return!1;try{const{isPermissionGranted:e}=await np(async()=>{const{isPermissionGranted:t}=await import("./index-C6HFAjjh.js");return{isPermissionGranted:t}},[]);Ba=await e()}catch{Ba=!1}return Ba}async function oRe(){if(await Wk())return!0;if(nRe()||No()&&typeof document<"u"&&document.visibilityState!=="visible")return!1;rRe();try{const{requestPermission:e}=await np(async()=>{const{requestPermission:t}=await import("./index-C6HFAjjh.js");return{requestPermission:t}},[]);Ba=await e()==="granted"}catch{Ba=!1}return Ba}async function ZU(){return B1()?Ip||(Ba!==null?Ba:(Ip=oRe().finally(()=>{Ip=void 0}),Ip)):!1}async function iRe(e,t){if(!B1())return!1;try{if(!await ZU())return!1;if(No()){const r=await bt("plugin:cortex-notifications|post",{...e,data:t});if(!hh(r))return r.ok}const{sendNotification:n}=await np(async()=>{const{sendNotification:r}=await import("./index-C6HFAjjh.js");return{sendNotification:r}},[]);return n({...e,extra:t,autoCancel:!0}),!0}catch{return!1}}function sRe(e){if(!e||typeof e!="object")return;const t=Reflect.get(e,"notification"),n=t&&typeof t=="object"?Reflect.get(t,"extra")??Reflect.get(e,"extra"):Reflect.get(e,"extra");return n&&typeof n=="object"?n:void 0}async function JE(e,t){let n=(t==null?void 0:t.aborted)??!1,r=()=>{};const o=()=>{n=!0,t==null||t.removeEventListener("abort",o),r()};t==null||t.addEventListener("abort",o,{once:!0});try{const{onAction:s}=await np(async()=>{const{onAction:c}=await import("./index-C6HFAjjh.js");return{onAction:c}},[]);if(n)return o;const a=await s(c=>{n||Promise.resolve(e(sRe(c))).catch(()=>{})});let l=!1;r=()=>{l||(l=!0,a.unregister().catch(()=>{}))},n&&r()}catch{o()}return o}async function aRe(e,t){if(!B1()||t!=null&&t.aborted)return()=>{};if(!No())return JE(e,t);try{return await y1()?vve(r=>e({...r}),t):JE(e,t)}catch{return()=>{}}}let Iu={status:null,supported:null,pending:!1,error:null};const Rw=new Set;let n2=Promise.resolve();const Jv=()=>typeof document<"u"&&document.visibilityState==="visible",eR=()=>Iu,lRe=e=>(Rw.add(e),()=>{Rw.delete(e)});function cc(e){Iu={...Iu,...e},Rw.forEach(t=>t())}async function JU(e,t){const n=await bt("mobile_notifications_configure",{enabled:e,locale:t,completionNotifications:!0});if(!n.ok)throw new Error("Native notification configuration failed");return n.value}function cRe(){var e;return((e=Iu.status)==null?void 0:e.completionNotifications)===!0&&Iu.status.enabled}function Mw(e){return n2=n2.then(e).catch(()=>{cc({error:"configure",pending:!1})}),n2}async function tR(e,t,n){if(!n()||!Jv())return;const r=await y1();if(!n())return;cc({status:r,supported:r!==null});const o=await(t?ZU():Wk());if(!r||!n()||!Jv())return;if(r.enabled&&!o){cc({status:{...r,permissionGranted:!1}});return}const s=await JU(r.enabled,e);n()&&cc({status:s,error:null})}function dRe(e){if(!No())return()=>{};let t=!0;const n=()=>{Mw(()=>tR(e,!1,()=>t))};return Mw(()=>tR(e,!0,()=>t)),document.addEventListener("visibilitychange",n),window.addEventListener("focus",n),()=>{t=!1,document.removeEventListener("visibilitychange",n),window.removeEventListener("focus",n)}}function uRe(e){f.useEffect(()=>dRe(e),[e])}function pRe(){return f.useSyncExternalStore(lRe,eR,eR)}function fRe(e,t){return!No()||Iu.pending?Promise.resolve():(cc({pending:!0,error:null}),Mw(async()=>{if(e&&(!Jv()||!await Wk()||!Jv())){cc({pending:!1,error:"permission"});return}const n=await JU(e,t);cc({status:n,supported:!0,pending:!1,error:null})}))}const hRe=/^\/m\/session\/([^/]+)$/;function eV(e){const t=hRe.exec(e);if(!t)return null;try{return Th(decodeURIComponent(t[1]))??null}catch{return null}}function Th(e){if(!(typeof e!="string"||!e.trim()||e.length>512)&&!/[\u0000-\u001f\u007f]/.test(e))try{return encodeURIComponent(e),e}catch{return}}async function mRe(e,t){const n=Th(e.sessionId);if(!n)return{path:"/m/sessions"};const r=(await t.sessions()).find(o=>o.sessionId===n);return r?{path:`/m/session/${encodeURIComponent(n)}`,projectId:r.projectId??void 0}:{path:"/m/sessions"}}async function gRe(e,t){const n=Th(e.approvalId);if(!n)return{path:"/m/approvals"};const r=(await t.approvals()).find(o=>o.id===n);return r?{path:`/m/approvals?approvalId=${encodeURIComponent(n)}`,projectId:r.projectId??void 0}:{path:"/m/approvals"}}async function vRe(e,t){const n=e.kind??(e.sessionId?"session":"sessions");return n==="session"?mRe(e,t):n==="approvals"?gRe(e,t):{path:"/m/sessions"}}function zi(e,t=Date.now()){if(!e)return"";const n=Date.parse(e);if(Number.isNaN(n))return"";const r=t-n;if(r<0)return"现在";const o=Math.floor(r/6e4);if(o<1)return"现在";if(o<60)return`${o} 分钟`;const s=Math.floor(o/60);if(s<24)return`${s} 小时`;const a=Math.floor(s/24);return a===1?"昨天":a<7?`${a} 天前`:`${Math.floor(a/7)} 周前`}function M0(e){return e==null||Number.isNaN(e)?"—":yn(e)}function dn(e,t){return e==="zh"?t.zh:t.en}function xRe({items:e,now:t=Date.now(),onDismiss:n,onActivate:r}){if(e.length===0)return null;const{visible:o}=B$(e);return i.jsx("div",{style:{position:"fixed",top:"calc(10px + env(safe-area-inset-top))",left:10,right:10,zIndex:1e3,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none"},children:o.map(s=>i.jsxs("div",{role:"button",onClick:()=>r(s),style:{pointerEvents:"auto",background:"var(--panel-translucent-bg)",border:"1px solid var(--panel-translucent-border)",borderRadius:20,boxShadow:"var(--shadow-toast)",padding:"11px 13px",display:"flex",gap:10,alignItems:"center",cursor:"pointer"},children:[i.jsx("div",{"aria-label":"Cortex",style:{width:36,height:36,borderRadius:9,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center",flex:"none"},children:i.jsxs("svg",{width:25,height:25,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[i.jsx("circle",{cx:33,cy:32,r:5,fill:"var(--brand-badge-core)"}),i.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"}),i.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"})]})}),i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:12.5,fontWeight:650,color:y.ink,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.title}),i.jsx("div",{style:{fontSize:11,color:y.sub,marginTop:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.meta})]}),i.jsx("span",{style:{font:`400 10px ${H}`,color:y.faint,flex:"none",alignSelf:"flex-start"},children:zi(s.ts,t)||"现在"}),i.jsx("button",{type:"button","aria-label":"Dismiss",onClick:a=>{a.stopPropagation(),n(s.id)},style:{border:"none",background:"transparent",color:y.faint,fontSize:12,cursor:"pointer",flex:"none",padding:"0 2px"},children:"✕"})]},s.id))})}function yRe(){const e=dl(),t=Xe(),{setCurrentProject:n}=zt();f.useEffect(()=>{const r=new AbortController;let o=()=>{};return aRe(async s=>{if(!s||r.signal.aborted)return!1;const a=await vRe(s,{sessions:()=>e.sessions.list.query({origin:"direct"}),approvals:()=>e.approvals.list.query({status:"pending"})}),l=s.scope===void 0?null:await y1();if(r.signal.aborted||s.scope!==void 0&&s.scope!==(l==null?void 0:l.scope))return!1;a.projectId&&n(a.projectId),t(a.path)},r.signal).then(s=>{r.signal.aborted?s():o=s}),()=>{r.abort(),o()}},[e,t,n])}function bRe(e){if(e.sessionId&&cRe())return Promise.resolve(!0);const t=e.sessionId?{kind:"session",sessionId:e.sessionId,projectId:e.projectId??""}:{kind:"sessions"};return iRe(tRe(e),t)}function wRe(){const e=fo(),t=f.useRef(e.pathname);return t.current=e.pathname,f.useCallback(n=>document.visibilityState==="visible"&&eV(t.current)===n,[])}function SRe(){const e=eV(fo().pathname);f.useEffect(()=>{const t=()=>{V9(document.visibilityState==="visible"?e:null)};return t(),document.addEventListener("visibilitychange",t),()=>{document.removeEventListener("visibilitychange",t),V9(null)}},[e])}function kRe(){const e=Xe(),{setCurrentProject:t}=zt();uRe(ht()),yRe(),SRe();const n=f.useCallback((l,c)=>{if(!Th(l)){e("/m/sessions");return}c&&t(c),e(`/m/session/${encodeURIComponent(l)}`)},[e,t]),r=wRe(),{items:o,dismiss:s}=$$({isSessionOpen:r,externalDelivery:bRe}),a=f.useCallback(l=>{n(l.sessionId,l.projectId),s(l.id)},[s,n]);return i.jsx(xRe,{items:o,onDismiss:s,onActivate:a})}const jRe="'IBM Plex Mono', monospace",CRe={position:"fixed",inset:0,zIndex:60,background:"var(--overlay-scrim-strong)",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 36px",boxSizing:"border-box"},TRe={width:"100%",background:"var(--proto-card)",borderRadius:18,boxShadow:"var(--shadow-overlay-strong)",padding:"24px 20px 14px",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center"},PRe={width:46,height:46,borderRadius:14,background:"var(--proto-accent-bg)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:14},ERe={fontSize:17,fontWeight:700,color:"var(--proto-ink)",letterSpacing:"-.01em"},RRe={font:`500 10.5px ${jRe}`,color:"var(--proto-muted-3)",marginTop:6},MRe={fontSize:13,lineHeight:1.6,color:"var(--proto-muted)",textAlign:"center",margin:"10px 0 18px"};function IRe({title:e,summary:t}){return i.jsxs(i.Fragment,{children:[i.jsx("div",{style:PRe,children:i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.8",children:[i.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),i.jsx("path",{d:"M3.5 16.5h13"})]})}),i.jsx("div",{style:ERe,children:e}),i.jsx("div",{style:RRe,children:t})]})}function tV(e){return i.jsx("div",{role:"dialog","aria-modal":"true","aria-label":e.title,style:CRe,children:i.jsxs("div",{style:TRe,children:[i.jsx(IRe,{title:e.title,summary:e.summary}),i.jsx("div",{style:MRe,children:e.description}),e.children]})})}const ARe={width:"100%",display:"flex",flexDirection:"column",gap:2},DRe={height:48,border:"none",borderRadius:13,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14.5,fontWeight:600,cursor:"pointer",width:"100%"},nR={height:44,border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600,color:"var(--proto-muted-2)",cursor:"pointer",flex:1};function LRe(e){return i.jsxs("div",{style:ARe,children:[i.jsx("button",{type:"button",onClick:e.onInstall,disabled:e.busy,style:{...DRe,opacity:e.busy?.6:1},children:e.busy?"正在处理…":V$(e.update.kind)}),i.jsxs("div",{style:{display:"flex",width:"100%"},children:[i.jsx("button",{type:"button",onClick:e.onSkip,style:nR,children:"跳过此版本"}),i.jsx("button",{type:"button",onClick:e.onDismiss,style:nR,children:"稍后"})]})]})}function ORe(e){return i.jsxs(tV,{title:"App 新版本已就绪",summary:U$(e.update),description:q$(e.update.kind),children:[e.error?i.jsxs("div",{style:{fontSize:12,color:"var(--proto-danger)",marginBottom:10,textAlign:"center"},children:["安装失败:",e.error]}):null,i.jsx(LRe,{...e})]})}const NRe={width:"100%",display:"flex",flexDirection:"column",gap:2},FRe={height:48,border:"none",borderRadius:13,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14.5,fontWeight:600,cursor:"pointer",width:"100%"},zRe={height:44,border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600,color:"var(--proto-muted-2)",cursor:"pointer",width:"100%"};function BRe(e){return i.jsxs("div",{style:NRe,children:[i.jsx("button",{type:"button",onClick:e.onApply,style:FRe,children:"退出 App"}),i.jsx("button",{type:"button",onClick:e.onDismiss,style:zRe,children:"忽略"})]})}function $Re(e){return i.jsx(tV,{title:"新版本已就绪",summary:H$(e.update),description:"热更新已在后台下载完成,重启 App 后生效。运行中的线程在服务端继续执行,不受重启影响。",children:i.jsx(BRe,{onApply:e.onApply,onDismiss:e.onDismiss})})}function _Re(){const e=X$();return e?e.kind==="hot"?i.jsx($Re,{update:e.update,onApply:e.apply,onDismiss:e.dismiss}):i.jsx(ORe,{update:e.update,busy:e.busy,error:e.error,onInstall:e.install,onSkip:e.skip,onDismiss:e.dismiss}):null}const rR="--cortex-vvh",oR="--cortex-vvt";function WRe(e,t){const n=()=>{e.setProperty(rR,`${t.height}px`),e.setProperty(oR,`${t.offsetTop}px`)};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n),e.removeProperty(rR),e.removeProperty(oR)}}function HRe(){f.useEffect(()=>{const e=window.visualViewport;if(e)return WRe(document.documentElement.style,e)},[])}const URe={position:"fixed",top:0,left:0,right:0,height:"var(--cortex-vvh, 100dvh)",transform:"translateY(var(--cortex-vvt, 0px))",display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--proto-alt)"};function VRe({pathname:e,vocab:t,needsYouCount:n,onTab:r}){return i.jsxs("div",{style:URe,children:[i.jsx("div",{style:{flex:1,minHeight:0,overflow:"hidden"},children:i.jsx(_Ee,{})}),AEe(e)&&i.jsx(VEe,{vocab:t,activeId:IEe(e),needsYouCount:n,onNavigate:r})]})}function qRe({children:e}){return i.jsx(o$,{children:i.jsx(t_,{children:i.jsx(T$,{children:i.jsx(SB,{children:i.jsxs(IB,{children:[e,i.jsx(kRe,{}),i.jsx(_Re,{})]})})})})})}function KRe(){var a;const e=O(),t=fo(),n=Xe(),r=he();HRe(),eRe(t.pathname,n);const s=((a=ae(r.approvals.list.queryOptions({status:"pending"})).data)==null?void 0:a.length)??0;return i.jsx(qRe,{children:i.jsx(VRe,{pathname:t.pathname,vocab:e,needsYouCount:s,onTab:l=>QEe(l,n)})})}function GRe(e){return e.awaitingInput?{kind:"awaiting",text:"等待操作"}:e.running&&e.backgroundRunning?{kind:"background",text:"后台运行"}:e.running?{kind:"running",text:e.numTurns!=null?`running · ${e.numTurns} turns`:"running"}:{kind:"idle",text:"空闲"}}function YRe(e,t){return{id:e.sessionId,title:e.label||e.name||e.sessionId,time:zi(e.lastUsedAt||e.createdAt,t),running:e.running,numTurns:e.numTurns,unread:e.unread}}function QRe(e,t=Date.now()){return H7e(e,t).map(n=>({key:n.label,rows:n.items.map(r=>YRe(r,t))}))}function XRe(e,t){return t==="TODAY"?e.today:t==="YESTERDAY"?e.yesterday:e.earlier}function ZRe({onClick:e}){return i.jsx("button",{type:"button","aria-label":"New session",onClick:e,style:{width:34,height:34,borderRadius:"50%",background:y.ink,border:"none",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ink-solid-fg)",lineHeight:0,cursor:"pointer"},children:i.jsx(gc,{size:15,strokeWidth:1.9})})}function JRe({unread:e,onClick:t}){return i.jsxs("div",{style:{position:"relative",flex:"none"},children:[i.jsx("button",{type:"button","aria-label":"Scheduled",onClick:t,style:{width:34,height:34,borderRadius:"50%",background:y.card,border:`1px solid ${y.hairline}`,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},children:i.jsxs("svg",{width:16,height:16,viewBox:"0 0 14 14",fill:"none",stroke:y.sub,strokeWidth:1.5,children:[i.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),i.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]})}),e>0&&i.jsx("span",{"aria-label":`${e} unread scheduled`,style:{position:"absolute",top:-3,right:-4,background:y.run,color:"var(--ink-solid-fg)",font:`600 8.5px ${H}`,padding:"1px 4.5px",borderRadius:999,border:`1.5px solid ${y.canvas}`},children:e})]})}function eMe({row:e,byId:t,onOpen:n}){const r=t.get(e.id),o=r?GRe(r):{kind:"idle",text:"空闲"},s=o.kind==="running"||o.kind==="background";return i.jsxs(et,{radius:9,padding:"12px 13px",onClick:()=>n(e.id),style:s?{boxShadow:`inset 2px 0 0 ${y.run}`}:void 0,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[e.unread&&i.jsx("span",{"aria-label":"unread",style:{width:7,height:7,borderRadius:"50%",background:y.run,flex:"none"}}),i.jsx("span",{style:{fontSize:14,fontWeight:e.unread?600:400,color:e.unread?y.ink:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint,flex:"none"},children:e.time})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginTop:4},children:[o.kind==="running"&&i.jsx(Mi,{color:y.run,pulse:!0}),o.kind==="background"&&i.jsx(Mi,{color:y.run,pulse:!0}),o.kind==="awaiting"&&i.jsx(Mi,{color:y.amber,pulse:!0}),i.jsx("span",{style:{font:`400 10px ${H}`,color:s?y.run:y.muted},children:o.text})]})]})}function tMe({groups:e,sessions:t,scope:n,copy:r,scheduled:o,onOpen:s,onNew:a}){const l=new Map(t.map(c=>[c.sessionId,c]));return i.jsx(At,{label:"1a 会话列表",header:i.jsx(Hx,{title:r.title,qn:n,trailing:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o&&i.jsx(JRe,{unread:o.unread,onClick:o.onOpen}),i.jsx(ZRe,{onClick:a})]})}),children:i.jsxs(Yn,{gap:6,children:[e.length===0&&i.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:y.faint,fontSize:13},children:r.empty}),e.map(c=>i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx(fu,{style:{padding:"6px 2px 2px"},children:XRe(r,c.key)}),c.rows.map(d=>i.jsx(eMe,{row:d,byId:l,onOpen:s},d.id))]},c.key))]})})}const Os={display:"block",marginBottom:5,color:y.faint,font:`600 9.5px ${H}`,letterSpacing:".05em"},Bi={width:"100%",minHeight:40,boxSizing:"border-box",border:`1px solid ${y.hairline}`,borderRadius:9,padding:"8px 10px",background:y.card,color:y.ink,fontSize:13},Hk={display:"grid",gridTemplateColumns:"1fr 1fr",gap:8};function nMe({copy:e,mode:t,onBack:n}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"0 2px 12px"},children:[i.jsx("button",{type:"button","data-action":"sheet-back",onClick:n,"aria-label":e.back,style:{border:0,background:"transparent",color:y.run,fontSize:20,padding:"0 3px",cursor:"pointer"},children:"‹"}),i.jsx("span",{style:{fontSize:17,fontWeight:700,color:y.ink},children:t==="edit"?e.scEditSchedule:e.scNewSchedule})]})}function rMe({copy:e,form:t,editableFields:n,onChange:r}){const o={interval:e.scTypeInterval,daily:e.scTypeDaily,weekly:e.scTypeWeekly,once:e.scTypeOnce};return i.jsxs("div",{children:[i.jsx("span",{style:Os,children:e.scType}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",border:`1px solid ${y.hairline}`,borderRadius:9,overflow:"hidden"},children:_5.map(s=>i.jsx(oMe,{type:s,form:t,disabled:!n.type,label:o[s],onChange:r},s))})]})}function oMe({type:e,form:t,disabled:n,label:r,onChange:o}){const s=t.type===e;return i.jsx("button",{type:"button",disabled:n,"aria-pressed":s,onClick:()=>o({type:e}),style:{border:0,borderRight:e==="once"?0:`1px solid ${y.hairline}`,padding:"8px 2px",background:s?"var(--proto-accent-bg)":y.card,color:s?y.run:y.muted,fontSize:10.5},children:r})}function iMe({copy:e,form:t,editableFields:n,onChange:r}){return rp(t.type).time?i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scTime}),i.jsx("input",{style:Bi,value:t.time,disabled:!n.time,onChange:o=>r({time:o.target.value})})]}):null}function sMe({copy:e,form:t,editableFields:n,onChange:r}){return rp(t.type).interval?i.jsxs("div",{children:[i.jsx("span",{style:Os,children:e.scEvery}),i.jsxs("div",{style:Hk,children:[i.jsx("input",{style:Bi,type:"number",min:1,value:t.intervalValue,disabled:!n.interval,onChange:o=>r({intervalValue:Number(o.target.value)})}),i.jsx("select",{style:Bi,value:t.intervalUnit,disabled:!n.interval,onChange:o=>r({intervalUnit:o.target.value}),children:Av.map(o=>i.jsx("option",{value:o,children:o},o))})]})]}):null}function aMe({copy:e,form:t,editableFields:n,onChange:r}){return!rp(t.type).delay||!n.delay?null:i.jsxs("div",{"data-schedule-delay":!0,children:[i.jsx("span",{style:Os,children:e.scIn}),i.jsxs("div",{style:Hk,children:[i.jsx("input",{style:Bi,type:"number",min:1,value:t.delayValue,onChange:o=>r({delayValue:Number(o.target.value)})}),i.jsx("select",{style:Bi,value:t.delayUnit,onChange:o=>r({delayUnit:o.target.value}),children:Av.map(o=>i.jsx("option",{value:o,children:o},o))})]})]})}function lMe({copy:e,form:t,mode:n}){return n!=="edit"||t.type!=="once"?null:i.jsx("div",{"data-once-timing-note":!0,style:{border:`1px solid ${y.hairline}`,borderRadius:9,padding:10,color:y.muted,fontSize:11.5,lineHeight:1.5},children:e.scOnceTimingUnavailable})}function cMe({copy:e,form:t,editableFields:n,onChange:r}){if(!rp(t.type).dayOfWeek)return null;const o=[e.scDaySun,e.scDayMon,e.scDayTue,e.scDayWed,e.scDayThu,e.scDayFri,e.scDaySat];return i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scDay}),i.jsx("select",{style:Bi,value:t.dayOfWeek,disabled:!n.dayOfWeek,onChange:s=>r({dayOfWeek:Number(s.target.value)}),children:m$.map(s=>i.jsx("option",{value:s.value,children:o[s.value]??s.label},s.value))})]})}function dMe({copy:e,form:t,editableFields:n,profileOptions:r,onChange:o}){return i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scProfile}),i.jsx("select",{style:Bi,value:t.profile,disabled:!n.profile,onChange:s=>o({profile:s.target.value}),children:r.map(s=>i.jsx("option",{value:s,children:s},s))})]})}function uMe({copy:e,form:t,editableFields:n,onChange:r}){return i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scMessage}),i.jsx("textarea",{style:{...Bi,minHeight:82,resize:"vertical"},value:t.message,disabled:!n.message,onChange:o=>r({message:o.target.value})})]})}function pMe({copy:e,form:t,mode:n,editableFields:r,onChange:o}){return i.jsxs("div",{style:{...Hk,opacity:n==="edit"?.6:1},children:[i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scTarget}),i.jsx("select",{style:Bi,value:t.target,disabled:!r.target,onChange:s=>o({target:s.target.value}),children:h$.map(s=>i.jsx("option",{value:s,children:s},s))})]}),i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scFallback}),i.jsx("select",{style:Bi,value:t.fallback,disabled:!r.fallback,onChange:s=>o({fallback:s.target.value}),children:f$.map(s=>i.jsx("option",{value:s,children:s},s))})]})]})}function fMe({copy:e,mode:t,valid:n,pending:r,error:o,onSubmit:s}){return i.jsxs(i.Fragment,{children:[o&&i.jsx("div",{role:"alert",style:{color:y.fail,fontSize:11.5},children:o}),i.jsx("button",{type:"button","data-action":"save-schedule",disabled:!n||r,onClick:s,style:{border:0,borderRadius:9,padding:11,background:y.run,color:"var(--ink-solid-fg)",fontSize:13,fontWeight:700},children:t==="edit"?e.scSaveSchedule:e.scCreateSchedule})]})}function hMe(e){return i.jsxs("div",{style:{display:"grid",gap:12},children:[i.jsx(rMe,{...e}),i.jsx(iMe,{...e}),i.jsx(sMe,{...e}),i.jsx(aMe,{...e}),i.jsx(lMe,{...e}),i.jsx(cMe,{...e}),i.jsx(dMe,{...e}),i.jsx(uMe,{...e}),i.jsx(pMe,{...e}),i.jsx(fMe,{...e})]})}function mMe(e){const t=O(),n={...e,copy:t};return i.jsxs("div",{"data-mobile-schedule-editor":!0,children:[i.jsx(nMe,{...n}),i.jsx(hMe,{...n})]})}function Uk({size:e,color:t}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",stroke:t,strokeWidth:1.6,style:{flex:"none"},children:[i.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),i.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]})}function gMe({sub:e}){return e.kind!=="run"?null:i.jsxs(i.Fragment,{children:[e.stamp,e.cost&&i.jsxs(i.Fragment,{children:[" · ",e.cost]})]})}function vMe({sub:e,copy:t}){return e.kind!=="pending"?null:i.jsxs(i.Fragment,{children:[e.cadence,e.nextDelta&&i.jsxs(i.Fragment,{children:[" · ",t.nextIn.replace("{d}",e.nextDelta)]})]})}function xMe({sub:e,copy:t}){return e.kind!=="paused"?null:i.jsxs(i.Fragment,{children:[e.cadence," · ",i.jsx("span",{style:{color:y.amberText},children:t.paused})]})}function yMe({row:e,copy:t,now:n}){const r=kH(e,n);return i.jsxs("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:2},children:[i.jsx(gMe,{sub:r}),i.jsx(vMe,{sub:r,copy:t}),i.jsx(xMe,{sub:r,copy:t})]})}function bMe({rows:e,copy:t}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"0 2px 10px"},children:[i.jsx(Uk,{size:14,color:y.run}),i.jsx("span",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em"},children:t.title}),i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint},children:t.countUnit.replace("{n}",String(e.length))})]})}function wMe(e){return{display:"flex",alignItems:"center",gap:9,padding:13,minHeight:44,boxSizing:"border-box",cursor:"pointer",borderBottom:e?"none":`1px solid ${y.divider}`}}function SMe({row:e,copy:t}){return i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{font:`500 10px ${H}`,color:y.muted,flex:"none"},children:e.kind==="repeat"?`×${e.runs.length}`:t.once}),e.unread&&i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:y.run,flex:"none"}}),i.jsx("span",{style:{fontSize:13,color:y.faint,flex:"none"},children:"›"})]})}function kMe({row:e,copy:t,now:n,last:r,onRow:o}){return i.jsxs("div",{"data-schedule-row":e.scheduleId,onClick:()=>o(e),style:wMe(r),children:[i.jsx(Uk,{size:13,color:e.unread?y.run:y.faint}),i.jsx(jMe,{row:e,copy:t,now:n}),i.jsx(SMe,{row:e,copy:t})]})}function jMe({row:e,copy:t,now:n}){return i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:14,fontWeight:e.unread?600:400,color:e.unread?y.ink:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),i.jsx(yMe,{row:e,copy:t,now:n})]})}function CMe({rows:e,copy:t,now:n,onRow:r}){return i.jsx("div",{style:{background:y.card,border:`1px solid ${y.hairline}`,borderRadius:13,overflow:"hidden"},children:e.map((o,s)=>i.jsx(kMe,{row:o,copy:t,now:n,last:s===e.length-1,onRow:r},o.scheduleId))})}function TMe({rows:e,copy:t,now:n,onRow:r}){return i.jsxs(i.Fragment,{children:[i.jsx(bMe,{rows:e,copy:t}),i.jsx(CMe,{rows:e,copy:t,now:n,onRow:r})]})}function PMe(e,t,n){const r=e.schedule;if(!r)return null;const o=kk(r.nextRun,n),s=r.paused?` · ${t.paused}`:o?` · ${t.nextIn.replace("{d}",o)}`:"";return Kv(r)+s}function EMe({row:e,copy:t,now:n,onBack:r}){const o=PMe(e,t,n);return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"0 2px 10px"},children:[i.jsx("span",{"data-action":"sheet-back",onClick:r,style:{fontSize:15,color:y.run,flex:"none",cursor:"pointer",padding:"0 2px"},children:"‹"}),i.jsx(Uk,{size:14,color:y.run}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),o&&i.jsx("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:1},children:o})]})]})}function RMe(){return i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"64px 1fr 70px",gap:10,padding:"4px 15px 6px",font:`600 9.5px ${H}`,color:y.faint,letterSpacing:".05em"},children:[i.jsx("span",{children:"RUN"}),i.jsx("span",{children:"FIRED"}),i.jsx("span",{style:{textAlign:"right"},children:"COST"})]})}function MMe(e){return{display:"grid",gridTemplateColumns:"64px 1fr 70px",gap:10,padding:13,minHeight:44,boxSizing:"border-box",alignItems:"center",cursor:"pointer",borderTop:e?"none":`1px solid ${y.divider}`}}function IMe({run:e,ordinal:t}){return i.jsxs("span",{style:{font:`${e.unread?600:400} 12px ${H}`,color:e.unread?y.ink:"var(--proto-muted)",display:"flex",alignItems:"center",gap:6},children:["#",t,e.unread&&i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:y.run}})]})}function AMe({cost:e}){return i.jsx("span",{style:{font:`400 12px ${H}`,color:y.muted,textAlign:"right"},children:e!=null?yn(e):"—"})}function DMe({run:e,ordinal:t,first:n,now:r,onOpenRun:o}){return i.jsxs("div",{"data-run-row":e.sessionId,onClick:()=>o(e.sessionId),style:MMe(n),children:[i.jsx(IMe,{run:e,ordinal:t}),i.jsx("span",{style:{font:`400 12px ${H}`,color:"var(--proto-muted-2)"},children:jk(e,r)}),i.jsx(AMe,{cost:e.costUsd})]})}function LMe({row:e,now:t,onOpenRun:n}){const r=Ck(e.runs);return i.jsx("div",{style:{background:y.card,border:`1px solid ${y.hairline}`,borderRadius:13,overflow:"hidden",maxHeight:"46vh",overflowY:"auto"},children:e.runs.map((o,s)=>i.jsx(DMe,{run:o,ordinal:r.get(o.sessionId),first:s===0,now:t,onOpenRun:n},o.sessionId))})}function OMe({row:e,copy:t,onEdit:n}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 4px 0",gap:10},children:[i.jsx("span",{style:{fontSize:12,fontWeight:600,color:y.muted},children:t.allRuns.replace("{n}",String(e.runs.length))}),n&&i.jsx("button",{type:"button","data-action":"edit-schedule",onClick:n,style:{border:0,background:"transparent",color:y.run,fontSize:11.5,fontWeight:600,cursor:"pointer"},children:t.edit}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint},children:t.runListHint})]})}function NMe({row:e,copy:t,now:n,onBack:r,onOpenRun:o,onEdit:s}){return i.jsxs(i.Fragment,{children:[i.jsx(EMe,{row:e,copy:t,now:n,onBack:r}),i.jsx(RMe,{}),i.jsx(LMe,{row:e,now:n,onOpenRun:o}),i.jsx(OMe,{row:e,copy:t,onEdit:s})]})}function FMe(e){const[t,n]=f.useState({kind:"list"}),r=f.useCallback(()=>n(s=>s.kind==="editor"?(e.close(),s.returnTo):{kind:"list"}),[e.close]),o=f.useCallback((s,a)=>{e.openEdit(s),n({kind:"editor",returnTo:a})},[e.openEdit]);return{level:t,setLevel:n,back:r,openEditor:o}}function zMe(e,t,n){return f.useCallback(r=>{const o=SH(r);if(o.type==="modal"){t({kind:"runs",scheduleId:r.scheduleId});return}if(o.type==="open")return e(o.sessionId);n(o.schedule,{kind:"list"})},[e,n,t])}function BMe(e,t){return f.useCallback(()=>{e.submit().then(n=>{n&&t(r=>r.kind==="editor"?r.returnTo:{kind:"list"})})},[e.submit,t])}function $Me(e,t){return t.kind!=="runs"?null:e.find(n=>n.scheduleId===t.scheduleId)??null}function _Me({row:e,copy:t,now:n,back:r,onOpenSession:o,openEditor:s}){const a=e.schedule?()=>s(e.schedule,{kind:"runs",scheduleId:e.scheduleId}):void 0;return i.jsx(NMe,{row:e,copy:t,now:n,onBack:r,onOpenRun:o,onEdit:a})}function WMe(e,t,n,r){return e.kind!=="editor"||!t.form||!t.mode?null:i.jsx(mMe,{form:t.form,mode:t.mode,editableFields:t.editableFields,profileOptions:t.profileOptions,valid:t.valid,pending:t.pending,error:t.error,onChange:t.onChange,onSubmit:n,onBack:r})}function HMe({rows:e,copy:t,editor:n,level:r,runsRow:o,now:s,back:a,onOpenSession:l,onRow:c,openEditor:d,submit:u}){const p=WMe(r,n,u,a);return p||(o?i.jsx(_Me,{row:o,copy:t,now:s,back:a,onOpenSession:l,openEditor:d}):i.jsx(TMe,{rows:e,copy:t,now:s,onRow:c}))}function UMe(e){const{rows:t,editor:n,onOpenSession:r,onClose:o}=e,s=FMe(n),a=$Me(t,s.level),l=zMe(r,s.setLevel,s.openEditor),c=BMe(n,s.setLevel),d=f.useCallback(()=>{n.close(),o()},[n.close,o]),u=s.level.kind==="list"?void 0:s.back;return i.jsx(li,{onClose:d,onBack:u,children:i.jsx(HMe,{...e,level:s.level,runsRow:a,now:e.now??Date.now(),back:s.back,onRow:l,openEditor:s.openEditor,submit:c})})}function VMe(e){const t=O(),{toast:n}=Fn(),r=y$({onCreated:()=>n({title:t.scToastCreated,tone:"done"}),onUpdated:()=>n({title:t.scToastUpdated,tone:"done"}),onError:(o,s)=>n({title:o==="edit"?t.scToastUpdateFailed:t.scToastCreateFailed,description:s.message,tone:"failed"})});return i.jsx(UMe,{...e,editor:r})}const qMe={en:{title:"Sessions",today:"Today",yesterday:"Yesterday",earlier:"Earlier",empty:"No sessions yet"},zh:{title:"会话",today:"今天",yesterday:"昨天",earlier:"更早",empty:"暂无会话"}},KMe={en:{title:"Scheduled",countUnit:"{n}",once:"once",paused:"paused",nextIn:"next in {d}",allRuns:"all {n} runs",runListHint:"tap a run → opens that session",edit:"Edit schedule"},zh:{title:"Scheduled",countUnit:"{n} 个",once:"单次",paused:"已暂停",nextIn:"{d} 后运行",allRuns:"全部 {n} runs",runListHint:"点击任意 run → 打开该次会话",edit:"编辑调度"}};function GMe(){const e=he(),t=Xe(),n=ht(),r=dn(n,qMe),o=dn(n,KMe),{currentProjectId:s}=zt();Tk();const a=tl(s,"direct"),l=tl(s,"scheduled"),c=ae(e.schedules.list.queryOptions({projectId:s??void 0})),d=a.data??[],u=f.useMemo(()=>QRe(d),[d]),p=f.useMemo(()=>wH(c.data??[],l.data??[]),[c.data,l.data]),h=s?jh(s):void 0,[m,x]=f.useState(!1);return a.isLoading?i.jsx(At,{label:"1a 会话列表",children:i.jsx("div",{style:{padding:16,color:y.muted,fontSize:13},children:r.empty})}):i.jsxs(i.Fragment,{children:[i.jsx(tMe,{groups:u,sessions:d,scope:h,copy:r,scheduled:p.length>0?{unread:CH(p),onOpen:()=>x(!0)}:void 0,onOpen:v=>t(`/m/session/${v}`),onNew:()=>t("/m/session/new")}),m&&i.jsx(VMe,{rows:p,copy:o,onOpenSession:v=>{x(!1),t(`/m/session/${v}`,{replace:!0})},onClose:()=>x(!1)})]})}function YMe(e){return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`}function QMe(e,t){const n=new Date(e),r=a=>new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),o=Math.round((r(t)-r(n))/864e5),s=YMe(n);return o<=0?`今天 ${s}`:o===1?`昨天 ${s}`:`${n.getMonth()+1}月${n.getDate()}日 ${s}`}function XMe(e){return e==="completed"?"done":e==="running"?"running":"pending"}function ZMe(e){const t=Math.max(0,Math.round(e/6e4));if(t<60)return`${t}m`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}h`:`${n}h ${r}m`}function JMe(e){const t=e.steps.map((o,s)=>({label:o.stage??`Step ${o.stepIndex+1}`,state:XMe(o.status),lineDone:s>0&&e.steps[s-1].status==="completed"})),n=e.status==="running"&&e.currentStep?`${e.currentStep.name} ${e.currentStep.index+1}/${e.totalSteps}`:e.status,r=new Date(e.updatedAt).getTime()-new Date(e.createdAt).getTime();return{name:e.templateName,pillText:n,nodes:t,footer:{elapsed:ZMe(r),cost:yn(e.totalCostUsd),subCount:e.children.length}}}function eIe(e,t){return{names:e.slice(0,t.visibleCount).map(n=>n.kind),overflow:t.hiddenCount}}const nV={zh:{askPill:"Agent 提问",answeredPill:"✓ 已回答",defaultBadge:"默认",customOption:"自定义…(在底部输入)",confirm:"确认",queued:"待答",multiTag:"多选",ttlSuffix:"后按默认继续",planPendingPill:"计划待批",planApprovedPill:"✓ 计划已批准",planRejectedPill:"已驳回",approvedBy:"由你批准",readHint:"批准前建议通读全文",readLink:"阅读 ›",approve:"批准并执行",reject:"驳回并反馈",approveHint:"",viewFullPlan:"查看完整计划 ›",viewOriginalPlan:"查看原计划 ›",rewriteNote:""},en:{askPill:"Agent question",answeredPill:"✓ answered",defaultBadge:"default",customOption:"Custom… (type below)",confirm:"Confirm",queued:"queued",multiTag:"multi",ttlSuffix:"until defaults apply",planPendingPill:"Plan pending",planApprovedPill:"✓ Plan approved",planRejectedPill:"Rejected",approvedBy:"approved by you",readHint:"read the full plan before approving",readLink:"Read ›",approve:"Approve & run",reject:"Reject with note",approveHint:"",viewFullPlan:"View full plan ›",viewOriginalPlan:"View original plan ›",rewriteNote:""}};function Lf({bg:e,fg:t,text:n}){return i.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:999,background:e,color:t,flex:"none"},children:n})}function Fg(e,t,n){return{border:`1px solid ${e&&!t?y.runBorder:y.hairline}`,background:"var(--proto-card)",borderRadius:14,overflow:"hidden",boxShadow:e&&!t?"var(--focus-ring-accent)":void 0,...t?{opacity:.55}:n?{opacity:.9}:{}}}const tIe=i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 14 14",fill:"none",stroke:y.run,strokeWidth:"1.4",style:{flex:"none"},children:[i.jsx("path",{d:"M3 1.5h5.5L11.5 4.5V12.5H3z"}),i.jsx("path",{d:"M5 6.5h4M5 9h4"})]});function nIe({model:e,state:t,copy:n,onPick:r,onToggle:o,onConfirmMulti:s,onCustom:a}){const l=e.status==="pending",c=aa(e,t),d=e.questions.length,u=jS(e.ts,l),[p,h]=f.useState(!1),m=v=>v.answer??t.answers[v.question]??null,x=e.level?$B(e.level):null;return i.jsxs("div",{...e.level?{"data-ask-level":e.level}:{},style:Fg(l,!1,!1),onClick:l?void 0:()=>h(v=>!v),children:[i.jsx("div",{style:{padding:"12px 14px 0"},children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[l?i.jsx(Lf,{bg:x?x.bg:y.runBg,fg:x?x.fg:y.run,text:d>1?`${n.askPill} · ${Math.min(c+1,d)}/${d}`:n.askPill}):i.jsx(Lf,{bg:y.doneBg,fg:y.done,text:n.answeredPill}),i.jsx("span",{style:{font:`400 10px ${H}`,color:y.faint},children:e.shortId}),l&&u!=null?i.jsxs("span",{style:{marginLeft:"auto",font:`500 10px ${H}`,color:y.amberText},children:[wS(u)," ",n.ttlSuffix]}):e.timeLabel?i.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${H}`,color:y.faint},children:e.timeLabel}):null]})}),e.questions.map((v,S)=>{const b=m(v),g=l&&S===c,w=l&&S>c,k=S===d-1;return b!=null&&!g?i.jsxs("div",{style:{padding:`10px 14px ${k?"14px":"0"}`},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",borderRadius:11,padding:"9px 13px"},children:[i.jsx("span",{style:{width:16,height:16,borderRadius:"50%",background:y.done,color:"var(--ink-solid-fg)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,flex:"none"},children:"✓"}),i.jsxs("span",{style:{fontSize:12,color:y.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[v.question," → ",i.jsx("b",{style:{color:y.ink},children:b})]})]}),!l&&p&&v.options.length>0&&i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"8px 0 0"},children:v.options.map(C=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:`1px solid ${b.includes(C.label)?y.runBorder:"var(--proto-line-2)"}`,borderRadius:9,padding:"6px 11px"},children:[i.jsx("span",{style:{fontSize:11.5,color:b.includes(C.label)?y.ink:y.muted},children:C.label}),b.includes(C.label)&&i.jsx("span",{style:{marginLeft:"auto",fontSize:10,fontWeight:700,color:y.done},children:"✓"})]},C.label))})]},v.question):g?i.jsxs("div",{style:{padding:`12px 14px ${k?"14px":"0"}`},children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[i.jsxs("span",{style:{font:`600 10px ${H}`,color:y.run,flex:"none"},children:["Q",S+1]}),i.jsx("span",{style:{fontSize:14.5,fontWeight:600,color:y.ink,lineHeight:1.4},children:v.question}),v.multiSelect&&i.jsx("span",{style:{font:`500 9px ${H}`,color:y.muted,background:y.gray,padding:"1px 6px",borderRadius:5,flex:"none"},children:n.multiTag})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"10px 0 0"},children:[v.options.map((C,T)=>{const P=v.multiSelect&&t.selected.includes(C.label),R=!v.multiSelect&&T===0;return i.jsxs("button",{type:"button",onClick:()=>v.multiSelect?o(C.label):r(C.label),style:{minHeight:44,border:`1.5px solid ${P||R?y.run:"var(--proto-line-3)"}`,borderRadius:11,display:"flex",alignItems:"center",gap:8,padding:"8px 13px",boxSizing:"border-box",background:"var(--proto-card)",cursor:"pointer",textAlign:"left",width:"100%"},children:[v.multiSelect&&i.jsx("span",{style:{fontSize:12,fontWeight:700,color:P?y.run:y.faint,flex:"none"},children:P?"☑":"☐"}),i.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:y.ink,minWidth:0,flex:1,overflowWrap:"anywhere"},children:C.label}),R?i.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:y.runBg,color:y.run,flex:"none"},children:n.defaultBadge}):C.description?i.jsx("span",{style:{marginLeft:"auto",minWidth:0,maxWidth:"55%",font:`400 10px ${H}`,color:"var(--proto-muted-3)",flex:"0 1 auto",textAlign:"right",lineHeight:1.35,whiteSpace:"normal",overflowWrap:"anywhere"},children:C.description}):null]},C.label)}),i.jsx("button",{type:"button",onClick:a,style:{minHeight:44,border:"1.5px solid var(--proto-line-3)",borderRadius:11,display:"flex",alignItems:"center",padding:"8px 13px",boxSizing:"border-box",background:"var(--proto-card)",cursor:"pointer",textAlign:"left",width:"100%"},children:i.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:y.sub},children:n.customOption})}),v.multiSelect&&i.jsx("button",{type:"button",onClick:s,disabled:t.selected.length===0,style:{height:44,borderRadius:11,background:y.ink,color:"var(--ink-solid-fg)",border:"none",fontSize:14,fontWeight:600,cursor:"pointer",opacity:t.selected.length===0?.45:1,width:"100%"},children:n.confirm})]})]},v.question):w?i.jsx("div",{style:{padding:`12px 14px ${k?"14px":"0"}`},children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,border:"1px dashed var(--proto-line-3)",borderRadius:11,padding:"9px 13px",opacity:.6},children:[i.jsxs("span",{style:{font:`600 10px ${H}`,color:"var(--proto-muted-3)",flex:"none"},children:["Q",S+1]}),i.jsx("span",{style:{fontSize:12,color:y.grayInk,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v.question}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint,flex:"none"},children:n.queued})]})},v.question):null})]})}function rIe({model:e,copy:t,dimmed:n=!1,onApprove:r,onRejectStart:o,onOpenRead:s}){const a=e.status==="pending",l=e.status==="rejected",c=e.status==="approved",d=i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[c?i.jsx(Lf,{bg:y.doneBg,fg:y.done,text:t.planApprovedPill}):l?i.jsx(Lf,{bg:y.gray,fg:y.grayInk,text:t.planRejectedPill}):i.jsx(Lf,{bg:y.runBg,fg:y.run,text:t.planPendingPill}),i.jsx("span",{style:{font:`400 10px ${H}`,color:y.faint},children:"ExitPlanMode"}),e.timeLabel&&i.jsxs("span",{style:{marginLeft:"auto",font:`400 10px ${H}`,color:y.faint},children:[e.timeLabel,c?` ${t.approvedBy}`:""]})]}),u=i.jsx("div",{style:{fontSize:a&&!n?14.5:13.5,fontWeight:600,color:c?y.sub:l?y.grayInk:y.ink,lineHeight:1.4,marginTop:8,overflowWrap:"break-word",...l?{textDecoration:"line-through",textDecorationColor:"var(--proto-line)"}:{}},children:e.title});return a&&n?i.jsx("div",{style:Fg(!0,!0,!1),children:i.jsxs("div",{style:{padding:"11px 14px 12px"},children:[d,u,i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",borderRadius:11,padding:"9px 13px",marginTop:9},children:[i.jsx("span",{style:{font:`500 10.5px ${H}`,color:y.sub,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.filePath??""}),i.jsx("span",{role:"button",onClick:s,style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:y.run,flex:"none",cursor:"pointer"},children:t.viewFullPlan})]})]})}):a?i.jsxs("div",{style:Fg(!0,!1,!1),children:[i.jsxs("div",{style:{padding:"12px 14px 0"},children:[d,u]}),i.jsx("div",{style:{padding:"11px 14px 12px"},children:i.jsxs("div",{role:"button",onClick:s,style:{minHeight:52,border:"1px solid var(--proto-accent-bg)",background:"var(--proto-accent-bg)",borderRadius:11,display:"flex",alignItems:"center",gap:10,padding:"9px 13px",boxSizing:"border-box",cursor:"pointer"},children:[tIe,i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{font:`500 11px ${H}`,color:y.ink,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.filePath??`${e.lineCount} lines`}),i.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginTop:2},children:t.readHint})]}),i.jsx("span",{style:{fontSize:12,fontWeight:600,color:y.run,flex:"none"},children:t.readLink})]})}),i.jsxs("div",{style:{display:"flex",gap:8,padding:"0 14px 12px"},children:[i.jsx("button",{type:"button",onClick:o,style:{flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:y.ink,fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:t.reject}),i.jsx("button",{type:"button",onClick:r,style:{flex:1.3,height:44,borderRadius:11,background:y.ink,color:"var(--ink-solid-fg)",border:"none",fontSize:14,fontWeight:600,cursor:"pointer"},children:t.approve})]}),i.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"9px 14px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${H}`,color:"var(--proto-muted-3)"},children:i.jsx("span",{style:{marginLeft:"auto",color:y.faint},children:t.approveHint})})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:Fg(!1,!1,l),children:[i.jsxs("div",{style:{padding:"11px 14px 12px"},children:[d,u]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"9px 14px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${H}`,color:"var(--proto-muted-3)"},children:[e.filePath&&i.jsx("span",{style:{color:y.run,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.filePath}),l&&i.jsx("span",{children:t.rewriteNote}),i.jsx("span",{role:"button",onClick:s,style:{marginLeft:"auto",color:y.run,fontWeight:600,cursor:"pointer",flex:"none"},children:l?t.viewOriginalPlan:t.viewFullPlan})]})]}),l&&e.feedback&&i.jsx("div",{style:{alignSelf:"flex-end",maxWidth:"82%",background:y.ink,color:"var(--ink-solid-fg)",borderRadius:"16px 16px 4px 16px",padding:"9px 13px",fontSize:13.5,lineHeight:1.55,whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:e.feedback})]})}function oIe(e,t){return e==="approved"?{label:`✓ ${t.wbDecApproved}`,fg:y.done,bg:y.doneBg}:e==="explained"?{label:t.wbDecExplainRequested,fg:y.run,bg:y.runBg}:e==="revised"?{label:t.wbDecReviseProposed,fg:y.amberInk,bg:y.amberBg}:null}function iIe(e,t){return e==="approve"?t.wbDecApproved:e==="explain"?t.wbDecExplainRequested:t.wbDecReviseProposed}function sIe({L:e}){return i.jsx("span",{style:{font:`700 8px ${H}`,letterSpacing:".06em",color:y.run,background:y.runBg,border:`1px solid ${y.runBorder}`,borderRadius:4,padding:"2px 5px",flex:"none"},children:e.wbDecBadge})}function r2({label:e,text:t}){return i.jsxs("div",{style:{marginTop:13},children:[i.jsx("div",{style:{font:`600 10px ${H}`,letterSpacing:".05em",color:y.faint,paddingBottom:4},children:e}),i.jsx("div",{style:{fontSize:13,lineHeight:1.6,color:y.body},children:i.jsx(ci,{text:t})})]})}function aIe({open:e}){return i.jsx("span",{style:{width:12,height:12,flex:"none",display:"flex",alignItems:"center",justifyContent:"center",color:y.faint,transform:e?"rotate(90deg)":"none",transition:"transform .16s ease"},children:i.jsx("svg",{width:7,height:10,viewBox:"0 0 7 10",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M1.5 1 5.5 5l-4 4"})})})}function lIe({d:e,actions:t}){const n=O(),[r,o]=f.useState(!1),[s,a]=f.useState("view"),[l,c]=f.useState(""),d=HB(e),u=oIe(d,n),p=!!(t!=null&&t.busy),h=s==="view"?null:UB({explain:n.wbDecExplainTemplate,explainBare:n.wbDecExplainTemplateBare,revise:n.wbDecReviseTemplate},s,e.title,l),m=!p&&h!==null,x=()=>{o(!1),a("view"),c("")},v=()=>{p||t==null||t.respond(e.id,"approve")},S=()=>{!m||s==="view"||(t==null||t.respond(e.id,s,h),x())},b=(g,w)=>i.jsx("span",{role:"button",onClick:()=>a(s===g?"view":g),style:{flex:1,height:38,borderRadius:10,border:`1px solid ${s===g?y.run:y.cardBorder}`,background:s===g?y.runBg:"var(--proto-card)",color:s===g?y.run:y.ink,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600},children:w});return i.jsxs("div",{style:{border:`1px solid ${y.hairline}`,background:"var(--proto-card)",borderRadius:12,boxSizing:"border-box"},children:[i.jsxs("div",{role:"button","data-decision-toggle":e.id,onClick:()=>r?x():o(!0),style:{display:"flex",alignItems:"center",gap:8,padding:"9px 11px"},children:[i.jsx(sIe,{L:n}),i.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:y.ink,minWidth:0,flex:1,lineHeight:1.4,...r?{overflowWrap:"break-word"}:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},children:e.title}),u&&i.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:999,background:u.bg,color:u.fg,flex:"none",whiteSpace:"nowrap"},children:u.label}),i.jsx(aIe,{open:r})]}),r&&i.jsxs("div",{style:{borderTop:`1px solid ${y.hairline}`,padding:"2px 12px 12px"},children:[i.jsx(r2,{label:n.wbDecContext,text:e.context}),i.jsx(r2,{label:n.wbDecDecision,text:e.decision}),i.jsx(r2,{label:n.wbDecReasoning,text:e.reasoning}),e.actions.length>0&&i.jsxs("div",{style:{marginTop:14,border:`1px solid ${y.hairline}`,background:y.canvas,borderRadius:10,padding:"9px 12px"},children:[i.jsx("div",{style:{font:`600 10px ${H}`,letterSpacing:".05em",color:y.faint,paddingBottom:5},children:n.wbDecLog}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:e.actions.map((g,w)=>i.jsxs("div",{style:{display:"flex",gap:7,alignItems:"baseline",fontSize:12,lineHeight:1.5},children:[i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint,flex:"none"},children:o1(g.ts)??""}),i.jsx("span",{style:{fontWeight:600,color:g.action==="approve"?y.done:y.sub,flex:"none"},children:iIe(g.action,n)}),g.message&&i.jsx("span",{style:{color:y.muted,overflowWrap:"anywhere",minWidth:0},children:g.message})]},w))})]}),t&&i.jsxs("div",{style:{marginTop:13},children:[i.jsxs("div",{style:{display:"flex",gap:8},children:[d==="approved"?i.jsxs("span",{style:{flex:1,height:38,borderRadius:10,background:y.doneBg,color:y.done,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600},children:["✓ ",n.wbDecApproved]}):i.jsxs("span",{role:"button",onClick:v,style:{flex:1,height:38,borderRadius:10,background:p?y.faint:y.ink,color:y.inkSolidFg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600},children:["✓ ",n.wbDecApprove]}),b("explain",n.wbDecExplain),b("revise",n.wbDecRevise)]}),s!=="view"&&i.jsxs("div",{style:{display:"flex",gap:8,marginTop:9,alignItems:"flex-end"},children:[i.jsx("textarea",{autoFocus:!0,rows:2,value:l,onChange:g=>c(g.target.value),placeholder:s==="explain"?n.wbDecExplainPlaceholder:n.wbDecRevisePlaceholder,style:{flex:1,minWidth:0,resize:"none",border:`1px solid ${y.runBorder}`,borderRadius:10,padding:"8px 11px",fontSize:13,lineHeight:1.5,color:y.ink,background:"var(--proto-card)",outline:"none",fontFamily:"inherit",boxSizing:"border-box"}}),i.jsx("span",{role:"button",onClick:S,style:{height:38,borderRadius:10,padding:"0 16px",background:m?y.ink:y.faint,color:y.inkSolidFg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600,flex:"none"},children:n.wbDecSend})]})]})]})]})}function cIe({decisions:e,sessionId:t}){const n=VB(t??"");return i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,marginTop:8},children:e.map(r=>i.jsx(lIe,{d:r,actions:t?n:void 0},r.id))})}const dIe="repeating-linear-gradient(45deg,var(--proto-line) 0 6px,var(--proto-rail) 6px 12px)";function uIe({attachment:e}){const{openDoc:t}=Ac(),n={kind:"html",name:e.name,path:e.path,mimeType:e.mimeType};return i.jsxs("div",{style:{width:"100%",border:`1px solid ${y.hairline}`,background:"var(--proto-card)",borderRadius:12,overflow:"hidden",boxSizing:"border-box"},children:[i.jsxs("div",{role:"button",onClick:()=>t(n),style:{display:"flex",alignItems:"center",gap:7,padding:"7px 10px",borderBottom:`1px solid ${y.hairline}`,background:"var(--proto-rail)",cursor:"pointer"},children:[i.jsx("span",{style:{font:`700 7.5px ${H}`,letterSpacing:".06em",color:"var(--proto-accent)",background:"var(--proto-accent-bg)",border:"1px solid var(--proto-accent-border)",borderRadius:4,padding:"2px 5px",flex:"none"},children:"VIEW"}),i.jsx("span",{style:{font:`500 10.5px ${H}`,color:y.body,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.name}),i.jsx("span",{style:{font:`500 10.5px ${H}`,color:"var(--proto-accent)",flex:"none"},children:"↗"})]}),i.jsx(w1,{item:n,mode:"inline"})]})}function pIe({attachment:e,url:t,kind:n}){return i.jsxs(i.Fragment,{children:[t&&n==="image"&&i.jsx("img",{src:t,alt:e.name,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),t&&n==="video"&&i.jsx(gh,{src:t,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),n==="video"&&i.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:26,height:26,borderRadius:"50%",background:"var(--media-control-bg-dark)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:2,boxSizing:"border-box"},children:"▶"}),i.jsx("span",{style:{position:"absolute",left:7,bottom:6,maxWidth:(e.type==="video"?104:74)-14,font:`500 8px ${H}`,color:y.muted,background:"var(--media-label-bg)",padding:"1px 5px",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",boxSizing:"border-box"},children:e.name})]})}function fIe({attachment:e,kind:t}){const{openMedia:n}=mh(),r=bS(e.path,!0),o=e.type==="video"?104:74;return i.jsx("div",{role:"button",onClick:()=>n({kind:t,name:e.name,path:e.path}),style:{width:o,height:74,borderRadius:12,background:r?"var(--media-stage-bg)":dIe,position:"relative",overflow:"hidden",flex:"none",cursor:"pointer"},children:i.jsx(pIe,{attachment:e,url:r,kind:t})})}function hIe({attachment:e}){const{openDoc:t}=Ac(),n=yS(e),r=n?()=>t({kind:n,name:e.name,path:e.path,mimeType:e.mimeType}):()=>void O5(e.path,e.name);return i.jsxs("div",{role:"button",onClick:r,style:{display:"flex",alignItems:"center",gap:6,background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:9,padding:"6px 10px",flex:"none",cursor:"pointer"},children:[i.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:y.muted,strokeWidth:"1.5",children:[i.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),i.jsx("path",{d:"M8.5 1.5V4H11"})]}),i.jsx("span",{style:{font:`500 10.5px ${H}`,color:y.body},children:e.name})]})}function mIe({attachment:e}){const t=bc(e.type);return t?i.jsx(fIe,{attachment:e,kind:t}):i.jsx(hIe,{attachment:e})}function iR({attachments:e,side:t="right"}){const n=t==="left"?"flex-start":"flex-end",r=e.filter(s=>s.type==="view"),o=e.filter(s=>s.type!=="view");return i.jsxs("div",{style:{alignSelf:r.length>0?"stretch":n,display:"flex",flexDirection:"column",gap:6,alignItems:r.length>0?"stretch":n},children:[r.map((s,a)=>i.jsx(uIe,{attachment:s},`view-${a}`)),o.length>0&&i.jsx("div",{style:{alignSelf:n,display:"flex",gap:6,flexWrap:"wrap",justifyContent:n},children:o.map((s,a)=>i.jsx(mIe,{attachment:s},a))})]})}function gIe({attachment:e}){const{openMedia:t}=mh(),n=e.type?bc(e.type):null;return!e.previewUrl||!n?null:i.jsxs("span",{role:"button",onClick:()=>t({kind:n,name:e.name,url:e.previewUrl}),style:{position:"relative",width:26,height:26,borderRadius:6,overflow:"hidden",background:"var(--media-stage-bg)",flex:"none",cursor:"pointer"},children:[n==="image"?i.jsx("img",{src:e.previewUrl,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):i.jsx(gh,{src:e.previewUrl,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),n==="video"&&i.jsx("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ink-solid-fg)",fontSize:8,textShadow:"var(--media-glyph-shadow)"},children:"▶"})]})}function vIe({attachment:e,onRetry:t}){return e.status==="queued"?i.jsx("span",{style:{font:`500 9px ${H}`,color:y.muted},children:"queued"}):e.status==="uploading"?i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{width:34,height:4,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:i.jsx("div",{style:{width:`${e.progress}%`,height:"100%",background:y.run}})}),i.jsxs("span",{style:{font:`400 9px ${H}`,color:y.run},children:[e.progress,"%"]})]}):e.status==="done"?i.jsx("span",{style:{fontSize:10,color:y.done,fontWeight:700},children:"✓"}):e.status==="error"?i.jsx("span",{role:"button",onClick:t,style:{font:`600 9px ${H}`,color:y.fail,cursor:"pointer"},children:"retry"}):null}function xIe({attachment:e,onRetry:t,onRemove:n}){const r=e.status==="uploading";return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:r?7:6,background:"var(--proto-card)",border:`1px solid ${r?y.runBorder:y.hairline}`,borderRadius:9,padding:"5px 9px",flex:"none"},children:[i.jsx(gIe,{attachment:e}),i.jsx("span",{style:{font:`500 10px ${H}`,color:y.body},children:e.name}),i.jsx(vIe,{attachment:e,onRetry:t}),i.jsx("span",{onClick:n,style:{color:y.faint,fontSize:11,cursor:"pointer"},children:"✕"})]})}function yIe({attachments:e,onRetry:t,onRemove:n}){return e.length===0?null:i.jsx("div",{style:{display:"flex",gap:6,padding:"0 2px 7px",overflowX:"auto"},children:e.map(r=>i.jsx(xIe,{attachment:r,onRetry:()=>t(r.id),onRemove:()=>n(r.id)},r.id))})}function bIe(e,t,n={}){return i1(e,t,{streaming:n.streaming,running:n.running,streamingText:n.streamingText,pendingUser:n.pendingUser,stripScheduledPrefix:n.stripScheduledPrefix,formatDivider:QMe,...n.now?{now:n.now}:{}})}const sR="—";function wIe(e,t,n,r,o){const s=t==null?sR:`${t} ${o.turnsUnit}`,a=e.phase==="background"?o.background:e.phase==="foreground"?o.foreground:o.idle,l=e.showMetrics?[a,n,s,...e.showCost?[r==null?sR:yn(r)]:[]].join(" · "):a;return{running:e.active,tone:e.active?"running":"idle",text:l}}function SIe(e,t,n,r){const o=r==="zh";if(e==="plan-approval")return{running:!1,tone:"waiting",text:o?"计划待批 · Agent 已暂停":"plan pending · agent paused"};const s=n>1?` ${Math.min(t+1,n)}/${n}`:"";return{running:!1,tone:"waiting",text:o?`等待你的回答${s} · Agent 已暂停`:`awaiting your answer${s} · agent paused`}}function kIe(e,t,n){var r;return e??n??((r=t[0])==null?void 0:r.name)??"—"}function jIe(e){return[e.model,e.thinking,e.backend].filter(Boolean).join(" · ")}function CIe(e,t){return e.map(n=>({name:n.name,sub:jIe(n),current:n.name===t}))}const Of=12,rV=16;function TIe(e){const t=e.overlayHeight-rV-e.groupHeight;return e.anchorTop==null||t<=Of?Of:Math.max(Of,Math.min(e.anchorTop-e.overlayTop,t))}function PIe(e){let t=null;const n=o=>o.getBoundingClientRect().top,r=()=>{t&&clearTimeout(t)};return{onTouchStart:o=>{const s=o.currentTarget;t=setTimeout(()=>e(n(s)),450)},onTouchEnd:r,onTouchMove:r,onContextMenu:o=>{o.preventDefault(),e(n(o.currentTarget))}}}function EIe({text:e,label:t,copiedLabel:n}){const{copiedKey:r,copy:o}=G0(),s=r===!0,a=()=>{o(e,!0)};return i.jsx("button",{type:"button","data-assistant-turn-copy":"true","aria-label":s?n:t,title:s?n:t,onClick:a,style:{width:28,height:26,padding:0,border:0,background:"transparent",color:s?"var(--proto-success)":y.muted,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:s?"✓":i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[i.jsx("rect",{x:"4.5",y:"4.5",width:"8",height:"8",rx:"1.5"}),i.jsx("path",{d:"M2.5 9.5V3.5a1 1 0 0 1 1-1h6"})]})})}function Ap({text:e,label:t,copiedLabel:n}){return e?i.jsx("div",{style:{height:26,marginTop:4,display:"flex",alignItems:"center"},children:i.jsx(EIe,{text:e,label:t,copiedLabel:n})}):null}function RIe({kind:e}){return i.jsx("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:y.muted,strokeWidth:"1.4",style:{marginLeft:"auto"},children:e==="copy"?i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"4.5",y:"4.5",width:"8",height:"8",rx:"1.5"}),i.jsx("path",{d:"M2.5 9.5V3.5a1 1 0 0 1 1-1h6"})]}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M2.5 11.5l.6-2.6 6.4-6.4a1.3 1.3 0 0 1 1.8 0l.2.2a1.3 1.3 0 0 1 0 1.8L5.1 10.9z"}),i.jsx("path",{d:"M8.6 3.4l2 2"})]})})}function aR({label:e,icon:t,onTap:n,onClose:r,disabled:o,divided:s}){const a=o?void 0:()=>{n==null||n(),r()};return i.jsxs("div",{role:"button",onClick:a,style:{display:"flex",alignItems:"center",height:46,padding:"0 15px",fontSize:14.5,color:y.ink,opacity:o?.35:1,cursor:o?"default":"pointer",borderTop:s?`1px solid ${y.divider}`:void 0},children:[e,i.jsx(RIe,{kind:t})]})}function MIe({isUser:e,text:t}){const n={flex:"0 1 auto",minHeight:0,overflow:"hidden",padding:"9px 13px",fontSize:13.5,boxShadow:"var(--shadow-context-menu)",whiteSpace:"pre-wrap",overflowWrap:"break-word"};return e?i.jsx("div",{style:{...n,maxWidth:"82%",background:y.ink,color:"var(--ink-solid-fg)",borderRadius:"16px 16px 4px 16px",lineHeight:1.55},children:t}):i.jsx("div",{style:{...n,maxWidth:"88%",background:"var(--proto-card)",color:y.body,borderRadius:14,lineHeight:1.6},children:t})}function IIe(e){const t=f.useRef(null),n=f.useRef(null),[r,o]=f.useState(null);return f.useLayoutEffect(()=>{const s=t.current,a=n.current;if(!s||!a)return;const l=s.getBoundingClientRect();o(TIe({anchorTop:e??null,overlayTop:l.top,overlayHeight:l.height,groupHeight:a.getBoundingClientRect().height}))},[e]),{overlayRef:t,groupRef:n,top:r}}function AIe({menu:e,copy:t}){return i.jsxs("div",{onClick:n=>n.stopPropagation(),style:{flex:"none",width:196,background:y.card,border:`1px solid ${y.cardBorder}`,borderRadius:13,boxShadow:"var(--shadow-menu-floating)",overflow:"hidden"},children:[i.jsx(aR,{label:t.menuCopy,icon:"copy",onTap:e.onCopy,onClose:e.onClose}),e.onEdit&&i.jsx(aR,{label:t.menuEdit,icon:"edit",onTap:e.onEdit,onClose:e.onClose,disabled:e.editDisabled,divided:!0})]})}function DIe({row:e,menu:t,copy:n,groupRef:r,top:o}){const s=e.kind==="user",a=e.kind==="user"||e.kind==="assistant"?e.text:"",l=o1(e.kind==="user"?e.ts:void 0),c={position:"absolute",left:14,right:14,top:o??Of,maxHeight:`calc(100% - ${Of+rV}px)`,visibility:o==null?"hidden":"visible",display:"flex",flexDirection:"column",alignItems:s?"flex-end":"flex-start",gap:9,WebkitUserSelect:"none",userSelect:"none",WebkitTouchCallout:"none"};return i.jsxs("div",{ref:r,"data-msg-menu-group":"true",style:c,children:[i.jsx(MIe,{isUser:s,text:a}),l&&i.jsx("div",{style:{flex:"none",font:`500 10.5px ${H}`,color:"var(--media-overlay-fg)",background:"var(--media-timestamp-bg)",padding:"3px 8px",borderRadius:6,letterSpacing:".02em"},children:l}),i.jsx(AIe,{menu:t,copy:n})]})}function LIe({row:e,menu:t,copy:n}){const{overlayRef:r,groupRef:o,top:s}=IIe(t.anchorTop);return i.jsx("div",{ref:r,onClick:t.onClose,style:{position:"absolute",inset:0,zIndex:8,background:"var(--overlay-scrim-interaction)",backdropFilter:"blur(1.5px)",WebkitBackdropFilter:"blur(1.5px)",overflow:"hidden"},children:i.jsx(DIe,{row:e,menu:t,copy:n,groupRef:o,top:s})})}function OIe({title:e,onCancel:t}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-alt)",border:"1px solid var(--proto-accent-border)",borderRadius:11,padding:"8px 8px 8px 12px",marginBottom:7},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:y.run,flex:"none"}}),i.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-accent-strong)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e}),i.jsx("div",{role:"button","aria-label":"Cancel edit",onClick:t,style:{marginLeft:"auto",width:26,height:26,borderRadius:8,background:"var(--proto-card)",border:"1px solid var(--proto-accent-border)",display:"flex",alignItems:"center",justifyContent:"center",color:y.run,fontSize:12,flex:"none",cursor:"pointer"},children:"×"})]})}function NIe(){return i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:y.ink,strokeWidth:"1.5",children:[i.jsx("rect",{x:"1.5",y:"4",width:"13",height:"9.5",rx:"2"}),i.jsx("circle",{cx:"8",cy:"8.7",r:"2.6"}),i.jsx("path",{d:"M5.5 4l1-1.7h3l1 1.7"})]})}function FIe(){return i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:y.ink,strokeWidth:"1.5",children:[i.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2.5"}),i.jsx("circle",{cx:"6",cy:"6",r:"1.3"}),i.jsx("path",{d:"M2.5 11.5 6 8.5l2.5 2 3-3 2 2"})]})}function zIe(){return i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:y.ink,strokeWidth:"1.4",children:[i.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),i.jsx("path",{d:"M8.5 1.5V4H11"})]})}function BIe(){return i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:y.ink,strokeWidth:"1.5",children:[i.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),i.jsx("path",{d:"M1.5 8h13M8 1.5c-1.8 1.8-2.7 4-2.7 6.5S6.2 13.2 8 14.5c1.8-1.3 2.7-4 2.7-6.5S9.8 3.3 8 1.5z"})]})}function $Ie(){return i.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:y.ink,strokeWidth:"1.6",children:i.jsx("path",{d:"M10.5 2.5 5.5 13.5"})})}function Qc(e){const t=e.onTap?()=>{var r;(r=e.onTap)==null||r.call(e),e.onClose()}:void 0,n=e.itemKey==="browser"||e.itemKey==="commission";return i.jsxs("div",{"data-plus-item":e.itemKey,"data-editable":n?e.onTap?"true":"false":void 0,onClick:t,style:{display:"flex",alignItems:"center",gap:9,padding:"11px 14px",borderBottom:e.last?void 0:"1px solid var(--proto-line-2)",cursor:e.onTap?"pointer":"default",opacity:e.onTap?1:.6},children:[e.icon,i.jsx("span",{style:{fontSize:13,color:y.ink},children:e.label}),e.value!=null&&i.jsx("span",{style:{marginLeft:"auto",font:`500 10px ${H}`,color:y.run},children:e.value})]})}function _Ie({copy:e,onClose:t,onCamera:n,onLibrary:r,onFile:o,browser:s,commission:a,onCommands:l}){return i.jsxs(i.Fragment,{children:[i.jsx("div",{onClick:t,style:{position:"absolute",inset:0,zIndex:5}}),i.jsxs("div",{style:{position:"absolute",left:14,bottom:90,width:208,background:"var(--panel-translucent-bg)",border:"1px solid var(--panel-translucent-border)",borderRadius:13,boxShadow:"var(--shadow-menu-strong)",overflow:"hidden",zIndex:6},children:[i.jsx(Qc,{label:e.attachCamera,onTap:n,onClose:t,icon:i.jsx(NIe,{})}),i.jsx(Qc,{label:e.attachLibrary,onTap:r,onClose:t,icon:i.jsx(FIe,{})}),i.jsx(Qc,{label:e.attachFile,onTap:o,onClose:t,icon:i.jsx(zIe,{})}),s&&i.jsx(Qc,{label:e.attachBrowser,onTap:s.onOpen,onClose:t,icon:i.jsx(BIe,{}),itemKey:"browser",value:s.device??void 0}),a&&i.jsx(Qc,{label:e.attachCommission,onTap:a.onOpen,onClose:t,icon:i.jsx(VIe,{}),itemKey:"commission",value:a.label??void 0}),i.jsx(Qc,{label:e.attachCommands,onTap:l,onClose:t,icon:i.jsx($Ie,{}),itemKey:"commands",last:!0})]})]})}function WIe({props:e}){return e.rejectBar?i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:y.amberCard,border:`1px solid ${y.amberBorder}`,borderRadius:11,padding:"8px 8px 8px 12px",marginBottom:7},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:y.amber,flex:"none"}}),i.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-amber-fg)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.rejectBar.title}),i.jsx("div",{role:"button","aria-label":"Cancel reject",onClick:e.rejectBar.onCancel,style:{marginLeft:"auto",width:26,height:26,borderRadius:8,background:"var(--proto-card)",border:`1px solid ${y.amberBorder}`,display:"flex",alignItems:"center",justifyContent:"center",color:y.amberText,fontSize:11,flex:"none",cursor:"pointer"},children:"✕"})]}),i.jsx("div",{style:{display:"flex",gap:6,padding:"0 2px 8px",overflowX:"auto"},children:e.rejectBar.chips.map(t=>i.jsx("span",{role:"button",onClick:()=>e.rejectBar.onChipTap(t),style:{flex:"none",fontSize:11,fontWeight:600,color:y.sub,border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:999,padding:"5px 11px",cursor:"pointer"},children:t},t))})]}):null}function HIe({props:e}){let t=i.jsx(yIe,{attachments:e.attachments,onRetry:e.onRetryAttachment,onRemove:e.onRemoveAttachment});return e.editing&&e.editCopy?t=i.jsx(OIe,{title:e.editCopy.editBarTitle,onCancel:e.editing.onCancel}):e.rejectBar&&(t=i.jsx(WIe,{props:e})),i.jsxs(i.Fragment,{children:[e.sessionId&&e.todos?i.jsx(oU,{sessionId:e.sessionId,todos:e.todos,lang:e.todoLang??"en"}):null,t]})}function UIe({label:e,onClick:t}){return i.jsxs("button",{type:"button",onClick:t,style:{display:"flex",alignItems:"center",gap:6,border:`1.5px solid ${y.runBorder}`,background:y.card,borderRadius:999,height:34,padding:"0 13px",boxSizing:"border-box",flex:"0 1 auto",minWidth:0,overflow:"hidden",cursor:"pointer"},children:[i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:y.run,flex:"none"}}),i.jsx("span",{style:{minWidth:0,font:`600 11.5px ${H}`,color:y.run,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e})]})}function VIe(){return i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:y.muted,strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",style:{flex:"none"},children:[i.jsx("path",{d:"M4.2 2.2v11.6"}),i.jsx("path",{d:"M4.2 3.1h7.8L10.4 5.7l1.6 2.6H4.2z"})]})}function qIe({value:e,text:t,label:n,onClick:r}){return i.jsxs("button",{type:"button","data-chip":"commission","data-commission-value":e,"data-editable":r?"true":"false","aria-label":`${n} · ${t}`,onClick:r,style:{display:"flex",alignItems:"center",gap:5,flex:"0 1 auto",minWidth:0,maxWidth:150,height:34,padding:"0 11px",boxSizing:"border-box",borderRadius:999,border:`1.5px solid ${y.runBorder}`,background:y.runBg,color:y.run,font:`500 11px ${H}`,overflow:"hidden",cursor:r?"pointer":"default"},children:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round",strokeLinecap:"round",style:{flex:"none"},children:[i.jsx("path",{d:"M4.2 2.2v11.6"}),i.jsx("path",{d:"M4.2 3.1h7.8L10.4 5.7l1.6 2.6H4.2z"})]}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]})}function KIe({device:e,label:t,onClick:n}){return i.jsxs("button",{type:"button","data-chip":"browser","data-browser-device":e,"data-editable":n?"true":"false","aria-label":`${t} · ${e}`,onClick:n,style:{display:"flex",alignItems:"center",gap:5,flex:"0 1 auto",minWidth:0,maxWidth:132,height:34,padding:"0 11px",boxSizing:"border-box",borderRadius:999,border:`1.5px solid ${y.runBorder}`,background:y.runBg,color:y.run,font:`500 11px ${H}`,overflow:"hidden",cursor:n?"pointer":"default"},children:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{flex:"none"},children:[i.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),i.jsx("path",{d:"M1.5 8h13M8 1.5c-1.8 1.8-2.7 4-2.7 6.5S6.2 13.2 8 14.5c1.8-1.3 2.7-4 2.7-6.5S9.8 3.3 8 1.5z"})]}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]})}function GIe({onClick:e}){return i.jsx("button",{type:"button","aria-label":"Attach",onClick:e,style:{flex:"none",width:34,height:34,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",background:y.card,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",color:y.sub,lineHeight:0,cursor:"pointer",padding:0},children:i.jsx(gc,{size:15})})}function YIe({props:e}){return e.editing||e.rejectBar?null:i.jsxs(i.Fragment,{children:[i.jsx(UIe,{label:e.profileChipLabel,onClick:e.onOpenProfile}),e.contextUsageSupported||e.contextUsage!=null?i.jsx("span",{"data-context-usage-position":"composer-toolbar",style:{display:"inline-flex",flex:"none"},children:i.jsx(wU,{usage:e.contextUsage??null,variant:"mobile",lang:e.contextUsageLang??"en",onClick:e.onContextUsageOpen,"data-context-compact-enabled":e.contextCompactAction?"true":void 0})}):null]})}function QIe({suggestions:e,onPick:t}){return i.jsx("div",{"data-mobile-slash-menu":!0,style:{margin:"0 0 7px",border:`1px solid ${y.hairline}`,borderRadius:12,background:y.card,overflow:"hidden",boxShadow:"var(--shadow-menu-soft)"},children:e.map(n=>i.jsxs("div",{"data-mobile-slash-command":n.command,onClick:()=>{n.disabled||t(n)},style:{display:"flex",alignItems:"center",gap:10,minHeight:38,padding:"0 12px",borderBottom:`1px solid ${y.divider}`,opacity:n.disabled?.45:1,cursor:n.disabled?"default":"pointer"},children:[i.jsx("span",{style:{font:`600 11.5px ${H}`,color:y.run},children:n.command}),i.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:10.5,color:y.muted},children:n.description})]},n.command))})}function XIe({copy:e,onClose:t,onSessionId:n}){const r=[{label:e.menuSessionId,onTap:n}];return i.jsxs(i.Fragment,{children:[i.jsx("div",{onClick:t,style:{position:"absolute",inset:0,zIndex:5}}),i.jsx("div",{style:{position:"absolute",top:"calc(52px + env(safe-area-inset-top))",right:14,width:148,background:"var(--panel-translucent-bg)",border:"1px solid var(--panel-translucent-border)",borderRadius:13,boxShadow:"var(--shadow-menu-strong)",overflow:"hidden",zIndex:6},children:r.map((o,s)=>i.jsx("div",{onClick:o.onTap,style:{padding:"11px 14px",fontSize:13,color:y.ink,borderBottom:s<r.length-1?"1px solid var(--proto-line-2)":void 0,cursor:"pointer"},children:o.label},o.label))})]})}function ZIe({row:e,copy:t,copied:n,onCopy:r}){return i.jsxs("div",{children:[i.jsx("div",{style:{font:`600 9.5px ${H}`,letterSpacing:".05em",color:y.muted,padding:"0 2px 5px"},children:e.label}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:11,padding:"10px 12px"},children:[i.jsx("span",{style:{flex:1,font:`500 12px ${H}`,color:y.ink,wordBreak:"break-all",userSelect:"all"},children:e.value}),i.jsx("span",{role:"button",onClick:r,style:{flex:"none",font:`600 9.5px ${H}`,color:n?y.run:y.muted,border:`1px solid ${n?y.runBorder:"var(--proto-line-3)"}`,borderRadius:7,padding:"4px 9px",cursor:e.value==="—"?"default":"pointer",opacity:e.value==="—"?.4:1},children:n?t.copied:t.copy})]})]})}function JIe({copy:e,cortexId:t,backendUuid:n,onClose:r}){const o=zH({cortexId:t,backendUuid:n,cortexIdLabel:e.cortexIdLabel,backendUuidLabel:e.backendUuidLabel}),{copiedKey:s,copy:a}=G0(),l=(c,d)=>{d!=="—"&&a(d,c)};return i.jsxs(li,{onClose:r,children:[i.jsx("div",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em",padding:"0 2px 12px"},children:e.sessionIdTitle}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:11},children:o.map(c=>i.jsx(ZIe,{row:c,copy:e,copied:s===c.key,onCopy:()=>l(c.key,c.value)},c.key))})]})}function eAe({usage:e,lang:t,compactAction:n,onClose:r}){return i.jsx(li,{onClose:r,children:i.jsxs("div",{"data-mobile-context-usage-sheet":"true",children:[i.jsx("div",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em",padding:"0 2px 10px"},children:bU(t)}),i.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:13,padding:"12px 13px"},children:i.jsx(kU,{usage:e,lang:t})}),n?i.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 2px 0"},children:i.jsx(SU,{action:n,lang:t})}):null]})})}function tAe({item:e,last:t,copy:n,onPick:r}){return i.jsxs("div",{onClick:()=>r(e.name),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:t?void 0:"1px solid var(--proto-line-soft)",cursor:"pointer"},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[i.jsx("span",{style:{font:`600 13px ${H}`,color:y.ink},children:e.name}),e.current&&i.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:y.runBg,color:y.run},children:n.profileCurrent})]}),i.jsx("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:3},children:e.sub})]}),e.current&&i.jsx("span",{style:{fontSize:15,fontWeight:700,color:y.run,flex:"none"},children:"✓"})]})}function nAe({items:e,copy:t,onClose:n,onPick:r}){return i.jsxs(li,{onClose:n,children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 10px"},children:[i.jsx("span",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em"},children:t.profileTitle}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint},children:t.profileSubtitle})]}),i.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:13,overflow:"hidden"},children:e.map((o,s)=>i.jsx(tAe,{item:o,last:s===e.length-1,copy:t,onPick:r},o.name))}),i.jsx("div",{style:{font:`400 9.5px ${H}`,color:y.faint,padding:"9px 4px 0"},children:t.profileFooter})]})}function rAe({item:e,attr:t,last:n,current:r,onPick:o}){return i.jsxs("div",{[t]:e.value??"__off__",onClick:()=>o(e.value),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:n?void 0:"1px solid var(--proto-line-soft)",cursor:"pointer"},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("span",{style:{font:`600 13px ${H}`,color:y.ink},children:e.label}),e.sub&&i.jsx("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:3},children:e.sub})]}),e.value===r&&i.jsx("span",{style:{fontSize:15,fontWeight:700,color:y.run,flex:"none"},children:"✓"})]})}function oV({items:e,attr:t,title:n,current:r,onClose:o,onPick:s}){return i.jsxs(li,{onClose:o,children:[i.jsx("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 10px"},children:i.jsx("span",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em"},children:n})}),i.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:13,overflow:"hidden"},children:e.map((a,l)=>i.jsx(rAe,{item:a,attr:t,last:l===e.length-1,current:r,onPick:s},a.value??"__off__"))})]})}function oAe({items:e,title:t,current:n,onClose:r,onPick:o}){return i.jsx(oV,{items:e.map(s=>({value:s.device,label:s.label,sub:s.sub})),attr:"data-device",title:t,current:n,onClose:r,onPick:o})}function iAe({items:e,title:t,current:n,onClose:r,onPick:o}){return i.jsx(oV,{items:e,attr:"data-commission-option",title:t,current:n,onClose:r,onPick:o})}function sAe(e){return i.jsx(cr,{onBack:e.onBack,trailing:i.jsx(qO,{onClick:e.onMore}),children:i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:15,fontWeight:650,color:y.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),i.jsx(aAe,{...e})]})})}function aAe({status:e}){return i.jsx("div",{"data-chat-status-line":"true",style:{display:"flex",alignItems:"center",gap:8,font:`400 10px ${H}`,color:e.tone==="waiting"?y.amberText:y.muted,marginTop:1},children:i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,minWidth:0},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:e.tone==="waiting"?y.amber:e.running?y.run:"var(--proto-line-3)",animation:e.running?"cxpulse 1.6s ease-in-out infinite":void 0,flex:"none"}}),i.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text})]})})}const Iw=6,lAe={font:`400 10px ${H}`,background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",padding:"1px 6px",borderRadius:4,flex:"none"},iV={display:"flex",alignItems:"center",gap:Iw,flex:1,minWidth:0,overflow:"hidden",position:"relative"},cAe={...iV,position:"absolute",visibility:"hidden",pointerEvents:"none",width:"max-content",overflow:"visible"};function lR({name:e}){return i.jsx("span",{style:lAe,children:e})}function dAe({count:e,calls:t,unit:n,onExpand:r}){const o=t.map(d=>d.kind),{containerRef:s,measureRef:a,layout:l}=ez(o,Iw),c=eIe(t,l);return i.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:Iw,fontSize:11,color:"var(--proto-muted-3)",flexWrap:"nowrap",whiteSpace:"nowrap",overflow:"hidden",cursor:"pointer"},children:[i.jsx("span",{style:{fontSize:8.5,flex:"none"},children:"▸"}),i.jsxs("span",{style:{flex:"none"},children:[e," ",n]}),i.jsxs("span",{ref:s,style:iV,children:[c.names.map((d,u)=>i.jsx(lR,{name:d},u)),c.overflow>0?i.jsxs("span",{style:{flex:"none"},children:["+",c.overflow]}):null,i.jsxs("span",{ref:a,"aria-hidden":"true",style:cAe,children:[o.map((d,u)=>i.jsx(lR,{name:d},u)),i.jsxs("span",{style:{flex:"none"},children:["+",t.length]})]})]})]})}function uAe({count:e,calls:t,unit:n,onCollapse:r}){return i.jsxs("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,overflow:"hidden"},children:[i.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--proto-muted-3)",padding:"6px 11px",cursor:"pointer"},children:[i.jsx("span",{style:{fontSize:8.5},children:"▾"}),i.jsxs("span",{children:[e," ",n]})]}),t.map((o,s)=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5.5px 11px",borderTop:"1px solid var(--proto-line-soft)"},children:[i.jsx("span",{style:{font:`600 9px ${H}`,color:"var(--proto-muted)",background:"var(--proto-gray)",padding:"1.5px 7px",borderRadius:5,flex:"none"},children:o.kind}),i.jsx("span",{style:{font:`400 10.5px ${H}`,color:y.body,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:o.input})]},s))]})}function cR({rows:e,unit:t}){const n=e.flatMap(o=>o.kind==="tools"?o.calls:[]),r=e.flatMap(o=>o.kind==="assistant"&&o.text?[o.text]:[]);return i.jsxs(i.Fragment,{children:[n.length>0&&i.jsx(sV,{count:n.length,calls:n,unit:t}),r.map((o,s)=>i.jsx("div",{style:{fontSize:12.5,lineHeight:1.6,color:y.body,overflowWrap:"break-word",wordBreak:"break-word"},children:i.jsx(ci,{text:o})},s))]})}function pAe({row:e,unit:t,sessionId:n}){return e.detailMode!=="lazy"||!e.hasDetails||!n?i.jsx(cR,{rows:e.children,unit:t}):i.jsx(uz,{sessionId:n,subagentId:e.id,fallbackRows:e.children,render:r=>i.jsx(cR,{rows:r,unit:t})})}function fAe({row:e,unit:t,sessionId:n}){const r=O(),[o,s]=f.useState(!1),a=e.description||e.agentType||r.subagentFallbackLabel;return i.jsxs("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8},children:[i.jsxs("div",{onClick:()=>s(!o),role:"button","aria-expanded":o,style:{position:"sticky",top:0,zIndex:1,display:"flex",alignItems:"center",gap:7,padding:"6px 11px",fontSize:11.5,color:y.faint,background:"var(--proto-rail)",minWidth:0},children:[i.jsx(Mi,{color:e.status==="running"?"var(--proto-accent)":"var(--proto-success)",pulse:e.status==="running"}),i.jsx("span",{style:{font:`600 9px ${H}`,color:"var(--proto-muted)",background:"var(--proto-gray)",padding:"1.5px 7px",borderRadius:5,flex:"none"},children:e.agentType||r.subagentFallbackLabel}),e.model?i.jsx("span",{style:{font:`600 9px ${H}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line-2)",padding:"1.5px 7px",borderRadius:5,flex:"none"},children:rz(e.model)}):null,i.jsx("span",{style:{font:`400 11px ${H}`,color:y.body,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:a}),i.jsx("span",{style:{font:`400 10px ${H}`,flex:"none",marginLeft:"auto"},children:`${e.toolCount} ${t}`})]}),o&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"8px 11px 10px",borderTop:"1px solid var(--proto-line-soft)"},children:[e.prompt?i.jsxs("div",{children:[i.jsx("div",{style:{font:`600 9px ${H}`,color:y.faint,marginBottom:5,textTransform:"uppercase",letterSpacing:".05em"},children:r.subagentPromptLabel}),i.jsx("pre",{style:{margin:0,font:`400 10.5px/1.55 ${H}`,color:y.body,whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},children:e.prompt})]}):null,i.jsx(pAe,{row:e,unit:t,sessionId:n})]})]})}function sV({count:e,calls:t,unit:n}){const[r,o]=f.useState(!1);return r?i.jsx(uAe,{count:e,calls:t,unit:n,onCollapse:()=>o(!1)}):i.jsx(dAe,{count:e,calls:t,unit:n,onExpand:()=>o(!0)})}const o2=()=>{};function hAe({text:e,preview:t,streamKey:n}){const r=ZB(e,!!t,n);return r.trim()?i.jsx(ci,{text:r,dropTrailingHr:!0,renderMath:!0}):null}function mAe({row:e,interactions:t}){const n=BB(e),r=(t==null?void 0:t.copy)??nV.zh;if(n.kind==="ask"){const a=n.model;return i.jsx(nIe,{model:a,state:(t==null?void 0:t.askState(a.requestId))??FB,copy:r,onPick:l=>t==null?void 0:t.onAskPick(a,l),onToggle:l=>t==null?void 0:t.onAskToggle(a,l),onConfirmMulti:()=>t==null?void 0:t.onAskConfirmMulti(a),onCustom:()=>t==null?void 0:t.onAskCustom(a)})}if(n.kind==="plan"){const a=n.model;return i.jsx(rIe,{model:a,copy:r,dimmed:(t==null?void 0:t.rejectingId)===a.requestId,onApprove:t?()=>t.onApprove(a):o2,onRejectStart:t?()=>t.onRejectStart(a):o2,onOpenRead:t?()=>t.onOpenRead(a):o2})}const o=n.tone==="rejected"?"var(--proto-danger)":n.tone==="inactive"?"var(--proto-muted-3)":y.done,s=n.tone==="rejected"?"✗":n.tone==="inactive"?"◌":"✓";return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 11px",background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",borderRadius:10,opacity:n.tone==="inactive"?.6:.75},children:[i.jsxs("span",{style:{fontSize:10,fontWeight:700,color:o,flexShrink:0},children:[s," ",n.label]}),i.jsx("span",{style:{fontSize:11.5,color:y.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.text})]})}function gAe({rows:e,toolCallsUnit:t,copyLabel:n,copiedLabel:r,interactions:o,editCopy:s,editing:a,onLongPress:l,onShowOriginal:c,streamKey:d}){const u=s?lz(e):null,p=cz(e),h=(a==null?void 0:a.rowIndex)??null;return i.jsx(i.Fragment,{children:e.map((m,x)=>{const v=h!=null&&x>h,S=h===x,b=!!s&&!!l&&h==null&&m.kind==="user",g=b?PIe(w=>l(x,w)):null;return i.jsxs(f.Fragment,{children:[m.kind==="divider"&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,...v?{opacity:.35}:{}},children:[i.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}}),i.jsx("div",{style:{fontSize:9.5,fontWeight:600,letterSpacing:".06em",color:y.faint},children:m.text}),i.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]}),m.kind==="user"&&i.jsxs(i.Fragment,{children:[m.attachments&&m.attachments.length>0&&i.jsx(iR,{attachments:m.attachments}),i.jsxs("div",{style:{alignSelf:"flex-end",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:5,maxWidth:"82%",...v?{opacity:.35,pointerEvents:"none"}:{}},children:[S&&s&&i.jsx("span",{style:{font:`600 9.5px ${H}`,color:y.run,background:"var(--proto-accent-bg)",padding:"2px 7px",borderRadius:4},children:s.editingBadge}),i.jsx("div",{...g??{},"data-msg-bubble":b?x:void 0,style:{background:y.ink,color:m.pending?y.inkSolidFgDim:y.inkSolidFg,borderRadius:"16px 16px 4px 16px",padding:"9px 13px",fontSize:13.5,lineHeight:1.55,whiteSpace:"pre-wrap",overflowWrap:"break-word",wordBreak:"break-word",WebkitUserSelect:b?"none":void 0,userSelect:b?"none":void 0,WebkitTouchCallout:b?"none":void 0,...S?{boxShadow:`0 0 0 2px ${y.canvas}, 0 0 0 3.5px ${y.run}`}:{}},children:m.text}),s&&m.edited&&!S&&i.jsx("span",{role:"button",onClick:c?()=>c(m.edited):void 0,style:{font:`400 9.5px ${H}`,color:y.faint,cursor:"pointer"},children:i.jsx("span",{style:{borderBottom:`1px dotted ${y.faint}`},children:s.edited})})]}),S&&s&&a&&i.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:i.jsx("span",{style:{font:`600 9px ${H}`,color:"var(--m-amber-ink)",background:y.amberBg,padding:"2px 7px",borderRadius:4},children:s.willRewind(a.replies,a.toolCalls)})})]}),m.kind==="subagent"&&i.jsxs("div",{style:v?{opacity:.35,pointerEvents:"none"}:void 0,children:[i.jsx(fAe,{row:m,unit:t,sessionId:d}),i.jsx(Ap,{text:p.get(x),label:n,copiedLabel:r})]}),m.kind==="tools"&&i.jsxs("div",{style:v?{opacity:.35,pointerEvents:"none"}:void 0,children:[i.jsx(sV,{count:m.count,calls:m.calls,unit:t}),i.jsx(Ap,{text:p.get(x),label:n,copiedLabel:r})]}),m.kind==="notice"&&i.jsxs("div",{style:v?{opacity:.35,pointerEvents:"none"}:void 0,children:[i.jsx(WB,{level:m.level,text:m.text,authAction:m.authAction,noticeAction:m.noticeAction,onNoticeAction:o==null?void 0:o.onCancelResume,noticeActionDone:o==null?void 0:o.resumeCancelled}),i.jsx(Ap,{text:p.get(x),label:n,copiedLabel:r})]}),m.kind==="assistant"&&i.jsxs("div",{...g??{},style:{fontSize:13.5,lineHeight:1.65,color:y.body,minWidth:0,overflowWrap:"break-word",wordBreak:"break-word",...v?{opacity:.35,pointerEvents:"none"}:{},WebkitUserSelect:b?"none":void 0,userSelect:b?"none":void 0,WebkitTouchCallout:b?"none":void 0},children:[s&&(u==null?void 0:u.has(x))&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,font:`400 9.5px ${H}`,color:y.faint,marginBottom:4},children:[i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--proto-line-3)",flex:"none"}}),s.regenNote]}),i.jsx(hAe,{text:m.text,preview:m.preview,streamKey:d}),m.attachments&&m.attachments.length>0&&i.jsx("div",{style:{marginTop:8},children:i.jsx(iR,{attachments:m.attachments,side:"left"})}),m.decisions&&m.decisions.length>0&&i.jsx(cIe,{decisions:m.decisions,sessionId:d}),i.jsx(Ap,{text:p.get(x),label:n,copiedLabel:r})]}),m.kind==="interaction"&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",...v?{opacity:.35,pointerEvents:"none"}:{}},children:[i.jsx(mAe,{row:m,interactions:o}),i.jsx(Ap,{text:p.get(x),label:n,copiedLabel:r})]})]},m.kind==="interaction"&&m.detail?`int-${m.detail.id}`:x)})})}function vAe({text:e}){return i.jsxs("div",{style:{alignSelf:"center",display:"flex",alignItems:"center",gap:6,font:`400 9.5px ${H}`,color:y.faint,background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",padding:"3px 10px",borderRadius:999},children:[i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:y.run}}),e]})}function xAe(e){var d,u;const{copy:t}=e,n=f.useRef(null),r=f.useRef(null),o=f.useRef(!0),s=f.useRef(0),a=()=>{const p=n.current;p&&(o.current=p.scrollHeight-p.scrollTop-p.clientHeight<40)},l=()=>{s.current=Date.now()+800};f.useEffect(()=>{const p=n.current;p&&o.current&&Date.now()>=s.current&&(p.scrollTop=p.scrollHeight)},[e.rows,e.systemLines]),f.useEffect(()=>{const p=n.current,h=r.current;if(!p||!h||typeof ResizeObserver>"u")return;const m=new ResizeObserver(()=>{o.current&&Date.now()>=s.current&&(p.scrollTop=p.scrollHeight)});return m.observe(h),()=>m.disconnect()},[]);const c=!e.editing&&!e.rejectBar&&((d=e.slashSuggestions)!=null&&d.length)&&e.onSlashPick?i.jsx(QIe,{suggestions:e.slashSuggestions,onPick:e.onSlashPick}):void 0;return i.jsxs("div",{"data-screen-label":"1b 会话详情",style:{height:"100%",position:"relative",display:"flex",flexDirection:"column",boxSizing:"border-box",background:y.canvas},children:[i.jsx(sAe,{title:e.title,status:e.status,onBack:e.onBack,onMore:e.onMoreToggle}),i.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[i.jsx("div",{ref:n,onScroll:a,onClick:l,style:{flex:1,minHeight:0,overflow:"auto",isolation:"isolate",background:y.canvas},children:i.jsxs("div",{ref:r,style:{padding:"14px 14px 0",display:"flex",flexDirection:"column",gap:12},children:[i.jsx(gAe,{rows:e.rows,toolCallsUnit:t.toolCallsUnit,copyLabel:t.copy,copiedLabel:t.copied,interactions:e.interactions,editCopy:e.editCopy,editing:e.editing,onLongPress:e.onLongPress,onShowOriginal:e.onShowOriginal,streamKey:e.streamKey}),e.inlineThreadCard,(u=e.systemLines)==null?void 0:u.map((p,h)=>i.jsx(vAe,{text:p},h)),i.jsx("div",{style:{height:"calc(8px + env(safe-area-inset-bottom))",flex:"none"}})]})}),i.jsx(moe,{placeholder:e.composerPlaceholder??(e.attachments.length>0?t.attachPlaceholder:t.composerPh),value:e.composerValue,onChange:e.onComposerChange,onSend:e.onSend,sendEnabled:e.sendEnabled,running:e.status.running,onStop:e.onStop,stopEnabled:e.stopEnabled,leading:e.editing||e.rejectBar?void 0:i.jsxs(i.Fragment,{children:[i.jsx(GIe,{onClick:e.onPlus}),e.browserDevice&&i.jsx(KIe,{device:e.browserDevice,label:t.attachBrowser,onClick:e.onOpenBrowser}),e.commissionValue&&i.jsx(qIe,{value:e.commissionValue,text:e.commissionLabel||t.attachCommission,label:t.attachCommission,onClick:e.onOpenCommission})]}),tools:i.jsx(YIe,{props:e}),above:i.jsx(HIe,{props:e}),commandMenu:c,onPlus:e.onPlus,lineUnit:t.lineUnit,charUnit:t.charUnit,tone:e.editing?"accent":e.rejectBar?"amber":"default"}),e.msgMenu&&e.editCopy&&e.rows[e.msgMenu.rowIndex]&&i.jsx(LIe,{row:e.rows[e.msgMenu.rowIndex],menu:e.msgMenu,copy:e.editCopy})]}),e.moreOpen&&i.jsx(XIe,{copy:t,onClose:e.onMoreClose,onSessionId:()=>{e.onMoreClose(),e.onSessionIdOpen()}}),e.sessionIdOpen&&i.jsx(JIe,{copy:t,cortexId:e.cortexId,backendUuid:e.backendUuid,onClose:e.onSessionIdClose}),e.originalSheet&&e.editCopy&&i.jsxs(li,{onClose:e.originalSheet.onClose,children:[i.jsx("div",{style:{font:`600 10px ${H}`,color:y.muted,letterSpacing:".05em",padding:"0 2px 8px"},children:e.editCopy.original}),i.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:13,padding:"11px 13px",fontSize:13,lineHeight:1.6,color:y.body,whiteSpace:"pre-wrap",overflowWrap:"break-word",maxHeight:"50vh",overflow:"auto"},children:e.originalSheet.text})]}),e.attachMenuOpen&&i.jsx(_Ie,{copy:t,onClose:e.onAttachClose,onCamera:e.onCamera,onLibrary:e.onLibrary,onFile:e.onFile,browser:e.onOpenBrowser||e.browserDevice?{device:e.browserDevice??null,onOpen:e.onOpenBrowser}:void 0,commission:e.onOpenCommission||e.commissionValue?{label:e.commissionLabel??e.commissionValue??null,onOpen:e.onOpenCommission}:void 0,onCommands:()=>e.onComposerChange("/")}),e.browserSheet&&i.jsx(oAe,{items:e.browserSheet.items,title:e.browserSheet.title,current:e.browserDevice??null,onClose:e.browserSheet.onClose,onPick:e.browserSheet.onPick}),e.commissionSheet&&i.jsx(iAe,{items:e.commissionSheet.items,title:e.commissionSheet.title,current:e.commissionValue??null,onClose:e.commissionSheet.onClose,onPick:e.commissionSheet.onPick}),e.profileSheet&&i.jsx(nAe,{items:e.profileSheet.items,copy:t,onClose:e.profileSheet.onClose,onPick:e.profileSheet.onPick}),e.contextUsageOpen&&(e.contextUsageSupported||e.contextUsage!=null)?i.jsx(eAe,{usage:e.contextUsage??null,lang:e.contextUsageLang??"en",compactAction:e.contextCompactAction,onClose:e.onContextUsageClose}):null]})}const dR="'IBM Plex Mono',monospace";function yAe({state:e}){return e==="done"?i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700},children:"✓"}):e==="running"?i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-accent)",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite"}}):i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box"}})}function bAe(e){return e==="running"?"var(--proto-ink)":e==="done"?"var(--proto-muted)":"var(--proto-faint)"}function wAe({card:e,pill:t,subthreadsLabel:n,openLabel:r,onOpen:o}){return i.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:12,overflow:"hidden",background:"var(--proto-card)"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 12px",borderBottom:"1px solid var(--proto-line-2)"},children:[i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.6",children:[i.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),i.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),i.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),i.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]}),i.jsx("span",{style:{font:`600 12px ${dR}`,color:"var(--proto-ink)"},children:e.name}),i.jsx("span",{style:{marginLeft:"auto",fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:999,background:t.bg,color:t.color},children:e.pillText})]}),i.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px"},children:e.nodes.map((s,a)=>i.jsxs(f.Fragment,{children:[a>0&&i.jsx("div",{style:{flex:1,height:1.5,background:s.lineDone?"var(--proto-success-bg)":"var(--proto-line)",margin:"0 6px"}}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[i.jsx(yAe,{state:s.state}),i.jsx("span",{style:{fontSize:10.5,color:bAe(s.state),fontWeight:s.state==="running"?600:void 0},children:s.label})]})]},a))}),i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",borderTop:"1px solid var(--proto-line-2)"},children:[i.jsxs("span",{style:{font:`400 10px ${dR}`,color:"var(--proto-muted-3)"},children:[e.footer.elapsed," · ",e.footer.cost," · ",e.footer.subCount," ",n]}),i.jsxs("span",{onClick:o,style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:[r," →"]})]})]})}function SAe({sessionId:e,subthreadsLabel:t,openLabel:n}){const r=Xe(),o=he(),a=ae({...o.threads.list.queryOptions({status:["running","waiting"],sessionId:e}),enabled:!!e}).data??[],l=a.find(u=>u.status==="running")??a[0]??null,c=(l==null?void 0:l.id)??"";vh(c);const d=ae({...o.threads.get.queryOptions({threadId:c}),enabled:!!c});return!c||d.isPending||d.isError||!d.data?null:i.jsx(wAe,{card:JMe(d.data),pill:Ek(d.data.status),subthreadsLabel:t,openLabel:n,onOpen:()=>r(`/m/thread/${c}`)})}function kAe(e){if(e.draftKeyRef.current===e.draftKey)return!1;if(e.draftKeyRef.current=e.draftKey,!e.draftKey)return!0;const t=ic(e.draftKey);return e.isDraft&&(t!=null&&t.draftUploadId)&&(e.draftUploadId.current=t.draftUploadId),e.setText((t==null?void 0:t.text)??""),e.replaceRestored((t==null?void 0:t.attachments)??[]),!0}function jAe(e){ws(e.draftKey,{text:e.text,attachments:Rk(e.uploads),...e.isDraft&&e.draftUploadId.current?{draftUploadId:e.draftUploadId.current}:{}})}function CAe(e){f.useEffect(()=>{kAe(e)||jAe(e)},[e.draftKey,e.text,e.uploads,e.isDraft])}const TAe={sessionId:"",turns:[]},PAe={zh:{composerPh:"输入消息,/ 调用命令",toolCallsUnit:"次工具调用",menuSessionId:"会话 ID",sessionIdTitle:"会话 ID",cortexIdLabel:"Cortex ID",backendUuidLabel:"后端 UUID",copy:"复制",copied:"已复制",attachCamera:"拍照",attachLibrary:"照片图库",attachFile:"选择文件",attachBrowser:"浏览器",attachCommission:"委托",attachCommands:"命令",attachPlaceholder:"补充说明…",profileTitle:"Profile",profileSubtitle:"仅本会话 · 热更新",profileCurrent:"当前",profileFooter:"切换仅影响本会话后续 turn · 运行中线程不受影响 · 全局默认在设置",lineUnit:"行",charUnit:"字"},en:{composerPh:"Message, / for commands",toolCallsUnit:"tool calls",menuSessionId:"Session ID",sessionIdTitle:"Session ID",cortexIdLabel:"Cortex ID",backendUuidLabel:"Backend UUID",copy:"Copy",copied:"Copied",attachCamera:"Take photo",attachLibrary:"Photo library",attachFile:"Choose file",attachBrowser:"Browser",attachCommission:"Commission",attachCommands:"Commands",attachPlaceholder:"Add a note…",profileTitle:"Profile",profileSubtitle:"This session · hot-swap",profileCurrent:"current",profileFooter:"Applies to this session’s next turns only · running threads unaffected · global default in Settings",lineUnit:"lines",charUnit:"chars"}},EAe={zh:{menuCopy:"复制",menuEdit:"编辑消息",editingBadge:"编辑中",willRewind:(e,t)=>`将被回退 · ${e} 条回复 · ${t} 次工具调用`,editBarTitle:"编辑消息 — 发送将回退后续回复",edited:"已编辑",original:"原消息",regenNote:"由编辑重新生成"},en:{menuCopy:"Copy",menuEdit:"Edit message",editingBadge:"Editing",willRewind:(e,t)=>`Will rewind · ${e} repl${e===1?"y":"ies"} · ${t} tool call${t===1?"":"s"}`,editBarTitle:"Editing message — send rewinds later replies",edited:"edited",original:"Original message",regenNote:"Regenerated from edit"}};function RAe(){var tj,nj,rj,oj,ij,sj,aj;const e=he(),t=Xe(),n=Ve(),r=ht(),o=O(),s=dn(r,PAe),{currentProjectId:a}=zt(),{sessionId:l}=Kx(),c=l==="new",d=tl(a,"direct"),u=tl(a,"scheduled"),p=f.useMemo(()=>[...d.data??[],...u.data??[]].find(Fe=>Fe.sessionId===l)??null,[d.data,u.data,l]),h=c?"":(p==null?void 0:p.sessionId)??l??"",m=(p==null?void 0:p.origin)==="scheduled",x=ae({...e.schedules.list.queryOptions({projectId:a??void 0}),enabled:!!(p!=null&&p.scheduleId)}),v=f.useMemo(()=>{if(!m||!(p!=null&&p.scheduleId))return null;const oe=(x.data??[]).find(ut=>ut.id===p.scheduleId)??null,Fe=(u.data??[]).filter(ut=>ut.scheduleId===p.scheduleId);return jH(oe,Fe,p.sessionId)},[m,p==null?void 0:p.scheduleId,p==null?void 0:p.sessionId,x.data,u.data]),S=ae({...e.sessions.transcript.queryOptions({sessionId:h,compactSubagents:!0}),enabled:!!h}),{liveTail:b,getMessageSnapshot:g,streaming:w,running:k,backgroundRunning:C,liveTurns:T,contextUsage:P,todos:R,streamingText:D,pendingUser:I}=S1(h,p==null?void 0:p.running,p==null?void 0:p.backgroundRunning,{deltas:!0,transcript:S.data??null,contextUsage:(p==null?void 0:p.contextUsage)??null,todos:(p==null?void 0:p.todos)??null}),L=TU({sessionId:h,isDraft:c,projectId:a??"general",transcript:S.data??null,liveTail:b,pendingUser:I,getMessageSnapshot:g}),W=jU(h,{running:k,hasBackendHistory:!!(p!=null&&p.backendSessionId)}),ee=Lk(h);CU(h,`${b.length}:${k}`);const V=S.data??TAe,X=f.useMemo(()=>bIe(V,b,{streaming:w,running:k,streamingText:D,pendingUser:L.pendingUser,stripScheduledPrefix:!!(p!=null&&p.scheduleId)||m}),[V,b,w,k,D,L.pendingUser,p==null?void 0:p.scheduleId,m]),K=iz(T,(p==null?void 0:p.numTurns)??null),se=f.useMemo(()=>sz(oz(S.data)),[S.data]),B=f.useMemo(()=>{var oe;for(const Fe of X)if(!(Fe.kind!=="interaction"||((oe=Fe.detail)==null?void 0:oe.status)!=="pending")&&!(Fe.detail.kind==="ask-user"&&Fe.detail.payload.blocking===!1))return{detail:Fe.detail,ts:Fe.ts??null};return null},[X]),G=(B==null?void 0:B.detail.kind)==="ask-user"?NB(B.detail,B.ts):null,ne=(B==null?void 0:B.detail.kind)==="plan-approval"?SS(B.detail,B.ts):null,[le,_]=f.useState({}),Y=oe=>le[oe]??FB,te=(oe,Fe)=>{_(ut=>({...ut,[oe.requestId]:Fe})),Jxe(oe,Fe)&&ee.answerQuestion(oe.requestId,e1e(oe,Fe))},ie=(oe,Fe)=>{const ut=Y(oe.requestId),$n=oe.questions[aa(oe,ut)];$n&&te(oe,$5(ut,$n.question,Fe))},ye=(oe,Fe)=>{_(ut=>({...ut,[oe.requestId]:Xxe(Y(oe.requestId),Fe)}))},Z=oe=>{const Fe=Y(oe.requestId),ut=oe.questions[aa(oe,Fe)];ut&&Fe.selected.length>0&&te(oe,Zxe(Fe,ut.question))},[xe,ke]=f.useState(null),Oe=fo();f.useEffect(()=>{const oe=Oe.state;oe!=null&&oe.rejectPlan&&(ke(oe.rejectPlan),t(Oe.pathname,{replace:!0}))},[Oe.state]);const Ie=(ne==null?void 0:ne.requestId)??null;f.useEffect(()=>{xe&&xe!==Ie&&ke(null)},[xe,Ie]);const Ae=oe=>t(`/m/session/${h}/plan/${oe.requestId}`),tt=ae(e.config.get.queryOptions({})),we=((nj=(tj=tt.data)==null?void 0:tj.profiles)==null?void 0:nj.profiles)??[],lt=((oj=(rj=tt.data)==null?void 0:rj.profiles)==null?void 0:oj.defaultProfile)??null,[Qe,Zt]=f.useState(null),[wn,Qn]=f.useState(null),[qt,ft]=f.useState(!1),[Vr,pr]=f.useState([]);f.useEffect(()=>{if(!qt)return;let oe=!0;return KS().then(Fe=>{oe&&pr(Fe)}).catch(()=>{oe&&pr([])}),()=>{oe=!1}},[qt]);const[mt,Bt]=f.useState(null),[Ct,fr]=f.useState(!1),Sn=Mk(Ct),gt=aU(p),go=sU(),[In,qi]=f.useState(null),Er=P$(p==null?void 0:p.profileName,In,h),Rr=kIe(c?Qe:Er,we,lt);f.useEffect(()=>{if(!In)return;const oe=(p==null?void 0:p.sessionId)===In.sessionId,Fe=!c&&h!==In.sessionId;(oe||Fe)&&qi(null)},[p==null?void 0:p.sessionId,c,In,h]);const zn=Re(e.sessions.send.mutationOptions()),qr=Re(e.sessions.createAndSend.mutationOptions()),Fo=Re(e.sessions.setProfile.mutationOptions({onSuccess:()=>n.invalidateQueries(e.sessions.list.queryFilter())})),vo=Re(e.sessions.cancel.mutationOptions()),xo=()=>{!h||vo.isPending||vo.mutate({sessionId:h})},hr=Re(e.sessions.rewind.mutationOptions({onSettled:()=>{h&&(n.invalidateQueries(e.sessions.transcript.queryFilter({sessionId:h})),n.invalidateQueries(e.sessions.list.queryFilter()),wd(n,e,h))}})),[An,pn]=f.useState(""),[Ks,Gs]=f.useState(!1),[ui,Xn]=f.useState(!1),[mr,Bn]=f.useState(null),[Kr,pi]=f.useState(null),[$,q]=f.useState(null),[J,Q]=f.useState(null),re=f.useRef(""),[ve,Ne]=f.useState(!1),[be,Se]=f.useState(!1),[Pe,Le]=f.useState(!1),[qe,Ze]=f.useState([]),Jt=f.useRef(null),nt=xh({isDraft:c,sessionId:h,projectId:a}),Ye=f.useRef(null),Tt=f.useRef(null);Tt.current!==nt&&(Tt.current=nt,Ye.current=c?((ij=ic(nt))==null?void 0:ij.draftUploadId)??crypto.randomUUID():null);const Ce=c?Ye.current??"":h,rt=JH({scope:nt,bucket:Ce}),Mt=rt.items,an=f.useRef(void 0);CAe({draftKey:nt,isDraft:c,text:An,uploads:Mt,setText:pn,replaceRestored:rt.replaceRestored,draftUploadId:Ye,draftKeyRef:an});const Mr=rt.addFiles,Zn=(oe,Fe)=>{const ut=Jt.current;ut&&(ut.accept=oe,Fe?ut.setAttribute("capture",Fe):ut.removeAttribute("capture"),ut.click())},Ot=rt.completed,Ki=!rt.hasNonDone,Jn=!!An.trim(),Ke=$!=null?X[$]:null,wt=!!Ke&&Ke.kind==="user"&&Ke.turnIndex!==void 0,Gi=()=>{q(null),pn(re.current),re.current=""},wl=oe=>{const Fe=X[oe];!Fe||Fe.kind!=="user"||Fe.turnIndex===void 0||k||(re.current=An,ke(null),q(oe),pn(Fe.text))};f.useEffect(()=>{if($==null)return;const oe=X[$];(!(!!oe&&oe.kind==="user"&&oe.turnIndex!==void 0)||k)&&Gi()},[X,k,$]);const en=wt?{rowIndex:$,...az(X,$),onCancel:Gi}:null,Gr=mr!=null?X[mr]:null,Ph=Gr&&(Gr.kind==="user"||Gr.kind==="assistant")?{rowIndex:mr,anchorTop:Kr,onCopy:()=>{var oe;(oe=navigator.clipboard)==null||oe.writeText(Gr.text).catch(()=>{})},...Gr.kind==="user"&&Gr.turnIndex!==void 0?{onEdit:()=>wl(mr),editDisabled:k||hr.isPending}:{},onClose:()=>Bn(null)}:null,Ys=!wt&&!!xe&&xe===Ie,cp=wt?Jn&&Ki&&!hr.isPending:Ys||!!G?Jn&&Ki&&!ee.busy:QH(An,Mt)&&(!!h||c)&&!zn.isPending&&!qr.isPending,RV=(oe,Fe,ut)=>{if(an.current!==Fe){ws(Fe,R$(ic(Fe)??{text:"",attachments:[]},oe));return}oe.draftUploadId&&(Ye.current=oe.draftUploadId),pn($n=>[oe.text,$n].filter(gr=>gr.length>0).join(`
441
+ `.slice(-6e3))}).then(o=>{n?o():r=o}),()=>{n=!0,r()}},[]),e}function yEe({controller:e,account:t,login:n}){const r=O(),o=e.state,s=async a=>{await e.prepareClaude()&&n(a)};return F1()?o.claude===null?i.jsx(Mu,{disabled:o.claudeBusy,onClick:e.detectClaude,children:r.setupRetry}):t?o.claude.installed?i.jsx(VU,{account:t,disabled:o.claudeBusy||o.busy,login:s}):i.jsxs("div",{className:"setup-install-row",children:[i.jsx("p",{className:"setup-hint",children:r.setupCcConsent}),i.jsx(Mu,{disabled:o.claudeBusy||o.busy||!t.capabilities.length,onClick:()=>s({backend:"claude",provider:t.provider,authType:t.capabilities.includes("oauth")?"oauth":t.capabilities[0]}),children:r.setupCcInstall})]}):null:i.jsx("p",{className:"setup-hint",children:r.setupCcLocal})}function bEe({controller:e,login:t}){var a;const n=O(),r=e.state,o=xEe(),s=r.claude===null?n.setupUnknown:r.claude.installed?n.setupCcInstalled:n.setupCcMissing;return i.jsxs("section",{className:"setup-card",children:[i.jsxs("div",{className:"setup-card-header",children:[i.jsx(Xu,{provider:"claude-code",label:"Claude Code",size:20}),i.jsx("h2",{children:"Claude Code"}),i.jsxs("span",{className:"setup-pill",children:[n.setupOptional," · ",s]})]}),i.jsxs("div",{className:"setup-card-body setup-cc-body",children:[i.jsx(yEe,{controller:e,account:(a=r.status)==null?void 0:a.accounts.find(l=>l.backend==="claude"),login:t}),r.claudeBusy?i.jsx("p",{className:"setup-hint",role:"status",children:n.setupWorking}):null,o?i.jsx("pre",{className:"setup-log",children:o}):null,r.claudeError?i.jsx("p",{role:"alert",className:"setup-error",children:r.claudeError}):null]})]})}function wEe({controller:e}){var s;const t=O(),n=e.available(),r=((s=e.state.profiles)==null?void 0:s.defaultProfile)??"",o=n.some(a=>a.name===r);return i.jsxs("section",{className:"setup-card",children:[i.jsxs("div",{className:"setup-card-header",children:[i.jsx("h2",{children:i.jsx("label",{htmlFor:"setup-profile",children:t.setupProfile})}),r?i.jsx("span",{className:"setup-pill",children:r}):null]}),i.jsxs("div",{className:"setup-card-body setup-profile-body",children:[i.jsxs("select",{id:"setup-profile",className:"setup-input",disabled:e.state.busy||!n.length,value:o?r:"",onChange:a=>void e.select(a.target.value),children:[i.jsx("option",{value:"",disabled:!0,children:t.setupChooseProfile}),n.map(a=>i.jsxs("option",{value:a.name,children:[a.name," · ",a.model," · ",a.backend??"claude"]},a.name))]}),o?null:i.jsx("p",{className:"setup-hint",children:n.length?t.setupMismatch:t.setupNoProfiles})]})]})}function SEe({controller:e,leave:t}){const n=O();return i.jsxs("footer",{className:"setup-footer",children:[i.jsxs("div",{className:"setup-footer-actions",children:[i.jsx(Mu,{"data-action":"setup-skip",onClick:t,children:n.setupSkip}),i.jsxs(Mu,{"data-action":"setup-continue",primary:!0,disabled:!e.canContinue(),onClick:()=>{e.canContinue()&&t()},children:[n.setupContinue,i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:i.jsx("path",{d:"m9 5 7 7-7 7"})})]})]}),i.jsx("p",{className:"setup-footnote",children:n.setupSkipWarning}),i.jsx("p",{className:"setup-footnote",children:n.setupHonesty})]})}function kEe({controller:e,login:t}){var a;const n=O(),[r,o]=f.useState(""),s=e.state;return i.jsxs("section",{className:"setup-card",children:[i.jsxs("div",{className:"setup-card-header",children:[i.jsx("h2",{children:"PI"}),i.jsx("span",{className:"setup-pill setup-good",children:n.setupBundled}),i.jsx(Mu,{className:"setup-rescan",disabled:s.busy,onClick:e.refresh,children:s.busy?n.setupWorking:n.setupRescan})]}),s.status&&!s.status.piRuntime.available?i.jsxs("p",{role:"alert",className:"setup-error",children:[n.setupRuntimeError,": ",s.status.piRuntime.error]}):null,i.jsx("div",{className:"setup-search",children:i.jsx("input",{type:"search","aria-label":n.setupSearch,placeholder:n.setupSearch,value:r,onChange:l=>o(l.target.value),className:"setup-input"})}),i.jsx("div",{className:"setup-providers",children:lEe(((a=s.status)==null?void 0:a.accounts)??[],r).map(l=>{var c;return i.jsx(VU,{account:l,disabled:s.busy||!((c=s.status)!=null&&c.piRuntime.available),login:t},l.provider)})})]})}function jEe({controller:e}){const t=O(),n=e.state;return i.jsxs(i.Fragment,{children:[n.sync==="success"?i.jsx("p",{className:"setup-feedback",role:"status",children:t.setupSyncSuccess}):null,n.error?i.jsxs("p",{role:"alert",className:"setup-error",children:[t.setupSyncFailed,": ",n.error]}):null]})}function CEe({controller:e,leave:t}){f.useSyncExternalStore(e.subscribe,e.snapshot);const n=O(),[r,o]=f.useState(null),s=f.useCallback(a=>{a.step==="done"&&e.loginDone(a.flowId)},[e]);return i.jsxs(i.Fragment,{children:[i.jsxs("main",{className:"setup-workspace",children:[i.jsxs("header",{children:[i.jsx("div",{className:"setup-eyebrow",children:n.setupEyebrow}),i.jsx("h1",{children:n.setupTitle}),i.jsx("p",{className:"setup-intro",children:n.setupDescription})]}),i.jsx(kEe,{controller:e,login:o}),i.jsx(jEe,{controller:e}),i.jsx(bEe,{controller:e,login:o}),i.jsx(wEe,{controller:e}),i.jsx(SEe,{controller:e,leave:t})]}),i.jsx(XO,{open:!!r,target:r,onClose:()=>o(null),onFlowStateChange:s})]})}function TEe(){const e=dl(),t=Xe(),n=f.useMemo(()=>new uEe({status:()=>e.auth.status.query({}),config:()=>e.config.get.query({}),sync:()=>e.auth.syncGateway.mutate({}),select:r=>e.config.set.mutate({section:"profiles",value:{defaultProfile:r}}),claude:()=>ZE(!1),install:()=>ZE(!0),canInstall:F1}),[e]);return f.useEffect(()=>{n.load()},[n]),i.jsxs("div",{className:"provider-setup",children:[i.jsx(gEe,{}),i.jsx("div",{className:"setup-scroll",children:i.jsx(CEe,{controller:n,leave:()=>t("/workbench",{replace:!0})})})]})}const PEe=SN([{path:"/setup/providers",element:i.jsx(TEe,{})},{path:"/",element:i.jsx(vwe,{}),children:[{index:!0,element:i.jsx(yN,{to:"/workbench",replace:!0})},{path:"workbench",element:i.jsx(hPe,{})},{path:"tasks",element:i.jsx(mPe,{})},{path:"threads",element:i.jsx(xwe,{title:"Threads"})},{path:"overview",element:i.jsx(qPe,{})},{path:"memory",element:i.jsx(rEe,{})},{path:"skills",element:i.jsx(aEe,{})},{path:"kit",element:i.jsx(SPe,{})},{path:"base",element:i.jsx(PPe,{})}]}]),EEe=[{id:"sessions",path:"/m/sessions",tab:"sessions",tabRoot:!0},{id:"threads",path:"/m/threads",tab:"threads",tabRoot:!0},{id:"tasks",path:"/m/tasks",tab:"tasks",tabRoot:!0},{id:"project",path:"/m/project",tab:"project",tabRoot:!0},{id:"session",path:"/m/session/:sessionId",tab:"sessions",parent:"sessions"},{id:"plan",path:"/m/session/:sessionId/plan/:requestId",tab:"sessions",parent:"session"},{id:"thread",path:"/m/thread/:threadId",tab:"threads",parent:"threads"},{id:"task",path:"/m/task/:taskId",tab:"tasks",parent:"tasks"},{id:"approvals",path:"/m/approvals",tab:"project",parent:"project"},{id:"issues",path:"/m/issues",tab:"project",parent:"project"},{id:"notes",path:"/m/notes",tab:"project",parent:"project"},{id:"memory",path:"/m/memory",tab:"project",parent:"project"},{id:"memoryFile",path:"/m/memory/file",tab:"project",parent:"memory"},{id:"machines",path:"/m/machines",tab:"project",parent:"project"},{id:"settings",path:"/m/settings",tab:"project",parent:"project"},{id:"settingsAccounts",path:"/m/settings/accounts",tab:"project",parent:"settings"},{id:"settingsAppearance",path:"/m/settings/appearance",tab:"project",parent:"settings"},{id:"settingsPlatform",path:"/m/settings/platform",tab:"project",parent:"settings"},{id:"settingsProfiles",path:"/m/settings/profiles",tab:"project",parent:"settings"},{id:"settingsBudget",path:"/m/settings/budget",tab:"project",parent:"settings"},{id:"settingsMcp",path:"/m/settings/mcp",tab:"project",parent:"settings"},{id:"settingsNotifications",path:"/m/settings/notifications",tab:"project",parent:"settings"},{id:"settingsAdvanced",path:"/m/settings/advanced",tab:"project",parent:"settings"},{id:"settingsHooks",path:"/m/settings/hooks",tab:"project",parent:"settings"},{id:"settingsUsage",path:"/m/settings/usage",tab:"project",parent:"settings"},{id:"daemon",path:"/m/daemon",tab:"project",parent:"settings"}],z1=EEe,qU=Object.fromEntries(z1.map(e=>[e.id,e]));function R0(e){return e.length>1?e.replace(/\/+$/,""):e}function $k(e){const t=R0(e);for(const n of z1){const r=X4({path:n.path,end:!0},t);if(r)return{route:n,params:r.params}}}function KU(e,t={}){return rN(qU[e].path,t)}function REe(e){const t=$k(e),n=t==null?void 0:t.route.parent;if(!(!t||!n))return rN(qU[n].path,t.params)}const MEe={sessions:"sessions",threads:"threads",tasks:"tasks",project:"project"},_k=z1.filter(e=>e.tabRoot).map(e=>({id:e.tab,path:e.path,labelKey:MEe[e.tab]}));function GU(e,t){return e===t||e.startsWith(`${t}/`)}function IEe(e){var r;const t=R0(e),n=$k(t);return n?n.route.tab:((r=_k.find(o=>GU(t,o.path)))==null?void 0:r.id)??"sessions"}function zd(e){var t;return((t=$k(e))==null?void 0:t.route.tabRoot)===!0}function AEe(e){const t=R0(e);return _k.some(n=>GU(t,n.path))}function DEe(e,t){return e==="project"&&t.needsYouCount>0?{count:t.needsYouCount}:{}}function LEe(e,t,n,r,o=!1){return n||r?{animate:!1}:o?{animate:!0,dir:"back"}:e==="REPLACE"?{animate:!1}:{animate:!0,dir:e==="POP"?"back":"forward"}}function YU(e,t){return R0(e)===R0(t)}function OEe(e,t,n){return t&&YU(t.key,n.key)?{current:t,retainedTab:null,returningToRetained:!0}:zd(e.key)&&!zd(n.key)?{current:n,retainedTab:e,returningToRetained:!1}:{current:n,retainedTab:zd(n.key)?null:t,returningToRetained:!1}}function NEe(e){return e==="forward"?{incoming:"animate-slide-in-right",outgoing:"animate-slide-out-left"}:{incoming:"animate-slide-in-left",outgoing:"animate-slide-out-right"}}function FEe(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const QU={position:"absolute",inset:0,background:y.canvas,isolation:"isolate"},zEe={...QU,visibility:"hidden",pointerEvents:"none"};function BEe(e,t,n){const[r,o]=f.useState({key:e,element:n}),[s,a]=f.useState(null),[l,c]=f.useState(null),[d,u]=f.useState("forward");return f.useLayoutEffect(()=>{if(YU(e,r.key))return;const h=OEe(r,s,{key:e,element:n}),m=zd(r.key)&&zd(e),x=LEe(t,!1,FEe(),m,h.returningToRetained);a(h.retainedTab),c(x.animate?r:null),x.animate&&u(x.dir),o(h.current)},[e]),{current:r,retainedTab:s,previous:l,dir:d,onSettled:()=>c(null)}}function t2({frame:e,role:t,className:n,hidden:r,onAnimationEnd:o}){return i.jsx("div",{"data-route-layer":t,"data-route-key":e.key,className:n,style:r?zEe:QU,"aria-hidden":t==="current"?void 0:!0,onAnimationEnd:o,children:e.element})}function $Ee({current:e,retainedTab:t,previous:n,dir:r,onSettled:o}){const s=NEe(r),a=t&&t.key!==(n==null?void 0:n.key)&&t.key!==e.key;return i.jsxs("div",{style:{position:"relative",height:"100%",overflow:"hidden"},children:[a&&i.jsx(t2,{frame:t,role:"retained",hidden:!0},t.key),n&&i.jsx(t2,{frame:n,role:"previous",className:s.outgoing},n.key),i.jsx(t2,{frame:e,role:"current",className:n?s.incoming:void 0,onAnimationEnd:n?o:void 0},e.key)]})}function _Ee(){const e=fo(),t=use(),n=mN(),r=BEe(e.pathname,t,n);return i.jsx($Ee,{...r})}const WEe="var(--proto-ink)",HEe="var(--proto-muted-3)";function UEe({id:e,color:t}){switch(e){case"sessions":return i.jsx("svg",{width:"21",height:"21",viewBox:"0 0 22 22",fill:"none",stroke:t,strokeWidth:"1.7",children:i.jsx("path",{d:"M4 4.5h14a1.5 1.5 0 0 1 1.5 1.5v8a1.5 1.5 0 0 1-1.5 1.5H9.5L5.5 19v-3.5H4A1.5 1.5 0 0 1 2.5 14V6A1.5 1.5 0 0 1 4 4.5z"})});case"threads":return i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 14 14",fill:"none",stroke:t,strokeWidth:"1.4",children:[i.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),i.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),i.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),i.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]});case"tasks":return i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:t,strokeWidth:"1.6",children:[i.jsx("path",{d:"M4 5.5l1.5 1.5L8 4.5"}),i.jsx("path",{d:"M4 12.5l1.5 1.5L8 11.5"}),i.jsx("path",{d:"M10.5 6h6M10.5 13h6"})]});case"project":return i.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:t,strokeWidth:"1.6",children:i.jsx("path",{d:"M3 5.5h5l1.5 2H17a1 1 0 0 1 1 1V15a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1z"})})}}function VEe({vocab:e,activeId:t,needsYouCount:n,onNavigate:r}){return i.jsx("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line)",background:"var(--proto-rail)",display:"flex",padding:"8px 6px",paddingBottom:"calc(8px + env(safe-area-inset-bottom))"},children:_k.map(o=>{const s=o.id===t,a=s?WEe:HEe,l=DEe(o.id,{needsYouCount:n});return i.jsxs("button",{type:"button","data-tab-id":o.id,"data-active":s?"true":"false","aria-current":s?"page":void 0,onClick:()=>r(o.path),style:{flex:1,minHeight:44,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:3,border:"none",background:"transparent",padding:0,cursor:"pointer"},children:[i.jsxs("div",{style:{position:"relative"},children:[i.jsx(UEe,{id:o.id,color:a}),l.count!==void 0&&i.jsx("span",{style:{position:"absolute",top:-4,right:-9,background:"var(--proto-amber)",color:"var(--ink-solid-fg)",font:"600 8px 'IBM Plex Mono', monospace",padding:"1px 4.5px",borderRadius:999},children:l.count})]}),i.jsx("span",{style:{fontSize:10,fontWeight:600,color:a},children:e[o.labelKey]})]},o.id)})})}function qEe(e){return REe(e)??KU("sessions")}function KEe(e,t,n=!1){return t?{kind:"history"}:zd(e)?{kind:"exit"}:n?{kind:"history"}:{kind:"navigate",to:qEe(e)}}function GEe(e,t){return e&&typeof(t==null?void 0:t.idx)=="number"&&t.idx>0}async function YEe(e,t,n,r){const o=KEe(e,t,n);if(o.kind==="history")return r.historyBack();if(o.kind==="exit")return void await r.exit();r.navigate(o.to,{replace:!0})}function QEe(e,t){t(e,{replace:!0})}function XEe(e){return!e||typeof e!="object"?!1:Reflect.get(e,"canGoBack")===!0}async function ZEe(){await bt("plugin:app|exit")}function JEe(){const e=window.history.state;return(e==null?void 0:e.__cortexOverlay)===!0}function eRe(e,t){const n=f.useRef({pathname:e,navigate:t});n.current={pathname:e,navigate:t},f.useEffect(()=>xve(r=>{const o=n.current,s=window.history.state,a=GEe(XEe(r),s);YEe(o.pathname,JEe(),a,{historyBack:()=>window.history.back(),exit:ZEe,navigate:o.navigate}).catch(()=>{})}),[])}function tRe(e){return{title:e.title,body:e.meta}}function B1(){return dr()}let Ba=null,Ip;const XU="cortex.mobile.notifications.permission-requested";let Ng=!1;function nRe(){if(!No())return Ng;try{return Ng||localStorage.getItem(XU)==="true"}catch{return Ng}}function rRe(){if(Ng=!0,!!No())try{localStorage.setItem(XU,"true")}catch{}}async function Wk(){if(!B1())return!1;try{const{isPermissionGranted:e}=await np(async()=>{const{isPermissionGranted:t}=await import("./index-BYjTpT0c.js");return{isPermissionGranted:t}},[]);Ba=await e()}catch{Ba=!1}return Ba}async function oRe(){if(await Wk())return!0;if(nRe()||No()&&typeof document<"u"&&document.visibilityState!=="visible")return!1;rRe();try{const{requestPermission:e}=await np(async()=>{const{requestPermission:t}=await import("./index-BYjTpT0c.js");return{requestPermission:t}},[]);Ba=await e()==="granted"}catch{Ba=!1}return Ba}async function ZU(){return B1()?Ip||(Ba!==null?Ba:(Ip=oRe().finally(()=>{Ip=void 0}),Ip)):!1}async function iRe(e,t){if(!B1())return!1;try{if(!await ZU())return!1;if(No()){const r=await bt("plugin:cortex-notifications|post",{...e,data:t});if(!hh(r))return r.ok}const{sendNotification:n}=await np(async()=>{const{sendNotification:r}=await import("./index-BYjTpT0c.js");return{sendNotification:r}},[]);return n({...e,extra:t,autoCancel:!0}),!0}catch{return!1}}function sRe(e){if(!e||typeof e!="object")return;const t=Reflect.get(e,"notification"),n=t&&typeof t=="object"?Reflect.get(t,"extra")??Reflect.get(e,"extra"):Reflect.get(e,"extra");return n&&typeof n=="object"?n:void 0}async function JE(e,t){let n=(t==null?void 0:t.aborted)??!1,r=()=>{};const o=()=>{n=!0,t==null||t.removeEventListener("abort",o),r()};t==null||t.addEventListener("abort",o,{once:!0});try{const{onAction:s}=await np(async()=>{const{onAction:c}=await import("./index-BYjTpT0c.js");return{onAction:c}},[]);if(n)return o;const a=await s(c=>{n||Promise.resolve(e(sRe(c))).catch(()=>{})});let l=!1;r=()=>{l||(l=!0,a.unregister().catch(()=>{}))},n&&r()}catch{o()}return o}async function aRe(e,t){if(!B1()||t!=null&&t.aborted)return()=>{};if(!No())return JE(e,t);try{return await y1()?vve(r=>e({...r}),t):JE(e,t)}catch{return()=>{}}}let Iu={status:null,supported:null,pending:!1,error:null};const Rw=new Set;let n2=Promise.resolve();const Jv=()=>typeof document<"u"&&document.visibilityState==="visible",eR=()=>Iu,lRe=e=>(Rw.add(e),()=>{Rw.delete(e)});function cc(e){Iu={...Iu,...e},Rw.forEach(t=>t())}async function JU(e,t){const n=await bt("mobile_notifications_configure",{enabled:e,locale:t,completionNotifications:!0});if(!n.ok)throw new Error("Native notification configuration failed");return n.value}function cRe(){var e;return((e=Iu.status)==null?void 0:e.completionNotifications)===!0&&Iu.status.enabled}function Mw(e){return n2=n2.then(e).catch(()=>{cc({error:"configure",pending:!1})}),n2}async function tR(e,t,n){if(!n()||!Jv())return;const r=await y1();if(!n())return;cc({status:r,supported:r!==null});const o=await(t?ZU():Wk());if(!r||!n()||!Jv())return;if(r.enabled&&!o){cc({status:{...r,permissionGranted:!1}});return}const s=await JU(r.enabled,e);n()&&cc({status:s,error:null})}function dRe(e){if(!No())return()=>{};let t=!0;const n=()=>{Mw(()=>tR(e,!1,()=>t))};return Mw(()=>tR(e,!0,()=>t)),document.addEventListener("visibilitychange",n),window.addEventListener("focus",n),()=>{t=!1,document.removeEventListener("visibilitychange",n),window.removeEventListener("focus",n)}}function uRe(e){f.useEffect(()=>dRe(e),[e])}function pRe(){return f.useSyncExternalStore(lRe,eR,eR)}function fRe(e,t){return!No()||Iu.pending?Promise.resolve():(cc({pending:!0,error:null}),Mw(async()=>{if(e&&(!Jv()||!await Wk()||!Jv())){cc({pending:!1,error:"permission"});return}const n=await JU(e,t);cc({status:n,supported:!0,pending:!1,error:null})}))}const hRe=/^\/m\/session\/([^/]+)$/;function eV(e){const t=hRe.exec(e);if(!t)return null;try{return Th(decodeURIComponent(t[1]))??null}catch{return null}}function Th(e){if(!(typeof e!="string"||!e.trim()||e.length>512)&&!/[\u0000-\u001f\u007f]/.test(e))try{return encodeURIComponent(e),e}catch{return}}async function mRe(e,t){const n=Th(e.sessionId);if(!n)return{path:"/m/sessions"};const r=(await t.sessions()).find(o=>o.sessionId===n);return r?{path:`/m/session/${encodeURIComponent(n)}`,projectId:r.projectId??void 0}:{path:"/m/sessions"}}async function gRe(e,t){const n=Th(e.approvalId);if(!n)return{path:"/m/approvals"};const r=(await t.approvals()).find(o=>o.id===n);return r?{path:`/m/approvals?approvalId=${encodeURIComponent(n)}`,projectId:r.projectId??void 0}:{path:"/m/approvals"}}async function vRe(e,t){const n=e.kind??(e.sessionId?"session":"sessions");return n==="session"?mRe(e,t):n==="approvals"?gRe(e,t):{path:"/m/sessions"}}function zi(e,t=Date.now()){if(!e)return"";const n=Date.parse(e);if(Number.isNaN(n))return"";const r=t-n;if(r<0)return"现在";const o=Math.floor(r/6e4);if(o<1)return"现在";if(o<60)return`${o} 分钟`;const s=Math.floor(o/60);if(s<24)return`${s} 小时`;const a=Math.floor(s/24);return a===1?"昨天":a<7?`${a} 天前`:`${Math.floor(a/7)} 周前`}function M0(e){return e==null||Number.isNaN(e)?"—":yn(e)}function dn(e,t){return e==="zh"?t.zh:t.en}function xRe({items:e,now:t=Date.now(),onDismiss:n,onActivate:r}){if(e.length===0)return null;const{visible:o}=B$(e);return i.jsx("div",{style:{position:"fixed",top:"calc(10px + env(safe-area-inset-top))",left:10,right:10,zIndex:1e3,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none"},children:o.map(s=>i.jsxs("div",{role:"button",onClick:()=>r(s),style:{pointerEvents:"auto",background:"var(--panel-translucent-bg)",border:"1px solid var(--panel-translucent-border)",borderRadius:20,boxShadow:"var(--shadow-toast)",padding:"11px 13px",display:"flex",gap:10,alignItems:"center",cursor:"pointer"},children:[i.jsx("div",{"aria-label":"Cortex",style:{width:36,height:36,borderRadius:9,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center",flex:"none"},children:i.jsxs("svg",{width:25,height:25,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[i.jsx("circle",{cx:33,cy:32,r:5,fill:"var(--brand-badge-core)"}),i.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"}),i.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"})]})}),i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:12.5,fontWeight:650,color:y.ink,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.title}),i.jsx("div",{style:{fontSize:11,color:y.sub,marginTop:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.meta})]}),i.jsx("span",{style:{font:`400 10px ${H}`,color:y.faint,flex:"none",alignSelf:"flex-start"},children:zi(s.ts,t)||"现在"}),i.jsx("button",{type:"button","aria-label":"Dismiss",onClick:a=>{a.stopPropagation(),n(s.id)},style:{border:"none",background:"transparent",color:y.faint,fontSize:12,cursor:"pointer",flex:"none",padding:"0 2px"},children:"✕"})]},s.id))})}function yRe(){const e=dl(),t=Xe(),{setCurrentProject:n}=zt();f.useEffect(()=>{const r=new AbortController;let o=()=>{};return aRe(async s=>{if(!s||r.signal.aborted)return!1;const a=await vRe(s,{sessions:()=>e.sessions.list.query({origin:"direct"}),approvals:()=>e.approvals.list.query({status:"pending"})}),l=s.scope===void 0?null:await y1();if(r.signal.aborted||s.scope!==void 0&&s.scope!==(l==null?void 0:l.scope))return!1;a.projectId&&n(a.projectId),t(a.path)},r.signal).then(s=>{r.signal.aborted?s():o=s}),()=>{r.abort(),o()}},[e,t,n])}function bRe(e){if(e.sessionId&&cRe())return Promise.resolve(!0);const t=e.sessionId?{kind:"session",sessionId:e.sessionId,projectId:e.projectId??""}:{kind:"sessions"};return iRe(tRe(e),t)}function wRe(){const e=fo(),t=f.useRef(e.pathname);return t.current=e.pathname,f.useCallback(n=>document.visibilityState==="visible"&&eV(t.current)===n,[])}function SRe(){const e=eV(fo().pathname);f.useEffect(()=>{const t=()=>{V9(document.visibilityState==="visible"?e:null)};return t(),document.addEventListener("visibilitychange",t),()=>{document.removeEventListener("visibilitychange",t),V9(null)}},[e])}function kRe(){const e=Xe(),{setCurrentProject:t}=zt();uRe(ht()),yRe(),SRe();const n=f.useCallback((l,c)=>{if(!Th(l)){e("/m/sessions");return}c&&t(c),e(`/m/session/${encodeURIComponent(l)}`)},[e,t]),r=wRe(),{items:o,dismiss:s}=$$({isSessionOpen:r,externalDelivery:bRe}),a=f.useCallback(l=>{n(l.sessionId,l.projectId),s(l.id)},[s,n]);return i.jsx(xRe,{items:o,onDismiss:s,onActivate:a})}const jRe="'IBM Plex Mono', monospace",CRe={position:"fixed",inset:0,zIndex:60,background:"var(--overlay-scrim-strong)",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 36px",boxSizing:"border-box"},TRe={width:"100%",background:"var(--proto-card)",borderRadius:18,boxShadow:"var(--shadow-overlay-strong)",padding:"24px 20px 14px",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center"},PRe={width:46,height:46,borderRadius:14,background:"var(--proto-accent-bg)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:14},ERe={fontSize:17,fontWeight:700,color:"var(--proto-ink)",letterSpacing:"-.01em"},RRe={font:`500 10.5px ${jRe}`,color:"var(--proto-muted-3)",marginTop:6},MRe={fontSize:13,lineHeight:1.6,color:"var(--proto-muted)",textAlign:"center",margin:"10px 0 18px"};function IRe({title:e,summary:t}){return i.jsxs(i.Fragment,{children:[i.jsx("div",{style:PRe,children:i.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.8",children:[i.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),i.jsx("path",{d:"M3.5 16.5h13"})]})}),i.jsx("div",{style:ERe,children:e}),i.jsx("div",{style:RRe,children:t})]})}function tV(e){return i.jsx("div",{role:"dialog","aria-modal":"true","aria-label":e.title,style:CRe,children:i.jsxs("div",{style:TRe,children:[i.jsx(IRe,{title:e.title,summary:e.summary}),i.jsx("div",{style:MRe,children:e.description}),e.children]})})}const ARe={width:"100%",display:"flex",flexDirection:"column",gap:2},DRe={height:48,border:"none",borderRadius:13,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14.5,fontWeight:600,cursor:"pointer",width:"100%"},nR={height:44,border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600,color:"var(--proto-muted-2)",cursor:"pointer",flex:1};function LRe(e){return i.jsxs("div",{style:ARe,children:[i.jsx("button",{type:"button",onClick:e.onInstall,disabled:e.busy,style:{...DRe,opacity:e.busy?.6:1},children:e.busy?"正在处理…":V$(e.update.kind)}),i.jsxs("div",{style:{display:"flex",width:"100%"},children:[i.jsx("button",{type:"button",onClick:e.onSkip,style:nR,children:"跳过此版本"}),i.jsx("button",{type:"button",onClick:e.onDismiss,style:nR,children:"稍后"})]})]})}function ORe(e){return i.jsxs(tV,{title:"App 新版本已就绪",summary:U$(e.update),description:q$(e.update.kind),children:[e.error?i.jsxs("div",{style:{fontSize:12,color:"var(--proto-danger)",marginBottom:10,textAlign:"center"},children:["安装失败:",e.error]}):null,i.jsx(LRe,{...e})]})}const NRe={width:"100%",display:"flex",flexDirection:"column",gap:2},FRe={height:48,border:"none",borderRadius:13,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14.5,fontWeight:600,cursor:"pointer",width:"100%"},zRe={height:44,border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600,color:"var(--proto-muted-2)",cursor:"pointer",width:"100%"};function BRe(e){return i.jsxs("div",{style:NRe,children:[i.jsx("button",{type:"button",onClick:e.onApply,style:FRe,children:"退出 App"}),i.jsx("button",{type:"button",onClick:e.onDismiss,style:zRe,children:"忽略"})]})}function $Re(e){return i.jsx(tV,{title:"新版本已就绪",summary:H$(e.update),description:"热更新已在后台下载完成,重启 App 后生效。运行中的线程在服务端继续执行,不受重启影响。",children:i.jsx(BRe,{onApply:e.onApply,onDismiss:e.onDismiss})})}function _Re(){const e=X$();return e?e.kind==="hot"?i.jsx($Re,{update:e.update,onApply:e.apply,onDismiss:e.dismiss}):i.jsx(ORe,{update:e.update,busy:e.busy,error:e.error,onInstall:e.install,onSkip:e.skip,onDismiss:e.dismiss}):null}const rR="--cortex-vvh",oR="--cortex-vvt";function WRe(e,t){const n=()=>{e.setProperty(rR,`${t.height}px`),e.setProperty(oR,`${t.offsetTop}px`)};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n),e.removeProperty(rR),e.removeProperty(oR)}}function HRe(){f.useEffect(()=>{const e=window.visualViewport;if(e)return WRe(document.documentElement.style,e)},[])}const URe={position:"fixed",top:0,left:0,right:0,height:"var(--cortex-vvh, 100dvh)",transform:"translateY(var(--cortex-vvt, 0px))",display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--proto-alt)"};function VRe({pathname:e,vocab:t,needsYouCount:n,onTab:r}){return i.jsxs("div",{style:URe,children:[i.jsx("div",{style:{flex:1,minHeight:0,overflow:"hidden"},children:i.jsx(_Ee,{})}),AEe(e)&&i.jsx(VEe,{vocab:t,activeId:IEe(e),needsYouCount:n,onNavigate:r})]})}function qRe({children:e}){return i.jsx(o$,{children:i.jsx(t_,{children:i.jsx(T$,{children:i.jsx(SB,{children:i.jsxs(IB,{children:[e,i.jsx(kRe,{}),i.jsx(_Re,{})]})})})})})}function KRe(){var a;const e=O(),t=fo(),n=Xe(),r=he();HRe(),eRe(t.pathname,n);const s=((a=ae(r.approvals.list.queryOptions({status:"pending"})).data)==null?void 0:a.length)??0;return i.jsx(qRe,{children:i.jsx(VRe,{pathname:t.pathname,vocab:e,needsYouCount:s,onTab:l=>QEe(l,n)})})}function GRe(e){return e.awaitingInput?{kind:"awaiting",text:"等待操作"}:e.running&&e.backgroundRunning?{kind:"background",text:"后台运行"}:e.running?{kind:"running",text:e.numTurns!=null?`running · ${e.numTurns} turns`:"running"}:{kind:"idle",text:"空闲"}}function YRe(e,t){return{id:e.sessionId,title:e.label||e.name||e.sessionId,time:zi(e.lastUsedAt||e.createdAt,t),running:e.running,numTurns:e.numTurns,unread:e.unread}}function QRe(e,t=Date.now()){return H7e(e,t).map(n=>({key:n.label,rows:n.items.map(r=>YRe(r,t))}))}function XRe(e,t){return t==="TODAY"?e.today:t==="YESTERDAY"?e.yesterday:e.earlier}function ZRe({onClick:e}){return i.jsx("button",{type:"button","aria-label":"New session",onClick:e,style:{width:34,height:34,borderRadius:"50%",background:y.ink,border:"none",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ink-solid-fg)",lineHeight:0,cursor:"pointer"},children:i.jsx(gc,{size:15,strokeWidth:1.9})})}function JRe({unread:e,onClick:t}){return i.jsxs("div",{style:{position:"relative",flex:"none"},children:[i.jsx("button",{type:"button","aria-label":"Scheduled",onClick:t,style:{width:34,height:34,borderRadius:"50%",background:y.card,border:`1px solid ${y.hairline}`,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},children:i.jsxs("svg",{width:16,height:16,viewBox:"0 0 14 14",fill:"none",stroke:y.sub,strokeWidth:1.5,children:[i.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),i.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]})}),e>0&&i.jsx("span",{"aria-label":`${e} unread scheduled`,style:{position:"absolute",top:-3,right:-4,background:y.run,color:"var(--ink-solid-fg)",font:`600 8.5px ${H}`,padding:"1px 4.5px",borderRadius:999,border:`1.5px solid ${y.canvas}`},children:e})]})}function eMe({row:e,byId:t,onOpen:n}){const r=t.get(e.id),o=r?GRe(r):{kind:"idle",text:"空闲"},s=o.kind==="running"||o.kind==="background";return i.jsxs(et,{radius:9,padding:"12px 13px",onClick:()=>n(e.id),style:s?{boxShadow:`inset 2px 0 0 ${y.run}`}:void 0,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[e.unread&&i.jsx("span",{"aria-label":"unread",style:{width:7,height:7,borderRadius:"50%",background:y.run,flex:"none"}}),i.jsx("span",{style:{fontSize:14,fontWeight:e.unread?600:400,color:e.unread?y.ink:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint,flex:"none"},children:e.time})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginTop:4},children:[o.kind==="running"&&i.jsx(Mi,{color:y.run,pulse:!0}),o.kind==="background"&&i.jsx(Mi,{color:y.run,pulse:!0}),o.kind==="awaiting"&&i.jsx(Mi,{color:y.amber,pulse:!0}),i.jsx("span",{style:{font:`400 10px ${H}`,color:s?y.run:y.muted},children:o.text})]})]})}function tMe({groups:e,sessions:t,scope:n,copy:r,scheduled:o,onOpen:s,onNew:a}){const l=new Map(t.map(c=>[c.sessionId,c]));return i.jsx(At,{label:"1a 会话列表",header:i.jsx(Hx,{title:r.title,qn:n,trailing:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o&&i.jsx(JRe,{unread:o.unread,onClick:o.onOpen}),i.jsx(ZRe,{onClick:a})]})}),children:i.jsxs(Yn,{gap:6,children:[e.length===0&&i.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:y.faint,fontSize:13},children:r.empty}),e.map(c=>i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx(fu,{style:{padding:"6px 2px 2px"},children:XRe(r,c.key)}),c.rows.map(d=>i.jsx(eMe,{row:d,byId:l,onOpen:s},d.id))]},c.key))]})})}const Os={display:"block",marginBottom:5,color:y.faint,font:`600 9.5px ${H}`,letterSpacing:".05em"},Bi={width:"100%",minHeight:40,boxSizing:"border-box",border:`1px solid ${y.hairline}`,borderRadius:9,padding:"8px 10px",background:y.card,color:y.ink,fontSize:13},Hk={display:"grid",gridTemplateColumns:"1fr 1fr",gap:8};function nMe({copy:e,mode:t,onBack:n}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"0 2px 12px"},children:[i.jsx("button",{type:"button","data-action":"sheet-back",onClick:n,"aria-label":e.back,style:{border:0,background:"transparent",color:y.run,fontSize:20,padding:"0 3px",cursor:"pointer"},children:"‹"}),i.jsx("span",{style:{fontSize:17,fontWeight:700,color:y.ink},children:t==="edit"?e.scEditSchedule:e.scNewSchedule})]})}function rMe({copy:e,form:t,editableFields:n,onChange:r}){const o={interval:e.scTypeInterval,daily:e.scTypeDaily,weekly:e.scTypeWeekly,once:e.scTypeOnce};return i.jsxs("div",{children:[i.jsx("span",{style:Os,children:e.scType}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",border:`1px solid ${y.hairline}`,borderRadius:9,overflow:"hidden"},children:_5.map(s=>i.jsx(oMe,{type:s,form:t,disabled:!n.type,label:o[s],onChange:r},s))})]})}function oMe({type:e,form:t,disabled:n,label:r,onChange:o}){const s=t.type===e;return i.jsx("button",{type:"button",disabled:n,"aria-pressed":s,onClick:()=>o({type:e}),style:{border:0,borderRight:e==="once"?0:`1px solid ${y.hairline}`,padding:"8px 2px",background:s?"var(--proto-accent-bg)":y.card,color:s?y.run:y.muted,fontSize:10.5},children:r})}function iMe({copy:e,form:t,editableFields:n,onChange:r}){return rp(t.type).time?i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scTime}),i.jsx("input",{style:Bi,value:t.time,disabled:!n.time,onChange:o=>r({time:o.target.value})})]}):null}function sMe({copy:e,form:t,editableFields:n,onChange:r}){return rp(t.type).interval?i.jsxs("div",{children:[i.jsx("span",{style:Os,children:e.scEvery}),i.jsxs("div",{style:Hk,children:[i.jsx("input",{style:Bi,type:"number",min:1,value:t.intervalValue,disabled:!n.interval,onChange:o=>r({intervalValue:Number(o.target.value)})}),i.jsx("select",{style:Bi,value:t.intervalUnit,disabled:!n.interval,onChange:o=>r({intervalUnit:o.target.value}),children:Av.map(o=>i.jsx("option",{value:o,children:o},o))})]})]}):null}function aMe({copy:e,form:t,editableFields:n,onChange:r}){return!rp(t.type).delay||!n.delay?null:i.jsxs("div",{"data-schedule-delay":!0,children:[i.jsx("span",{style:Os,children:e.scIn}),i.jsxs("div",{style:Hk,children:[i.jsx("input",{style:Bi,type:"number",min:1,value:t.delayValue,onChange:o=>r({delayValue:Number(o.target.value)})}),i.jsx("select",{style:Bi,value:t.delayUnit,onChange:o=>r({delayUnit:o.target.value}),children:Av.map(o=>i.jsx("option",{value:o,children:o},o))})]})]})}function lMe({copy:e,form:t,mode:n}){return n!=="edit"||t.type!=="once"?null:i.jsx("div",{"data-once-timing-note":!0,style:{border:`1px solid ${y.hairline}`,borderRadius:9,padding:10,color:y.muted,fontSize:11.5,lineHeight:1.5},children:e.scOnceTimingUnavailable})}function cMe({copy:e,form:t,editableFields:n,onChange:r}){if(!rp(t.type).dayOfWeek)return null;const o=[e.scDaySun,e.scDayMon,e.scDayTue,e.scDayWed,e.scDayThu,e.scDayFri,e.scDaySat];return i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scDay}),i.jsx("select",{style:Bi,value:t.dayOfWeek,disabled:!n.dayOfWeek,onChange:s=>r({dayOfWeek:Number(s.target.value)}),children:m$.map(s=>i.jsx("option",{value:s.value,children:o[s.value]??s.label},s.value))})]})}function dMe({copy:e,form:t,editableFields:n,profileOptions:r,onChange:o}){return i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scProfile}),i.jsx("select",{style:Bi,value:t.profile,disabled:!n.profile,onChange:s=>o({profile:s.target.value}),children:r.map(s=>i.jsx("option",{value:s,children:s},s))})]})}function uMe({copy:e,form:t,editableFields:n,onChange:r}){return i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scMessage}),i.jsx("textarea",{style:{...Bi,minHeight:82,resize:"vertical"},value:t.message,disabled:!n.message,onChange:o=>r({message:o.target.value})})]})}function pMe({copy:e,form:t,mode:n,editableFields:r,onChange:o}){return i.jsxs("div",{style:{...Hk,opacity:n==="edit"?.6:1},children:[i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scTarget}),i.jsx("select",{style:Bi,value:t.target,disabled:!r.target,onChange:s=>o({target:s.target.value}),children:h$.map(s=>i.jsx("option",{value:s,children:s},s))})]}),i.jsxs("label",{children:[i.jsx("span",{style:Os,children:e.scFallback}),i.jsx("select",{style:Bi,value:t.fallback,disabled:!r.fallback,onChange:s=>o({fallback:s.target.value}),children:f$.map(s=>i.jsx("option",{value:s,children:s},s))})]})]})}function fMe({copy:e,mode:t,valid:n,pending:r,error:o,onSubmit:s}){return i.jsxs(i.Fragment,{children:[o&&i.jsx("div",{role:"alert",style:{color:y.fail,fontSize:11.5},children:o}),i.jsx("button",{type:"button","data-action":"save-schedule",disabled:!n||r,onClick:s,style:{border:0,borderRadius:9,padding:11,background:y.run,color:"var(--ink-solid-fg)",fontSize:13,fontWeight:700},children:t==="edit"?e.scSaveSchedule:e.scCreateSchedule})]})}function hMe(e){return i.jsxs("div",{style:{display:"grid",gap:12},children:[i.jsx(rMe,{...e}),i.jsx(iMe,{...e}),i.jsx(sMe,{...e}),i.jsx(aMe,{...e}),i.jsx(lMe,{...e}),i.jsx(cMe,{...e}),i.jsx(dMe,{...e}),i.jsx(uMe,{...e}),i.jsx(pMe,{...e}),i.jsx(fMe,{...e})]})}function mMe(e){const t=O(),n={...e,copy:t};return i.jsxs("div",{"data-mobile-schedule-editor":!0,children:[i.jsx(nMe,{...n}),i.jsx(hMe,{...n})]})}function Uk({size:e,color:t}){return i.jsxs("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"none",stroke:t,strokeWidth:1.6,style:{flex:"none"},children:[i.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),i.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]})}function gMe({sub:e}){return e.kind!=="run"?null:i.jsxs(i.Fragment,{children:[e.stamp,e.cost&&i.jsxs(i.Fragment,{children:[" · ",e.cost]})]})}function vMe({sub:e,copy:t}){return e.kind!=="pending"?null:i.jsxs(i.Fragment,{children:[e.cadence,e.nextDelta&&i.jsxs(i.Fragment,{children:[" · ",t.nextIn.replace("{d}",e.nextDelta)]})]})}function xMe({sub:e,copy:t}){return e.kind!=="paused"?null:i.jsxs(i.Fragment,{children:[e.cadence," · ",i.jsx("span",{style:{color:y.amberText},children:t.paused})]})}function yMe({row:e,copy:t,now:n}){const r=kH(e,n);return i.jsxs("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:2},children:[i.jsx(gMe,{sub:r}),i.jsx(vMe,{sub:r,copy:t}),i.jsx(xMe,{sub:r,copy:t})]})}function bMe({rows:e,copy:t}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"0 2px 10px"},children:[i.jsx(Uk,{size:14,color:y.run}),i.jsx("span",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em"},children:t.title}),i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint},children:t.countUnit.replace("{n}",String(e.length))})]})}function wMe(e){return{display:"flex",alignItems:"center",gap:9,padding:13,minHeight:44,boxSizing:"border-box",cursor:"pointer",borderBottom:e?"none":`1px solid ${y.divider}`}}function SMe({row:e,copy:t}){return i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{font:`500 10px ${H}`,color:y.muted,flex:"none"},children:e.kind==="repeat"?`×${e.runs.length}`:t.once}),e.unread&&i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:y.run,flex:"none"}}),i.jsx("span",{style:{fontSize:13,color:y.faint,flex:"none"},children:"›"})]})}function kMe({row:e,copy:t,now:n,last:r,onRow:o}){return i.jsxs("div",{"data-schedule-row":e.scheduleId,onClick:()=>o(e),style:wMe(r),children:[i.jsx(Uk,{size:13,color:e.unread?y.run:y.faint}),i.jsx(jMe,{row:e,copy:t,now:n}),i.jsx(SMe,{row:e,copy:t})]})}function jMe({row:e,copy:t,now:n}){return i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:14,fontWeight:e.unread?600:400,color:e.unread?y.ink:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),i.jsx(yMe,{row:e,copy:t,now:n})]})}function CMe({rows:e,copy:t,now:n,onRow:r}){return i.jsx("div",{style:{background:y.card,border:`1px solid ${y.hairline}`,borderRadius:13,overflow:"hidden"},children:e.map((o,s)=>i.jsx(kMe,{row:o,copy:t,now:n,last:s===e.length-1,onRow:r},o.scheduleId))})}function TMe({rows:e,copy:t,now:n,onRow:r}){return i.jsxs(i.Fragment,{children:[i.jsx(bMe,{rows:e,copy:t}),i.jsx(CMe,{rows:e,copy:t,now:n,onRow:r})]})}function PMe(e,t,n){const r=e.schedule;if(!r)return null;const o=kk(r.nextRun,n),s=r.paused?` · ${t.paused}`:o?` · ${t.nextIn.replace("{d}",o)}`:"";return Kv(r)+s}function EMe({row:e,copy:t,now:n,onBack:r}){const o=PMe(e,t,n);return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"0 2px 10px"},children:[i.jsx("span",{"data-action":"sheet-back",onClick:r,style:{fontSize:15,color:y.run,flex:"none",cursor:"pointer",padding:"0 2px"},children:"‹"}),i.jsx(Uk,{size:14,color:y.run}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),o&&i.jsx("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:1},children:o})]})]})}function RMe(){return i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"64px 1fr 70px",gap:10,padding:"4px 15px 6px",font:`600 9.5px ${H}`,color:y.faint,letterSpacing:".05em"},children:[i.jsx("span",{children:"RUN"}),i.jsx("span",{children:"FIRED"}),i.jsx("span",{style:{textAlign:"right"},children:"COST"})]})}function MMe(e){return{display:"grid",gridTemplateColumns:"64px 1fr 70px",gap:10,padding:13,minHeight:44,boxSizing:"border-box",alignItems:"center",cursor:"pointer",borderTop:e?"none":`1px solid ${y.divider}`}}function IMe({run:e,ordinal:t}){return i.jsxs("span",{style:{font:`${e.unread?600:400} 12px ${H}`,color:e.unread?y.ink:"var(--proto-muted)",display:"flex",alignItems:"center",gap:6},children:["#",t,e.unread&&i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:y.run}})]})}function AMe({cost:e}){return i.jsx("span",{style:{font:`400 12px ${H}`,color:y.muted,textAlign:"right"},children:e!=null?yn(e):"—"})}function DMe({run:e,ordinal:t,first:n,now:r,onOpenRun:o}){return i.jsxs("div",{"data-run-row":e.sessionId,onClick:()=>o(e.sessionId),style:MMe(n),children:[i.jsx(IMe,{run:e,ordinal:t}),i.jsx("span",{style:{font:`400 12px ${H}`,color:"var(--proto-muted-2)"},children:jk(e,r)}),i.jsx(AMe,{cost:e.costUsd})]})}function LMe({row:e,now:t,onOpenRun:n}){const r=Ck(e.runs);return i.jsx("div",{style:{background:y.card,border:`1px solid ${y.hairline}`,borderRadius:13,overflow:"hidden",maxHeight:"46vh",overflowY:"auto"},children:e.runs.map((o,s)=>i.jsx(DMe,{run:o,ordinal:r.get(o.sessionId),first:s===0,now:t,onOpenRun:n},o.sessionId))})}function OMe({row:e,copy:t,onEdit:n}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 4px 0",gap:10},children:[i.jsx("span",{style:{fontSize:12,fontWeight:600,color:y.muted},children:t.allRuns.replace("{n}",String(e.runs.length))}),n&&i.jsx("button",{type:"button","data-action":"edit-schedule",onClick:n,style:{border:0,background:"transparent",color:y.run,fontSize:11.5,fontWeight:600,cursor:"pointer"},children:t.edit}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint},children:t.runListHint})]})}function NMe({row:e,copy:t,now:n,onBack:r,onOpenRun:o,onEdit:s}){return i.jsxs(i.Fragment,{children:[i.jsx(EMe,{row:e,copy:t,now:n,onBack:r}),i.jsx(RMe,{}),i.jsx(LMe,{row:e,now:n,onOpenRun:o}),i.jsx(OMe,{row:e,copy:t,onEdit:s})]})}function FMe(e){const[t,n]=f.useState({kind:"list"}),r=f.useCallback(()=>n(s=>s.kind==="editor"?(e.close(),s.returnTo):{kind:"list"}),[e.close]),o=f.useCallback((s,a)=>{e.openEdit(s),n({kind:"editor",returnTo:a})},[e.openEdit]);return{level:t,setLevel:n,back:r,openEditor:o}}function zMe(e,t,n){return f.useCallback(r=>{const o=SH(r);if(o.type==="modal"){t({kind:"runs",scheduleId:r.scheduleId});return}if(o.type==="open")return e(o.sessionId);n(o.schedule,{kind:"list"})},[e,n,t])}function BMe(e,t){return f.useCallback(()=>{e.submit().then(n=>{n&&t(r=>r.kind==="editor"?r.returnTo:{kind:"list"})})},[e.submit,t])}function $Me(e,t){return t.kind!=="runs"?null:e.find(n=>n.scheduleId===t.scheduleId)??null}function _Me({row:e,copy:t,now:n,back:r,onOpenSession:o,openEditor:s}){const a=e.schedule?()=>s(e.schedule,{kind:"runs",scheduleId:e.scheduleId}):void 0;return i.jsx(NMe,{row:e,copy:t,now:n,onBack:r,onOpenRun:o,onEdit:a})}function WMe(e,t,n,r){return e.kind!=="editor"||!t.form||!t.mode?null:i.jsx(mMe,{form:t.form,mode:t.mode,editableFields:t.editableFields,profileOptions:t.profileOptions,valid:t.valid,pending:t.pending,error:t.error,onChange:t.onChange,onSubmit:n,onBack:r})}function HMe({rows:e,copy:t,editor:n,level:r,runsRow:o,now:s,back:a,onOpenSession:l,onRow:c,openEditor:d,submit:u}){const p=WMe(r,n,u,a);return p||(o?i.jsx(_Me,{row:o,copy:t,now:s,back:a,onOpenSession:l,openEditor:d}):i.jsx(TMe,{rows:e,copy:t,now:s,onRow:c}))}function UMe(e){const{rows:t,editor:n,onOpenSession:r,onClose:o}=e,s=FMe(n),a=$Me(t,s.level),l=zMe(r,s.setLevel,s.openEditor),c=BMe(n,s.setLevel),d=f.useCallback(()=>{n.close(),o()},[n.close,o]),u=s.level.kind==="list"?void 0:s.back;return i.jsx(li,{onClose:d,onBack:u,children:i.jsx(HMe,{...e,level:s.level,runsRow:a,now:e.now??Date.now(),back:s.back,onRow:l,openEditor:s.openEditor,submit:c})})}function VMe(e){const t=O(),{toast:n}=Fn(),r=y$({onCreated:()=>n({title:t.scToastCreated,tone:"done"}),onUpdated:()=>n({title:t.scToastUpdated,tone:"done"}),onError:(o,s)=>n({title:o==="edit"?t.scToastUpdateFailed:t.scToastCreateFailed,description:s.message,tone:"failed"})});return i.jsx(UMe,{...e,editor:r})}const qMe={en:{title:"Sessions",today:"Today",yesterday:"Yesterday",earlier:"Earlier",empty:"No sessions yet"},zh:{title:"会话",today:"今天",yesterday:"昨天",earlier:"更早",empty:"暂无会话"}},KMe={en:{title:"Scheduled",countUnit:"{n}",once:"once",paused:"paused",nextIn:"next in {d}",allRuns:"all {n} runs",runListHint:"tap a run → opens that session",edit:"Edit schedule"},zh:{title:"Scheduled",countUnit:"{n} 个",once:"单次",paused:"已暂停",nextIn:"{d} 后运行",allRuns:"全部 {n} runs",runListHint:"点击任意 run → 打开该次会话",edit:"编辑调度"}};function GMe(){const e=he(),t=Xe(),n=ht(),r=dn(n,qMe),o=dn(n,KMe),{currentProjectId:s}=zt();Tk();const a=tl(s,"direct"),l=tl(s,"scheduled"),c=ae(e.schedules.list.queryOptions({projectId:s??void 0})),d=a.data??[],u=f.useMemo(()=>QRe(d),[d]),p=f.useMemo(()=>wH(c.data??[],l.data??[]),[c.data,l.data]),h=s?jh(s):void 0,[m,x]=f.useState(!1);return a.isLoading?i.jsx(At,{label:"1a 会话列表",children:i.jsx("div",{style:{padding:16,color:y.muted,fontSize:13},children:r.empty})}):i.jsxs(i.Fragment,{children:[i.jsx(tMe,{groups:u,sessions:d,scope:h,copy:r,scheduled:p.length>0?{unread:CH(p),onOpen:()=>x(!0)}:void 0,onOpen:v=>t(`/m/session/${v}`),onNew:()=>t("/m/session/new")}),m&&i.jsx(VMe,{rows:p,copy:o,onOpenSession:v=>{x(!1),t(`/m/session/${v}`,{replace:!0})},onClose:()=>x(!1)})]})}function YMe(e){return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`}function QMe(e,t){const n=new Date(e),r=a=>new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),o=Math.round((r(t)-r(n))/864e5),s=YMe(n);return o<=0?`今天 ${s}`:o===1?`昨天 ${s}`:`${n.getMonth()+1}月${n.getDate()}日 ${s}`}function XMe(e){return e==="completed"?"done":e==="running"?"running":"pending"}function ZMe(e){const t=Math.max(0,Math.round(e/6e4));if(t<60)return`${t}m`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}h`:`${n}h ${r}m`}function JMe(e){const t=e.steps.map((o,s)=>({label:o.stage??`Step ${o.stepIndex+1}`,state:XMe(o.status),lineDone:s>0&&e.steps[s-1].status==="completed"})),n=e.status==="running"&&e.currentStep?`${e.currentStep.name} ${e.currentStep.index+1}/${e.totalSteps}`:e.status,r=new Date(e.updatedAt).getTime()-new Date(e.createdAt).getTime();return{name:e.templateName,pillText:n,nodes:t,footer:{elapsed:ZMe(r),cost:yn(e.totalCostUsd),subCount:e.children.length}}}function eIe(e,t){return{names:e.slice(0,t.visibleCount).map(n=>n.kind),overflow:t.hiddenCount}}const nV={zh:{askPill:"Agent 提问",answeredPill:"✓ 已回答",defaultBadge:"默认",customOption:"自定义…(在底部输入)",confirm:"确认",queued:"待答",multiTag:"多选",ttlSuffix:"后按默认继续",planPendingPill:"计划待批",planApprovedPill:"✓ 计划已批准",planRejectedPill:"已驳回",approvedBy:"由你批准",readHint:"批准前建议通读全文",readLink:"阅读 ›",approve:"批准并执行",reject:"驳回并反馈",approveHint:"",viewFullPlan:"查看完整计划 ›",viewOriginalPlan:"查看原计划 ›",rewriteNote:""},en:{askPill:"Agent question",answeredPill:"✓ answered",defaultBadge:"default",customOption:"Custom… (type below)",confirm:"Confirm",queued:"queued",multiTag:"multi",ttlSuffix:"until defaults apply",planPendingPill:"Plan pending",planApprovedPill:"✓ Plan approved",planRejectedPill:"Rejected",approvedBy:"approved by you",readHint:"read the full plan before approving",readLink:"Read ›",approve:"Approve & run",reject:"Reject with note",approveHint:"",viewFullPlan:"View full plan ›",viewOriginalPlan:"View original plan ›",rewriteNote:""}};function Lf({bg:e,fg:t,text:n}){return i.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:999,background:e,color:t,flex:"none"},children:n})}function Fg(e,t,n){return{border:`1px solid ${e&&!t?y.runBorder:y.hairline}`,background:"var(--proto-card)",borderRadius:14,overflow:"hidden",boxShadow:e&&!t?"var(--focus-ring-accent)":void 0,...t?{opacity:.55}:n?{opacity:.9}:{}}}const tIe=i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 14 14",fill:"none",stroke:y.run,strokeWidth:"1.4",style:{flex:"none"},children:[i.jsx("path",{d:"M3 1.5h5.5L11.5 4.5V12.5H3z"}),i.jsx("path",{d:"M5 6.5h4M5 9h4"})]});function nIe({model:e,state:t,copy:n,onPick:r,onToggle:o,onConfirmMulti:s,onCustom:a}){const l=e.status==="pending",c=aa(e,t),d=e.questions.length,u=jS(e.ts,l),[p,h]=f.useState(!1),m=v=>v.answer??t.answers[v.question]??null,x=e.level?$B(e.level):null;return i.jsxs("div",{...e.level?{"data-ask-level":e.level}:{},style:Fg(l,!1,!1),onClick:l?void 0:()=>h(v=>!v),children:[i.jsx("div",{style:{padding:"12px 14px 0"},children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[l?i.jsx(Lf,{bg:x?x.bg:y.runBg,fg:x?x.fg:y.run,text:d>1?`${n.askPill} · ${Math.min(c+1,d)}/${d}`:n.askPill}):i.jsx(Lf,{bg:y.doneBg,fg:y.done,text:n.answeredPill}),i.jsx("span",{style:{font:`400 10px ${H}`,color:y.faint},children:e.shortId}),l&&u!=null?i.jsxs("span",{style:{marginLeft:"auto",font:`500 10px ${H}`,color:y.amberText},children:[wS(u)," ",n.ttlSuffix]}):e.timeLabel?i.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${H}`,color:y.faint},children:e.timeLabel}):null]})}),e.questions.map((v,S)=>{const b=m(v),g=l&&S===c,w=l&&S>c,k=S===d-1;return b!=null&&!g?i.jsxs("div",{style:{padding:`10px 14px ${k?"14px":"0"}`},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",borderRadius:11,padding:"9px 13px"},children:[i.jsx("span",{style:{width:16,height:16,borderRadius:"50%",background:y.done,color:"var(--ink-solid-fg)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,flex:"none"},children:"✓"}),i.jsxs("span",{style:{fontSize:12,color:y.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[v.question," → ",i.jsx("b",{style:{color:y.ink},children:b})]})]}),!l&&p&&v.options.length>0&&i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"8px 0 0"},children:v.options.map(C=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:`1px solid ${b.includes(C.label)?y.runBorder:"var(--proto-line-2)"}`,borderRadius:9,padding:"6px 11px"},children:[i.jsx("span",{style:{fontSize:11.5,color:b.includes(C.label)?y.ink:y.muted},children:C.label}),b.includes(C.label)&&i.jsx("span",{style:{marginLeft:"auto",fontSize:10,fontWeight:700,color:y.done},children:"✓"})]},C.label))})]},v.question):g?i.jsxs("div",{style:{padding:`12px 14px ${k?"14px":"0"}`},children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[i.jsxs("span",{style:{font:`600 10px ${H}`,color:y.run,flex:"none"},children:["Q",S+1]}),i.jsx("span",{style:{fontSize:14.5,fontWeight:600,color:y.ink,lineHeight:1.4},children:v.question}),v.multiSelect&&i.jsx("span",{style:{font:`500 9px ${H}`,color:y.muted,background:y.gray,padding:"1px 6px",borderRadius:5,flex:"none"},children:n.multiTag})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"10px 0 0"},children:[v.options.map((C,T)=>{const P=v.multiSelect&&t.selected.includes(C.label),R=!v.multiSelect&&T===0;return i.jsxs("button",{type:"button",onClick:()=>v.multiSelect?o(C.label):r(C.label),style:{minHeight:44,border:`1.5px solid ${P||R?y.run:"var(--proto-line-3)"}`,borderRadius:11,display:"flex",alignItems:"center",gap:8,padding:"8px 13px",boxSizing:"border-box",background:"var(--proto-card)",cursor:"pointer",textAlign:"left",width:"100%"},children:[v.multiSelect&&i.jsx("span",{style:{fontSize:12,fontWeight:700,color:P?y.run:y.faint,flex:"none"},children:P?"☑":"☐"}),i.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:y.ink,minWidth:0,flex:1,overflowWrap:"anywhere"},children:C.label}),R?i.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:y.runBg,color:y.run,flex:"none"},children:n.defaultBadge}):C.description?i.jsx("span",{style:{marginLeft:"auto",minWidth:0,maxWidth:"55%",font:`400 10px ${H}`,color:"var(--proto-muted-3)",flex:"0 1 auto",textAlign:"right",lineHeight:1.35,whiteSpace:"normal",overflowWrap:"anywhere"},children:C.description}):null]},C.label)}),i.jsx("button",{type:"button",onClick:a,style:{minHeight:44,border:"1.5px solid var(--proto-line-3)",borderRadius:11,display:"flex",alignItems:"center",padding:"8px 13px",boxSizing:"border-box",background:"var(--proto-card)",cursor:"pointer",textAlign:"left",width:"100%"},children:i.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:y.sub},children:n.customOption})}),v.multiSelect&&i.jsx("button",{type:"button",onClick:s,disabled:t.selected.length===0,style:{height:44,borderRadius:11,background:y.ink,color:"var(--ink-solid-fg)",border:"none",fontSize:14,fontWeight:600,cursor:"pointer",opacity:t.selected.length===0?.45:1,width:"100%"},children:n.confirm})]})]},v.question):w?i.jsx("div",{style:{padding:`12px 14px ${k?"14px":"0"}`},children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,border:"1px dashed var(--proto-line-3)",borderRadius:11,padding:"9px 13px",opacity:.6},children:[i.jsxs("span",{style:{font:`600 10px ${H}`,color:"var(--proto-muted-3)",flex:"none"},children:["Q",S+1]}),i.jsx("span",{style:{fontSize:12,color:y.grayInk,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v.question}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint,flex:"none"},children:n.queued})]})},v.question):null})]})}function rIe({model:e,copy:t,dimmed:n=!1,onApprove:r,onRejectStart:o,onOpenRead:s}){const a=e.status==="pending",l=e.status==="rejected",c=e.status==="approved",d=i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[c?i.jsx(Lf,{bg:y.doneBg,fg:y.done,text:t.planApprovedPill}):l?i.jsx(Lf,{bg:y.gray,fg:y.grayInk,text:t.planRejectedPill}):i.jsx(Lf,{bg:y.runBg,fg:y.run,text:t.planPendingPill}),i.jsx("span",{style:{font:`400 10px ${H}`,color:y.faint},children:"ExitPlanMode"}),e.timeLabel&&i.jsxs("span",{style:{marginLeft:"auto",font:`400 10px ${H}`,color:y.faint},children:[e.timeLabel,c?` ${t.approvedBy}`:""]})]}),u=i.jsx("div",{style:{fontSize:a&&!n?14.5:13.5,fontWeight:600,color:c?y.sub:l?y.grayInk:y.ink,lineHeight:1.4,marginTop:8,overflowWrap:"break-word",...l?{textDecoration:"line-through",textDecorationColor:"var(--proto-line)"}:{}},children:e.title});return a&&n?i.jsx("div",{style:Fg(!0,!0,!1),children:i.jsxs("div",{style:{padding:"11px 14px 12px"},children:[d,u,i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",borderRadius:11,padding:"9px 13px",marginTop:9},children:[i.jsx("span",{style:{font:`500 10.5px ${H}`,color:y.sub,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.filePath??""}),i.jsx("span",{role:"button",onClick:s,style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:y.run,flex:"none",cursor:"pointer"},children:t.viewFullPlan})]})]})}):a?i.jsxs("div",{style:Fg(!0,!1,!1),children:[i.jsxs("div",{style:{padding:"12px 14px 0"},children:[d,u]}),i.jsx("div",{style:{padding:"11px 14px 12px"},children:i.jsxs("div",{role:"button",onClick:s,style:{minHeight:52,border:"1px solid var(--proto-accent-bg)",background:"var(--proto-accent-bg)",borderRadius:11,display:"flex",alignItems:"center",gap:10,padding:"9px 13px",boxSizing:"border-box",cursor:"pointer"},children:[tIe,i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{font:`500 11px ${H}`,color:y.ink,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.filePath??`${e.lineCount} lines`}),i.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginTop:2},children:t.readHint})]}),i.jsx("span",{style:{fontSize:12,fontWeight:600,color:y.run,flex:"none"},children:t.readLink})]})}),i.jsxs("div",{style:{display:"flex",gap:8,padding:"0 14px 12px"},children:[i.jsx("button",{type:"button",onClick:o,style:{flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:y.ink,fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:t.reject}),i.jsx("button",{type:"button",onClick:r,style:{flex:1.3,height:44,borderRadius:11,background:y.ink,color:"var(--ink-solid-fg)",border:"none",fontSize:14,fontWeight:600,cursor:"pointer"},children:t.approve})]}),i.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"9px 14px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${H}`,color:"var(--proto-muted-3)"},children:i.jsx("span",{style:{marginLeft:"auto",color:y.faint},children:t.approveHint})})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:Fg(!1,!1,l),children:[i.jsxs("div",{style:{padding:"11px 14px 12px"},children:[d,u]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"9px 14px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${H}`,color:"var(--proto-muted-3)"},children:[e.filePath&&i.jsx("span",{style:{color:y.run,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.filePath}),l&&i.jsx("span",{children:t.rewriteNote}),i.jsx("span",{role:"button",onClick:s,style:{marginLeft:"auto",color:y.run,fontWeight:600,cursor:"pointer",flex:"none"},children:l?t.viewOriginalPlan:t.viewFullPlan})]})]}),l&&e.feedback&&i.jsx("div",{style:{alignSelf:"flex-end",maxWidth:"82%",background:y.ink,color:"var(--ink-solid-fg)",borderRadius:"16px 16px 4px 16px",padding:"9px 13px",fontSize:13.5,lineHeight:1.55,whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:e.feedback})]})}function oIe(e,t){return e==="approved"?{label:`✓ ${t.wbDecApproved}`,fg:y.done,bg:y.doneBg}:e==="explained"?{label:t.wbDecExplainRequested,fg:y.run,bg:y.runBg}:e==="revised"?{label:t.wbDecReviseProposed,fg:y.amberInk,bg:y.amberBg}:null}function iIe(e,t){return e==="approve"?t.wbDecApproved:e==="explain"?t.wbDecExplainRequested:t.wbDecReviseProposed}function sIe({L:e}){return i.jsx("span",{style:{font:`700 8px ${H}`,letterSpacing:".06em",color:y.run,background:y.runBg,border:`1px solid ${y.runBorder}`,borderRadius:4,padding:"2px 5px",flex:"none"},children:e.wbDecBadge})}function r2({label:e,text:t}){return i.jsxs("div",{style:{marginTop:13},children:[i.jsx("div",{style:{font:`600 10px ${H}`,letterSpacing:".05em",color:y.faint,paddingBottom:4},children:e}),i.jsx("div",{style:{fontSize:13,lineHeight:1.6,color:y.body},children:i.jsx(ci,{text:t})})]})}function aIe({open:e}){return i.jsx("span",{style:{width:12,height:12,flex:"none",display:"flex",alignItems:"center",justifyContent:"center",color:y.faint,transform:e?"rotate(90deg)":"none",transition:"transform .16s ease"},children:i.jsx("svg",{width:7,height:10,viewBox:"0 0 7 10",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M1.5 1 5.5 5l-4 4"})})})}function lIe({d:e,actions:t}){const n=O(),[r,o]=f.useState(!1),[s,a]=f.useState("view"),[l,c]=f.useState(""),d=HB(e),u=oIe(d,n),p=!!(t!=null&&t.busy),h=s==="view"?null:UB({explain:n.wbDecExplainTemplate,explainBare:n.wbDecExplainTemplateBare,revise:n.wbDecReviseTemplate},s,e.title,l),m=!p&&h!==null,x=()=>{o(!1),a("view"),c("")},v=()=>{p||t==null||t.respond(e.id,"approve")},S=()=>{!m||s==="view"||(t==null||t.respond(e.id,s,h),x())},b=(g,w)=>i.jsx("span",{role:"button",onClick:()=>a(s===g?"view":g),style:{flex:1,height:38,borderRadius:10,border:`1px solid ${s===g?y.run:y.cardBorder}`,background:s===g?y.runBg:"var(--proto-card)",color:s===g?y.run:y.ink,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600},children:w});return i.jsxs("div",{style:{border:`1px solid ${y.hairline}`,background:"var(--proto-card)",borderRadius:12,boxSizing:"border-box"},children:[i.jsxs("div",{role:"button","data-decision-toggle":e.id,onClick:()=>r?x():o(!0),style:{display:"flex",alignItems:"center",gap:8,padding:"9px 11px"},children:[i.jsx(sIe,{L:n}),i.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:y.ink,minWidth:0,flex:1,lineHeight:1.4,...r?{overflowWrap:"break-word"}:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},children:e.title}),u&&i.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:999,background:u.bg,color:u.fg,flex:"none",whiteSpace:"nowrap"},children:u.label}),i.jsx(aIe,{open:r})]}),r&&i.jsxs("div",{style:{borderTop:`1px solid ${y.hairline}`,padding:"2px 12px 12px"},children:[i.jsx(r2,{label:n.wbDecContext,text:e.context}),i.jsx(r2,{label:n.wbDecDecision,text:e.decision}),i.jsx(r2,{label:n.wbDecReasoning,text:e.reasoning}),e.actions.length>0&&i.jsxs("div",{style:{marginTop:14,border:`1px solid ${y.hairline}`,background:y.canvas,borderRadius:10,padding:"9px 12px"},children:[i.jsx("div",{style:{font:`600 10px ${H}`,letterSpacing:".05em",color:y.faint,paddingBottom:5},children:n.wbDecLog}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:e.actions.map((g,w)=>i.jsxs("div",{style:{display:"flex",gap:7,alignItems:"baseline",fontSize:12,lineHeight:1.5},children:[i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint,flex:"none"},children:o1(g.ts)??""}),i.jsx("span",{style:{fontWeight:600,color:g.action==="approve"?y.done:y.sub,flex:"none"},children:iIe(g.action,n)}),g.message&&i.jsx("span",{style:{color:y.muted,overflowWrap:"anywhere",minWidth:0},children:g.message})]},w))})]}),t&&i.jsxs("div",{style:{marginTop:13},children:[i.jsxs("div",{style:{display:"flex",gap:8},children:[d==="approved"?i.jsxs("span",{style:{flex:1,height:38,borderRadius:10,background:y.doneBg,color:y.done,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600},children:["✓ ",n.wbDecApproved]}):i.jsxs("span",{role:"button",onClick:v,style:{flex:1,height:38,borderRadius:10,background:p?y.faint:y.ink,color:y.inkSolidFg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600},children:["✓ ",n.wbDecApprove]}),b("explain",n.wbDecExplain),b("revise",n.wbDecRevise)]}),s!=="view"&&i.jsxs("div",{style:{display:"flex",gap:8,marginTop:9,alignItems:"flex-end"},children:[i.jsx("textarea",{autoFocus:!0,rows:2,value:l,onChange:g=>c(g.target.value),placeholder:s==="explain"?n.wbDecExplainPlaceholder:n.wbDecRevisePlaceholder,style:{flex:1,minWidth:0,resize:"none",border:`1px solid ${y.runBorder}`,borderRadius:10,padding:"8px 11px",fontSize:13,lineHeight:1.5,color:y.ink,background:"var(--proto-card)",outline:"none",fontFamily:"inherit",boxSizing:"border-box"}}),i.jsx("span",{role:"button",onClick:S,style:{height:38,borderRadius:10,padding:"0 16px",background:m?y.ink:y.faint,color:y.inkSolidFg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600,flex:"none"},children:n.wbDecSend})]})]})]})]})}function cIe({decisions:e,sessionId:t}){const n=VB(t??"");return i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,marginTop:8},children:e.map(r=>i.jsx(lIe,{d:r,actions:t?n:void 0},r.id))})}const dIe="repeating-linear-gradient(45deg,var(--proto-line) 0 6px,var(--proto-rail) 6px 12px)";function uIe({attachment:e}){const{openDoc:t}=Ac(),n={kind:"html",name:e.name,path:e.path,mimeType:e.mimeType};return i.jsxs("div",{style:{width:"100%",border:`1px solid ${y.hairline}`,background:"var(--proto-card)",borderRadius:12,overflow:"hidden",boxSizing:"border-box"},children:[i.jsxs("div",{role:"button",onClick:()=>t(n),style:{display:"flex",alignItems:"center",gap:7,padding:"7px 10px",borderBottom:`1px solid ${y.hairline}`,background:"var(--proto-rail)",cursor:"pointer"},children:[i.jsx("span",{style:{font:`700 7.5px ${H}`,letterSpacing:".06em",color:"var(--proto-accent)",background:"var(--proto-accent-bg)",border:"1px solid var(--proto-accent-border)",borderRadius:4,padding:"2px 5px",flex:"none"},children:"VIEW"}),i.jsx("span",{style:{font:`500 10.5px ${H}`,color:y.body,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.name}),i.jsx("span",{style:{font:`500 10.5px ${H}`,color:"var(--proto-accent)",flex:"none"},children:"↗"})]}),i.jsx(w1,{item:n,mode:"inline"})]})}function pIe({attachment:e,url:t,kind:n}){return i.jsxs(i.Fragment,{children:[t&&n==="image"&&i.jsx("img",{src:t,alt:e.name,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),t&&n==="video"&&i.jsx(gh,{src:t,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),n==="video"&&i.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:26,height:26,borderRadius:"50%",background:"var(--media-control-bg-dark)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:2,boxSizing:"border-box"},children:"▶"}),i.jsx("span",{style:{position:"absolute",left:7,bottom:6,maxWidth:(e.type==="video"?104:74)-14,font:`500 8px ${H}`,color:y.muted,background:"var(--media-label-bg)",padding:"1px 5px",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",boxSizing:"border-box"},children:e.name})]})}function fIe({attachment:e,kind:t}){const{openMedia:n}=mh(),r=bS(e.path,!0),o=e.type==="video"?104:74;return i.jsx("div",{role:"button",onClick:()=>n({kind:t,name:e.name,path:e.path}),style:{width:o,height:74,borderRadius:12,background:r?"var(--media-stage-bg)":dIe,position:"relative",overflow:"hidden",flex:"none",cursor:"pointer"},children:i.jsx(pIe,{attachment:e,url:r,kind:t})})}function hIe({attachment:e}){const{openDoc:t}=Ac(),n=yS(e),r=n?()=>t({kind:n,name:e.name,path:e.path,mimeType:e.mimeType}):()=>void O5(e.path,e.name);return i.jsxs("div",{role:"button",onClick:r,style:{display:"flex",alignItems:"center",gap:6,background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:9,padding:"6px 10px",flex:"none",cursor:"pointer"},children:[i.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:y.muted,strokeWidth:"1.5",children:[i.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),i.jsx("path",{d:"M8.5 1.5V4H11"})]}),i.jsx("span",{style:{font:`500 10.5px ${H}`,color:y.body},children:e.name})]})}function mIe({attachment:e}){const t=bc(e.type);return t?i.jsx(fIe,{attachment:e,kind:t}):i.jsx(hIe,{attachment:e})}function iR({attachments:e,side:t="right"}){const n=t==="left"?"flex-start":"flex-end",r=e.filter(s=>s.type==="view"),o=e.filter(s=>s.type!=="view");return i.jsxs("div",{style:{alignSelf:r.length>0?"stretch":n,display:"flex",flexDirection:"column",gap:6,alignItems:r.length>0?"stretch":n},children:[r.map((s,a)=>i.jsx(uIe,{attachment:s},`view-${a}`)),o.length>0&&i.jsx("div",{style:{alignSelf:n,display:"flex",gap:6,flexWrap:"wrap",justifyContent:n},children:o.map((s,a)=>i.jsx(mIe,{attachment:s},a))})]})}function gIe({attachment:e}){const{openMedia:t}=mh(),n=e.type?bc(e.type):null;return!e.previewUrl||!n?null:i.jsxs("span",{role:"button",onClick:()=>t({kind:n,name:e.name,url:e.previewUrl}),style:{position:"relative",width:26,height:26,borderRadius:6,overflow:"hidden",background:"var(--media-stage-bg)",flex:"none",cursor:"pointer"},children:[n==="image"?i.jsx("img",{src:e.previewUrl,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):i.jsx(gh,{src:e.previewUrl,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),n==="video"&&i.jsx("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ink-solid-fg)",fontSize:8,textShadow:"var(--media-glyph-shadow)"},children:"▶"})]})}function vIe({attachment:e,onRetry:t}){return e.status==="queued"?i.jsx("span",{style:{font:`500 9px ${H}`,color:y.muted},children:"queued"}):e.status==="uploading"?i.jsxs(i.Fragment,{children:[i.jsx("div",{style:{width:34,height:4,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:i.jsx("div",{style:{width:`${e.progress}%`,height:"100%",background:y.run}})}),i.jsxs("span",{style:{font:`400 9px ${H}`,color:y.run},children:[e.progress,"%"]})]}):e.status==="done"?i.jsx("span",{style:{fontSize:10,color:y.done,fontWeight:700},children:"✓"}):e.status==="error"?i.jsx("span",{role:"button",onClick:t,style:{font:`600 9px ${H}`,color:y.fail,cursor:"pointer"},children:"retry"}):null}function xIe({attachment:e,onRetry:t,onRemove:n}){const r=e.status==="uploading";return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:r?7:6,background:"var(--proto-card)",border:`1px solid ${r?y.runBorder:y.hairline}`,borderRadius:9,padding:"5px 9px",flex:"none"},children:[i.jsx(gIe,{attachment:e}),i.jsx("span",{style:{font:`500 10px ${H}`,color:y.body},children:e.name}),i.jsx(vIe,{attachment:e,onRetry:t}),i.jsx("span",{onClick:n,style:{color:y.faint,fontSize:11,cursor:"pointer"},children:"✕"})]})}function yIe({attachments:e,onRetry:t,onRemove:n}){return e.length===0?null:i.jsx("div",{style:{display:"flex",gap:6,padding:"0 2px 7px",overflowX:"auto"},children:e.map(r=>i.jsx(xIe,{attachment:r,onRetry:()=>t(r.id),onRemove:()=>n(r.id)},r.id))})}function bIe(e,t,n={}){return i1(e,t,{streaming:n.streaming,running:n.running,streamingText:n.streamingText,pendingUser:n.pendingUser,stripScheduledPrefix:n.stripScheduledPrefix,formatDivider:QMe,...n.now?{now:n.now}:{}})}const sR="—";function wIe(e,t,n,r,o){const s=t==null?sR:`${t} ${o.turnsUnit}`,a=e.phase==="background"?o.background:e.phase==="foreground"?o.foreground:o.idle,l=e.showMetrics?[a,n,s,...e.showCost?[r==null?sR:yn(r)]:[]].join(" · "):a;return{running:e.active,tone:e.active?"running":"idle",text:l}}function SIe(e,t,n,r){const o=r==="zh";if(e==="plan-approval")return{running:!1,tone:"waiting",text:o?"计划待批 · Agent 已暂停":"plan pending · agent paused"};const s=n>1?` ${Math.min(t+1,n)}/${n}`:"";return{running:!1,tone:"waiting",text:o?`等待你的回答${s} · Agent 已暂停`:`awaiting your answer${s} · agent paused`}}function kIe(e,t,n){var r;return e??n??((r=t[0])==null?void 0:r.name)??"—"}function jIe(e){return[e.model,e.thinking,e.backend].filter(Boolean).join(" · ")}function CIe(e,t){return e.map(n=>({name:n.name,sub:jIe(n),current:n.name===t}))}const Of=12,rV=16;function TIe(e){const t=e.overlayHeight-rV-e.groupHeight;return e.anchorTop==null||t<=Of?Of:Math.max(Of,Math.min(e.anchorTop-e.overlayTop,t))}function PIe(e){let t=null;const n=o=>o.getBoundingClientRect().top,r=()=>{t&&clearTimeout(t)};return{onTouchStart:o=>{const s=o.currentTarget;t=setTimeout(()=>e(n(s)),450)},onTouchEnd:r,onTouchMove:r,onContextMenu:o=>{o.preventDefault(),e(n(o.currentTarget))}}}function EIe({text:e,label:t,copiedLabel:n}){const{copiedKey:r,copy:o}=G0(),s=r===!0,a=()=>{o(e,!0)};return i.jsx("button",{type:"button","data-assistant-turn-copy":"true","aria-label":s?n:t,title:s?n:t,onClick:a,style:{width:28,height:26,padding:0,border:0,background:"transparent",color:s?"var(--proto-success)":y.muted,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:s?"✓":i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[i.jsx("rect",{x:"4.5",y:"4.5",width:"8",height:"8",rx:"1.5"}),i.jsx("path",{d:"M2.5 9.5V3.5a1 1 0 0 1 1-1h6"})]})})}function Ap({text:e,label:t,copiedLabel:n}){return e?i.jsx("div",{style:{height:26,marginTop:4,display:"flex",alignItems:"center"},children:i.jsx(EIe,{text:e,label:t,copiedLabel:n})}):null}function RIe({kind:e}){return i.jsx("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:y.muted,strokeWidth:"1.4",style:{marginLeft:"auto"},children:e==="copy"?i.jsxs(i.Fragment,{children:[i.jsx("rect",{x:"4.5",y:"4.5",width:"8",height:"8",rx:"1.5"}),i.jsx("path",{d:"M2.5 9.5V3.5a1 1 0 0 1 1-1h6"})]}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M2.5 11.5l.6-2.6 6.4-6.4a1.3 1.3 0 0 1 1.8 0l.2.2a1.3 1.3 0 0 1 0 1.8L5.1 10.9z"}),i.jsx("path",{d:"M8.6 3.4l2 2"})]})})}function aR({label:e,icon:t,onTap:n,onClose:r,disabled:o,divided:s}){const a=o?void 0:()=>{n==null||n(),r()};return i.jsxs("div",{role:"button",onClick:a,style:{display:"flex",alignItems:"center",height:46,padding:"0 15px",fontSize:14.5,color:y.ink,opacity:o?.35:1,cursor:o?"default":"pointer",borderTop:s?`1px solid ${y.divider}`:void 0},children:[e,i.jsx(RIe,{kind:t})]})}function MIe({isUser:e,text:t}){const n={flex:"0 1 auto",minHeight:0,overflow:"hidden",padding:"9px 13px",fontSize:13.5,boxShadow:"var(--shadow-context-menu)",whiteSpace:"pre-wrap",overflowWrap:"break-word"};return e?i.jsx("div",{style:{...n,maxWidth:"82%",background:y.ink,color:"var(--ink-solid-fg)",borderRadius:"16px 16px 4px 16px",lineHeight:1.55},children:t}):i.jsx("div",{style:{...n,maxWidth:"88%",background:"var(--proto-card)",color:y.body,borderRadius:14,lineHeight:1.6},children:t})}function IIe(e){const t=f.useRef(null),n=f.useRef(null),[r,o]=f.useState(null);return f.useLayoutEffect(()=>{const s=t.current,a=n.current;if(!s||!a)return;const l=s.getBoundingClientRect();o(TIe({anchorTop:e??null,overlayTop:l.top,overlayHeight:l.height,groupHeight:a.getBoundingClientRect().height}))},[e]),{overlayRef:t,groupRef:n,top:r}}function AIe({menu:e,copy:t}){return i.jsxs("div",{onClick:n=>n.stopPropagation(),style:{flex:"none",width:196,background:y.card,border:`1px solid ${y.cardBorder}`,borderRadius:13,boxShadow:"var(--shadow-menu-floating)",overflow:"hidden"},children:[i.jsx(aR,{label:t.menuCopy,icon:"copy",onTap:e.onCopy,onClose:e.onClose}),e.onEdit&&i.jsx(aR,{label:t.menuEdit,icon:"edit",onTap:e.onEdit,onClose:e.onClose,disabled:e.editDisabled,divided:!0})]})}function DIe({row:e,menu:t,copy:n,groupRef:r,top:o}){const s=e.kind==="user",a=e.kind==="user"||e.kind==="assistant"?e.text:"",l=o1(e.kind==="user"?e.ts:void 0),c={position:"absolute",left:14,right:14,top:o??Of,maxHeight:`calc(100% - ${Of+rV}px)`,visibility:o==null?"hidden":"visible",display:"flex",flexDirection:"column",alignItems:s?"flex-end":"flex-start",gap:9,WebkitUserSelect:"none",userSelect:"none",WebkitTouchCallout:"none"};return i.jsxs("div",{ref:r,"data-msg-menu-group":"true",style:c,children:[i.jsx(MIe,{isUser:s,text:a}),l&&i.jsx("div",{style:{flex:"none",font:`500 10.5px ${H}`,color:"var(--media-overlay-fg)",background:"var(--media-timestamp-bg)",padding:"3px 8px",borderRadius:6,letterSpacing:".02em"},children:l}),i.jsx(AIe,{menu:t,copy:n})]})}function LIe({row:e,menu:t,copy:n}){const{overlayRef:r,groupRef:o,top:s}=IIe(t.anchorTop);return i.jsx("div",{ref:r,onClick:t.onClose,style:{position:"absolute",inset:0,zIndex:8,background:"var(--overlay-scrim-interaction)",backdropFilter:"blur(1.5px)",WebkitBackdropFilter:"blur(1.5px)",overflow:"hidden"},children:i.jsx(DIe,{row:e,menu:t,copy:n,groupRef:o,top:s})})}function OIe({title:e,onCancel:t}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-alt)",border:"1px solid var(--proto-accent-border)",borderRadius:11,padding:"8px 8px 8px 12px",marginBottom:7},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:y.run,flex:"none"}}),i.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-accent-strong)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e}),i.jsx("div",{role:"button","aria-label":"Cancel edit",onClick:t,style:{marginLeft:"auto",width:26,height:26,borderRadius:8,background:"var(--proto-card)",border:"1px solid var(--proto-accent-border)",display:"flex",alignItems:"center",justifyContent:"center",color:y.run,fontSize:12,flex:"none",cursor:"pointer"},children:"×"})]})}function NIe(){return i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:y.ink,strokeWidth:"1.5",children:[i.jsx("rect",{x:"1.5",y:"4",width:"13",height:"9.5",rx:"2"}),i.jsx("circle",{cx:"8",cy:"8.7",r:"2.6"}),i.jsx("path",{d:"M5.5 4l1-1.7h3l1 1.7"})]})}function FIe(){return i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:y.ink,strokeWidth:"1.5",children:[i.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2.5"}),i.jsx("circle",{cx:"6",cy:"6",r:"1.3"}),i.jsx("path",{d:"M2.5 11.5 6 8.5l2.5 2 3-3 2 2"})]})}function zIe(){return i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:y.ink,strokeWidth:"1.4",children:[i.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),i.jsx("path",{d:"M8.5 1.5V4H11"})]})}function BIe(){return i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:y.ink,strokeWidth:"1.5",children:[i.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),i.jsx("path",{d:"M1.5 8h13M8 1.5c-1.8 1.8-2.7 4-2.7 6.5S6.2 13.2 8 14.5c1.8-1.3 2.7-4 2.7-6.5S9.8 3.3 8 1.5z"})]})}function $Ie(){return i.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:y.ink,strokeWidth:"1.6",children:i.jsx("path",{d:"M10.5 2.5 5.5 13.5"})})}function Qc(e){const t=e.onTap?()=>{var r;(r=e.onTap)==null||r.call(e),e.onClose()}:void 0,n=e.itemKey==="browser"||e.itemKey==="commission";return i.jsxs("div",{"data-plus-item":e.itemKey,"data-editable":n?e.onTap?"true":"false":void 0,onClick:t,style:{display:"flex",alignItems:"center",gap:9,padding:"11px 14px",borderBottom:e.last?void 0:"1px solid var(--proto-line-2)",cursor:e.onTap?"pointer":"default",opacity:e.onTap?1:.6},children:[e.icon,i.jsx("span",{style:{fontSize:13,color:y.ink},children:e.label}),e.value!=null&&i.jsx("span",{style:{marginLeft:"auto",font:`500 10px ${H}`,color:y.run},children:e.value})]})}function _Ie({copy:e,onClose:t,onCamera:n,onLibrary:r,onFile:o,browser:s,commission:a,onCommands:l}){return i.jsxs(i.Fragment,{children:[i.jsx("div",{onClick:t,style:{position:"absolute",inset:0,zIndex:5}}),i.jsxs("div",{style:{position:"absolute",left:14,bottom:90,width:208,background:"var(--panel-translucent-bg)",border:"1px solid var(--panel-translucent-border)",borderRadius:13,boxShadow:"var(--shadow-menu-strong)",overflow:"hidden",zIndex:6},children:[i.jsx(Qc,{label:e.attachCamera,onTap:n,onClose:t,icon:i.jsx(NIe,{})}),i.jsx(Qc,{label:e.attachLibrary,onTap:r,onClose:t,icon:i.jsx(FIe,{})}),i.jsx(Qc,{label:e.attachFile,onTap:o,onClose:t,icon:i.jsx(zIe,{})}),s&&i.jsx(Qc,{label:e.attachBrowser,onTap:s.onOpen,onClose:t,icon:i.jsx(BIe,{}),itemKey:"browser",value:s.device??void 0}),a&&i.jsx(Qc,{label:e.attachCommission,onTap:a.onOpen,onClose:t,icon:i.jsx(VIe,{}),itemKey:"commission",value:a.label??void 0}),i.jsx(Qc,{label:e.attachCommands,onTap:l,onClose:t,icon:i.jsx($Ie,{}),itemKey:"commands",last:!0})]})]})}function WIe({props:e}){return e.rejectBar?i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:y.amberCard,border:`1px solid ${y.amberBorder}`,borderRadius:11,padding:"8px 8px 8px 12px",marginBottom:7},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:y.amber,flex:"none"}}),i.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-amber-fg)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.rejectBar.title}),i.jsx("div",{role:"button","aria-label":"Cancel reject",onClick:e.rejectBar.onCancel,style:{marginLeft:"auto",width:26,height:26,borderRadius:8,background:"var(--proto-card)",border:`1px solid ${y.amberBorder}`,display:"flex",alignItems:"center",justifyContent:"center",color:y.amberText,fontSize:11,flex:"none",cursor:"pointer"},children:"✕"})]}),i.jsx("div",{style:{display:"flex",gap:6,padding:"0 2px 8px",overflowX:"auto"},children:e.rejectBar.chips.map(t=>i.jsx("span",{role:"button",onClick:()=>e.rejectBar.onChipTap(t),style:{flex:"none",fontSize:11,fontWeight:600,color:y.sub,border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:999,padding:"5px 11px",cursor:"pointer"},children:t},t))})]}):null}function HIe({props:e}){let t=i.jsx(yIe,{attachments:e.attachments,onRetry:e.onRetryAttachment,onRemove:e.onRemoveAttachment});return e.editing&&e.editCopy?t=i.jsx(OIe,{title:e.editCopy.editBarTitle,onCancel:e.editing.onCancel}):e.rejectBar&&(t=i.jsx(WIe,{props:e})),i.jsxs(i.Fragment,{children:[e.sessionId&&e.todos?i.jsx(oU,{sessionId:e.sessionId,todos:e.todos,lang:e.todoLang??"en"}):null,t]})}function UIe({label:e,onClick:t}){return i.jsxs("button",{type:"button",onClick:t,style:{display:"flex",alignItems:"center",gap:6,border:`1.5px solid ${y.runBorder}`,background:y.card,borderRadius:999,height:34,padding:"0 13px",boxSizing:"border-box",flex:"0 1 auto",minWidth:0,overflow:"hidden",cursor:"pointer"},children:[i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:y.run,flex:"none"}}),i.jsx("span",{style:{minWidth:0,font:`600 11.5px ${H}`,color:y.run,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e})]})}function VIe(){return i.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:y.muted,strokeWidth:"1.4",strokeLinejoin:"round",strokeLinecap:"round",style:{flex:"none"},children:[i.jsx("path",{d:"M4.2 2.2v11.6"}),i.jsx("path",{d:"M4.2 3.1h7.8L10.4 5.7l1.6 2.6H4.2z"})]})}function qIe({value:e,text:t,label:n,onClick:r}){return i.jsxs("button",{type:"button","data-chip":"commission","data-commission-value":e,"data-editable":r?"true":"false","aria-label":`${n} · ${t}`,onClick:r,style:{display:"flex",alignItems:"center",gap:5,flex:"0 1 auto",minWidth:0,maxWidth:150,height:34,padding:"0 11px",boxSizing:"border-box",borderRadius:999,border:`1.5px solid ${y.runBorder}`,background:y.runBg,color:y.run,font:`500 11px ${H}`,overflow:"hidden",cursor:r?"pointer":"default"},children:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round",strokeLinecap:"round",style:{flex:"none"},children:[i.jsx("path",{d:"M4.2 2.2v11.6"}),i.jsx("path",{d:"M4.2 3.1h7.8L10.4 5.7l1.6 2.6H4.2z"})]}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]})}function KIe({device:e,label:t,onClick:n}){return i.jsxs("button",{type:"button","data-chip":"browser","data-browser-device":e,"data-editable":n?"true":"false","aria-label":`${t} · ${e}`,onClick:n,style:{display:"flex",alignItems:"center",gap:5,flex:"0 1 auto",minWidth:0,maxWidth:132,height:34,padding:"0 11px",boxSizing:"border-box",borderRadius:999,border:`1.5px solid ${y.runBorder}`,background:y.runBg,color:y.run,font:`500 11px ${H}`,overflow:"hidden",cursor:n?"pointer":"default"},children:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",style:{flex:"none"},children:[i.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),i.jsx("path",{d:"M1.5 8h13M8 1.5c-1.8 1.8-2.7 4-2.7 6.5S6.2 13.2 8 14.5c1.8-1.3 2.7-4 2.7-6.5S9.8 3.3 8 1.5z"})]}),i.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})]})}function GIe({onClick:e}){return i.jsx("button",{type:"button","aria-label":"Attach",onClick:e,style:{flex:"none",width:34,height:34,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",background:y.card,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",color:y.sub,lineHeight:0,cursor:"pointer",padding:0},children:i.jsx(gc,{size:15})})}function YIe({props:e}){return e.editing||e.rejectBar?null:i.jsxs(i.Fragment,{children:[i.jsx(UIe,{label:e.profileChipLabel,onClick:e.onOpenProfile}),e.contextUsageSupported||e.contextUsage!=null?i.jsx("span",{"data-context-usage-position":"composer-toolbar",style:{display:"inline-flex",flex:"none"},children:i.jsx(wU,{usage:e.contextUsage??null,variant:"mobile",lang:e.contextUsageLang??"en",onClick:e.onContextUsageOpen,"data-context-compact-enabled":e.contextCompactAction?"true":void 0})}):null]})}function QIe({suggestions:e,onPick:t}){return i.jsx("div",{"data-mobile-slash-menu":!0,style:{margin:"0 0 7px",border:`1px solid ${y.hairline}`,borderRadius:12,background:y.card,overflow:"hidden",boxShadow:"var(--shadow-menu-soft)"},children:e.map(n=>i.jsxs("div",{"data-mobile-slash-command":n.command,onClick:()=>{n.disabled||t(n)},style:{display:"flex",alignItems:"center",gap:10,minHeight:38,padding:"0 12px",borderBottom:`1px solid ${y.divider}`,opacity:n.disabled?.45:1,cursor:n.disabled?"default":"pointer"},children:[i.jsx("span",{style:{font:`600 11.5px ${H}`,color:y.run},children:n.command}),i.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:10.5,color:y.muted},children:n.description})]},n.command))})}function XIe({copy:e,onClose:t,onSessionId:n}){const r=[{label:e.menuSessionId,onTap:n}];return i.jsxs(i.Fragment,{children:[i.jsx("div",{onClick:t,style:{position:"absolute",inset:0,zIndex:5}}),i.jsx("div",{style:{position:"absolute",top:"calc(52px + env(safe-area-inset-top))",right:14,width:148,background:"var(--panel-translucent-bg)",border:"1px solid var(--panel-translucent-border)",borderRadius:13,boxShadow:"var(--shadow-menu-strong)",overflow:"hidden",zIndex:6},children:r.map((o,s)=>i.jsx("div",{onClick:o.onTap,style:{padding:"11px 14px",fontSize:13,color:y.ink,borderBottom:s<r.length-1?"1px solid var(--proto-line-2)":void 0,cursor:"pointer"},children:o.label},o.label))})]})}function ZIe({row:e,copy:t,copied:n,onCopy:r}){return i.jsxs("div",{children:[i.jsx("div",{style:{font:`600 9.5px ${H}`,letterSpacing:".05em",color:y.muted,padding:"0 2px 5px"},children:e.label}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:11,padding:"10px 12px"},children:[i.jsx("span",{style:{flex:1,font:`500 12px ${H}`,color:y.ink,wordBreak:"break-all",userSelect:"all"},children:e.value}),i.jsx("span",{role:"button",onClick:r,style:{flex:"none",font:`600 9.5px ${H}`,color:n?y.run:y.muted,border:`1px solid ${n?y.runBorder:"var(--proto-line-3)"}`,borderRadius:7,padding:"4px 9px",cursor:e.value==="—"?"default":"pointer",opacity:e.value==="—"?.4:1},children:n?t.copied:t.copy})]})]})}function JIe({copy:e,cortexId:t,backendUuid:n,onClose:r}){const o=zH({cortexId:t,backendUuid:n,cortexIdLabel:e.cortexIdLabel,backendUuidLabel:e.backendUuidLabel}),{copiedKey:s,copy:a}=G0(),l=(c,d)=>{d!=="—"&&a(d,c)};return i.jsxs(li,{onClose:r,children:[i.jsx("div",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em",padding:"0 2px 12px"},children:e.sessionIdTitle}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:11},children:o.map(c=>i.jsx(ZIe,{row:c,copy:e,copied:s===c.key,onCopy:()=>l(c.key,c.value)},c.key))})]})}function eAe({usage:e,lang:t,compactAction:n,onClose:r}){return i.jsx(li,{onClose:r,children:i.jsxs("div",{"data-mobile-context-usage-sheet":"true",children:[i.jsx("div",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em",padding:"0 2px 10px"},children:bU(t)}),i.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:13,padding:"12px 13px"},children:i.jsx(kU,{usage:e,lang:t})}),n?i.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 2px 0"},children:i.jsx(SU,{action:n,lang:t})}):null]})})}function tAe({item:e,last:t,copy:n,onPick:r}){return i.jsxs("div",{onClick:()=>r(e.name),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:t?void 0:"1px solid var(--proto-line-soft)",cursor:"pointer"},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[i.jsx("span",{style:{font:`600 13px ${H}`,color:y.ink},children:e.name}),e.current&&i.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:y.runBg,color:y.run},children:n.profileCurrent})]}),i.jsx("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:3},children:e.sub})]}),e.current&&i.jsx("span",{style:{fontSize:15,fontWeight:700,color:y.run,flex:"none"},children:"✓"})]})}function nAe({items:e,copy:t,onClose:n,onPick:r}){return i.jsxs(li,{onClose:n,children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 10px"},children:[i.jsx("span",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em"},children:t.profileTitle}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint},children:t.profileSubtitle})]}),i.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:13,overflow:"hidden"},children:e.map((o,s)=>i.jsx(tAe,{item:o,last:s===e.length-1,copy:t,onPick:r},o.name))}),i.jsx("div",{style:{font:`400 9.5px ${H}`,color:y.faint,padding:"9px 4px 0"},children:t.profileFooter})]})}function rAe({item:e,attr:t,last:n,current:r,onPick:o}){return i.jsxs("div",{[t]:e.value??"__off__",onClick:()=>o(e.value),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:n?void 0:"1px solid var(--proto-line-soft)",cursor:"pointer"},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("span",{style:{font:`600 13px ${H}`,color:y.ink},children:e.label}),e.sub&&i.jsx("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:3},children:e.sub})]}),e.value===r&&i.jsx("span",{style:{fontSize:15,fontWeight:700,color:y.run,flex:"none"},children:"✓"})]})}function oV({items:e,attr:t,title:n,current:r,onClose:o,onPick:s}){return i.jsxs(li,{onClose:o,children:[i.jsx("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 10px"},children:i.jsx("span",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em"},children:n})}),i.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:13,overflow:"hidden"},children:e.map((a,l)=>i.jsx(rAe,{item:a,attr:t,last:l===e.length-1,current:r,onPick:s},a.value??"__off__"))})]})}function oAe({items:e,title:t,current:n,onClose:r,onPick:o}){return i.jsx(oV,{items:e.map(s=>({value:s.device,label:s.label,sub:s.sub})),attr:"data-device",title:t,current:n,onClose:r,onPick:o})}function iAe({items:e,title:t,current:n,onClose:r,onPick:o}){return i.jsx(oV,{items:e,attr:"data-commission-option",title:t,current:n,onClose:r,onPick:o})}function sAe(e){return i.jsx(cr,{onBack:e.onBack,trailing:i.jsx(qO,{onClick:e.onMore}),children:i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:15,fontWeight:650,color:y.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),i.jsx(aAe,{...e})]})})}function aAe({status:e}){return i.jsx("div",{"data-chat-status-line":"true",style:{display:"flex",alignItems:"center",gap:8,font:`400 10px ${H}`,color:e.tone==="waiting"?y.amberText:y.muted,marginTop:1},children:i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,minWidth:0},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:e.tone==="waiting"?y.amber:e.running?y.run:"var(--proto-line-3)",animation:e.running?"cxpulse 1.6s ease-in-out infinite":void 0,flex:"none"}}),i.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text})]})})}const Iw=6,lAe={font:`400 10px ${H}`,background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",padding:"1px 6px",borderRadius:4,flex:"none"},iV={display:"flex",alignItems:"center",gap:Iw,flex:1,minWidth:0,overflow:"hidden",position:"relative"},cAe={...iV,position:"absolute",visibility:"hidden",pointerEvents:"none",width:"max-content",overflow:"visible"};function lR({name:e}){return i.jsx("span",{style:lAe,children:e})}function dAe({count:e,calls:t,unit:n,onExpand:r}){const o=t.map(d=>d.kind),{containerRef:s,measureRef:a,layout:l}=ez(o,Iw),c=eIe(t,l);return i.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:Iw,fontSize:11,color:"var(--proto-muted-3)",flexWrap:"nowrap",whiteSpace:"nowrap",overflow:"hidden",cursor:"pointer"},children:[i.jsx("span",{style:{fontSize:8.5,flex:"none"},children:"▸"}),i.jsxs("span",{style:{flex:"none"},children:[e," ",n]}),i.jsxs("span",{ref:s,style:iV,children:[c.names.map((d,u)=>i.jsx(lR,{name:d},u)),c.overflow>0?i.jsxs("span",{style:{flex:"none"},children:["+",c.overflow]}):null,i.jsxs("span",{ref:a,"aria-hidden":"true",style:cAe,children:[o.map((d,u)=>i.jsx(lR,{name:d},u)),i.jsxs("span",{style:{flex:"none"},children:["+",t.length]})]})]})]})}function uAe({count:e,calls:t,unit:n,onCollapse:r}){return i.jsxs("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,overflow:"hidden"},children:[i.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--proto-muted-3)",padding:"6px 11px",cursor:"pointer"},children:[i.jsx("span",{style:{fontSize:8.5},children:"▾"}),i.jsxs("span",{children:[e," ",n]})]}),t.map((o,s)=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5.5px 11px",borderTop:"1px solid var(--proto-line-soft)"},children:[i.jsx("span",{style:{font:`600 9px ${H}`,color:"var(--proto-muted)",background:"var(--proto-gray)",padding:"1.5px 7px",borderRadius:5,flex:"none"},children:o.kind}),i.jsx("span",{style:{font:`400 10.5px ${H}`,color:y.body,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:o.input})]},s))]})}function cR({rows:e,unit:t}){const n=e.flatMap(o=>o.kind==="tools"?o.calls:[]),r=e.flatMap(o=>o.kind==="assistant"&&o.text?[o.text]:[]);return i.jsxs(i.Fragment,{children:[n.length>0&&i.jsx(sV,{count:n.length,calls:n,unit:t}),r.map((o,s)=>i.jsx("div",{style:{fontSize:12.5,lineHeight:1.6,color:y.body,overflowWrap:"break-word",wordBreak:"break-word"},children:i.jsx(ci,{text:o})},s))]})}function pAe({row:e,unit:t,sessionId:n}){return e.detailMode!=="lazy"||!e.hasDetails||!n?i.jsx(cR,{rows:e.children,unit:t}):i.jsx(uz,{sessionId:n,subagentId:e.id,fallbackRows:e.children,render:r=>i.jsx(cR,{rows:r,unit:t})})}function fAe({row:e,unit:t,sessionId:n}){const r=O(),[o,s]=f.useState(!1),a=e.description||e.agentType||r.subagentFallbackLabel;return i.jsxs("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8},children:[i.jsxs("div",{onClick:()=>s(!o),role:"button","aria-expanded":o,style:{position:"sticky",top:0,zIndex:1,display:"flex",alignItems:"center",gap:7,padding:"6px 11px",fontSize:11.5,color:y.faint,background:"var(--proto-rail)",minWidth:0},children:[i.jsx(Mi,{color:e.status==="running"?"var(--proto-accent)":"var(--proto-success)",pulse:e.status==="running"}),i.jsx("span",{style:{font:`600 9px ${H}`,color:"var(--proto-muted)",background:"var(--proto-gray)",padding:"1.5px 7px",borderRadius:5,flex:"none"},children:e.agentType||r.subagentFallbackLabel}),e.model?i.jsx("span",{style:{font:`600 9px ${H}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line-2)",padding:"1.5px 7px",borderRadius:5,flex:"none"},children:rz(e.model)}):null,i.jsx("span",{style:{font:`400 11px ${H}`,color:y.body,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:a}),i.jsx("span",{style:{font:`400 10px ${H}`,flex:"none",marginLeft:"auto"},children:`${e.toolCount} ${t}`})]}),o&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"8px 11px 10px",borderTop:"1px solid var(--proto-line-soft)"},children:[e.prompt?i.jsxs("div",{children:[i.jsx("div",{style:{font:`600 9px ${H}`,color:y.faint,marginBottom:5,textTransform:"uppercase",letterSpacing:".05em"},children:r.subagentPromptLabel}),i.jsx("pre",{style:{margin:0,font:`400 10.5px/1.55 ${H}`,color:y.body,whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},children:e.prompt})]}):null,i.jsx(pAe,{row:e,unit:t,sessionId:n})]})]})}function sV({count:e,calls:t,unit:n}){const[r,o]=f.useState(!1);return r?i.jsx(uAe,{count:e,calls:t,unit:n,onCollapse:()=>o(!1)}):i.jsx(dAe,{count:e,calls:t,unit:n,onExpand:()=>o(!0)})}const o2=()=>{};function hAe({text:e,preview:t,streamKey:n}){const r=ZB(e,!!t,n);return r.trim()?i.jsx(ci,{text:r,dropTrailingHr:!0,renderMath:!0}):null}function mAe({row:e,interactions:t}){const n=BB(e),r=(t==null?void 0:t.copy)??nV.zh;if(n.kind==="ask"){const a=n.model;return i.jsx(nIe,{model:a,state:(t==null?void 0:t.askState(a.requestId))??FB,copy:r,onPick:l=>t==null?void 0:t.onAskPick(a,l),onToggle:l=>t==null?void 0:t.onAskToggle(a,l),onConfirmMulti:()=>t==null?void 0:t.onAskConfirmMulti(a),onCustom:()=>t==null?void 0:t.onAskCustom(a)})}if(n.kind==="plan"){const a=n.model;return i.jsx(rIe,{model:a,copy:r,dimmed:(t==null?void 0:t.rejectingId)===a.requestId,onApprove:t?()=>t.onApprove(a):o2,onRejectStart:t?()=>t.onRejectStart(a):o2,onOpenRead:t?()=>t.onOpenRead(a):o2})}const o=n.tone==="rejected"?"var(--proto-danger)":n.tone==="inactive"?"var(--proto-muted-3)":y.done,s=n.tone==="rejected"?"✗":n.tone==="inactive"?"◌":"✓";return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 11px",background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",borderRadius:10,opacity:n.tone==="inactive"?.6:.75},children:[i.jsxs("span",{style:{fontSize:10,fontWeight:700,color:o,flexShrink:0},children:[s," ",n.label]}),i.jsx("span",{style:{fontSize:11.5,color:y.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.text})]})}function gAe({rows:e,toolCallsUnit:t,copyLabel:n,copiedLabel:r,interactions:o,editCopy:s,editing:a,onLongPress:l,onShowOriginal:c,streamKey:d}){const u=s?lz(e):null,p=cz(e),h=(a==null?void 0:a.rowIndex)??null;return i.jsx(i.Fragment,{children:e.map((m,x)=>{const v=h!=null&&x>h,S=h===x,b=!!s&&!!l&&h==null&&m.kind==="user",g=b?PIe(w=>l(x,w)):null;return i.jsxs(f.Fragment,{children:[m.kind==="divider"&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,...v?{opacity:.35}:{}},children:[i.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}}),i.jsx("div",{style:{fontSize:9.5,fontWeight:600,letterSpacing:".06em",color:y.faint},children:m.text}),i.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]}),m.kind==="user"&&i.jsxs(i.Fragment,{children:[m.attachments&&m.attachments.length>0&&i.jsx(iR,{attachments:m.attachments}),i.jsxs("div",{style:{alignSelf:"flex-end",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:5,maxWidth:"82%",...v?{opacity:.35,pointerEvents:"none"}:{}},children:[S&&s&&i.jsx("span",{style:{font:`600 9.5px ${H}`,color:y.run,background:"var(--proto-accent-bg)",padding:"2px 7px",borderRadius:4},children:s.editingBadge}),i.jsx("div",{...g??{},"data-msg-bubble":b?x:void 0,style:{background:y.ink,color:m.pending?y.inkSolidFgDim:y.inkSolidFg,borderRadius:"16px 16px 4px 16px",padding:"9px 13px",fontSize:13.5,lineHeight:1.55,whiteSpace:"pre-wrap",overflowWrap:"break-word",wordBreak:"break-word",WebkitUserSelect:b?"none":void 0,userSelect:b?"none":void 0,WebkitTouchCallout:b?"none":void 0,...S?{boxShadow:`0 0 0 2px ${y.canvas}, 0 0 0 3.5px ${y.run}`}:{}},children:m.text}),s&&m.edited&&!S&&i.jsx("span",{role:"button",onClick:c?()=>c(m.edited):void 0,style:{font:`400 9.5px ${H}`,color:y.faint,cursor:"pointer"},children:i.jsx("span",{style:{borderBottom:`1px dotted ${y.faint}`},children:s.edited})})]}),S&&s&&a&&i.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:i.jsx("span",{style:{font:`600 9px ${H}`,color:"var(--m-amber-ink)",background:y.amberBg,padding:"2px 7px",borderRadius:4},children:s.willRewind(a.replies,a.toolCalls)})})]}),m.kind==="subagent"&&i.jsxs("div",{style:v?{opacity:.35,pointerEvents:"none"}:void 0,children:[i.jsx(fAe,{row:m,unit:t,sessionId:d}),i.jsx(Ap,{text:p.get(x),label:n,copiedLabel:r})]}),m.kind==="tools"&&i.jsxs("div",{style:v?{opacity:.35,pointerEvents:"none"}:void 0,children:[i.jsx(sV,{count:m.count,calls:m.calls,unit:t}),i.jsx(Ap,{text:p.get(x),label:n,copiedLabel:r})]}),m.kind==="notice"&&i.jsxs("div",{style:v?{opacity:.35,pointerEvents:"none"}:void 0,children:[i.jsx(WB,{level:m.level,text:m.text,authAction:m.authAction,noticeAction:m.noticeAction,onNoticeAction:o==null?void 0:o.onCancelResume,noticeActionDone:o==null?void 0:o.resumeCancelled}),i.jsx(Ap,{text:p.get(x),label:n,copiedLabel:r})]}),m.kind==="assistant"&&i.jsxs("div",{...g??{},style:{fontSize:13.5,lineHeight:1.65,color:y.body,minWidth:0,overflowWrap:"break-word",wordBreak:"break-word",...v?{opacity:.35,pointerEvents:"none"}:{},WebkitUserSelect:b?"none":void 0,userSelect:b?"none":void 0,WebkitTouchCallout:b?"none":void 0},children:[s&&(u==null?void 0:u.has(x))&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,font:`400 9.5px ${H}`,color:y.faint,marginBottom:4},children:[i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--proto-line-3)",flex:"none"}}),s.regenNote]}),i.jsx(hAe,{text:m.text,preview:m.preview,streamKey:d}),m.attachments&&m.attachments.length>0&&i.jsx("div",{style:{marginTop:8},children:i.jsx(iR,{attachments:m.attachments,side:"left"})}),m.decisions&&m.decisions.length>0&&i.jsx(cIe,{decisions:m.decisions,sessionId:d}),i.jsx(Ap,{text:p.get(x),label:n,copiedLabel:r})]}),m.kind==="interaction"&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",...v?{opacity:.35,pointerEvents:"none"}:{}},children:[i.jsx(mAe,{row:m,interactions:o}),i.jsx(Ap,{text:p.get(x),label:n,copiedLabel:r})]})]},m.kind==="interaction"&&m.detail?`int-${m.detail.id}`:x)})})}function vAe({text:e}){return i.jsxs("div",{style:{alignSelf:"center",display:"flex",alignItems:"center",gap:6,font:`400 9.5px ${H}`,color:y.faint,background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",padding:"3px 10px",borderRadius:999},children:[i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:y.run}}),e]})}function xAe(e){var d,u;const{copy:t}=e,n=f.useRef(null),r=f.useRef(null),o=f.useRef(!0),s=f.useRef(0),a=()=>{const p=n.current;p&&(o.current=p.scrollHeight-p.scrollTop-p.clientHeight<40)},l=()=>{s.current=Date.now()+800};f.useEffect(()=>{const p=n.current;p&&o.current&&Date.now()>=s.current&&(p.scrollTop=p.scrollHeight)},[e.rows,e.systemLines]),f.useEffect(()=>{const p=n.current,h=r.current;if(!p||!h||typeof ResizeObserver>"u")return;const m=new ResizeObserver(()=>{o.current&&Date.now()>=s.current&&(p.scrollTop=p.scrollHeight)});return m.observe(h),()=>m.disconnect()},[]);const c=!e.editing&&!e.rejectBar&&((d=e.slashSuggestions)!=null&&d.length)&&e.onSlashPick?i.jsx(QIe,{suggestions:e.slashSuggestions,onPick:e.onSlashPick}):void 0;return i.jsxs("div",{"data-screen-label":"1b 会话详情",style:{height:"100%",position:"relative",display:"flex",flexDirection:"column",boxSizing:"border-box",background:y.canvas},children:[i.jsx(sAe,{title:e.title,status:e.status,onBack:e.onBack,onMore:e.onMoreToggle}),i.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[i.jsx("div",{ref:n,onScroll:a,onClick:l,style:{flex:1,minHeight:0,overflow:"auto",isolation:"isolate",background:y.canvas},children:i.jsxs("div",{ref:r,style:{padding:"14px 14px 0",display:"flex",flexDirection:"column",gap:12},children:[i.jsx(gAe,{rows:e.rows,toolCallsUnit:t.toolCallsUnit,copyLabel:t.copy,copiedLabel:t.copied,interactions:e.interactions,editCopy:e.editCopy,editing:e.editing,onLongPress:e.onLongPress,onShowOriginal:e.onShowOriginal,streamKey:e.streamKey}),e.inlineThreadCard,(u=e.systemLines)==null?void 0:u.map((p,h)=>i.jsx(vAe,{text:p},h)),i.jsx("div",{style:{height:"calc(8px + env(safe-area-inset-bottom))",flex:"none"}})]})}),i.jsx(moe,{placeholder:e.composerPlaceholder??(e.attachments.length>0?t.attachPlaceholder:t.composerPh),value:e.composerValue,onChange:e.onComposerChange,onSend:e.onSend,sendEnabled:e.sendEnabled,running:e.status.running,onStop:e.onStop,stopEnabled:e.stopEnabled,leading:e.editing||e.rejectBar?void 0:i.jsxs(i.Fragment,{children:[i.jsx(GIe,{onClick:e.onPlus}),e.browserDevice&&i.jsx(KIe,{device:e.browserDevice,label:t.attachBrowser,onClick:e.onOpenBrowser}),e.commissionValue&&i.jsx(qIe,{value:e.commissionValue,text:e.commissionLabel||t.attachCommission,label:t.attachCommission,onClick:e.onOpenCommission})]}),tools:i.jsx(YIe,{props:e}),above:i.jsx(HIe,{props:e}),commandMenu:c,onPlus:e.onPlus,lineUnit:t.lineUnit,charUnit:t.charUnit,tone:e.editing?"accent":e.rejectBar?"amber":"default"}),e.msgMenu&&e.editCopy&&e.rows[e.msgMenu.rowIndex]&&i.jsx(LIe,{row:e.rows[e.msgMenu.rowIndex],menu:e.msgMenu,copy:e.editCopy})]}),e.moreOpen&&i.jsx(XIe,{copy:t,onClose:e.onMoreClose,onSessionId:()=>{e.onMoreClose(),e.onSessionIdOpen()}}),e.sessionIdOpen&&i.jsx(JIe,{copy:t,cortexId:e.cortexId,backendUuid:e.backendUuid,onClose:e.onSessionIdClose}),e.originalSheet&&e.editCopy&&i.jsxs(li,{onClose:e.originalSheet.onClose,children:[i.jsx("div",{style:{font:`600 10px ${H}`,color:y.muted,letterSpacing:".05em",padding:"0 2px 8px"},children:e.editCopy.original}),i.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:13,padding:"11px 13px",fontSize:13,lineHeight:1.6,color:y.body,whiteSpace:"pre-wrap",overflowWrap:"break-word",maxHeight:"50vh",overflow:"auto"},children:e.originalSheet.text})]}),e.attachMenuOpen&&i.jsx(_Ie,{copy:t,onClose:e.onAttachClose,onCamera:e.onCamera,onLibrary:e.onLibrary,onFile:e.onFile,browser:e.onOpenBrowser||e.browserDevice?{device:e.browserDevice??null,onOpen:e.onOpenBrowser}:void 0,commission:e.onOpenCommission||e.commissionValue?{label:e.commissionLabel??e.commissionValue??null,onOpen:e.onOpenCommission}:void 0,onCommands:()=>e.onComposerChange("/")}),e.browserSheet&&i.jsx(oAe,{items:e.browserSheet.items,title:e.browserSheet.title,current:e.browserDevice??null,onClose:e.browserSheet.onClose,onPick:e.browserSheet.onPick}),e.commissionSheet&&i.jsx(iAe,{items:e.commissionSheet.items,title:e.commissionSheet.title,current:e.commissionValue??null,onClose:e.commissionSheet.onClose,onPick:e.commissionSheet.onPick}),e.profileSheet&&i.jsx(nAe,{items:e.profileSheet.items,copy:t,onClose:e.profileSheet.onClose,onPick:e.profileSheet.onPick}),e.contextUsageOpen&&(e.contextUsageSupported||e.contextUsage!=null)?i.jsx(eAe,{usage:e.contextUsage??null,lang:e.contextUsageLang??"en",compactAction:e.contextCompactAction,onClose:e.onContextUsageClose}):null]})}const dR="'IBM Plex Mono',monospace";function yAe({state:e}){return e==="done"?i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700},children:"✓"}):e==="running"?i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-accent)",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite"}}):i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box"}})}function bAe(e){return e==="running"?"var(--proto-ink)":e==="done"?"var(--proto-muted)":"var(--proto-faint)"}function wAe({card:e,pill:t,subthreadsLabel:n,openLabel:r,onOpen:o}){return i.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:12,overflow:"hidden",background:"var(--proto-card)"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 12px",borderBottom:"1px solid var(--proto-line-2)"},children:[i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.6",children:[i.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),i.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),i.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),i.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]}),i.jsx("span",{style:{font:`600 12px ${dR}`,color:"var(--proto-ink)"},children:e.name}),i.jsx("span",{style:{marginLeft:"auto",fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:999,background:t.bg,color:t.color},children:e.pillText})]}),i.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px"},children:e.nodes.map((s,a)=>i.jsxs(f.Fragment,{children:[a>0&&i.jsx("div",{style:{flex:1,height:1.5,background:s.lineDone?"var(--proto-success-bg)":"var(--proto-line)",margin:"0 6px"}}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[i.jsx(yAe,{state:s.state}),i.jsx("span",{style:{fontSize:10.5,color:bAe(s.state),fontWeight:s.state==="running"?600:void 0},children:s.label})]})]},a))}),i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",borderTop:"1px solid var(--proto-line-2)"},children:[i.jsxs("span",{style:{font:`400 10px ${dR}`,color:"var(--proto-muted-3)"},children:[e.footer.elapsed," · ",e.footer.cost," · ",e.footer.subCount," ",n]}),i.jsxs("span",{onClick:o,style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:[r," →"]})]})]})}function SAe({sessionId:e,subthreadsLabel:t,openLabel:n}){const r=Xe(),o=he(),a=ae({...o.threads.list.queryOptions({status:["running","waiting"],sessionId:e}),enabled:!!e}).data??[],l=a.find(u=>u.status==="running")??a[0]??null,c=(l==null?void 0:l.id)??"";vh(c);const d=ae({...o.threads.get.queryOptions({threadId:c}),enabled:!!c});return!c||d.isPending||d.isError||!d.data?null:i.jsx(wAe,{card:JMe(d.data),pill:Ek(d.data.status),subthreadsLabel:t,openLabel:n,onOpen:()=>r(`/m/thread/${c}`)})}function kAe(e){if(e.draftKeyRef.current===e.draftKey)return!1;if(e.draftKeyRef.current=e.draftKey,!e.draftKey)return!0;const t=ic(e.draftKey);return e.isDraft&&(t!=null&&t.draftUploadId)&&(e.draftUploadId.current=t.draftUploadId),e.setText((t==null?void 0:t.text)??""),e.replaceRestored((t==null?void 0:t.attachments)??[]),!0}function jAe(e){ws(e.draftKey,{text:e.text,attachments:Rk(e.uploads),...e.isDraft&&e.draftUploadId.current?{draftUploadId:e.draftUploadId.current}:{}})}function CAe(e){f.useEffect(()=>{kAe(e)||jAe(e)},[e.draftKey,e.text,e.uploads,e.isDraft])}const TAe={sessionId:"",turns:[]},PAe={zh:{composerPh:"输入消息,/ 调用命令",toolCallsUnit:"次工具调用",menuSessionId:"会话 ID",sessionIdTitle:"会话 ID",cortexIdLabel:"Cortex ID",backendUuidLabel:"后端 UUID",copy:"复制",copied:"已复制",attachCamera:"拍照",attachLibrary:"照片图库",attachFile:"选择文件",attachBrowser:"浏览器",attachCommission:"委托",attachCommands:"命令",attachPlaceholder:"补充说明…",profileTitle:"Profile",profileSubtitle:"仅本会话 · 热更新",profileCurrent:"当前",profileFooter:"切换仅影响本会话后续 turn · 运行中线程不受影响 · 全局默认在设置",lineUnit:"行",charUnit:"字"},en:{composerPh:"Message, / for commands",toolCallsUnit:"tool calls",menuSessionId:"Session ID",sessionIdTitle:"Session ID",cortexIdLabel:"Cortex ID",backendUuidLabel:"Backend UUID",copy:"Copy",copied:"Copied",attachCamera:"Take photo",attachLibrary:"Photo library",attachFile:"Choose file",attachBrowser:"Browser",attachCommission:"Commission",attachCommands:"Commands",attachPlaceholder:"Add a note…",profileTitle:"Profile",profileSubtitle:"This session · hot-swap",profileCurrent:"current",profileFooter:"Applies to this session’s next turns only · running threads unaffected · global default in Settings",lineUnit:"lines",charUnit:"chars"}},EAe={zh:{menuCopy:"复制",menuEdit:"编辑消息",editingBadge:"编辑中",willRewind:(e,t)=>`将被回退 · ${e} 条回复 · ${t} 次工具调用`,editBarTitle:"编辑消息 — 发送将回退后续回复",edited:"已编辑",original:"原消息",regenNote:"由编辑重新生成"},en:{menuCopy:"Copy",menuEdit:"Edit message",editingBadge:"Editing",willRewind:(e,t)=>`Will rewind · ${e} repl${e===1?"y":"ies"} · ${t} tool call${t===1?"":"s"}`,editBarTitle:"Editing message — send rewinds later replies",edited:"edited",original:"Original message",regenNote:"Regenerated from edit"}};function RAe(){var tj,nj,rj,oj,ij,sj,aj;const e=he(),t=Xe(),n=Ve(),r=ht(),o=O(),s=dn(r,PAe),{currentProjectId:a}=zt(),{sessionId:l}=Kx(),c=l==="new",d=tl(a,"direct"),u=tl(a,"scheduled"),p=f.useMemo(()=>[...d.data??[],...u.data??[]].find(Fe=>Fe.sessionId===l)??null,[d.data,u.data,l]),h=c?"":(p==null?void 0:p.sessionId)??l??"",m=(p==null?void 0:p.origin)==="scheduled",x=ae({...e.schedules.list.queryOptions({projectId:a??void 0}),enabled:!!(p!=null&&p.scheduleId)}),v=f.useMemo(()=>{if(!m||!(p!=null&&p.scheduleId))return null;const oe=(x.data??[]).find(ut=>ut.id===p.scheduleId)??null,Fe=(u.data??[]).filter(ut=>ut.scheduleId===p.scheduleId);return jH(oe,Fe,p.sessionId)},[m,p==null?void 0:p.scheduleId,p==null?void 0:p.sessionId,x.data,u.data]),S=ae({...e.sessions.transcript.queryOptions({sessionId:h,compactSubagents:!0}),enabled:!!h}),{liveTail:b,getMessageSnapshot:g,streaming:w,running:k,backgroundRunning:C,liveTurns:T,contextUsage:P,todos:R,streamingText:D,pendingUser:I}=S1(h,p==null?void 0:p.running,p==null?void 0:p.backgroundRunning,{deltas:!0,transcript:S.data??null,contextUsage:(p==null?void 0:p.contextUsage)??null,todos:(p==null?void 0:p.todos)??null}),L=TU({sessionId:h,isDraft:c,projectId:a??"general",transcript:S.data??null,liveTail:b,pendingUser:I,getMessageSnapshot:g}),W=jU(h,{running:k,hasBackendHistory:!!(p!=null&&p.backendSessionId)}),ee=Lk(h);CU(h,`${b.length}:${k}`);const V=S.data??TAe,X=f.useMemo(()=>bIe(V,b,{streaming:w,running:k,streamingText:D,pendingUser:L.pendingUser,stripScheduledPrefix:!!(p!=null&&p.scheduleId)||m}),[V,b,w,k,D,L.pendingUser,p==null?void 0:p.scheduleId,m]),K=iz(T,(p==null?void 0:p.numTurns)??null),se=f.useMemo(()=>sz(oz(S.data)),[S.data]),B=f.useMemo(()=>{var oe;for(const Fe of X)if(!(Fe.kind!=="interaction"||((oe=Fe.detail)==null?void 0:oe.status)!=="pending")&&!(Fe.detail.kind==="ask-user"&&Fe.detail.payload.blocking===!1))return{detail:Fe.detail,ts:Fe.ts??null};return null},[X]),G=(B==null?void 0:B.detail.kind)==="ask-user"?NB(B.detail,B.ts):null,ne=(B==null?void 0:B.detail.kind)==="plan-approval"?SS(B.detail,B.ts):null,[le,_]=f.useState({}),Y=oe=>le[oe]??FB,te=(oe,Fe)=>{_(ut=>({...ut,[oe.requestId]:Fe})),Jxe(oe,Fe)&&ee.answerQuestion(oe.requestId,e1e(oe,Fe))},ie=(oe,Fe)=>{const ut=Y(oe.requestId),$n=oe.questions[aa(oe,ut)];$n&&te(oe,$5(ut,$n.question,Fe))},ye=(oe,Fe)=>{_(ut=>({...ut,[oe.requestId]:Xxe(Y(oe.requestId),Fe)}))},Z=oe=>{const Fe=Y(oe.requestId),ut=oe.questions[aa(oe,Fe)];ut&&Fe.selected.length>0&&te(oe,Zxe(Fe,ut.question))},[xe,ke]=f.useState(null),Oe=fo();f.useEffect(()=>{const oe=Oe.state;oe!=null&&oe.rejectPlan&&(ke(oe.rejectPlan),t(Oe.pathname,{replace:!0}))},[Oe.state]);const Ie=(ne==null?void 0:ne.requestId)??null;f.useEffect(()=>{xe&&xe!==Ie&&ke(null)},[xe,Ie]);const Ae=oe=>t(`/m/session/${h}/plan/${oe.requestId}`),tt=ae(e.config.get.queryOptions({})),we=((nj=(tj=tt.data)==null?void 0:tj.profiles)==null?void 0:nj.profiles)??[],lt=((oj=(rj=tt.data)==null?void 0:rj.profiles)==null?void 0:oj.defaultProfile)??null,[Qe,Zt]=f.useState(null),[wn,Qn]=f.useState(null),[qt,ft]=f.useState(!1),[Vr,pr]=f.useState([]);f.useEffect(()=>{if(!qt)return;let oe=!0;return KS().then(Fe=>{oe&&pr(Fe)}).catch(()=>{oe&&pr([])}),()=>{oe=!1}},[qt]);const[mt,Bt]=f.useState(null),[Ct,fr]=f.useState(!1),Sn=Mk(Ct),gt=aU(p),go=sU(),[In,qi]=f.useState(null),Er=P$(p==null?void 0:p.profileName,In,h),Rr=kIe(c?Qe:Er,we,lt);f.useEffect(()=>{if(!In)return;const oe=(p==null?void 0:p.sessionId)===In.sessionId,Fe=!c&&h!==In.sessionId;(oe||Fe)&&qi(null)},[p==null?void 0:p.sessionId,c,In,h]);const zn=Re(e.sessions.send.mutationOptions()),qr=Re(e.sessions.createAndSend.mutationOptions()),Fo=Re(e.sessions.setProfile.mutationOptions({onSuccess:()=>n.invalidateQueries(e.sessions.list.queryFilter())})),vo=Re(e.sessions.cancel.mutationOptions()),xo=()=>{!h||vo.isPending||vo.mutate({sessionId:h})},hr=Re(e.sessions.rewind.mutationOptions({onSettled:()=>{h&&(n.invalidateQueries(e.sessions.transcript.queryFilter({sessionId:h})),n.invalidateQueries(e.sessions.list.queryFilter()),wd(n,e,h))}})),[An,pn]=f.useState(""),[Ks,Gs]=f.useState(!1),[ui,Xn]=f.useState(!1),[mr,Bn]=f.useState(null),[Kr,pi]=f.useState(null),[$,q]=f.useState(null),[J,Q]=f.useState(null),re=f.useRef(""),[ve,Ne]=f.useState(!1),[be,Se]=f.useState(!1),[Pe,Le]=f.useState(!1),[qe,Ze]=f.useState([]),Jt=f.useRef(null),nt=xh({isDraft:c,sessionId:h,projectId:a}),Ye=f.useRef(null),Tt=f.useRef(null);Tt.current!==nt&&(Tt.current=nt,Ye.current=c?((ij=ic(nt))==null?void 0:ij.draftUploadId)??crypto.randomUUID():null);const Ce=c?Ye.current??"":h,rt=JH({scope:nt,bucket:Ce}),Mt=rt.items,an=f.useRef(void 0);CAe({draftKey:nt,isDraft:c,text:An,uploads:Mt,setText:pn,replaceRestored:rt.replaceRestored,draftUploadId:Ye,draftKeyRef:an});const Mr=rt.addFiles,Zn=(oe,Fe)=>{const ut=Jt.current;ut&&(ut.accept=oe,Fe?ut.setAttribute("capture",Fe):ut.removeAttribute("capture"),ut.click())},Ot=rt.completed,Ki=!rt.hasNonDone,Jn=!!An.trim(),Ke=$!=null?X[$]:null,wt=!!Ke&&Ke.kind==="user"&&Ke.turnIndex!==void 0,Gi=()=>{q(null),pn(re.current),re.current=""},wl=oe=>{const Fe=X[oe];!Fe||Fe.kind!=="user"||Fe.turnIndex===void 0||k||(re.current=An,ke(null),q(oe),pn(Fe.text))};f.useEffect(()=>{if($==null)return;const oe=X[$];(!(!!oe&&oe.kind==="user"&&oe.turnIndex!==void 0)||k)&&Gi()},[X,k,$]);const en=wt?{rowIndex:$,...az(X,$),onCancel:Gi}:null,Gr=mr!=null?X[mr]:null,Ph=Gr&&(Gr.kind==="user"||Gr.kind==="assistant")?{rowIndex:mr,anchorTop:Kr,onCopy:()=>{var oe;(oe=navigator.clipboard)==null||oe.writeText(Gr.text).catch(()=>{})},...Gr.kind==="user"&&Gr.turnIndex!==void 0?{onEdit:()=>wl(mr),editDisabled:k||hr.isPending}:{},onClose:()=>Bn(null)}:null,Ys=!wt&&!!xe&&xe===Ie,cp=wt?Jn&&Ki&&!hr.isPending:Ys||!!G?Jn&&Ki&&!ee.busy:QH(An,Mt)&&(!!h||c)&&!zn.isPending&&!qr.isPending,RV=(oe,Fe,ut)=>{if(an.current!==Fe){ws(Fe,R$(ic(Fe)??{text:"",attachments:[]},oe));return}oe.draftUploadId&&(Ye.current=oe.draftUploadId),pn($n=>[oe.text,$n].filter(gr=>gr.length>0).join(`
442
442
  `)),rt.mergeRestored(oe.attachments),Ze($n=>[...$n,r==="zh"?`发送失败 · ${ut.message} · 内容已退回输入框`:`send failed · ${ut.message} · text restored to the composer`])},MV=uU(we,Rr),Yk=pU(we,Rr,{currentBackend:MV,hasHistory:V.turns.length>0||b.length>0}).map(oe=>({name:oe.name,detail:oe.sub,disabled:oe.disabled})),Qk={newDisabled:rt.hasNonDone,cancelDisabled:!k||vo.isPending,compactDisabled:!(p!=null&&p.contextCompactionSupported)||W.disabled||W.pending,settingsDisabled:rt.hasNonDone},IV=wt||Ys||G?[]:VH(An,Yk,Qk),AV={onNew:()=>t("/m/session/new"),onCancel:()=>{k&&xo()},onCompact:W.onCompact,onProfile:Zk,onSettings:()=>t("/m/settings")},DV=()=>{ws(nt,{text:"",attachments:Ot,...c&&Ye.current?{draftUploadId:Ye.current}:{}}),pn("")},Xk=oe=>{DV(),qH(oe,AV)},LV=oe=>{const Fe=UH(oe,Yk,Qk);if(Fe.kind==="none")return!1;Fe.kind==="action"&&Xk(Fe.action);const ut=_H(Fe);return ut&&Ze($n=>[...$n,o[ut]]),!0},OV=oe=>{oe.disabled||(oe.action?Xk(oe.action):pn(`${oe.command} `))},NV=()=>{const oe=An.trim();if(wt){if(!cp)return;const gr=Ke;hr.mutate({sessionId:h,turnIndex:gr.turnIndex,text:oe}),q(null),pn(re.current),re.current="";return}if(Ys){if(!cp)return;ee.rejectPlan(xe,oe),ke(null),pn("");return}if(G){if(!cp)return;const gr=Y(G.requestId),Yi=G.questions[aa(G,gr)];Yi&&te(G,$5(gr,Yi.question,oe)),pn("");return}if(LV(oe)||!cp)return;const Fe={text:oe,attachments:Ot,...c&&Ye.current?{draftUploadId:Ye.current}:{}},ut=nt,$n=xU({message:L.prepare(oe,Ot),mutate:()=>c?qr.mutateAsync({projectId:a??"general",profileName:Qe??void 0,text:oe,draftUploadId:Fe.draftUploadId,...wn?{browser:{device:wn}}:{},...go&&Xv(mt)?{commission:Xv(mt)}:{},...Ot.length>0?{attachments:Ot}:{}}):zn.mutateAsync({sessionId:h,text:oe,...Ot.length>0?{attachments:Ot}:{}}),onEnqueue:L.enqueue,onAccepted:(gr,Yi)=>{if(!("sessionId"in Yi)){L.accept(gr.clientId,{acceptedAt:Yi.acceptedAt});return}L.accept(gr.clientId,{acceptedAt:Yi.acceptedAt,createdSessionId:Yi.sessionId}),Ye.current=null,qi({sessionId:Yi.sessionId,profileName:Qe}),n.invalidateQueries(e.sessions.list.queryFilter()),t(`/m/session/${Yi.sessionId}`,{replace:!0})},onRejected:gr=>L.reject(gr.clientId)});I$(nt),pn(""),rt.reset(),$n.then(gr=>{!gr.ok&&gr.restore&&RV(Fe,ut,gr.error)})};function Zk(oe){if(Se(!1),oe===Rr)return;const Fe=Rr,ut=r==="zh"?`profile 切换 ${Fe} → ${oe} · 下一 turn 生效`:`profile ${Fe} → ${oe} · takes effect next turn`;c?(Zt(oe),Ze($n=>[...$n,ut])):h&&Fo.mutate({sessionId:h,profileName:oe},{onSuccess:()=>Ze($n=>[...$n,ut])})}const FV=(p==null?void 0:p.costUsd)??null,zV=!c&&K!=null,Jk=yU({running:k||L.pendingUser.length>0,backgroundRunning:C,hasRun:zV}),BV={foreground:o.pillRunning,background:o.pillBackground,idle:o.wbIdle,turnsUnit:o.wbTurnsUnit},W1=((sj=p==null?void 0:p.browser)==null?void 0:sj.device)??wn,$V=tU({running:Jk.active,backgroundRunning:C,device:W1,turnProgressStarted:T!==null||w}),_V=B?SIe(B.detail.kind,G?aa(G,Y(G.requestId)):0,(G==null?void 0:G.questions.length)??1,r):$V&&W1?{running:!0,tone:"running",text:nU(W1,o.wbBrowserStarting)}:wIe(Jk,K,se,FV,BV),WV={copy:dn(r,nV),askState:Y,onAskPick:ie,onAskToggle:ye,onAskConfirmMulti:Z,onAskCustom:()=>{},rejectingId:Ys?xe:null,onApprove:oe=>ee.approvePlan(oe.requestId),onRejectStart:oe=>ke(oe.requestId),onOpenRead:Ae,onCancelResume:ee.cancelResume,resumeCancelled:ee.resumeCancelled},HV=Ys&&ne?{title:r==="zh"?`驳回「${ne.title}」— 说明原因后发送`:`Rejecting "${ne.title}" — explain, then send`,chips:r==="zh"?["范围太大","先做 dry-run","成本超预期","步骤顺序不对"]:["Scope too big","Dry-run first","Over budget","Wrong step order"],onChipTap:oe=>pn(Fe=>Fe?`${Fe}${r==="zh"?";":"; "}${oe}`:oe),onCancel:()=>ke(null)}:void 0,UV=Ys?r==="zh"?"说明驳回原因…":"Reason for rejecting…":G?r==="zh"?`点选项,或直接输入回答 Q${Math.min(aa(G,Y(G.requestId))+1,G.questions.length)}…`:`Tap an option, or type your answer to Q${Math.min(aa(G,Y(G.requestId))+1,G.questions.length)}…`:void 0,VV=c?r==="zh"?"新会话":"New session":v??(p==null?void 0:p.label)??(p==null?void 0:p.name)??l??"",ej=m?r==="zh"?"发送消息后提取为普通会话 · schedule 下次 run 不受影响":"Replying converts this run into a normal session · the schedule's next run is unaffected":null,qV=Mt.map(oe=>{var ut,$n;const Fe=YH(oe);return{id:oe.id,name:((ut=oe.file)==null?void 0:ut.name)??(($n=oe.meta)==null?void 0:$n.name)??"file",progress:oe.progress,status:oe.status,type:Fe==="image"||Fe==="video"?Fe:"file",previewUrl:oe.previewUrl}});return i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:Jt,type:"file",multiple:!0,style:{display:"none"},onChange:oe=>{oe.target.files&&oe.target.files.length>0&&Mr(oe.target.files),oe.target.value=""}}),i.jsx(xAe,{title:VV,status:_V,rows:X,copy:s,onBack:()=>t("/m/sessions"),moreOpen:Ks,onMoreToggle:()=>Gs(oe=>!oe),onMoreClose:()=>Gs(!1),sessionIdOpen:ui,onSessionIdOpen:()=>Xn(!0),onSessionIdClose:()=>Xn(!1),cortexId:(p==null?void 0:p.name)??null,backendUuid:(p==null?void 0:p.backendSessionId)??null,inlineThreadCard:h?i.jsx(SAe,{sessionId:h,subthreadsLabel:r==="zh"?"子线程":"sub-threads",openLabel:r==="zh"?"打开":"Open"}):void 0,systemLines:ej?[...qe,ej]:qe,interactions:WV,rejectBar:HV,editCopy:dn(r,EAe),msgMenu:Ph,onLongPress:(oe,Fe)=>{pi(Fe),Bn(oe)},editing:en,onShowOriginal:oe=>Q({text:oe.originalText}),originalSheet:J?{text:J.text,onClose:()=>Q(null)}:null,streamKey:h,sessionId:h,todos:R,todoLang:r,composerValue:An,onComposerChange:pn,onSend:NV,slashSuggestions:IV,onSlashPick:OV,sendEnabled:cp,composerPlaceholder:UV,onStop:xo,stopEnabled:!vo.isPending,profileChipLabel:Rr,browserDevice:c?wn:((aj=p==null?void 0:p.browser)==null?void 0:aj.device)??null,onOpenBrowser:c?()=>ft(!0):void 0,browserSheet:qt?{items:[{device:null,label:o.wbBrowserOffOption,sub:""},{device:Qv,label:Qv,sub:o.wbBrowserThisHost},...Vr.map(oe=>({device:oe.device,label:oe.device,sub:oe.platform}))],title:o.wbBrowser,onClose:()=>ft(!1),onPick:oe=>{Qn(oe),ft(!1)}}:void 0,commissionValue:c?go?mt:null:(gt==null?void 0:gt.value)??null,commissionLabel:c?go&&mt==="new"?o.wbCommissionNewOption:null:(gt==null?void 0:gt.label)??(gt?o.wbCommissionUnnamed:null),onOpenCommission:c&&go?()=>fr(!0):void 0,commissionSheet:Ct?{items:Sn.map(oe=>({value:oe.value,label:oe.label,sub:oe.sub})),title:o.wbCommissionMode,onClose:()=>fr(!1),onPick:oe=>{Bt(oe),fr(!1)}}:void 0,onOpenProfile:()=>Se(!0),contextUsage:P,contextUsageSupported:!!(p!=null&&p.contextCompactionSupported),contextUsageLang:r,contextCompactAction:p!=null&&p.contextCompactionSupported?W:void 0,contextUsageOpen:Pe,onContextUsageOpen:()=>Le(!0),onContextUsageClose:()=>Le(!1),attachments:qV,onRemoveAttachment:rt.remove,onRetryAttachment:rt.retry,onPlus:()=>Ne(oe=>!oe),attachMenuOpen:ve,onAttachClose:()=>Ne(!1),onCamera:()=>Zn("image/*","environment"),onLibrary:()=>Zn("image/*,video/*"),onFile:()=>Zn("*/*"),profileSheet:be?{items:CIe(we,Rr),onClose:()=>Se(!1),onPick:Zk}:void 0})]})}const MAe={zh:{lang:"zh",pendingPill:"计划待批",approvedStamp:"✓ 计划已批准",rejectedStamp:"已驳回",cancelledStamp:"已取消",expiredStamp:"已过期",approve:"批准并执行",reject:"驳回并反馈",approvedBy:"由你批准",feedbackLabel:"驳回反馈"},en:{lang:"en",pendingPill:"Plan pending",approvedStamp:"✓ Plan approved",rejectedStamp:"Rejected",cancelledStamp:"Cancelled",expiredStamp:"Expired",approve:"Approve & run",reject:"Reject with note",approvedBy:"approved by you",feedbackLabel:"Reject feedback"}};function IAe({model:e,copy:t,onBack:n,onApprove:r,onReject:o}){const s=e.status==="pending",[a,l]=f.useState(0),c=f.useRef(null),d=()=>{const m=c.current;if(!m)return;const x=KB(m.scrollTop,m.clientHeight,m.scrollHeight);l(v=>Math.max(v,x))},u=GB(e.status,t.lang),p=QB(a,t.lang),h=e.status==="approved"?{text:`${t.approvedStamp}${e.timeLabel?` · ${e.timeLabel} ${t.approvedBy}`:""}`,fg:y.done,bg:y.doneBg}:e.status==="rejected"?{text:`${t.rejectedStamp}${e.timeLabel?` · ${e.timeLabel}`:""}`,fg:y.grayInk,bg:y.gray}:e.status==="cancelled"?{text:t.cancelledStamp,fg:y.grayInk,bg:y.gray}:{text:t.expiredStamp,fg:y.grayInk,bg:y.gray};return i.jsxs("div",{"data-screen-label":"6b 计划全文阅读页",style:{height:"100%",display:"flex",flexDirection:"column",boxSizing:"border-box",position:"relative",background:y.canvas},children:[i.jsxs("div",{style:{flex:"none",padding:"8px 14px 10px",paddingTop:"calc(8px + env(safe-area-inset-top))",borderBottom:`1px solid ${y.hairline}`,background:y.canvas},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[i.jsx("button",{type:"button","aria-label":"Back",onClick:n,style:{border:"none",background:"transparent",color:y.run,fontSize:15,lineHeight:1,padding:"0 2px",margin:0,cursor:"pointer",flex:"none",minHeight:44,minWidth:30,display:"flex",alignItems:"center"},children:"‹"}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{fontSize:15,fontWeight:650,color:y.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),i.jsx("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:YB(e.filePath,e.lineCount,u,t.lang)})]}),s?i.jsx("span",{style:{marginLeft:"auto",font:`600 9.5px ${H}`,color:y.amberInk,background:y.amberBg,padding:"2px 8px",borderRadius:999,flex:"none"},children:t.pendingPill}):i.jsx("span",{style:{marginLeft:"auto",font:`600 9.5px ${H}`,color:h.fg,background:h.bg,padding:"2px 8px",borderRadius:999,flex:"none"},children:u})]}),s&&i.jsx("div",{style:{height:3,borderRadius:999,background:"var(--proto-line)",overflow:"hidden",marginTop:9},children:i.jsx("div",{style:{width:`${a}%`,height:"100%",background:y.run}})})]}),i.jsxs("div",{style:{flex:1,minHeight:0,position:"relative",background:"var(--proto-card)"},children:[i.jsxs("div",{ref:c,onScroll:d,style:{position:"absolute",inset:0,overflow:"auto",padding:"16px 18px 24px",boxSizing:"border-box"},children:[e.timeLabel&&i.jsx("div",{style:{font:`400 10px ${H}`,color:y.faint,paddingBottom:8},children:e.timeLabel}),i.jsx("div",{style:{fontSize:13,lineHeight:1.7,color:y.body},children:i.jsx(ci,{text:e.planContent})}),e.status==="rejected"&&e.feedback&&i.jsxs("div",{style:{marginTop:16,border:`1px solid ${y.amberBorder}`,background:y.amberCard,borderRadius:11,padding:"10px 13px"},children:[i.jsx("div",{style:{font:`600 10px ${H}`,color:y.amberText,paddingBottom:4},children:t.feedbackLabel}),i.jsx("div",{style:{fontSize:12.5,lineHeight:1.6,color:"var(--proto-amber-fg)",whiteSpace:"pre-wrap"},children:e.feedback})]})]}),i.jsx("div",{style:{position:"absolute",left:0,right:0,bottom:0,height:56,background:"linear-gradient(180deg,var(--proto-card-transparent),var(--proto-card))",pointerEvents:"none"}})]}),i.jsx("div",{style:{flex:"none",background:"var(--proto-card)",borderTop:"1px solid var(--proto-line-2)",padding:"10px 14px",paddingBottom:"calc(14px + env(safe-area-inset-bottom))"},children:s?i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsx("button",{type:"button",onClick:o,style:{flex:1,height:48,borderRadius:13,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:y.ink,fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:t.reject}),i.jsxs("button",{type:"button",onClick:r,style:{flex:1.3,height:48,borderRadius:13,background:y.ink,color:"var(--ink-solid-fg)",border:"none",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,cursor:"pointer"},children:[i.jsx("span",{style:{fontSize:14,fontWeight:600},children:t.approve}),p]})]}):i.jsx("div",{style:{height:48,borderRadius:13,background:h.bg,color:h.fg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600},children:h.text})})]})}function AAe(){const{sessionId:e="",requestId:t=""}=Kx(),n=Xe(),r=he(),o=ht(),s=dn(o,MAe),a=ae({...r.sessions.transcript.queryOptions({sessionId:e,compactSubagents:!0}),enabled:!!e});S1(e,void 0);const l=Lk(e),c=c1e(a.data,t),d=()=>n(`/m/session/${e}`);if(!c)return i.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,background:y.canvas},children:[i.jsx("div",{style:{font:`400 11px ${H}`,color:y.faint},children:a.isPending?"…":o==="zh"?"未找到该计划":"Plan not found"}),i.jsx("button",{type:"button",onClick:d,style:{border:`1px solid ${y.hairline}`,background:"var(--proto-card)",borderRadius:999,padding:"7px 16px",fontSize:12.5,fontWeight:600,color:y.ink,cursor:"pointer"},children:o==="zh"?"返回会话":"Back to chat"})]});const u=SS(c.detail,c.ts);return i.jsx(IAe,{model:u,copy:s,onBack:d,onApprove:()=>{u.status==="pending"&&l.approvePlan(u.requestId)},onReject:()=>n(`/m/session/${e}`,{state:{rejectPlan:t}})})}function DAe(e,t){const n=typeof t=="number"&&t>0,r=typeof e=="number"?e:0;return{numerator:M0(typeof e=="number"?e:null),denominator:n?M0(t):"—",pct:n?Math.max(0,Math.min(100,r/t*100)):0}}function LAe(e){return e==="running"||e==="waiting"}function OAe(e,t){var n;if(t&&t.steps.length>0)return t.steps.map((r,o)=>({label:r.stage??`#${o+1}`,state:r.status==="completed"?"done":r.status==="running"?"active":"pending"}));if(e.totalSteps>0){const r=((n=e.currentStep)==null?void 0:n.index)??-1;return Array.from({length:e.totalSteps},(o,s)=>{var a;return{label:s===r&&((a=e.currentStep)!=null&&a.name)?e.currentStep.name:`#${s+1}`,state:s<r?"done":s===r?"active":"pending"}})}return[]}function NAe(e,t,n,r){const o=[e.id];if(e.taskId&&o.push(`task ${e.taskId}`),o.push(KH(e.createdAt,n)),t){o.push(yn(t.totalCostUsd));const s=t.children.length;s>0&&o.push(`${s} ${r}`)}return o.join(" · ")}function FAe(e,t){switch(e){case"running":return{tone:"running",label:t.running};case"waiting":return{tone:"waiting",label:t.waiting};case"completed":return{tone:"done",label:t.done};case"failed":case"aborted":return{tone:"failed",label:t.failed};case"cancelled":return{tone:"cancelled",label:t.cancelled};default:return{tone:KO(e),label:t.running}}}function zAe({color:e}){return i.jsxs("svg",{width:13,height:13,viewBox:"0 0 14 14",fill:"none",stroke:e,strokeWidth:1.6,style:{flex:"none"},children:[i.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),i.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),i.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),i.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]})}function BAe({copy:e,qn:t,band:n}){return i.jsx(Hx,{title:e.title,qn:t,below:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:9},children:[i.jsx("span",{style:{fontSize:10,fontWeight:600,color:y.muted},children:e.today}),i.jsx("div",{style:{flex:1,height:4,borderRadius:999,background:"var(--proto-line)",overflow:"hidden"},children:i.jsx("div",{style:{width:`${n.pct}%`,height:"100%",background:y.run}})}),i.jsxs("span",{style:{font:`500 10px ${H}`,color:y.ink},children:[n.numerator," / ",n.denominator]})]})})}function $Ae({groups:e,copy:t,renderThread:n}){return i.jsx(i.Fragment,{children:e.map((r,o)=>i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:9},children:[i.jsxs(fu,{style:{padding:o===0?"0 2px 2px":"6px 2px 2px"},children:[t[r.kind]," · ",r.threads.length]}),r.threads.map(n)]},r.kind))})}function _Ae({state:e}){return e==="done"?i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:y.doneBg,color:y.done,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,flex:"none"},children:"✓"}):e==="active"?i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:y.run,boxShadow:`0 0 0 3px ${y.runBg}`,animation:"cxpulse 1.6s ease-in-out infinite",flex:"none"}}):i.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}})}const uR=4;function WAe({step:e}){const t=e.state==="active"?y.ink:e.state==="done"?y.sub:y.faint;return i.jsx("span",{title:e.label,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:10.5,color:t,fontWeight:e.state==="active"?600:400},children:e.label})}function HAe({step:e,connected:t}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",minWidth:0,overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0,flex:"0 1 auto"},children:[i.jsx(_Ae,{state:e.state}),i.jsx(WAe,{step:e})]}),t&&i.jsx("div",{style:{flex:1,minWidth:2,height:1.5,margin:"0 6px",background:e.state==="done"?"var(--proto-success-bg)":y.hairline}})]})}function UAe({steps:e}){const t=Math.min(uR,e.length);return i.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${t}, minmax(0, 1fr))`,rowGap:8,padding:"10px 0 4px"},children:e.map((n,r)=>i.jsx(HAe,{step:n,connected:r<e.length-1&&(r+1)%uR!==0},r))})}function aV({info:e,detail:t,now:n,copy:r,onOpen:o}){const s=OAe(e,t),a=FAe(e.status,r),l=e.status==="running"?y.run:e.status==="waiting"?y.amber:y.muted;return i.jsxs(et,{onClick:o,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx(zAe,{color:l}),i.jsx("span",{style:{font:`600 12.5px ${H}`,color:y.ink},children:e.templateName}),i.jsx("span",{style:{marginLeft:"auto"},children:i.jsx(Kn,{tone:a.tone,children:a.label})})]}),s.length>0&&i.jsx(UAe,{steps:s}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[i.jsx("span",{style:{font:`400 10px ${H}`,color:"var(--proto-muted-3)"},children:NAe(e,t,n,r.subthread)}),i.jsxs("span",{style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:y.run},children:[r.open," ›"]})]})]})}const VAe={en:{title:"Threads",active:"Active",history:"History",today:"Today",open:"Open",subthread:"subthreads",empty:"No threads",running:"Running",waiting:"Waiting",done:"Done",failed:"Failed",cancelled:"Cancelled"},zh:{title:"线程",active:"活跃",history:"历史",today:"今日",open:"打开",subthread:"子线程",empty:"暂无线程",running:"运行中",waiting:"等待中",done:"已完成",failed:"失败",cancelled:"已取消"}};function qAe({info:e,now:t,copy:n,onOpen:r}){const o=he();vh(e.id);const s=ae(o.threads.get.queryOptions({threadId:e.id}));return i.jsx(aV,{info:e,detail:s.data,now:t,copy:n,onOpen:r})}function KAe(){var h,m;const e=he(),t=Xe(),n=ht(),r=dn(n,VAe),{currentProjectId:o}=zt(),s=LU(!0);zk();const a=o??void 0,l=ae(e.threads.list.queryOptions({projectId:a})),c=ae(e.cost.summary.queryOptions({projectId:a})),d=DU(l.data??[]),u=f.useMemo(()=>{var x,v;return DAe((x=c.data)==null?void 0:x.today,(v=c.data)==null?void 0:v.dailyBudget)},[(h=c.data)==null?void 0:h.today,(m=c.data)==null?void 0:m.dailyBudget]),p=o?jh(o):void 0;return i.jsx(At,{label:"1c 线程",header:i.jsx(BAe,{copy:r,qn:p,band:u}),children:i.jsxs(Yn,{children:[l.isSuccess&&d.length===0&&i.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:y.faint,fontSize:13},children:r.empty}),i.jsx($Ae,{groups:d,copy:r,renderThread:x=>{const v=()=>t(`/m/thread/${x.id}`);return LAe(x.status)?i.jsx(qAe,{info:x,now:s,copy:r,onOpen:v},x.id):i.jsx(aV,{info:x,detail:void 0,now:s,copy:r,onOpen:v},x.id)}})]})})}const GAe={"in-progress":"inProgress",actionable:"actionable","approval-needed":"approvalNeeded","waiting-deps":"waiting",blocked:"blocked",done:"done"},lV={flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};function lp({task:e,textColor:t=y.body}){return i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0,flex:1},children:[i.jsx("span",{style:{font:`500 10px ${H}`,color:y.muted,flex:"none"},children:e.id}),i.jsx("span",{style:{fontSize:12.5,color:t,lineHeight:1.45,...lV},title:e.text,children:e.text})]})}function Vk({text:e,color:t,dot:n,onClick:r,singleLine:o=!1}){return i.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:5,marginTop:5,minWidth:0,cursor:r?"pointer":"default"},children:[n&&i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:n,flex:"none"}}),i.jsx("span",{"data-task-blocker":o?"true":void 0,style:{font:`400 9.5px ${H}`,color:t,...o?lV:{}},children:e})]})}function YAe({task:e,copy:t,onOpenTask:n,onOpenThread:r}){const o=NS(e),s=o,a=l=>{l.stopPropagation(),s&&r(s)};return i.jsxs(et,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),children:[i.jsx(lp,{task:e}),i.jsx("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:5},children:i.jsxs("span",{onClick:a,style:{font:`500 9.5px ${H}`,color:y.run,background:y.runBg,padding:"2px 7px",borderRadius:999,cursor:s?"pointer":"default"},children:[t.claim,o?` · ${o}`:"",s?" ›":""]})})]})}function QAe({task:e,copy:t,expanded:n,onToggle:r,onOpenTask:o}){return i.jsxs(et,{radius:11,padding:"10px 13px",onClick:()=>o(e.id),children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0},children:[i.jsx(lp,{task:e}),i.jsx("span",{role:"button","aria-label":"Toggle done-when","aria-expanded":n,onClick:s=>{s.stopPropagation(),r(e.id)},style:{marginLeft:"auto",color:y.faint,fontSize:8.5,flex:"none",cursor:"pointer",padding:"2px 2px 2px 8px"},children:n?"▾":"▸"})]}),n&&i.jsxs("div",{style:{marginTop:7,padding:"8px 10px",background:"var(--proto-alt)",borderRadius:8,font:`400 10px/1.6 ${H}`,color:y.sub},children:[t.doneWhen,": ",e.doneWhen??t.doneWhenGap]})]})}function XAe({task:e,copy:t,onOpenTask:n,onOpenApprovals:r}){const o=s=>{s.stopPropagation(),r()};return i.jsxs(et,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),children:[i.jsx(lp,{task:e}),i.jsx(Vk,{text:`${t.approvalNeeded} · ${t.openApprovals}`,color:y.amberText,dot:y.amber,onClick:o})]})}function ZAe({task:e,copy:t,onOpenTask:n}){const r=Ok(e),o=r.length>0?`${t.needs} ${r.join(", ")}`:t.waiting;return i.jsxs(et,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),style:{opacity:.8},children:[i.jsx(lp,{task:e,textColor:y.sub}),i.jsx(Vk,{text:o,color:y.muted})]})}function JAe({task:e,copy:t,onOpenTask:n}){const r=e.blockedBy?`${t.blocked} · ${e.blockedBy}`:t.blocked;return i.jsxs(et,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),style:{opacity:.75},children:[i.jsx(lp,{task:e,textColor:y.sub}),i.jsx(Vk,{text:r,color:y.amberText,dot:y.amber,singleLine:!0})]})}function eDe({task:e,onOpenTask:t}){const n=k1(e.completedAt);return i.jsx(et,{radius:11,padding:"10px 13px",onClick:()=>t(e.id),style:{opacity:.7},children:i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0},children:[i.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:y.done,flex:"none"}}),i.jsx(lp,{task:e,textColor:y.sub}),n&&i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.muted,flex:"none"},children:n})]})})}const tDe={"in-progress":YAe,actionable:QAe,"approval-needed":XAe,"waiting-deps":ZAe,blocked:JAe,done:eDe};function nDe({groups:e,scope:t,copy:n,expandedIds:r,onToggleExpand:o,onOpenTask:s,onOpenThread:a,onOpenApprovals:l}){return i.jsx(At,{label:"1d 任务",header:i.jsx(Hx,{title:n.title,qn:t}),children:i.jsxs(Yn,{gap:6,children:[e.length===0&&i.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:y.faint,fontSize:13},children:n.empty}),e.map((c,d)=>{const u=tDe[c.kind];return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsxs(fu,{style:{padding:d===0?"0 2px 2px":"6px 2px 2px"},children:[n[GAe[c.kind]]," · ",c.tasks.length]}),c.tasks.map(p=>i.jsx(u,{task:p,copy:n,expanded:r.has(p.id),onToggle:o,onOpenTask:s,onOpenThread:a,onOpenApprovals:l},p.id))]},c.kind)})]})})}const rDe={en:{title:"Tasks",inProgress:"In progress",actionable:"Actionable",approvalNeeded:"Approval needed",waiting:"Waiting",blocked:"Blocked",claim:"claimed",needs:"needs",doneWhen:"done-when",doneWhenGap:"no done-when recorded",openApprovals:"open approvals",done:"Done",empty:"No tasks"},zh:{title:"任务",inProgress:"进行中",actionable:"可执行",approvalNeeded:"需要审批",waiting:"等待",blocked:"阻塞",claim:"认领",needs:"依赖",doneWhen:"done-when",doneWhenGap:"done-when 未记录",openApprovals:"打开审批",done:"完成",empty:"暂无任务"}};function oDe(){const[e,t]=f.useState(()=>new Set);return{expandedIds:e,toggle:r=>t(o=>{const s=new Set(o);return s.has(r)?s.delete(r):s.add(r),s})}}function iDe(e){const t=he();Nk();const n=ae(t.tasks.list.queryOptions({projectId:e??void 0})),r=n.data??[],o=f.useMemo(()=>PU(r),[r]);return{query:n,groups:o}}function sDe(){const e=Xe(),t=dn(ht(),rDe),{currentProjectId:n}=zt(),{query:r,groups:o}=iDe(n),s=oDe(),a=n?jh(n):void 0;return r.isLoading?i.jsx(At,{label:"1d 任务",children:i.jsx("div",{style:{padding:16,color:y.muted,fontSize:13},children:t.empty})}):i.jsx(nDe,{groups:o,scope:a,copy:t,expandedIds:s.expandedIds,onToggleExpand:s.toggle,onOpenTask:l=>e(`/m/task/${l}`),onOpenThread:l=>e(`/m/thread/${l}`),onOpenApprovals:()=>e("/m/approvals")})}function aDe({copy:e,busy:t,onAdd:n}){const[r,o]=f.useState(""),s=async a=>{a.preventDefault(),a.stopPropagation();const l=r.trim();!l||t||(await n(l),o(""))};return i.jsxs("form",{onSubmit:s,onClick:a=>a.stopPropagation(),style:{display:"flex",alignItems:"center",gap:8,marginTop:9,border:`1px solid ${y.divider}`,borderRadius:9,padding:"6px 10px"},children:[i.jsx("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none",stroke:y.muted,strokeWidth:"1.6",children:i.jsx("path",{d:"M9.8 1.8l2.4 2.4L4.6 11.8l-3 .6.6-3z"})}),i.jsx("input",{value:r,onChange:a=>o(a.target.value),placeholder:e.quickPlaceholder,"aria-label":e.quickPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:11,color:y.ink}})]})}function lDe({vm:e,copy:t,busy:n,onOpen:r,onAdd:o}){return i.jsx("div",{"data-mobile-notes-card":"",children:i.jsxs(et,{tone:"blue",radius:14,padding:"12px 14px",onClick:r,style:{cursor:"pointer"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{style:{fontSize:13.5,fontWeight:650,color:y.ink},children:t.title}),i.jsx("span",{style:{font:`600 10px ${H}`,color:y.sub,background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999},children:e.activeCount}),i.jsx("span",{style:{marginLeft:"auto",fontSize:13,color:y.faint},children:"›"})]}),e.previews.map(s=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:5},children:[i.jsx("span",{style:{width:13,height:13,borderRadius:"50%",border:`1.5px solid ${y.hairline}`,boxSizing:"border-box",flex:"none"}}),i.jsx("span",{style:{fontSize:12,lineHeight:1.55,color:y.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.text})]},s.id)),i.jsx(aDe,{copy:t,busy:n,onAdd:o})]})})}function cDe({label:e,onClick:t}){return i.jsx("button",{type:"button","aria-label":e,onClick:t,style:{display:"flex",alignItems:"center",justifyContent:"center",width:30,height:30,border:"none",background:"transparent",color:y.sub,cursor:"pointer",padding:0},children:i.jsxs("svg",{width:"19",height:"19",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),i.jsx("path",{d:"M19.4 15a1.7 1.7 0 0 0 .34 1.87l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.7 1.7 0 0 0-1.87-.34 1.7 1.7 0 0 0-1 1.55V21a2 2 0 1 1-4 0v-.09a1.7 1.7 0 0 0-1-1.55 1.7 1.7 0 0 0-1.87.34l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.7 1.7 0 0 0 .34-1.87 1.7 1.7 0 0 0-1.55-1H3a2 2 0 1 1 0-4h.09a1.7 1.7 0 0 0 1.55-1 1.7 1.7 0 0 0-.34-1.87l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.7 1.7 0 0 0 1.87.34h.09a1.7 1.7 0 0 0 1-1.55V3a2 2 0 1 1 4 0v.09a1.7 1.7 0 0 0 1 1.55 1.7 1.7 0 0 0 1.87-.34l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.7 1.7 0 0 0-.34 1.87v.09a1.7 1.7 0 0 0 1.55 1H21a2 2 0 1 1 0 4h-.09a1.7 1.7 0 0 0-1.55 1z"})]})})}function dDe({current:e,copy:t}){const n=e.cost,r=n?WU(n.today,n.dailyBudget):null;return i.jsxs(et,{tone:"blue",radius:14,padding:"13px 14px",style:{boxShadow:"var(--focus-ring-accent)"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[i.jsx("div",{style:{width:36,height:36,borderRadius:9,background:y.runBg,color:y.run,display:"flex",alignItems:"center",justifyContent:"center",font:`600 12px ${H}`,flex:"none"},children:e.initials}),i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i.jsx("span",{style:{fontSize:15,fontWeight:650,color:y.ink},children:e.id}),i.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"1.5px 7px",borderRadius:999,background:y.runBg,color:y.run,flex:"none"},children:t.current})]}),i.jsxs("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:2},children:[e.runningThreads," ",t.threadsRunning," · ",e.needsYou," ",t.needsYou]})]})]}),n&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:12},children:[i.jsx("span",{style:{font:`600 20px ${H}`,color:y.ink,letterSpacing:"-.02em"},children:rr(n.today)}),i.jsx("div",{style:{flex:1,height:6,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:i.jsx("div",{style:{width:`${r??0}%`,height:"100%",background:y.run}})}),i.jsxs("span",{style:{font:`400 10px ${H}`,color:y.faint},children:["/ ",rr(n.dailyBudget)," ",t.perDay]})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,marginTop:7,font:`400 10px ${H}`,color:y.faint},children:[i.jsxs("span",{children:[t.week," ",i.jsx("b",{style:{color:y.body},children:rr(n.week)})]}),i.jsxs("span",{children:[t.month," ",i.jsx("b",{style:{color:y.body},children:rr(n.month)})]}),i.jsxs("span",{style:{marginLeft:"auto",color:"var(--proto-amber-text)"},children:[t.forecastToday," ",rr(n.forecastToday)]})]})]})]})}function uDe({pending:e,globalPending:t,waitingThreads:n,copy:r,onClick:o}){return i.jsxs("div",{onClick:o,style:{display:"flex",alignItems:"center",gap:8,border:`1px solid ${y.amberBorder}`,background:y.amberCard,borderRadius:13,padding:"12px 13px",cursor:"pointer"},children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:y.amber,flex:"none"}}),i.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"var(--proto-amber-fg)"},children:[r.approvals," · ",e," ",r.pending]}),i.jsxs("span",{style:{font:`400 9.5px ${H}`,color:"var(--proto-amber-accent)"},children:[t>0?`${t} ${r.globalPending} · `:"",n," ",r.threadsWaiting]}),i.jsxs("span",{style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:y.amberInk},children:[r.handle," ›"]})]})}function pDe({issues:e,copy:t,onClick:n}){const r=e.count-e.previews.length;return i.jsxs(et,{radius:14,padding:"12px 14px",onClick:n,style:{cursor:"pointer"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{style:{fontSize:13.5,fontWeight:650,color:y.ink},children:t.issuesTitle}),i.jsx("span",{style:{font:`600 10px ${H}`,color:y.sub,background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999},children:e.count}),i.jsx("span",{style:{marginLeft:"auto",fontSize:13,color:y.faint},children:"›"})]}),e.previews.map(o=>i.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:y.sub,marginTop:4,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o},o)),r>0&&i.jsxs("div",{style:{font:`400 10px ${H}`,color:y.faint,marginTop:7},children:["+ ",r," more"]})]})}function fDe({label:e,onClick:t,divider:n}){return i.jsxs("div",{onClick:t,style:{display:"flex",alignItems:"center",gap:9,padding:"11px 13px",borderBottom:n?`1px solid ${y.divider}`:void 0,cursor:"pointer"},children:[i.jsx("span",{style:{fontSize:13,color:y.sub,flex:"none"},children:e}),i.jsx("span",{style:{marginLeft:"auto",fontSize:13,color:y.faint,flex:"none"},children:"›"})]})}function hDe({label:e}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 2px 0"},children:[i.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}}),i.jsx("div",{style:{fontSize:9.5,fontWeight:600,letterSpacing:".06em",color:y.faint},children:e}),i.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]})}function mDe({row:e,copy:t,onSwitch:n,divider:r}){const o=e.todayCost!=null?`${t.today} ${rr(e.todayCost)}`:null;return i.jsxs("div",{onClick:()=>n(e.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:r?`1px solid ${y.divider}`:void 0,cursor:"pointer"},children:[i.jsx("div",{style:{width:34,height:34,borderRadius:9,background:y.gray,color:y.sub,display:"flex",alignItems:"center",justifyContent:"center",font:`600 12px ${H}`,flex:"none"},children:e.initials}),i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:14,fontWeight:600,color:y.ink},children:e.id}),i.jsx("div",{style:{display:"flex",alignItems:"center",gap:5,font:`400 10px ${H}`,color:y.muted,marginTop:2},children:e.running>0?i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:y.run,flex:"none"}}),i.jsxs("span",{children:[e.running," ",t.running,o?` · ${o}`:""]})]}):i.jsxs("span",{children:[t.idle,o?` · ${o}`:""]})})]}),e.badgeCount>0&&i.jsx("span",{"aria-label":"project attention",style:{minWidth:18,height:18,padding:"0 6px",borderRadius:999,background:e.badgeTone==="action"?y.amber:y.run,color:"var(--ink-solid-fg)",font:`600 10px ${H}`,display:"flex",alignItems:"center",justifyContent:"center",flex:"none"},children:e.badgeCount}),i.jsx("span",{style:{fontSize:13,color:y.faint,flex:"none"},children:"›"})]})}function gDe({props:e}){const{copy:t,current:n,pendingApprovals:r,globalPendingApprovals:o,issues:s}=e;return i.jsxs(i.Fragment,{children:[n&&i.jsx(dDe,{current:n,copy:t}),r>0&&i.jsx(uDe,{pending:r,globalPending:o,waitingThreads:(n==null?void 0:n.waitingThreads)??0,copy:t,onClick:e.onApprovals}),s.count>0&&i.jsx(pDe,{issues:s,copy:t,onClick:e.onIssues}),i.jsx(lDe,{vm:e.notesVm,copy:e.notesCopy,busy:e.notesBusy,onOpen:e.onNotes,onAdd:e.onAddNote}),i.jsx(et,{radius:13,padding:0,style:{overflow:"hidden"},children:i.jsx(fDe,{label:t.memory,onClick:e.onMemory,divider:!1})})]})}function vDe({props:e}){return e.switchRows.length===0?null:i.jsxs(i.Fragment,{children:[i.jsx(hDe,{label:e.copy.switchProject}),i.jsx(et,{radius:13,padding:0,style:{overflow:"hidden"},children:e.switchRows.map((t,n)=>i.jsx(mDe,{row:t,copy:e.copy,onSwitch:e.onSwitch,divider:n<e.switchRows.length-1},t.id))})]})}const xDe={display:"flex",alignItems:"center",gap:9,background:"var(--proto-card)",border:`1.5px dashed ${y.runBorder}`,borderRadius:13,padding:13,cursor:"pointer"};function yDe({copy:e,onClick:t}){return i.jsxs("div",{onClick:t,style:xDe,children:[i.jsx("span",{style:{color:y.run,display:"flex"},children:i.jsx(gc,{size:14})}),i.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:y.run},children:e.newProject})]})}function bDe(e){const t=i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[i.jsx(C8e,{status:e.rateLimitStatus,onOpen:e.onOpenRateLimit}),i.jsx(cDe,{label:e.copy.settings,onClick:e.onSettings})]});return i.jsx(At,{label:"1e 项目",header:i.jsx(Hx,{title:e.copy.title,trailing:t}),children:i.jsxs(Yn,{gap:10,children:[i.jsx(gDe,{props:e}),i.jsx(vDe,{props:e}),i.jsx(yDe,{copy:e.copy,onClick:e.onNewProject})]})})}const cV=new Set(["running","waiting"]);function wDe(e,t){let n=0,r=0;if(!t)return{running:n,waiting:r};for(const o of e)o.projectId===t&&(cV.has(o.status)&&n++,o.status==="waiting"&&r++);return{running:n,waiting:r}}function SDe(e){return e.reduce((t,n)=>t+(n.online?1:0),0)}function kDe(e){const t={byProject:{},global:0,total:0};for(const n of e)n.status==="pending"&&(t.total++,n.projectId==null?t.global++:t.byProject[n.projectId]=(t.byProject[n.projectId]??0)+1);return t}function jDe(e,t,n,r,o={},s={},a={},l={}){const c=e.filter(d=>d.id!==t);return PH(c,s).map(d=>{const u=n.reduce((v,S)=>v+(S.projectId===d.id&&cV.has(S.status)?1:0),0),p=r==null?void 0:r[d.id],h=o[d.id]??0,m=(a[d.id]??0)+(l[d.id]??0),x=MH(h,m);return{id:d.id,initials:jh(d.id),running:u,todayCost:p?p.today:null,unread:h,actionRequired:m,badgeCount:x.count,badgeTone:x.tone}})}function CDe({name:e,onNameChange:t,onCreate:n,onClose:r,copy:o,error:s,pending:a,behind:l}){const d=BS(e)&&!a;return i.jsxs(li,{onClose:r,behind:l,children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 12px"},children:[i.jsx("span",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em"},children:o.title}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint},children:o.tag})]}),i.jsx("input",{value:e,onChange:u=>t(u.target.value),onKeyDown:u=>{u.key==="Enter"&&d&&n()},placeholder:o.placeholder,autoFocus:!0,style:{width:"100%",height:48,border:"1.5px solid var(--proto-line-3)",borderRadius:13,background:"var(--proto-card)",padding:"0 14px",font:`400 13.5px ${H}`,color:y.ink,boxSizing:"border-box",outline:"none"}}),s&&i.jsx("div",{"data-project-create-error":!0,style:{marginTop:8,fontSize:11,lineHeight:1.5,color:"var(--proto-danger)"},children:s}),i.jsx("button",{type:"button",onClick:n,disabled:!d,"aria-busy":a,style:{width:"100%",height:48,border:"none",borderRadius:13,background:y.ink,color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,marginTop:12,opacity:d?1:.45,cursor:d?"pointer":"default"},children:o.create})]})}function TDe(e,{setCurrentProject:t,close:n,navigate:r}){t(e),n(),r("/m/session/new")}function dV(e,t,n){const r=u_(e,t,n);return{...r,previews:r.active.slice(0,2)}}const PDe={en:{title:"Projects",current:"Current",threadsRunning:"running",needsYou:"need you",perDay:"day",week:"Week",month:"Month",forecastToday:"Forecast",approvals:"Approvals",pending:"pending",globalPending:"global",threadsWaiting:"threads paused",handle:"Review",memory:"Project memory",settings:"Settings",switchProject:"SWITCH PROJECT",running:"running",today:"today",idle:"idle",newProject:"New project",issuesTitle:"Issues"},zh:{title:"项目",current:"当前",threadsRunning:"线程运行中",needsYou:"需要你",perDay:"日",week:"本周",month:"本月",forecastToday:"预测今日",approvals:"审批",pending:"待处理",globalPending:"全局",threadsWaiting:"线程暂停等待",handle:"处理",memory:"项目记忆",settings:"设置",switchProject:"切换项目",running:"运行中",today:"今日",idle:"空闲",newProject:"新建项目",issuesTitle:"Issues"}},EDe={en:{title:"New project",tag:"projects/",placeholder:"Project name, e.g. rl-locomotion",create:"Create and start a chat"},zh:{title:"新建项目",tag:"projects/",placeholder:"项目名字,如 rl-locomotion",create:"创建并开始对话"}};function RDe(e){const t=he();return{projects:ae({...t.projects.list.queryOptions({}),refetchOnMount:!1}).data??[],sessions:wc("direct").data??[],scopedCost:ae({...t.cost.summary.queryOptions({projectId:e||void 0}),enabled:!!e}).data??null,globalCost:ae(t.cost.summary.queryOptions({})).data,threads:ae(t.threads.list.queryOptions({})).data??[],approvals:ae(t.approvals.list.queryOptions({status:"pending"})).data??[],issues:ae({...t.issues.list.queryOptions({projectId:e}),enabled:!!e}).data??[]}}function MDe(e,t,n){return f.useMemo(()=>{if(!e)return null;const r=wDe(t.threads,e);return{id:e,initials:jh(e),runningThreads:r.running,waitingThreads:r.waiting,needsYou:n,cost:t.scopedCost}},[e,t.threads,n,t.scopedCost])}function IDe(e,t,n){const r=f.useMemo(()=>EH(t.sessions),[t.sessions]),o=f.useMemo(()=>RH(t.sessions),[t.sessions]),s=f.useMemo(()=>TH(t.sessions),[t.sessions]);return f.useMemo(()=>{var a;return jDe(t.projects,e,t.threads,(a=t.globalCost)==null?void 0:a.byProject,r,s,o,n)},[t.projects,e,t.threads,t.globalCost,r,s,o,n])}function ADe(e,t,n){const[r,o]=f.useState(!1),[s,a]=f.useState(""),l=f.useCallback(()=>o(!1),[]),c=f.useCallback(m=>{TDe(m,{setCurrentProject:n,close:l,navigate:t})},[l,t,n]),d=g_({onCreated:c}),u=f.useCallback(m=>{a(m),d.clearError()},[d.clearError]),p=f.useCallback(()=>{d.createProject(s)},[d.createProject,s]),h=f.useCallback(()=>{a(""),d.clearError(),o(!0)},[d.clearError]);return{open:r,name:s,setName:u,submit:p,close:l,show:h,copy:dn(e,EDe),error:d.error,pending:d.isPending}}function DDe({rate:e,rateOpen:t,closeRate:n,project:r}){return i.jsxs(i.Fragment,{children:[t&&e&&i.jsx(I8e,{status:e,onClose:n}),r.open&&i.jsx(CDe,{name:r.name,onNameChange:r.setName,onCreate:r.submit,onClose:r.close,copy:r.copy,error:r.error,pending:r.pending})]})}function LDe(){const e=Xe(),t=ht(),{currentProjectId:n,setCurrentProject:r}=zt(),o=n??"";Tk(),zk();const s=RDe(o),{notes:a,busy:l,add:c}=zS(o),d=f.useMemo(()=>dV(a,Date.now(),t),[a,t]),u=f.useMemo(()=>kDe(s.approvals),[s.approvals]),p=o?u.byProject[o]??0:0,h=MDe(o,s,p),m=IDe(o,s,u.byProject),x=OH(),[v,S]=f.useState(!1);f.useEffect(()=>{x||S(!1)},[x]);const b=ADe(t,e,r),g=f.useMemo(()=>({count:s.issues.length,previews:s.issues.slice(0,2).map(C=>C.title)}),[s.issues]),w=C=>{r(C),e("/m/sessions")},k={copy:dn(t,PDe),current:h,pendingApprovals:p+u.global,globalPendingApprovals:u.global,issues:g,notesVm:d,notesCopy:FS[t],notesBusy:l,switchRows:m,rateLimitStatus:x,onOpenRateLimit:()=>S(!0),onIssues:()=>e("/m/issues"),onNotes:()=>e("/m/notes"),onAddNote:c,onApprovals:()=>e("/m/approvals"),onMemory:()=>e("/m/memory"),onSettings:()=>e("/m/settings"),onSwitch:w,onNewProject:b.show};return i.jsxs(i.Fragment,{children:[i.jsx(bDe,{...k}),i.jsx(DDe,{rate:x,rateOpen:v,closeRate:()=>S(!1),project:b})]})}function ODe({vm:e,copy:t,expandedId:n,feedback:r,busy:o,onBack:s,onExpand:a,onFeedback:l,onApprove:c,onReject:d}){return i.jsx(At,{label:"1f 审批",header:i.jsxs(cr,{onBack:s,trailing:i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint},children:"PENDING_APPROVALS.md"}),children:[i.jsx("div",{style:{fontSize:16,fontWeight:650,color:y.ink,letterSpacing:"-.01em",flex:"none"},children:t.title}),i.jsxs(Kn,{tone:"waiting",children:[e.pendingCount," ",t.toProcess]})]}),children:i.jsxs(Yn,{gap:10,children:[e.cards.length===0&&i.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:y.faint,fontSize:13},children:t.empty}),e.groups.map(u=>i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[i.jsx(NDe,{label:u.projectId??t.globalGroup}),u.cards.map(p=>p.id===n?i.jsx(FDe,{card:p,copy:t,feedback:r,busy:o,onFeedback:l,onApprove:c,onReject:d},p.id):i.jsx(zDe,{card:p,copy:t,onExpand:a},p.id))]},u.projectId??"__global__"))]})})}function NDe({label:e}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"2px 2px 0"},children:[i.jsx("div",{style:{fontSize:9.5,fontWeight:600,letterSpacing:".06em",color:y.faint},children:e}),i.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]})}function uV({copy:e,operation:t}){return i.jsxs("span",{style:{fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:999,background:y.amberBg,color:y.amberInk,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.tier," · ",t]})}function FDe({card:e,copy:t,feedback:n,busy:r,onFeedback:o,onApprove:s,onReject:a}){return i.jsxs(et,{tone:"amber",radius:14,padding:0,style:{overflow:"hidden",boxShadow:"var(--shadow-card-raised)"},children:[i.jsxs("div",{style:{padding:"12px 14px 0"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,overflow:"hidden"},children:[e.operation&&i.jsx(uV,{copy:t,operation:e.operation}),i.jsx("span",{style:{font:`400 10px ${H}`,color:"var(--proto-amber-accent)",flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.id}),e.time&&i.jsx("span",{style:{font:`400 10px ${H}`,color:y.faint,flex:"none"},children:e.time})]}),i.jsx("div",{style:{fontSize:14.5,fontWeight:600,color:y.ink,lineHeight:1.4,marginTop:8},children:e.title}),e.reason&&i.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:y.sub,marginTop:4},children:e.reason}),e.impact&&i.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:y.sub,marginTop:4},children:e.impact}),e.command&&i.jsx("div",{style:{marginTop:8,padding:"8px 10px",background:y.amberCard,border:`1px solid ${y.amberBg}`,borderRadius:9,font:`400 10.5px ${H}`,color:"var(--proto-amber-fg)",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e.command}),i.jsxs("div",{style:{fontSize:12,lineHeight:1.55,color:y.sub,marginTop:4},children:[e.provenance&&i.jsxs(i.Fragment,{children:[t.from," ",i.jsx("span",{style:{font:`400 11px ${H}`,color:y.run},children:e.provenance})," · "]}),t.paused]}),i.jsx("textarea",{"data-approval-feedback":!0,value:n,disabled:r,rows:2,onChange:l=>o(l.target.value),placeholder:t.feedbackPlaceholder,"aria-label":t.feedbackPlaceholder,style:{width:"100%",minHeight:58,marginTop:10,padding:"9px 10px",resize:"vertical",border:"1px solid var(--proto-line-3)",borderRadius:9,background:"var(--proto-card)",color:y.ink,font:"400 12px/1.45 inherit",boxSizing:"border-box",opacity:r?.6:1}})]}),i.jsxs("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[i.jsx(pR,{kind:"outline",busy:r,onClick:()=>a(e.id,n),children:t.reject}),i.jsx(pR,{kind:"ink",busy:r,onClick:()=>s(e.id),children:t.approve})]})]})}function pR({kind:e,busy:t,onClick:n,children:r}){const o=e==="ink";return i.jsx("button",{type:"button",disabled:t,onClick:n,style:{flex:1,height:44,borderRadius:11,background:o?y.ink:"var(--proto-card)",color:o?"var(--proto-card)":y.ink,border:o?"none":"1.5px solid var(--proto-line-3)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",fontFamily:"inherit",cursor:t?"not-allowed":"pointer",opacity:t?.6:1},children:r})}function zDe({card:e,copy:t,onExpand:n}){const r=[e.id,e.provenance?`${t.from} ${e.provenance}`:null,t.seeDiff].filter(Boolean).join(" · ");return i.jsxs(et,{radius:14,padding:"11px 14px",onClick:()=>n(e.id),children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,overflow:"hidden"},children:[e.operation&&i.jsx(uV,{copy:t,operation:e.operation}),i.jsx("span",{style:{fontSize:13,fontWeight:600,color:y.body,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),e.time&&i.jsx("span",{style:{font:`400 10px ${H}`,color:y.faint,flex:"none"},children:e.time})]}),i.jsx("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:5,paddingLeft:2},children:r})]})}function BDe(e,t=Date.now(),n=null){const r=e.filter(c=>c.status==="pending"),o=c=>({id:c.id,projectId:c.projectId,operation:c.operation,title:c.title,time:zi(c.queuedAt,t),reason:c.reason,impact:c.impact,command:c.command,provenance:c.provenance}),s=new Map;for(const c of r){const d=c.projectId??"";s.has(d)||s.set(d,[]),s.get(d).push(o(c))}const l=[...s.keys()].sort((c,d)=>{const u=p=>p===n?0:p===""?1:2;return u(c)-u(d)||c.localeCompare(d)}).map(c=>({projectId:c===""?null:c,cards:s.get(c)}));return{pendingCount:r.length,groups:l,cards:l.flatMap(c=>c.cards)}}const $De={en:{title:"Approvals",toProcess:"pending",tier:"Approval",from:"from",paused:"thread paused, waiting",approve:"Approve",reject:"Reject with feedback",feedbackPlaceholder:"Optional feedback",seeDiff:"tap for diff ›",empty:"No pending approvals",globalGroup:"GLOBAL"},zh:{title:"审批",toProcess:"待处理",tier:"审批",from:"来自",paused:"线程已暂停等待",approve:"批准",reject:"拒绝并反馈",feedbackPlaceholder:"可选反馈",seeDiff:"点开看 diff ›",empty:"没有待处理的审批",globalGroup:"全局"}};function _De(e){const t=fo(),n=Th(new URLSearchParams(t.search).get("approvalId"))??null,[r,o]=f.useState(n),[s,a]=f.useState("");return f.useEffect(()=>{o(n),a("")},[n,t.key]),{expandedId:w$(e,r),feedback:s,expand:u=>{a(""),o(u)},setFeedback:a,settle:u=>{u.catch(()=>{}).finally(()=>a(""))}}}function WDe(){const e=Xe(),t=dn(ht(),$De),n=S$(),{currentProjectId:r}=zt(),o=f.useMemo(()=>BDe(n.entries,Date.now(),r),[n.entries,r]),s=_De(o.cards);return i.jsx(ODe,{vm:o,copy:t,expandedId:s.expandedId,feedback:s.feedback,busy:n.isPending,onBack:()=>e("/m/project"),onExpand:s.expand,onFeedback:s.setFeedback,onApprove:a=>s.settle(n.approve(a)),onReject:(a,l)=>s.settle(n.reject(a,l))})}function HDe({cards:e,copy:t,expandedId:n,busy:r,onBack:o,onExpand:s,onDelete:a,onHandle:l}){return i.jsx(At,{label:"24c Issues",header:i.jsxs(cr,{onBack:o,trailing:i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint},children:"ISSUES.md"}),children:[i.jsx("div",{style:{fontSize:16,fontWeight:650,color:y.ink,letterSpacing:"-.01em",flex:"none"},children:t.title}),e.length>0&&i.jsx("span",{style:{font:`600 10px ${H}`,color:y.sub,background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999,flex:"none"},children:e.length})]}),children:i.jsxs(Yn,{gap:10,children:[e.length===0&&i.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:y.faint,fontSize:13},children:t.empty}),e.map(c=>c.id===n?i.jsx(UDe,{card:c,copy:t,busy:r,onDelete:a,onHandle:l},c.id):i.jsx(VDe,{card:c,onExpand:s},c.id)),e.length>0&&i.jsx("div",{style:{marginTop:"auto",display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 0 12px"},children:i.jsx("span",{style:{fontSize:10.5,color:y.faint},children:t.footer})})]})})}function UDe({card:e,copy:t,busy:n,onDelete:r,onHandle:o}){return i.jsxs(et,{tone:"blue",radius:14,padding:0,style:{overflow:"hidden",boxShadow:"var(--shadow-card-raised)"},children:[i.jsxs("div",{style:{padding:"12px 14px 0"},children:[e.date&&i.jsx("div",{style:{display:"flex",alignItems:"center",gap:7},children:i.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${H}`,color:y.faint},children:e.date})}),i.jsx("div",{style:{fontSize:14.5,fontWeight:600,color:y.ink,lineHeight:1.4,marginTop:e.date?8:0},children:e.title}),e.desc&&i.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:y.sub,marginTop:4,whiteSpace:"pre-wrap"},children:e.desc}),e.fields.map((s,a)=>i.jsxs("div",{style:{fontSize:12,lineHeight:1.55,color:y.sub,marginTop:4,whiteSpace:"pre-wrap"},children:[i.jsx("b",{style:{color:y.body},children:s.label}),":",s.text]},`${s.label}-${a}`))]}),i.jsxs("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[i.jsx(fR,{kind:"danger-outline",busy:n,onClick:()=>r(e.id),width:104,children:t.del}),i.jsx(fR,{kind:"accent",busy:n,onClick:()=>o(e.id),children:t.handle})]})]})}function fR({kind:e,busy:t,onClick:n,width:r,children:o}){const s=e==="accent";return i.jsx("button",{type:"button",disabled:t,onClick:n,style:{flex:r?"none":1,width:r,height:44,borderRadius:11,background:s?y.run:"var(--proto-card)",color:s?"var(--ink-solid-fg)":"var(--proto-danger)",border:s?"none":"1.5px solid var(--proto-danger-bg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",fontFamily:"inherit",cursor:t?"not-allowed":"pointer",opacity:t?.6:1},children:o})}function VDe({card:e,onExpand:t}){return i.jsx(et,{radius:14,padding:"11px 14px",onClick:()=>t(e.id),children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[i.jsx("span",{style:{fontSize:13,fontWeight:600,color:y.body,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),e.date&&i.jsx("span",{style:{font:`400 10px ${H}`,color:y.faint,flex:"none"},children:e.date})]})})}const qDe={en:{title:"Issues",del:"Delete",handle:"Handle",empty:"No issues",footer:"Handle = new session carrying this issue · handle / delete removes it"},zh:{title:"Issues",del:"删除",handle:"处理",empty:"没有 issue",footer:"处理 = 新建会话携带此 issue · 处理 / 删除后即离场"}};function KDe(){const e=he(),t=Xe(),n=Ve(),r=ht(),o=dn(r,qDe),{currentProjectId:s}=zt(),a=ae({...e.issues.list.queryOptions({projectId:s??""}),enabled:!!s}),l=f.useMemo(()=>a.data??[],[a.data]),c=f.useMemo(()=>l.map(D$),[l]),[d,u]=f.useState(null);f.useEffect(()=>{u(x=>L$(l,x))},[l]);const p=()=>n.invalidateQueries(e.issues.list.queryFilter()),h=Re(e.issues.delete.mutationOptions({onSettled:p})),m=h.isPending;return i.jsx(HDe,{cards:c,copy:o,expandedId:d,busy:m,onBack:()=>t("/m/project"),onExpand:u,onDelete:x=>s&&h.mutate({projectId:s,id:x}),onHandle:x=>{if(!s)return;const v=l.find(g=>g.id===x);if(!v)return;const S=O$(s,v),b=xh({isDraft:!0,projectId:s});ws(b,{text:S,attachments:[]}),t("/m/session/new"),h.mutate({projectId:s,id:x})}})}const hR=8;function GDe(e){return Math.max(-78,Math.min(0,e))}function YDe(e){return Math.abs(e.deltaX)>Math.abs(e.deltaY)&&e.deltaX<=-48?"delete-open":"closed"}function QDe(e){return Math.abs(e.deltaX)>hR||Math.abs(e.deltaY)>hR}function mR(e,t){return{deltaX:t.clientX-e.x,deltaY:t.clientY-e.y}}function XDe(e,t,n,r){const o=f.useRef(null),s=f.useRef(!1),[a,l]=f.useState(0);return{offset:t?-78:a,onPointerDown:m=>{var x,v;(v=(x=m.currentTarget).setPointerCapture)==null||v.call(x,m.pointerId),s.current=!1,o.current={x:m.clientX,y:m.clientY}},onPointerMove:m=>{if(!o.current)return;const x=mR(o.current,m);Math.abs(x.deltaX)>Math.abs(x.deltaY)&&l(GDe(x.deltaX))},onPointerUp:m=>{if(!o.current)return;const x=mR(o.current,m);s.current=QDe(x),YDe(x)==="delete-open"?r(e):t||r(null),l(0),o.current=null},onPointerCancel:()=>{s.current=!0,l(0),o.current=null},onClick:()=>{if(s.current){s.current=!1;return}r(null),t||n()}}}function pV({completed:e,busy:t,onClick:n}){return i.jsx("button",{type:"button",disabled:t,onClick:r=>{r.stopPropagation(),n()},style:{width:22,height:22,borderRadius:"50%",border:e?0:`2px solid ${y.hairline}`,background:e?y.done:"transparent",color:y.inkSolidFg,padding:0,flex:"none",fontSize:10},children:e?"✓":""})}function ZDe({row:e,copy:t,busy:n,onSave:r,onCancel:o}){const[s,a]=f.useState(e.text),l=async()=>{const c=s.trim();!c||n||(await r(c),o())};return i.jsxs("div",{style:{border:`1px solid ${y.runBorder}`,background:y.card,borderRadius:14,padding:13},children:[i.jsx("input",{value:s,onChange:c=>a(c.target.value),autoFocus:!0,style:{width:"100%",boxSizing:"border-box",height:40,borderRadius:10,border:`1.5px solid ${y.hairline}`,padding:"0 12px",fontSize:14}}),i.jsxs("div",{style:{display:"flex",gap:8,marginTop:9},children:[i.jsx("button",{type:"button",disabled:n,onClick:()=>void l(),style:{flex:1,height:40,border:0,borderRadius:10,background:y.run,color:y.inkSolidFg,fontSize:13,fontWeight:600},children:t.save}),i.jsx("button",{type:"button",disabled:n,onClick:o,style:{width:76,height:40,border:`1px solid ${y.hairline}`,borderRadius:10,background:y.card,color:y.ink,fontSize:13,fontWeight:600},children:t.cancel})]})]})}function JDe({row:e,copy:t,busy:n,actions:r,onEdit:o}){return i.jsxs("div",{style:{display:"flex",gap:8,marginTop:11},children:[i.jsx("button",{type:"button",disabled:n,onClick:()=>r.onHandoff(e.text),style:{flex:1,height:40,border:0,borderRadius:10,background:y.run,color:y.inkSolidFg,fontSize:13,fontWeight:600},children:t.handoff}),i.jsx("button",{type:"button",disabled:n,onClick:o,style:{width:76,height:40,borderRadius:10,border:`1.5px solid ${y.hairline}`,background:y.card,color:y.ink,fontSize:13,fontWeight:600},children:t.edit})]})}function eLe({row:e,copy:t,busy:n,actionOpen:r,swipeOpen:o,actions:s,onActions:a,onSwipe:l,onEdit:c}){const{offset:d,...u}=XDe(e.id,o,()=>a(e.id),l);return i.jsxs("div",{"data-note-click":e.id,"data-note-swipe":e.id,style:{borderRadius:14,overflow:"hidden",background:"var(--proto-danger)",position:"relative"},children:[i.jsx("button",{type:"button",disabled:n,onClick:()=>void s.onDelete(e.id),style:{position:"absolute",right:0,top:0,bottom:0,width:78,border:0,background:"var(--proto-danger)",color:"var(--ink-solid-fg)",fontSize:13,fontWeight:600},children:t.delete}),i.jsxs("div",{...u,style:{transform:`translateX(${d}px)`,transition:d===0||o?"transform 180ms ease":"none",touchAction:"pan-y",border:`1px solid ${r?y.runBorder:y.divider}`,background:y.card,borderRadius:14,padding:"12px 14px",position:"relative"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[i.jsx(pV,{completed:!1,busy:n,onClick:()=>void s.onSetCompleted(e.id,!0)}),i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:{fontSize:14,fontWeight:600,color:y.ink,lineHeight:1.4},children:e.text}),i.jsx("div",{style:{font:`400 10px ${H}`,color:y.faint,marginTop:4},children:e.timeLabel})]})]}),r&&i.jsx(JDe,{row:e,copy:t,busy:n,actions:s,onEdit:c})]})]})}function tLe({row:e,busy:t,onReopen:n}){return i.jsxs("div",{style:{border:`1px solid ${y.hairline}`,background:y.card,borderRadius:14,padding:"11px 14px",display:"flex",alignItems:"center",gap:10,opacity:.7},children:[i.jsx(pV,{completed:!0,busy:t,onClick:n}),i.jsx("span",{style:{fontSize:14,color:y.muted,textDecoration:"line-through",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text}),i.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${H}`,color:y.faint,flex:"none"},children:e.timeLabel})]})}function nLe({copy:e,busy:t,onAdd:n}){const[r,o]=f.useState(""),s=async a=>{a.preventDefault();const l=r.trim();!l||t||(await n(l),o(""))};return i.jsxs("form",{"data-notes-fixed-composer":"",onSubmit:s,style:{flex:"none",borderTop:`1px solid ${y.divider}`,background:y.card,display:"flex",alignItems:"center",gap:8,padding:"10px 14px calc(10px + env(safe-area-inset-bottom))"},children:[i.jsxs("div",{style:{flex:1,height:44,borderRadius:12,border:`1.5px solid ${y.hairline}`,background:y.card,display:"flex",alignItems:"center",gap:9,padding:"0 14px",boxSizing:"border-box"},children:[i.jsx("span",{style:{width:16,height:16,borderRadius:"50%",border:`1.5px solid ${y.hairline}`,boxSizing:"border-box"}}),i.jsx("input",{value:r,onChange:a=>o(a.target.value),placeholder:e.inputPlaceholder,"aria-label":e.inputPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:14,color:y.ink}})]}),i.jsx("button",{type:"submit",disabled:t||!r.trim(),style:{width:44,height:44,borderRadius:12,border:0,background:y.run,color:y.inkSolidFg,fontSize:17,opacity:t||!r.trim()?.45:1},children:"↑"})]})}function rLe(e){const[t,n]=f.useState(null),[r,o]=f.useState(null),[s,a]=f.useState(null),[l,c]=f.useState(!0),d=e;return i.jsx(At,{label:"26c 移动端笔记",header:i.jsxs(cr,{onBack:e.onBack,trailing:i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint},children:"context/NOTES.md"}),children:[i.jsx("span",{style:{fontSize:16,fontWeight:650,color:y.ink},children:e.copy.title}),i.jsx("span",{style:{font:`600 10px ${H}`,color:y.sub,background:y.hairline,padding:"2px 8px",borderRadius:999},children:e.vm.activeCount})]}),footer:i.jsx(nLe,{copy:e.copy,busy:e.busy,onAdd:e.onAdd}),children:i.jsxs(Yn,{gap:9,children:[e.vm.active.map(u=>s===u.id?i.jsx(ZDe,{row:u,copy:e.copy,busy:e.busy,onSave:p=>e.onUpdate(u.id,p),onCancel:()=>a(null)},u.id):i.jsx(eLe,{row:u,copy:e.copy,busy:e.busy,actionOpen:t===u.id,swipeOpen:r===u.id,actions:d,onActions:n,onSwipe:o,onEdit:()=>a(u.id)},u.id)),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px 0"},children:[i.jsxs("button",{type:"button",onClick:()=>c(u=>!u),style:{border:0,padding:0,background:"transparent",fontSize:10,fontWeight:700,letterSpacing:".06em",color:y.muted},children:[e.copy.completed," · ",e.vm.completedCount," ",l?"▾":"▸"]}),e.vm.completedCount>0&&i.jsx("button",{type:"button",disabled:e.busy,onClick:()=>void e.onClearCompleted(),style:{marginLeft:"auto",border:0,background:"transparent",color:"var(--proto-danger)",fontSize:11,fontWeight:600},children:e.copy.clear})]}),l&&e.vm.completed.map(u=>i.jsx(tLe,{row:u,busy:e.busy,onReopen:()=>void e.onSetCompleted(u.id,!1)},u.id))]})})}function oLe(){const e=Xe(),t=ht(),{currentProjectId:n}=zt(),r=n??"",o=zS(r),s=f.useMemo(()=>dV(o.notes,Date.now(),t),[o.notes,t]);return i.jsx(rLe,{vm:s,copy:FS[t],busy:o.busy,onBack:()=>e("/m/project"),onAdd:o.add,onUpdate:o.update,onSetCompleted:o.setCompleted,onDelete:o.delete,onClearCompleted:o.clearCompleted,onHandoff:a=>{M$(r,a),e("/m/session/new")}})}function iLe(){return i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:y.muted,strokeWidth:"1.5",children:[i.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),i.jsx("path",{d:"M8.5 1.5V4H11"})]})}function sLe({vm:e,copy:t,onBack:n,onMore:r}){const o=KO(e.status);return i.jsxs("div",{style:{flex:"none",padding:"8px 14px 0",paddingTop:"calc(8px + env(safe-area-inset-top))",borderBottom:`1px solid ${y.hairline}`,background:y.canvas},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[i.jsx("button",{type:"button","aria-label":"Back",onClick:n,style:{border:"none",background:"transparent",color:y.run,fontSize:15,lineHeight:1,padding:"0 2px",margin:0,cursor:"pointer",flex:"none",minHeight:34,display:"flex",alignItems:"center"},children:"‹"}),i.jsx("span",{style:{font:`600 15px ${H}`,color:y.ink},children:e.name}),i.jsx(Kn,{tone:o,children:t.status[o]}),i.jsx("div",{style:{marginLeft:"auto",flex:"none"},children:i.jsx(qO,{onClick:r})})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,font:`400 9.5px ${H}`,color:"var(--proto-muted-3)",padding:"6px 0 9px 24px",whiteSpace:"nowrap",overflow:"hidden"},children:[e.crumbs.map((s,a)=>i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[i.jsx("span",{style:{color:y.run},children:s.name}),i.jsx("span",{children:"›"})]},a)),i.jsx("span",{style:{color:y.ink,fontWeight:600},children:e.name}),i.jsxs("span",{children:[e.selfLevel!=null?` · L${e.selfLevel}`:""," · ",t.depth," ",e.depthText]})]})]})}function aLe({kind:e,hasConnector:t}){return i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e==="done"&&i.jsx("span",{style:{width:13,height:13,borderRadius:"50%",background:y.doneBg,color:y.done,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:7.5,fontWeight:700,flex:"none"},children:"✓"}),e==="running"&&i.jsx("span",{style:{width:13,height:13,borderRadius:"50%",background:y.run,flex:"none",boxShadow:`0 0 0 3px ${y.runBg}`,animation:"cxpulse 1.6s ease-in-out infinite"}}),e==="pending"&&i.jsx("span",{style:{width:13,height:13,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),t&&i.jsx("span",{style:{flex:1,width:1.5,background:"var(--proto-line-2)",margin:"3px 0"}})]})}function lLe({agent:e}){return i.jsxs("div",{style:{border:"1px solid var(--proto-accent-bg)",background:"var(--proto-rail)",borderRadius:9,padding:"9px 11px",marginTop:6,overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,font:`400 9px ${H}`,color:"var(--proto-muted-3)"},children:[e.live&&i.jsx(Mi,{color:y.run,size:5,pulse:!0}),i.jsx("span",{children:e.turnLabel}),e.cost&&i.jsx("span",{style:{marginLeft:"auto"},children:e.cost})]}),e.text&&i.jsx("div",{style:{fontSize:11,lineHeight:1.65,color:y.sub,marginTop:6,overflowWrap:"break-word",wordBreak:"break-word"},children:i.jsx(ci,{text:e.text})})]})}function cLe({step:e,copy:t,selected:n,onSelect:r}){const o=e.kind==="running",s=n&&(e.kind==="done"||e.kind==="running"),a=o?y.ink:e.kind==="done"?y.sub:y.faint,l=e.kind==="pending"?t.pending:e.time,c=e.kind!=="pending";return i.jsxs(i.Fragment,{children:[i.jsx(aLe,{kind:e.kind,hasConnector:e.hasConnector}),i.jsxs("div",{onClick:c?r:void 0,style:{paddingBottom:e.hasConnector?9:4,minWidth:0,cursor:c?"pointer":void 0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline"},children:[i.jsx("span",{style:{fontSize:11.5,fontWeight:o||n?600:500,color:n?y.ink:a},children:e.name}),e.note&&!s&&i.jsx("span",{style:{fontSize:9,color:"var(--proto-muted-3)",marginLeft:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:e.note}),l&&i.jsx("span",{style:{marginLeft:"auto",font:`400 9px ${H}`,color:o?y.run:y.faint,flex:"none"},children:l}),c&&i.jsx("span",{style:{color:y.faint,fontSize:8,flex:"none",marginLeft:4,transform:s?"rotate(90deg)":void 0,transition:"transform .15s"},children:"▸"})]}),e.agent&&n&&i.jsx(lLe,{agent:e.agent}),e.kind==="done"&&n&&e.sessionId&&i.jsx("div",{style:{border:"1px solid var(--proto-line-2)",background:"var(--proto-rail)",borderRadius:9,padding:"9px 11px",marginTop:6,overflow:"hidden",maxHeight:400,overflowY:"auto",WebkitOverflowScrolling:"touch"},children:i.jsx(s$,{sessionId:e.sessionId,live:!1})})]})]})}function dLe({vm:e,copy:t,onArtifactClick:n}){return i.jsxs("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:12,overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:"1px solid var(--proto-line-2)"},children:[i.jsx("span",{style:{fontSize:12,fontWeight:650,color:y.ink},children:t.artifacts}),i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint,marginLeft:7},children:e.artifactCount})]}),e.artifacts.length===0?i.jsx("div",{style:{padding:"9px 13px",font:`400 10px ${H}`,color:y.faint},children:t.noArtifacts}):e.artifacts.map((r,o)=>i.jsxs("div",{onClick:n?()=>n(r):void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"9px 13px",borderBottom:o<e.artifacts.length-1?"1px solid var(--proto-alt)":void 0,cursor:n?"pointer":void 0},children:[i.jsx(iLe,{}),i.jsx("span",{style:{font:`500 12px ${H}`,color:y.body},children:r.filename}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint},children:r.meta}),n&&i.jsx("span",{style:{color:y.run,fontSize:8,flex:"none"},children:"▸"})]},o))]})}function uLe({vm:e,copy:t,onCancel:n}){return i.jsxs("div",{style:{flex:"none",borderTop:`1px solid ${y.hairline}`,background:"var(--proto-rail)",display:"flex",alignItems:"center",gap:8,padding:"10px 14px 34px",paddingBottom:"calc(14px + env(safe-area-inset-bottom))",minHeight:44,boxSizing:"border-box"},children:[e.live&&i.jsxs(i.Fragment,{children:[i.jsx("div",{title:"Pause has no backend op yet",style:{flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:y.ink,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"not-allowed",opacity:.6},children:t.pause}),i.jsx("button",{type:"button","data-cancel-thread-id":e.tid,onClick:n,style:{flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-danger-bg)",background:"var(--proto-card)",color:y.fail,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:t.cancel})]}),i.jsxs("span",{style:{font:`500 10.5px ${H}`,color:"var(--proto-muted-3)",flex:"none",marginLeft:"auto",paddingLeft:4},children:["Σ ",e.cost]})]})}function pLe({vm:e,copy:t,onBack:n,onMore:r,onCancel:o,onArtifactClick:s}){const a=e.steps.findIndex(p=>p.kind==="running"),l=a>=0?a:e.steps.length-1,[c,d]=f.useState(null),u=c??l;return i.jsx(At,{label:"1g 线程详情",header:i.jsx(sLe,{vm:e,copy:t,onBack:n,onMore:r}),footer:i.jsx(uLe,{vm:e,copy:t,onCancel:o}),children:i.jsxs("div",{style:{padding:"12px 14px 0",display:"flex",flexDirection:"column",gap:10},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,font:`400 10px ${H}`,color:"var(--proto-muted-3)",padding:"0 2px"},children:[i.jsx("span",{children:e.metaParts.join(" · ")}),i.jsx("span",{style:{marginLeft:"auto",color:y.run},children:e.elapsed})]}),i.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:12,padding:"11px 13px 7px"},children:i.jsx("div",{style:{display:"grid",gridTemplateColumns:"15px 1fr",columnGap:8},children:e.steps.map((p,h)=>i.jsx(cLe,{step:p,copy:t,selected:h===u,onSelect:()=>d(h===u?-1:h)},h))})}),i.jsx(dLe,{vm:e,copy:t,onArtifactClick:s}),i.jsx("div",{style:{height:4,flex:"none"}})]})})}function gR(e){return String(e).padStart(2,"0")}function fV(e){const t=Math.max(0,Math.floor(e));return`${gR(Math.floor(t/60))}:${gR(t%60)}`}function fLe(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function hLe(e){const t=e.split("/").filter(Boolean);return t[t.length-1]??e}function mLe(e){if(e.kind==="running")return e.elapsedSeconds==null?"":fV(e.elapsedSeconds);const t=e.durationSeconds;return e.kind==="done"&&t!=null?fLe(t):""}function gLe(e,t){if(e.kind!=="running")return;const n=t.activeProfile??e.step.agentSlotId,r=t.activeOutput??"";return{turnLabel:e.step.numTurns!=null?`turn ${e.step.numTurns} · ${n}`:n,cost:e.step.costUsd!=null?yn(e.step.costUsd):"",lines:r.split(`
443
443
  `).map(o=>o.trim()).filter(Boolean),text:r,live:t.live}}function vLe(e,t,n,r){const o=e.step;return{kind:e.kind,name:o.stage??`#${o.stepIndex+1}`,note:e.kind==="done"?o.outputSummary??"":"",time:mLe(e),hasConnector:t<n,agent:gLe(e,r),sessionId:o.sessionId??null}}function xLe(e,t){const n=e.artifacts.artifactPath;if(!n)return[];const r=hLe(n);return[{filename:r,meta:zi(e.updatedAt,t),wsRelPath:`workspace/threads/${e.id}/${r}`}]}function yLe(e,t){return[e.id,e.activeAgent?`agent ${e.activeAgent}`:null,t].filter(n=>!!n)}function bLe(e,t,n){const r=QF(e,n),o=xLe(e,n);return{name:e.templateName,tid:e.id,status:e.status,live:r.live,crumbs:t.map(s=>({name:s.name,accent:!0})),selfLevel:t.length>0?t.length+1:null,depthText:`${r.depth.level}/${r.depth.limit}`,metaParts:yLe(e,r.machine),elapsed:fV(r.elapsedSeconds),cost:yn(e.totalCostUsd),steps:r.steps.map((s,a)=>vLe(s,a,r.steps.length-1,r)),artifacts:o,artifactCount:o.length}}const wLe={en:{pause:"Pause",cancel:"Cancel",artifacts:"Artifacts",noArtifacts:"No artifacts",pending:"wait",depth:"depth",status:{running:"Running",waiting:"Waiting",done:"Done",failed:"Failed",cancelled:"Cancelled"}},zh:{pause:"暂停",cancel:"取消",artifacts:"产物",noArtifacts:"暂无产物",pending:"待",depth:"深度",status:{running:"运行中",waiting:"等待",done:"完成",failed:"失败",cancelled:"已取消"}}};function SLe(){var p;const{threadId:e=""}=Kx(),t=Xe(),n=fo(),r=ht(),o=dn(r,wLe),s=(((p=n.state)==null?void 0:p.trail)??[]).filter(h=>h.id!==e),a=f.useCallback(()=>t("/m/threads"),[t]),l=c$({threadId:e,includeArtifactContent:!1,onCancelled:a}),{openDoc:c}=Ac(),d=f.useCallback(h=>{const m=xS(h.filename);m&&c({kind:m,name:h.filename,path:h.wsRelPath})},[c]);if(l.loading)return i.jsx(At,{label:"1g 线程详情",children:i.jsx("div",{style:{padding:16,color:y.muted,fontSize:13},children:"…"})});if(l.error)return i.jsx(At,{label:"1g 线程详情",children:i.jsxs("div",{style:{margin:14,background:y.failBg,border:`1px solid ${y.failBorder}`,borderRadius:10,padding:"10px 14px",fontSize:12.5,color:y.fail},children:[e,": ",l.error.message]})});if(!l.detail)return null;const u=bLe(l.detail,s,l.now);return i.jsx(pLe,{vm:u,copy:o,onBack:()=>t(-1),onMore:()=>{},onCancel:l.cancel,onArtifactClick:d})}const kLe={tasksTag:"tasks.json",doneWhen:"DONE-WHEN",doneWhenGap:"done-when 未记录",blockerLabel:"阻塞原因",claimPrefix:"认领",open:"打开 ›",priorityLabel:"优先级",statusLabel:"状态",approvalNeededLabel:"需要审批",approvedAtLabel:"批准时间",completedAtLabel:"完成时间",templateLabel:"模板",depsLabel:"依赖",depsEmpty:"无依赖",historyLabel:"历史",historyEmpty:"暂无派发历史",footer:"只读 — 编辑 / 派发 / 取消在桌面或对话内完成",notFound:"任务未找到",status:{"in-progress":"进行中","approval-needed":"approval-needed",actionable:"可执行",blocked:"阻塞",done:"完成",waiting:"等待"},priority:{high:"P高",medium:"P中",low:"P低"},dispatchStatus:{running:"运行中",completed:"完成",failed:"失败",cancelled:"已取消",stale:"停滞"},dispatchType:{local:"本地",dispatch:"派发"}},jLe={tasksTag:"tasks.json",doneWhen:"DONE-WHEN",doneWhenGap:"no done-when recorded",blockerLabel:"Blocked",claimPrefix:"claimed",open:"open ›",priorityLabel:"Priority",statusLabel:"Status",approvalNeededLabel:"Approval needed",approvedAtLabel:"Approved at",completedAtLabel:"Completed at",templateLabel:"Template",depsLabel:"Depends",depsEmpty:"No dependencies",historyLabel:"History",historyEmpty:"No dispatch history",footer:"Read-only — edit / dispatch / cancel on desktop or in chat",notFound:"Task not found",status:{"in-progress":"In progress","approval-needed":"approval-needed",actionable:"Executable",blocked:"Blocked",done:"Done",waiting:"Waiting"},priority:{high:"High",medium:"Med",low:"Low"},dispatchStatus:{running:"running",completed:"completed",failed:"failed",cancelled:"cancelled",stale:"stale"},dispatchType:{local:"local",dispatch:"dispatch"}},CLe={"in-progress":"running","approval-needed":"waiting",actionable:"running",blocked:"failed",done:"done",waiting:"waiting"},TLe={"in-progress":y.run,"approval-needed":y.amberText,actionable:y.run,blocked:y.fail,done:y.done,waiting:y.amberText};function PLe(){return i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:y.run,strokeWidth:"1.6",style:{flex:"none"},children:[i.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),i.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),i.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),i.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]})}const ELe={display:"flex",alignItems:"center",gap:9,padding:"10px 13px"};function RLe({label:e,reason:t}){return t==null?null:i.jsx("div",{"data-task-blocker-card":"true",children:i.jsxs(et,{tone:"fail",style:{background:y.failBg},children:[i.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".07em",color:y.fail},children:e}),i.jsx("div",{style:{font:`400 11px/1.7 ${H}`,color:y.fail,marginTop:6,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:t})]})})}function MLe({vm:e,copy:t,onBack:n,onOpenThread:r}){if(!e.found)return i.jsx(At,{label:"1h 任务详情",header:i.jsx(cr,{onBack:n,children:i.jsx("span",{style:{font:`600 15px ${H}`,color:y.ink},children:"—"})}),children:i.jsx("div",{style:{padding:16,color:y.muted,fontSize:13},children:t.notFound})});const o=i.jsxs(cr,{onBack:n,trailing:i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint},children:t.tasksTag}),children:[i.jsx("span",{style:{font:`600 15px ${H}`,color:y.ink,flex:"none"},children:e.displayId}),i.jsx(Kn,{tone:CLe[e.statusKind],children:t.status[e.statusKind]})]}),s=[{key:"priority",node:i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{fontSize:12,color:y.muted,width:62,flex:"none"},children:t.priorityLabel}),i.jsx("span",{style:{fontSize:12,color:y.body,fontWeight:600},children:t.priority[e.priority]})]})},{key:"status",node:i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{fontSize:12,color:y.muted,width:62,flex:"none"},children:t.statusLabel}),i.jsx("span",{style:{font:`500 11px ${H}`,color:y.body},children:e.status})]})},{key:"approval-needed",node:i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{fontSize:12,color:y.muted,width:62,flex:"none"},children:t.approvalNeededLabel}),i.jsx("span",{style:{font:`500 11px ${H}`,color:y.body},children:e.approvalNeeded==null?"—":String(e.approvalNeeded)})]})},{key:"approved-at",node:i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{fontSize:12,color:y.muted,width:62,flex:"none"},children:t.approvedAtLabel}),i.jsx("span",{style:{font:`500 11px ${H}`,color:y.body},children:e.approvedAt??"—"})]})},{key:"completed-at",node:i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{fontSize:12,color:y.muted,width:62,flex:"none"},children:t.completedAtLabel}),i.jsx("span",{style:{font:`500 11px ${H}`,color:e.completedAt?y.done:y.body},children:k1(e.completedAt)??"—"})]})},{key:"template",node:i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{fontSize:12,color:y.muted,width:62,flex:"none"},children:t.templateLabel}),i.jsx("span",{style:{font:`500 11px ${H}`,color:y.body,overflowWrap:"anywhere"},children:e.template})]})},{key:"deps",node:i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{fontSize:12,color:y.muted,width:62,flex:"none"},children:t.depsLabel}),i.jsx("span",{style:{display:"flex",flexDirection:"column",gap:3,minWidth:0},children:e.deps.length===0?i.jsx("span",{style:{fontSize:11,color:y.faint},children:t.depsEmpty}):e.deps.map(a=>i.jsxs("span",{style:{font:`500 11px ${H}`,color:a.known?TLe[a.statusKind]:y.faint},children:[a.displayId,a.known?` · ${t.status[a.statusKind]}`:""]},a.id))})]})}];return i.jsx(At,{label:"1h 任务详情",header:o,children:i.jsxs(Yn,{gap:10,children:[i.jsx("div",{style:{fontSize:16,fontWeight:650,color:y.ink,lineHeight:1.45,padding:"0 2px"},children:e.text}),i.jsxs(et,{children:[i.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".07em",color:y.faint},children:t.doneWhen}),i.jsx("div",{style:{font:`400 11px/1.7 ${H}`,color:e.doneWhen?y.sub:y.faint,marginTop:6,whiteSpace:"pre-wrap"},children:e.doneWhen??t.doneWhenGap})]}),i.jsx(RLe,{label:t.blockerLabel,reason:e.blockedBy}),e.claim&&i.jsxs(et,{children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx(PLe,{}),i.jsx("span",{style:{font:`600 12.5px ${H}`,color:y.ink},children:e.claim.template}),i.jsxs("span",{style:{font:`400 9.5px ${H}`,color:y.muted},children:[t.claimPrefix," · ",e.claim.threadId??e.claim.claimedBy]}),e.claim.threadId&&i.jsx("span",{onClick:()=>r(e.claim.threadId),style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:y.run,cursor:"pointer",flex:"none"},children:t.open})]}),e.claim.meta&&i.jsx("div",{style:{font:`400 10px ${H}`,color:y.muted,marginTop:4},children:e.claim.meta})]}),i.jsx(et,{padding:0,style:{overflow:"hidden"},children:s.map((a,l)=>i.jsx("div",{style:{...ELe,borderBottom:l<s.length-1?`1px solid ${y.divider}`:void 0},children:a.node},a.key))}),i.jsxs(et,{padding:0,style:{overflow:"hidden"},children:[i.jsx("div",{style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:"1px solid var(--proto-line-2)"},children:i.jsx("span",{style:{fontSize:12,fontWeight:650,color:y.ink},children:t.historyLabel})}),e.history.length===0?i.jsx("div",{style:{padding:"10px 13px",font:`400 10px ${H}`,color:y.faint},children:t.historyEmpty}):i.jsx("div",{style:{padding:"9px 13px",display:"flex",flexDirection:"column",gap:7,font:`400 10px/1.5 ${H}`},children:e.history.map((a,l)=>i.jsx(ILe,{h:a,copy:t},l))})]}),i.jsx("div",{style:{font:`400 9.5px ${H}`,color:y.faint,padding:"0 4px"},children:t.footer})]})})}function ILe({h:e,copy:t}){const n=zi(e.startedAt),r=`${t.dispatchType[e.type]} · ${t.dispatchStatus[e.status]}`;return i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsx("span",{style:{color:y.faint,flex:"none"},children:n}),i.jsxs("span",{style:{color:y.sub},children:[r,e.isCompleting?" ✓":""]})]})}function ALe(e){if(e==null||!Number.isFinite(e)||e<0)return null;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}const DLe={found:!1,displayId:"",text:"",status:"open",template:"",statusKind:"waiting",priority:"medium",approvalNeeded:null,approvedAt:null,completedAt:null,doneWhen:null,blockedBy:null,claim:null,deps:[],history:[]};function LLe(e,t,n){var a;if(!t.claimed)return null;const r=((a=n==null?void 0:n.newestDispatch)==null?void 0:a.dispatch)??null,o=[],s=ALe((r==null?void 0:r.durationMs)??null);return s&&o.push(s),(r==null?void 0:r.cost)!=null&&o.push(M0(r.cost)),{template:e.template,threadId:t.threadId,claimedBy:t.id,meta:o.length>0?o.join(" · "):null}}function OLe(e){return e.map(t=>({id:t.id,displayId:`T-${t.id}`,statusKind:t.statusKind??"waiting",known:t.known}))}function NLe(e){return(e==null?void 0:e.dispatches.map(({dispatch:t,isCompleting:n})=>({startedAt:t.startedAt,type:t.type,status:t.status,isCompleting:n})))??[]}function FLe(e,t,n,r=Date.now()){const o=t.find(a=>a.id===e);if(!o)return DLe;const s=o_(o,t,n);return{found:!0,displayId:`T-${o.id}`,text:o.text,status:o.status,template:o.template,statusKind:s.statusKind,priority:o.priority,approvalNeeded:o.approvalNeeded??null,approvedAt:o.approvedAt??null,completedAt:s.completedAt,doneWhen:o.doneWhen,blockedBy:o.blockedBy??null,claim:LLe(o,s.claim,s.verification),deps:OLe(s.upstream),history:NLe(s.verification)}}function zLe(){const e=he(),t=Xe(),r=ht()==="zh"?kLe:jLe,{taskId:o}=Kx(),{currentProjectId:s}=zt();Nk();const a=ae(e.tasks.list.queryOptions({projectId:s??void 0})),l=ae({...e.tasks.verification.queryOptions({projectId:s??"",taskId:o??""}),enabled:!!s&&!!o}),c=a.data??[],d=f.useMemo(()=>FLe(o??"",c,l.data??null),[o,c,l.data]);return a.isLoading?i.jsx(At,{label:"1h 任务详情",children:i.jsx("div",{style:{padding:16,color:y.muted,fontSize:13},children:r.notFound})}):i.jsx(MLe,{vm:d,copy:r,onBack:()=>t(-1),onOpenThread:u=>t(`/m/thread/${u}`)})}function BLe(){return i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:y.muted,strokeWidth:"1.5",style:{flex:"none"},children:[i.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),i.jsx("path",{d:"M8.5 1.5V4H11"})]})}function hV({open:e=!1,color:t=y.faint}){return i.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:t,strokeWidth:"1.6",style:{flex:"none",transform:e?"rotate(90deg)":"none",transition:"transform .15s ease"},children:i.jsx("path",{d:"M3.5 1.5 7 5 3.5 8.5"})})}function mV({row:e,last:t,onOpen:n}){return i.jsxs("div",{role:"button",onClick:()=>n(e.path),style:{display:"flex",alignItems:"center",gap:9,padding:"10px 13px",borderBottom:t?void 0:"1px solid var(--proto-alt)",cursor:"pointer"},children:[i.jsx(BLe,{}),i.jsx("span",{style:{font:`500 12px ${H}`,color:y.body,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint,flex:"none"},children:e.time}),i.jsx(hV,{color:y.faint})]})}function gV({children:e}){return i.jsx(et,{tone:"default",padding:0,style:{overflow:"hidden"},children:e})}function $Le({dir:e,copy:t,open:n,onToggle:r,onOpen:o}){return i.jsxs(gV,{children:[i.jsxs("div",{role:"button","aria-expanded":n,onClick:()=>r(e.name),style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:n?"1px solid var(--proto-line-2)":void 0,cursor:"pointer"},children:[i.jsxs("span",{style:{fontSize:12,fontWeight:650,color:y.ink},children:[e.name,"/"]}),i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint,marginLeft:7},children:e.entryCount}),i.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:i.jsx(hV,{open:n})})]}),n&&(e.entries.length===0?i.jsx("div",{style:{padding:"10px 13px",font:`400 11px ${H}`,color:y.faint},children:t.emptyDir}):e.entries.map((s,a)=>i.jsx(mV,{row:s,last:a===e.entries.length-1,onOpen:o},s.path)))]})}function _Le({vm:e,copy:t,openDirs:n,onToggleDir:r,onBack:o,onOpenFile:s}){const a=i.jsx(cr,{onBack:o,trailing:i.jsxs("span",{style:{font:`400 9.5px ${H}`,color:y.faint},children:["memory/ · ",e.fileCount," ",t.filesUnit]}),children:i.jsx("div",{style:{fontSize:16,fontWeight:650,color:y.ink,letterSpacing:"-.01em"},children:t.title})});return i.jsx(At,{label:"1j 项目记忆",header:a,children:i.jsx(Yn,{gap:10,children:e.isEmpty?i.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:y.faint,fontSize:13},children:t.empty}):i.jsxs(i.Fragment,{children:[e.core.length>0&&i.jsxs(gV,{children:[i.jsx("div",{style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:"1px solid var(--proto-line-2)"},children:i.jsx("span",{style:{fontSize:12,fontWeight:650,color:y.ink},children:t.core})}),e.core.map((l,c)=>i.jsx(mV,{row:l,last:c===e.core.length-1,onOpen:s},l.path))]}),e.dirs.map(l=>i.jsx($Le,{dir:l,copy:t,open:n.has(l.name),onToggle:r,onOpen:s},l.name)),i.jsx("div",{style:{font:`400 9.5px ${H}`,color:y.faint,padding:"0 4px"},children:t.footer})]})})})}function WLe(e,t=Date.now()){const n=((e==null?void 0:e.topLevelFiles)??[]).map(o=>({name:o.name,path:o.path,time:zi(o.modifiedAt,t)})),r=((e==null?void 0:e.dirs)??[]).map(o=>({name:o.name,entryCount:o.entryCount,entries:o.entries.map(s=>({name:s.name,path:s.path,time:zi(s.modifiedAt,t)}))}));return{fileCount:(e==null?void 0:e.fileCount)??0,core:n,dirs:r,isEmpty:n.length===0&&r.length===0}}const HLe={en:{title:"Project memory",core:"Core",filesUnit:"files",emptyDir:"Empty",footer:"Tap a file for a read-only preview · agent writes to behavioral content (rules/skills) go through approval",empty:"No project memory yet"},zh:{title:"项目记忆",core:"核心",filesUnit:"个文件",emptyDir:"空",footer:"点文件只读预览 · agent 写入行为性内容(规则/技能)走审批",empty:"暂无项目记忆"}};function ULe(){const e=he(),t=Xe(),n=ht(),r=dn(n,HLe),o=Date.now(),{currentProjectId:s}=zt(),a=ae({...e.memory.tree.queryOptions({projectId:s??""}),enabled:!!s}),l=f.useMemo(()=>UU(a.data),[a.data]),c=f.useMemo(()=>WLe(l,o),[l,o]),[d,u]=f.useState(()=>new Set),p=f.useCallback(h=>{u(m=>{const x=new Set(m);return x.has(h)?x.delete(h):x.add(h),x})},[]);return i.jsx(At,{label:"1j 项目记忆",children:a.isLoading?i.jsx("div",{style:{padding:16,color:y.muted,fontSize:13},children:r.empty}):i.jsx(_Le,{vm:c,copy:r,openDirs:d,onToggleDir:p,onBack:()=>t("/m/project"),onOpenFile:h=>t(`/m/memory/file?path=${encodeURIComponent(h)}`)})})}function VLe({basename:e,metaLine:t,content:n,status:r,copy:o,onBack:s}){return i.jsxs("div",{"data-screen-label":"1j 项目记忆 · 文件",style:{height:"100%",display:"flex",flexDirection:"column",boxSizing:"border-box",background:y.canvas},children:[i.jsx(cr,{onBack:s,children:i.jsxs("div",{style:{minWidth:0},children:[i.jsx("div",{style:{font:`600 14px ${H}`,color:y.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e}),t&&i.jsx("div",{style:{font:`400 10px ${H}`,color:y.faint,marginTop:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t})]})}),i.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",background:"var(--proto-card)"},children:[r==="loading"&&i.jsx("div",{style:{padding:16,font:`400 12px ${H}`,color:y.faint},children:o.loading}),r==="error"&&i.jsx("div",{style:{padding:16,fontSize:12.5,color:y.fail},children:o.error}),r==="empty"&&i.jsx("div",{style:{padding:16,font:`400 12px ${H}`,color:y.faint},children:o.empty}),r==="ready"&&i.jsx("div",{style:{padding:"16px 18px calc(28px + env(safe-area-inset-bottom))",fontSize:13,lineHeight:1.7,color:y.body},children:i.jsx(ci,{text:n})})]})]})}function qLe(e){const t=e.split("/").filter(Boolean);return t.length?t[t.length-1]:e}function KLe(e){return e==null||!Number.isFinite(e)||e<0?"":K3(e,{fractionDigits:1,trimTrailingZeros:!0,maxUnit:"MB"})}function GLe(e,t=Date.now()){if(!e)return"";const n=zi(e.modifiedAt,t),r=KLe(e.sizeBytes);return[e.path,n,r].filter(o=>o&&o.length>0).join(" · ")}const YLe={en:{loading:"Loading file…",error:"Couldn't read this file",empty:"(empty file)"},zh:{loading:"正在加载文件…",error:"无法读取该文件",empty:"(空文件)"}};function QLe(){const e=he(),t=Xe(),n=ht(),r=dn(n,YLe),o=Date.now(),[s]=Hse(),a=s.get("path")??"",{currentProjectId:l}=zt(),c=ae({...e.memory.file.queryOptions({projectId:l??"",path:a}),enabled:!!l&&!!a}),d=c.data,u=qLe(a),p=f.useMemo(()=>GLe(d,o),[d,o]),h=!a||c.isError?"error":c.isLoading||!d?"loading":d.content.length===0?"empty":"ready";return i.jsx(VLe,{basename:u,metaLine:p,content:(d==null?void 0:d.content)??"",status:h,copy:r,onBack:()=>t("/m/memory")})}const Ai={font:`400 9.5px ${H}`,color:y.muted};function XLe({vm:e,copy:t}){return i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,fontSize:10,fontWeight:600,color:y.done},children:[i.jsx(Mi,{color:y.done,size:6}),t.daemon," · ",e.onlineCount,"/",e.total," ",t.onlineWord]})}function ZLe(e){return e>=90?y.fail:e>=75?y.amber:y.run}function vV({percent:e,width:t=40}){return i.jsx("span",{style:{width:t,height:4,borderRadius:2,background:y.divider,overflow:"hidden",flexShrink:0},children:i.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",background:ZLe(e)}})})}function JLe({gpu:e}){return i.jsxs("div",{style:{marginTop:6},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,...Ai},children:[i.jsx("span",{style:{color:y.body,fontWeight:600},children:e.index}),i.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),i.jsx(vV,{percent:e.utilPercent}),i.jsx("span",{style:{color:y.sub},children:e.utilText})]}),i.jsxs("div",{style:{...Ai,color:y.faint,paddingLeft:14,marginTop:2},children:[e.memText," · ",e.tempText," · ",e.powerText,e.owners.length>0&&i.jsxs("span",{style:{color:y.run},children:[" · ",e.owners.join(" ")]})]}),e.processes.length>0&&i.jsxs("div",{style:{...Ai,color:y.faint,paddingLeft:14,marginTop:2},children:[e.processes.map(t=>`${t.name} ${t.memText}`).join(" · "),e.hiddenProcessCount>0&&` +${e.hiddenProcessCount}`]})]})}function eOe({run:e}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,...Ai,marginTop:5},children:[i.jsx(Mi,{color:y.run,size:5,pulse:!0}),i.jsx("span",{style:{color:y.body,fontWeight:600},children:e.label}),e.gpuText&&i.jsx("span",{style:{color:y.sub},children:e.gpuText}),e.duration&&i.jsx("span",{style:{marginLeft:"auto",color:y.faint},children:e.duration})]})}function Td({text:e,tone:t}){return i.jsx("div",{style:{...Ai,color:t==="fail"?y.fail:y.faint,marginTop:6},children:e})}function xV({card:e,copy:t,uptime:n}){const r=[];return e.connectedFor&&r.push(`${t.up} ${e.connectedFor}`),n&&r.push(`${t.uptime} ${n}`),e.sshConfigured&&r.push("ssh ✓"),e.capabilities.length>0&&r.push(e.capabilities.join(",")),i.jsxs("div",{style:{marginTop:8,paddingTop:7,borderTop:`1px solid ${y.divider}`},children:[i.jsx("div",{style:{...Ai,color:y.faint},children:r.join(" · ")}),e.cortexPath&&i.jsxs("div",{style:{...Ai,color:y.faint,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[t.path," ",e.cortexPath]})]})}function tOe({panel:e,copy:t}){if(e.status==="probing")return i.jsx(Td,{text:t.probing});if(e.status==="error"||!e.vm)return i.jsx(Td,{text:t.probeFailed,tone:"fail"});const{meters:n,gpus:r,liveRuns:o,probeError:s}=e.vm;return i.jsxs(i.Fragment,{children:[s&&i.jsx(Td,{text:`${t.probeFailed}: ${s}`,tone:"fail"}),n.length>0&&i.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap",marginTop:6},children:n.map(a=>i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,...Ai},children:[i.jsx("span",{style:{color:y.faint},children:a.label}),i.jsx(vV,{percent:a.percent,width:30}),i.jsx("span",{children:a.text})]},a.key))}),r.map(a=>i.jsx(JLe,{gpu:a},a.index)),!s&&r.length===0&&i.jsx(Td,{text:t.noGpu}),o.map(a=>i.jsx(eOe,{run:a},a.key))]})}function nOe({card:e,copy:t,expanded:n,panel:r,onToggle:o}){return i.jsx(et,{tone:"default",padding:0,style:{overflow:"hidden"},children:i.jsxs("div",{role:"button","aria-expanded":n,onClick:()=>o(e.name),style:{padding:"11px 13px 9px"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{style:{font:`600 12.5px ${H}`,color:y.ink},children:e.name}),i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint},children:e.os}),i.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:i.jsx(Kn,{tone:"done",children:t.online})})]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,...Ai,marginTop:4},children:[i.jsxs("span",{children:[t.hb," ",e.heartbeat,e.gpuCount!==null&&e.gpuCount>0&&` · ${e.gpuCount} ${t.gpu}`,e.liveRuns>0&&` · ${e.liveRuns} ${t.running}`]}),e.liveRuns>0&&i.jsx("span",{style:{marginLeft:"auto",display:"inline-flex"},children:i.jsx(Mi,{color:y.run,size:6,pulse:!0})})]}),n&&i.jsxs(i.Fragment,{children:[r?i.jsx(tOe,{panel:r,copy:t}):i.jsx(Td,{text:t.probing}),i.jsx(xV,{card:e,copy:t,uptime:(r==null?void 0:r.uptime)??""})]})]})})}function vR({children:e,onClick:t}){return i.jsx("button",{type:"button",onClick:t,style:{flex:1,height:38,borderRadius:10,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:y.ink,fontSize:12.5,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:e})}function rOe({card:e,copy:t,expanded:n,onToggle:r,onRetry:o,onLogs:s}){return i.jsxs(et,{tone:"fail",padding:"11px 13px",children:[i.jsxs("div",{role:"button","aria-expanded":n,onClick:()=>r(e.name),children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{style:{font:`600 12.5px ${H}`,color:y.sub},children:e.name}),i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.faint},children:e.os}),i.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:i.jsx(Kn,{tone:"failed",children:t.offline})})]}),i.jsxs("div",{style:{...Ai,marginTop:4},children:[t.lastHb," ",e.heartbeat]}),n&&i.jsxs(i.Fragment,{children:[i.jsx(Td,{text:t.offlineNoTelemetry}),i.jsx(xV,{card:e,copy:t,uptime:""})]})]}),i.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[i.jsx(vR,{onClick:o?()=>o(e.name):void 0,children:t.retry}),i.jsx(vR,{onClick:s?()=>s(e.name):void 0,children:t.logs})]})]})}function oOe({vm:e,copy:t}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"2px 4px",font:`400 9.5px ${H}`,color:y.faint},children:[i.jsxs("span",{children:["machines.json · ",e.total," ",t.registered]}),i.jsx("span",{style:{marginLeft:"auto",color:y.muted},children:t.editDesktop})]})}function iOe({vm:e,copy:t,onBack:n,expanded:r,onToggle:o,panel:s,onRetry:a,onLogs:l,onAdd:c,addDisabled:d}){return i.jsxs(i.Fragment,{children:[i.jsx(cr,{onBack:n,trailing:i.jsx(XLe,{vm:e,copy:t}),children:i.jsx("div",{style:{fontSize:16,fontWeight:650,color:y.ink,letterSpacing:"-.01em"},children:t.title})}),i.jsxs(Yn,{gap:10,children:[e.cards.length===0&&i.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:y.faint,fontSize:13},children:t.empty}),e.cards.map(u=>u.online?i.jsx(nOe,{card:u,copy:t,expanded:r===u.name,panel:r===u.name?s:null,onToggle:o},u.name):i.jsx(rOe,{card:u,copy:t,expanded:r===u.name,onToggle:o,onRetry:a,onLogs:l},u.name)),c&&i.jsx("button",{type:"button","data-machine-add":!0,onClick:c,disabled:d,style:{border:`1px solid ${y.runBorder}`,borderRadius:9,padding:"9px 12px",background:y.runBg,color:y.run,fontSize:11,fontWeight:650},children:t.add}),e.cards.length>0&&i.jsx(oOe,{vm:e,copy:t})]})]})}function sOe(e,t){if(!e)return"—";const n=Date.parse(e);if(Number.isNaN(n))return"—";const r=t-n;if(r<0)return"—";const o=Math.floor(r/1e3);if(o<60)return`${o}s 前`;const s=Math.floor(o/60);if(s<60)return`${s}m 前`;const a=Math.floor(s/60);return a<24?`${a}h 前`:`${Math.floor(a/24)}d 前`}function aOe(e){return{name:e.name,online:e.online,liveRuns:e.liveRuns,gpuCount:e.gpuCount,os:e.os,connectedAt:e.online?e.connectedAt:null}}function lOe(e,t=Date.now()){const n=e.map(r=>{const o=aOe(r);return{name:o.name,online:o.online,os:o.os,gpuCount:o.gpuCount,liveRuns:o.liveRuns,heartbeat:sOe(r.lastHeartbeat,t),connectedFor:wv(r.connectedAt,t),capabilities:r.capabilities,cortexPath:r.cortexPath,sshConfigured:r.sshConfigured}});return{cards:n,onlineCount:n.filter(r=>r.online).length,total:n.length}}const cOe={en:{title:"Machines",online:"Online",offline:"Offline",hb:"HB",lastHb:"last HB",gpu:"GPU",running:"running",daemon:"daemon",onlineWord:"online",retry:"Retry",logs:"Logs",registered:"registered",editDesktop:"edit on desktop",add:"Add machine",empty:"No machines",probing:"Probing…",probeFailed:"Probe failed",noGpu:"No GPU reported",offlineNoTelemetry:"Offline — no live telemetry",up:"up",uptime:"uptime",path:"path"},zh:{title:"机器",online:"在线",offline:"离线",hb:"心跳",lastHb:"上次心跳",gpu:"GPU",running:"运行中",daemon:"daemon",onlineWord:"在线",retry:"重试连接",logs:"查看日志",registered:"台注册",editDesktop:"编辑走桌面设置",add:"添加机器",empty:"暂无机器",probing:"探测中…",probeFailed:"探测失败",noGpu:"未检测到 GPU",offlineNoTelemetry:"离线 — 无实时数据",up:"已连接",uptime:"运行时长",path:"路径"}};function dOe(e){return!e||e.status==="offline"?null:e.status==="error"?{status:"error",vm:null,uptime:""}:e.status==="probing"?{status:"probing",vm:null,uptime:""}:{status:"ready",vm:e.facts,uptime:e.uptime}}function uOe(e){const t=O(),{toast:n}=Fn();return async()=>{var o;const r=(o=window.prompt(t.stAddMachinePrompt))==null?void 0:o.trim();if(r)try{await e.requestAddMachine(r),n({title:t.stToastQueuedApproval,tone:"waiting"})}catch(s){const a=s instanceof Error?s.message:String(s);n({title:`${t.stToastCouldNotQueue}: ${a}`,tone:"failed"})}}}function pOe(){const e=Xe(),t=dn(ht(),cOe),[n,r]=f.useState(null),o=lh(n?[n]:[]),s=f.useMemo(()=>lOe(o.machines,Date.now()),[o.machines]),a=dOe(n?o.detailFor(n):void 0),l=uOe(o);return i.jsx(At,{label:"1k 机器",children:o.loading?i.jsx("div",{style:{padding:16,color:y.muted,fontSize:13},children:t.empty}):i.jsx(iOe,{vm:s,copy:t,onBack:()=>e("/m/settings"),expanded:n,onToggle:c=>r(d=>d===c?null:c),panel:a,onAdd:l,addDisabled:o.addPending})})}function i2(e,t){var r;const n=(r=Gn(Ku(e.settings),t))==null?void 0:r.value;return typeof n=="boolean"?n:null}function fOe(e){const t=[];return gu(e.env,"SLACK_")&&t.push("slack"),gu(e.env,"FEISHU_")&&t.push("feishu"),t}function hOe(e,t){var c,d;const n=e.profiles,r=(n==null?void 0:n.defaultProfile)??null,o=r?(n==null?void 0:n.profiles.find(u=>u.name===r))??null:null,s=((c=e.budget)==null?void 0:c.daily_usd)??null,a=0,l=[i2(e,"turnNotify"),i2(e,"autoResume"),i2(e,"notifyCompaction")];return{daemonHost:null,profileName:r,profileModel:(o==null?void 0:o.model)??null,profileThinking:(o==null?void 0:o.thinking)??null,profiles:(n==null?void 0:n.profiles)??[],budgetSpendLabel:`${M0(a)} / ${M0(s)}`,budgetBarPct:kv(a,s),notifyOn:l[0],autoResumeOn:l[1],notifyEnabledCount:l.some(u=>u!==null)?l.filter(u=>u===!0).length:null,platforms:fOe(e),templatesCount:e.threadTemplates.templates.length,pluginsCount:null,mcpServers:((d=e.mcp)==null?void 0:d.servers)??[],hooks:e.hooks}}const mOe=new Set(["templates","plugins"]),gOe=new Set(["hooks"]),qk={fontSize:14,fontWeight:600,color:y.ink},yV={font:`400 10px ${H}`,color:y.muted,marginTop:2};function vOe({children:e}){return i.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"2px 7px",borderRadius:999,background:y.gray,color:y.grayInk,flex:"none"},children:e})}function xOe(e){const t=O(),n=Z$(e.connectionStatus);return i.jsxs("button",{type:"button",onClick:e.onOpenDaemon,"data-settings-daemon":!0,style:{width:"100%",border:0,background:"transparent",padding:"12px 13px",display:"flex",alignItems:"center",gap:10,textAlign:"left"},children:[i.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:n.color,animation:n.pulse?"cxpulse 1.6s ease-in-out infinite":void 0}}),i.jsx("span",{style:qk,children:e.copy.daemon}),i.jsx("span",{style:{marginLeft:"auto",fontSize:10,color:n.color},children:t[J$(e.connectionStatus)]}),i.jsx("span",{style:{color:y.faint},children:"›"})]})}function yOe(e){return[e.profileName,e.profileModel,e.profileThinking].filter(Boolean).join(" · ")||void 0}function bOe(e){const t=O(),n=yOe(e.vm);return i.jsx(et,{padding:0,children:i.jsxs("button",{type:"button","data-settings-entry":"profiles",onClick:()=>e.onOpenSection("profiles"),style:{width:"100%",border:0,background:"transparent",padding:"12px 13px",display:"flex",alignItems:"center",gap:10,textAlign:"left"},children:[i.jsx("span",{style:{width:34,height:34,borderRadius:9,background:y.runBg,color:y.run,display:"flex",alignItems:"center",justifyContent:"center",font:`600 11px ${H}`,flex:"none"},children:"P"}),i.jsxs("span",{style:{minWidth:0,flex:1},children:[i.jsx("span",{style:{...qk,display:"block"},children:t.stNavProfiles}),n&&i.jsx("span",{style:{...yV,display:"block"},children:n})]}),i.jsx("span",{style:{font:`500 10px ${H}`,color:y.run,flex:"none"},children:e.copy.switchProfile})]})})}function wOe(e){return{machines:`${e.onlineMachines} ${e.copy.machinesOk}`}}function SOe(e){const t=mOe.has(e.section),n=t?e.copy.desktopOnly:gOe.has(e.section)?e.copy.inspectOnly:null,r=t?void 0:()=>e.onOpen(e.section);return i.jsxs("button",{type:"button","data-settings-entry":e.section,onClick:r,"aria-disabled":t||void 0,style:{width:"100%",border:0,borderBottom:e.last?void 0:`1px solid ${y.divider}`,background:"transparent",padding:"12px 13px",display:"flex",alignItems:"center",gap:9,textAlign:"left",cursor:r?"pointer":"default"},children:[i.jsxs("span",{style:{minWidth:0,flex:1},children:[i.jsx("span",{style:{...qk,display:"block"},children:e.label}),e.summary&&i.jsx("span",{style:{...yV,display:"block"},children:e.summary})]}),n&&i.jsx(vOe,{children:n}),r&&i.jsx("span",{style:{color:y.faint,fontSize:15},children:"›"})]})}function kOe(e){const t=O(),n=AN(t).filter(o=>o.key!=="profiles"),r=wOe(e);return i.jsx(et,{padding:0,style:{overflow:"hidden"},children:n.map((o,s)=>i.jsx(SOe,{section:o.key,label:o.label,summary:r[o.key],copy:e.copy,last:s===n.length-1,onOpen:e.onOpenSection},o.key))})}function jOe({copy:e}){return i.jsxs("div",{style:{display:"flex",gap:7,padding:"2px 4px",font:`400 9.5px ${H}`,color:y.faint},children:[i.jsx("span",{children:e.footerBrand}),i.jsxs("span",{style:{marginLeft:"auto"},children:["build ",$S]})]})}function COe(e){return i.jsx(At,{label:"1l Settings",header:i.jsx(cr,{onBack:e.onBack,children:i.jsx("div",{style:{fontSize:16,fontWeight:650,color:y.ink},children:e.copy.title})}),children:i.jsxs(Yn,{gap:10,children:[i.jsx(et,{padding:0,children:i.jsx(xOe,{copy:e.copy,connectionStatus:e.connectionStatus,onOpenDaemon:e.onOpenDaemon})}),i.jsx(bOe,{...e}),i.jsx(kOe,{...e}),i.jsx(jOe,{copy:e.copy})]})})}const TOe={en:{title:"Settings",daemon:"Daemon",machinesOk:"online",desktopOnly:"Edit on desktop",inspectOnly:"View only",footerBrand:"cortex mobile",switchProfile:"Switch"},zh:{title:"设置",daemon:"Daemon",machinesOk:"台在线",desktopOnly:"桌面编辑",inspectOnly:"仅查看",footerBrand:"cortex mobile",switchProfile:"切换"}},POe={budget:null,profiles:null,mcp:null,threadTemplates:{agents:[],templates:[],shells:[]},hooks:[],env:[],settings:[]},EOe={appearance:"/m/settings/appearance",platform:"/m/settings/platform",accounts:"/m/settings/accounts",profiles:"/m/settings/profiles",budget:"/m/settings/budget",usage:"/m/settings/usage",machines:"/m/machines",templates:"/m/settings/templates",plugins:"/m/settings/plugins",mcp:"/m/settings/mcp",notifications:"/m/settings/notifications",hooks:"/m/settings/hooks",advanced:"/m/settings/advanced"};function ROe(){const e=he(),t=Xe(),n=dn(ht(),TOe),r=OS(),o=ae(e.config.get.queryOptions({})),s=lh(),a=f.useMemo(()=>hOe(o.data??POe),[o.data]);return i.jsx(COe,{vm:a,copy:n,connectionStatus:r,onlineMachines:SDe(s.machines),onBack:()=>t("/m/project"),onOpenDaemon:()=>t("/m/daemon"),onOpenSection:l=>t(EOe[l])})}function Aw(e,t,n){return t==="api_key"?e.authLoginApiKey:n==="claude"?e.authLoginSubscription:e.authLoginOAuth}function bV({value:e}){const t=O();return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0},children:[i.jsx("span",{children:i.jsx(Kn,{tone:e.tone,children:t[e.labelKey]})}),i.jsxs("span",{style:{font:`400 9.5px ${H}`,color:y.muted,overflowWrap:"anywhere"},children:[t.accountsSource,": ",e.source??"—"]}),e.expiresAt?i.jsxs("span",{style:{font:`400 9.5px ${H}`,color:y.muted,overflowWrap:"anywhere"},children:[t.accountsExpires,": ",e.expiresAt]}):null]})}function xR({children:e,target:t,action:n,disabled:r,onClick:o}){return i.jsx("button",{type:"button","data-auth-action":n,"data-backend":t.backend,"data-provider":t.provider,"data-auth-type":t.authType,disabled:r,onClick:()=>o(t),style:{border:`1px solid ${n==="logout"?"var(--proto-danger-bg)":y.run}`,borderRadius:8,padding:"6px 9px",background:y.card,color:n==="logout"?y.fail:y.run,fontSize:10.5,fontWeight:650,cursor:r?"not-allowed":"pointer",opacity:r?.45:1},children:e})}function wV({backend:e,provider:t,loginTypes:n,logoutTypes:r,disabled:o,onLogin:s,onLogout:a}){const l=O(),c=d=>({backend:e,provider:t,authType:d});return i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginTop:8},children:[n.map(d=>i.jsxs(xR,{target:c(d),action:"login",disabled:o,onClick:s,children:[l.accountsLogin," ",Aw(l,d,e)]},`login:${d}`)),r.map(d=>i.jsxs(xR,{target:c(d),action:"logout",disabled:o,onClick:a,children:[l.accountsLogout," ",Aw(l,d,e)]},`logout:${d}`))]})}function MOe({account:e,actionsDisabled:t,onLogin:n,onLogout:r}){const o=O();return i.jsxs(et,{children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:9},children:[i.jsx(Xu,{provider:"claude-code",label:"Claude Code",size:16}),i.jsx("span",{style:{fontSize:14,fontWeight:700,color:y.ink},children:"Claude Code"}),e.inUse?i.jsx(Kn,{tone:"done",children:o.accountsInUse}):null]}),e.slots.map((s,a)=>i.jsxs("div",{style:{padding:"9px 0",borderTop:a>0?`1px solid ${y.divider}`:void 0},children:[i.jsx("div",{style:{font:`600 11px ${H}`,color:y.ink,marginBottom:7},children:Aw(o,s.authType,"claude")}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:7},children:s.credentials.map((l,c)=>i.jsx(bV,{value:l},`${l.source??"none"}:${c}`))}),i.jsx(wV,{backend:"claude",provider:e.provider,loginTypes:s.canLogin?[s.authType]:[],logoutTypes:s.canLogout?[s.authType]:[],disabled:t,onLogin:n,onLogout:r})]},s.authType))]})}function IOe({provider:e,actionsDisabled:t,onLogin:n,onLogout:r}){const o=O(),s={...e.status,source:e.source,expiresAt:e.expiresAt};return i.jsxs(et,{children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[i.jsx(Xu,{provider:e.provider,label:e.label,size:15}),i.jsx("span",{style:{fontSize:13,fontWeight:700,color:y.ink},children:e.label}),i.jsx("span",{style:{font:`400 9px ${H}`,color:y.muted},children:e.provider}),e.loginTypes.map(a=>i.jsx(Kn,{tone:"running",children:a==="api_key"?o.authLoginApiKey:o.authLoginOAuth},a))]}),i.jsx("div",{style:{marginTop:8},children:i.jsx(bV,{value:s})}),i.jsx(wV,{backend:"pi",provider:e.provider,loginTypes:e.loginTypes,logoutTypes:e.logoutTypes,disabled:t,onLogin:n,onLogout:r})]})}function AOe({provider:e,editDisabled:t,deleteDisabled:n,confirming:r,onEdit:o,onDelete:s}){const a=O();return i.jsxs(et,{children:[i.jsxs("div",{"data-custom-provider":e.name,style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[i.jsx("span",{style:{fontSize:13,fontWeight:700,color:y.ink},children:e.name}),i.jsx("span",{style:{font:`400 9px ${H}`,color:y.muted},children:e.api}),e.routed?null:i.jsx(Kn,{tone:"waiting",children:a.cpvUnrouted}),i.jsx(Kn,{tone:"cancelled",children:e.hasApiKey?a.cpvKeyStored:a.cpvNoKey})]}),i.jsxs("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.muted,overflowWrap:"anywhere"},children:e.upstreamUrl??"—"}),i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.muted,overflowWrap:"anywhere"},children:e.models.map(l=>l.id).join(", ")})]}),i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginTop:8},children:[i.jsx("button",{type:"button","data-cpv-action":"edit","data-cpv-provider":e.name,disabled:t,onClick:o,style:{border:`1px solid ${y.run}`,borderRadius:8,padding:"6px 9px",background:y.card,color:y.run,fontSize:10.5,fontWeight:650,cursor:t?"not-allowed":"pointer",opacity:t?.45:1},children:a.cpvEdit}),i.jsx("button",{type:"button","data-cpv-action":"delete","data-cpv-provider":e.name,disabled:n,onClick:s,style:{border:"1px solid var(--proto-danger-bg)",borderRadius:8,padding:"6px 9px",background:y.card,color:y.fail,fontSize:10.5,fontWeight:650,cursor:n?"not-allowed":"pointer",opacity:n?.45:1},children:r?a.cpvConfirmDelete:a.cpvDelete})]})]})}function DOe({vm:e,onBack:t,onLogin:n,onLogout:r,actionsDisabled:o,custom:s,onRescan:a,rescanning:l}){const c=O(),d=a?i.jsx("button",{type:"button","data-accounts-sync":!0,disabled:l,onClick:a,style:{border:`1px solid ${y.hairline}`,borderRadius:8,padding:"5px 8px",background:y.card,color:y.run,fontSize:10,fontWeight:650},children:c.accountsSyncModels}):i.jsxs("span",{style:{font:`500 10px ${H}`,color:y.muted},children:[e.piProviders.length," PI"]}),u=i.jsx(cr,{onBack:t,trailing:d,children:i.jsx("div",{style:{fontSize:16,fontWeight:650,color:y.ink},children:c.accountsTitle})});return i.jsx(At,{label:c.accountsTitle,header:u,children:i.jsxs(Yn,{gap:14,children:[e.claude?i.jsx(MOe,{account:e.claude,actionsDisabled:o,onLogin:n,onLogout:r}):null,e.groups.map(p=>i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs(fu,{children:[c[p.labelKey]," · ",p.providers.length]}),p.providers.map(h=>i.jsx(IOe,{provider:h,actionsDisabled:o,onLogin:n,onLogout:r},h.provider))]},p.key)),e.piProviders.length===0?i.jsx(et,{children:i.jsx("span",{style:{fontSize:12,color:y.muted},children:c.accountsNoProviders})}):null,s?i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs(fu,{children:[c.cpvTitle," · ",s.providers.length,i.jsx("button",{type:"button","data-cpv-action":"new",disabled:s.savePending,onClick:s.onNew,style:{marginLeft:8,border:`1px solid ${y.run}`,borderRadius:8,padding:"3px 8px",background:y.card,color:y.run,fontSize:10,fontWeight:650,cursor:"pointer"},children:c.cpvNew})]}),s.providers.length>0?s.providers.map(p=>i.jsx(AOe,{provider:p,editDisabled:s.savePending,deleteDisabled:s.removePending,confirming:s.confirmingDelete===p.name,onEdit:()=>s.onEdit(p),onDelete:()=>s.onDelete(p.name)},p.name)):i.jsx(et,{children:i.jsx("span",{style:{fontSize:12,color:y.muted},children:c.cpvNone})})]}):null]})})}const Dp={width:"100%",border:"1.5px solid var(--proto-line-3)",borderRadius:13,background:"var(--proto-card)",padding:"11px 14px",font:`400 13.5px ${H}`,color:y.ink,boxSizing:"border-box",outline:"none"};function Lp({label:e,hint:t,danger:n,children:r}){return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5,marginBottom:11},children:[i.jsx("span",{style:{font:`600 10px ${H}`,color:y.muted},children:e}),r,t?i.jsx("span",{style:{font:`400 9.5px ${H}`,color:n?y.fail:y.faint},children:t}):null]})}function LOe({draft:e,creating:t,errors:n,pending:r,onChange:o,onSave:s,onClose:a,behind:l}){const c=O(),d=h=>o({...e,...h}),u=(h,m)=>RF(n[h],c)??m,p=q3(n)&&!r;return i.jsxs(li,{onClose:a,behind:l,children:[i.jsx("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 12px"},children:i.jsx("span",{style:{fontSize:17,fontWeight:700,color:y.ink,letterSpacing:"-.01em"},children:t?c.cpvCreateTitle:c.cpvEditTitle})}),i.jsx(Lp,{label:c.cpvFieldName,hint:u("name",t?c.cpvNameHint:c.cpvNoRename),danger:!!n.name,children:i.jsx("input",{"data-cpv-field":"name",value:e.name,disabled:!t,onChange:h=>d({name:h.target.value}),style:{...Dp,opacity:t?1:.55}})}),i.jsx(Lp,{label:c.cpvFieldApi,hint:c.cpvApiHint,children:i.jsx("select",{"data-cpv-field":"api",value:e.api,onChange:h=>d({api:h.target.value}),style:Dp,children:PF.map(h=>i.jsx("option",{value:h,children:h},h))})}),i.jsx(Lp,{label:c.cpvFieldUrl,hint:u("upstreamUrl",c.cpvUrlHint),danger:!!n.upstreamUrl,children:i.jsx("input",{"data-cpv-field":"url",value:e.upstreamUrl,onChange:h=>d({upstreamUrl:h.target.value}),style:Dp})}),i.jsx(Lp,{label:c.cpvFieldKey,hint:c.cpvKeyHint,children:i.jsx("input",{"data-cpv-field":"key",type:"password",value:e.apiKey,placeholder:c.cpvKeyPlaceholder,onChange:h=>d({apiKey:h.target.value}),style:Dp})}),i.jsx(Lp,{label:c.cpvFieldModels,hint:u("models",c.cpvModelsHint),danger:!!n.models,children:i.jsx("textarea",{"data-cpv-field":"models",value:e.models,rows:3,onChange:h=>d({models:h.target.value}),style:{...Dp,resize:"vertical"}})}),i.jsx("button",{type:"button","data-cpv-action":"save",onClick:s,disabled:!p,style:{width:"100%",height:48,border:"none",borderRadius:13,background:y.ink,color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,marginTop:2,opacity:p?1:.45,cursor:p?"pointer":"default"},children:c.cpvSave})]})}const OOe={accounts:[]};function NOe(){const e=O(),t=Xe(),{openLogin:n}=P3(),r=IF(),o=MF(),s=f.useMemo(()=>TF(r.status??OOe),[r.status]);return i.jsxs(At,{label:e.accountsTitle,children:[r.statusLoading?i.jsx("div",{style:{padding:16,color:y.muted},children:e.accountsLoading}):r.statusError?i.jsx("div",{style:{padding:16,color:y.fail},children:e.accountsLoadFailed}):i.jsx(DOe,{vm:s,onBack:()=>t("/m/settings"),onLogin:n,onLogout:r.logout,actionsDisabled:r.logoutPending,onRescan:r.syncGateway,rescanning:r.syncPending,custom:{providers:o.providers,confirmingDelete:o.confirmingDelete,savePending:o.savePending,removePending:o.removePending,onNew:o.openCreate,onEdit:o.openEdit,onDelete:o.requestDelete}}),o.draft?i.jsx(LOe,{draft:o.draft,creating:o.creating,errors:o.errors,pending:o.savePending,onChange:o.changeDraft,onClose:o.closeDraft,onSave:o.save}):null]})}const FOe={font:`600 12.5px ${H}`,color:y.ink,overflowWrap:"anywhere"},zOe={font:`400 9.5px ${H}`,color:y.muted,marginTop:3,overflowWrap:"anywhere"};function SV({targets:e}){return i.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:e.map(t=>i.jsx(Kn,{tone:"running",children:t},t))})}function BOe({row:e,copy:t,onOpen:n}){return i.jsxs(et,{onClick:()=>n(e.key),children:[i.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:FOe,children:e.id}),i.jsxs("div",{style:zOe,children:[e.event," · ",e.source]})]}),i.jsx("span",{style:{flex:"none"},children:i.jsx(Kn,{tone:e.enabled?"done":"cancelled",children:e.enabled?t.enabled:t.disabled})})]}),(e.mountsOn.length>0||e.scriptMissing)&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8,flexWrap:"wrap"},children:[i.jsx(SV,{targets:e.mountsOn}),e.scriptMissing&&i.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:i.jsx(Kn,{tone:"failed",children:t.scriptMissing})})]})]})}function $Oe({group:e,copy:t,onOpenHook:n}){return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[i.jsxs(fu,{children:[t.group[e.key]," · ",e.rows.length]}),e.rows.map(r=>i.jsx(BOe,{row:r,copy:t,onOpen:n},r.key))]})}function _Oe({label:e,children:t,divider:n=!0}){return i.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"9px 13px",borderBottom:n?`1px solid ${y.divider}`:void 0},children:[i.jsx("span",{style:{fontSize:11,color:y.muted,flex:"none",width:92},children:e}),i.jsx("span",{style:{font:`500 10.5px ${H}`,color:y.ink,minWidth:0,flex:1,overflowWrap:"anywhere"},children:t})]})}function WOe(e,t){var r,o;const n=[{label:t.field.event,value:e.event}];return((r=e.matcher)==null?void 0:r.kind)==="regex"&&n.push({label:t.field.matcher,value:e.matcher.value}),((o=e.matcher)==null?void 0:o.kind)==="filters"&&n.push({label:t.field.filters,value:i.jsx("span",{style:{display:"flex",flexDirection:"column",gap:2},children:e.matcher.entries.map(s=>i.jsxs("span",{children:[s.key," = ",s.value]},s.key))})}),e.run.kind==="none"?n.push({label:t.field.run,value:t.none}):n.push({label:e.run.kind==="script"?t.field.script:t.field.command,value:i.jsxs(i.Fragment,{children:[e.run.value,e.run.missing&&i.jsx("span",{style:{marginLeft:6},children:i.jsx(Kn,{tone:"failed",children:t.scriptMissing})})]})}),e.timeoutSec!==null&&n.push({label:t.field.timeout,value:`${e.timeoutSec}${t.secondUnit}`}),e.backends!==null&&n.push({label:t.field.backends,value:e.backends.join(", ")}),e.requiresTool!==null&&n.push({label:t.field.requiresTool,value:e.requiresTool}),e.result!==null&&n.push({label:t.field.result,value:e.result}),e.blocking!==null&&n.push({label:t.field.blocking,value:`${e.blocking.mode} · ${e.blocking.ttlMin}${t.minuteUnit}`}),n.push({label:t.field.mountsOn,value:i.jsx(SV,{targets:e.mountsOn})}),n.push({label:t.field.appliesAt,value:t.applies[e.appliesAt]}),n.push({label:t.field.source,value:e.source}),e.version!==null&&n.push({label:t.field.version,value:e.version}),e.fileName!==null&&n.push({label:t.field.fileName,value:e.fileName}),e.template!==null&&n.push({label:t.field.template,value:e.template}),e.phase!==null&&n.push({label:t.field.phase,value:e.phase}),n.push({label:t.field.order,value:String(e.order)}),n}function HOe({row:e,copy:t,onClose:n}){const r=WOe(e.detail,t);return i.jsxs(li,{onClose:n,children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"0 2px 10px"},children:[i.jsx("span",{style:{font:`700 15px ${H}`,color:y.ink,minWidth:0,overflowWrap:"anywhere"},children:e.id}),i.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:i.jsx(Kn,{tone:e.enabled?"done":"cancelled",children:e.enabled?t.enabled:t.disabled})})]}),i.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${y.hairline}`,borderRadius:13,overflow:"hidden"},children:r.map((o,s)=>i.jsx(_Oe,{label:o.label,divider:s<r.length-1,children:o.value},o.label))}),i.jsx("div",{style:{font:`400 9.5px ${H}`,color:y.faint,padding:"9px 4px 0"},children:t.sheetFooter})]})}function UOe({vm:e,copy:t,sheetRow:n,onBack:r,onOpenHook:o,onCloseSheet:s}){return i.jsxs(i.Fragment,{children:[i.jsx(cr,{onBack:r,trailing:i.jsxs("span",{style:{font:`500 10px ${H}`,color:y.muted},children:[e.enabledCount,"/",e.total," ",t.enabledWord]}),children:i.jsx("div",{style:{fontSize:16,fontWeight:650,color:y.ink,letterSpacing:"-.01em"},children:t.title})}),i.jsxs(Yn,{gap:14,children:[e.groups.length===0&&i.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:y.faint,fontSize:13},children:t.empty}),e.groups.map(a=>i.jsx($Oe,{group:a,copy:t,onOpenHook:o},a.key)),e.groups.length>0&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"2px 4px",font:`400 9.5px ${H}`,color:y.faint},children:[i.jsxs("span",{children:[e.total," ",t.countUnit]}),i.jsx("span",{style:{marginLeft:"auto",color:y.muted},children:t.editDesktop})]})]}),n&&i.jsx(HOe,{row:n,copy:t,onClose:s})]})}function VOe(e){return e.matcher!==null?{kind:"regex",value:e.matcher}:e.matcherFilters===null?null:{kind:"filters",entries:Object.entries(e.matcherFilters).map(([t,n])=>({key:t,value:n===null?"null":String(n)}))}}function qOe(e){return e.run.script!==null?{kind:"script",value:e.run.script,missing:e.scriptExists===!1}:e.run.command!==null?{kind:"command",value:e.run.command,missing:!1}:{kind:"none"}}function KOe(e){var t,n;return{id:e.id,event:e.event,matcher:VOe(e),run:qOe(e),timeoutSec:e.run.timeoutSec,backends:((t=e.scope)==null?void 0:t.backends)??null,requiresTool:((n=e.scope)==null?void 0:n.requiresTool)??null,result:e.result,blocking:e.blocking,source:e.source,version:e.version,fileName:e.fileName,order:e.order,mountsOn:e.mountsOn,appliesAt:e.appliesAt,template:e.template,phase:e.phase}}function GOe(e){return{key:`${e.id}#${e.order}`,id:e.id,event:e.event,source:e.source,enabled:e.enabled,mountsOn:e.mountsOn,scriptMissing:e.scriptExists===!1,detail:KOe(e)}}function YOe(e){return{groups:tF(e.hooks).map(n=>({key:n.key,rows:n.hooks.map(GOe)})),total:e.hooks.length,enabledCount:e.hooks.filter(n=>n.enabled).length,missingScriptCount:e.hooks.filter(n=>n.scriptExists===!1).length}}const QOe={en:{title:"Hooks",enabledWord:"enabled",countUnit:"hooks",group:{agent:"AGENT EVENTS",cc:"CLAUDE CODE EVENTS",pi:"PI EVENTS",cortex:"CORTEX BUS EVENTS",template:"TEMPLATE-SCOPED",other:"OTHER EVENTS"},enabled:"Enabled",disabled:"Disabled",scriptMissing:"script missing",empty:"No mounted hooks",editDesktop:"Edit on desktop",none:"—",secondUnit:"s",minuteUnit:"min",field:{event:"Event",matcher:"Matcher",filters:"Filters",script:"Script",command:"Command",run:"Run",timeout:"Timeout",backends:"Backends",requiresTool:"Requires tool",result:"Result",blocking:"Blocking",source:"Source",version:"Version",fileName:"File",order:"Load order",mountsOn:"Mounts on",appliesAt:"Applies",template:"Template",phase:"Phase"},applies:{"next-agent":"Next agent start","server-restart":"Server restart"},sheetFooter:"Read-only on mobile — edit on desktop"},zh:{title:"钩子",enabledWord:"已启用",countUnit:"条钩子",group:{agent:"AGENT 事件",cc:"CLAUDE CODE 事件",pi:"PI 事件",cortex:"CORTEX 总线事件",template:"模板内联",other:"其他事件"},enabled:"已启用",disabled:"已停用",scriptMissing:"脚本缺失",empty:"暂无已挂载钩子",editDesktop:"桌面编辑",none:"—",secondUnit:"秒",minuteUnit:"分钟",field:{event:"事件",matcher:"匹配",filters:"过滤条件",script:"脚本",command:"命令",run:"执行",timeout:"超时",backends:"后端",requiresTool:"限定工具",result:"结果",blocking:"阻塞",source:"来源",version:"版本",fileName:"文件",order:"加载顺序",mountsOn:"挂载到",appliesAt:"生效",template:"模板",phase:"阶段"},applies:{"next-agent":"下次 agent 启动","server-restart":"需重启 server"},sheetFooter:"移动端只读 — 编辑请到桌面端"}},XOe={hooks:[]};function ZOe(){const e=he(),t=Xe(),n=ht(),r=dn(n,QOe),o=ae(e.hooks.list.queryOptions({})),s=f.useMemo(()=>YOe(o.data??XOe),[o.data]),[a,l]=f.useState(null),c=f.useMemo(()=>a===null?null:s.groups.flatMap(d=>d.rows).find(d=>d.key===a)??null,[a,s]);return i.jsx(At,{label:"1l-h 钩子",children:o.isLoading?i.jsx("div",{style:{padding:16,color:y.muted,fontSize:13},children:r.title}):i.jsx(UOe,{vm:s,copy:r,sheetRow:c,onBack:()=>t("/m/settings"),onOpenHook:l,onCloseSheet:()=>l(null)})})}function JOe(e){return e==="connected"?"done":e==="disconnected"?"failed":"waiting"}function eNe(e){return e==="connecting"||e==="reconnecting"}function tNe(e){return e==="done"?y.done:e==="failed"?y.fail:y.grayInk}function nNe({proc:e,copy:t,border:n}){const r=t.dash;return i.jsxs("div",{style:{padding:"11px 13px 9px",borderBottom:n?`1px solid ${y.divider}`:void 0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:tNe(e.tone),flex:"none"}}),i.jsx("span",{style:{font:`600 12.5px ${H}`,color:y.ink},children:e.name}),e.label&&i.jsx("span",{style:{font:`400 9.5px ${H}`,color:y.muted},children:e.label}),i.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.muted},children:["pid ",e.pid??r,e.port!=null?` · :${e.port}`:""]})]}),i.jsxs("div",{style:{font:`400 9.5px ${H}`,color:y.muted,marginTop:4,paddingLeft:15},children:[t.uptimeLabel," ",e.uptime??r,e.extras.map(o=>` · ${o.key} ${o.value}`).join("")]})]})}const yR=2e3;function rNe({label:e,hint:t,disabled:n,onConfirm:r}){const[o,s]=f.useState(0),a=f.useRef(null),l=f.useRef(null),c=f.useRef(0),d=()=>{a.current&&clearTimeout(a.current),l.current&&cancelAnimationFrame(l.current),a.current=null,l.current=null,s(0)},u=()=>{if(n)return;c.current=Date.now();const h=()=>{const m=Math.min(1,(Date.now()-c.current)/yR);s(m),m<1&&(l.current=requestAnimationFrame(h))};l.current=requestAnimationFrame(h),a.current=setTimeout(()=>{d(),r()},yR)},p=o>0;return i.jsxs("button",{type:"button",disabled:n,onPointerDown:u,onPointerUp:d,onPointerLeave:d,onPointerCancel:d,style:{position:"relative",flex:1,height:44,borderRadius:11,border:`1.5px solid ${y.failBorder}`,background:"var(--proto-card)",color:y.fail,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",overflow:"hidden",cursor:n?"default":"pointer",opacity:n?.5:1,touchAction:"none",userSelect:"none"},children:[i.jsx("span",{"aria-hidden":!0,style:{position:"absolute",left:0,top:0,bottom:0,width:`${o*100}%`,background:y.failBg,transition:p?void 0:"width .15s ease"}}),i.jsx("span",{style:{position:"relative"},children:p?t:e})]})}const bR={flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:y.ink,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"};function oNe({ev:e,copy:t}){return i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsx("span",{style:{color:y.faint,flex:"none"},children:e.time}),i.jsxs("span",{style:{color:e.tone==="fail"?y.amberText:y.sub},children:[e.ref," · ",t.status[e.status]]})]})}const iNe={connected:"connConnected",connecting:"connConnecting",reconnecting:"connReconnecting",disconnected:"connDisconnected"};function sNe({vm:e,copy:t,connStatus:n,restartState:r,showDisconnect:o,onBack:s,onSoftRestart:a,onHardRestart:l,onDisconnect:c}){const d=r==="pending";return i.jsxs(At,{label:"1r Daemon 状态",children:[i.jsx(cr,{onBack:s,children:i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[i.jsx("span",{style:{fontSize:16,fontWeight:650,color:y.ink,letterSpacing:"-.01em"},children:t.title}),i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[eNe(n)&&i.jsx(Mi,{color:y.amber,pulse:!0}),i.jsx(Kn,{tone:JOe(n),children:t[iNe[n]]})]})]})}),i.jsxs(Yn,{gap:10,children:[i.jsxs(et,{padding:0,style:{overflow:"hidden"},children:[e.processes.map((u,p)=>i.jsx(nNe,{proc:u,copy:t,border:p<e.processes.length-1},u.name)),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"10px 13px",font:`400 10px ${H}`,color:y.muted,flexWrap:"wrap",borderTop:`1px solid ${y.divider}`},children:[i.jsx("span",{children:t.threadsRunning(e.threadCount)}),i.jsx("span",{children:"·"}),i.jsx("span",{children:t.schedules(e.scheduleCount)})]})]}),i.jsxs(et,{padding:0,style:{overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 13px",borderBottom:`1px solid ${y.divider}`},children:[i.jsx("span",{style:{fontSize:12,fontWeight:650,color:y.ink},children:t.recentTitle}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint},children:"executions.list"})]}),e.lastRestart===null&&e.events.length===0?i.jsx("div",{style:{padding:"14px 13px",font:`400 10px ${H}`,color:y.faint},children:t.recentEmpty}):i.jsxs("div",{style:{padding:"9px 13px",display:"flex",flexDirection:"column",gap:7,font:`400 10px/1.5 ${H}`},children:[e.lastRestart&&i.jsxs("div",{style:{display:"flex",gap:8},children:[i.jsx("span",{style:{color:y.faint,flex:"none"},children:e.lastRestart.time}),i.jsxs("span",{style:{color:y.sub},children:[t.lastRestartLabel,e.lastRestart.reason?` · ${e.lastRestart.reason}`:""]})]}),e.events.map(u=>i.jsx(oNe,{ev:u,copy:t},u.id))]}),i.jsx("div",{style:{padding:"0 13px 10px",font:`400 9px ${H}`,color:y.faint},children:t.recentGap})]}),i.jsxs(et,{padding:"12px 13px",children:[i.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[i.jsx("span",{style:{fontSize:13,fontWeight:600,color:y.ink},children:t.softRestart}),i.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${H}`,color:y.faint},children:t.softNote(e.threadCount)})]}),i.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[i.jsx("button",{type:"button",disabled:d,onClick:a,style:{...bR,opacity:d?.5:1,cursor:d?"default":"pointer"},children:t.softRestart}),i.jsx(rNe,{label:t.forceKill,hint:t.holdHint,disabled:d,onConfirm:l})]}),i.jsx("div",{style:{font:`400 9px ${H}`,color:y.faint,marginTop:8},children:t.footerNote}),r==="success"&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8},children:[i.jsx(Mi,{color:y.done}),i.jsx("span",{style:{fontSize:11,fontWeight:600,color:y.done},children:t.sent})]}),r==="error"&&i.jsx("div",{style:{marginTop:8,fontSize:11,fontWeight:600,color:y.fail},children:t.failed})]}),o&&i.jsxs(et,{padding:"12px 13px",children:[i.jsx("button",{type:"button",onClick:c,style:{...bR,width:"100%"},children:t.disconnect}),i.jsx("div",{style:{font:`400 9px ${H}`,color:y.faint,marginTop:8,textAlign:"center"},children:t.disconnectNote})]})]})]})}const aNe=5,lNe=new Set(["failed","cancelled","stale"]);function cNe(e,t){if(e.processes.length>0)return e.processes;const n=t?"running":"unknown",r=o=>({name:o,label:"",status:n,tone:v_(n),pid:null,port:null,uptime:null,extras:[]});return[r("cortex-server"),r("cortex-daemon")]}function dNe(e,t){return e.slice(0,aNe).map(n=>({id:n.id,time:zi(n.startedAt,t),ref:n.taskId?`${n.type} · ${n.taskId}`:n.type,status:n.status,tone:lNe.has(n.status)?"fail":"default"}))}function uNe(e,t){var r,o;const n=(r=e.lastRestart)==null?void 0:r.at;return n?{time:zi(n,t),reason:((o=e.lastRestart)==null?void 0:o.reason)??null}:null}function pNe(e){const t=e.now??Date.now(),n=x_(e.daemon);return{ok:e.ok,threadCount:e.threads.length,scheduleCount:e.schedules.length,processes:cNe(n,e.ok),lastRestart:uNe(n,t),events:dNe(e.executions,t)}}const fNe={en:{title:"Daemon",connConnected:"connected",connConnecting:"connecting",connReconnecting:"reconnecting",connDisconnected:"disconnected",threadsRunning:e=>`${e} threads running`,schedules:e=>`schedules ${e}`,uptimeLabel:"uptime",dash:"—",lastRestartLabel:"Last restart",recentTitle:"Recent events",recentGap:"daemon event log not exposed on web — showing recent executions",recentEmpty:"No recent activity",status:{running:"running",completed:"completed",failed:"failed",cancelled:"cancelled",stale:"stale"},softRestart:"Soft restart",forceKill:"Force kill",softNote:e=>`pauses ${e} running thread(s)`,holdHint:"Keep holding…",footerNote:"Soft restart keeps thread state and auto-resumes · Force kill needs a 2s long-press; running threads are marked interrupted",sent:"Restart signal sent",failed:"Restart failed",disconnect:"Disconnect",disconnectNote:"Clears the saved server & token, returns to the login screen"},zh:{title:"Daemon",connConnected:"已连接",connConnecting:"连接中",connReconnecting:"正在重连",connDisconnected:"已断开",threadsRunning:e=>`${e} 线程运行中`,schedules:e=>`schedules ${e}`,uptimeLabel:"uptime",dash:"—",lastRestartLabel:"上次重启",recentTitle:"最近事件",recentGap:"Web 未提供 daemon 事件日志,以下为最近执行",recentEmpty:"暂无最近活动",status:{running:"运行中",completed:"已完成",failed:"失败",cancelled:"已取消",stale:"过期"},softRestart:"软重启",forceKill:"强制终止",softNote:e=>`先暂停 ${e} 个运行中线程`,holdHint:"继续按住…",footerNote:"软重启不丢线程状态,恢复后自动续跑 · 强制终止需长按 2s 确认,运行中线程标记 interrupted",sent:"重启信号已发送",failed:"重启失败",disconnect:"断开连接",disconnectNote:"清除已保存的服务器与令牌,返回登录页"}},hNe={status:OTe("active")};function mNe(){const e=he(),t=ae(e.threads.list.queryOptions(hNe)),n=ae(e.schedules.list.queryOptions({})),r=ae(e.executions.list.queryOptions({limit:5})),o=y_(),s=!t.isError&&!n.isError,a=f.useMemo(()=>pNe({threads:t.data??[],schedules:n.data??[],executions:r.data??[],daemon:o.daemon,ok:s}),[t.data,n.data,r.data,o.daemon,s]);return{daemon:o,vm:a}}function gNe(){const e=Xe(),t=dn(ht(),fNe),n=OS(),{daemon:r,vm:o}=mNe(),s=r.restartState;return i.jsx(sNe,{vm:o,copy:t,connStatus:n,restartState:s,showDisconnect:dr(),onBack:()=>e("/m/settings"),onSoftRestart:()=>r.restart("soft"),onHardRestart:()=>r.restart("hard"),onDisconnect:()=>void b_()})}const Di={font:`400 9.5px ${H}`,color:y.muted},kV={fontSize:9.5,fontWeight:700,color:y.faint,textTransform:"uppercase"},vNe={width:86,borderRadius:8,border:`1px solid ${y.divider}`,background:y.card,color:y.ink,font:`500 10px ${H}`,padding:"7px 22px 7px 8px",boxSizing:"border-box"};function xNe(e){return new Date(e*1e3).toISOString()}function ol(e){return G3(e)}function yNe({provider:e,copy:t}){if(e.observedAt===null||e.observedAgo===null)return null;const n=xNe(e.observedAt);return i.jsxs("span",{style:Di,children:[t.observed," ",i.jsxs("time",{dateTime:n,title:n,children:[e.observedAgo," ",t.ago]})]})}function bNe(e){return i.jsx("button",{type:"button",role:"switch","aria-label":`Usage throttle ${ol(e.target)}`,"aria-checked":e.enabled,"aria-disabled":e.disabled,disabled:e.disabled,onClick:e.onClick,style:{width:38,height:22,borderRadius:999,border:0,padding:2,display:"flex",alignItems:"center",justifyContent:e.enabled?"flex-end":"flex-start",background:e.enabled?y.run:y.divider,cursor:e.disabled?"default":"pointer",opacity:e.disabled?.55:1},children:i.jsx("span",{style:{width:18,height:18,borderRadius:"50%",background:y.card}})})}function wNe(e){return i.jsxs("div",{style:{position:"relative",width:86},children:[i.jsx("input",{"data-usage-threshold-input":ol(e.target),type:"number",min:1,max:100,step:"0.1",inputMode:"decimal",value:e.value,disabled:e.disabled,onChange:t=>e.onChange(t.target.value),style:{...vNe,opacity:e.disabled?.55:1}}),i.jsx("span",{style:{position:"absolute",right:8,top:7,font:`500 10px ${H}`,color:y.muted},children:"%"})]})}function SNe(e){return i.jsx("button",{type:"button","data-usage-threshold-save":ol(e.policy.target),disabled:e.saveDisabled,onClick:()=>e.parsedThreshold!==null&&e.onSavePolicy(e.policy.target,{enabled:e.policy.enabled,thresholdPercent:e.parsedThreshold}),style:{border:0,borderRadius:8,padding:"7px 10px",background:y.runBg,color:y.run,fontSize:10.5,fontWeight:650,opacity:e.saveDisabled?.45:1,cursor:e.saveDisabled?"default":"pointer"},children:e.pending?e.copy.policy.saving:e.copy.policy.save})}function kNe(){return i.jsxs("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),i.jsx("path",{d:"M3 3v5h5"})]})}function jNe(e){return i.jsx("button",{type:"button","data-usage-threshold-reset":ol(e.policy.target),"aria-label":e.copy.policy.resetDefault,title:e.copy.policy.resetDefault,disabled:e.resetDisabled,onClick:()=>e.onSavePolicy(e.policy.target,{enabled:!0,thresholdPercent:null}),style:{width:30,height:30,borderRadius:8,border:`1px solid ${y.divider}`,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",background:y.card,color:y.sub,opacity:e.resetDisabled?.45:1,cursor:e.resetDisabled?"default":"pointer"},children:i.jsx(kNe,{})})}function CNe(e){return i.jsxs(i.Fragment,{children:[i.jsx(SNe,{...e}),i.jsx(jNe,{...e})]})}function TNe(e){return i.jsxs("div",{"data-usage-policy-controls":ol(e.policy.target),style:{display:"flex",alignItems:"center",gap:6,marginTop:8},children:[i.jsx(bNe,{target:e.policy.target,enabled:e.policy.enabled,disabled:e.disabled,onClick:()=>e.onSavePolicy(e.policy.target,{enabled:!e.policy.enabled,thresholdPercent:e.policy.thresholdPercent})}),i.jsx("span",{style:{fontSize:11,fontWeight:600,color:y.ink},children:e.copy.policy.enabled}),i.jsx("span",{style:Di,children:e.copy.policy.threshold}),i.jsx(wNe,{target:e.policy.target,value:e.draft,disabled:e.disabled,onChange:e.setDraft}),i.jsx(CNe,{...e})]})}function PNe(e){const t=e.isPolicySaving(e.policy.target),n=e.getPolicyError(e.policy.target),{draft:r,parsedThreshold:o,setDraft:s}=OF(e.policy),a=LF(e.policyControlsState!=="ready",t,o,e.policy),l={policy:e.policy,pending:t,parsedThreshold:o,copy:e.copy,saveDisabled:a.saveDisabled,resetDisabled:a.resetDisabled,onSavePolicy:e.onSavePolicy};return i.jsxs("div",{"data-usage-policy-row":ol(e.policy.target),"data-usage-policy-provider":e.policy.target.provider,"data-usage-policy-window-type":e.policy.target.windowType??"","data-usage-policy-window-label":e.policy.target.windowLabel??"",style:{marginTop:8,paddingTop:8,borderTop:`1px solid ${y.divider}`},children:[i.jsx("div",{style:Di,children:e.copy.policy.title}),i.jsx(TNe,{...e,...l,disabled:a.disabled,draft:r,setDraft:s}),n?i.jsx("div",{"data-usage-policy-error":ol(e.policy.target),style:{...Di,color:y.fail,marginTop:6},children:n.message}):null]})}function ENe(e){const t=e.window.resetElapsed?e.copy.resetElapsed:e.window.resetIn===null?null:`${e.copy.resetsIn} ${e.window.resetIn}`;return i.jsxs("div",{"data-usage-window":e.window.type,style:{padding:"9px 0",borderTop:`1px solid ${y.divider}`},children:[i.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[i.jsx("span",{style:{fontSize:11,fontWeight:600,color:y.sub},children:e.window.label}),i.jsx("span",{style:{marginLeft:"auto",font:`600 10px ${H}`,color:y.ink},children:e.window.utilizationLabel??e.copy.unavailable})]}),i.jsx("div",{style:{height:5,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden",marginTop:6},children:i.jsx("div",{className:"usage-meter-fill",style:{width:e.window.utilizationWidth,height:"100%",background:y.run}})}),t?i.jsx("div",{style:{...Di,marginTop:5},children:t}):null,e.window.policy?i.jsx(PNe,{policy:e.window.policy,copy:e.copy,policyControlsState:e.policyControlsState,isPolicySaving:e.isPolicySaving,getPolicyError:e.getPolicyError,onSavePolicy:e.onSavePolicy}):null]})}function RNe(e){const t=e.isPolicySaving(e.fallback.target),n=e.getPolicyError(e.fallback.target),r=e.fallback.enabled?e.copy.policy.enabled:e.copy.policy.disabled;return i.jsxs("div",{"data-usage-legacy-fallback":e.fallback.target.provider,style:{marginTop:10,border:`1px solid ${y.divider}`,borderRadius:8,padding:"8px 10px"},children:[i.jsx("div",{style:{fontSize:10.5,fontWeight:650,color:y.ink},children:e.copy.policy.legacyFallbackTitle}),i.jsx("div",{style:{...Di,marginTop:3},children:e.copy.policy.legacyFallbackBody}),i.jsx("div",{style:{...Di,marginTop:3},children:`${r} · ${e.fallback.thresholdPercent}%`}),i.jsx("button",{type:"button","data-usage-legacy-clear":e.fallback.target.provider,disabled:t,onClick:()=>e.onSavePolicy(e.fallback.target,{enabled:!0,thresholdPercent:null}),style:{marginTop:8,borderRadius:8,border:`1px solid ${y.divider}`,padding:"7px 10px",background:y.card,color:y.sub,fontSize:10.5,fontWeight:650,opacity:t?.45:1,cursor:t?"default":"pointer"},children:t?e.copy.policy.saving:e.copy.policy.clearLegacy}),n?i.jsx("div",{"data-usage-policy-error":ol(e.fallback.target),style:{...Di,color:y.fail,marginTop:6},children:n.message}):null]})}function MNe(e){return e.provider.quotaState==="unsupported"?null:i.jsxs("section",{"data-usage-quota":e.provider.provider,"data-usage-quota-state":e.provider.quotaState,style:{padding:"10px 13px"},children:[i.jsx("div",{style:kV,children:e.copy.quota}),e.provider.quotaState==="available"?e.provider.windows.map(t=>i.jsx(ENe,{window:t,...e},`${t.type}:${t.label}:${t.resetsAt??"none"}`)):i.jsx("div",{style:{marginTop:7,fontSize:10.5,color:y.muted},children:e.copy.neverObserved}),e.provider.legacyFallback?i.jsx(RNe,{fallback:e.provider.legacyFallback,copy:e.copy,isPolicySaving:e.isPolicySaving,getPolicyError:e.getPolicyError,onSavePolicy:e.onSavePolicy}):null]})}function INe({provider:e,copy:t}){return e.spend?i.jsxs("section",{"data-usage-spend":e.provider,style:{borderTop:`1px solid ${y.divider}`,padding:"10px 13px"},children:[i.jsx("div",{style:kV,children:t.gatewaySpend}),i.jsxs("div",{style:{display:"flex",gap:22,marginTop:7},children:[i.jsxs("span",{style:{font:`600 12px ${H}`},children:[e.spend.today," ",i.jsx("small",{children:t.today})]}),i.jsxs("span",{style:{font:`600 12px ${H}`},children:[e.spend.month," ",i.jsx("small",{children:t.month})]})]})]}):null}function ANe(e){const{provider:t,copy:n}=e;return i.jsxs(et,{padding:0,children:[i.jsxs("div",{"data-usage-provider":t.provider,style:{padding:"11px 13px 8px"},children:[i.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:i.jsx("span",{style:{fontSize:13.5,fontWeight:650,color:y.ink},children:t.displayName})}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:5},children:[i.jsx("span",{style:Di,children:t.modes.join(" · ")}),i.jsx(yNe,{provider:t,copy:n})]})]}),i.jsx(MNe,{provider:t,copy:n,policyControlsState:e.policyControlsState,isPolicySaving:e.isPolicySaving,getPolicyError:e.getPolicyError,onSavePolicy:e.onSavePolicy}),i.jsx(INe,{provider:t,copy:n}),t.note?i.jsx("div",{style:{...Di,padding:"0 13px 10px"},children:t.note}):null]})}function wR({label:e,error:t}){return t?i.jsxs("div",{role:"alert",style:{color:y.fail,fontSize:10.5},children:[e,": ",t.message]}):null}function DNe({copy:e,pending:t,onRefresh:n}){return i.jsx("button",{type:"button","data-usage-refresh":!0,"aria-busy":t,onClick:n,style:{border:0,borderRadius:8,padding:"7px 10px",background:y.runBg,color:y.run,fontSize:10.5,fontWeight:650},children:t?e.refreshing:e.refresh})}function LNe(e){const{view:t,copy:n,isLoading:r,queryError:o,refreshError:s,isRefreshing:a,policyControlsState:l,isPolicySaving:c,getPolicyError:d,onBack:u,onRefresh:p,onSavePolicy:h}=e,m=t.providers.length>0,x=i.jsx(cr,{onBack:u,trailing:i.jsx(DNe,{copy:n,pending:a,onRefresh:p}),children:i.jsx("div",{style:{fontSize:16,fontWeight:650,color:y.ink},children:n.title})});return i.jsx(At,{label:"1l-u 用量",header:x,children:i.jsxs(Yn,{gap:10,children:[r&&!m?i.jsx("div",{style:{color:y.muted,fontSize:12},children:n.loading}):null,i.jsx(wR,{label:n.loadError,error:o}),i.jsx(wR,{label:n.refreshError,error:s}),!r&&!o&&!m?i.jsx("div",{style:{color:y.muted,fontSize:12},children:n.empty}):null,t.providers.map(v=>i.jsx(ANe,{provider:v,copy:n,policyControlsState:l,isPolicySaving:c,getPolicyError:d,onSavePolicy:h},v.provider))]})})}const ONe={en:{title:"Usage",refresh:"Refresh",refreshing:"Refreshing…",loading:"Loading usage…",loadError:"Failed to load usage",refreshError:"Refresh failed",empty:"No usage data",quota:"Quota",neverObserved:"Never observed",unavailable:"Unavailable",gatewaySpend:"Gateway spend",today:"Today",month:"Month",observed:"Observed",ago:"ago",resetsIn:"Resets in",resetElapsed:"Reset elapsed",policy:{title:"Rate-limit threshold",enabled:"Enabled",disabled:"Disabled",threshold:"Threshold",save:"Save",saving:"Saving…",resetDefault:"Reset to default",legacyFallbackTitle:"Legacy fallback",legacyFallbackBody:"Unset rows inherit the old provider-wide policy until you clear it.",clearLegacy:"Clear legacy fallback"}},zh:{title:"用量",refresh:"刷新",refreshing:"刷新中…",loading:"正在加载用量…",loadError:"加载用量失败",refreshError:"刷新失败",empty:"暂无用量数据",quota:"配额",neverObserved:"尚未观测",unavailable:"不可用",gatewaySpend:"网关消费额",today:"今日",month:"本月",observed:"观测于",ago:"前",resetsIn:"重置还需",resetElapsed:"重置时间已过",policy:{title:"限流阈值",enabled:"启用",disabled:"关闭",threshold:"阈值",save:"保存",saving:"保存中…",resetDefault:"恢复默认",legacyFallbackTitle:"旧版兜底",legacyFallbackBody:"未单独设置的行会继续继承旧的 provider 级策略,直到你清除它。",clearLegacy:"清除旧版兜底"}}};function NNe(){const e=Xe(),t=dn(ht(),ONe),n=WF();return i.jsx(At,{label:"1l-u 用量",children:i.jsx(LNe,{view:n.view,copy:t,isLoading:n.isLoading,queryError:n.queryError,refreshError:n.refreshError,isRefreshing:n.isRefreshing,policyControlsState:n.policyControlsState,isPolicySaving:n.isPolicySaving,getPolicyError:n.getPolicyError,onBack:()=>e("/m/settings",{replace:!0}),onRefresh:n.refresh,onSavePolicy:n.savePolicy})})}function s2({children:e}){return i.jsx("div",{style:{background:y.card,border:`1px solid ${y.hairline}`,borderRadius:13,overflow:"hidden"},children:e})}function Kk(e){return{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:e?`1px solid ${y.divider}`:void 0}}const jV={fontSize:14,fontWeight:600,color:y.ink};function FNe({id:e,label:t,active:n,onChange:r}){return i.jsx("button",{type:"button","aria-pressed":n,onClick:()=>r(e),style:{border:0,fontSize:11,fontWeight:600,padding:"3px 10px",cursor:"pointer",background:n?"var(--ink-solid-bg)":"transparent",color:n?"var(--ink-solid-fg)":y.muted},children:t})}function zNe({value:e,options:t,onChange:n,ariaLabel:r}){return i.jsx("div",{role:"group","aria-label":r,style:{display:"flex",border:`1px solid ${y.hairline}`,borderRadius:6,overflow:"hidden",flex:"none"},children:t.map(o=>i.jsx(FNe,{...o,active:e===o.id,onChange:n},o.id))})}function Ym({title:e,divider:t,...n}){return i.jsxs("div",{style:Kk(t),children:[i.jsx("div",{style:{minWidth:0,flex:1},children:i.jsx("div",{style:jV,children:e})}),i.jsx(zNe,{...n})]})}function BNe({copy:e,hue:t,onChange:n}){const r={label:e.accent,default:e.accentDefault,blue:e.accentBlue,teal:e.accentTeal,violet:e.accentViolet,rose:e.accentRose,orange:e.accentOrange,custom:e.accentCustom,reset:e.accentReset};return i.jsxs("div",{style:{...Kk(!0),display:"block"},children:[i.jsx("div",{style:jV,children:e.accent}),i.jsx("div",{style:{marginTop:9},children:i.jsx(kO,{hue:t,copy:r,onChange:n,compact:!0})})]})}function $Ne({copy:e,lang:t,onSetLang:n,theme:r,onSetTheme:o,palette:s,onSetPaletteValue:a,activePreset:l,onPickPreset:c,onResetPalette:d,accentHue:u,onSetAccentHue:p,accentIntensity:h,onSetAccentIntensity:m,motionMode:x,onSetMotionMode:v,onBack:S}){return i.jsx(At,{label:"1l-ap 外观",header:i.jsx(cr,{onBack:S,children:i.jsx("div",{style:{fontSize:16,fontWeight:650,color:y.ink,letterSpacing:"-.01em"},children:e.title})}),children:i.jsxs(Yn,{gap:10,children:[i.jsxs(s2,{children:[i.jsx(Ym,{divider:!0,title:e.language,ariaLabel:e.language,value:t,options:[{id:"en",label:"EN"},{id:"zh",label:"中"}],onChange:n}),i.jsx(Ym,{divider:!1,title:e.theme,ariaLabel:e.theme,value:r,options:[{id:"light",label:e.themeLight},{id:"dark",label:e.themeDark},{id:"system",label:e.themeSystem}],onChange:o})]}),i.jsxs(s2,{children:[i.jsx("div",{style:{...Kk(!0),display:"block"},children:i.jsx(NO,{palette:s,copy:e.palette,activePreset:l,onPickPreset:c,onChange:a,onReset:d})}),i.jsx(BNe,{copy:e,hue:u,onChange:p}),i.jsx(Ym,{divider:!1,title:e.accentIntensity,ariaLabel:e.accentIntensity,value:h,options:[{id:"soft",label:e.accentIntensitySoft},{id:"normal",label:e.accentIntensityNormal},{id:"vivid",label:e.accentIntensityVivid}],onChange:m})]}),i.jsx(s2,{children:i.jsx(Ym,{divider:!1,title:e.motion,ariaLabel:e.motion,value:x,options:[{id:"system",label:e.motionSystem},{id:"full",label:e.motionFull},{id:"reduced",label:e.motionReduced}],onChange:v})}),i.jsx("div",{style:{padding:"2px 4px",font:`400 9.5px ${H}`,color:y.faint},children:"localStorage · cortex.lang · cortex.theme · cortex.palette · cortex.accent-hue · cortex.accent-intensity · cortex.motion"})]})})}const _Ne={en:{title:"Appearance",language:"Language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",palette:{presets:"Presets",custom:"custom",reset:"Reset",background:"Background",foreground:"Foreground",hue:"Hue",tint:"Tint",lightness:"Light",contrast:"Contrast",presetNames:{default:"Default",graphite:"Graphite",sepia:"Sepia",indigo:"Indigo",forest:"Forest",rose:"Rose",deep:"Deep"}},accent:"Accent color",accentDefault:"Default indigo",accentBlue:"Blue",accentTeal:"Teal",accentViolet:"Violet",accentRose:"Rose",accentOrange:"Orange",accentCustom:"Custom accent hue",accentReset:"Reset",accentIntensity:"Intensity",accentIntensitySoft:"Soft",accentIntensityNormal:"Normal",accentIntensityVivid:"Vivid",motion:"Motion",motionSystem:"System",motionFull:"Full",motionReduced:"Reduced"},zh:{title:"外观",language:"语言",theme:"主题",themeLight:"浅色",themeDark:"深色",themeSystem:"跟随系统",palette:{presets:"预设",custom:"自定义",reset:"恢复默认",background:"背景",foreground:"前景",hue:"色相",tint:"着色",lightness:"明度",contrast:"对比",presetNames:{default:"默认",graphite:"石墨",sepia:"暖褐",indigo:"靛青",forest:"森林",rose:"玫瑰",deep:"深邃"}},accent:"强调色",accentDefault:"默认靛蓝",accentBlue:"蓝色",accentTeal:"青色",accentViolet:"紫色",accentRose:"玫红",accentOrange:"橙色",accentCustom:"自定义强调色色相",accentReset:"恢复默认",accentIntensity:"浓度",accentIntensitySoft:"柔和",accentIntensityNormal:"标准",accentIntensityVivid:"鲜明",motion:"动效",motionSystem:"跟随系统",motionFull:"完整",motionReduced:"减弱"}};function WNe(){const e=Xe(),t=ht(),n=x3(),r=nh(),o=Wx(),s=MO(),a=IO(),l=AO(),c=DO(),d=LO(),u=TO(),p=PO(),h=EO(),m=RO(),x=k3(),v=OO();return i.jsx($Ne,{copy:dn(t,_Ne),lang:t,onSetLang:n,theme:r,onSetTheme:o,palette:s,onSetPaletteValue:a,activePreset:l,onPickPreset:c,onResetPalette:d,accentHue:u,onSetAccentHue:p,accentIntensity:h,onSetAccentIntensity:m,motionMode:x,onSetMotionMode:v,onBack:()=>e("/m/settings")})}const HNe={fontSize:13.5,fontWeight:600,color:y.ink},Gk={fontSize:10.5,color:y.muted,lineHeight:1.45,marginTop:2},Au={font:`400 9px ${H}`,color:y.faint};function Li(e){return i.jsx(At,{label:`Settings · ${e.title}`,header:i.jsx(cr,{onBack:e.onBack,trailing:e.trailing,children:i.jsx("span",{style:{fontSize:16,fontWeight:650,color:y.ink},children:e.title})}),children:i.jsx(Yn,{children:e.children})})}function xn(e){return i.jsxs("div",{children:[e.title&&i.jsx("div",{style:{...Au,padding:"0 2px 5px",fontWeight:700},children:e.title}),i.jsx(et,{padding:0,style:{overflow:"hidden"},children:e.children}),e.note&&i.jsx("div",{style:{...Gk,padding:"6px 3px 0"},children:e.note})]})}function Oo(e){return i.jsxs("div",{"data-settings-row":e.dataKey,onClick:e.onClick,style:{display:"flex",alignItems:"center",gap:10,padding:"11px 13px",borderBottom:e.last?void 0:`1px solid ${y.divider}`,cursor:e.onClick?"pointer":void 0},children:[i.jsxs("div",{style:{minWidth:0,flex:1},children:[i.jsx("div",{style:HNe,children:e.title}),e.sub!==void 0&&i.jsx("div",{style:Gk,children:e.sub})]}),e.trailing]})}function $1(e){const t=!e.disabled&&!!e.onChange;return i.jsx("button",{type:"button",role:"switch","aria-checked":e.value,"aria-label":e.label,disabled:!t,onClick:()=>{var n;t&&((n=e.onChange)==null||n.call(e,!e.value))},style:{width:44,height:26,border:0,borderRadius:999,padding:2,background:e.value?y.done:"var(--proto-line-3)",opacity:e.disabled?.55:1,display:"flex",justifyContent:e.value?"flex-end":"flex-start"},children:i.jsx("span",{style:{width:22,height:22,borderRadius:"50%",background:"var(--ink-solid-bg)",boxShadow:"var(--shadow-switch-thumb)"}})})}function Io(e){return i.jsx("button",{type:"button",onClick:e.onClick,disabled:e.disabled,style:{border:`1px solid ${e.danger?y.failBorder:y.runBorder}`,borderRadius:8,background:e.danger?y.failBg:y.runBg,color:e.danger?y.fail:y.run,fontSize:11,fontWeight:600,padding:"7px 10px",opacity:e.disabled?.5:1},children:e.children})}const CV={width:"100%",boxSizing:"border-box",border:`1px solid ${y.hairline}`,borderRadius:8,background:y.card,color:y.ink,padding:"9px 10px",font:`400 12px ${H}`};function _1({hint:e,error:t}){const n=t!=null,r=n?t:e;return r==null?null:i.jsx("span",{"data-settings-field-error":n||void 0,style:{...Gk,display:"block",color:n?y.fail:y.faint,marginTop:4},children:r})}function xs(e){const{label:t,hint:n,error:r,...o}=e,s=r!=null;return i.jsxs("label",{style:{display:"block"},children:[i.jsx("span",{style:{...Au,display:"block",marginBottom:4},children:t}),i.jsx("input",{...o,"aria-invalid":o["aria-invalid"]??(s||void 0),style:{...CV,borderColor:s?y.failBorder:void 0,...o.style}}),i.jsx(_1,{hint:n,error:r})]})}function Nf(e){const{label:t,hint:n,error:r,children:o,...s}=e,a=r!=null;return i.jsxs("label",{style:{display:"block"},children:[i.jsx("span",{style:{...Au,display:"block",marginBottom:4},children:t}),i.jsx("select",{...s,"aria-invalid":s["aria-invalid"]??(a||void 0),style:{...CV,borderColor:a?y.failBorder:void 0,...s.style},children:o}),i.jsx(_1,{hint:n,error:r})]})}function UNe(){const e=O(),t=he(),n=Xe(),[r,o]=f.useState(!1),s=ae(t.config.get.queryOptions({})),a=()=>{(!r||window.confirm(e.psUnsaved))&&n("/m/settings")};let l;return s.isLoading?l=i.jsx(xn,{children:i.jsx("p",{children:e.stLoadingConfig})}):s.isError||!s.data?l=i.jsx(xn,{children:i.jsx("p",{children:e.stFailedLoadConfig})}):l=i.jsx(LN,{snapshot:s.data,onDirtyChange:o}),i.jsx(Li,{title:e.stNavPlatform,onBack:a,children:l})}function VNe(e){const t=O(),n=[e.profile.model,e.profile.backend,e.profile.thinking].filter(Boolean).join(" · ");return i.jsx(Oo,{title:e.profile.name,sub:n,trailing:i.jsxs("div",{style:{display:"flex",gap:5},children:[!e.current&&i.jsx(Io,{disabled:e.defaultPending,onClick:e.onDefault,children:t.default}),i.jsx(Io,{disabled:e.editPending,onClick:e.onEdit,children:t.pfEdit}),i.jsx(Io,{danger:!0,disabled:e.current||e.removePending,onClick:e.onDelete,children:t.pfDelete})]})})}function qNe(e){const t=O(),n=(r,o,s)=>{const a=e.draft.extraOption.map((l,c)=>c===r?{...l,[o]:s}:l);e.onChange({...e.draft,extraOption:a})};return i.jsxs("div",{"data-profile-extra-options":!0,style:{display:"flex",flexDirection:"column",gap:7},children:[e.draft.extraOption.map((r,o)=>i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr auto",gap:5},children:[i.jsx(xs,{"data-profile-option-key":o,label:t.pfOptionKeyPlaceholder,value:r.key,onChange:s=>n(o,"key",s.target.value)}),i.jsx(xs,{"data-profile-option-value":o,label:t.pfOptionValuePlaceholder,value:r.value,onChange:s=>n(o,"value",s.target.value)}),i.jsx(Io,{danger:!0,onClick:()=>e.onChange({...e.draft,extraOption:e.draft.extraOption.filter((s,a)=>a!==o)}),children:"×"})]},o)),i.jsx(Io,{onClick:()=>e.onChange({...e.draft,extraOption:[...e.draft.extraOption,{key:"",value:""}]}),children:t.pfAddOption}),i.jsx(_1,{error:e.error})]})}function KNe(e){const t=O(),n=e.state.draft,r=(s,a)=>e.onChange({...n,[s]:a}),o=s=>$N(e.errors[s],t);return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:9,padding:13},children:[i.jsx(xs,{"data-profile-field":"name",label:t.pfFieldName,value:n.name,disabled:e.state.mode==="update",error:o("name"),hint:e.state.mode==="create"?t.pfNameHint:t.pfNoRename,onChange:s=>r("name",s.target.value)}),i.jsx(xs,{"data-profile-field":"model",label:t.pfFieldModel,value:n.model,error:o("model"),hint:t.pfModelHint,onChange:s=>r("model",s.target.value)}),i.jsx(Nf,{"data-profile-field":"backend",label:t.pfFieldBackend,value:n.backend,onChange:s=>e.onBackendChange(s.target.value),children:zN.map(s=>i.jsx("option",{children:s},s))}),i.jsx(xs,{"data-profile-field":"mode",label:t.pfFieldMode,value:n.mode,error:o("mode"),hint:t.pfModeHint,onChange:s=>r("mode",s.target.value)}),i.jsx(xs,{"data-profile-field":"provider",label:t.pfFieldProvider,value:n.provider,error:o("provider"),hint:t.pfProviderHint,onChange:s=>r("provider",s.target.value)}),i.jsxs(Nf,{"data-profile-field":"thinking",label:t.pfFieldThinking,value:n.thinking,error:o("thinking"),onChange:s=>r("thinking",s.target.value),children:[i.jsx("option",{value:"",children:t.pfNotDeclared}),Qx[n.backend].map(s=>i.jsx("option",{children:s},s))]}),n.backend==="claude"&&i.jsxs(Nf,{"data-profile-field":"claudeBackend",label:t.pfFieldClaudeBackend,value:n.claudeBackend,onChange:s=>r("claudeBackend",s.target.value),children:[i.jsx("option",{value:"",children:t.pfPrintDefault}),i.jsx("option",{value:"print",children:"print"}),i.jsx("option",{value:"tui",children:"tui"})]}),i.jsx(qNe,{draft:n,error:o("extraOption"),onChange:e.onChange})]})}function GNe(e){const t=O();return i.jsxs(xn,{title:e.state.mode==="create"?t.pfCreateTitle:t.pfEditTitle,children:[i.jsx(KNe,{state:e.state,errors:e.errors,onChange:e.onChange,onBackendChange:e.onBackendChange}),i.jsxs("div",{style:{display:"flex",gap:7,padding:"0 13px 13px"},children:[i.jsx(Io,{onClick:e.onCancel,children:t.cancel}),i.jsx(Io,{disabled:!z3(e.errors)||e.pending,onClick:e.onSave,children:t.pfSave})]})]})}function YNe(e){const t=O(),n=e.controller,r=s=>i.jsx(Li,{title:t.stNavProfiles,onBack:e.onBack,children:s});if(n.loading)return r(i.jsx(xn,{children:i.jsx("div",{style:{padding:13},children:t.stLoadingConfig})}));if(n.error)return r(i.jsx(xn,{children:i.jsx("div",{style:{padding:13,color:y.fail},children:t.stFailedLoadConfig})}));const o=n.draft?{mode:n.creating?"create":"update",draft:n.draft}:null;return i.jsxs(Li,{title:t.stNavProfiles,onBack:e.onBack,trailing:i.jsx(Io,{onClick:n.openCreate,children:t.pfNew}),children:[o&&i.jsx(GNe,{state:o,errors:n.errors,pending:n.savePending,onChange:n.changeDraft,onBackendChange:n.changeBackend,onCancel:n.closeDraft,onSave:n.save}),i.jsx(xn,{children:n.profileFacts.map(s=>i.jsx(VNe,{profile:s.profile,current:s.current,defaultPending:n.defaultPendingName!==null,editPending:n.savePending,removePending:n.removePendingName!==null,onDefault:()=>n.setDefault(s.profile.name),onEdit:()=>n.openEdit(s.profile.name),onDelete:()=>{window.confirm(`${t.pfDelete} ${s.profile.name}?`)&&n.confirmDelete(s.profile.name)}},s.profile.name))})]})}function QNe(){const e=Xe(),t=WN();return i.jsx(YNe,{controller:t,onBack:()=>e("/m/settings")})}function SR({value:e,limit:t}){return i.jsx("div",{style:{height:6,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:i.jsx("div",{style:{width:kv(e,t),height:"100%",background:y.run}})})}function XNe(e){const t=O(),[n,r]=f.useState(e.daily===null?"":String(e.daily)),[o,s]=f.useState(e.monthly===null?"":String(e.monthly));f.useEffect(()=>r(e.daily===null?"":String(e.daily)),[e.daily]),f.useEffect(()=>s(e.monthly===null?"":String(e.monthly)),[e.monthly]);const a=ece(n,o),l=(a==null?void 0:a.daily_usd)===e.daily&&(a==null?void 0:a.monthly_usd)===e.monthly;return i.jsxs("div",{style:{display:"grid",gap:9,padding:"11px 13px"},children:[i.jsx(xs,{label:t.stDaily,inputMode:"decimal",value:n,onChange:c=>r(c.target.value)}),i.jsx(xs,{label:t.stMonthly,inputMode:"decimal",value:o,onChange:c=>s(c.target.value)}),i.jsx(Io,{disabled:!a||l||e.pending,onClick:()=>{a&&e.onSave(a)},children:t.stApply})]})}function ZNe(e){const t=O();return i.jsx(xn,{title:t.stCurrentSpend,children:i.jsxs("div",{style:{padding:"11px 13px"},children:[i.jsxs("div",{style:{font:`600 15px ${H}`,color:y.ink},children:[Ko(e.today)," / ",Ko(e.daily)]}),i.jsx(SR,{value:e.today,limit:e.daily}),i.jsxs("div",{style:{font:`600 12px ${H}`,color:y.sub,marginTop:12},children:[Ko(e.month)," / ",Ko(e.monthly)]}),i.jsx(SR,{value:e.month,limit:e.monthly})]})})}function JNe(){var g;const e=O(),t=he(),n=Xe(),{toast:r}=Fn(),o=JN(),[s,a]=f.useState(null),l=ae(t.config.get.queryOptions({})),c=ae(t.projects.list.queryOptions({})),d=ae(t.cost.summary.queryOptions({})),u=ae({...t.cost.summary.queryOptions({projectId:s??void 0}),enabled:s!==null}),p=((g=l.data)==null?void 0:g.budget)??null,h=XN(p,s),m=s===null?d.data:u.data,x=w=>{w&&r({title:w==="clear"?e.stToastBudgetCleared:e.stToastBudgetWritten,tone:"done"})},v=w=>{r({title:`${e.stToastWriteFailed}: ${w.message}`,tone:"failed"})},S=w=>{o.isPending||o.write(s,w).then(x).catch(v)},b=()=>{s&&!o.isPending&&o.clear(s).then(x).catch(v)};return l.isLoading?i.jsx(Li,{title:e.stNavBudget,onBack:()=>n("/m/settings"),children:i.jsx(xn,{children:i.jsx("div",{style:{padding:13},children:e.stLoadingConfig})})}):l.isError?i.jsx(Li,{title:e.stNavBudget,onBack:()=>n("/m/settings"),children:i.jsx(xn,{children:i.jsx("div",{style:{padding:13,color:y.fail},children:e.stFailedLoadConfig})})}):i.jsxs(Li,{title:e.stNavBudget,onBack:()=>n("/m/settings"),children:[i.jsxs(xn,{title:e.stBudgetScope,note:h.inherited?e.stBudgetInherited:void 0,children:[i.jsx("div",{style:{padding:"11px 13px"},children:i.jsxs(Nf,{label:e.stBudgetScope,value:s??"",onChange:w=>a(w.target.value||null),children:[i.jsx("option",{value:"",children:e.stBudgetScopeGlobal}),(c.data??[]).map(w=>i.jsx("option",{value:w.id,children:w.id},w.id))]})}),i.jsx(XNe,{daily:h.daily,monthly:h.monthly,pending:o.isPending,onSave:S}),i5(p,s)&&i.jsx("div",{style:{padding:"0 13px 11px"},children:i.jsx(Io,{danger:!0,disabled:o.isPending,onClick:b,children:e.stBudgetClear})})]}),i.jsx(ZNe,{today:(m==null?void 0:m.today)??0,month:(m==null?void 0:m.month)??0,daily:h.daily,monthly:h.monthly})]})}function eFe(){var s,a;const e=O(),t=he(),n=Xe(),r=ae(t.config.get.queryOptions({})),o=((a=(s=r.data)==null?void 0:s.mcp)==null?void 0:a.servers)??[];return r.isLoading?i.jsx(Li,{title:e.stNavMcp,onBack:()=>n("/m/settings"),children:i.jsx(xn,{children:i.jsx("div",{style:{padding:13},children:e.stLoadingConfig})})}):r.isError?i.jsx(Li,{title:e.stNavMcp,onBack:()=>n("/m/settings"),children:i.jsx(xn,{children:i.jsx("div",{style:{padding:13,color:y.fail},children:e.stFailedLoadConfig})})}):i.jsx(Li,{title:e.stNavMcp,onBack:()=>n("/m/settings"),children:i.jsx(xn,{title:e.stServers,note:e.stMcpFootNote,children:o.length===0?i.jsx(Oo,{title:e.stNoServers,last:!0}):o.map((l,c)=>i.jsx(Oo,{title:l,last:c===o.length-1},l))})})}function tFe(){const e=O(),t=ht(),{status:n,supported:r,pending:o,error:s}=pRe();if(!No()||!r||!n)return null;const a=n.running?e.stMobileNotifyRunning:e.stMobileNotifyStopped,l=n.enabled?a:e.stMobileNotifyDisabled,c=!n.permissionGranted||s==="permission"?e.stMobileNotifyPermission:null;return i.jsxs(xn,{note:e.stMobileNotifyNote,children:[i.jsx(Oo,{dataKey:"nativeBackgroundNotifications",title:e.stMobileNotifyTitle,sub:c??l,last:!0,trailing:i.jsx($1,{value:n.enabled,label:e.stMobileNotifyTitle,disabled:o,onChange:d=>{fRe(d,t)}})}),s==="configure"&&i.jsx("div",{role:"alert",style:{padding:"0 13px 11px"},children:i.jsx(_1,{error:e.stMobileNotifyError})})]})}function TV(e){const t=O(),n=Gn(e.settings,e.descriptor.setting),r=typeof(n==null?void 0:n.value)=="boolean"?n.value:!1;return i.jsx(Oo,{dataKey:e.descriptor.setting,title:t[e.descriptor.titleKey],sub:`${t[e.descriptor.descKey]} · ${(n==null?void 0:n.source)??"—"}`,trailing:i.jsx($1,{value:r,label:t[e.descriptor.titleKey],disabled:!n||e.pending,onChange:o=>e.onToggle(e.descriptor.setting,o)})})}function nFe(e){var s,a;const t=O(),n=Ku(e.snapshot.settings),r=(s=Gn(n,"adminChannel"))==null?void 0:s.value,o=(a=Gn(n,"feishuAdminChannel"))==null?void 0:a.value;return i.jsxs(i.Fragment,{children:[i.jsx(xn,{children:UN.map(l=>i.jsx(TV,{descriptor:l,settings:n,pending:e.write.pending,onToggle:e.write.onToggle},l.setting))}),i.jsxs(xn,{title:t.stNotifyRoutingTitle,children:[i.jsx(Oo,{title:"Slack",sub:gu(e.snapshot.env,"SLACK_")?String(r??"—"):"—"}),i.jsx(Oo,{title:"飞书",sub:gu(e.snapshot.env,"FEISHU_")?String(o??"—"):"—",last:!0})]})]})}function rFe(e){var r;const t=O(),n=((r=Xx(e.snapshot.env)[e.descriptor.env])==null?void 0:r.present)===!0;return i.jsx(Oo,{dataKey:e.descriptor.env,title:t[e.descriptor.titleKey],sub:`${t[e.descriptor.descKey]} · ${e.descriptor.env}`,trailing:i.jsx($1,{value:n,label:t[e.descriptor.titleKey],disabled:!0})})}function oFe(e){const t=O(),n=Gn(e.settings,e.descriptor.setting),r=typeof(n==null?void 0:n.value)=="number"?n.value:null,[o,s]=f.useState(r===null?"":String(r));f.useEffect(()=>s(r===null?"":String(r)),[r]);const a=HN(o),l=a!==null&&a>=1&&a<=yg;return i.jsx(Oo,{dataKey:e.descriptor.setting,title:t[e.descriptor.titleKey],sub:t[e.descriptor.descKey],trailing:i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",width:132},children:[i.jsx("input",{type:"number",value:o,onChange:c=>s(c.target.value),style:{width:56,minWidth:0}}),i.jsx(Io,{disabled:r===null||!l||a===r||e.write.pending,onClick:()=>{l&&e.write.onSet(e.descriptor.setting,a)},children:t.stBuiltinSave})]})})}function iFe(e){var a;const t=O(),n=Gn(e.settings,"taskDispatchMaxConcurrent"),r=n==null?void 0:n.value,o=((a=Xx(e.snapshot.env).CORTEX_GPU_MONITOR_MOCK)==null?void 0:a.present)===!0,s=n?typeof r=="number"?r:t.stAuto:"—";return i.jsxs(i.Fragment,{children:[i.jsx(Oo,{title:t.advConc,sub:t.stAdvConcNote,trailing:i.jsx("span",{style:Au,children:s})}),i.jsx(Oo,{title:t.stGpuMock,sub:t.advMock,last:!0,trailing:i.jsx("span",{style:Au,children:o?t.stSet:"—"})})]})}function sFe(e){const t=Ku(e.snapshot.settings);return i.jsxs(xn,{children:[VN.map(n=>n.kind==="env"?i.jsx(rFe,{descriptor:n,snapshot:e.snapshot},`env:${n.env}`):i.jsx(TV,{descriptor:n,settings:t,pending:e.write.pending,onToggle:e.write.onToggle},n.setting)),qN.map(n=>i.jsx(oFe,{descriptor:n,settings:t,write:e.write},n.setting)),i.jsx(iFe,{snapshot:e.snapshot,settings:t})]})}function aFe(e){var l;const t=O(),n=typeof((l=e.entry)==null?void 0:l.value)=="number"?e.entry.value:null,r=n===null?{value:1,unit:"min"}:Sv(n),[o,s]=f.useState(r);f.useEffect(()=>{n!==null&&s(Sv(n))},[n]);const a=KN(o.value,o.unit);return i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 82px",gap:7,padding:"0 13px 11px"},children:[i.jsx(xs,{label:t.stBuiltinInterval,type:"number",min:1,value:o.value,onChange:c=>s({...o,value:Number(c.target.value)})}),i.jsxs(Nf,{label:"Unit",value:o.unit,onChange:c=>s({...o,unit:c.target.value}),children:[i.jsx("option",{value:"sec",children:"sec"}),i.jsx("option",{value:"min",children:"min"}),i.jsx("option",{value:"hr",children:"hr"})]}),i.jsx("div",{style:{gridColumn:"1 / -1"},children:i.jsx(Io,{disabled:n===null||a===null||a===n||e.write.pending,onClick:()=>{a!==null&&e.write.onSet(e.descriptor.interval,a)},children:t.stBuiltinSave})})]})}function lFe(e){const t=O(),n=Gn(e.settings,e.descriptor.enabled),r=Gn(e.settings,e.descriptor.interval),o=typeof(n==null?void 0:n.value)=="boolean"?n.value:!1;return i.jsxs("div",{style:{borderBottom:"1px solid var(--m-divider)"},children:[i.jsx(Oo,{title:t[e.descriptor.titleKey],sub:t[e.descriptor.descKey],last:!0,trailing:i.jsx($1,{value:o,label:t[e.descriptor.titleKey],disabled:!n||e.write.pending,onChange:s=>e.write.onToggle(e.descriptor.enabled,s)})}),i.jsx(aFe,{descriptor:e.descriptor,entry:r,write:e.write})]})}function cFe(e){const t=O(),n=Ku(e.snapshot.settings);return i.jsxs(i.Fragment,{children:[i.jsx(sFe,{snapshot:e.snapshot,write:e.write}),i.jsx(xn,{title:t.stBuiltinJobsTitle,children:GN.map(r=>i.jsx(lFe,{descriptor:r,settings:n,write:e.write},r.enabled))}),i.jsx("div",{style:Au,children:"settings · config.set"})]})}function PV({kind:e}){const t=he(),n=O(),r=Xe(),o=ae(t.config.get.queryOptions({})),s=B3(),a=e==="notifications"?n.stNavNotifications:n.stNavAdvanced;let l;return o.isLoading?l=i.jsx(xn,{children:i.jsx("div",{style:{padding:13},children:n.stLoadingConfig})}):o.isError||!o.data?l=i.jsx(xn,{children:i.jsx("div",{style:{padding:13,color:y.fail},children:n.stFailedLoadConfig})}):l=e==="notifications"?i.jsx(nFe,{snapshot:o.data,write:s}):i.jsx(cFe,{snapshot:o.data,write:s}),i.jsxs(Li,{title:a,onBack:()=>r("/m/settings"),children:[e==="notifications"&&i.jsx(tFe,{}),l]})}function dFe(){return i.jsx(PV,{kind:"notifications"})}function uFe(){return i.jsx(PV,{kind:"advanced"})}const pFe={sessions:i.jsx(GMe,{}),threads:i.jsx(KAe,{}),tasks:i.jsx(sDe,{}),project:i.jsx(LDe,{}),session:i.jsx(RAe,{}),plan:i.jsx(AAe,{}),thread:i.jsx(SLe,{}),task:i.jsx(zLe,{}),approvals:i.jsx(WDe,{}),issues:i.jsx(KDe,{}),notes:i.jsx(oLe,{}),memory:i.jsx(ULe,{}),memoryFile:i.jsx(QLe,{}),machines:i.jsx(pOe,{}),settings:i.jsx(ROe,{}),settingsAccounts:i.jsx(NOe,{}),settingsAppearance:i.jsx(WNe,{}),settingsPlatform:i.jsx(UNe,{}),settingsProfiles:i.jsx(QNe,{}),settingsBudget:i.jsx(JNe,{}),settingsMcp:i.jsx(eFe,{}),settingsNotifications:i.jsx(dFe,{}),settingsAdvanced:i.jsx(uFe,{}),settingsHooks:i.jsx(ZOe,{}),settingsUsage:i.jsx(NNe,{}),daemon:i.jsx(gNe,{})},fFe=z1.map(e=>({path:e.path,element:pFe[e.id]})),kR=i.jsx(yN,{to:KU("sessions"),replace:!0}),hFe=[{path:"/",element:i.jsx(KRe,{}),children:[{index:!0,element:kR},...fFe,{path:"*",element:kR}]}],mFe=SN(hFe);function gFe(){const e=y3();return i.jsx($se,{router:e?mFe:PEe})}const EV=document.getElementById("root");if(!EV)throw new Error("#root element not found");QI(EV).render(i.jsx(f.StrictMode,{children:i.jsx(hie,{children:i.jsx(gFe,{})})}));export{qre as a,Ka as i};