factory-factory 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/client/assets/{DotsThree.es-3R3Ey_3J.js → DotsThree.es-Dx8TXzzQ.js} +1 -1
- package/dist/client/assets/{abnfDiagram-WEYOIA3C-Bee0noBy.js → abnfDiagram-WEYOIA3C-D-WiX0ND.js} +1 -1
- package/dist/client/assets/{admin-page-DfuRxjZu.js → admin-page-BdYXlEfi.js} +1 -1
- package/dist/client/assets/{agent-authoring-DisJfxVO.js → agent-authoring-CzgCC7xn.js} +1 -1
- package/dist/client/assets/{agents-Dk3H1TXr.js → agents-B6BxITMg.js} +1 -1
- package/dist/client/assets/{agents-CfdFfTgO.js → agents-CIGVR3Yk.js} +1 -1
- package/dist/client/assets/{architectureDiagram-ZHVYKT53-BLmWRglN.js → architectureDiagram-ZHVYKT53-D-Nk4IRx.js} +1 -1
- package/dist/client/assets/{chat-k4KrNKEG.js → chat-BsZewCkt.js} +6 -6
- package/dist/client/assets/{chunk-2E7WHVMD-w7vgcqiS.js → chunk-2E7WHVMD-DsLW-8KW.js} +1 -1
- package/dist/client/assets/{chunk-NQOKRVIF-KtzgEnyd.js → chunk-NQOKRVIF-CMnJ0k4D.js} +1 -1
- package/dist/client/assets/{classDiagram-v2-4MYWR3UA-CEW1Tyc1.js → classDiagram-v2-4MYWR3UA-BRoc4t8Q.js} +1 -1
- package/dist/client/assets/client-modules.json +1 -1
- package/dist/client/assets/{codex-accounts-DneS5v9d.js → codex-accounts-C8imj_4P.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-WF24UDRP-D1ROISR-.js → cynefinDiagram-WF24UDRP-6T3PH0XT.js} +1 -1
- package/dist/client/assets/{data-import-button-_xEBb5se.js → data-import-button-BH9f-Pg6.js} +1 -1
- package/dist/client/assets/detail-C4NZBe6t.js +2 -0
- package/dist/client/assets/{diagram-CBK3MWTC-DmmdvgW0.js → diagram-CBK3MWTC-YepopftI.js} +1 -1
- package/dist/client/assets/{diagram-I5XIIV2D-DWcHOCm7.js → diagram-I5XIIV2D-BJli7Wmv.js} +1 -1
- package/dist/client/assets/{diagram-ODIL2UCW-CCjV8NYE.js → diagram-ODIL2UCW-CSqmCku9.js} +1 -1
- package/dist/client/assets/{diagram-RJA3I4VV-CPsIPBHP.js → diagram-RJA3I4VV-Din95BTu.js} +1 -1
- package/dist/client/assets/{diagram-TYUNFSNR-DfiCPVDZ.js → diagram-TYUNFSNR-DDVwAmk7.js} +1 -1
- package/dist/client/assets/{diff-viewer-B3Gavo18.js → diff-viewer-DNUPJg_G.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-V4P3TTPT-DFgHqp_A.js → ebnfDiagram-V4P3TTPT-Bt8SCelN.js} +1 -1
- package/dist/client/assets/{erDiagram-KYQIGQAA-3CMf47Oo.js → erDiagram-KYQIGQAA-BDYCjid-.js} +1 -1
- package/dist/client/assets/{event-agent-workspace-form-BRo9-ant.js → event-agent-workspace-form-CWmktyXd.js} +1 -1
- package/dist/client/assets/{file-viewer-j5Jpwj03.js → file-viewer-CbXNMHbC.js} +1 -1
- package/dist/client/assets/{flowDiagram-IUGLLWBU-BibxWOGu.js → flowDiagram-IUGLLWBU-CJN9xdYn.js} +1 -1
- package/dist/client/assets/{highlighted-body-JLMTFACH-CTYCDAzZ.js → highlighted-body-JLMTFACH-Dy-R6Y8r.js} +1 -1
- package/dist/client/assets/{home-JqvALE6e.js → home-pNFIyVOJ.js} +1 -1
- package/dist/client/assets/{index-CsEmj4uI.js → index-BHTworEd.js} +3 -3
- package/dist/client/assets/index-sK2DBc7b.css +2 -0
- package/dist/client/assets/{infoDiagram-MVDRKAX5-DSWdrt8D.js → infoDiagram-MVDRKAX5-CZx5KLLZ.js} +1 -1
- package/dist/client/assets/{inline-workspace-form-Bz5l2APT.js → inline-workspace-form-DvVz3qgr.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-FSgsA2AR.js → ishikawaDiagram-HPEHV2GE-C0ax8nAT.js} +1 -1
- package/dist/client/assets/{issue-launch-sheet-BRDwvTJ4.js → issue-launch-sheet-Cvig-i15.js} +1 -1
- package/dist/client/assets/{kanban-BdZGeiS3.js → kanban-CWhDBIAX.js} +1 -1
- package/dist/client/assets/{kanban-card-rSBlZkVU.js → kanban-card-xzqAUkmg.js} +1 -1
- package/dist/client/assets/{kanban-definition-FNSA4HC5-tMB1t3DY.js → kanban-definition-FNSA4HC5-FG4uAvnN.js} +1 -1
- package/dist/client/assets/{legacy-BTW92e33.js → legacy-COQTLf7j.js} +1 -1
- package/dist/client/assets/{legacy-V_60vIE-.js → legacy-xGT-esX6.js} +1 -1
- package/dist/client/assets/{list-BmKFMI74.js → list-DhQWjiv0.js} +1 -1
- package/dist/client/assets/{list-DsaPNjwB.js → list-sOGdiDXi.js} +1 -1
- package/dist/client/assets/{logs-BOc2McRY.js → logs-DOOyulI5.js} +1 -1
- package/dist/client/assets/mermaid-WFAXDIZX-Bb-EeuSh.js +1 -0
- package/dist/client/assets/{mermaid-diagram-xMTMF9cZ.js → mermaid-diagram-DHR-LEin.js} +4 -4
- package/dist/client/assets/{mindmap-definition-6OY57UG3-j7CA3P01.js → mindmap-definition-6OY57UG3-B3bdhe56.js} +1 -1
- package/dist/client/assets/{mobile-baseline-L5CeIxdL.js → mobile-baseline-C2AnUNW1.js} +1 -1
- package/dist/client/assets/{new-D7tQEfVC.js → new-BJg9Bigj.js} +1 -1
- package/dist/client/assets/{new-BQd-dhG6.js → new-DUJNL_Jv.js} +1 -1
- package/dist/client/assets/{pegDiagram-ECIUJNBX-DEegjstG.js → pegDiagram-ECIUJNBX-DOYkHKRd.js} +1 -1
- package/dist/client/assets/{pieDiagram-GNMPY74T-dwwO6W-b.js → pieDiagram-GNMPY74T-8JeV6xrB.js} +1 -1
- package/dist/client/assets/{pr-inbox-item-B5bRWOFi.js → pr-inbox-item-BGuMexFr.js} +1 -1
- package/dist/client/assets/project-CTLOJEoH.js +1 -0
- package/dist/client/assets/{project-header-HAvaNT0j.js → project-header-cDqQN0Dp.js} +1 -1
- package/dist/client/assets/{project-repo-form-auALDtmF.js → project-repo-form-8h-x4Jm-.js} +1 -1
- package/dist/client/assets/{provider-cli-warning-zS21ocrg.js → provider-cli-warning-B6YVtj_C.js} +1 -1
- package/dist/client/assets/{query-state-CXtAqj2j.js → query-state-DeXwsPfq.js} +1 -1
- package/dist/client/assets/{railroadDiagram-Y72NRBL7-D7Uog2Fm.js → railroadDiagram-Y72NRBL7-D6nXF23_.js} +1 -1
- package/dist/client/assets/{requirementDiagram-EQYSW5RA-B3wNTb-Q.js → requirementDiagram-EQYSW5RA-CjjGJH_A.js} +1 -1
- package/dist/client/assets/{reviews-CDcqIqww.js → reviews-r5Fft2S9.js} +1 -1
- package/dist/client/assets/{right-panel-Da3HBtP9.js → right-panel-BUm-IUuW.js} +3 -3
- package/dist/client/assets/{sequenceDiagram-BLEHNHQU-DP_HwtCk.js → sequenceDiagram-BLEHNHQU-X8vRIVgX.js} +1 -1
- package/dist/client/assets/{settings-page-layout-GGXQVcn2.js → settings-page-layout-Cyc2QcuG.js} +1 -1
- package/dist/client/assets/{setup-terminal-modal-BkWxwfcM.js → setup-terminal-modal-CRZrWgCt.js} +2 -2
- package/dist/client/assets/{startup-script-form-C-ML7N9W.js → startup-script-form-edXnfByI.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-DJI19fIo.js → stateDiagram-v2-A6IESKWZ-Bum1zshG.js} +1 -1
- package/dist/client/assets/{swimlanesDiagram-AYQRV4AK-B9lsGgJz.js → swimlanesDiagram-AYQRV4AK-DBKC7Yfq.js} +1 -1
- package/dist/client/assets/{terminal-instance-Bj45VPmw.js → terminal-instance-Y05XGV6V.js} +1 -1
- package/dist/client/assets/{timeline-definition-JXYKGLGB-CW_cFL5m.js → timeline-definition-JXYKGLGB-CLF-s_Xn.js} +1 -1
- package/dist/client/assets/{transcript-scroll-fixture-CRCDh-Wd.js → transcript-scroll-fixture-DNVPzw5t.js} +1 -1
- package/dist/client/assets/{use-project-header-navigation-D1btSafx.js → use-project-header-navigation-CGIZMabH.js} +1 -1
- package/dist/client/assets/{use-workspace-creation-draft-CofTBRfu.js → use-workspace-creation-draft-Bl2dlNzf.js} +1 -1
- package/dist/client/assets/{use-workspace-project-navigation-B3bveEA4.js → use-workspace-project-navigation-B0LZj578.js} +1 -1
- package/dist/client/assets/{usecaseDiagram-WPOLBNNX-MCJs1VFk.js → usecaseDiagram-WPOLBNNX-CUYfjlrO.js} +1 -1
- package/dist/client/assets/{vennDiagram-Q3Y3IDCW-DV_BPr8T.js → vennDiagram-Q3Y3IDCW-B9Upmplw.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-IVAIDKWA-E_U6VORQ.js → wardleyDiagram-IVAIDKWA-C9_DfFfF.js} +1 -1
- package/dist/client/assets/{websocket-DW_R60Td.js → websocket-BT8C-OBP.js} +1 -1
- package/dist/client/assets/{workspace-creation-drop-drain-Dk5pygZx.js → workspace-creation-drop-drain-BcuDXdq-.js} +1 -1
- package/dist/client/assets/{xychartDiagram-4URNHDU4-BBqR12LO.js → xychartDiagram-4URNHDU4-wRTlHEa4.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/src/backend/services/workspace/service/worktree/git-ops.service.d.ts.map +1 -1
- package/dist/src/backend/services/workspace/service/worktree/git-ops.service.js +3 -3
- package/dist/src/backend/services/workspace/service/worktree/git-ops.service.js.map +1 -1
- package/dist/src/backend/services/workspace/service/worktree/git-ops.service.test.js +30 -6
- package/dist/src/backend/services/workspace/service/worktree/git-ops.service.test.js.map +1 -1
- package/dist/src/backend/services/workspace/service/worktree/git-ops.symlink.integration.test.js +1 -4
- package/dist/src/backend/services/workspace/service/worktree/git-ops.symlink.integration.test.js.map +1 -1
- package/dist/src/backend/services/workspace-git-state.concurrency.test.js +6 -1
- package/dist/src/backend/services/workspace-git-state.concurrency.test.js.map +1 -1
- package/dist/src/backend/services/workspace-git-state.linux.test.d.ts +2 -0
- package/dist/src/backend/services/workspace-git-state.linux.test.d.ts.map +1 -0
- package/dist/src/backend/services/workspace-git-state.linux.test.js +68 -0
- package/dist/src/backend/services/workspace-git-state.linux.test.js.map +1 -0
- package/dist/src/backend/services/workspace-git-state.service.d.ts +4 -0
- package/dist/src/backend/services/workspace-git-state.service.d.ts.map +1 -1
- package/dist/src/backend/services/workspace-git-state.service.js +39 -7
- package/dist/src/backend/services/workspace-git-state.service.js.map +1 -1
- package/dist/src/backend/services/workspace-git-state.service.test.js +104 -3
- package/dist/src/backend/services/workspace-git-state.service.test.js.map +1 -1
- package/dist/src/backend/services/workspace-git-state.untracked.test.d.ts +2 -0
- package/dist/src/backend/services/workspace-git-state.untracked.test.d.ts.map +1 -0
- package/dist/src/backend/services/workspace-git-state.untracked.test.js +32 -0
- package/dist/src/backend/services/workspace-git-state.untracked.test.js.map +1 -0
- package/dist/tsconfig.backend.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/client/assets/detail-nvqdqAi4.js +0 -2
- package/dist/client/assets/index-Dv7JoSz4.css +0 -2
- package/dist/client/assets/mermaid-WFAXDIZX-BEvuy0OL.js +0 -1
- package/dist/client/assets/project-Dsu4tgVT.js +0 -1
package/dist/client/assets/{data-import-button-_xEBb5se.js → data-import-button-BH9f-Pg6.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{n as r}from"./trpc-D9WuCSM1.js";import{r as i,t as a}from"./background-task-2TNZSSC3.js";import{r as o}from"./utils-DQeSPVda.js";import{t as s}from"./CheckCircle.es-WUl0_Fqk.js";import{t as c}from"./spinner-BxeSV-Bb.js";import{t as l}from"./Warning.es-BRY0GI4S.js";import{t as u}from"./button-Dslj7pht.js";import{C as d,E as f,S as p,T as ee,_ as m,b as h,h as te,k as g,l as ne,o as _,p as v,r as y,s as b,v as x,w as S,x as C,y as re}from"./schemas-cLRPP1ma.js";import{B as w,H as ie,I as ae,J as oe,L as se,Q as ce,R as le,U as ue,V as de,W as fe,X as pe,Y as me,Z as he,d as ge,et as T,f as _e,l as ve,q as ye,z as be}from"./workspace-cache-reconciler-TKQHxUsu.js";import{d as xe,f as E,i as Se,l as D,m as Ce}from"./appearance-DsbwoDTa.js";import{an as we,g as Te,o as Ee,on as De}from"./index-CsEmj4uI.js";import{i as Oe,r as O}from"./agent-definition.schema-DaZC-6OB.js";import{t as ke}from"./CircleDashed.es-Q7XmyA0_.js";import{t as Ae}from"./Terminal.es-DXk70l2n.js";import{n as je,r as Me,t as Ne}from"./voice-vad-ChMQMgBS.js";var k=n();function Pe({status:e}){return e===`ok`?(0,k.jsx)(s,{className:`h-4 w-4 text-success`}):e===`warning`?(0,k.jsx)(l,{className:`h-4 w-4 text-warning`}):(0,k.jsx)(ke,{className:`h-4 w-4 text-muted-foreground`})}function Fe(e){let t=[];return e.claude.isInstalled?e.claude.isAuthenticated===!0?t.push({label:`Claude`,status:`ok`,detail:`Ready`}):t.push({label:`Claude`,status:`warning`,detail:`Installed — use Sign in to Claude in the setup terminal`}):t.push({label:`Claude`,status:`missing`,detail:`Bundled runtime unavailable — update Factory Factory`}),e.codex.isInstalled?e.codex.isAuthenticated===!0?t.push({label:`Codex`,status:`ok`,detail:`Ready`}):t.push({label:`Codex`,status:`warning`,detail:`Use Sign in to Codex in the setup terminal`}):t.push({label:`Codex`,status:`missing`,detail:e.codex.error??`Bundled runtime unavailable — update Factory Factory`}),e.github.isInstalled?e.github.isAuthenticated?t.push({label:`GitHub CLI`,status:`ok`,detail:`Ready`}):t.push({label:`GitHub CLI`,status:`warning`,detail:`Installed — run gh auth login to authenticate`}):t.push({label:`GitHub CLI`,status:`missing`,detail:`Not installed`}),t}function Ie({onOpenTerminal:e}){let{refresh:t,isRefreshing:n}=we(),{data:i,isLoading:a,isRefetching:o}=r.admin.checkCLIHealth.useQuery({forceRefresh:!1},{refetchOnWindowFocus:!1,staleTime:6e4});if(a)return(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground py-2`,children:[(0,k.jsx)(c,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{children:`Checking CLI prerequisites…`})]});if(!i)return null;let s=Fe(i),l=s.some(e=>e.status!==`ok`);return(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`CLI Prerequisites`}),(0,k.jsxs)(u,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted-foreground`,onClick:()=>void t(),disabled:o||n,children:[o||n?(0,k.jsx)(c,{className:`mr-1 h-3 w-3`,"aria-hidden":`true`}):(0,k.jsx)(De,{className:`mr-1 h-3 w-3`}),`Recheck`]})]}),(0,k.jsx)(`ul`,{className:`space-y-1.5`,children:s.map(e=>(0,k.jsxs)(`li`,{className:`flex items-center gap-2 text-sm`,children:[(0,k.jsx)(Pe,{status:e.status}),(0,k.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,k.jsxs)(`span`,{className:`text-muted-foreground`,children:[`— `,e.detail]})]},e.label))}),l&&(0,k.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:e,children:[(0,k.jsx)(Ae,{className:`mr-2 h-4 w-4`}),`Open terminal to log in`]})]})}var A=e(t(),1),Le=new Map([[`regular`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M240,136v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V136a16,16,0,0,1,16-16H80a8,8,0,0,1,0,16H32v64H224V136H176a8,8,0,0,1,0-16h48A16,16,0,0,1,240,136ZM85.66,77.66,120,43.31V128a8,8,0,0,0,16,0V43.31l34.34,34.35a8,8,0,0,0,11.32-11.32l-48-48a8,8,0,0,0-11.32,0l-48,48A8,8,0,0,0,85.66,77.66ZM200,168a12,12,0,1,0-12,12A12,12,0,0,0,200,168Z`}))]]),Re=A.forwardRef((e,t)=>A.createElement(o,{ref:t,...e,weights:Le}));Re.displayName=`UploadIcon`;var ze=x({id:C().regex(/^[A-Za-z0-9_-]+$/),label:C().trim().min(1).max(100),kind:te(se),enabled:b(),identityKey:C().regex(/^(?:[a-f0-9]{64}|native-email:[a-f0-9]{64}(?::imported:[A-Za-z0-9_-]+)?)$/).nullable()}),Be=[{model:`flux-hannah-en`,name:`Hannah`,description:`Clear, confident, thoughtful`},{model:`flux-kit-en`,name:`Kit`,description:`Friendly, energetic, thoughtful`},{model:`flux-alexis-en`,name:`Alexis`,description:`Clear, professional, calm`},{model:`flux-cliff-en`,name:`Cliff`,description:`Deep, confident, calm`},{model:`flux-sienna-en`,name:`Sienna`,description:`Clear, professional, calm`},{model:`flux-cole-en`,name:`Cole`,description:`Friendly, clear, interesting`},{model:`flux-brooke-en`,name:`Brooke`,description:`Friendly, intelligent, fast`},{model:`flux-colin-en`,name:`Colin`,description:`Warm, friendly, trustworthy`},{model:`flux-gemma-en`,name:`Gemma`,description:`Friendly, kind, approachable`},{model:`flux-haley-en`,name:`Haley`,description:`Clear, professional, caring`},{model:`flux-heather-en`,name:`Heather`,description:`Clear, engaging, energetic`},{model:`flux-miles-en`,name:`Miles`,description:`Clear, calm, professional`},{model:`flux-sean-en`,name:`Sean`,description:`Friendly, kind, caring`},{model:`flux-bree-en`,name:`Bree`,description:`Friendly, sweet, kind`},{model:`flux-brittany-en`,name:`Brittany`,description:`Confident, kind, soft`},{model:`flux-bruce-en`,name:`Bruce`,description:`Friendly, kind, natural`},{model:`flux-conor-en`,name:`Conor`,description:`Confident, deep, friendly`},{model:`flux-donovan-en`,name:`Donovan`,description:`Professional, calm, thoughtful`},{model:`flux-drew-en`,name:`Drew`,description:`Confident, relaxed, soft`},{model:`flux-elise-en`,name:`Elise`,description:`Clear, professional, calm`},{model:`flux-jack-en`,name:`Jack`,description:`Confident, thoughtful, friendly`},{model:`flux-kai-en`,name:`Kai`,description:`Clear, calm, professional`},{model:`flux-kelsey-en`,name:`Kelsey`,description:`Clear, professional, caring`},{model:`flux-maeve-en`,name:`Maeve`,description:`Friendly, energetic, confident`},{model:`flux-marcelo-en`,name:`Marcelo`,description:`Clear, calm, professional`},{model:`flux-marcus-en`,name:`Marcus`,description:`Friendly, helpful, smooth`},{model:`flux-meena-en`,name:`Meena`,description:`Empathetic, professional, calm`},{model:`flux-meghan-en`,name:`Meghan`,description:`Friendly, nice, energetic`},{model:`flux-naveen-en`,name:`Naveen`,description:`Clear, professional, knowledgeable`},{model:`flux-paige-en`,name:`Paige`,description:`Clear, professional, calm`},{model:`flux-priya-en`,name:`Priya`,description:`Confident, empathetic, professional`},{model:`flux-rufus-en`,name:`Rufus`,description:`Friendly, confident, intelligent`},{model:`flux-sharon-en`,name:`Sharon`,description:`Formal, calm, relaxed`},{model:`flux-tanner-en`,name:`Tanner`,description:`Professional, calm, confident`},{model:`flux-wade-en`,name:`Wade`,description:`Warm, confident, clear`},{model:`flux-wes-en`,name:`Wes`,description:`Thoughtful, friendly, warm`}],j=`flux-haley-en`,M=.5,N=1.5,P=.05;function Ve(e){return Be.some(t=>t.model===e)}function He(e){if(!Number.isFinite(e))return 1;let t=Math.round((Math.min(N,Math.max(M,e))-M)/P);return Math.round((M+t*P)*100)/100}function Ue(e){return Ve(e)?e:j}function F(e){return e.prs.length?e.prs.map(({id:e,url:t})=>({id:e,url:t})):e.prUrl?[{id:`legacy-pr-${e.id}`,url:e.prUrl}]:[]}function We(e,t){let n=!0,r=(e,r)=>{new Set(e).size!==e.length&&(t.addIssue({code:`custom`,path:[`data`,...r],message:`Duplicate source identity`}),n=!1)};return r(e.data.projects.map(e=>e.id),[`projects`]),r(e.data.projects.map(e=>e.slug),[`projects`]),r(e.data.workspaces.map(e=>e.id),[`workspaces`]),r(e.data.agentSessions.map(e=>e.id),[`agentSessions`]),r(e.data.terminalSessions.map(e=>e.id),[`terminalSessions`]),r(e.data.workspaces.flatMap(e=>e.prEvents.map(e=>e.id)),[`workspaces`]),r(e.data.workspaces.flatMap(e=>F(e).map(e=>e.id)),[`workspaces`]),n}function Ge(e,t){let n=new Map(e.data.agentSessions.map(e=>[e.id,e.workspaceId]));for(let[r,i]of e.data.workspaces.entries())[i.ratchetActiveSessionId,i.prMonitoring?.recipientSessionId,...i.prMonitoring?.legacySessionIds??[],...i.prEvents.map(e=>e.deliverySessionId)].some(e=>e!=null&&n.has(e)&&n.get(e)!==i.id)&&t.addIssue({code:`custom`,path:[`data`,`workspaces`,r],message:`Declared session must belong to its file workspace`})}function Ke(e,t){let n=new Map(e.data.workspaces.map(e=>[e.id,e]));for(let[r,i]of e.data.workspaces.entries()){if(i.parentWorkspaceId===null)continue;let e=n.get(i.parentWorkspaceId);e&&e!==i&&e.parentWorkspaceId===null&&e.projectId===i.projectId||t.addIssue({code:`custom`,path:[`data`,`workspaces`,r,`parentWorkspaceId`],message:`Parent must be a different file-owned root in the same project`})}}function qe(e,t){let n=new Map;for(let[r,i]of e.data.workspaces.entries())for(let e of i.prEvents){if(e.deliveryId===null)continue;let a=n.get(e.deliveryId);a!==void 0&&a!==i.id&&t.addIssue({code:`custom`,path:[`data`,`workspaces`,r,`prEvents`],message:`Receipt members must belong to one workspace`}),n.set(e.deliveryId,i.id)}}function Je(e,t,n){let r=e.payload.kind===`MONITORING_ENABLED`?e.payload:e.payload.target,i=e.payload.kind===`MONITORING_ENABLED`?e.prId===null:e.payload.target.prId===e.prId;return e.workspaceId===t&&r.workspaceId===t&&(e.prId===null||n.has(e.prId))&&i}function Ye(e,t){let n=new Map;for(let[r,i]of e.data.workspaces.entries()){let e=new Set,a=new Set(F(i).map(e=>e.id));i.prEvents.forEach(o=>{let s=e=>t.addIssue({code:`custom`,path:[`data`,`workspaces`,r,`prEvents`],message:e});Je(o,i.id,a)||s(`Event and payload must belong to their declared workspace and PR`);let c=o.prId===null?void 0:n.get(o.prId);if((e.has(o.deduplicationKey)||c?.has(o.deduplicationKey))&&s(`Duplicate event deduplication key`),e.add(o.deduplicationKey),o.prId!==null){let e=c??new Set;e.add(o.deduplicationKey),n.set(o.prId,e)}})}}function Xe(e,t){for(let[n,r]of e.data.workspaces.entries())for(let[i,a]of r.prs.entries()){let o=a.dedicatedSession?.sessionId;if(o==null)continue;let s=e.data.agentSessions.find(e=>e.id===o);s&&s.workspaceId===r.id&&s.workspacePrId===a.id&&s.workflow===`pr-monitoring`||t.addIssue({code:`custom`,path:[`data`,`workspaces`,n,`prs`,i,`dedicatedSession`],message:`Dedicated conversation must belong to this PR and workspace`})}}function Ze(e,t){if(!We(e,t))return;Ke(e,t),qe(e,t),Ye(e,t),Ge(e,t),Xe(e,t);let n=new Set,r=new Map;for(let[i,a]of e.data.workspaces.entries()){let e=new Set;for(let[o,s]of F(a).entries())(n.has(s.id)||e.has(s.url))&&t.addIssue({code:`custom`,path:[`data`,`workspaces`,i,`prs`,o],message:`Duplicate PR identity or URL`}),n.add(s.id),e.add(s.url),r.set(s.id,a.id)}for(let[n,i]of e.data.agentSessions.entries())i.workspacePrId&&r.get(i.workspacePrId)!==i.workspaceId&&t.addIssue({code:`custom`,path:[`data`,`agentSessions`,n,`workspacePrId`],message:`Session PR must belong to its workspace`})}function Qe(e,t){for(let[n,r]of e.data.workspaces.entries()){let e=r.prs.find(e=>e.id===r.ratchetActivePrId);r.ratchetActivePrId===null&&r.ratchetActiveSessionId===null||r.ratchetActiveSessionId&&e&&!e.detachedAt&&e.ratchet.activeSessionId===r.ratchetActiveSessionId||t.addIssue({code:`custom`,path:[`data`,`workspaces`,n,`ratchetActivePrId`],message:`Active fixer must belong to an attached PR in this workspace`})}}var I=T(),$e=h({enabled:b(),deliveryMode:ve.default(`MAIN`),recipientSessionId:C().nullable(),bindingRevision:m().int().nonnegative(),eventEpoch:m().int().nonnegative(),deliveryPauseReason:C().nullable(),legacySessionIds:_(C()).default([]),lastCheckedAt:I.nullable()}),et=h({id:C().min(1),workspaceId:C().min(1),prId:C().nullable(),kind:C(),deduplicationKey:C().min(1),payload:ge,state:y([`PENDING`,`DISPATCHING`,`DELIVERED`,`SUPERSEDED`,`CANCELLED`]),attempts:m().int().nonnegative(),deliveryId:C().min(1).nullable(),deliverySessionId:C().min(1).nullable(),deliveryProvider:C().nullable().optional(),deliveryProviderSessionId:C().nullable().optional(),deliveryBindingRevision:m().int().nonnegative().nullable(),deliveryText:C().refine(e=>new TextEncoder().encode(e).byteLength<=16384,`Frozen delivery text exceeds 16 KiB`).nullable(),claimedAt:I.nullable(),deliveredAt:I.nullable(),createdAt:I}).refine(e=>e.kind===e.payload.kind,`Event kind disagrees with payload`).refine(e=>e.state!==`DISPATCHING`||!!(e.deliveryId&&e.deliverySessionId&&e.deliveryProvider&&e.deliveryProviderSessionId&&e.deliveryText&&e.deliveryBindingRevision!==null),`Dispatching event requires complete frozen delivery metadata`),L=h({dedicatedSession:h({sessionId:C().min(1).nullable()}).nullable().optional(),id:C().min(1),url:ee(),number:m().int().nullable(),title:C().nullable(),headRefName:C().nullable(),baseRefName:C().nullable(),state:y([`NONE`,`DRAFT`,`OPEN`,`CHANGES_REQUESTED`,`APPROVED`,`MERGED`,`CLOSED`]),reviewState:C().nullable(),ciStatus:y([`UNKNOWN`,`PENDING`,`SUCCESS`,`FAILURE`]),hasMergeConflict:b(),completionDismissed:b().default(!1),terminalObservedAt:I.nullable().default(null),syncedAt:I.nullable(),detachedAt:I.nullable(),revision:m().int().nonnegative(),observation:_e.nullable().default(null),observationEpoch:m().int().nonnegative().default(0),transitionSequence:m().int().nonnegative().default(0),ciFailedAt:I.nullable(),ciLastNotifiedAt:I.nullable(),reviewLastCheckedAt:I.nullable(),reviewLastCommentId:C().nullable()}),tt=h({lastCheckedAt:I.nullable(),retryCount:m().int().nonnegative(),nextCheckAt:I.nullable()}),R=C().refine(e=>e.trim().length>0,`Definition text must not be blank`),nt=S().transform((e,t)=>{let n=Oe.safeParse(e);if(!n.success){for(let e of n.error.issues)t.addIssue({...e});return g}let r=re(C(),S()).parse(e);for(let e of[`provider`,`model`,`reasoningEffort`])Object.hasOwn(r,e)&&(r[e]===void 0||r[e]!==n.data[e])&&t.addIssue({code:`custom`,path:[e],message:`Noncanonical execution preference`});return n.data}),rt=h({version:v(1),definitions:_(h({id:C(),projectId:C(),name:R,instructions:R,isEnabled:b(),executionConfig:nt,definitionRevision:O,managementRevision:O,createdAt:T(),updatedAt:T()}))}).superRefine((e,t)=>{let n=new Set;e.definitions.forEach((e,r)=>{n.has(e.id)&&t.addIssue({code:`custom`,path:[`definitions`,r,`id`],message:`Duplicate automation definition identity`}),n.add(e.id)})}),it=h({id:C(),projectId:C(),name:C(),prompt:C(),cadence:y(w),scheduledTime:C().regex(/^([01]\d|2[0-3]):[0-5]\d$/).nullable(),timezone:C().refine(e=>{try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch{return!1}},`Invalid timezone`).nullable(),scheduledDayOfMonth:m().int().min(1).max(31).nullable(),isEnabled:b(),nextRunAt:T(),lastRunAt:T().nullable(),createdAt:T(),updatedAt:T()}),at=h({version:v(1),tasks:_(it)}).superRefine((e,t)=>{let n=new Set;for(let r of e.tasks)n.has(r.id)&&t.addIssue({code:`custom`,message:`Duplicate periodic task identity`}),n.add(r.id)}),ot=h({version:v(1),projectId:C(),name:C(),prompt:C(),cadence:y(w),scheduledTime:C().nullable(),timezone:C().nullable(),scheduledDayOfMonth:m().int().nullable(),dueAt:T()}),st=h({version:v(1),executions:_(h({id:C(),periodicTaskId:C(),workspaceId:C().nullable(),launchSnapshot:ot.nullable(),status:y(de),prUrl:C().nullable(),prNumber:m().int().nullable(),errorMessage:C().nullable(),startedAt:T(),completedAt:T().nullable()})),jsonStorage:_(h({model:v(`PeriodicTaskExecution`),identity:p([C()]),field:v(`launchSnapshot`)}))}).superRefine((e,t)=>{let n=new Set,r=new Set;e.executions.forEach((e,i)=>{n.has(e.id)&&t.addIssue({code:`custom`,message:`Duplicate execution identity`,path:[`executions`,i,`id`]}),e.workspaceId!==null&&r.has(e.workspaceId)&&t.addIssue({code:`custom`,message:`Duplicate execution workspace`,path:[`executions`,i,`workspaceId`]}),n.add(e.id),e.workspaceId!==null&&r.add(e.workspaceId)});let i=new Map(e.executions.map(e=>[e.id,e])),a=new Set;e.jsonStorage.forEach((e,n)=>{let r=e.identity[0];(a.has(r)||!i.has(r)||i.get(r)?.launchSnapshot!==null)&&t.addIssue({code:`custom`,message:`Invalid execution JSON-null target`,path:[`jsonStorage`,n,`identity`]}),a.add(r)})}),ct=h({version:v(1),jsonStorage:_(ne(`model`,[h({model:v(`Workspace`),identity:p([C()]),field:v(`creationMetadata`)}),h({model:v(`WorkspacePR`),identity:p([C().min(1)]),field:v(`observation`)}),h({model:v(`AgentSession`),identity:p([C()]),field:v(`providerMetadata`)})]))});function lt(e,t,n,r){let i=new Map,a=(e,t,n,a,o)=>{let s=JSON.stringify([e,t.id,n]),c=i.get(s)??[];c.push(a),i.set(s,c),Object.hasOwn(t,n)&&a!==void 0||r.addIssue({code:`custom`,message:`Covered ${n} must be present`,path:o})};for(let[t,r]of e.workspaces.entries())if(a(`Workspace`,r,`creationMetadata`,r.creationMetadata,[`data`,`workspaces`,t,`creationMetadata`]),n)for(let[e,n]of r.prs.entries())a(`WorkspacePR`,n,`observation`,n.observation,[`data`,`workspaces`,t,`prs`,e,`observation`]);if(n)for(let[t,n]of e.agentSessions.entries())a(`AgentSession`,n,`providerMetadata`,n.providerMetadata,[`data`,`agentSessions`,t,`providerMetadata`]);let o=new Set;for(let[e,n]of t.jsonStorage.entries()){let t=JSON.stringify([n.model,n.identity[0],n.field]),a=i.get(t);(o.has(t)||a?.length!==1||a[0]!==null)&&r.addIssue({code:`custom`,message:`Invalid ${n.model} JSON-null target`,path:[`data`,`recovery`,`baseJson`,`jsonStorage`,e,`identity`]}),o.add(t)}}var ut=h({version:v(1),connections:_(h({id:C().refine(e=>e.trim().length>0,`Connection ID must not be blank`),provider:v(`SLACK`),externalId:C().refine(e=>e.trim().length>0,`Workspace ID must not be blank`),name:C().min(1),isEnabled:b(),createdAt:T(),updatedAt:T()}))}).superRefine((e,t)=>{let n=new Set,r=new Set;e.connections.forEach((e,i)=>{for(let[a,o]of[[`id`,n],[`externalId`,r]])o.has(e[a])&&t.addIssue({code:`custom`,path:[`connections`,i,a],message:`Duplicate Slack connection identity`}),o.add(e[a])})}),dt=h({model:C(),status:y([`PARTIAL`,`EXCLUDED`]),limitation:C()}),z=e=>({status:`PARTIAL`,limitation:e}),B=e=>({status:`EXCLUDED`,limitation:e}),V={Project:z(`configuration/paths; no encrypted tracker configuration restore or repository files.`),Workspace:z(`base metadata; worktree contents, complete origin history and live workflow/process authority excluded; physical nullable-JSON fidelity unproven.`),WorkspaceMetadata:z(`existing generated summaries/provenance fields when parent is accepted; no full-domain recovery claim.`),WorkspaceRunScript:z(`command/cleanup and inert runtime disposition; postRunCommand absent and PID/port/start authority excluded.`),CodexAccount:z(`identity/label metadata; owner may remap identity; native home, credentials, timestamps and executable login authority excluded.`),AgentSession:z(`base metadata/provider history identities; provider history bytes/live process and physical nullable-JSON fidelity excluded.`),TerminalSession:z(`label/metadata; process identities and terminal bytes excluded.`),UserSettings:z(`exported preference subset; keys, credentials, workspace ordering and caches excluded.`),WorkspacePR:z(`existing associations/cache; no exact normalized full ledger guarantee and physical nullable-JSON fidelity unproven.`),WorkspacePRMonitoring:z(`base configuration/history; restored disabled, no executable monitoring authority.`),WorkspacePRDedicatedSession:z(`existing base association where valid accepted owner graph exists; not an independent session/history payload.`),WorkspacePREvent:z(`flattened raw event/effect evidence; no proof of omitted original members or original frozen ordering; unfinished effects inert.`),WorkspacePRDelivery:z(`only evidence represented through base events; exact normalized delivery/membership/order not included.`),WorkspacePRDiscovery:z(`base scheduling/cache fields where present; defaults otherwise, not delivery authority or full retained history.`),DecisionLog:B(`generic decision history absent.`),WorkspaceLaunchOrigin:B(`original launch provenance absent.`),WorkspaceChildOrigin:B(`original retained/deleted-child provenance absent; import-created invalidation/origin bookkeeping is not source recovery.`),WorkspaceNotification:B(`retained mailbox rows/revision/read/ack/supersession history absent.`),WorkspaceMailState:B(`retained wake/cursor proof absent; live claims/leases are intentionally never restored.`),AgentSessionLaunchOrigin:B(`original session launch provenance absent.`),SessionLifecycleEvent:B(`lifecycle history absent.`),ClosedSession:B(`archive payload/metadata recovery absent.`),PeriodicTask:B(`periodic configuration absent.`),PeriodicTaskExecution:B(`periodic history absent.`),AgentDefinition:B(`automation definitions absent.`),AgentConnection:B(`automation connection configuration absent; secrets excluded.`),AgentTrigger:B(`automation trigger configuration absent.`),AgentRun:B(`automation run/effect history absent.`),AgentProposal:B(`draft/accepted proposal provenance absent.`),AgentSourceState:B(`source continuity state absent.`),AgentSourcePage:B(`source pages absent.`),AgentSourceBaseline:B(`source baselines absent.`),AgentSourceCheckpoint:B(`source checkpoint proof absent.`),AgentSourceHead:B(`source head proof absent.`),AgentEvent:B(`automation retained events absent.`),AgentEvaluation:B(`frozen automation decisions absent.`),AgentInitialDelivery:B(`initial automation effect evidence absent.`)},ft={...V,Workspace:z(`base metadata; Workspace.creationMetadata preserves SQL NULL versus top-level JSON null; worktree contents, complete origin history and live workflow/process authority excluded; WorkspacePR.observation and AgentSession.providerMetadata physical nullable-JSON fidelity unproven.`)},H={...V,Workspace:z(`base metadata; Workspace.creationMetadata preserves SQL NULL versus top-level JSON null; worktree contents, complete origin history and live workflow/process authority excluded.`),WorkspacePR:z(`existing associations/cache; WorkspacePR.observation preserves SQL NULL versus top-level JSON null for actual included PR rows; no exact normalized full ledger guarantee.`),AgentSession:z(`base metadata/provider history identities; AgentSession.providerMetadata preserves SQL NULL versus top-level JSON null; provider history bytes/live process excluded.`)},U={...H,PeriodicTask:z(`complete scalar configuration and timestamps; restored disabled; source enabled state is reported, not restored as scheduling authority; periodic execution history excluded.`)},W={...U,Workspace:z(`base metadata; Workspace.periodicTaskId links to newly imported disabled tasks; Workspace.creationMetadata preserves SQL NULL versus top-level JSON null; worktree contents, complete origin history and live workflow/process authority excluded.`)},G={...W,PeriodicTask:z(`complete scalar configuration and timestamps; restored disabled; source enabled state is reported, not restored as scheduling authority.`),PeriodicTaskExecution:z(`all supported retained execution scalars and canonical version-1 or legacy null launch snapshots with SQL NULL versus top-level JSON null fidelity; imported RUNNING rows become historical FAILED without asserting provider outcome; live execution and replay authority excluded.`)},pt={...G,AgentDefinition:z(`all supported scalar definition bodies and execution preferences, source revisions and timestamps; restored disabled; connections, event membership, proposal provenance, activation and run/evaluation history excluded.`)},mt={Project:z(`configuration/paths; no encrypted tracker configuration restore or repository files.`),Workspace:z(`base metadata; Workspace.periodicTaskId links to newly imported disabled tasks; Workspace.creationMetadata preserves SQL NULL versus top-level JSON null; worktree contents, complete origin history and live workflow/process authority excluded.`),WorkspaceMetadata:z(`existing generated summaries/provenance fields when parent is accepted; no full-domain recovery claim.`),WorkspaceRunScript:z(`command/cleanup and inert runtime disposition; postRunCommand absent and PID/port/start authority excluded.`),CodexAccount:z(`identity/label metadata; owner may remap identity; native home, credentials, timestamps and executable login authority excluded.`),AgentSession:z(`base metadata/provider history identities; AgentSession.providerMetadata preserves SQL NULL versus top-level JSON null; provider history bytes/live process excluded.`),TerminalSession:z(`label/metadata; process identities and terminal bytes excluded.`),UserSettings:z(`exported preference subset; keys, credentials, workspace ordering and caches excluded.`),WorkspacePR:z(`existing associations/cache; WorkspacePR.observation preserves SQL NULL versus top-level JSON null for actual included PR rows; no exact normalized full ledger guarantee.`),WorkspacePRMonitoring:z(`base configuration/history; restored disabled, no executable monitoring authority.`),WorkspacePRDedicatedSession:z(`existing base association where valid accepted owner graph exists; not an independent session/history payload.`),WorkspacePREvent:z(`flattened raw event/effect evidence; no proof of omitted original members or original frozen ordering; unfinished effects inert.`),WorkspacePRDelivery:z(`only evidence represented through base events; exact normalized delivery/membership/order not included.`),WorkspacePRDiscovery:z(`base scheduling/cache fields where present; defaults otherwise, not delivery authority or full retained history.`),DecisionLog:B(`generic decision history absent.`),WorkspaceLaunchOrigin:B(`original launch provenance absent.`),WorkspaceChildOrigin:B(`original retained/deleted-child provenance absent; import-created invalidation/origin bookkeeping is not source recovery.`),WorkspaceNotification:B(`retained mailbox rows/revision/read/ack/supersession history absent.`),WorkspaceMailState:B(`retained wake/cursor proof absent; live claims/leases are intentionally never restored.`),AgentSessionLaunchOrigin:B(`original session launch provenance absent.`),SessionLifecycleEvent:B(`lifecycle history absent.`),ClosedSession:B(`archive payload/metadata recovery absent.`),PeriodicTask:z(`complete scalar configuration and timestamps; restored disabled; source enabled state is reported, not restored as scheduling authority.`),PeriodicTaskExecution:z(`all supported retained execution scalars and canonical version-1 or legacy null launch snapshots with SQL NULL versus top-level JSON null fidelity; imported RUNNING rows become historical FAILED without asserting provider outcome; live execution and replay authority excluded.`),AgentDefinition:z(`all supported scalar definition bodies and execution preferences, source revisions and timestamps; restored disabled; connection bindings, event membership, proposal provenance, activation and run/evaluation history excluded.`),AgentConnection:z(`SLACK connection identity, name, source enabled state and timestamps; restored disabled and without credentials; GitHub connections, credentials and live connection authority excluded.`),AgentTrigger:B(`automation trigger configuration absent.`),AgentRun:B(`automation run/effect history absent.`),AgentProposal:B(`draft/accepted proposal provenance absent.`),AgentSourceState:B(`source continuity state absent.`),AgentSourcePage:B(`source pages absent.`),AgentSourceBaseline:B(`source baselines absent.`),AgentSourceCheckpoint:B(`source checkpoint proof absent.`),AgentSourceHead:B(`source head proof absent.`),AgentEvent:B(`automation retained events absent.`),AgentEvaluation:B(`frozen automation decisions absent.`),AgentInitialDelivery:B(`initial automation effect evidence absent.`)},K=[`SECRETS_AND_ENCRYPTION_KEYS`,`NATIVE_ACCOUNT_HOMES`,`WORKTREE_AND_REPOSITORY_CONTENTS`,`PROVIDER_OWNED_HISTORY`,`LIVE_PROCESS_IDS_AND_RUNTIME_LEASES`,`PHYSICAL_NULLABLE_JSON_FIDELITY`],ht=h({baseJson:ct.optional(),periodicConfig:at.optional(),periodicHistory:st.optional(),automationDefinitions:rt.optional(),slackConnections:ut.optional()}),q=h({version:v(1),profile:y([`base-1`,`base-json-workspace-1`,`base-json-1`,`base-json-periodic-config-1`,`base-json-periodic-links-1`,`base-json-periodic-history-1`,`base-json-automation-definitions-1`,`base-json-slack-connections-1`]),status:v(`PARTIAL`),capabilities:h({baseJson:v(1).optional(),periodicConfig:v(1).optional(),periodicHistory:v(1).optional(),automationDefinitions:v(1).optional(),slackConnections:v(1).optional()}),coverage:_(dt),exclusions:_(y(K))}).superRefine((e,t)=>{let n=e.profile===`base-json-slack-connections-1`;(n!==Object.hasOwn(e.capabilities,`slackConnections`)||n&&e.capabilities.slackConnections!==1)&&t.addIssue({code:`custom`,message:`Slack profile capabilities do not match`})}).superRefine((e,t)=>{let n=e.profile!==`base-1`,r=[`base-json-periodic-config-1`,`base-json-periodic-links-1`,`base-json-periodic-history-1`,`base-json-automation-definitions-1`,`base-json-slack-connections-1`].includes(e.profile),i=e.profile===`base-json-slack-connections-1`||e.profile===`base-json-automation-definitions-1`,a=i||e.profile===`base-json-periodic-history-1`;(i!==Object.hasOwn(e.capabilities,`automationDefinitions`)||i&&e.capabilities.automationDefinitions!==1)&&t.addIssue({code:`custom`,message:`Automation profile capabilities do not match`}),(a!==Object.hasOwn(e.capabilities,`periodicHistory`)||a&&e.capabilities.periodicHistory!==1)&&t.addIssue({code:`custom`,message:`History profile capabilities do not match`}),(r!==Object.hasOwn(e.capabilities,`periodicConfig`)||r&&e.capabilities.periodicConfig!==1)&&t.addIssue({code:`custom`,message:`Periodic profile capabilities do not match`}),(n!==Object.hasOwn(e.capabilities,`baseJson`)||n&&e.capabilities.baseJson!==1)&&t.addIssue({code:`custom`,message:`Profile capabilities do not match`})}).superRefine((e,t)=>{let n=![`base-1`,`base-json-workspace-1`].includes(e.profile),r=new Map(Object.entries({"base-1":V,"base-json-workspace-1":ft,"base-json-1":H,"base-json-periodic-config-1":U,"base-json-periodic-links-1":W,"base-json-periodic-history-1":G,"base-json-automation-definitions-1":pt,"base-json-slack-connections-1":mt}[e.profile]));for(let n of e.coverage){let e=r.get(n.model);e&&e.status===n.status&&e.limitation===n.limitation||t.addIssue({code:`custom`,message:`Invalid base-1 classification: ${n.model}`}),r.delete(n.model)}r.size&&t.addIssue({code:`custom`,message:`Missing base-1 model classifications`}),(e.exclusions.length!==K.length-Number(n)||new Set(e.exclusions).size!==K.length-Number(n)||n&&e.exclusions.includes(`PHYSICAL_NULLABLE_JSON_FIDELITY`))&&t.addIssue({code:`custom`,message:`Exactly the base-1 global exclusions are required`})});function J(e){return Object.values(e)}var gt=y(J(ce)),_t=y(J(pe)),vt=y(J(le)),yt=y(J(fe)),bt=y(J(be)),xt=y(J(ae)),St=y(J(ue)),Ct=y(J(ie)),wt=y(J(me)),Y=y(J(oe)),Tt=y(J(ye)),Et=y(J(he)),Dt=x({id:C(),name:C(),slug:C().min(1),repoPath:C(),worktreeBasePath:C().min(1),defaultBranch:C(),githubOwner:C().nullable(),githubRepo:C().nullable(),issueProvider:vt,issueTrackerConfig:S().nullable(),isArchived:b(),startupScriptCommand:C().nullable(),startupScriptPath:C().nullable(),startupScriptTimeout:m(),createdAt:C(),updatedAt:C()}),Ot=x({requestId:C(),title:C().nullable(),branch:C().nullable(),summary:C().nullable(),sidebarSummary:C().nullable(),generatedAt:T().nullable(),sourceSessionId:C().nullable(),sourceMessageId:C().nullable()}),X=x({conversationMetadata:Ot.nullable().optional(),prs:_(L).optional().default([]),prDiscovery:tt.nullable().optional().default(null),prMonitoring:$e.nullable().optional().default(null),prEvents:_(et).optional().default([]),id:C(),projectId:C(),parentWorkspaceId:C().nullable().optional().default(null),name:C(),description:C().nullable(),status:gt,worktreePath:C().nullable(),branchName:C().nullable(),isAutoGeneratedBranch:b(),creationSource:_t,creationMetadata:S().nullable(),initErrorMessage:C().nullable(),initOutput:C().nullable(),initStartedAt:C().nullable(),initCompletedAt:C().nullable(),initRetryCount:m(),runScriptCommand:C().nullable(),runScriptCleanupCommand:C().nullable(),runScriptPid:m().nullable(),runScriptPort:m().nullable(),runScriptStartedAt:C().nullable(),runScriptStatus:yt,prUrl:C().nullable(),githubIssueNumber:m().nullable(),githubIssueUrl:C().nullable(),linearIssueId:C().nullable(),linearIssueIdentifier:C().nullable(),linearIssueUrl:C().nullable(),defaultSessionProvider:Et,ratchetSessionProvider:Et.optional(),prNumber:m().nullable(),prState:bt,prReviewState:C().nullable(),prCiStatus:xt,prUpdatedAt:C().nullable(),prCiFailedAt:C().nullable(),prCiLastNotifiedAt:C().nullable(),prReviewLastCheckedAt:C().nullable(),prReviewLastCommentId:C().nullable(),ratchetEnabled:b(),ratchetState:St,ratchetLastCheckedAt:C().nullable(),ratchetActiveSessionId:C().nullable(),ratchetLastCiRunId:C().nullable(),hasHadSessions:b(),createdAt:C(),updatedAt:C()}),kt=x({id:C(),workspaceId:C(),name:C().nullable(),workflow:C(),workspacePrId:C().nullable().optional().default(null),model:C(),status:wt,provider:Y,codexAccountId:C().nullable().optional().default(null),providerSessionId:C().nullable(),providerProjectPath:C().nullable(),providerProcessPid:m().nullable(),providerMetadata:S().nullable(),createdAt:C(),updatedAt:C()}),At=x({id:C(),workspaceId:C(),name:C().nullable(),status:wt,pid:m().nullable(),createdAt:C(),updatedAt:C()}),jt=x({preferredIde:C(),customIdeCommand:C().nullable(),playSoundOnComplete:b(),childWorkspacesEnabled:b().default(!0),ticketDispatchPrompt:C().nullable().optional().default(null),notificationSoundPath:C().nullable(),ratchetEnabled:b(),ratchetReplyToPrComments:b().optional().default(!0),ratchetReviewTriggerMode:Ct.optional().default(`CHANGES_REQUESTED`),defaultSessionProvider:Y,defaultClaudeModel:C().optional().default(`sonnet`),defaultCodexModel:C().optional().default(`default`),defaultClaudeReasoningEffort:C().nullable().optional().default(null),defaultCodexReasoningEffort:C().nullable().optional().default(null),defaultWorkspacePermissions:Tt.optional().default(`STRICT`),ratchetPermissions:Tt.optional(),reviewerSessionProvider:Y.optional().default(`CODEX`),reviewerClaudeModel:C().nullable().optional().default(null),reviewerCodexModel:C().nullable().optional().default(null),postReviewToGitHub:b().optional().default(!0),voiceModeEnabled:b().optional().default(!1),voiceTtsModel:C().optional().default(j).transform(Ue),voiceTtsSpeed:m().optional().default(1).transform(He),voiceUtteranceEndMs:m().int().min(Me).max(je).optional().default(Ne),voiceBargeInSustainedMs:m().int().min(8).max(80).optional().default(16),appearanceColorScheme:C().optional().default(Se).transform(Ce),appearanceBackgroundColor:E.nullable().optional().default(null),appearanceForegroundColor:E.nullable().optional().default(null),appearanceFontScale:xe.optional().default(100),appearanceFontSans:D.nullable().optional().default(null),appearanceFontMono:D.nullable().optional().default(null)}),Z=x({meta:x({exportedAt:C(),version:C(),schemaVersion:d([v(4),v(5),v(6),v(7)])}),data:x({projects:_(Dt),workspaces:_(X),agentSessions:_(kt),codexAccounts:_(ze).optional().default([]),terminalSessions:_(At),userSettings:jt.nullable()})}),Mt=L.extend({ratchet:x({lastCheckedAt:C().nullable(),activeSessionId:C().nullable(),dispatchSnapshotKey:C().nullable(),dispatchOutcome:y([`RUNNING`,`COMPLETED`,`DIED`]).nullable(),dispatchRetryCount:m().int().nonnegative(),dispatchStalled:b()})}),Nt=Z.extend({meta:Z.shape.meta.extend({schemaVersion:v(5)}),data:Z.shape.data.extend({workspaces:_(X.omit({prUrl:!0,prNumber:!0,prState:!0,prReviewState:!0,prCiStatus:!0,prUpdatedAt:!0,prCiFailedAt:!0,prCiLastNotifiedAt:!0,prReviewLastCheckedAt:!0,prReviewLastCommentId:!0,ratchetLastCiRunId:!0,ratchetState:!0}).extend({prs:_(Mt),ratchetActivePrId:C().nullable()}))})}).superRefine(Qe);function Pt(e){return{...e,meta:{...e.meta,schemaVersion:6},data:{...e.data,workspaces:e.data.workspaces.map(t=>{let n=[...new Set([...t.ratchetActiveSessionId?[t.ratchetActiveSessionId]:[],...t.prs.flatMap(e=>e.ratchet.activeSessionId?[e.ratchet.activeSessionId]:[]),...e.data.agentSessions.filter(e=>e.workspaceId===t.id&&e.workflow===`ratchet`).map(e=>e.id)])];return X.parse({...t,prs:t.prs.map(({ratchet:e,...t})=>t),prUrl:null,prNumber:null,prState:`NONE`,prReviewState:null,prCiStatus:`UNKNOWN`,prUpdatedAt:null,prCiFailedAt:null,prCiLastNotifiedAt:null,prReviewLastCheckedAt:null,prReviewLastCommentId:null,ratchetLastCiRunId:null,ratchetState:`IDLE`,ratchetActiveSessionId:null,prMonitoring:{enabled:t.ratchetEnabled,deliveryMode:`MAIN`,recipientSessionId:null,bindingRevision:0,eventEpoch:+!!t.ratchetEnabled,deliveryPauseReason:n.length?`LEGACY_FIXER`:null,legacySessionIds:n,lastCheckedAt:t.ratchetLastCheckedAt}})})}}}function Ft(e){if(e.meta.schemaVersion===6||e.meta.schemaVersion===7)return{...e,meta:{...e.meta,schemaVersion:e.meta.schemaVersion}};let t=e.data.workspaces.map(t=>{let n=[...new Set([...t.ratchetActiveSessionId?[t.ratchetActiveSessionId]:[],...e.data.agentSessions.filter(e=>e.workspaceId===t.id&&e.workflow===`ratchet`).map(e=>e.id)])],r=e.meta.schemaVersion===4?t.prUrl?[L.parse({id:`legacy-pr-${t.id}`,url:t.prUrl,number:t.prNumber,title:null,headRefName:null,baseRefName:null,state:t.prState,reviewState:t.prReviewState,ciStatus:t.prCiStatus,hasMergeConflict:t.ratchetState===`MERGE_CONFLICT`,syncedAt:t.prUpdatedAt,detachedAt:null,revision:0,ciFailedAt:t.prCiFailedAt,ciLastNotifiedAt:t.prCiLastNotifiedAt,reviewLastCheckedAt:t.prReviewLastCheckedAt,reviewLastCommentId:t.prReviewLastCommentId})]:[]:t.prs;return{...t,prs:r,prMonitoring:t.prMonitoring??{enabled:t.ratchetEnabled,deliveryMode:`MAIN`,recipientSessionId:null,bindingRevision:0,eventEpoch:+!!t.ratchetEnabled,deliveryPauseReason:n.length?`LEGACY_FIXER`:null,legacySessionIds:n,lastCheckedAt:t.ratchetLastCheckedAt}}}),n=e.data.agentSessions.map(n=>{let r=t.find(e=>e.id===n.workspaceId);return e.meta.schemaVersion===4&&r?.ratchetActiveSessionId===n.id?{...n,workspacePrId:r.prs[0]?.id??null}:n});return{...e,meta:{...e.meta,schemaVersion:6},data:{...e.data,workspaces:t,agentSessions:n}}}function It(e,t,n){try{return n(e)}catch(e){if(!(e instanceof f))throw e;for(let n of e.issues)t.addIssue({...n});return g}}function Lt(e,t){let n=new Set(e.data.codexAccounts.map(e=>e.id));e.data.agentSessions.forEach((e,r)=>{e.codexAccountId!==null&&!n.has(e.codexAccountId)&&t.addIssue({code:`custom`,path:[`data`,`agentSessions`,r,`codexAccountId`],message:`Saved Codex account metadata is required`})})}var Q=h({meta:h({...Z.shape.meta.shape,schemaVersion:v(8),recovery:q}),data:h({...Z.shape.data.shape,recovery:ht})}).superRefine((e,t)=>{let n=e.meta.recovery.profile===`base-json-slack-connections-1`;(n!==Object.hasOwn(e.data.recovery,`slackConnections`)||n&&!e.data.recovery.slackConnections)&&t.addIssue({code:`custom`,message:`Slack profile sections do not match`})}).superRefine((e,t)=>{let n=e.meta.recovery.profile!==`base-1`,r=e.data.recovery.baseJson;(n!==Object.hasOwn(e.data.recovery,`baseJson`)||n&&!r)&&t.addIssue({code:`custom`,message:`Profile sections do not match`});let i=e.meta.recovery.profile===`base-json-periodic-config-1`||e.meta.recovery.profile===`base-json-periodic-links-1`||e.meta.recovery.profile===`base-json-periodic-history-1`||e.meta.recovery.profile===`base-json-automation-definitions-1`||e.meta.recovery.profile===`base-json-slack-connections-1`,a=e.data.recovery.periodicConfig;(i!==Object.hasOwn(e.data.recovery,`periodicConfig`)||i&&!a)&&t.addIssue({code:`custom`,message:`Periodic profile sections do not match`})}).superRefine((e,t)=>{let n=e.data.recovery.automationDefinitions,r=e.meta.recovery.profile===`base-json-automation-definitions-1`||e.meta.recovery.profile===`base-json-slack-connections-1`;(r!==Object.hasOwn(e.data.recovery,`automationDefinitions`)||r&&!n)&&t.addIssue({code:`custom`,message:`Automation profile sections do not match`});let i=new Set(e.data.projects.map(e=>e.id));n?.definitions.forEach((e,n)=>{i.has(e.projectId)||t.addIssue({code:`custom`,path:[`data`,`recovery`,`automationDefinitions`,`definitions`,n,`projectId`],message:`Automation definition project is absent from backup`})});let a=e.data.recovery.periodicConfig,o=e.meta.recovery.profile!==`base-1`,s=e.data.recovery.baseJson,c=e.data.recovery.periodicHistory,l=e.meta.recovery.profile===`base-json-periodic-history-1`||e.meta.recovery.profile===`base-json-automation-definitions-1`||e.meta.recovery.profile===`base-json-slack-connections-1`;(l!==Object.hasOwn(e.data.recovery,`periodicHistory`)||l&&!c)&&t.addIssue({code:`custom`,message:`History profile sections do not match`});let u=new Map(a?.tasks.map(e=>[e.id,e])),d=new Set(e.data.workspaces.map(e=>e.id));c?.executions.forEach((e,n)=>{let r=u.get(e.periodicTaskId);for(let[i,a]of[[`periodicTaskId`,!!r],[`workspaceId`,e.workspaceId===null||d.has(e.workspaceId)],[`launchSnapshot`,e.launchSnapshot===null||e.launchSnapshot.projectId===r?.projectId]])a||t.addIssue({code:`custom`,message:`Execution source dependency does not match backup`,path:[`data`,`recovery`,`periodicHistory`,`executions`,n,i]})});let f=new Set(e.data.projects.map(e=>e.id));for(let[e,n]of(a?.tasks??[]).entries())f.has(n.projectId)||t.addIssue({code:`custom`,message:`Periodic task project is absent from backup`,path:[`data`,`recovery`,`periodicConfig`,`tasks`,e,`projectId`]});o&&s&<(e.data,s,e.meta.recovery.profile===`base-json-1`||e.meta.recovery.profile===`base-json-periodic-config-1`||e.meta.recovery.profile===`base-json-periodic-links-1`||e.meta.recovery.profile===`base-json-periodic-history-1`||e.meta.recovery.profile===`base-json-automation-definitions-1`||e.meta.recovery.profile===`base-json-slack-connections-1`,t)}),$=Q.safeExtend({meta:Q.shape.meta.extend({recovery:q.safeExtend({profile:y([`base-json-1`,`base-json-periodic-config-1`])})}),data:Q.shape.data.extend({workspaces:_(X.extend({prs:_(L.extend({observation:L.shape.observation.removeDefault()})).optional().default([])}))})}),Rt=Q.safeExtend({meta:Q.shape.meta.extend({recovery:q.safeExtend({profile:y([`base-json-periodic-links-1`,`base-json-periodic-history-1`,`base-json-automation-definitions-1`,`base-json-slack-connections-1`])})}),data:$.shape.data.extend({workspaces:_($.shape.data.shape.workspaces.element.extend({periodicTaskId:C().nullable()}))})}).superRefine((e,t)=>{let n=new Set(e.data.recovery.periodicConfig?.tasks.map(e=>e.id));e.data.workspaces.forEach((e,r)=>{e.periodicTaskId!==null&&!n.has(e.periodicTaskId)&&t.addIssue({code:`custom`,message:`Workspace periodic task is absent from backup`,path:[`data`,`workspaces`,r,`periodicTaskId`]})})}),zt=Q.safeExtend({meta:Q.shape.meta.extend({recovery:q.safeExtend({profile:y([`base-1`,`base-json-workspace-1`])})})}),Bt=d([Nt.transform((e,t)=>It(e,t,Pt)),Z.transform((e,t)=>It(e,t,Ft)),zt,$,Rt]).superRefine(Ze).superRefine(Lt);function Vt({onImportSuccess:e,variant:t=`outline`,className:n,children:o}){let s=(0,A.useRef)(null),[c,l]=(0,A.useState)({open:!1,data:null,summary:``}),d=r.useUtils(),{publishImportResult:f}=Ee(),p=r.admin.importData.useMutation({onSuccess:async t=>{f(t.results),l({open:!1,data:null,summary:``});try{await d.invalidate()}catch{i.error(`Import completed, but refreshing data failed. Reload to refresh.`)}e?.()},onError:e=>{i.error(`Couldn't import backup. ${e.message}`),l({open:!1,data:null,summary:``})}}),ee=e=>[`Exported: ${new Date(e.meta.exportedAt).toLocaleString()}`,`Version: ${e.meta.version}`,``,`Projects: ${e.data.projects.length}`,`Workspaces: ${e.data.workspaces.length}`,`Agent Sessions: ${e.data.agentSessions.length}`,`Terminal Sessions: ${e.data.terminalSessions.length}`,`User Settings: ${e.data.userSettings?`Yes`:`No`}`].join(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{n as r}from"./trpc-D9WuCSM1.js";import{r as i,t as a}from"./background-task-2TNZSSC3.js";import{r as o}from"./utils-DQeSPVda.js";import{t as s}from"./CheckCircle.es-WUl0_Fqk.js";import{t as c}from"./spinner-BxeSV-Bb.js";import{t as l}from"./Warning.es-BRY0GI4S.js";import{t as u}from"./button-Dslj7pht.js";import{C as d,E as f,S as p,T as ee,_ as m,b as h,h as te,k as g,l as ne,o as _,p as v,r as y,s as b,v as x,w as S,x as C,y as re}from"./schemas-cLRPP1ma.js";import{B as w,H as ie,I as ae,J as oe,L as se,Q as ce,R as le,U as ue,V as de,W as fe,X as pe,Y as me,Z as he,d as ge,et as T,f as _e,l as ve,q as ye,z as be}from"./workspace-cache-reconciler-TKQHxUsu.js";import{d as xe,f as E,i as Se,l as D,m as Ce}from"./appearance-DsbwoDTa.js";import{an as we,g as Te,o as Ee,on as De}from"./index-BHTworEd.js";import{i as Oe,r as O}from"./agent-definition.schema-DaZC-6OB.js";import{t as ke}from"./CircleDashed.es-Q7XmyA0_.js";import{t as Ae}from"./Terminal.es-DXk70l2n.js";import{n as je,r as Me,t as Ne}from"./voice-vad-ChMQMgBS.js";var k=n();function Pe({status:e}){return e===`ok`?(0,k.jsx)(s,{className:`h-4 w-4 text-success`}):e===`warning`?(0,k.jsx)(l,{className:`h-4 w-4 text-warning`}):(0,k.jsx)(ke,{className:`h-4 w-4 text-muted-foreground`})}function Fe(e){let t=[];return e.claude.isInstalled?e.claude.isAuthenticated===!0?t.push({label:`Claude`,status:`ok`,detail:`Ready`}):t.push({label:`Claude`,status:`warning`,detail:`Installed — use Sign in to Claude in the setup terminal`}):t.push({label:`Claude`,status:`missing`,detail:`Bundled runtime unavailable — update Factory Factory`}),e.codex.isInstalled?e.codex.isAuthenticated===!0?t.push({label:`Codex`,status:`ok`,detail:`Ready`}):t.push({label:`Codex`,status:`warning`,detail:`Use Sign in to Codex in the setup terminal`}):t.push({label:`Codex`,status:`missing`,detail:e.codex.error??`Bundled runtime unavailable — update Factory Factory`}),e.github.isInstalled?e.github.isAuthenticated?t.push({label:`GitHub CLI`,status:`ok`,detail:`Ready`}):t.push({label:`GitHub CLI`,status:`warning`,detail:`Installed — run gh auth login to authenticate`}):t.push({label:`GitHub CLI`,status:`missing`,detail:`Not installed`}),t}function Ie({onOpenTerminal:e}){let{refresh:t,isRefreshing:n}=we(),{data:i,isLoading:a,isRefetching:o}=r.admin.checkCLIHealth.useQuery({forceRefresh:!1},{refetchOnWindowFocus:!1,staleTime:6e4});if(a)return(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground py-2`,children:[(0,k.jsx)(c,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{children:`Checking CLI prerequisites…`})]});if(!i)return null;let s=Fe(i),l=s.some(e=>e.status!==`ok`);return(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`CLI Prerequisites`}),(0,k.jsxs)(u,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs text-muted-foreground`,onClick:()=>void t(),disabled:o||n,children:[o||n?(0,k.jsx)(c,{className:`mr-1 h-3 w-3`,"aria-hidden":`true`}):(0,k.jsx)(De,{className:`mr-1 h-3 w-3`}),`Recheck`]})]}),(0,k.jsx)(`ul`,{className:`space-y-1.5`,children:s.map(e=>(0,k.jsxs)(`li`,{className:`flex items-center gap-2 text-sm`,children:[(0,k.jsx)(Pe,{status:e.status}),(0,k.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,k.jsxs)(`span`,{className:`text-muted-foreground`,children:[`— `,e.detail]})]},e.label))}),l&&(0,k.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:e,children:[(0,k.jsx)(Ae,{className:`mr-2 h-4 w-4`}),`Open terminal to log in`]})]})}var A=e(t(),1),Le=new Map([[`regular`,A.createElement(A.Fragment,null,A.createElement(`path`,{d:`M240,136v64a16,16,0,0,1-16,16H32a16,16,0,0,1-16-16V136a16,16,0,0,1,16-16H80a8,8,0,0,1,0,16H32v64H224V136H176a8,8,0,0,1,0-16h48A16,16,0,0,1,240,136ZM85.66,77.66,120,43.31V128a8,8,0,0,0,16,0V43.31l34.34,34.35a8,8,0,0,0,11.32-11.32l-48-48a8,8,0,0,0-11.32,0l-48,48A8,8,0,0,0,85.66,77.66ZM200,168a12,12,0,1,0-12,12A12,12,0,0,0,200,168Z`}))]]),Re=A.forwardRef((e,t)=>A.createElement(o,{ref:t,...e,weights:Le}));Re.displayName=`UploadIcon`;var ze=x({id:C().regex(/^[A-Za-z0-9_-]+$/),label:C().trim().min(1).max(100),kind:te(se),enabled:b(),identityKey:C().regex(/^(?:[a-f0-9]{64}|native-email:[a-f0-9]{64}(?::imported:[A-Za-z0-9_-]+)?)$/).nullable()}),Be=[{model:`flux-hannah-en`,name:`Hannah`,description:`Clear, confident, thoughtful`},{model:`flux-kit-en`,name:`Kit`,description:`Friendly, energetic, thoughtful`},{model:`flux-alexis-en`,name:`Alexis`,description:`Clear, professional, calm`},{model:`flux-cliff-en`,name:`Cliff`,description:`Deep, confident, calm`},{model:`flux-sienna-en`,name:`Sienna`,description:`Clear, professional, calm`},{model:`flux-cole-en`,name:`Cole`,description:`Friendly, clear, interesting`},{model:`flux-brooke-en`,name:`Brooke`,description:`Friendly, intelligent, fast`},{model:`flux-colin-en`,name:`Colin`,description:`Warm, friendly, trustworthy`},{model:`flux-gemma-en`,name:`Gemma`,description:`Friendly, kind, approachable`},{model:`flux-haley-en`,name:`Haley`,description:`Clear, professional, caring`},{model:`flux-heather-en`,name:`Heather`,description:`Clear, engaging, energetic`},{model:`flux-miles-en`,name:`Miles`,description:`Clear, calm, professional`},{model:`flux-sean-en`,name:`Sean`,description:`Friendly, kind, caring`},{model:`flux-bree-en`,name:`Bree`,description:`Friendly, sweet, kind`},{model:`flux-brittany-en`,name:`Brittany`,description:`Confident, kind, soft`},{model:`flux-bruce-en`,name:`Bruce`,description:`Friendly, kind, natural`},{model:`flux-conor-en`,name:`Conor`,description:`Confident, deep, friendly`},{model:`flux-donovan-en`,name:`Donovan`,description:`Professional, calm, thoughtful`},{model:`flux-drew-en`,name:`Drew`,description:`Confident, relaxed, soft`},{model:`flux-elise-en`,name:`Elise`,description:`Clear, professional, calm`},{model:`flux-jack-en`,name:`Jack`,description:`Confident, thoughtful, friendly`},{model:`flux-kai-en`,name:`Kai`,description:`Clear, calm, professional`},{model:`flux-kelsey-en`,name:`Kelsey`,description:`Clear, professional, caring`},{model:`flux-maeve-en`,name:`Maeve`,description:`Friendly, energetic, confident`},{model:`flux-marcelo-en`,name:`Marcelo`,description:`Clear, calm, professional`},{model:`flux-marcus-en`,name:`Marcus`,description:`Friendly, helpful, smooth`},{model:`flux-meena-en`,name:`Meena`,description:`Empathetic, professional, calm`},{model:`flux-meghan-en`,name:`Meghan`,description:`Friendly, nice, energetic`},{model:`flux-naveen-en`,name:`Naveen`,description:`Clear, professional, knowledgeable`},{model:`flux-paige-en`,name:`Paige`,description:`Clear, professional, calm`},{model:`flux-priya-en`,name:`Priya`,description:`Confident, empathetic, professional`},{model:`flux-rufus-en`,name:`Rufus`,description:`Friendly, confident, intelligent`},{model:`flux-sharon-en`,name:`Sharon`,description:`Formal, calm, relaxed`},{model:`flux-tanner-en`,name:`Tanner`,description:`Professional, calm, confident`},{model:`flux-wade-en`,name:`Wade`,description:`Warm, confident, clear`},{model:`flux-wes-en`,name:`Wes`,description:`Thoughtful, friendly, warm`}],j=`flux-haley-en`,M=.5,N=1.5,P=.05;function Ve(e){return Be.some(t=>t.model===e)}function He(e){if(!Number.isFinite(e))return 1;let t=Math.round((Math.min(N,Math.max(M,e))-M)/P);return Math.round((M+t*P)*100)/100}function Ue(e){return Ve(e)?e:j}function F(e){return e.prs.length?e.prs.map(({id:e,url:t})=>({id:e,url:t})):e.prUrl?[{id:`legacy-pr-${e.id}`,url:e.prUrl}]:[]}function We(e,t){let n=!0,r=(e,r)=>{new Set(e).size!==e.length&&(t.addIssue({code:`custom`,path:[`data`,...r],message:`Duplicate source identity`}),n=!1)};return r(e.data.projects.map(e=>e.id),[`projects`]),r(e.data.projects.map(e=>e.slug),[`projects`]),r(e.data.workspaces.map(e=>e.id),[`workspaces`]),r(e.data.agentSessions.map(e=>e.id),[`agentSessions`]),r(e.data.terminalSessions.map(e=>e.id),[`terminalSessions`]),r(e.data.workspaces.flatMap(e=>e.prEvents.map(e=>e.id)),[`workspaces`]),r(e.data.workspaces.flatMap(e=>F(e).map(e=>e.id)),[`workspaces`]),n}function Ge(e,t){let n=new Map(e.data.agentSessions.map(e=>[e.id,e.workspaceId]));for(let[r,i]of e.data.workspaces.entries())[i.ratchetActiveSessionId,i.prMonitoring?.recipientSessionId,...i.prMonitoring?.legacySessionIds??[],...i.prEvents.map(e=>e.deliverySessionId)].some(e=>e!=null&&n.has(e)&&n.get(e)!==i.id)&&t.addIssue({code:`custom`,path:[`data`,`workspaces`,r],message:`Declared session must belong to its file workspace`})}function Ke(e,t){let n=new Map(e.data.workspaces.map(e=>[e.id,e]));for(let[r,i]of e.data.workspaces.entries()){if(i.parentWorkspaceId===null)continue;let e=n.get(i.parentWorkspaceId);e&&e!==i&&e.parentWorkspaceId===null&&e.projectId===i.projectId||t.addIssue({code:`custom`,path:[`data`,`workspaces`,r,`parentWorkspaceId`],message:`Parent must be a different file-owned root in the same project`})}}function qe(e,t){let n=new Map;for(let[r,i]of e.data.workspaces.entries())for(let e of i.prEvents){if(e.deliveryId===null)continue;let a=n.get(e.deliveryId);a!==void 0&&a!==i.id&&t.addIssue({code:`custom`,path:[`data`,`workspaces`,r,`prEvents`],message:`Receipt members must belong to one workspace`}),n.set(e.deliveryId,i.id)}}function Je(e,t,n){let r=e.payload.kind===`MONITORING_ENABLED`?e.payload:e.payload.target,i=e.payload.kind===`MONITORING_ENABLED`?e.prId===null:e.payload.target.prId===e.prId;return e.workspaceId===t&&r.workspaceId===t&&(e.prId===null||n.has(e.prId))&&i}function Ye(e,t){let n=new Map;for(let[r,i]of e.data.workspaces.entries()){let e=new Set,a=new Set(F(i).map(e=>e.id));i.prEvents.forEach(o=>{let s=e=>t.addIssue({code:`custom`,path:[`data`,`workspaces`,r,`prEvents`],message:e});Je(o,i.id,a)||s(`Event and payload must belong to their declared workspace and PR`);let c=o.prId===null?void 0:n.get(o.prId);if((e.has(o.deduplicationKey)||c?.has(o.deduplicationKey))&&s(`Duplicate event deduplication key`),e.add(o.deduplicationKey),o.prId!==null){let e=c??new Set;e.add(o.deduplicationKey),n.set(o.prId,e)}})}}function Xe(e,t){for(let[n,r]of e.data.workspaces.entries())for(let[i,a]of r.prs.entries()){let o=a.dedicatedSession?.sessionId;if(o==null)continue;let s=e.data.agentSessions.find(e=>e.id===o);s&&s.workspaceId===r.id&&s.workspacePrId===a.id&&s.workflow===`pr-monitoring`||t.addIssue({code:`custom`,path:[`data`,`workspaces`,n,`prs`,i,`dedicatedSession`],message:`Dedicated conversation must belong to this PR and workspace`})}}function Ze(e,t){if(!We(e,t))return;Ke(e,t),qe(e,t),Ye(e,t),Ge(e,t),Xe(e,t);let n=new Set,r=new Map;for(let[i,a]of e.data.workspaces.entries()){let e=new Set;for(let[o,s]of F(a).entries())(n.has(s.id)||e.has(s.url))&&t.addIssue({code:`custom`,path:[`data`,`workspaces`,i,`prs`,o],message:`Duplicate PR identity or URL`}),n.add(s.id),e.add(s.url),r.set(s.id,a.id)}for(let[n,i]of e.data.agentSessions.entries())i.workspacePrId&&r.get(i.workspacePrId)!==i.workspaceId&&t.addIssue({code:`custom`,path:[`data`,`agentSessions`,n,`workspacePrId`],message:`Session PR must belong to its workspace`})}function Qe(e,t){for(let[n,r]of e.data.workspaces.entries()){let e=r.prs.find(e=>e.id===r.ratchetActivePrId);r.ratchetActivePrId===null&&r.ratchetActiveSessionId===null||r.ratchetActiveSessionId&&e&&!e.detachedAt&&e.ratchet.activeSessionId===r.ratchetActiveSessionId||t.addIssue({code:`custom`,path:[`data`,`workspaces`,n,`ratchetActivePrId`],message:`Active fixer must belong to an attached PR in this workspace`})}}var I=T(),$e=h({enabled:b(),deliveryMode:ve.default(`MAIN`),recipientSessionId:C().nullable(),bindingRevision:m().int().nonnegative(),eventEpoch:m().int().nonnegative(),deliveryPauseReason:C().nullable(),legacySessionIds:_(C()).default([]),lastCheckedAt:I.nullable()}),et=h({id:C().min(1),workspaceId:C().min(1),prId:C().nullable(),kind:C(),deduplicationKey:C().min(1),payload:ge,state:y([`PENDING`,`DISPATCHING`,`DELIVERED`,`SUPERSEDED`,`CANCELLED`]),attempts:m().int().nonnegative(),deliveryId:C().min(1).nullable(),deliverySessionId:C().min(1).nullable(),deliveryProvider:C().nullable().optional(),deliveryProviderSessionId:C().nullable().optional(),deliveryBindingRevision:m().int().nonnegative().nullable(),deliveryText:C().refine(e=>new TextEncoder().encode(e).byteLength<=16384,`Frozen delivery text exceeds 16 KiB`).nullable(),claimedAt:I.nullable(),deliveredAt:I.nullable(),createdAt:I}).refine(e=>e.kind===e.payload.kind,`Event kind disagrees with payload`).refine(e=>e.state!==`DISPATCHING`||!!(e.deliveryId&&e.deliverySessionId&&e.deliveryProvider&&e.deliveryProviderSessionId&&e.deliveryText&&e.deliveryBindingRevision!==null),`Dispatching event requires complete frozen delivery metadata`),L=h({dedicatedSession:h({sessionId:C().min(1).nullable()}).nullable().optional(),id:C().min(1),url:ee(),number:m().int().nullable(),title:C().nullable(),headRefName:C().nullable(),baseRefName:C().nullable(),state:y([`NONE`,`DRAFT`,`OPEN`,`CHANGES_REQUESTED`,`APPROVED`,`MERGED`,`CLOSED`]),reviewState:C().nullable(),ciStatus:y([`UNKNOWN`,`PENDING`,`SUCCESS`,`FAILURE`]),hasMergeConflict:b(),completionDismissed:b().default(!1),terminalObservedAt:I.nullable().default(null),syncedAt:I.nullable(),detachedAt:I.nullable(),revision:m().int().nonnegative(),observation:_e.nullable().default(null),observationEpoch:m().int().nonnegative().default(0),transitionSequence:m().int().nonnegative().default(0),ciFailedAt:I.nullable(),ciLastNotifiedAt:I.nullable(),reviewLastCheckedAt:I.nullable(),reviewLastCommentId:C().nullable()}),tt=h({lastCheckedAt:I.nullable(),retryCount:m().int().nonnegative(),nextCheckAt:I.nullable()}),R=C().refine(e=>e.trim().length>0,`Definition text must not be blank`),nt=S().transform((e,t)=>{let n=Oe.safeParse(e);if(!n.success){for(let e of n.error.issues)t.addIssue({...e});return g}let r=re(C(),S()).parse(e);for(let e of[`provider`,`model`,`reasoningEffort`])Object.hasOwn(r,e)&&(r[e]===void 0||r[e]!==n.data[e])&&t.addIssue({code:`custom`,path:[e],message:`Noncanonical execution preference`});return n.data}),rt=h({version:v(1),definitions:_(h({id:C(),projectId:C(),name:R,instructions:R,isEnabled:b(),executionConfig:nt,definitionRevision:O,managementRevision:O,createdAt:T(),updatedAt:T()}))}).superRefine((e,t)=>{let n=new Set;e.definitions.forEach((e,r)=>{n.has(e.id)&&t.addIssue({code:`custom`,path:[`definitions`,r,`id`],message:`Duplicate automation definition identity`}),n.add(e.id)})}),it=h({id:C(),projectId:C(),name:C(),prompt:C(),cadence:y(w),scheduledTime:C().regex(/^([01]\d|2[0-3]):[0-5]\d$/).nullable(),timezone:C().refine(e=>{try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch{return!1}},`Invalid timezone`).nullable(),scheduledDayOfMonth:m().int().min(1).max(31).nullable(),isEnabled:b(),nextRunAt:T(),lastRunAt:T().nullable(),createdAt:T(),updatedAt:T()}),at=h({version:v(1),tasks:_(it)}).superRefine((e,t)=>{let n=new Set;for(let r of e.tasks)n.has(r.id)&&t.addIssue({code:`custom`,message:`Duplicate periodic task identity`}),n.add(r.id)}),ot=h({version:v(1),projectId:C(),name:C(),prompt:C(),cadence:y(w),scheduledTime:C().nullable(),timezone:C().nullable(),scheduledDayOfMonth:m().int().nullable(),dueAt:T()}),st=h({version:v(1),executions:_(h({id:C(),periodicTaskId:C(),workspaceId:C().nullable(),launchSnapshot:ot.nullable(),status:y(de),prUrl:C().nullable(),prNumber:m().int().nullable(),errorMessage:C().nullable(),startedAt:T(),completedAt:T().nullable()})),jsonStorage:_(h({model:v(`PeriodicTaskExecution`),identity:p([C()]),field:v(`launchSnapshot`)}))}).superRefine((e,t)=>{let n=new Set,r=new Set;e.executions.forEach((e,i)=>{n.has(e.id)&&t.addIssue({code:`custom`,message:`Duplicate execution identity`,path:[`executions`,i,`id`]}),e.workspaceId!==null&&r.has(e.workspaceId)&&t.addIssue({code:`custom`,message:`Duplicate execution workspace`,path:[`executions`,i,`workspaceId`]}),n.add(e.id),e.workspaceId!==null&&r.add(e.workspaceId)});let i=new Map(e.executions.map(e=>[e.id,e])),a=new Set;e.jsonStorage.forEach((e,n)=>{let r=e.identity[0];(a.has(r)||!i.has(r)||i.get(r)?.launchSnapshot!==null)&&t.addIssue({code:`custom`,message:`Invalid execution JSON-null target`,path:[`jsonStorage`,n,`identity`]}),a.add(r)})}),ct=h({version:v(1),jsonStorage:_(ne(`model`,[h({model:v(`Workspace`),identity:p([C()]),field:v(`creationMetadata`)}),h({model:v(`WorkspacePR`),identity:p([C().min(1)]),field:v(`observation`)}),h({model:v(`AgentSession`),identity:p([C()]),field:v(`providerMetadata`)})]))});function lt(e,t,n,r){let i=new Map,a=(e,t,n,a,o)=>{let s=JSON.stringify([e,t.id,n]),c=i.get(s)??[];c.push(a),i.set(s,c),Object.hasOwn(t,n)&&a!==void 0||r.addIssue({code:`custom`,message:`Covered ${n} must be present`,path:o})};for(let[t,r]of e.workspaces.entries())if(a(`Workspace`,r,`creationMetadata`,r.creationMetadata,[`data`,`workspaces`,t,`creationMetadata`]),n)for(let[e,n]of r.prs.entries())a(`WorkspacePR`,n,`observation`,n.observation,[`data`,`workspaces`,t,`prs`,e,`observation`]);if(n)for(let[t,n]of e.agentSessions.entries())a(`AgentSession`,n,`providerMetadata`,n.providerMetadata,[`data`,`agentSessions`,t,`providerMetadata`]);let o=new Set;for(let[e,n]of t.jsonStorage.entries()){let t=JSON.stringify([n.model,n.identity[0],n.field]),a=i.get(t);(o.has(t)||a?.length!==1||a[0]!==null)&&r.addIssue({code:`custom`,message:`Invalid ${n.model} JSON-null target`,path:[`data`,`recovery`,`baseJson`,`jsonStorage`,e,`identity`]}),o.add(t)}}var ut=h({version:v(1),connections:_(h({id:C().refine(e=>e.trim().length>0,`Connection ID must not be blank`),provider:v(`SLACK`),externalId:C().refine(e=>e.trim().length>0,`Workspace ID must not be blank`),name:C().min(1),isEnabled:b(),createdAt:T(),updatedAt:T()}))}).superRefine((e,t)=>{let n=new Set,r=new Set;e.connections.forEach((e,i)=>{for(let[a,o]of[[`id`,n],[`externalId`,r]])o.has(e[a])&&t.addIssue({code:`custom`,path:[`connections`,i,a],message:`Duplicate Slack connection identity`}),o.add(e[a])})}),dt=h({model:C(),status:y([`PARTIAL`,`EXCLUDED`]),limitation:C()}),z=e=>({status:`PARTIAL`,limitation:e}),B=e=>({status:`EXCLUDED`,limitation:e}),V={Project:z(`configuration/paths; no encrypted tracker configuration restore or repository files.`),Workspace:z(`base metadata; worktree contents, complete origin history and live workflow/process authority excluded; physical nullable-JSON fidelity unproven.`),WorkspaceMetadata:z(`existing generated summaries/provenance fields when parent is accepted; no full-domain recovery claim.`),WorkspaceRunScript:z(`command/cleanup and inert runtime disposition; postRunCommand absent and PID/port/start authority excluded.`),CodexAccount:z(`identity/label metadata; owner may remap identity; native home, credentials, timestamps and executable login authority excluded.`),AgentSession:z(`base metadata/provider history identities; provider history bytes/live process and physical nullable-JSON fidelity excluded.`),TerminalSession:z(`label/metadata; process identities and terminal bytes excluded.`),UserSettings:z(`exported preference subset; keys, credentials, workspace ordering and caches excluded.`),WorkspacePR:z(`existing associations/cache; no exact normalized full ledger guarantee and physical nullable-JSON fidelity unproven.`),WorkspacePRMonitoring:z(`base configuration/history; restored disabled, no executable monitoring authority.`),WorkspacePRDedicatedSession:z(`existing base association where valid accepted owner graph exists; not an independent session/history payload.`),WorkspacePREvent:z(`flattened raw event/effect evidence; no proof of omitted original members or original frozen ordering; unfinished effects inert.`),WorkspacePRDelivery:z(`only evidence represented through base events; exact normalized delivery/membership/order not included.`),WorkspacePRDiscovery:z(`base scheduling/cache fields where present; defaults otherwise, not delivery authority or full retained history.`),DecisionLog:B(`generic decision history absent.`),WorkspaceLaunchOrigin:B(`original launch provenance absent.`),WorkspaceChildOrigin:B(`original retained/deleted-child provenance absent; import-created invalidation/origin bookkeeping is not source recovery.`),WorkspaceNotification:B(`retained mailbox rows/revision/read/ack/supersession history absent.`),WorkspaceMailState:B(`retained wake/cursor proof absent; live claims/leases are intentionally never restored.`),AgentSessionLaunchOrigin:B(`original session launch provenance absent.`),SessionLifecycleEvent:B(`lifecycle history absent.`),ClosedSession:B(`archive payload/metadata recovery absent.`),PeriodicTask:B(`periodic configuration absent.`),PeriodicTaskExecution:B(`periodic history absent.`),AgentDefinition:B(`automation definitions absent.`),AgentConnection:B(`automation connection configuration absent; secrets excluded.`),AgentTrigger:B(`automation trigger configuration absent.`),AgentRun:B(`automation run/effect history absent.`),AgentProposal:B(`draft/accepted proposal provenance absent.`),AgentSourceState:B(`source continuity state absent.`),AgentSourcePage:B(`source pages absent.`),AgentSourceBaseline:B(`source baselines absent.`),AgentSourceCheckpoint:B(`source checkpoint proof absent.`),AgentSourceHead:B(`source head proof absent.`),AgentEvent:B(`automation retained events absent.`),AgentEvaluation:B(`frozen automation decisions absent.`),AgentInitialDelivery:B(`initial automation effect evidence absent.`)},ft={...V,Workspace:z(`base metadata; Workspace.creationMetadata preserves SQL NULL versus top-level JSON null; worktree contents, complete origin history and live workflow/process authority excluded; WorkspacePR.observation and AgentSession.providerMetadata physical nullable-JSON fidelity unproven.`)},H={...V,Workspace:z(`base metadata; Workspace.creationMetadata preserves SQL NULL versus top-level JSON null; worktree contents, complete origin history and live workflow/process authority excluded.`),WorkspacePR:z(`existing associations/cache; WorkspacePR.observation preserves SQL NULL versus top-level JSON null for actual included PR rows; no exact normalized full ledger guarantee.`),AgentSession:z(`base metadata/provider history identities; AgentSession.providerMetadata preserves SQL NULL versus top-level JSON null; provider history bytes/live process excluded.`)},U={...H,PeriodicTask:z(`complete scalar configuration and timestamps; restored disabled; source enabled state is reported, not restored as scheduling authority; periodic execution history excluded.`)},W={...U,Workspace:z(`base metadata; Workspace.periodicTaskId links to newly imported disabled tasks; Workspace.creationMetadata preserves SQL NULL versus top-level JSON null; worktree contents, complete origin history and live workflow/process authority excluded.`)},G={...W,PeriodicTask:z(`complete scalar configuration and timestamps; restored disabled; source enabled state is reported, not restored as scheduling authority.`),PeriodicTaskExecution:z(`all supported retained execution scalars and canonical version-1 or legacy null launch snapshots with SQL NULL versus top-level JSON null fidelity; imported RUNNING rows become historical FAILED without asserting provider outcome; live execution and replay authority excluded.`)},pt={...G,AgentDefinition:z(`all supported scalar definition bodies and execution preferences, source revisions and timestamps; restored disabled; connections, event membership, proposal provenance, activation and run/evaluation history excluded.`)},mt={Project:z(`configuration/paths; no encrypted tracker configuration restore or repository files.`),Workspace:z(`base metadata; Workspace.periodicTaskId links to newly imported disabled tasks; Workspace.creationMetadata preserves SQL NULL versus top-level JSON null; worktree contents, complete origin history and live workflow/process authority excluded.`),WorkspaceMetadata:z(`existing generated summaries/provenance fields when parent is accepted; no full-domain recovery claim.`),WorkspaceRunScript:z(`command/cleanup and inert runtime disposition; postRunCommand absent and PID/port/start authority excluded.`),CodexAccount:z(`identity/label metadata; owner may remap identity; native home, credentials, timestamps and executable login authority excluded.`),AgentSession:z(`base metadata/provider history identities; AgentSession.providerMetadata preserves SQL NULL versus top-level JSON null; provider history bytes/live process excluded.`),TerminalSession:z(`label/metadata; process identities and terminal bytes excluded.`),UserSettings:z(`exported preference subset; keys, credentials, workspace ordering and caches excluded.`),WorkspacePR:z(`existing associations/cache; WorkspacePR.observation preserves SQL NULL versus top-level JSON null for actual included PR rows; no exact normalized full ledger guarantee.`),WorkspacePRMonitoring:z(`base configuration/history; restored disabled, no executable monitoring authority.`),WorkspacePRDedicatedSession:z(`existing base association where valid accepted owner graph exists; not an independent session/history payload.`),WorkspacePREvent:z(`flattened raw event/effect evidence; no proof of omitted original members or original frozen ordering; unfinished effects inert.`),WorkspacePRDelivery:z(`only evidence represented through base events; exact normalized delivery/membership/order not included.`),WorkspacePRDiscovery:z(`base scheduling/cache fields where present; defaults otherwise, not delivery authority or full retained history.`),DecisionLog:B(`generic decision history absent.`),WorkspaceLaunchOrigin:B(`original launch provenance absent.`),WorkspaceChildOrigin:B(`original retained/deleted-child provenance absent; import-created invalidation/origin bookkeeping is not source recovery.`),WorkspaceNotification:B(`retained mailbox rows/revision/read/ack/supersession history absent.`),WorkspaceMailState:B(`retained wake/cursor proof absent; live claims/leases are intentionally never restored.`),AgentSessionLaunchOrigin:B(`original session launch provenance absent.`),SessionLifecycleEvent:B(`lifecycle history absent.`),ClosedSession:B(`archive payload/metadata recovery absent.`),PeriodicTask:z(`complete scalar configuration and timestamps; restored disabled; source enabled state is reported, not restored as scheduling authority.`),PeriodicTaskExecution:z(`all supported retained execution scalars and canonical version-1 or legacy null launch snapshots with SQL NULL versus top-level JSON null fidelity; imported RUNNING rows become historical FAILED without asserting provider outcome; live execution and replay authority excluded.`),AgentDefinition:z(`all supported scalar definition bodies and execution preferences, source revisions and timestamps; restored disabled; connection bindings, event membership, proposal provenance, activation and run/evaluation history excluded.`),AgentConnection:z(`SLACK connection identity, name, source enabled state and timestamps; restored disabled and without credentials; GitHub connections, credentials and live connection authority excluded.`),AgentTrigger:B(`automation trigger configuration absent.`),AgentRun:B(`automation run/effect history absent.`),AgentProposal:B(`draft/accepted proposal provenance absent.`),AgentSourceState:B(`source continuity state absent.`),AgentSourcePage:B(`source pages absent.`),AgentSourceBaseline:B(`source baselines absent.`),AgentSourceCheckpoint:B(`source checkpoint proof absent.`),AgentSourceHead:B(`source head proof absent.`),AgentEvent:B(`automation retained events absent.`),AgentEvaluation:B(`frozen automation decisions absent.`),AgentInitialDelivery:B(`initial automation effect evidence absent.`)},K=[`SECRETS_AND_ENCRYPTION_KEYS`,`NATIVE_ACCOUNT_HOMES`,`WORKTREE_AND_REPOSITORY_CONTENTS`,`PROVIDER_OWNED_HISTORY`,`LIVE_PROCESS_IDS_AND_RUNTIME_LEASES`,`PHYSICAL_NULLABLE_JSON_FIDELITY`],ht=h({baseJson:ct.optional(),periodicConfig:at.optional(),periodicHistory:st.optional(),automationDefinitions:rt.optional(),slackConnections:ut.optional()}),q=h({version:v(1),profile:y([`base-1`,`base-json-workspace-1`,`base-json-1`,`base-json-periodic-config-1`,`base-json-periodic-links-1`,`base-json-periodic-history-1`,`base-json-automation-definitions-1`,`base-json-slack-connections-1`]),status:v(`PARTIAL`),capabilities:h({baseJson:v(1).optional(),periodicConfig:v(1).optional(),periodicHistory:v(1).optional(),automationDefinitions:v(1).optional(),slackConnections:v(1).optional()}),coverage:_(dt),exclusions:_(y(K))}).superRefine((e,t)=>{let n=e.profile===`base-json-slack-connections-1`;(n!==Object.hasOwn(e.capabilities,`slackConnections`)||n&&e.capabilities.slackConnections!==1)&&t.addIssue({code:`custom`,message:`Slack profile capabilities do not match`})}).superRefine((e,t)=>{let n=e.profile!==`base-1`,r=[`base-json-periodic-config-1`,`base-json-periodic-links-1`,`base-json-periodic-history-1`,`base-json-automation-definitions-1`,`base-json-slack-connections-1`].includes(e.profile),i=e.profile===`base-json-slack-connections-1`||e.profile===`base-json-automation-definitions-1`,a=i||e.profile===`base-json-periodic-history-1`;(i!==Object.hasOwn(e.capabilities,`automationDefinitions`)||i&&e.capabilities.automationDefinitions!==1)&&t.addIssue({code:`custom`,message:`Automation profile capabilities do not match`}),(a!==Object.hasOwn(e.capabilities,`periodicHistory`)||a&&e.capabilities.periodicHistory!==1)&&t.addIssue({code:`custom`,message:`History profile capabilities do not match`}),(r!==Object.hasOwn(e.capabilities,`periodicConfig`)||r&&e.capabilities.periodicConfig!==1)&&t.addIssue({code:`custom`,message:`Periodic profile capabilities do not match`}),(n!==Object.hasOwn(e.capabilities,`baseJson`)||n&&e.capabilities.baseJson!==1)&&t.addIssue({code:`custom`,message:`Profile capabilities do not match`})}).superRefine((e,t)=>{let n=![`base-1`,`base-json-workspace-1`].includes(e.profile),r=new Map(Object.entries({"base-1":V,"base-json-workspace-1":ft,"base-json-1":H,"base-json-periodic-config-1":U,"base-json-periodic-links-1":W,"base-json-periodic-history-1":G,"base-json-automation-definitions-1":pt,"base-json-slack-connections-1":mt}[e.profile]));for(let n of e.coverage){let e=r.get(n.model);e&&e.status===n.status&&e.limitation===n.limitation||t.addIssue({code:`custom`,message:`Invalid base-1 classification: ${n.model}`}),r.delete(n.model)}r.size&&t.addIssue({code:`custom`,message:`Missing base-1 model classifications`}),(e.exclusions.length!==K.length-Number(n)||new Set(e.exclusions).size!==K.length-Number(n)||n&&e.exclusions.includes(`PHYSICAL_NULLABLE_JSON_FIDELITY`))&&t.addIssue({code:`custom`,message:`Exactly the base-1 global exclusions are required`})});function J(e){return Object.values(e)}var gt=y(J(ce)),_t=y(J(pe)),vt=y(J(le)),yt=y(J(fe)),bt=y(J(be)),xt=y(J(ae)),St=y(J(ue)),Ct=y(J(ie)),wt=y(J(me)),Y=y(J(oe)),Tt=y(J(ye)),Et=y(J(he)),Dt=x({id:C(),name:C(),slug:C().min(1),repoPath:C(),worktreeBasePath:C().min(1),defaultBranch:C(),githubOwner:C().nullable(),githubRepo:C().nullable(),issueProvider:vt,issueTrackerConfig:S().nullable(),isArchived:b(),startupScriptCommand:C().nullable(),startupScriptPath:C().nullable(),startupScriptTimeout:m(),createdAt:C(),updatedAt:C()}),Ot=x({requestId:C(),title:C().nullable(),branch:C().nullable(),summary:C().nullable(),sidebarSummary:C().nullable(),generatedAt:T().nullable(),sourceSessionId:C().nullable(),sourceMessageId:C().nullable()}),X=x({conversationMetadata:Ot.nullable().optional(),prs:_(L).optional().default([]),prDiscovery:tt.nullable().optional().default(null),prMonitoring:$e.nullable().optional().default(null),prEvents:_(et).optional().default([]),id:C(),projectId:C(),parentWorkspaceId:C().nullable().optional().default(null),name:C(),description:C().nullable(),status:gt,worktreePath:C().nullable(),branchName:C().nullable(),isAutoGeneratedBranch:b(),creationSource:_t,creationMetadata:S().nullable(),initErrorMessage:C().nullable(),initOutput:C().nullable(),initStartedAt:C().nullable(),initCompletedAt:C().nullable(),initRetryCount:m(),runScriptCommand:C().nullable(),runScriptCleanupCommand:C().nullable(),runScriptPid:m().nullable(),runScriptPort:m().nullable(),runScriptStartedAt:C().nullable(),runScriptStatus:yt,prUrl:C().nullable(),githubIssueNumber:m().nullable(),githubIssueUrl:C().nullable(),linearIssueId:C().nullable(),linearIssueIdentifier:C().nullable(),linearIssueUrl:C().nullable(),defaultSessionProvider:Et,ratchetSessionProvider:Et.optional(),prNumber:m().nullable(),prState:bt,prReviewState:C().nullable(),prCiStatus:xt,prUpdatedAt:C().nullable(),prCiFailedAt:C().nullable(),prCiLastNotifiedAt:C().nullable(),prReviewLastCheckedAt:C().nullable(),prReviewLastCommentId:C().nullable(),ratchetEnabled:b(),ratchetState:St,ratchetLastCheckedAt:C().nullable(),ratchetActiveSessionId:C().nullable(),ratchetLastCiRunId:C().nullable(),hasHadSessions:b(),createdAt:C(),updatedAt:C()}),kt=x({id:C(),workspaceId:C(),name:C().nullable(),workflow:C(),workspacePrId:C().nullable().optional().default(null),model:C(),status:wt,provider:Y,codexAccountId:C().nullable().optional().default(null),providerSessionId:C().nullable(),providerProjectPath:C().nullable(),providerProcessPid:m().nullable(),providerMetadata:S().nullable(),createdAt:C(),updatedAt:C()}),At=x({id:C(),workspaceId:C(),name:C().nullable(),status:wt,pid:m().nullable(),createdAt:C(),updatedAt:C()}),jt=x({preferredIde:C(),customIdeCommand:C().nullable(),playSoundOnComplete:b(),childWorkspacesEnabled:b().default(!0),ticketDispatchPrompt:C().nullable().optional().default(null),notificationSoundPath:C().nullable(),ratchetEnabled:b(),ratchetReplyToPrComments:b().optional().default(!0),ratchetReviewTriggerMode:Ct.optional().default(`CHANGES_REQUESTED`),defaultSessionProvider:Y,defaultClaudeModel:C().optional().default(`sonnet`),defaultCodexModel:C().optional().default(`default`),defaultClaudeReasoningEffort:C().nullable().optional().default(null),defaultCodexReasoningEffort:C().nullable().optional().default(null),defaultWorkspacePermissions:Tt.optional().default(`STRICT`),ratchetPermissions:Tt.optional(),reviewerSessionProvider:Y.optional().default(`CODEX`),reviewerClaudeModel:C().nullable().optional().default(null),reviewerCodexModel:C().nullable().optional().default(null),postReviewToGitHub:b().optional().default(!0),voiceModeEnabled:b().optional().default(!1),voiceTtsModel:C().optional().default(j).transform(Ue),voiceTtsSpeed:m().optional().default(1).transform(He),voiceUtteranceEndMs:m().int().min(Me).max(je).optional().default(Ne),voiceBargeInSustainedMs:m().int().min(8).max(80).optional().default(16),appearanceColorScheme:C().optional().default(Se).transform(Ce),appearanceBackgroundColor:E.nullable().optional().default(null),appearanceForegroundColor:E.nullable().optional().default(null),appearanceFontScale:xe.optional().default(100),appearanceFontSans:D.nullable().optional().default(null),appearanceFontMono:D.nullable().optional().default(null)}),Z=x({meta:x({exportedAt:C(),version:C(),schemaVersion:d([v(4),v(5),v(6),v(7)])}),data:x({projects:_(Dt),workspaces:_(X),agentSessions:_(kt),codexAccounts:_(ze).optional().default([]),terminalSessions:_(At),userSettings:jt.nullable()})}),Mt=L.extend({ratchet:x({lastCheckedAt:C().nullable(),activeSessionId:C().nullable(),dispatchSnapshotKey:C().nullable(),dispatchOutcome:y([`RUNNING`,`COMPLETED`,`DIED`]).nullable(),dispatchRetryCount:m().int().nonnegative(),dispatchStalled:b()})}),Nt=Z.extend({meta:Z.shape.meta.extend({schemaVersion:v(5)}),data:Z.shape.data.extend({workspaces:_(X.omit({prUrl:!0,prNumber:!0,prState:!0,prReviewState:!0,prCiStatus:!0,prUpdatedAt:!0,prCiFailedAt:!0,prCiLastNotifiedAt:!0,prReviewLastCheckedAt:!0,prReviewLastCommentId:!0,ratchetLastCiRunId:!0,ratchetState:!0}).extend({prs:_(Mt),ratchetActivePrId:C().nullable()}))})}).superRefine(Qe);function Pt(e){return{...e,meta:{...e.meta,schemaVersion:6},data:{...e.data,workspaces:e.data.workspaces.map(t=>{let n=[...new Set([...t.ratchetActiveSessionId?[t.ratchetActiveSessionId]:[],...t.prs.flatMap(e=>e.ratchet.activeSessionId?[e.ratchet.activeSessionId]:[]),...e.data.agentSessions.filter(e=>e.workspaceId===t.id&&e.workflow===`ratchet`).map(e=>e.id)])];return X.parse({...t,prs:t.prs.map(({ratchet:e,...t})=>t),prUrl:null,prNumber:null,prState:`NONE`,prReviewState:null,prCiStatus:`UNKNOWN`,prUpdatedAt:null,prCiFailedAt:null,prCiLastNotifiedAt:null,prReviewLastCheckedAt:null,prReviewLastCommentId:null,ratchetLastCiRunId:null,ratchetState:`IDLE`,ratchetActiveSessionId:null,prMonitoring:{enabled:t.ratchetEnabled,deliveryMode:`MAIN`,recipientSessionId:null,bindingRevision:0,eventEpoch:+!!t.ratchetEnabled,deliveryPauseReason:n.length?`LEGACY_FIXER`:null,legacySessionIds:n,lastCheckedAt:t.ratchetLastCheckedAt}})})}}}function Ft(e){if(e.meta.schemaVersion===6||e.meta.schemaVersion===7)return{...e,meta:{...e.meta,schemaVersion:e.meta.schemaVersion}};let t=e.data.workspaces.map(t=>{let n=[...new Set([...t.ratchetActiveSessionId?[t.ratchetActiveSessionId]:[],...e.data.agentSessions.filter(e=>e.workspaceId===t.id&&e.workflow===`ratchet`).map(e=>e.id)])],r=e.meta.schemaVersion===4?t.prUrl?[L.parse({id:`legacy-pr-${t.id}`,url:t.prUrl,number:t.prNumber,title:null,headRefName:null,baseRefName:null,state:t.prState,reviewState:t.prReviewState,ciStatus:t.prCiStatus,hasMergeConflict:t.ratchetState===`MERGE_CONFLICT`,syncedAt:t.prUpdatedAt,detachedAt:null,revision:0,ciFailedAt:t.prCiFailedAt,ciLastNotifiedAt:t.prCiLastNotifiedAt,reviewLastCheckedAt:t.prReviewLastCheckedAt,reviewLastCommentId:t.prReviewLastCommentId})]:[]:t.prs;return{...t,prs:r,prMonitoring:t.prMonitoring??{enabled:t.ratchetEnabled,deliveryMode:`MAIN`,recipientSessionId:null,bindingRevision:0,eventEpoch:+!!t.ratchetEnabled,deliveryPauseReason:n.length?`LEGACY_FIXER`:null,legacySessionIds:n,lastCheckedAt:t.ratchetLastCheckedAt}}}),n=e.data.agentSessions.map(n=>{let r=t.find(e=>e.id===n.workspaceId);return e.meta.schemaVersion===4&&r?.ratchetActiveSessionId===n.id?{...n,workspacePrId:r.prs[0]?.id??null}:n});return{...e,meta:{...e.meta,schemaVersion:6},data:{...e.data,workspaces:t,agentSessions:n}}}function It(e,t,n){try{return n(e)}catch(e){if(!(e instanceof f))throw e;for(let n of e.issues)t.addIssue({...n});return g}}function Lt(e,t){let n=new Set(e.data.codexAccounts.map(e=>e.id));e.data.agentSessions.forEach((e,r)=>{e.codexAccountId!==null&&!n.has(e.codexAccountId)&&t.addIssue({code:`custom`,path:[`data`,`agentSessions`,r,`codexAccountId`],message:`Saved Codex account metadata is required`})})}var Q=h({meta:h({...Z.shape.meta.shape,schemaVersion:v(8),recovery:q}),data:h({...Z.shape.data.shape,recovery:ht})}).superRefine((e,t)=>{let n=e.meta.recovery.profile===`base-json-slack-connections-1`;(n!==Object.hasOwn(e.data.recovery,`slackConnections`)||n&&!e.data.recovery.slackConnections)&&t.addIssue({code:`custom`,message:`Slack profile sections do not match`})}).superRefine((e,t)=>{let n=e.meta.recovery.profile!==`base-1`,r=e.data.recovery.baseJson;(n!==Object.hasOwn(e.data.recovery,`baseJson`)||n&&!r)&&t.addIssue({code:`custom`,message:`Profile sections do not match`});let i=e.meta.recovery.profile===`base-json-periodic-config-1`||e.meta.recovery.profile===`base-json-periodic-links-1`||e.meta.recovery.profile===`base-json-periodic-history-1`||e.meta.recovery.profile===`base-json-automation-definitions-1`||e.meta.recovery.profile===`base-json-slack-connections-1`,a=e.data.recovery.periodicConfig;(i!==Object.hasOwn(e.data.recovery,`periodicConfig`)||i&&!a)&&t.addIssue({code:`custom`,message:`Periodic profile sections do not match`})}).superRefine((e,t)=>{let n=e.data.recovery.automationDefinitions,r=e.meta.recovery.profile===`base-json-automation-definitions-1`||e.meta.recovery.profile===`base-json-slack-connections-1`;(r!==Object.hasOwn(e.data.recovery,`automationDefinitions`)||r&&!n)&&t.addIssue({code:`custom`,message:`Automation profile sections do not match`});let i=new Set(e.data.projects.map(e=>e.id));n?.definitions.forEach((e,n)=>{i.has(e.projectId)||t.addIssue({code:`custom`,path:[`data`,`recovery`,`automationDefinitions`,`definitions`,n,`projectId`],message:`Automation definition project is absent from backup`})});let a=e.data.recovery.periodicConfig,o=e.meta.recovery.profile!==`base-1`,s=e.data.recovery.baseJson,c=e.data.recovery.periodicHistory,l=e.meta.recovery.profile===`base-json-periodic-history-1`||e.meta.recovery.profile===`base-json-automation-definitions-1`||e.meta.recovery.profile===`base-json-slack-connections-1`;(l!==Object.hasOwn(e.data.recovery,`periodicHistory`)||l&&!c)&&t.addIssue({code:`custom`,message:`History profile sections do not match`});let u=new Map(a?.tasks.map(e=>[e.id,e])),d=new Set(e.data.workspaces.map(e=>e.id));c?.executions.forEach((e,n)=>{let r=u.get(e.periodicTaskId);for(let[i,a]of[[`periodicTaskId`,!!r],[`workspaceId`,e.workspaceId===null||d.has(e.workspaceId)],[`launchSnapshot`,e.launchSnapshot===null||e.launchSnapshot.projectId===r?.projectId]])a||t.addIssue({code:`custom`,message:`Execution source dependency does not match backup`,path:[`data`,`recovery`,`periodicHistory`,`executions`,n,i]})});let f=new Set(e.data.projects.map(e=>e.id));for(let[e,n]of(a?.tasks??[]).entries())f.has(n.projectId)||t.addIssue({code:`custom`,message:`Periodic task project is absent from backup`,path:[`data`,`recovery`,`periodicConfig`,`tasks`,e,`projectId`]});o&&s&<(e.data,s,e.meta.recovery.profile===`base-json-1`||e.meta.recovery.profile===`base-json-periodic-config-1`||e.meta.recovery.profile===`base-json-periodic-links-1`||e.meta.recovery.profile===`base-json-periodic-history-1`||e.meta.recovery.profile===`base-json-automation-definitions-1`||e.meta.recovery.profile===`base-json-slack-connections-1`,t)}),$=Q.safeExtend({meta:Q.shape.meta.extend({recovery:q.safeExtend({profile:y([`base-json-1`,`base-json-periodic-config-1`])})}),data:Q.shape.data.extend({workspaces:_(X.extend({prs:_(L.extend({observation:L.shape.observation.removeDefault()})).optional().default([])}))})}),Rt=Q.safeExtend({meta:Q.shape.meta.extend({recovery:q.safeExtend({profile:y([`base-json-periodic-links-1`,`base-json-periodic-history-1`,`base-json-automation-definitions-1`,`base-json-slack-connections-1`])})}),data:$.shape.data.extend({workspaces:_($.shape.data.shape.workspaces.element.extend({periodicTaskId:C().nullable()}))})}).superRefine((e,t)=>{let n=new Set(e.data.recovery.periodicConfig?.tasks.map(e=>e.id));e.data.workspaces.forEach((e,r)=>{e.periodicTaskId!==null&&!n.has(e.periodicTaskId)&&t.addIssue({code:`custom`,message:`Workspace periodic task is absent from backup`,path:[`data`,`workspaces`,r,`periodicTaskId`]})})}),zt=Q.safeExtend({meta:Q.shape.meta.extend({recovery:q.safeExtend({profile:y([`base-1`,`base-json-workspace-1`])})})}),Bt=d([Nt.transform((e,t)=>It(e,t,Pt)),Z.transform((e,t)=>It(e,t,Ft)),zt,$,Rt]).superRefine(Ze).superRefine(Lt);function Vt({onImportSuccess:e,variant:t=`outline`,className:n,children:o}){let s=(0,A.useRef)(null),[c,l]=(0,A.useState)({open:!1,data:null,summary:``}),d=r.useUtils(),{publishImportResult:f}=Ee(),p=r.admin.importData.useMutation({onSuccess:async t=>{f(t.results),l({open:!1,data:null,summary:``});try{await d.invalidate()}catch{i.error(`Import completed, but refreshing data failed. Reload to refresh.`)}e?.()},onError:e=>{i.error(`Couldn't import backup. ${e.message}`),l({open:!1,data:null,summary:``})}}),ee=e=>[`Exported: ${new Date(e.meta.exportedAt).toLocaleString()}`,`Version: ${e.meta.version}`,``,`Projects: ${e.data.projects.length}`,`Workspaces: ${e.data.workspaces.length}`,`Agent Sessions: ${e.data.agentSessions.length}`,`Terminal Sessions: ${e.data.terminalSessions.length}`,`User Settings: ${e.data.userSettings?`Yes`:`No`}`].join(`
|
|
2
2
|
`),m=e=>e instanceof Error?e.message:`Unknown error`,h=async e=>{let t=await e.text(),n=JSON.parse(t),r=Bt.safeParse(n);if(!r.success)throw Error(`Invalid backup file format: ${r.error.message}`);return r.data},te=async e=>{let t=e.target.files?.[0];if(t){try{let e=await h(t);l({open:!0,data:e,summary:ee(e)})}catch(e){i.error(`Couldn't read file. ${m(e)}`)}s.current&&(s.current.value=``)}};return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(u,{onClick:()=>s.current?.click(),disabled:p.isPending,variant:t,className:n,children:[(0,k.jsx)(Re,{className:`w-4 h-4 mr-2`}),p.isPending?`Importing…`:o||`Import data`]}),(0,k.jsx)(`input`,{ref:s,type:`file`,accept:`.json`,onChange:e=>{a(te(e),`Couldn't import backup.`)},className:`hidden`}),(0,k.jsx)(Te,{open:c.open,onOpenChange:e=>{e||l({open:!1,data:null,summary:``})},title:`Confirm import`,description:`Review the data to be imported. Existing records will be skipped.\n\n${c.summary}`,confirmText:`Import`,onConfirm:()=>{c.data&&p.mutate(c.data)},isPending:p.isPending})]})}export{P as a,M as i,Be as n,j as o,N as r,Ie as s,Vt as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-viewer-DNUPJg_G.js","assets/rolldown-runtime-COiEfhsA.js","assets/jsx-runtime-CldxteV5.js","assets/dist-DxBCWJgX.js","assets/trpc-D9WuCSM1.js","assets/utils-DQeSPVda.js","assets/bundle-mjs-CdK3cBzO.js","assets/button-Dslj7pht.js","assets/loading-SklnwAL1.js","assets/spinner-BxeSV-Bb.js","assets/use-persistent-scroll-DMRAfhA7.js","assets/schemas-cLRPP1ma.js","assets/use-workspace-drawer-D5BHCzpQ.js","assets/use-mobile-Di9JSXG3.js","assets/chat-BsZewCkt.js","assets/react-dom-BNtzwOHF.js","assets/background-task-2TNZSSC3.js","assets/CheckCircle.es-WUl0_Fqk.js","assets/status-indicators-Dvz22Kk_.js","assets/Warning.es-BRY0GI4S.js","assets/es2015-CDGxiYHE.js","assets/dist-B1Zs6lmy.js","assets/dialog-LD_zPUYD.js","assets/dist-y4SI7xsk.js","assets/dist-DmRbNcLV.js","assets/ArrowClockwise.es-CucFsYLg.js","assets/CaretDown.es-Dad3vS2k.js","assets/pending-request-presentation-BqY92kUN.js","assets/ShieldWarning.es-CuA46yPp.js","assets/WarningCircle.es-D-X961df.js","assets/workspace-cache-reconciler-TKQHxUsu.js","assets/preload-helper-BLdHbfdN.js","assets/MagnifyingGlass.es-BlNhc0fx.js","assets/attachment-file-conversion-BG03_iix.js","assets/formatters-CbVS7bYs.js","assets/input-uo3fNc4V.js","assets/Plus.es-wnPcLFe1.js","assets/dist-CLSCCiF9.js","assets/github-pr-preview-B2sd2tDg.js","assets/date-time-DaFd7tnC.js","assets/use-websocket-channel-BApRAMMz.js","assets/index-BHTworEd.js","assets/hooks-CZYZW9i_.js","assets/components-Be4xRGcU.js","assets/lib-D-JAPasO.js","assets/queryClient-DaT6C6i7.js","assets/image-drop-zone-NvcW7wXO.js","assets/appearance-DsbwoDTa.js","assets/appearance-D7nkDMex.js","assets/dist-D8Wfxh48.js","assets/index-sK2DBc7b.css","assets/lib-BF21T6dw.js","assets/FileText.es-C3zlL7Ja.js","assets/SlidersHorizontal.es-DWmgkQAH.js","assets/Folder.es-BA68BESp.js","assets/agent-definition.schema-DaZC-6OB.js","assets/codex-accounts-C8imj_4P.js","assets/card-D16by-Fq.js","assets/websocket-BT8C-OBP.js","assets/popover-DjYf9lKZ.js","assets/Terminal.es-DXk70l2n.js","assets/list-keys-CmT9WnL5.js","assets/agent-authoring-CzgCC7xn.js","assets/collapsible-dJ6oDAH6.js","assets/CaretLeft.es-CZp1Z1Qg.js","assets/radio-group-FNSEl1BJ.js","assets/styles-B5GgyFSq.js","assets/use-diff-highlighting-CLJSy52c.js","assets/file-viewer-CbXNMHbC.js","assets/file-viewer-DVd46AFa.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{f as r,l as i,s as a}from"./hooks-CZYZW9i_.js";import{i as o}from"./lib-D-JAPasO.js";import{n as s}from"./trpc-D9WuCSM1.js";import{r as c,t as l}from"./background-task-2TNZSSC3.js";import{r as u,t as d}from"./utils-DQeSPVda.js";import{t as f}from"./CheckCircle.es-WUl0_Fqk.js";import{c as p,s as m,u as h,y as g}from"./status-indicators-Dvz22Kk_.js";import{n as _,t as v}from"./spinner-BxeSV-Bb.js";import{t as y}from"./Warning.es-BRY0GI4S.js";import{t as b}from"./CaretDown.es-Dad3vS2k.js";import{t as x}from"./pending-request-presentation-BqY92kUN.js";import{t as S}from"./button-Dslj7pht.js";import{i as C,n as w,t as T}from"./image-drop-zone-NvcW7wXO.js";import{t as E}from"./loading-SklnwAL1.js";import{k as D,l as O,o as k,p as A,v as j,w as M,x as N,y as P}from"./schemas-cLRPP1ma.js";import{d as F,n as ee,r as te}from"./use-persistent-scroll-DMRAfhA7.js";import{b as ne,v as re,x as ie,y as ae}from"./workspace-cache-reconciler-TKQHxUsu.js";import{p as oe}from"./es2015-CDGxiYHE.js";import{t as se}from"./preload-helper-BLdHbfdN.js";import{t as ce}from"./input-uo3fNc4V.js";import{a as le}from"./dist-y4SI7xsk.js";import{a as I,n as L,r as R}from"./Plus.es-wnPcLFe1.js";import{r as z,t as B}from"./use-websocket-channel-BApRAMMz.js";import{n as ue}from"./use-workspace-drawer-D5BHCzpQ.js";import{C as V,F as H,G as de,H as fe,I as U,N as pe,P as me,S as he,U as ge,V as _e,W as ve,X as ye,b as be,c as W,d as xe,f as Se,i as Ce,j as we,l as Te,m as Ee,n as De,r as Oe,t as ke,u as Ae,v as je,y as Me}from"./chat-BsZewCkt.js";import{$ as Ne,$t as Pe,Dt as Fe,F as Ie,J as Le,Jt as Re,M as ze,Ot as Be,P as Ve,Q as He,U as Ue,Y as We,Yt as Ge,Z as Ke,b as qe,ct as Je,et as Ye,g as Xe,it as G,j as Ze,kt as Qe,lt as $e,on as et,t as tt,u as nt,y as rt}from"./index-BHTworEd.js";import{i as it}from"./websocket-BT8C-OBP.js";import{n as at,r as K,t as ot}from"./popover-DjYf9lKZ.js";import{c as st,i as ct,l as lt,n as ut,o as dt,r as q,s as J,u as ft}from"./DotsThree.es-Dx8TXzzQ.js";import{t as pt}from"./list-keys-CmT9WnL5.js";import{a as mt,d as ht,f as gt,i as Y,n as _t,o as X,r as vt}from"./CaretLeft.es-CZp1Z1Qg.js";import{n as yt,t as bt}from"./endOfMonth-DC74gC1p.js";import{t as xt}from"./live-session-control-B9Xbg14T.js";import{t as St}from"./voice-vad-ChMQMgBS.js";import{t as Ct}from"./Microphone.es-Dtdzh_vQ.js";import{a as wt,c as Tt,i as Et,n as Dt,o as Ot,r as kt,s as At,t as jt}from"./right-panel-BUm-IUuW.js";function Mt(e,t){return+X(e)-X(t)}function Nt(e,t){let n=X(e,t?.in);return n.setHours(23,59,59,999),n}function Pt(e,t){let n=X(e,t?.in);return+Nt(n,t)==+bt(n,t)}function Ft(e,t,n){let[r,i,a]=vt(n?.in,e,e,t),o=U(i,a),s=Math.abs(yt(i,a));if(s<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-o*s);let c=U(i,a)===-o;Pt(r)&&s===1&&U(r,a)===1&&(c=!1);let l=o*(s-+c);return l===0?0:l}function It(e,t,n){let r=Mt(e,t)/1e3;return me(n?.roundingMethod)(r)}function Lt(e,t,n){let r=mt(),i=n?.locale??r.locale??_t,a=U(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),[s,c]=vt(n?.in,...a>0?[t,e]:[e,t]),l=It(c,s),u=(Y(c)-Y(s))/1e3,d=Math.round((l-u)/60),f;if(d<2)return n?.includeSeconds?l<5?i.formatDistance(`lessThanXSeconds`,5,o):l<10?i.formatDistance(`lessThanXSeconds`,10,o):l<20?i.formatDistance(`lessThanXSeconds`,20,o):l<40?i.formatDistance(`halfAMinute`,0,o):l<60?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,1,o):d===0?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,d,o);if(d<45)return i.formatDistance(`xMinutes`,d,o);if(d<90)return i.formatDistance(`aboutXHours`,1,o);if(d<1440){let e=Math.round(d/60);return i.formatDistance(`aboutXHours`,e,o)}if(d<2520)return i.formatDistance(`xDays`,1,o);if(d<43200){let e=Math.round(d/ht);return i.formatDistance(`xDays`,e,o)}if(d<86400)return f=Math.round(d/gt),i.formatDistance(`aboutXMonths`,f,o);if(f=Ft(c,s),f<12){let e=Math.round(d/gt);return i.formatDistance(`xMonths`,e,o)}{let e=f%12,t=Math.trunc(f/12);return e<3?i.formatDistance(`aboutXYears`,t,o):e<9?i.formatDistance(`overXYears`,t,o):i.formatDistance(`almostXYears`,t+1,o)}}function Rt(e,t){return Lt(e,H(e),t)}var Z=e(t(),1);function zt(e){return e.replace(/(?::\d+){1,2}$/,``)}function Bt(e,t,n){if(t&&t!==`.`){if(t===`..`){let r=e[e.length-1];e.length>0&&r!==`..`?e.pop():n||e.push(t)}else e.push(t)}}function Vt(e,t){let n=t?e.replace(/\\/g,`/`):e,r=n.startsWith(`/`)||t&&/^[A-Za-z]:\//.test(n),i=[];for(let e of n.split(`/`))Bt(i,e,r);return`${r?`/`:``}${i.join(`/`)}`.replace(/\/+$/,``)||(r?`/`:`.`)}function Ht(e){try{return decodeURIComponent(e)}catch{return e}}function Ut(e,t){let n=e.trim();if(!n)return null;if(/^[A-Za-z]:(?:[\\/]|%5C)/i.test(n))return Ht(n.split(/[?#]/,1)[0]??n);try{let e=new URL(n,t??`http://localhost`);return e.protocol!==`http:`&&e.protocol!==`https:`&&e.protocol!==`file:`||t&&e.origin!==t&&e.protocol!==`file:`?null:decodeURIComponent(e.pathname)}catch{return Ht(n)}}function Wt(e,t,n=typeof window<`u`?window.location.origin:void 0){if(!(e&&t))return null;let r=Ut(e,n);if(!r)return null;let i=/^[A-Za-z]:[\\/]/.test(t),a=Vt(zt(r),i),o=Vt(t,i),s=i?a.toLowerCase():a,c=i?o.toLowerCase():o;if(!(s===c||s.startsWith(`${c}/`)))return null;let l=a.slice(o.length).replace(/^\/+/,``);return l.length>0?l:null}var Gt=j({filePath:N(),ownerId:N(),ownerLabel:N().optional(),acquiredAt:N(),expiresAt:N(),metadata:P(N(),M()).optional()});j({version:A(1),workspaceId:N(),locks:k(Gt)});var Kt=k(N());P(N(),k(N()));var qt=`ff_resume_workspace_ids`;function Jt(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(qt);if(!e)return[];let t=JSON.parse(e);return Kt.parse(t)}catch{return[]}}function Yt(e){if(typeof window<`u`)try{window.localStorage.setItem(qt,JSON.stringify(e))}catch{}}function Xt(e){Yt(Jt().filter(t=>t!==e))}function Zt(e){return Jt().includes(e)}var Qt=[];function $t(){let{mutate:e,isPending:t}=s.workspace.openInIde.useMutation({onError:e=>c.error(e.message)}),{data:n}=s.workspace.getAvailableIdes.useQuery();return{openInIde:(0,Z.useMemo)(()=>({mutate:e,isPending:t}),[e,t]),availableIdes:n?.ides??Qt,preferredIde:n?.preferredIde??`cursor`}}function en(e,t){if(lt(e)){t();return}let n=typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?e.message:`Couldn't archive workspace.`;c.error(n||`Couldn't archive workspace.`)}function tn({workspaceId:e}){let t=s.useUtils(),{data:n,isLoading:r}=wt(e),i=(0,Z.useCallback)(()=>{l(t.workspace.get.invalidate({id:e}),`Couldn't refresh data.`)},[t,e]),a=s.workspace.syncPRStatus.useMutation({meta:{errorToast:`Couldn't sync pull request status.`},onSuccess:()=>{l(t.workspace.get.invalidate({id:e}),`Couldn't refresh data.`)}}),o=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{n?.prs.length&&!o.current&&!a.isPending&&(o.current=!0,a.mutate({workspaceId:e,force:!1}))},[n?.prs.length,e,a]);let{data:c,isLoading:u}=s.session.listSessions.useQuery({workspaceId:e},{refetchInterval:1e4,staleTime:0,refetchOnWindowFocus:!1}),{data:d}=s.session.getMaxSessionsPerWorkspace.useQuery();return{workspace:n,workspaceLoading:r,sessions:c,sessionsLoading:u,initialDbSessionId:c?.[0]?.id,maxSessions:d,invalidateWorkspace:i}}function nn({workspaceId:e,slug:t,sessions:n,inputRef:r,selectedDbSessionId:a,setSelectedDbSessionId:o,onArchiveGitIndexLocked:c}){let l=i(),u=s.useUtils(),d=(0,Z.useRef)(e);(0,Z.useLayoutEffect)(()=>{d.current=e},[e]);let{createSession:f,deleteSession:p,createChat:m,createQuickActionAsync:h}=De({workspaceId:e,sessions:n,onCreated:(e,t,n)=>{d.current===t&&(o(e.id),n===`chat`&&setTimeout(()=>r.current?.focus(),0))}}),g=w(m),_=w(h),v=(0,Z.useRef)(null);(0,Z.useLayoutEffect)(()=>(v.current=Symbol(`${e}/${t}`),()=>{v.current=null}),[e,t]);let y=(e,t,n)=>{en(e,t?c:()=>void 0),t&&n?.(e)},b=nt(),x=w((e,n)=>{let r=v.current,i=u.workspace.get.getData({id:e.id})?.projectId;b.archiveWorkspace({...e,projectId:i}).then(e=>{let i=e[0];if(!i)return;let a=v.current===r;if(i.success){if(!a)return;l(t?`/projects/${t}/workspaces`:`/projects`,{replace:!0}),n?.onSuccess?.(void 0)}else y(i.error,a,n?.onError)})}),S=(0,Z.useMemo)(()=>({isPending:b.isArchiving,mutate:x}),[b.isArchiving,x]),{openInIde:C,availableIdes:T,preferredIde:E}=$t();return{createSession:f,deleteSession:p,archiveWorkspace:S,openInIde:C,availableIdes:T,preferredIde:E,handleSelectSession:(0,Z.useCallback)(e=>{o(e),setTimeout(()=>r.current?.focus(),0)},[r,o]),handleCloseSession:w(e=>{if(!n||n.length===0)return;let t=n.findIndex(t=>t.id===e);if(t===-1)return;let r=e===a;p.mutate({id:e}),r&&n.length>1?o((n[t+1]??n[t-1])?.id??null):n.length===1&&o(null)}),handleNewChat:g,handleQuickAction:_}}var rn=`ff_setup_warning_dismissed:`;function an(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function on(e){return`${rn}${e}`}function sn(e,t){if(!t)return!1;try{return an()?.getItem(on(e))===t}catch{return!1}}function cn(e,t){if(t)try{an()?.setItem(on(e),t)}catch{}}function ln(e){try{an()?.removeItem(on(e))}catch{}}function un(e,t,n,r){let i=t?.hasHadSessions===!0&&t.prState===`NONE`,{data:a}=s.workspace.hasChanges.useQuery({workspaceId:e},{enabled:i}),o=(0,Z.useRef)({workspaceId:e,running:n});return(0,Z.useEffect)(()=>{let t=o.current;i&&t.workspaceId===e&&t.running&&!n&&r.workspace.hasChanges.invalidate({workspaceId:e}),o.current={workspaceId:e,running:n}},[n,i,r,e]),a}function dn(e,t,n){let{data:r,isPending:i,isError:a}=s.workspace.getInitStatus.useQuery({id:e},{refetchInterval:e=>{let t=e.state.data?.status,n=e.state.data?.retryAvailability;return e.state.status===`error`||!n||n?.status===`BLOCKED`&&![`NOT_RETRYABLE`,`RETRY_LIMIT`].includes(n.reason)?1e3:t===`READY`||t===`FAILED`||t===`ARCHIVING`||t===`ARCHIVED`?!1:1e3}}),o=(0,Z.useMemo)(()=>r&&a?{...r,retryAvailability:{status:`BLOCKED`,reason:`AUTHORITY_UNAVAILABLE`,explanation:`Setup retry availability could not be checked. Refresh and try again.`}}:r,[r,a]),c=(0,Z.useRef)(void 0),u=(0,Z.useRef)(!1),d=o?.hasWorktreePath??!1;(0,Z.useEffect)(()=>{let r=o?.status,i=c.current;if(d&&!u.current&&l(n.workspace.get.invalidate({id:e}),`Couldn't refresh data.`),u.current=d,r===`READY`){let r=i!==void 0&&i!==`READY`,a=i===void 0&&!t?.worktreePath;(r||a)&&l(n.workspace.get.invalidate({id:e}),`Couldn't refresh data.`)}c.current=r},[o?.status,d,e,n,t?.worktreePath]);let f=o?.status,p=o?.initErrorMessage??null,m=f===`FAILED`&&d||f===`READY`&&!!p,[h,g]=(0,Z.useState)(null),_=h?.workspaceId===e&&h.initErrorMessage===p?h.dismissed:null;return(0,Z.useEffect)(()=>{o&&(p?o.chatBanner?.showDismiss===!0?g({workspaceId:e,initErrorMessage:p,dismissed:sn(e,p)}):g({workspaceId:e,initErrorMessage:p,dismissed:!1}):(ln(e),g({workspaceId:e,initErrorMessage:p,dismissed:!1})))},[e,o,p]),{workspaceInitStatus:o,isInitStatusPending:i,isScriptFailed:m,setupWarningDismissed:_,dismissSetupWarning:(0,Z.useCallback)(()=>{cn(e,p),g({workspaceId:e,initErrorMessage:p,dismissed:!0})},[e,p])}}var fn=`workspace-selected-session-`,pn=5e3;function mn({currentSelectedDbSessionId:e,persistedSessionId:t,initialDbSessionId:n,sessionIds:r,pendingSelectionId:i,pendingSelectionSetAtMs:a,nowMs:o=Date.now()}){return r.length===0||i!=null&&e===i&&!r.includes(i)&&a!=null&&o-a<pn||e&&r.includes(e)?e:t&&r.includes(t)?t:n&&r.includes(n)?n:r[0]??null}function hn(e,t,n,r=null,i,a){let o=`${fn}${e}`,s=(0,Z.useRef)(null),c=r?`${a??``}:${r}`:null,l=(0,Z.useRef)({id:null,setAtMs:null}),[u,d]=(0,Z.useState)(()=>{let e=localStorage.getItem(o);return r??e??t});return(0,Z.useEffect)(()=>{if(r||(s.current=null),r&&c!==s.current&&n.includes(r)){s.current=c,l.current={id:null,setAtMs:null},localStorage.setItem(o,r),d(r),i?.();return}let e=l.current;e.id&&n.includes(e.id)&&(l.current={id:null,setAtMs:null});let a=localStorage.getItem(o),f=mn({currentSelectedDbSessionId:u,persistedSessionId:a,initialDbSessionId:t,sessionIds:n,pendingSelectionId:l.current.id,pendingSelectionSetAtMs:l.current.setAtMs});f!==u&&d(f)},[t,u,n,o,r,i,c]),{selectedDbSessionId:u,setSelectedDbSessionId:(0,Z.useCallback)(e=>{l.current={id:e,setAtMs:e?Date.now():null},d(e),e?localStorage.setItem(o,e):localStorage.removeItem(o)},[o])}}function gn({workspaceLoading:e,workspace:t,selectedDbSessionId:n,activeTabId:r,loadingSession:i,inputRef:a}){let o=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{!(o.current||e)&&t&&n&&r===`chat`&&!i&&(o.current=!0,setTimeout(()=>a.current?.focus(),0))},[n,r,i,e,t,a])}function _n({status:e,slug:t,archivePending:n}){let r=i(),a=(0,Z.useRef)(n),o=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{let i=a.current&&!n;a.current=n,!n&&(e===`ARCHIVING`?i&&(o.current=!0):o.current=!1,!(o.current||e!==`ARCHIVING`&&e!==`ARCHIVED`)&&r(t?`/projects/${t}/workspaces`:`/projects`,{replace:!0}))},[n,e,t,r])}var Q=n();function vn(e){return(0,Q.jsx)(T,{dropIdentity:`${e.workspaceId}/${e.sessionId??`none`}/${e.inputDraftGeneration??0}`,disabled:!(e.sessionId&&e.connected)||e.sessionStatus.phase===`loading`||!e.chatCapabilities.attachments.enabled||!e.chatCapabilities.attachments.kinds.includes(`image`),label:`Drop images to attach to your message`,onAttachments:t=>{e.setInputAttachments(e=>[...e,...t]),e.inputRef.current?.focus()},children:e.children})}var yn=.02,bn=2;function xn(e){if(e.length===0)return 0;let t=0;for(let n of e){let e=n/32768;t+=e*e}return Math.sqrt(t/e.length)}var Sn=class{sustainedFramesToTrigger;loudFrameStreak=0;speaking=!1;constructor(e=bn){this.sustainedFramesToTrigger=e}observe(e){return xn(e)>=yn?this.loudFrameStreak+=1:(this.loudFrameStreak=0,this.speaking=!1),!this.speaking&&this.loudFrameStreak>=this.sustainedFramesToTrigger&&(this.speaking=!0,!0)}isSpeaking(){return this.speaking}reset(){this.loudFrameStreak=0,this.speaking=!1}},Cn=`wss://api.deepgram.com/v1/listen`,wn=16e3,Tn=`/audio-worklets/pcm-capture-processor.js`,En=128/wn*1e3,Dn=[`please stop`,`hold on`,`cancel that`];function On(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var kn=Dn.map(e=>RegExp(`\\b${On(e)}\\b`));function An(e){let t=e.trim().toLowerCase();return kn.some(e=>e.test(t))}var jn=new Set([`Results`,`UtteranceEnd`]);function Mn(e){if(typeof e!=`string`)return null;try{let t=JSON.parse(e);if(t&&typeof t==`object`&&jn.has(t.type))return t}catch{}return null}function Nn({workletNode:e,silentGain:t,audioContext:n,mediaStream:r,socket:i}){e&&(e.port.onmessage=null,e.port.close(),e.disconnect()),t?.disconnect(),n?.close().catch(()=>void 0);for(let e of r?.getTracks()??[])e.stop();i&&(i.onclose=null,i.onmessage=null,i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({type:`CloseStream`})),i.close())}function Pn(e){return new Promise((t,n)=>{e.addEventListener(`open`,()=>t(),{once:!0}),e.addEventListener(`close`,e=>{n(Error(`Couldn't connect to Deepgram (WebSocket closed, code ${e.code}${e.reason?`: ${e.reason}`:``}). Check the browser Network tab for the actual handshake response.`))},{once:!0})})}function Fn(e,t){let n=new URLSearchParams({model:`nova-3`,language:`en`,encoding:`linear16`,sample_rate:String(wn),channels:`1`,interim_results:`true`,smart_format:`true`,vad_events:`true`,utterance_end_ms:String(t)});return new WebSocket(`${Cn}?${n.toString()}`,[`bearer`,e])}async function In(e,t){await e.audioWorklet.addModule(Tn);let n=e.createMediaStreamSource(t),r=new AudioWorkletNode(e,`pcm-capture-processor`,{processorOptions:{targetSampleRate:wn}}),i=e.createGain();return i.gain.value=0,n.connect(r),r.connect(i),i.connect(e.destination),{workletNode:r,silentGain:i}}function Ln(){let e=``;return{appendFinal(t){return e=e?`${e} ${t}`:t,e},preview(t){return e?`${e} ${t}`:t},flush(){let t=e.trim();return e=``,t}}}function Rn(e,t,n,r){let i=e.channel?.alternatives?.[0]?.transcript;if(i){if(n.runningRef.current&&An(i))t.flush(),r.current=!0,n.onSoftStop?.();else if(!r.current){if(e.is_final){let e=t.appendFinal(i);n.onInterimTranscript?.(e)}else n.onInterimTranscript?.(t.preview(i))}}}function zn(e,t){let n=Ln(),r={current:!1};e.onmessage=e=>{let i=Mn(e.data);if(i?.type===`UtteranceEnd`){let e=n.flush(),i=r.current;r.current=!1,!i&&e&&t.onFinalTranscript(e)}else i?.type===`Results`&&Rn(i,n,t,r)}}function Bn(e,t){e.port.onmessage=e=>{t.socketRef.current?.readyState===WebSocket.OPEN&&t.socketRef.current.send(e.data);let n=t.speechDetectorRef.current;if(!n)return;let r=n.isSpeaking();n.observe(new Int16Array(e.data))?t.onSpeechDetected?.():r&&!n.isSpeaking()&&t.onSpeechEnded?.()}}function Vn(e,t){e.onclose=e=>{t.isStale()||(t.cleanup(),t.setError(`Lost connection to Deepgram (code ${e.code}). Tap the microphone to reconnect.`))}}async function Hn(e){let t=null,n=null,r=new AudioContext({sampleRate:wn});r.resume().catch(()=>void 0);let i=null,a=null,o=()=>Nn({workletNode:i,silentGain:a,audioContext:r,mediaStream:n,socket:t});try{let{accessToken:s}=await e.mintGrantToken.mutateAsync();if(e.isStale()||(t=Fn(s,e.utteranceEndMs),zn(t,e),await Pn(t),e.isStale()))return o(),null;let c={current:null};if(t.addEventListener(`close`,e=>{c.current=e}),n=await navigator.mediaDevices.getUserMedia({audio:!0}),e.isStale())return o(),null;let l=await In(r,n);if(e.isStale())return o(),null;if(i=l.workletNode,a=l.silentGain,c.current)throw Error(`Lost connection to Deepgram (code ${c.current.code}) while starting capture. Tap the microphone to reconnect.`);let u=new Sn(Math.max(1,Math.round(e.bargeInSustainedMs/En)));return Bn(i,{...e,speechDetectorRef:{current:u}}),Vn(t,e),{socket:t,stream:n,audioContext:r,workletNode:i,silentGain:a,speechDetector:u}}catch(e){throw o(),e}}function Un({onFinalTranscript:e,onInterimTranscript:t,running:n,onSoftStop:r,onSpeechDetected:i,onSpeechEnded:a,utteranceEndMs:o=St,bargeInSustainedMs:c=16}){let[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=s.voice.mintGrantToken.useMutation({meta:{errorToast:!1}}),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(null),b=(0,Z.useRef)(null),x=(0,Z.useRef)(null),S=(0,Z.useRef)(n??!1);S.current=n??!1;let C=(0,Z.useRef)(0),w=(0,Z.useCallback)(()=>{Nn({workletNode:_.current,silentGain:v.current,audioContext:g.current,mediaStream:y.current,socket:b.current}),_.current=null,v.current=null,g.current=null,y.current=null,b.current=null,x.current=null,u(!1)},[]);return{isCapturing:l,isConnecting:d,error:p,start:(0,Z.useCallback)(async()=>{C.current+=1;let n=C.current,s=()=>C.current!==n;m(null),f(!0);try{let n=await Hn({mintGrantToken:h,isStale:s,runningRef:S,onSoftStop:r,onFinalTranscript:e,onInterimTranscript:t,onSpeechDetected:i,onSpeechEnded:a,socketRef:b,cleanup:w,setError:m,utteranceEndMs:o,bargeInSustainedMs:c});if(!n)return;b.current=n.socket,y.current=n.stream,g.current=n.audioContext,_.current=n.workletNode,v.current=n.silentGain,x.current=n.speechDetector,u(!0)}catch(e){s()||m(e instanceof Error?e.message:`Couldn't start voice capture`)}finally{s()||f(!1)}},[w,h,e,t,r,i,a,o,c]),stop:(0,Z.useCallback)(()=>{C.current+=1,w(),f(!1)},[w])}}O(`type`,[j({type:A(`soft_stop`)})]);var Wn=j({type:A(`audio_chunk`),data:N()}),Gn=j({type:A(`clear_playback`)}),Kn=O(`type`,[Wn,Gn]),qn=24e3,Jn=.3,Yn=120;function Xn(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new Int16Array(n.buffer)}function Zn({sessionId:e,enabled:t}){let[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(null),a=(0,Z.useRef)(0),o=(0,Z.useRef)(new Set),s=(0,Z.useRef)(!1),c=(0,Z.useRef)(!1),l=(0,Z.useRef)([]),u=(0,Z.useRef)(null),d=(0,Z.useCallback)(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null),l.current=[]},[]),f=(0,Z.useCallback)(e=>{let t=i.current;if(!t)return;t.state===`suspended`&&!s.current&&(s.current=!0,t.resume().catch(()=>void 0).finally(()=>{s.current=!1}));let n=new Float32Array(e.length);for(let t=0;t<e.length;t++)n[t]=(e[t]??0)/32768;let c=t.createBuffer(1,n.length,qn);c.copyToChannel(n,0);let l=t.createBufferSource();l.buffer=c,l.connect(t.destination);let u=a.current<=t.currentTime?t.currentTime+Jn:a.current;l.start(u),a.current=u+c.duration,o.current.add(l),r(!0),l.onended=()=>{o.current.delete(l),o.current.size===0&&r(!1)}},[]),p=(0,Z.useCallback)(()=>{u.current=null;let e=l.current;if(l.current=[],e.length===0)return;let t=e.reduce((e,t)=>e+t.length,0),n=new Int16Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;f(n)},[f]),m=(0,Z.useCallback)(e=>{l.current.push(e),u.current===null&&(u.current=setTimeout(p,Yn))},[p]),h=(0,Z.useCallback)(()=>{d();for(let e of o.current)try{e.stop()}catch{}o.current.clear(),a.current=i.current?.currentTime??0,r(!1)},[d]),g=(0,Z.useCallback)(()=>{i.current||(i.current=new AudioContext,a.current=0),i.current.resume().catch(()=>void 0)},[]),_=(0,Z.useCallback)(e=>{if(e.type===`audio_chunk`){if(c.current)return;m(Xn(e.data))}else e.type===`clear_playback`&&h()},[m,h]),v=(0,Z.useCallback)(()=>{c.current=!0,h()},[h]),y=(0,Z.useCallback)(()=>{c.current=!1},[]),b=t&&e?z(`/voice`,{sessionId:e}):null,{send:x}=B({url:b,schema:Kn,onMessage:_}),S=(0,Z.useCallback)(()=>{x({type:`soft_stop`})},[x]);return(0,Z.useEffect)(()=>{if(t&&e)return g(),()=>{d();for(let e of o.current)try{e.stop()}catch{}o.current.clear(),i.current?.close().catch(()=>void 0),i.current=null,a.current=0,c.current=!1,r(!1)}},[t,e,d,g]),{isSpeaking:n,sendSoftStop:S,stopPlayback:h,primeAudioContext:g,beginBargeIn:v,endBargeIn:y}}var Qn=new Map([[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M213.92,218.62l-160-176A8,8,0,0,0,42.08,53.38L80,95.09V128a48,48,0,0,0,69.11,43.12l11.1,12.2A63.41,63.41,0,0,1,128,192a64.07,64.07,0,0,1-64-64,8,8,0,0,0-16,0,80.11,80.11,0,0,0,72,79.6V240a8,8,0,0,0,16,0V207.59a78.83,78.83,0,0,0,35.16-12.22l30.92,34a8,8,0,1,0,11.84-10.76ZM128,160a32,32,0,0,1-32-32V112.69l41.66,45.82A32,32,0,0,1,128,160Zm57.52-3.91A63.32,63.32,0,0,0,192,128a8,8,0,0,1,16,0,79.16,79.16,0,0,1-8.11,35.12,8,8,0,0,1-7.19,4.49,7.88,7.88,0,0,1-3.51-.82A8,8,0,0,1,185.52,156.09ZM84,44.87A48,48,0,0,1,176,64v64a49.19,49.19,0,0,1-.26,5,8,8,0,0,1-8,7.17,8.13,8.13,0,0,1-.84,0,8,8,0,0,1-7.12-8.79c.11-1.1.17-2.24.17-3.36V64A32,32,0,0,0,98.64,51.25,8,8,0,1,1,84,44.87Z`}))]]),$n=Z.forwardRef((e,t)=>Z.createElement(u,{ref:t,...e,weights:Qn}));$n.displayName=`MicrophoneSlashIcon`;function er(e,t,n,r){return e||t?e?`connecting`:n?`speaking`:r?`thinking`:`listening`:`off`}function tr(e,t,n){return n?{label:t?`Voice on`:`Voice off`,title:n}:e?{label:`Connecting…`,title:`Connecting to Deepgram — speech is not captured yet. Click to cancel.`}:t?{label:`Voice on`,title:`Exit voice mode`}:{label:`Voice off`,title:`Enter voice mode`}}var nr={off:``,connecting:`Connecting`,speaking:`Speaking`,thinking:`Thinking`,listening:`Listening`};function rr({phase:e}){return e===`off`?null:(0,Q.jsxs)(`output`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:d(`h-1.5 w-1.5 rounded-full`,e===`connecting`&&`animate-pulse bg-muted-foreground`,e===`speaking`&&`animate-pulse bg-info`,e===`thinking`&&`animate-pulse bg-running`,e===`listening`&&`bg-success`)}),nr[e]]})}var ir=(0,Z.memo)(function({sessionId:e,onFinalTranscript:t,running:n,disabled:r}){let{data:i}=s.voice.getConfig.useQuery(),[a,o]=(0,Z.useState)(!1),{isSpeaking:l,sendSoftStop:u,primeAudioContext:d,beginBargeIn:f,endBargeIn:p}=Zn({sessionId:e,enabled:a}),{isCapturing:m,isConnecting:h,error:g,start:_,stop:y}=Un({onFinalTranscript:(0,Z.useCallback)(e=>t(e,{voiceMode:!0}),[t]),running:n,onSoftStop:u,onSpeechDetected:f,onSpeechEnded:p,utteranceEndMs:i?.utteranceEndMs,bargeInSustainedMs:i?.bargeInSustainedMs});(0,Z.useEffect)(()=>()=>y(),[y]);let b=(0,Z.useRef)(e);(0,Z.useEffect)(()=>{let t=b.current!==e;b.current=e,(!e||t)&&(m||h)&&(y(),o(!1))},[e,m,h,y]);let x=er(h,m,l,!!n&&!l),C=(0,Z.useRef)(`off`);(0,Z.useEffect)(()=>{C.current===`listening`&&x===`thinking`&&tt(`sounds/voice-thinking-start.mp3`,{volume:.3}),C.current=x},[x]),(0,Z.useEffect)(()=>(window.dispatchEvent(new CustomEvent(`voice-mode-changed`,{detail:{active:m}})),()=>{window.dispatchEvent(new CustomEvent(`voice-mode-changed`,{detail:{active:!1}}))}),[m]),(0,Z.useEffect)(()=>{g&&(c.error(g),o(!1))},[g]);let w=!!(i?.enabled&&i.hasApiKey);(0,Z.useEffect)(()=>{i!==void 0&&!w&&(m||h)&&(y(),o(!1))},[i,w,m,h,y]);let T=(0,Z.useCallback)(()=>{m||h?(y(),o(!1)):(d(),o(!0),_())},[m,h,_,y,d]);if(!w)return null;let E=tr(h,m,g);return(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsxs)(S,{type:`button`,variant:m?`default`:`outline`,size:`sm`,className:`shrink-0`,disabled:!(m||h)&&(r||!e),title:E.title,onClick:T,children:[h?(0,Q.jsx)(v,{"aria-hidden":`true`,className:`h-4 w-4`}):m?(0,Q.jsx)(Ct,{className:l?`h-4 w-4 animate-pulse`:`h-4 w-4`}):(0,Q.jsx)($n,{className:`h-4 w-4`}),E.label]}),(0,Q.jsx)(rr,{phase:x})]})});function ar(e,t){for(let n=e.length-1;n>=0;--n){let r=e[n];if(!(r?.source!==`user`||t.has(r.id))&&(r.text?.trim()||r.attachments?.length))return r}return null}function or({sessionId:e,sessionRuntime:t,messages:n,queuedMessageIds:r,connected:i,hasPendingMessages:a,sendMessage:o,restartSession:s}){let c=t.phase===`error`?re(t):null,l=c?`${e??``}\n${c}`:null,[u,d]=(0,Z.useState)(null);l===null&&u!==null&&d(null);let f=(0,Z.useMemo)(()=>c?ar(n,r):null,[c,n,r]),p=(0,Z.useCallback)(()=>{f&&o(f.text??``,{preserveInput:!0,attachments:f.attachments??[]})},[f,o]),m=(0,Z.useCallback)(()=>d(l),[l]);return!c||l===u?null:{message:c,onRetry:f?p:void 0,retryDisabled:!i||a,onRestart:s,onDismiss:m}}function sr(e,t){let n=s.useUtils(),r=s.workspace.retryInit.useMutation({onSettled:()=>{l(n.workspace.getInitStatus.invalidate({id:e}),`Couldn't refresh data.`)},onError:e=>{c.error(e.message)}}),{mutate:i,isPending:a}=r;return{retry:(0,Z.useCallback)(()=>{t?.status!==`AVAILABLE`||a||i({id:e,useExistingBranch:Zt(e)||void 0})},[i,a,e,t]),retryInit:r}}var cr={error:`danger`,warning:`warning`,info:`info`};function lr(e){return m(cr[e]).surface}var ur=(0,Z.memo)(function({banner:e,retryPending:t,retryAvailability:n,onRetry:r,onPlay:i}){let a=e.showRetry||e.showPlay;return(0,Q.jsx)(`div`,{className:`px-4 pt-4`,children:(0,Q.jsxs)(`div`,{className:[`rounded-md border p-3 text-sm flex items-start gap-3`,lr(e.kind)].join(` `),children:[e.kind===`info`?(0,Q.jsx)(_,{className:`h-4 w-4 mt-0.5 shrink-0 animate-spin`}):(0,Q.jsx)(y,{className:`h-4 w-4 mt-0.5 shrink-0`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{children:e.message}),e.showRetry&&n?.status!==`AVAILABLE`&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs`,children:n?.status===`BLOCKED`?n.explanation:`Checking setup retry availability…`}),a&&(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[e.showRetry&&(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,disabled:t||n?.status!==`AVAILABLE`,onClick:r,children:[t?(0,Q.jsx)(v,{className:`h-3.5 w-3.5 mr-1.5`,"aria-hidden":`true`}):(0,Q.jsx)(et,{className:`h-3.5 w-3.5 mr-1.5`}),t?`Retrying…`:`Retry setup`]}),e.showPlay&&(0,Q.jsxs)(S,{size:`sm`,onClick:i,children:[(0,Q.jsx)(Ze,{className:`h-3.5 w-3.5 mr-1.5`}),`Dispatch queued messages`]})]})]})]})})});function dr(e,t){return e===`starting`||t}function fr({loadingSession:e,stopping:t,displayStartingState:n,running:r,promptInFlight:i,pendingRequestType:a,sessionPhase:o,sessionRuntime:s,messageCount:c}){return e?`Loading session…`:t?`Stopping…`:n&&!r?`Agent is starting…`:s.phase===`error`?`Couldn't continue this chat. Type a message to retry…`:a&&s.phase===`running`?x(a).composerPlaceholder:i?`Message will be queued…`:o===`ready`&&c===0?`Type a message to start the agent…`:`Type a message…`}function pr(e,t){return e&&!t&&e.kind!==`info`?e:null}function mr(e,t){return e?(0,Q.jsx)(ur,{banner:e,...t}):void 0}function hr(e,t){let{sessionId:n,parentSessionName:r,onOpenSubagent:i}=e,{subagents:a,subagentListState:o}=t,s=(0,Z.useCallback)(e=>{let t=a.find(t=>t.id===e);n&&t&&i?.({parentSessionId:n,parentSessionName:r?.trim()||`Untitled session`,subagent:t})},[n,r,i,a]),c=a.filter(e=>e.status===`running`),l=c.length===1?c[0]?.id:void 0,u=(0,Z.useCallback)(()=>{l&&s(l)},[s,l]),d=!!i,f=(0,Z.useMemo)(()=>d?(0,Q.jsx)(dt,{activeOnly:!0,state:o,onSelect:e=>s(e.id)}):void 0,[d,o,s]);return{onOpenSubagent:d?s:void 0,onOpenSingleSubagent:d&&l?u:void 0,runningSubagentList:f}}var gr=(0,Z.memo)(function(e){let t=e.autoStartPending??!1,{retry:n,retryInit:r}=sr(e.workspaceId,e.retryAvailability),i=ut(e.messages,e.sessionId,e.connected,e.sessionStatus.phase===`loading`),a=Oe(i.messages,{filterDuplicateResults:!0,groupBoundaries:e.transcriptPageBoundaries}),o=hr(e,i),s=(0,Z.useMemo)(()=>new Set(e.queuedMessages.map(e=>e.id)),[e.queuedMessages]),{sendMessage:c,transcriptScroll:l}=ke(e.sendMessage,e.transcriptScroll),u=(0,Z.useCallback)(()=>c(`/compact`,{preserveInput:!0}),[c]),d=e.sessionStatus.phase===`running`,f=e.sessionRuntime.work?.promptInFlight??d,p=e.sessionStatus.phase===`stopping`,m=dr(e.sessionStatus.phase,t),h=e.sessionStatus.phase===`loading`,g=e.chatCapabilities.rewind.enabled,_=e.pendingRequest.type===`permission`?e.pendingRequest.request.requestId:null,v=Me(e.pendingRequest,e.sessionRuntime),y=v===`plan_approval`;(0,Z.useEffect)(()=>{if(!(y&&_))return;let t=document.activeElement;t&&t!==document.body||e.inputRef?.current?.focus()},[y,_,e.inputRef]);let b=fr({loadingSession:h,stopping:p,displayStartingState:m,running:d,promptInFlight:f,pendingRequestType:v,sessionPhase:e.sessionStatus.phase,sessionRuntime:e.sessionRuntime,messageCount:e.messages.length}),x=or({sessionId:e.sessionId,sessionRuntime:e.sessionRuntime,messages:e.messages,queuedMessageIds:s,connected:e.connected,hasPendingMessages:e.pendingMessages.size>0,sendMessage:c,restartSession:e.restartSession}),S=pr(e.initBanner,e.isScriptFailed),{retryAvailability:C,resumeQueuedMessages:w}=e,T=(0,Z.useMemo)(()=>mr(S,{retryAvailability:C,retryPending:r.isPending,onRetry:n,onPlay:w}),[S,C,r.isPending,n,w]);return(0,Q.jsxs)(`div`,{className:`relative flex h-full flex-col overflow-hidden`,children:[(0,Q.jsx)(V,{contentClassName:`mx-auto w-full max-w-4xl`,onViewSetupOutput:e.onViewSetupOutput,sessionId:e.sessionId,thinkingInFooter:!0,pendingRequestType:e.sessionRuntime.phase===`running`?v:null,header:T,workspaceId:e.workspaceId,messages:a,pendingMessages:e.pendingMessages,history:e.history,subagentTimelineError:i.error,runningSubagentIconIndices:i.runningSubagentIconIndices,...o,acpPlan:e.acpPlan,running:d,work:e.sessionRuntime.work,controlSessionId:xt(e.sessionId,e.connected&&e.controlsHydrated===!0,e.sessionRuntime),startingSession:m,loadingSession:h,latestThinking:e.latestThinking??null,scroll:l,queuedMessageIds:s,onRemoveQueuedMessage:e.removeQueuedMessage,onSteerQueuedMessage:e.connected&&f&&!p&&!e.isCompacting?e.steerQueuedMessage:void 0,isCompacting:e.isCompacting,getUuidForMessageId:e.getUuidForMessageId,onRewindToMessage:g?e.startRewindPreview:void 0,resolveWorkspaceFileLink:e.resolveWorkspaceFileLink,onWorkspaceFileLink:e.onWorkspaceFileLink,initBanner:e.initBanner}),(0,Q.jsxs)(`div`,{className:`z-20 flex max-h-full min-h-0 flex-col border-t bg-background pb-safe`,children:[x&&(0,Q.jsx)(de,{className:`shrink-0`,...x}),(0,Q.jsx)(je,{permission:e.pendingRequest.type===`permission`?e.pendingRequest.request:null,onApprove:e.approvePermission,className:`min-h-0 shrink overflow-y-auto`}),(0,Q.jsx)(`div`,{className:`min-h-0 shrink overflow-y-auto`,children:(0,Q.jsx)(Ee,{question:e.pendingRequest.type===`question`?e.pendingRequest.request:null,onAnswer:e.answerQuestion})}),(0,Q.jsx)(`div`,{className:`flex min-h-0 shrink items-stretch gap-2`,children:(0,Q.jsx)(be,{leadingControls:(0,Q.jsx)(ir,{sessionId:e.sessionId,onFinalTranscript:c,running:d,disabled:!e.connected||h}),className:`mx-auto w-full max-w-4xl flex-1 min-w-0`,onSend:c,onCompact:u,onStop:e.stopChat,disabled:!e.connected||h,running:d,promptInFlight:f,stopping:p,isCompacting:e.isCompacting,inputRef:e.inputRef,placeholder:b,settings:e.chatSettings,capabilities:e.chatCapabilities,capabilitiesLoaded:e.chatCapabilitiesLoaded,onSettingsChange:e.updateSettings,value:e.inputDraft,onChange:e.setInputDraft,attachments:e.inputAttachments,onAttachmentsChange:e.setInputAttachments,pendingMessageCount:e.pendingMessages.size,slashCommands:e.slashCommands,slashCommandsLoaded:e.slashCommandsLoaded,tokenStats:e.tokenStats,workspaceId:e.workspaceId,codexAccountId:e.codexAccountId,acpConfigOptions:e.acpConfigOptions,onSetConfigOption:e.setConfigOption,onRunQuickActionInNewChat:e.onRunQuickActionInNewChat,newChatUnavailableReason:e.newChatUnavailableReason})})]}),(0,Q.jsx)(Se,{rewindPreview:e.rewindPreview,onConfirm:e.confirmRewind,onCancel:e.cancelRewind})]})}),_r=(0,Z.createContext)(null),vr=_r.Provider;function yr(){let e=(0,Z.useContext)(_r);if(!e)throw Error(`ConnectedChatContent must be rendered inside ChatContentPropsProvider`);return(0,Q.jsx)(vn,{...e,children:(0,Q.jsx)(gr,{...e})})}var br=(0,Q.jsx)(yr,{});function xr(e){return!!e}function Sr(e,t){return!e||e.showDismiss===!0&&t!==!1?null:e}function Cr(e){let{workspaceSummaries:t,sessions:n,selectedSessionId:r,liveRuntime:i,chatConnected:a}=e,o=new Map((t??[]).map(e=>[e.sessionId,e]));if(!(r&&a&&e.runtimeSessionId===r))return o;let s=n?.find(e=>e.id===r);if(!s)return o;let c=o.get(r);return o.set(r,{sessionId:r,name:c?.name??s.name??null,workflow:c?.workflow??s.workflow??null,model:c?.model??s.model??null,provider:c?.provider??s.provider,persistedStatus:c?.persistedStatus??s.status,pendingRequestType:e.livePendingRequestType===void 0?c?.pendingRequestType??null:e.livePendingRequestType,runtimePhase:i.phase,processState:i.processState,activity:i.activity,updatedAt:i.updatedAt,lastExit:i.lastExit??c?.lastExit??null,errorMessage:i.errorMessage??c?.errorMessage??null}),o}function wr(e){let t=!1;for(let n of e){if(n.source===`agent`)return!1;n.source===`user`&&(t=!0)}return t}var Tr=new Map([[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M232.07,186.76a80,80,0,0,0-62.5-114.17A80,80,0,1,0,23.93,138.76l-7.27,24.71a16,16,0,0,0,19.87,19.87l24.71-7.27a80.39,80.39,0,0,0,25.18,7.35,80,80,0,0,0,108.34,40.65l24.71,7.27a16,16,0,0,0,19.87-19.86ZM62,159.5a8.28,8.28,0,0,0-2.26.32L32,168l8.17-27.76a8,8,0,0,0-.63-6,64,64,0,1,1,26.26,26.26A8,8,0,0,0,62,159.5Zm153.79,28.73L224,216l-27.76-8.17a8,8,0,0,0-6,.63,64.05,64.05,0,0,1-85.87-24.88A79.93,79.93,0,0,0,174.7,89.71a64,64,0,0,1,41.75,92.48A8,8,0,0,0,215.82,188.23Z`}))]]),Er=Z.forwardRef((e,t)=>Z.createElement(u,{ref:t,...e,weights:Tr}));Er.displayName=`ChatsCircleIcon`;var Dr=ve.transform((e,t)=>Array.isArray(e.messages)?{...e,messages:e.messages}:(t.issues.push({code:`custom`,message:`Expected a messages JSON array`,path:[`messages`],input:e.messages}),D));function Or(e){let t=JSON.parse(N().parse(e));return Dr.parse(t)}function $(e){if(e===void 0)throw Error(`Missing archive grouping trace value`);return e}function kr(e){let t=e.message?.message?.content,n=e.message?.event;return[...Array.isArray(t)?t.filter(ye):[],...n?.type===`content_block_start`&&ye(n.content_block)?[n.content_block]:[],...n?.type===`message_start`&&Array.isArray(n.message.content)?n.message.content.filter(ye):[]]}function Ar(e){let t=e.map(()=>[]),n=new Map,r=[],i=(e,n)=>$(t[$(e)]).push(n),a=()=>{if(r.length===0)return;let t=new Map,a=new Map,o=new Map,s=_e(r,{onToolCall:(e,n)=>t.set(n,e),onToolResult:(e,t)=>{let n=o.get(e)??new Set;n.add(t),o.set(e,n)},onToolSequence:(e,t)=>a.set(e,t)}),c=new Set,l=new Map,u=0;for(let e of r)l.set(e,u),kr(e).some(t=>!o.get(e)?.has(t))&&(c.add(e),u+=1);let d=e=>{let r=$(a.get(e)),o=$(r[0]),s=$(r.at(-1));if(l.get(o)===l.get(s)&&!c.has(s)){i(n.get(o),{kind:`rich`,value:e});return}let u,d;for(let r of e.pairedCalls){let a=$(t.get(r)),o=$(l.get(a));if(!u||d!==o){let t=$(n.get(a));u={type:`tool_sequence`,id:`${e.id}:archive:${t}`,pairedCalls:[]},i(t,{kind:`rich`,value:u}),d=o}u.pairedCalls.push(r)}};for(let e of s)fe(e)?d(e):i(n.get(e),{kind:`rich`,value:e});for(let t of c){let r=$(n.get(t));i(r,{kind:`fallback`,value:$(e[r]),sourceIndex:r})}r=[]};return e.forEach((e,t)=>{let o=ge.safeParse(e);o.success?(n.set(o.data,t),r.push(o.data)):(a(),i(t,{kind:`fallback`,value:e,sourceIndex:t}))}),a(),pt(t.flat(),e=>e.kind===`rich`?e.value.id:`fallback-${e.sourceIndex}`)}function jr({sessionId:e}){let t=(0,Z.useRef)(null),{data:n,isLoading:r,error:i,isFetching:a,refetch:o}=s.closedSessions.getTranscriptJson.useQuery({id:e},{select:Or,structuralSharing:!1});if((0,Z.useEffect)(()=>{if(n&&t.current){let e=t.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[n]),r)return(0,Q.jsx)(E,{message:`Loading transcript…`});if(i&&i.data?.code!==`NOT_FOUND`&&!n)return(0,Q.jsx)(Fe,{title:`Couldn't load transcript`,error:i,onRetry:()=>{o()},isRetrying:a,className:`h-full`});if(!n||i?.data?.code===`NOT_FOUND`)return(0,Q.jsx)(Be,{icon:Er,title:`Transcript not found`,description:`This session's history is no longer available.`,className:`h-full`});let c=i?(0,Q.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`shrink-0 border-b p-3 text-sm`,children:`Latest transcript read failed. Showing previously loaded history.`}):null;if(n.messages.length===0)return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[c,(0,Q.jsx)(Be,{icon:Er,title:`No messages in this session`,className:`min-h-0 flex-1`})]});let l=Ar(n.messages),u=(0,Q.jsx)(Pe,{ref:t,className:`min-h-0 flex-1`,children:(0,Q.jsx)(`div`,{className:`p-4 space-y-4`,children:l.map(({item:e,key:t})=>e.kind===`rich`?(0,Q.jsx)(we,{item:e.value},t):(0,Q.jsxs)(`section`,{"aria-label":`Archived message JSON`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Archived message JSON`}),(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-sm`,children:JSON.stringify(e.value,null,2)})]},t))})});return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[c,u]})}function Mr({workspaceId:e,screenshotPath:t}){let{data:n,isLoading:r,error:i,isFetching:a,refetch:o}=s.workspace.readScreenshot.useQuery({workspaceId:e,path:t},{staleTime:6e4});return r?(0,Q.jsx)(E,{message:`Loading screenshot…`}):n?(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full p-4 overflow-auto`,children:(0,Q.jsx)(`img`,{src:`data:${n.mimeType};base64,${n.data}`,alt:n.name,className:`max-w-full max-h-full object-contain rounded-md`})}):(0,Q.jsx)(Fe,{title:`Couldn't load screenshot`,error:i,onRetry:()=>{o()},isRetrying:a,className:`h-full`})}var Nr=(0,Z.lazy)(()=>se(()=>import(`./diff-viewer-DNUPJg_G.js`).then(e=>({default:e.DiffViewer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67]))),Pr=(0,Z.lazy)(()=>se(()=>import(`./file-viewer-CbXNMHbC.js`).then(e=>({default:e.FileViewer})),__vite__mapDeps([68,1,2,3,4,19,5,6,29,7,8,9,10,11,12,13,34,14,15,16,17,18,20,21,22,23,24,25,26,27,28,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,69])));function Fr({workspaceId:e,children:t,className:n}){let{tabs:r,activeTabId:i}=te(),a=r.find(e=>e.id===i),o=!a||a.type===`chat`,s=a?.type===`file`?a.path:void 0,c=a?.type===`diff`?a.path:void 0,l=a?.type===`screenshot`?a.path:void 0,u=a?.type===`closed-session`?a.closedSessionId:void 0,f=a?.type===`subagent`?a.subagentSelection:void 0,p=a?.id,m=qe({workspaceId:e,tabId:a?.type===`subagent`?a.id:null});return(0,Q.jsxs)(`div`,{className:d(`h-full`,n),children:[(0,Q.jsx)(`div`,{className:d(`h-full`,!o&&`hidden`),children:t}),(0,Q.jsx)(C,{variant:`compact`,title:`Couldn't load the viewer`,children:(0,Q.jsxs)(Z.Suspense,{fallback:(0,Q.jsx)(E,{size:`compact`,message:`Loading viewer…`}),children:[s&&p&&(0,Q.jsx)(Pr,{workspaceId:e,filePath:s,tabId:p},p),c&&p&&(0,Q.jsx)(Nr,{workspaceId:e,filePath:c,tabId:p},p)]})},`viewer-${p}`),l&&p&&(0,Q.jsx)(Mr,{workspaceId:e,screenshotPath:l,tabId:p}),u&&(0,Q.jsx)(jr,{sessionId:u}),f&&p&&(0,Q.jsx)(ct,{workspaceId:e,selection:f,scroll:{ready:m.ready,initialPosition:m.initialPosition,onPositionChange:m.onPositionChange}},p)]})}var Ir=new Map([[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M112,152a8,8,0,0,0-8,8v28.69L66.34,151A8,8,0,0,1,64,145.37V95a32,32,0,1,0-16,0v50.38a23.85,23.85,0,0,0,7,17L92.69,200H64a8,8,0,0,0,0,16h48a8,8,0,0,0,8-8V160A8,8,0,0,0,112,152ZM40,64A16,16,0,1,1,56,80,16,16,0,0,1,40,64Zm168,97V110.63a23.85,23.85,0,0,0-7-17L163.31,56H192a8,8,0,0,0,0-16H144a8,8,0,0,0-8,8V96a8,8,0,0,0,16,0V67.31L189.66,105a8,8,0,0,1,2.34,5.66V161a32,32,0,1,0,16,0Zm-8,47a16,16,0,1,1,16-16A16,16,0,0,1,200,208Z`}))]]),Lr=Z.forwardRef((e,t)=>Z.createElement(u,{ref:t,...e,weights:Ir}));Lr.displayName=`GitDiffIcon`;var Rr=new Map([[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM128,72a12,12,0,1,0-12-12A12,12,0,0,0,128,72Zm0,112a12,12,0,1,0,12,12A12,12,0,0,0,128,184Z`}))]]),zr=Z.forwardRef((e,t)=>Z.createElement(u,{ref:t,...e,weights:Rr}));zr.displayName=`DotsThreeVerticalIcon`;function Br({chatLabel:e,onRestartSession:t,disabled:n=!1,onRename:r}){let i=(0,Z.useRef)(!1);return(0,Q.jsxs)(Ke,{children:[(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(Je,{asChild:!0,children:(0,Q.jsx)(S,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":`Chat actions`,children:(0,Q.jsx)(zr,{className:`h-4 w-4`})})})}),(0,Q.jsx)(R,{side:`bottom`,children:`Chat actions`})]}),(0,Q.jsxs)(He,{align:`end`,className:`w-64`,onCloseAutoFocus:e=>{i.current&&(i.current=!1,e.preventDefault(),r?.())},children:[(0,Q.jsx)(Ye,{className:`truncate`,children:e??`No chat selected`}),r&&(0,Q.jsxs)(Ne,{disabled:n||e===null,onSelect:()=>{i.current=!0},children:[(0,Q.jsx)(ze,{className:`h-4 w-4`}),` Rename chat`]}),(0,Q.jsxs)(Ne,{disabled:n||e===null,onSelect:t,className:`items-start`,children:[(0,Q.jsx)(et,{className:`mt-0.5 h-4 w-4`}),(0,Q.jsxs)(`span`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{children:`Restart agent`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Stop and restart the agent, resuming from where it left off`})]})]})]})]})}function Vr({workspaceId:e,onSelectClosedSession:t,disabled:n}){let[r,i]=(0,Z.useState)(!1),{data:a,isLoading:o}=s.closedSessions.list.useQuery({workspaceId:e,limit:20}),c=a&&a.length>0;return o||c?(0,Q.jsxs)(Ke,{open:r,onOpenChange:i,children:[(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(Je,{asChild:!0,children:(0,Q.jsxs)(S,{variant:`ghost`,size:`sm`,disabled:n,className:d(`h-7 px-2 text-xs gap-1.5`,`text-muted-foreground hover:text-foreground`,`border border-input bg-background hover:bg-sidebar-accent`),children:[(0,Q.jsx)(Re,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{children:`Closed`})]})})}),(0,Q.jsx)(R,{children:`View closed session history`})]}),(0,Q.jsxs)(He,{align:`start`,className:`w-80`,children:[(0,Q.jsx)(Ye,{children:`Closed Sessions`}),(0,Q.jsx)(G,{}),o&&(0,Q.jsx)(E,{size:`compact`,message:`Loading closed sessions…`}),!(o||c)&&(0,Q.jsx)(`div`,{className:`py-6 px-2 text-center text-sm text-muted-foreground`,children:`No closed sessions yet. Ratchet sessions will appear here after they complete.`}),!o&&c&&(0,Q.jsx)(Pe,{className:`max-h-96`,children:a.map(e=>(0,Q.jsxs)(Ne,{onClick:()=>{t(e.id),i(!1)},className:`flex items-start gap-2 px-3 py-2 cursor-pointer`,children:[e.workflow===`periodic-task`?(0,Q.jsx)(Qe,{"aria-label":`Agent session`,className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}):(0,Q.jsx)(st,{className:`h-4 w-4 shrink-0 mt-0.5 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium truncate`,children:W(e,`${e.workflow} session`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(h,{className:`h-3 w-3 shrink-0`}),(0,Q.jsx)(`span`,{children:Rt(new Date(e.completedAt),{addSuffix:!0})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`capitalize`,children:e.provider.toLowerCase()}),(0,Q.jsx)(`span`,{children:`•`}),(0,Q.jsx)(`span`,{children:e.model})]})]})]},e.id))})]})]}):null}function Hr(e,t){if(!e)return t===`RUNNING`;let n=ie(e);return n===`working`||n===`starting`||n===`awaiting-input`}function Ur({summary:e,persistedStatus:t,queuedMessageCount:n=0}){let r=Hr(e,t);return!r&&n<=0?null:{running:r,...e&&ie(e)===`awaiting-input`?{awaitingInput:!0}:{},queuedMessageCount:Math.max(0,n)}}function Wr(e){return`${e} queued message${e===1?``:`s`}`}function Gr(e,t){let n=t.queuedMessageCount>0?`its transcript moves to Closed sessions. You can read it there; discarded queued messages cannot be recovered.`:`its transcript moves to Closed sessions. You can read it there.`,r=Wr(t.queuedMessageCount),i=t.awaitingInput?`is waiting for your input`:`is still working`;return t.running&&t.queuedMessageCount>0?{title:`Stop and close ${e}?`,description:`${e} ${i} and has ${r}. Closing the tab stops the agent, discards the queued messages, and ${n}`,confirmText:`Stop and close`}:t.running?{title:`Stop and close ${e}?`,description:`${e} ${i}. Closing the tab stops the agent and ${n}`,confirmText:`Stop and close`}:{title:`Discard and close ${e}?`,description:`${e} has ${r} that ${t.queuedMessageCount===1?`has`:`have`} not been sent. Closing the tab discards ${t.queuedMessageCount===1?`it`:`them`} and ${n}`,confirmText:`Discard and close`}}function Kr({sessionId:e,workspaceId:t,name:n,onDone:r}){let i=(0,Z.useRef)(null),a=(0,Z.useRef)(!1);(0,Z.useLayoutEffect)(()=>(a.current=!0,i.current?.focus(),i.current?.select(),()=>{a.current=!1}),[]);let[o,c]=(0,Z.useState)(n),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),p=(0,Z.useRef)(!1),m=(0,Z.useRef)(!1),h=s.useUtils(),g=s.session.updateSession.useMutation({meta:{errorToast:!1}}),_=e=>{a.current&&e()},v=async()=>{if(p.current||m.current)return;let i=o.trim();if(!i||i===n)r();else{p.current=!0,f(!0),u(!1);try{await g.mutateAsync({id:e,name:i}),await h.session.listSessions.invalidate({workspaceId:t}),_(r)}catch{_(()=>u(!0))}finally{p.current=!1,_(()=>f(!1))}}};return(0,Q.jsxs)(ot,{open:l,children:[(0,Q.jsx)(at,{asChild:!0,children:(0,Q.jsx)(`div`,{className:`relative shrink-0 p-1`,children:(0,Q.jsx)(ce,{"aria-label":`Chat name`,value:o,readOnly:d,"aria-busy":d,"aria-invalid":l,ref:i,onChange:e=>c(e.target.value),onBlur:()=>{l||v()},onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),v()):e.key===`Escape`&&!e.nativeEvent.isComposing&&!d&&(e.preventDefault(),m.current=!0,r())},className:`h-7 w-40 text-sm`})})}),(0,Q.jsx)(K,{role:`alert`,"aria-label":`Chat rename error`,side:`bottom`,align:`end`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),className:`p-2 text-xs text-destructive`,children:`Couldn't rename chat. Press Enter to retry or Escape to cancel.`})]})}var qr={color:`text-muted-foreground`,pulse:!1,spin:!1,label:`Idle`,description:`Ready for input`,icon:le,isRunning:!1};function Jr(e){return e===`RUNNING`?{color:`text-running`,pulse:!0,spin:!1,label:`Running`,description:`Processing your request`,icon:p,isRunning:!0}:e===`PAUSED`?{color:`text-muted-foreground`,pulse:!1,spin:!1,label:`Paused`,description:`Session paused`,icon:J,isRunning:!1}:e===`COMPLETED`?{color:`text-success`,pulse:!1,spin:!1,label:`Completed`,description:`Session finished`,icon:f,isRunning:!1}:e===`FAILED`?{color:`text-destructive`,pulse:!1,spin:!1,label:`Failed`,description:`Session failed`,icon:g,isRunning:!1}:qr}function Yr(e,t){if(!e)return Jr(t);switch(ie(e)){case`loading`:return{color:`text-muted-foreground`,pulse:!1,spin:!0,label:`Loading`,description:`Loading session…`,icon:_,isRunning:!1};case`starting`:return{color:`text-muted-foreground`,pulse:!1,spin:!0,label:`Starting`,description:`Launching agent…`,icon:_,isRunning:!1};case`stopping`:return{color:`text-running`,pulse:!1,spin:!0,label:`Stopping`,description:`Finishing current request…`,icon:_,isRunning:!1};case`error`:return{color:`text-destructive`,pulse:!1,spin:!1,label:`Error`,description:ae(e)??`Session entered an error state`,icon:g,isRunning:!1};case`unexpected-exit`:return{color:`text-destructive`,pulse:!1,spin:!1,label:`Error`,description:ae(e)??`Exited unexpectedly${e.lastExit?.code==null?``:` (code ${e.lastExit.code})`}`,icon:g,isRunning:!1};case`stopped`:return{color:`text-muted-foreground`,pulse:!1,spin:!1,label:`Stopped`,description:`Send a message to start`,icon:J,isRunning:!1};case`awaiting-input`:{let t=x(e.pendingRequestType??`permission_request`);return{color:m(`attention`).text,pulse:!1,spin:!1,label:t.label,description:t.description,icon:t.icon,isRunning:!1,awaitingInput:!0}}case`working`:return{color:`text-running`,pulse:!0,spin:!1,label:`Running`,description:`Processing your request`,icon:p,isRunning:!0};case`idle`:return qr}}function Xr(e){switch(e){case`chat`:case`file`:return F;case`diff`:return Lr;case`screenshot`:return he;case`closed-session`:return Re;case`subagent`:return Qe}}function Zr(e,t){let n=e?.findIndex(e=>e.id===t)??-1,r=e?.[n];return r?W(r,`Chat ${n+1}`):null}function Qr({sessionSummary:e,isCIFix:t,isAgent:n,persistedStatus:r}){let i=Yr(e,r),a=i.icon;return t&&!i.awaitingInput?(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`flex items-center justify-center`,children:(0,Q.jsx)(Ue,{enabled:!0,animated:i.isRunning,className:`h-3.5 w-3.5 rounded-[4px] shrink-0`,iconClassName:d(i.isRunning&&`animate-pulse text-running`,!i.isRunning&&`text-warning`)})})}),(0,Q.jsxs)(R,{side:`bottom`,className:`text-xs`,children:[(0,Q.jsxs)(`div`,{className:`font-medium`,children:[`CI Fix: `,i.label]}),(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:i.description})]})]}):(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`flex items-center justify-center`,children:n?(0,Q.jsx)(xe,{label:i.label,icon:a,color:i.color,pulse:i.pulse,spin:i.spin}):(0,Q.jsx)(a,{role:`img`,"aria-label":i.label,className:d(`h-3.5 w-3.5 shrink-0`,i.color,i.pulse&&`animate-pulse`,i.spin&&`animate-spin`)})})}),(0,Q.jsxs)(R,{side:`bottom`,className:`text-xs`,children:[(0,Q.jsx)(`div`,{className:`font-medium`,children:i.label}),(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:i.description})]})]})}function $r({tab:e,isActive:t,tabStop:n,onSelect:r,onClose:i}){let a=Xr(e.type);return(0,Q.jsx)(Tt,{icon:(0,Q.jsx)(a,{className:`h-3.5 w-3.5 shrink-0`}),label:e.label,isActive:t,tabStop:n,onSelect:r,onClose:i,truncate:!0})}function ei({selection:e,label:t,isActive:n,tabStop:r,onSelect:i,onClose:a,onRefresh:o}){let{selection:s,iconIndex:c}=q(e),{parentSessionId:l,parentSessionName:u,subagent:f}=s;return(0,Z.useEffect)(()=>{f!==e.subagent&&o({parentSessionId:l,parentSessionName:u,subagent:f})},[l,u,f,o,e.subagent]),(0,Q.jsx)(Tt,{icon:(0,Q.jsx)(`span`,{role:`img`,"aria-label":`${f.status} subagent`,className:d(`inline-flex shrink-0`,(f.status===`starting`||f.status===`running`)&&`animate-pulse motion-reduce:animate-none`),children:(0,Q.jsx)(pe,{index:c,className:`h-3.5 w-3.5`})}),label:t,isActive:n,tabStop:r,onSelect:i,onClose:a,truncate:!0})}function ti({label:e,isActive:t,tabStop:n,sessionSummary:r,isCIFix:i,isAgent:a,persistedStatus:o,onSelect:s,onClose:c}){return(0,Q.jsx)(Tt,{icon:(0,Q.jsx)(Qr,{sessionSummary:r,isCIFix:i,isAgent:a,persistedStatus:o}),label:e,isActive:t,tabStop:n,onSelect:s,onClose:c,truncate:!0})}function ni({className:e,workspaceId:t,sessions:n,currentSessionId:r,queuedMessageCount:i,sessionSummariesById:a,onSelectSession:o,onCreateSession:s,onCloseSession:c,onSelectClosedSession:l,onRestartSession:u,disabled:f,maxSessions:p}){let m=Ae(),{tabs:h,activeTabId:g,selectTab:_,closeTab:v,updateSubagentTab:y}=te(),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),E=(e,t)=>{let n=Ur({summary:a?.get(e.id),persistedStatus:e.status,queuedMessageCount:i?.sessionId===e.id?i.count:0});n?(x({sessionId:e.id,label:t,risk:n}),C(!0)):c?.(e.id)},D=b?Gr(b.label,b.risk):null,O=h.filter(e=>e.type!==`chat`),k=O.some(e=>e.id===g),A=!!n?.some(e=>e.id===r),j=e=>{o?.(e),_(`chat`)},M=e=>{if(!n||n.length<2)return!1;let t=n.findIndex(e=>e.id===r),i=n[t<0?e===1?0:n.length-1:(t+e+n.length)%n.length];return i?(j(i.id),!0):!1},N=!f&&(n?.length??0)>1;Ge(`chat.next`,()=>M(1),N),Ge(`chat.previous`,()=>M(-1),N);let P=Ie(n,p),F=f||P||n===void 0,ee=Zr(n,r);return(0,Q.jsxs)(`div`,{ref:m,className:d(`flex items-center bg-shell`,e),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto p-1`,style:{scrollbarWidth:`none`,msOverflowStyle:`none`},children:[n&&n.length>0&&(0,Q.jsx)(`div`,{role:`tablist`,"aria-label":`Chats`,onKeyDown:Te,className:`flex shrink-0 items-center gap-0.5`,children:n.map((e,t)=>{let i=e.id===r,o=W(e,`Chat ${t+1}`);return(0,Q.jsx)(ti,{label:o,isActive:i&&g===`chat`,tabStop:i||!A&&t===0,sessionSummary:a?.get(e.id),isCIFix:e.workflow===`ci-fix`,isAgent:e.workflow===`periodic-task`,persistedStatus:e.status,onSelect:()=>j(e.id),onClose:n.length>1?()=>E(e,o):void 0},e.id)})}),l&&(0,Q.jsx)(`div`,{className:`ml-0.5 shrink-0`,children:(0,Q.jsx)(Vr,{workspaceId:t,onSelectClosedSession:l,disabled:f})}),O.length>0&&(0,Q.jsx)(`div`,{className:`h-4 w-px shrink-0 bg-border mx-1`}),O.length>0&&(0,Q.jsx)(`div`,{role:`tablist`,"aria-label":`Open tabs`,onKeyDown:Te,className:`flex shrink-0 items-center gap-0.5`,children:O.map((e,t)=>{let n=e.id===g,r=n||!k&&t===0;return e.type===`subagent`&&e.subagentSelection?(0,Q.jsx)(ei,{selection:e.subagentSelection,label:e.label,isActive:n,tabStop:r,onSelect:()=>_(e.id),onClose:()=>v(e.id),onRefresh:y},e.id):(0,Q.jsx)($r,{tab:e,isActive:n,tabStop:r,onSelect:()=>_(e.id),onClose:()=>v(e.id)},e.id)})})]}),n?.filter(e=>e.id===w).map(e=>(0,Q.jsx)(Kr,{sessionId:e.id,workspaceId:t,name:W(e,`Chat ${n.indexOf(e)+1}`),onDone:()=>T(t=>t===e.id?null:t)},e.id)),s&&(0,Q.jsx)(`div`,{className:`mx-1 flex shrink-0 items-center py-1`,children:(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(`span`,{children:(0,Q.jsx)(it,{provider:n?.[0]?.provider,onCreate:s,disabled:F})})}),(0,Q.jsx)(R,{children:P?`Maximum ${p} sessions per workspace`:`New session`})]})}),u&&(0,Q.jsx)(`div`,{className:`shrink-0 pr-1`,children:(0,Q.jsx)(Br,{chatLabel:ee,onRename:()=>T(r??null),onRestartSession:u,disabled:f})}),(0,Q.jsx)(Xe,{open:S,onOpenChange:C,title:D?.title??``,description:D?.description??``,confirmText:D?.confirmText,variant:`destructive`,onConfirm:()=>{C(!1),b&&c?.(b.sessionId)}})]})}var ri=(0,Z.memo)(function({workspaceId:e,sessions:t,selectedSessionId:n,sessionSummariesById:r,queuedMessageCount:i,isCreatingSession:a,isDeletingSession:o,onSelectSession:s,onCreateSession:c,onCloseSession:l,onRestartSession:u,children:d,emptyState:f,maxSessions:p,hasWorktreePath:m}){let h=t&&t.length===0,{openTab:g}=te();return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full min-h-0`,children:[(0,Q.jsx)(`div`,{className:`border-b flex-shrink-0`,children:(0,Q.jsx)(ni,{workspaceId:e,sessions:t,currentSessionId:n,queuedMessageCount:i,sessionSummariesById:r,onSelectSession:s,onCreateSession:c,onCloseSession:l,onRestartSession:u,onSelectClosedSession:e=>{g(`closed-session`,e,`History`)},disabled:a||o||!m,maxSessions:p})}),h&&f,(0,Q.jsx)(Fr,{workspaceId:e,className:`flex-1 min-h-0`,children:h?f?null:(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-8`,children:(0,Q.jsxs)(`div`,{className:`max-w-md w-full space-y-6 text-center`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`h2`,{className:`text-2xl font-semibold`,children:`Start a session`}),(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`Click the + button above to start a new chat session in this workspace.`})]}),!m&&(0,Q.jsx)(`div`,{className:[`border px-4 py-3 rounded-md text-sm`,lr(`warning`)].join(` `),children:`Workspace is initializing… Please wait for the worktree to be created.`})]})}):d})]})});function ii({workspaceId:e,banner:t,errorMessage:n,retryAvailability:r}){let{retry:i,retryInit:a}=sr(e,r);return(0,Q.jsx)(ur,{banner:{kind:`error`,message:t?.message??n??`Workspace setup failed`,showRetry:!0,showPlay:!1,showDismiss:!1},retryAvailability:r,retryPending:a.isPending,onRetry:i,onPlay:()=>void 0})}function ai({output:e,className:t,emptyMessage:n=`Waiting for output…`}){let r=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{r.current&&e!==null&&(r.current.scrollTop=r.current.scrollHeight)},[e]),(0,Q.jsx)(Pe,{viewportRef:r,className:t,children:(0,Q.jsx)(`pre`,{className:`p-2 text-xs font-mono text-foreground whitespace-pre-wrap break-words`,children:e||(0,Q.jsx)(`span`,{className:`text-foreground italic`,children:n})})})}function oi({workspaceId:e,retryAvailability:t,initErrorMessage:n,initOutput:r,hasStartupScript:i,showPlay:a=!1,onPlay:o,showDismiss:s=!1,onDismiss:c}){let[l,u]=(0,Z.useState)(!1),{retry:d,retryInit:f}=sr(e,t);return(0,Q.jsxs)(`div`,{className:`border-b bg-destructive/10 px-4 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2 text-sm text-destructive`,children:[(0,Q.jsx)(y,{className:`mt-0.5 h-3 w-3 shrink-0`}),(0,Q.jsxs)(`span`,{className:`min-w-0 break-words whitespace-normal`,children:[`Init script failed`,n?`: ${n}`:``,t?.status!==`AVAILABLE`&&(0,Q.jsx)(`span`,{className:`mt-1 block text-xs`,children:t?.status===`BLOCKED`?t.explanation:`Checking setup retry availability…`})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1 self-start sm:justify-end`,children:[i&&r&&(0,Q.jsxs)(S,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>u(!l),children:[l?(0,Q.jsx)(b,{className:`h-3 w-3 mr-1`}):(0,Q.jsx)($e,{className:`h-3 w-3 mr-1`}),l?`Hide output`:`Show output`]}),(0,Q.jsx)(S,{variant:`outline`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:d,disabled:f.isPending||t?.status!==`AVAILABLE`,children:f.isPending?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v,{"aria-hidden":`true`,className:`h-3 w-3 mr-1`}),`Retrying…`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(et,{className:`h-3 w-3 mr-1`}),`Retry`]})}),a&&(0,Q.jsxs)(S,{variant:`outline`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:o,disabled:!o,children:[(0,Q.jsx)(Ze,{className:`h-3 w-3 mr-1`}),`Dispatch queued messages`]}),s&&(0,Q.jsx)(S,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:c,"aria-label":`Dismiss`,children:(0,Q.jsx)(oe,{className:`h-3 w-3`})})]})]}),l&&i&&(0,Q.jsx)(ai,{output:r,className:`mt-2 h-32 w-full rounded-md border bg-background`})]})}function si(){return(0,Q.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-md`,children:(0,Q.jsxs)(`div`,{role:`status`,className:`flex items-center gap-3 p-8`,children:[(0,Q.jsx)(v,{"aria-hidden":`true`,className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Archiving…`})]})})}function ci(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function li({visible:e,children:t}){let[n,r]=(0,Z.useState)(e),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(e),[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null);if(e!==o){s(e);let t=!ci();a(t?e?`opening`:`closing`:null),r(e||t)}return(0,Z.useEffect)(()=>{if(!i){l(null);return}let e=requestAnimationFrame(()=>{let e=d.current?.parentElement,t=u.current;e&&t&&l(Math.round(e.offsetWidth*t.getSize().asPercentage/100))}),t=setTimeout(()=>{i===`closing`&&r(!1),a(null)},150);return()=>{cancelAnimationFrame(e),clearTimeout(t)}},[i]),n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Dt,{}),(0,Q.jsx)(kt,{id:`workspace-side`,defaultSize:`30%`,minSize:`15%`,maxSize:`50%`,panelRef:u,elementRef:d,"data-side-panel-motion":i??void 0,style:c?{minWidth:c}:void 0,children:(0,Q.jsx)(`div`,{className:`h-full border-l`,children:t})})]}):null}var ui=`Take a screenshot of the workspace dev app using Playwright MCP tools. Read factory-factory.json for the scripts.run command, pick a free port, replace {port}, and start the dev server in the background. Once ready, determine the most relevant screen and save a screenshot to .factory-factory/screenshots/ with a descriptive filename.`;function di({workspaceId:e,isScriptFailed:t,workspaceInitStatus:n,setupWarningDismissed:r,dismissSetupWarning:i,resumeQueuedMessages:a}){let o=Sr(n?.chatBanner,r);return t&&o?(0,Q.jsx)(oi,{retryAvailability:n?.retryAvailability,workspaceId:e,initErrorMessage:n?.initErrorMessage??null,initOutput:n?.initOutput??null,hasStartupScript:n?.hasStartupScript??!1,showPlay:o.showPlay,onPlay:a,showDismiss:o.showDismiss,onDismiss:i}):null}var fi=(0,Z.memo)(function({workspaceState:e,header:t,sessionTabs:n,resumeQueuedMessages:r,rightPanelVisible:i,setRightPanelVisible:a,archiveDialog:o}){let s=ue(),[c,l]=(0,Z.useState)(!1),u=n.sessions?.findIndex(e=>e.id===n.selectedDbSessionId)??-1,d=u>=0?n.sessions?.[u]:void 0,f=d?d.name?.trim()||`Session ${u+1}`:null,p=(0,Z.useCallback)(async()=>{l(!0);try{await t.handleQuickAction(`Take Screenshots`,ui)}catch{}finally{l(!1)}},[t.handleQuickAction]),m=(0,Z.useCallback)(e=>{f&&n.selectedDbSessionId&&e.parentSessionId===n.selectedDbSessionId&&(n.handleOpenSubagentTab({...e,parentSessionName:f}),s&&a(!1))},[s,f,a,n.handleOpenSubagentTab,n.selectedDbSessionId]);if(e.workspaceLoading)return(0,Q.jsx)(E,{message:`Loading workspace…`});if(!e.workspace)return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-destructive`,children:`Workspace not found`}),(0,Q.jsx)(S,{variant:`outline`,onClick:e.handleBackToWorkspaces,children:`Workspaces`})]});let h=(0,Q.jsx)(`div`,{className:`h-full flex flex-col min-w-0`,children:(0,Q.jsx)(ri,{workspaceId:e.workspaceId,sessions:n.sessions,selectedSessionId:n.selectedDbSessionId,sessionSummariesById:n.sessionSummariesById,queuedMessageCount:n.queuedMessageCount,isCreatingSession:t.isCreatingSession,isDeletingSession:n.isDeletingSession,onSelectSession:n.handleSelectSession,onCreateSession:n.handleNewChat,onCloseSession:n.handleCloseChatSession,onRestartSession:n.handleRestartSession,maxSessions:n.maxSessions,hasWorktreePath:n.hasWorktreePath,emptyState:e.workspaceInitStatus?.phase===`BLOCKED_FAILED`?(0,Q.jsx)(ii,{retryAvailability:e.workspaceInitStatus.retryAvailability,workspaceId:e.workspaceId,banner:e.workspaceInitStatus.chatBanner,errorMessage:e.workspaceInitStatus.initErrorMessage}):void 0,children:br})}),g=(0,Q.jsx)(jt,{workspaceId:e.workspaceId,isTakingScreenshots:c,onTakeScreenshots:p,selectedSessionId:n.selectedDbSessionId,selectedSessionName:f,selectedSessionReady:n.selectedSessionReady,selectedSessionControlId:n.selectedSessionControlId,selectedSessionControlRuntimeId:n.selectedSessionControlRuntimeId,onOpenSubagent:m});return(0,Q.jsxs)(`div`,{className:`relative flex h-full flex-col overflow-hidden`,children:[t.archivePending&&(0,Q.jsx)(si,{}),(0,Q.jsx)(di,{workspaceId:e.workspaceId,isScriptFailed:e.isScriptFailed,workspaceInitStatus:e.workspaceInitStatus,setupWarningDismissed:e.setupWarningDismissed,dismissSetupWarning:e.dismissSetupWarning,resumeQueuedMessages:r}),s?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`flex-1 min-h-0`,children:h}),(0,Q.jsx)(Ot,{open:i,onOpenChange:a,children:g})]}):(0,Q.jsxs)(Et,{direction:`horizontal`,className:`flex-1 overflow-hidden`,autoSaveId:`workspace-main-panel`,children:[(0,Q.jsx)(kt,{id:`workspace-chat`,defaultSize:`70%`,minSize:`30%`,children:h}),(0,Q.jsx)(li,{visible:i,children:g})]}),(0,Q.jsx)(Le,{open:o.open,onOpenChange:o.setOpen,activeChildCount:o.activeChildCount,onConfirm:o.onConfirm})]})});function pi(){let{slug:e=``,id:t=``}=r(),n=i(),[c,u]=o(),{key:d}=a(),f=s.useUtils(),{workspace:p,workspaceLoading:m,sessions:h,initialDbSessionId:g,maxSessions:_}=tn({workspaceId:t}),{rightPanelVisible:v,setRightPanelVisible:y,setActiveBottomTab:b,activeTabId:x,selectTab:S,tabs:C,openTab:w,openSubagentTab:T}=te(),{workspaceInitStatus:E,isScriptFailed:D,setupWarningDismissed:O,dismissSetupWarning:k}=dn(t,p,f);(0,Z.useEffect)(()=>{let e=E?.phase;(e===`READY`||e===`ARCHIVED`)&&Xt(t)},[t,E?.phase]);let A=(0,Z.useMemo)(()=>h?.map(e=>e.id)??[],[h]),j=(0,Z.useCallback)(()=>S(`chat`),[S]),{selectedDbSessionId:M,setSelectedDbSessionId:N}=hn(t,g??null,A,c.get(`session`),j,d),P=(0,Z.useCallback)(e=>{N(e),c.has(`session`)&&u(e=>{let t=new URLSearchParams(e);return t.delete(`session`),t},{replace:!0})},[N,c,u]),[F,ee]=(0,Z.useState)(!1),[re,ie]=(0,Z.useState)(!1),ae=(0,Z.useCallback)(()=>ie(!0),[]),oe=p?.creationSource!==`CHILD_WORKSPACE`,se=ft(p),{data:ce}=s.workspace.listChildren.useQuery({parentWorkspaceId:t},{enabled:!se&&F&&oe}),le=ce?.length??0,{messages:I,transcriptHistory:L,transcriptPageBoundaries:R,connected:z,sessionStatus:B,processStatus:ue,sessionRuntime:V,runtimeSessionId:H,controlsHydrated:de,pendingRequest:fe,chatSettings:U,chatCapabilities:pe,chatCapabilitiesLoaded:me,inputDraft:he,inputAttachments:ge,inputDraftGeneration:_e,queuedMessages:ve,removeQueuedMessage:ye,steerQueuedMessage:be,resumeQueuedMessages:W,latestThinking:xe,pendingMessages:Se,isCompacting:we,slashCommands:Te,slashCommandsLoaded:Ee,tokenStats:De,rewindPreview:Oe,sendMessage:ke,stopChat:Ae,restartSession:je,approvePermission:Ne,answerQuestion:Pe,updateSettings:Fe,setInputDraft:Ie,setInputAttachments:Le,startRewindPreview:Re,confirmRewind:ze,cancelRewind:Be,getUuidForMessageId:He,acpConfigOptions:Ue,acpPlan:Ge,setConfigOption:Ke,inputRef:qe}=Ce({dbSessionId:M}),Je=B.phase===`loading`,Ye=p?.creationSource===`GITHUB_ISSUE`&&M!==null&&(B.phase===`loading`||B.phase===`ready`)&&ue.state===`unknown`&&wr(I),Xe=Me(fe),G=(0,Z.useMemo)(()=>Cr({workspaceSummaries:p?.sessionSummaries,sessions:h,selectedSessionId:M,liveRuntime:V,livePendingRequestType:Xe,runtimeSessionId:H,chatConnected:z}),[p?.sessionSummaries,h,M,V,Xe,H,z]),Ze=(0,Z.useMemo)(()=>H===null?null:{sessionId:H,count:ve.length},[H,ve.length]),Qe=(0,Z.useMemo)(()=>Array.from(G.values()).some(e=>ne(e)),[G]),$e=xt(M,z&&de&&H===M,V),et=V.work?.controlRuntimeId,tt=xr(M),nt=un(t,p,Qe,f),{createSession:it,deleteSession:at,archiveWorkspace:K,openInIde:ot,availableIdes:st,preferredIde:ct,handleSelectSession:lt,handleCloseSession:ut,handleNewChat:dt,handleQuickAction:q}=nn({workspaceId:t,slug:e,sessions:h,inputRef:qe,selectedDbSessionId:M,setSelectedDbSessionId:P,onArchiveGitIndexLocked:ae});_n({status:p?.status,slug:e,archivePending:K.isPending});let J=(0,Z.useCallback)((e=!1)=>{K.mutate(e?{id:t,removeGitIndexLock:!0}:{id:t})},[K,t]),pt=(0,Z.useCallback)(()=>{se?J():ee(!0)},[se,J]),mt=(0,Z.useCallback)(()=>{l(Promise.resolve(n(`/projects/${e}/workspaces`)),`Couldn't open workspace list.`)},[n,e]),ht=(0,Z.useCallback)(()=>J(),[J]),gt=(0,Z.useCallback)(()=>J(!0),[J]),Y=rt({workspaceId:t,sessionId:M}),_t=(0,Z.useCallback)(e=>{Y.clearSession(e),ut(e)},[Y.clearSession,ut]),X=C.find(e=>e.id===x),vt=!X||X.type===`chat`,yt=Sr(E?.chatBanner,O),bt=(0,Z.useCallback)(e=>Wt(e,p?.worktreePath),[p?.worktreePath]),St=(0,Z.useCallback)(e=>{w(`file`,e,e.split(`/`).pop()??e)},[w]);gn({workspaceLoading:m,workspace:p,selectedDbSessionId:M,activeTabId:x,loadingSession:Je,inputRef:qe});let Ct=`${t}/main/${M??`none`}`,wt=Y.ready&&M!==null&&H===M,Tt=(0,Z.useMemo)(()=>({identity:Ct,active:vt,ready:wt,initialIntent:`following`,initialPosition:Y.initialPosition,onPositionChange:Y.onPositionChange}),[Ct,vt,wt,Y.initialPosition,Y.onPositionChange]),Et=(0,Z.useCallback)((e,t)=>{l(q(e,t),`Couldn't run quick action.`)},[q]),Dt=Ve({sessions:h,maxSessions:_,isCreatingSession:it.isPending,isDeletingSession:at.isPending,hasWorktreePath:!!p?.worktreePath}),Ot={onViewSetupOutput:(0,Z.useCallback)(()=>{b(`setup-logs`),y(!0)},[b,y]),retryAvailability:E?.retryAvailability,workspaceId:t,sessionId:M,codexAccountId:h?.find(e=>e.id===M)?.codexAccountId,resolveWorkspaceFileLink:bt,onWorkspaceFileLink:St,onOpenSubagent:T,parentSessionName:h?.find(e=>e.id===M)?.name,messages:I,history:L,transcriptPageBoundaries:R,sessionStatus:B,sessionRuntime:V,transcriptScroll:Tt,pendingRequest:fe,approvePermission:Ne,answerQuestion:Pe,connected:z,controlsHydrated:de,sendMessage:ke,stopChat:Ae,restartSession:je,inputRef:qe,chatSettings:U,chatCapabilities:pe,chatCapabilitiesLoaded:me,updateSettings:Fe,inputDraft:he,setInputDraft:Ie,inputAttachments:ge,inputDraftGeneration:_e,setInputAttachments:Le,queuedMessages:ve,removeQueuedMessage:ye,steerQueuedMessage:be,resumeQueuedMessages:W,latestThinking:xe,pendingMessages:Se,isCompacting:we,slashCommands:Te,slashCommandsLoaded:Ee,tokenStats:De,rewindPreview:Oe,startRewindPreview:Re,confirmRewind:ze,cancelRewind:Be,getUuidForMessageId:He,acpConfigOptions:Ue,acpPlan:Ge,setConfigOption:Ke,autoStartPending:Ye,initBanner:yt,isScriptFailed:D,onRunQuickActionInNewChat:Et,newChatUnavailableReason:Dt},kt=(0,Z.useMemo)(()=>({workspaceLoading:m,workspace:p,workspaceId:t,handleBackToWorkspaces:mt,isScriptFailed:D,workspaceInitStatus:E,setupWarningDismissed:O,dismissSetupWarning:k}),[m,p,t,mt,D,E,O,k]),jt=(0,Z.useMemo)(()=>({archivePending:K.isPending,handleQuickAction:q,isCreatingSession:it.isPending}),[K.isPending,q,it.isPending]),Mt=!!p?.worktreePath,Nt=(0,Z.useMemo)(()=>({sessions:h,selectedDbSessionId:M,selectedSessionReady:tt,selectedSessionControlId:$e,selectedSessionControlRuntimeId:et,sessionSummariesById:G,queuedMessageCount:Ze,isDeletingSession:at.isPending,handleSelectSession:lt,handleNewChat:dt,handleCloseChatSession:_t,handleRestartSession:je,handleOpenSubagentTab:T,maxSessions:_,hasWorktreePath:Mt}),[h,M,tt,$e,et,G,Ze,at.isPending,lt,dt,_t,je,T,_,Mt]),Pt=(0,Z.useMemo)(()=>({open:F,setOpen:ee,activeChildCount:le,onConfirm:ht}),[F,le,ht]);return(0,Q.jsxs)(Q.Fragment,{children:[p&&(0,Q.jsx)(At,{workspace:p,workspaceId:t,availableIdes:st,preferredIde:ct,openInIde:ot,archivePending:K.isPending,onArchiveRequest:pt,handleQuickAction:q,running:Qe,isCreatingSession:it.isPending,hasChanges:nt}),(0,Q.jsx)(vr,{value:Ot,children:(0,Q.jsx)(fi,{workspaceState:kt,header:jt,sessionTabs:Nt,resumeQueuedMessages:W,rightPanelVisible:v,setRightPanelVisible:y,archiveDialog:Pt})}),(0,Q.jsx)(We,{open:re,onOpenChange:ie,onRetry:ht,onRemoveLockAndArchive:gt,isPending:K.isPending})]})}function mi(){let{id:e=``}=r(),[t]=o();return(0,Q.jsx)(ee,{workspaceId:e,initialActiveTabId:t.has(`session`)?`chat`:void 0,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(E,{message:`Loading chat…`}),children:(0,Q.jsx)(pi,{},e)})},e)}export{mi as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./mermaid-parser.core-BrXnuEs7.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as n,p as r}from"./src-BWF7jMDv.js";import{C as i,E as a,H as o,U as s,_ as c,a as l,c as u,f as d,q as f,v as p,y as m}from"./chunk-DSNLSHJZ-CSSZ0uRv.js";import{t as h}from"./ordinal-BDEzSJ7C.js";import{t as g}from"./defaultLocale-BFoDCU3G.js";import{i as _}from"./chunk-7S6XSTFO-v9BVbuJB.js";import{t as v}from"./chunk-JWPE2WC7-DVXcaiue.js";import{i as y,n as b}from"./chunk-UHW7PFBP-FWZD9983.js";import{t as x}from"./chunk-VQ5W62QI-BxZNPUPp.js";import{o as S}from"./mermaid-diagram-xMTMF9cZ.js";function C(e){var t=0,n=e.children,r=n&&n.length;if(!r)t=1;else for(;--r>=0;)t+=n[r].value;e.value=t}function w(){return this.eachAfter(C)}function T(e,t){let n=-1;for(let r of this)e.call(t,r,++n,this);return this}function E(e,t){for(var n=this,r=[n],i,a,o=-1;n=r.pop();)if(e.call(t,n,++o,this),i=n.children)for(a=i.length-1;a>=0;--a)r.push(i[a]);return this}function D(e,t){for(var n=this,r=[n],i=[],a,o,s,c=-1;n=r.pop();)if(i.push(n),a=n.children)for(o=0,s=a.length;o<s;++o)r.push(a[o]);for(;n=i.pop();)e.call(t,n,++c,this);return this}function O(e,t){let n=-1;for(let r of this)if(e.call(t,r,++n,this))return r}function k(e){return this.eachAfter(function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n})}function A(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}function j(e){for(var t=this,n=M(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r}function M(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}function N(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}function P(){return Array.from(this)}function F(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}function I(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}function*L(){var e=this,t,n=[e],r,i,a;do for(t=n.reverse(),n=[];e=t.pop();)if(yield e,r=e.children)for(i=0,a=r.length;i<a;++i)n.push(r[i]);while(n.length)}function R(e,t){e instanceof Map?(e=[void 0,e],t===void 0&&(t=V)):t===void 0&&(t=B);for(var n=new W(e),r,i=[n],a,o,s,c;r=i.pop();)if((o=t(r.data))&&(c=(o=Array.from(o)).length))for(r.children=o,s=c-1;s>=0;--s)i.push(a=o[s]=new W(o[s])),a.parent=r,a.depth=r.depth+1;return n.eachBefore(U)}function z(){return R(this).eachBefore(H)}function B(e){return e.children}function V(e){return Array.isArray(e)?e[1]:null}function H(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function U(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function W(e){this.data=e,this.depth=this.height=0,this.parent=null}W.prototype=R.prototype={constructor:W,count:w,each:T,eachAfter:D,eachBefore:E,find:O,sum:k,sort:A,path:j,ancestors:N,descendants:P,leaves:F,links:I,copy:z,[Symbol.iterator]:L};function G(e){if(typeof e!=`function`)throw Error();return e}function K(){return 0}function q(e){return function(){return e}}function ee(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}function te(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(r-t)/e.value;++s<c;)o=a[s],o.y0=n,o.y1=i,o.x0=t,o.x1=t+=o.value*l}function ne(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(i-n)/e.value;++s<c;)o=a[s],o.x0=t,o.x1=r,o.y0=n,o.y1=n+=o.value*l}var re=(1+Math.sqrt(5))/2;function ie(e,t,n,r,i,a){for(var o=[],s=t.children,c,l,u=0,d=0,f=s.length,p,m,h=t.value,g,_,v,y,b,x,S;u<f;){p=i-n,m=a-r;do g=s[d++].value;while(!g&&d<f);for(_=v=g,x=Math.max(m/p,p/m)/(h*e),S=g*g*x,b=Math.max(v/S,S/_);d<f;++d){if(g+=l=s[d].value,l<_&&(_=l),l>v&&(v=l),S=g*g*x,y=Math.max(v/S,S/_),y>b){g-=l;break}b=y}o.push(c={value:g,dice:p<m,children:s.slice(u,d)}),c.dice?te(c,n,r,i,h?r+=m*g/h:a):ne(c,n,r,h?n+=p*g/h:i,a),h-=g,u=d}return o}var ae=(function e(t){function n(e,n,r,i,a){ie(t,e,n,r,i,a)}return n.ratio=function(t){return e((t=+t)>1?t:1)},n})(re);function oe(){var e=ae,t=!1,n=1,r=1,i=[0],a=K,o=K,s=K,c=K,l=K;function u(e){return e.x0=e.y0=0,e.x1=n,e.y1=r,e.eachBefore(d),i=[0],t&&e.eachBefore(ee),e}function d(t){var n=i[t.depth],r=t.x0+n,u=t.y0+n,d=t.x1-n,f=t.y1-n;d<r&&(r=d=(r+d)/2),f<u&&(u=f=(u+f)/2),t.x0=r,t.y0=u,t.x1=d,t.y1=f,t.children&&(n=i[t.depth+1]=a(t)/2,r+=l(t)-n,u+=o(t)-n,d-=s(t)-n,f-=c(t)-n,d<r&&(r=d=(r+d)/2),f<u&&(u=f=(u+f)/2),e(t,r,u,d,f))}return u.round=function(e){return arguments.length?(t=!!e,u):t},u.size=function(e){return arguments.length?(n=+e[0],r=+e[1],u):[n,r]},u.tile=function(t){return arguments.length?(e=G(t),u):e},u.padding=function(e){return arguments.length?u.paddingInner(e).paddingOuter(e):u.paddingInner()},u.paddingInner=function(e){return arguments.length?(a=typeof e==`function`?e:q(+e),u):a},u.paddingOuter=function(e){return arguments.length?u.paddingTop(e).paddingRight(e).paddingBottom(e).paddingLeft(e):u.paddingTop()},u.paddingTop=function(e){return arguments.length?(o=typeof e==`function`?e:q(+e),u):o},u.paddingRight=function(e){return arguments.length?(s=typeof e==`function`?e:q(+e),u):s},u.paddingBottom=function(e){return arguments.length?(c=typeof e==`function`?e:q(+e),u):c},u.paddingLeft=function(e){return arguments.length?(l=typeof e==`function`?e:q(+e),u):l},u}var J=class{constructor(){this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.setAccTitle=s,this.getAccTitle=p,this.setDiagramTitle=f,this.getDiagramTitle=i,this.getAccDescription=c,this.setAccDescription=o}static{t(this,`TreeMapDB`)}getNodes(){return this.nodes}getConfig(){let e=d,t=m();return _({...e.treemap,...t.treemap??{}})}addNode(e,t){this.nodes.push(e),this.levels.set(e,t),t===0&&(this.outerNodes.push(e),this.root??=e)}getRoot(){return{name:``,children:this.outerNodes}}addClass(e,t){let n=this.classes.get(e)??{id:e,styles:[],textStyles:[]},r=t.replace(/\\,/g,`§§§`).replace(/,/g,`;`).replace(/§§§/g,`,`).split(`;`);r&&r.forEach(e=>{b(e)&&(n?.textStyles?n.textStyles.push(e):n.textStyles=[e]),n?.styles?n.styles.push(e):n.styles=[e]}),this.classes.set(e,n)}getClasses(){return this.classes}getStylesForClass(e){return this.classes.get(e)?.styles??[]}clear(){l(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function Y(e){if(!e.length)return[];let t=[],n=[];return e.forEach(e=>{let r={name:e.name,children:e.type===`Leaf`?void 0:[]};for(r.classSelector=e?.classSelector,e?.cssCompiledStyles&&(r.cssCompiledStyles=e.cssCompiledStyles),e.type===`Leaf`&&e.value!==void 0&&(r.value=e.value);n.length>0&&n[n.length-1].level>=e.level;)n.pop();if(n.length===0)t.push(r);else{let e=n[n.length-1].node;e.children?e.children.push(r):e.children=[r]}e.type!==`Leaf`&&n.push({node:r,level:e.level})}),t}t(Y,`buildHierarchy`);var se=t((e,n)=>{v(e,n);let r=[];for(let t of e.TreemapRows??[])t.$type===`ClassDefStatement`&&n.addClass(t.className??``,t.styleText??``);for(let t of e.TreemapRows??[]){let e=t.item;if(!e)continue;let i=t.indent?parseInt(t.indent):0,a=ce(e),o=e.classSelector?n.getStylesForClass(e.classSelector):[],s=o.length>0?o:void 0,c={level:i,name:a,type:e.$type,value:e.value,classSelector:e.classSelector,cssCompiledStyles:s};r.push(c)}let i=Y(r),a=t((e,t)=>{for(let r of e)n.addNode(r,t),r.children&&r.children.length>0&&a(r.children,t+1)},`addNodesRecursively`);a(i,0)},`populate`),ce=t(e=>e.name?String(e.name):``,`getItemName`),X={parser:{yy:void 0},parse:t(async t=>{try{let r=await e(`treemap`,t);n.debug(`Treemap AST:`,r);let i=X.parser?.yy;if(!(i instanceof J))throw Error(`parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.`);se(r,i)}catch(e){throw n.error(`Error parsing treemap:`,e),e}},`parse`)},Z=10,Q=10,$=25,le={draw:t((e,i,a,o)=>{let s=o.db,c=s.getConfig(),l=c.padding??Z,d=s.getDiagramTitle(),f=s.getRoot(),{themeVariables:p}=m();if(!f)return;let _=d?30:0,v=S(i),b=c.nodeWidth?c.nodeWidth*Q:960,C=c.nodeHeight?c.nodeHeight*Q:500,w=b,T=C+_;v.attr(`viewBox`,`0 0 ${w} ${T}`),u(v,T,w,c.useMaxWidth);let E;try{let e=c.valueFormat||`,`;if(e===`$0,0`)E=t(e=>`$`+g(`,`)(e),`valueFormat`);else if(e.startsWith(`$`)&&e.includes(`,`)){let n=/\.\d+/.exec(e),r=n?n[0]:``;E=t(e=>`$`+g(`,`+r)(e),`valueFormat`)}else if(e.startsWith(`$`)){let n=e.substring(1);E=t(e=>`$`+g(n||``)(e),`valueFormat`)}else E=g(e)}catch(e){n.error(`Error creating format function:`,e),E=g(`,`)}let D=h().range([`transparent`,p.cScale0,p.cScale1,p.cScale2,p.cScale3,p.cScale4,p.cScale5,p.cScale6,p.cScale7,p.cScale8,p.cScale9,p.cScale10,p.cScale11]),O=h().range([`transparent`,p.cScalePeer0,p.cScalePeer1,p.cScalePeer2,p.cScalePeer3,p.cScalePeer4,p.cScalePeer5,p.cScalePeer6,p.cScalePeer7,p.cScalePeer8,p.cScalePeer9,p.cScalePeer10,p.cScalePeer11]),k=h().range([p.cScaleLabel0,p.cScaleLabel1,p.cScaleLabel2,p.cScaleLabel3,p.cScaleLabel4,p.cScaleLabel5,p.cScaleLabel6,p.cScaleLabel7,p.cScaleLabel8,p.cScaleLabel9,p.cScaleLabel10,p.cScaleLabel11]);d&&v.append(`text`).attr(`x`,w/2).attr(`y`,_/2).attr(`class`,`treemapTitle`).attr(`text-anchor`,`middle`).attr(`dominant-baseline`,`middle`).text(d);let A=v.append(`g`).attr(`transform`,`translate(0, ${_})`).attr(`class`,`treemapContainer`),j=R(f).sum(e=>e.value??0).sort((e,t)=>(t.value??0)-(e.value??0)),M=oe().size([b,C]).paddingTop(e=>e.children&&e.children.length>0?$+Q:0).paddingInner(l).paddingLeft(e=>e.children&&e.children.length>0?Q:0).paddingRight(e=>e.children&&e.children.length>0?Q:0).paddingBottom(e=>e.children&&e.children.length>0?Q:0).round(!0)(j),N=M.descendants().filter(e=>e.children&&e.children.length>0),P=A.selectAll(`.treemapSection`).data(N).enter().append(`g`).attr(`class`,`treemapSection`).attr(`transform`,e=>`translate(${e.x0},${e.y0})`);P.append(`rect`).attr(`width`,e=>e.x1-e.x0).attr(`height`,$).attr(`class`,`treemapSectionHeader`).attr(`fill`,`none`).attr(`fill-opacity`,.6).attr(`stroke-width`,.6).attr(`style`,e=>e.depth===0?`display: none;`:``),P.append(`clipPath`).attr(`id`,(e,t)=>`clip-section-${i}-${t}`).append(`rect`).attr(`width`,e=>Math.max(0,e.x1-e.x0-12)).attr(`height`,$),P.append(`rect`).attr(`width`,e=>e.x1-e.x0).attr(`height`,e=>e.y1-e.y0).attr(`class`,(e,t)=>`treemapSection section${t}`).attr(`fill`,e=>D(e.data.name)).attr(`fill-opacity`,.6).attr(`stroke`,e=>O(e.data.name)).attr(`stroke-width`,2).attr(`stroke-opacity`,.4).attr(`style`,e=>{if(e.depth===0)return`display: none;`;let t=y({cssCompiledStyles:e.data.cssCompiledStyles});return t.nodeStyles+`;`+t.borderStyles.join(`;`)}),P.append(`text`).attr(`class`,`treemapSectionLabel`).attr(`x`,6).attr(`y`,$/2).attr(`dominant-baseline`,`middle`).text(e=>e.depth===0?``:e.data.name).attr(`font-weight`,`bold`).attr(`clip-path`,(e,t)=>`url(#clip-section-${i}-${t})`).attr(`style`,e=>e.depth===0?`display: none;`:`dominant-baseline: middle; font-size: 12px; fill:`+k(e.data.name)+`; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;`+y({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`)).each(function(e){if(e.depth===0)return;let t=r(this),n=e.data.name;t.text(n);let i=e.x1-e.x0,a;a=c.showValues!==!1&&e.value?i-10-30-10-6:i-6-6;let o=Math.max(15,a),s=t.node();if(s.getComputedTextLength()>o){let e=n;for(;e.length>0;){if(e=n.substring(0,e.length-1),e.length===0){t.text(`...`),s.getComputedTextLength()>o&&t.text(``);break}if(t.text(e+`...`),s.getComputedTextLength()<=o)break}}}),c.showValues!==!1&&P.append(`text`).attr(`class`,`treemapSectionValue`).attr(`x`,e=>e.x1-e.x0-10).attr(`y`,$/2).attr(`text-anchor`,`end`).attr(`dominant-baseline`,`middle`).text(e=>e.value?E(e.value):``).attr(`font-style`,`italic`).attr(`style`,e=>e.depth===0?`display: none;`:`text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:`+k(e.data.name)+`; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;`+y({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`));let F=M.leaves(),I=F.length>20,L=I?16:38,z=I?14:28,B=I?4:8,V=I?4:6,H=I?2:4,U=I?8:10,W=I?1:2,G=A.selectAll(`.treemapLeafGroup`).data(F).enter().append(`g`).attr(`class`,(e,t)=>`treemapNode treemapLeafGroup leaf${t}${e.data.classSelector?` ${e.data.classSelector}`:``}x`).attr(`transform`,e=>`translate(${e.x0},${e.y0})`);G.append(`rect`).attr(`width`,e=>e.x1-e.x0).attr(`height`,e=>e.y1-e.y0).attr(`class`,`treemapLeaf`).attr(`fill`,e=>e.parent?D(e.parent.data.name):D(e.data.name)).attr(`style`,e=>y({cssCompiledStyles:e.data.cssCompiledStyles}).nodeStyles).attr(`fill-opacity`,.3).attr(`stroke`,e=>e.parent?D(e.parent.data.name):D(e.data.name)).attr(`stroke-width`,3),G.append(`clipPath`).attr(`id`,(e,t)=>`clip-${i}-${t}`).append(`rect`).attr(`width`,e=>Math.max(0,e.x1-e.x0-4)).attr(`height`,e=>Math.max(0,e.y1-e.y0-4)),G.append(`text`).attr(`class`,`treemapLabel`).attr(`x`,e=>(e.x1-e.x0)/2).attr(`y`,e=>(e.y1-e.y0)/2).attr(`style`,e=>`text-anchor: middle; dominant-baseline: middle; font-size: ${L}px;fill:`+k(e.data.name)+`;`+y({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`)).attr(`clip-path`,(e,t)=>`url(#clip-${i}-${t})`).text(e=>e.data.name).each(function(e){let t=r(this),n=e.x1-e.x0,i=e.y1-e.y0,a=t.node(),o=n-2*H,s=i-2*H;if(o<U||s<U){t.style(`display`,`none`);return}let c=parseInt(t.style(`font-size`),10),l=.6;for(;a.getComputedTextLength()>o&&c>B;)c--,t.style(`font-size`,`${c}px`);let u=Math.max(V,Math.min(z,Math.round(c*l))),d=c+W+u;for(;d>s&&c>B&&(c--,u=Math.max(V,Math.min(z,Math.round(c*l))),!(u<V&&c===B));)t.style(`font-size`,`${c}px`),d=c+W+u;t.style(`font-size`,`${c}px`),I?(c<B||s<B)&&t.style(`display`,`none`):(a.getComputedTextLength()>o||c<B||s<c)&&t.style(`display`,`none`)}),c.showValues!==!1&&G.append(`text`).attr(`class`,`treemapValue`).attr(`x`,e=>(e.x1-e.x0)/2).attr(`y`,function(e){return(e.y1-e.y0)/2}).attr(`style`,e=>`text-anchor: middle; dominant-baseline: hanging; font-size: ${z}px;fill:`+k(e.data.name)+`;`+y({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`)).attr(`clip-path`,(e,t)=>`url(#clip-${i}-${t})`).text(e=>e.value?E(e.value):``).each(function(e){let t=r(this),n=this.parentNode;if(!n){t.style(`display`,`none`);return}let i=r(n).select(`.treemapLabel`);if(i.empty()||i.style(`display`)===`none`){t.style(`display`,`none`);return}let a=parseFloat(i.style(`font-size`)),o=Math.max(V,Math.min(z,Math.round(a*.6)));t.style(`font-size`,`${o}px`);let s=(e.y1-e.y0)/2+a/2+W;t.attr(`y`,s);let c=e.x1-e.x0,l=e.y1-e.y0-4,u=c-2*H;t.node().getComputedTextLength()>u||s+o>l||o<V?t.style(`display`,`none`):t.style(`display`,null)});let K=c.diagramPadding??8;x(v,K,`flowchart`,c?.useMaxWidth||!1)},`draw`),getClasses:t(function(e,t){return t.db.getClasses()},`getClasses`)},ue={sectionStrokeColor:`black`,sectionStrokeWidth:`1`,sectionFillColor:`#efefef`,leafStrokeColor:`black`,leafStrokeWidth:`1`,leafFillColor:`#efefef`,labelFontSize:`12px`,valueFontSize:`10px`,titleFontSize:`14px`},de={parser:X,get db(){return new J},renderer:le,styles:t(({treemap:e}={})=>{let t=a(),n=m(),r=_(t,n.themeVariables),i=_(ue,e),o=i.titleColor??r.titleColor,s=i.labelColor??r.textColor,c=i.valueColor??r.textColor;return`
|
|
1
|
+
import{n as e}from"./mermaid-parser.core-BrXnuEs7.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as n,p as r}from"./src-BWF7jMDv.js";import{C as i,E as a,H as o,U as s,_ as c,a as l,c as u,f as d,q as f,v as p,y as m}from"./chunk-DSNLSHJZ-CSSZ0uRv.js";import{t as h}from"./ordinal-BDEzSJ7C.js";import{t as g}from"./defaultLocale-BFoDCU3G.js";import{i as _}from"./chunk-7S6XSTFO-v9BVbuJB.js";import{t as v}from"./chunk-JWPE2WC7-DVXcaiue.js";import{i as y,n as b}from"./chunk-UHW7PFBP-FWZD9983.js";import{t as x}from"./chunk-VQ5W62QI-BxZNPUPp.js";import{o as S}from"./mermaid-diagram-DHR-LEin.js";function C(e){var t=0,n=e.children,r=n&&n.length;if(!r)t=1;else for(;--r>=0;)t+=n[r].value;e.value=t}function w(){return this.eachAfter(C)}function T(e,t){let n=-1;for(let r of this)e.call(t,r,++n,this);return this}function E(e,t){for(var n=this,r=[n],i,a,o=-1;n=r.pop();)if(e.call(t,n,++o,this),i=n.children)for(a=i.length-1;a>=0;--a)r.push(i[a]);return this}function D(e,t){for(var n=this,r=[n],i=[],a,o,s,c=-1;n=r.pop();)if(i.push(n),a=n.children)for(o=0,s=a.length;o<s;++o)r.push(a[o]);for(;n=i.pop();)e.call(t,n,++c,this);return this}function O(e,t){let n=-1;for(let r of this)if(e.call(t,r,++n,this))return r}function k(e){return this.eachAfter(function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n})}function A(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}function j(e){for(var t=this,n=M(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r}function M(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}function N(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}function P(){return Array.from(this)}function F(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}function I(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}function*L(){var e=this,t,n=[e],r,i,a;do for(t=n.reverse(),n=[];e=t.pop();)if(yield e,r=e.children)for(i=0,a=r.length;i<a;++i)n.push(r[i]);while(n.length)}function R(e,t){e instanceof Map?(e=[void 0,e],t===void 0&&(t=V)):t===void 0&&(t=B);for(var n=new W(e),r,i=[n],a,o,s,c;r=i.pop();)if((o=t(r.data))&&(c=(o=Array.from(o)).length))for(r.children=o,s=c-1;s>=0;--s)i.push(a=o[s]=new W(o[s])),a.parent=r,a.depth=r.depth+1;return n.eachBefore(U)}function z(){return R(this).eachBefore(H)}function B(e){return e.children}function V(e){return Array.isArray(e)?e[1]:null}function H(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function U(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function W(e){this.data=e,this.depth=this.height=0,this.parent=null}W.prototype=R.prototype={constructor:W,count:w,each:T,eachAfter:D,eachBefore:E,find:O,sum:k,sort:A,path:j,ancestors:N,descendants:P,leaves:F,links:I,copy:z,[Symbol.iterator]:L};function G(e){if(typeof e!=`function`)throw Error();return e}function K(){return 0}function q(e){return function(){return e}}function ee(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}function te(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(r-t)/e.value;++s<c;)o=a[s],o.y0=n,o.y1=i,o.x0=t,o.x1=t+=o.value*l}function ne(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(i-n)/e.value;++s<c;)o=a[s],o.x0=t,o.x1=r,o.y0=n,o.y1=n+=o.value*l}var re=(1+Math.sqrt(5))/2;function ie(e,t,n,r,i,a){for(var o=[],s=t.children,c,l,u=0,d=0,f=s.length,p,m,h=t.value,g,_,v,y,b,x,S;u<f;){p=i-n,m=a-r;do g=s[d++].value;while(!g&&d<f);for(_=v=g,x=Math.max(m/p,p/m)/(h*e),S=g*g*x,b=Math.max(v/S,S/_);d<f;++d){if(g+=l=s[d].value,l<_&&(_=l),l>v&&(v=l),S=g*g*x,y=Math.max(v/S,S/_),y>b){g-=l;break}b=y}o.push(c={value:g,dice:p<m,children:s.slice(u,d)}),c.dice?te(c,n,r,i,h?r+=m*g/h:a):ne(c,n,r,h?n+=p*g/h:i,a),h-=g,u=d}return o}var ae=(function e(t){function n(e,n,r,i,a){ie(t,e,n,r,i,a)}return n.ratio=function(t){return e((t=+t)>1?t:1)},n})(re);function oe(){var e=ae,t=!1,n=1,r=1,i=[0],a=K,o=K,s=K,c=K,l=K;function u(e){return e.x0=e.y0=0,e.x1=n,e.y1=r,e.eachBefore(d),i=[0],t&&e.eachBefore(ee),e}function d(t){var n=i[t.depth],r=t.x0+n,u=t.y0+n,d=t.x1-n,f=t.y1-n;d<r&&(r=d=(r+d)/2),f<u&&(u=f=(u+f)/2),t.x0=r,t.y0=u,t.x1=d,t.y1=f,t.children&&(n=i[t.depth+1]=a(t)/2,r+=l(t)-n,u+=o(t)-n,d-=s(t)-n,f-=c(t)-n,d<r&&(r=d=(r+d)/2),f<u&&(u=f=(u+f)/2),e(t,r,u,d,f))}return u.round=function(e){return arguments.length?(t=!!e,u):t},u.size=function(e){return arguments.length?(n=+e[0],r=+e[1],u):[n,r]},u.tile=function(t){return arguments.length?(e=G(t),u):e},u.padding=function(e){return arguments.length?u.paddingInner(e).paddingOuter(e):u.paddingInner()},u.paddingInner=function(e){return arguments.length?(a=typeof e==`function`?e:q(+e),u):a},u.paddingOuter=function(e){return arguments.length?u.paddingTop(e).paddingRight(e).paddingBottom(e).paddingLeft(e):u.paddingTop()},u.paddingTop=function(e){return arguments.length?(o=typeof e==`function`?e:q(+e),u):o},u.paddingRight=function(e){return arguments.length?(s=typeof e==`function`?e:q(+e),u):s},u.paddingBottom=function(e){return arguments.length?(c=typeof e==`function`?e:q(+e),u):c},u.paddingLeft=function(e){return arguments.length?(l=typeof e==`function`?e:q(+e),u):l},u}var J=class{constructor(){this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.setAccTitle=s,this.getAccTitle=p,this.setDiagramTitle=f,this.getDiagramTitle=i,this.getAccDescription=c,this.setAccDescription=o}static{t(this,`TreeMapDB`)}getNodes(){return this.nodes}getConfig(){let e=d,t=m();return _({...e.treemap,...t.treemap??{}})}addNode(e,t){this.nodes.push(e),this.levels.set(e,t),t===0&&(this.outerNodes.push(e),this.root??=e)}getRoot(){return{name:``,children:this.outerNodes}}addClass(e,t){let n=this.classes.get(e)??{id:e,styles:[],textStyles:[]},r=t.replace(/\\,/g,`§§§`).replace(/,/g,`;`).replace(/§§§/g,`,`).split(`;`);r&&r.forEach(e=>{b(e)&&(n?.textStyles?n.textStyles.push(e):n.textStyles=[e]),n?.styles?n.styles.push(e):n.styles=[e]}),this.classes.set(e,n)}getClasses(){return this.classes}getStylesForClass(e){return this.classes.get(e)?.styles??[]}clear(){l(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}};function Y(e){if(!e.length)return[];let t=[],n=[];return e.forEach(e=>{let r={name:e.name,children:e.type===`Leaf`?void 0:[]};for(r.classSelector=e?.classSelector,e?.cssCompiledStyles&&(r.cssCompiledStyles=e.cssCompiledStyles),e.type===`Leaf`&&e.value!==void 0&&(r.value=e.value);n.length>0&&n[n.length-1].level>=e.level;)n.pop();if(n.length===0)t.push(r);else{let e=n[n.length-1].node;e.children?e.children.push(r):e.children=[r]}e.type!==`Leaf`&&n.push({node:r,level:e.level})}),t}t(Y,`buildHierarchy`);var se=t((e,n)=>{v(e,n);let r=[];for(let t of e.TreemapRows??[])t.$type===`ClassDefStatement`&&n.addClass(t.className??``,t.styleText??``);for(let t of e.TreemapRows??[]){let e=t.item;if(!e)continue;let i=t.indent?parseInt(t.indent):0,a=ce(e),o=e.classSelector?n.getStylesForClass(e.classSelector):[],s=o.length>0?o:void 0,c={level:i,name:a,type:e.$type,value:e.value,classSelector:e.classSelector,cssCompiledStyles:s};r.push(c)}let i=Y(r),a=t((e,t)=>{for(let r of e)n.addNode(r,t),r.children&&r.children.length>0&&a(r.children,t+1)},`addNodesRecursively`);a(i,0)},`populate`),ce=t(e=>e.name?String(e.name):``,`getItemName`),X={parser:{yy:void 0},parse:t(async t=>{try{let r=await e(`treemap`,t);n.debug(`Treemap AST:`,r);let i=X.parser?.yy;if(!(i instanceof J))throw Error(`parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.`);se(r,i)}catch(e){throw n.error(`Error parsing treemap:`,e),e}},`parse`)},Z=10,Q=10,$=25,le={draw:t((e,i,a,o)=>{let s=o.db,c=s.getConfig(),l=c.padding??Z,d=s.getDiagramTitle(),f=s.getRoot(),{themeVariables:p}=m();if(!f)return;let _=d?30:0,v=S(i),b=c.nodeWidth?c.nodeWidth*Q:960,C=c.nodeHeight?c.nodeHeight*Q:500,w=b,T=C+_;v.attr(`viewBox`,`0 0 ${w} ${T}`),u(v,T,w,c.useMaxWidth);let E;try{let e=c.valueFormat||`,`;if(e===`$0,0`)E=t(e=>`$`+g(`,`)(e),`valueFormat`);else if(e.startsWith(`$`)&&e.includes(`,`)){let n=/\.\d+/.exec(e),r=n?n[0]:``;E=t(e=>`$`+g(`,`+r)(e),`valueFormat`)}else if(e.startsWith(`$`)){let n=e.substring(1);E=t(e=>`$`+g(n||``)(e),`valueFormat`)}else E=g(e)}catch(e){n.error(`Error creating format function:`,e),E=g(`,`)}let D=h().range([`transparent`,p.cScale0,p.cScale1,p.cScale2,p.cScale3,p.cScale4,p.cScale5,p.cScale6,p.cScale7,p.cScale8,p.cScale9,p.cScale10,p.cScale11]),O=h().range([`transparent`,p.cScalePeer0,p.cScalePeer1,p.cScalePeer2,p.cScalePeer3,p.cScalePeer4,p.cScalePeer5,p.cScalePeer6,p.cScalePeer7,p.cScalePeer8,p.cScalePeer9,p.cScalePeer10,p.cScalePeer11]),k=h().range([p.cScaleLabel0,p.cScaleLabel1,p.cScaleLabel2,p.cScaleLabel3,p.cScaleLabel4,p.cScaleLabel5,p.cScaleLabel6,p.cScaleLabel7,p.cScaleLabel8,p.cScaleLabel9,p.cScaleLabel10,p.cScaleLabel11]);d&&v.append(`text`).attr(`x`,w/2).attr(`y`,_/2).attr(`class`,`treemapTitle`).attr(`text-anchor`,`middle`).attr(`dominant-baseline`,`middle`).text(d);let A=v.append(`g`).attr(`transform`,`translate(0, ${_})`).attr(`class`,`treemapContainer`),j=R(f).sum(e=>e.value??0).sort((e,t)=>(t.value??0)-(e.value??0)),M=oe().size([b,C]).paddingTop(e=>e.children&&e.children.length>0?$+Q:0).paddingInner(l).paddingLeft(e=>e.children&&e.children.length>0?Q:0).paddingRight(e=>e.children&&e.children.length>0?Q:0).paddingBottom(e=>e.children&&e.children.length>0?Q:0).round(!0)(j),N=M.descendants().filter(e=>e.children&&e.children.length>0),P=A.selectAll(`.treemapSection`).data(N).enter().append(`g`).attr(`class`,`treemapSection`).attr(`transform`,e=>`translate(${e.x0},${e.y0})`);P.append(`rect`).attr(`width`,e=>e.x1-e.x0).attr(`height`,$).attr(`class`,`treemapSectionHeader`).attr(`fill`,`none`).attr(`fill-opacity`,.6).attr(`stroke-width`,.6).attr(`style`,e=>e.depth===0?`display: none;`:``),P.append(`clipPath`).attr(`id`,(e,t)=>`clip-section-${i}-${t}`).append(`rect`).attr(`width`,e=>Math.max(0,e.x1-e.x0-12)).attr(`height`,$),P.append(`rect`).attr(`width`,e=>e.x1-e.x0).attr(`height`,e=>e.y1-e.y0).attr(`class`,(e,t)=>`treemapSection section${t}`).attr(`fill`,e=>D(e.data.name)).attr(`fill-opacity`,.6).attr(`stroke`,e=>O(e.data.name)).attr(`stroke-width`,2).attr(`stroke-opacity`,.4).attr(`style`,e=>{if(e.depth===0)return`display: none;`;let t=y({cssCompiledStyles:e.data.cssCompiledStyles});return t.nodeStyles+`;`+t.borderStyles.join(`;`)}),P.append(`text`).attr(`class`,`treemapSectionLabel`).attr(`x`,6).attr(`y`,$/2).attr(`dominant-baseline`,`middle`).text(e=>e.depth===0?``:e.data.name).attr(`font-weight`,`bold`).attr(`clip-path`,(e,t)=>`url(#clip-section-${i}-${t})`).attr(`style`,e=>e.depth===0?`display: none;`:`dominant-baseline: middle; font-size: 12px; fill:`+k(e.data.name)+`; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;`+y({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`)).each(function(e){if(e.depth===0)return;let t=r(this),n=e.data.name;t.text(n);let i=e.x1-e.x0,a;a=c.showValues!==!1&&e.value?i-10-30-10-6:i-6-6;let o=Math.max(15,a),s=t.node();if(s.getComputedTextLength()>o){let e=n;for(;e.length>0;){if(e=n.substring(0,e.length-1),e.length===0){t.text(`...`),s.getComputedTextLength()>o&&t.text(``);break}if(t.text(e+`...`),s.getComputedTextLength()<=o)break}}}),c.showValues!==!1&&P.append(`text`).attr(`class`,`treemapSectionValue`).attr(`x`,e=>e.x1-e.x0-10).attr(`y`,$/2).attr(`text-anchor`,`end`).attr(`dominant-baseline`,`middle`).text(e=>e.value?E(e.value):``).attr(`font-style`,`italic`).attr(`style`,e=>e.depth===0?`display: none;`:`text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:`+k(e.data.name)+`; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;`+y({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`));let F=M.leaves(),I=F.length>20,L=I?16:38,z=I?14:28,B=I?4:8,V=I?4:6,H=I?2:4,U=I?8:10,W=I?1:2,G=A.selectAll(`.treemapLeafGroup`).data(F).enter().append(`g`).attr(`class`,(e,t)=>`treemapNode treemapLeafGroup leaf${t}${e.data.classSelector?` ${e.data.classSelector}`:``}x`).attr(`transform`,e=>`translate(${e.x0},${e.y0})`);G.append(`rect`).attr(`width`,e=>e.x1-e.x0).attr(`height`,e=>e.y1-e.y0).attr(`class`,`treemapLeaf`).attr(`fill`,e=>e.parent?D(e.parent.data.name):D(e.data.name)).attr(`style`,e=>y({cssCompiledStyles:e.data.cssCompiledStyles}).nodeStyles).attr(`fill-opacity`,.3).attr(`stroke`,e=>e.parent?D(e.parent.data.name):D(e.data.name)).attr(`stroke-width`,3),G.append(`clipPath`).attr(`id`,(e,t)=>`clip-${i}-${t}`).append(`rect`).attr(`width`,e=>Math.max(0,e.x1-e.x0-4)).attr(`height`,e=>Math.max(0,e.y1-e.y0-4)),G.append(`text`).attr(`class`,`treemapLabel`).attr(`x`,e=>(e.x1-e.x0)/2).attr(`y`,e=>(e.y1-e.y0)/2).attr(`style`,e=>`text-anchor: middle; dominant-baseline: middle; font-size: ${L}px;fill:`+k(e.data.name)+`;`+y({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`)).attr(`clip-path`,(e,t)=>`url(#clip-${i}-${t})`).text(e=>e.data.name).each(function(e){let t=r(this),n=e.x1-e.x0,i=e.y1-e.y0,a=t.node(),o=n-2*H,s=i-2*H;if(o<U||s<U){t.style(`display`,`none`);return}let c=parseInt(t.style(`font-size`),10),l=.6;for(;a.getComputedTextLength()>o&&c>B;)c--,t.style(`font-size`,`${c}px`);let u=Math.max(V,Math.min(z,Math.round(c*l))),d=c+W+u;for(;d>s&&c>B&&(c--,u=Math.max(V,Math.min(z,Math.round(c*l))),!(u<V&&c===B));)t.style(`font-size`,`${c}px`),d=c+W+u;t.style(`font-size`,`${c}px`),I?(c<B||s<B)&&t.style(`display`,`none`):(a.getComputedTextLength()>o||c<B||s<c)&&t.style(`display`,`none`)}),c.showValues!==!1&&G.append(`text`).attr(`class`,`treemapValue`).attr(`x`,e=>(e.x1-e.x0)/2).attr(`y`,function(e){return(e.y1-e.y0)/2}).attr(`style`,e=>`text-anchor: middle; dominant-baseline: hanging; font-size: ${z}px;fill:`+k(e.data.name)+`;`+y({cssCompiledStyles:e.data.cssCompiledStyles}).labelStyles.replace(`color:`,`fill:`)).attr(`clip-path`,(e,t)=>`url(#clip-${i}-${t})`).text(e=>e.value?E(e.value):``).each(function(e){let t=r(this),n=this.parentNode;if(!n){t.style(`display`,`none`);return}let i=r(n).select(`.treemapLabel`);if(i.empty()||i.style(`display`)===`none`){t.style(`display`,`none`);return}let a=parseFloat(i.style(`font-size`)),o=Math.max(V,Math.min(z,Math.round(a*.6)));t.style(`font-size`,`${o}px`);let s=(e.y1-e.y0)/2+a/2+W;t.attr(`y`,s);let c=e.x1-e.x0,l=e.y1-e.y0-4,u=c-2*H;t.node().getComputedTextLength()>u||s+o>l||o<V?t.style(`display`,`none`):t.style(`display`,null)});let K=c.diagramPadding??8;x(v,K,`flowchart`,c?.useMaxWidth||!1)},`draw`),getClasses:t(function(e,t){return t.db.getClasses()},`getClasses`)},ue={sectionStrokeColor:`black`,sectionStrokeWidth:`1`,sectionFillColor:`#efefef`,leafStrokeColor:`black`,leafStrokeWidth:`1`,leafFillColor:`#efefef`,labelFontSize:`12px`,valueFontSize:`10px`,titleFontSize:`14px`},de={parser:X,get db(){return new J},renderer:le,styles:t(({treemap:e}={})=>{let t=a(),n=m(),r=_(t,n.themeVariables),i=_(ue,e),o=i.titleColor??r.titleColor,s=i.labelColor??r.textColor,c=i.valueColor??r.textColor;return`
|
|
2
2
|
.treemapNode.section {
|
|
3
3
|
stroke: ${i.sectionStrokeColor};
|
|
4
4
|
stroke-width: ${i.sectionStrokeWidth};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./mermaid-parser.core-BrXnuEs7.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as n}from"./src-BWF7jMDv.js";import{C as r,H as i,U as a,_ as o,a as s,c,f as l,q as u,v as d,y as f}from"./chunk-DSNLSHJZ-CSSZ0uRv.js";import{i as p}from"./chunk-7S6XSTFO-v9BVbuJB.js";import{t as m}from"./chunk-JWPE2WC7-DVXcaiue.js";import{o as h}from"./mermaid-diagram-
|
|
1
|
+
import{n as e}from"./mermaid-parser.core-BrXnuEs7.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as n}from"./src-BWF7jMDv.js";import{C as r,H as i,U as a,_ as o,a as s,c,f as l,q as u,v as d,y as f}from"./chunk-DSNLSHJZ-CSSZ0uRv.js";import{i as p}from"./chunk-7S6XSTFO-v9BVbuJB.js";import{t as m}from"./chunk-JWPE2WC7-DVXcaiue.js";import{o as h}from"./mermaid-diagram-DHR-LEin.js";var g=l.packet,_=class{constructor(){this.packet=[],this.setAccTitle=a,this.getAccTitle=d,this.setDiagramTitle=u,this.getDiagramTitle=r,this.getAccDescription=o,this.setAccDescription=i}static{t(this,`PacketDB`)}getConfig(){let e=p({...g,...f().packet});return e.showBits&&(e.paddingY+=10),e}getPacket(){return this.packet}pushWord(e){e.length>0&&this.packet.push(e)}clear(){s(),this.packet=[]}},v=1e4,y=t((e,t)=>{m(e,t);let r=-1,i=[],a=1,{bitsPerRow:o}=t.getConfig();for(let{start:s,end:c,bits:l,label:u}of e.blocks){if(s!==void 0&&c!==void 0&&c<s)throw Error(`Packet block ${s} - ${c} is invalid. End must be greater than start.`);if(s??=r+1,s!==r+1)throw Error(`Packet block ${s} - ${c??s} is not contiguous. It should start from ${r+1}.`);if(l===0)throw Error(`Packet block ${s} is invalid. Cannot have a zero bit field.`);for(c??=s+(l??1)-1,l??=c-s+1,r=c,n.debug(`Packet block ${s} - ${r} with label ${u}`);i.length<=o+1&&t.getPacket().length<v;){let[e,n]=b({start:s,end:c,bits:l,label:u},a,o);if(i.push(e),e.end+1===a*o&&(t.pushWord(i),i=[],a++),!n)break;({start:s,end:c,bits:l,label:u}=n)}}t.pushWord(i)},`populate`),b=t((e,t,n)=>{if(e.start===void 0)throw Error(`start should have been set during first phase`);if(e.end===void 0)throw Error(`end should have been set during first phase`);if(e.start>e.end)throw Error(`Block start ${e.start} is greater than block end ${e.end}.`);if(e.end+1<=t*n)return[e,void 0];let r=t*n-1,i=t*n;return[{start:e.start,end:r,label:e.label,bits:r-e.start},{start:i,end:e.end,label:e.label,bits:e.end-i}]},`getNextFittingBlock`),x={parser:{yy:void 0},parse:t(async t=>{let r=await e(`packet`,t),i=x.parser?.yy;if(!(i instanceof _))throw Error(`parser.parser?.yy was not a PacketDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.`);n.debug(r),y(r,i)},`parse`)},S=t((e,t,n,r)=>{let i=r.db,a=i.getConfig(),{rowHeight:o,paddingY:s,bitWidth:l,bitsPerRow:u}=a,d=i.getPacket(),f=i.getDiagramTitle(),p=o+s,m=p*(d.length+1)-(f?0:o),g=l*u+2,_=h(t);_.attr(`viewBox`,`0 0 ${g} ${m}`),c(_,m,g,a.useMaxWidth);for(let[e,t]of d.entries())C(_,t,e,a);_.append(`text`).text(f).attr(`x`,g/2).attr(`y`,m-p/2).attr(`dominant-baseline`,`middle`).attr(`text-anchor`,`middle`).attr(`class`,`packetTitle`)},`draw`),C=t((e,t,n,{rowHeight:r,paddingX:i,paddingY:a,bitWidth:o,bitsPerRow:s,showBits:c,bitOrder:l})=>{let u=e.append(`g`),d=n*(r+a)+a,f=l===`descending`;for(let e of t){let t=e.end-e.start+1,n=e.start%s,a=(f?s-n-t:n)*o+1,l=t*o-i;if(u.append(`rect`).attr(`x`,a).attr(`y`,d).attr(`width`,l).attr(`height`,r).attr(`class`,`packetBlock`),u.append(`text`).attr(`x`,a+l/2).attr(`y`,d+r/2).attr(`class`,`packetLabel`).attr(`dominant-baseline`,`middle`).attr(`text-anchor`,`middle`).text(e.label),!c)continue;let[p,m]=f?[e.end,e.start]:[e.start,e.end],h=t===1,g=d-2;u.append(`text`).attr(`x`,a+(h?l/2:0)).attr(`y`,g).attr(`class`,`packetByte start`).attr(`dominant-baseline`,`auto`).attr(`text-anchor`,h?`middle`:`start`).text(p),h||u.append(`text`).attr(`x`,a+l).attr(`y`,g).attr(`class`,`packetByte end`).attr(`dominant-baseline`,`auto`).attr(`text-anchor`,`end`).text(m)}},`drawWord`),w={draw:S},T={byteFontSize:`10px`,startByteColor:`black`,endByteColor:`black`,labelColor:`black`,labelFontSize:`12px`,titleColor:`black`,titleFontSize:`14px`,blockStrokeColor:`black`,blockStrokeWidth:`1`,blockFillColor:`#efefef`},E={parser:x,get db(){return new _},renderer:w,styles:t(({packet:e}={})=>{let t=p(T,e);return`
|
|
2
2
|
.packetByte {
|
|
3
3
|
font-size: ${t.byteFontSize};
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./mermaid-parser.core-BrXnuEs7.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as n}from"./src-BWF7jMDv.js";import{C as r,H as i,U as a,_ as o,a as s,c,f as l,q as u,v as d,y as f,z as p}from"./chunk-DSNLSHJZ-CSSZ0uRv.js";import{i as m}from"./chunk-7S6XSTFO-v9BVbuJB.js";import{t as h}from"./chunk-JWPE2WC7-DVXcaiue.js";import{r as g,t as _}from"./chunk-YZO67HFG-DrH1RXFI.js";import{t as v}from"./chunk-2Q5K7J3B-C1jixKkw.js";import{o as y}from"./mermaid-diagram-
|
|
1
|
+
import{n as e}from"./mermaid-parser.core-BrXnuEs7.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as n}from"./src-BWF7jMDv.js";import{C as r,H as i,U as a,_ as o,a as s,c,f as l,q as u,v as d,y as f,z as p}from"./chunk-DSNLSHJZ-CSSZ0uRv.js";import{i as m}from"./chunk-7S6XSTFO-v9BVbuJB.js";import{t as h}from"./chunk-JWPE2WC7-DVXcaiue.js";import{r as g,t as _}from"./chunk-YZO67HFG-DrH1RXFI.js";import{t as v}from"./chunk-2Q5K7J3B-C1jixKkw.js";import{o as y}from"./mermaid-diagram-DHR-LEin.js";var b=/[─━│┃└┗├┣]/,x=/[└┗├┣]/,S=/[─━]/,C=/^[\s│┃]+$/,w=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,T=/^\s*%%/,E=` `;function D(e){return e.some(e=>b.test(e))}t(D,`isBoxDrawingFormat`);function O(e){for(let t of e){let e=x.exec(t);if(e?.index&&e.index>0)return e.index}return 4}t(O,`inferSegmentWidth`);function k(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(e,n)=>{let r=parseInt(n,10),i=t.get(r);return i?`line ${i}`:e})}t(k,`remapErrorLines`);function A(e){let t=e.split(`
|
|
2
2
|
`),n=new Map,r=-1;for(let[e,n]of t.entries())if(n.trim()===`treeView-beta`){r=e;break}if(r===-1)return{text:e,lineMap:n};let i=[];for(let e=r+1;e<t.length;e++){let n=t[e];n.trim()===``||T.test(n)||w.test(n)||C.test(n)||i.push(n.replace(/\t/g,` `))}if(!D(i))return{text:e,lineMap:n};let a=O(i),o=[],s=0;for(let e=0;e<=r;e++)o.push(t[e]),s++,n.set(s,e+1);for(let e=r+1;e<t.length;e++){let r=t[e],i=r.trim(),c=e+1;if(i===``||T.test(r)||w.test(r)){o.push(r),s++,n.set(s,c);continue}if(C.test(r))continue;let l=r.replace(/\t/g,` `),u=x.exec(l);if(u?.index!==void 0){let e=u.index,t=Math.round(e/a)+1,r=e+1;for(;r<l.length&&S.test(l[r]);)r++;for(;r<l.length&&l[r]===` `;)r++;let i=l.slice(r).trimEnd();if(!i)throw Error(`Line ${c}: Empty node \u2014 expected a filename or directory name after the box-drawing prefix`);let d=E.repeat(t);o.push(d+i),s++,n.set(s,c)}else if(/^[\s─━│┃└┗├┣]+$/.test(l))continue;else if(b.test(l))o.push(r),s++,n.set(s,c);else if(/^\s+/.test(l))throw Error(`Line ${c}: Unexpected indentation without box-drawing characters. In box-drawing format, use \u251C\u2500\u2500 or \u2514\u2500\u2500 prefixes for indented nodes.`);else o.push(r),s++,n.set(s,c)}return{text:o.join(`
|
|
3
3
|
`),lineMap:n}}t(A,`preprocessBoxDrawing`);var j=new v(()=>({cnt:1,stack:[{id:0,level:-1,name:`/`,nodeType:`directory`,children:[]}]})),M=t(()=>{j.reset(),s()},`clear`),N=t(()=>j.records.stack[0],`getRoot`),P=t(()=>j.records.cnt,`getCount`),F=l.treeView,I={clear:M,addNode:t((e,t,n,r,i,a)=>{for(;e<=j.records.stack[j.records.stack.length-1].level;)j.records.stack.pop();let o={id:j.records.cnt++,level:e,name:t,nodeType:n,icon:i,cssClass:r,description:a,children:[]};j.records.stack[j.records.stack.length-1].children.push(o),j.records.stack.push(o)},`addNode`),getRoot:N,getCount:P,getConfig:t(()=>m(F,f().treeView),`getConfig`),getAccTitle:d,getAccDescription:o,getDiagramTitle:r,setAccDescription:i,setAccTitle:a,setDiagramTitle:u},L=t(e=>{h(e,I);for(let t of e.nodes){let e=typeof t.indent==`number`?t.indent:0,n=t.name,r=n.endsWith(`/`);r&&(n=n.slice(0,-1));let i=r?`directory`:`file`,a=t.classAnnotation||void 0,o=t.iconAnnotation,s=o===void 0?void 0:o||`none`,c=t.descAnnotation||void 0,l=c?p(c,f()):void 0;I.addNode(e,n,i,a,s,l)}},`populate`),R={parse:t(async t=>{let{text:r,lineMap:i}=A(t);try{let t=await e(`treeView`,r);n.debug(t),L(t)}catch(e){throw i.size>0&&e instanceof Error&&(e.message=k(e.message,i)),e}},`parse`)},z={prefix:`mermaid-treeview`,height:24,width:24,icons:{folder:{body:`<path fill="currentColor" d="M10.59 4.59A2 2 0 0 0 9.17 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.17z"/>`},file:{body:`<path fill="currentColor" fill-rule="evenodd" d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8.83a2 2 0 0 0-.59-1.42l-4.82-4.82A2 2 0 0 0 13.17 2H6Zm7.5 1.9l4.6 4.6h-3.6a1 1 0 0 1-1-1V3.9Z" clip-rule="evenodd"/>`}}};function B(e,t){let n=t?.filenameIcons?.[e];if(n)return n;let r=e.lastIndexOf(`.`);if(r>0){let n=e.substring(r).toLowerCase(),i=t?.extensionIcons;return i?.[n]??i?.[n.slice(1)]}}t(B,`detectIcon`);function V(e,t){return e.includes(`:`)?e:e in z.icons||!t?`${z.prefix}:${e}`:`${t}:${e}`}t(V,`qualifyIcon`);function H(e,t){if(e.icon!==`none`){if(e.icon)return V(e.icon,t.defaultIconPack);if(t.showIcons){if(e.nodeType===`file`){let n=B(e.name,t);if(n===`none`)return;if(n)return V(n,t.defaultIconPack)}return`${z.prefix}:${e.nodeType===`directory`?`folder`:`file`}`}}}t(H,`getNodeIcon`),g([{name:z.prefix,icons:z}]);var U=14,W=4,G=16,K=t(async(e,n)=>{let r=[],i=t(e=>{let t=H(e,n);t&&r.push({icon:t,node:e}),e.children.forEach(i)},`collect`);i(e);let a=await Promise.all(r.map(async({icon:e,node:t})=>({id:t.id,svg:await _(e,{height:U,width:U})})));return new Map(a.map(({id:e,svg:t})=>[e,t]))},`resolveNodeIcons`),q=t((e,t,n,r,i,a)=>{let o=r.append(`g`),s=`treeView-node-label`;n.nodeType===`directory`&&(s+=` treeView-node-dir`),n.cssClass&&(s+=` ${n.cssClass}`);let c=U+W,l=H(n,i),u=l!==void 0;l&&o.append(`g`).attr(`class`,`treeView-node-icon`).attr(`transform`,`translate(${e+i.paddingX}, ${t+i.paddingY})`).html(a.get(n.id)??``);let d=o.append(`text`).text(n.name).attr(`dominant-baseline`,`middle`).attr(`class`,s),{height:f,width:p}=d.node().getBBox(),m=f+i.paddingY*2,h=e+i.paddingX+(u?c:0);d.attr(`x`,h),d.attr(`y`,t+m/2);let g=h+p;return n.BBox={x:e,y:t,width:p+i.paddingX*2+(u?c:0),height:m},n.cssClass?.split(/\s+/).includes(`highlight`)&&o.insert(`rect`,`:first-child`).attr(`x`,e).attr(`y`,t+1).attr(`width`,0).attr(`height`,m-2).attr(`rx`,3).attr(`class`,`treeView-highlight-bg`),{node:n,nodeGroup:o,labelRightEdge:g,centerY:t+m/2}},`positionLabel`),J=t((e,t,n,r,i,a)=>e.append(`line`).attr(`x1`,t).attr(`y1`,n).attr(`x2`,r).attr(`y2`,i).attr(`stroke-width`,a).attr(`class`,`treeView-node-line`),`positionLine`),Y=t((e,n,r,i)=>{let a=0,o=0,s=[],c=t((e,t,n,r)=>{let c=r*(n.rowIndent+n.paddingX),l=q(c,a,t,e,n,i);s.push(l);let{height:u,width:d}=t.BBox;J(e,c-n.rowIndent,a+u/2,c,a+u/2,n.lineThickness),o=Math.max(o,c+d),a+=u},`drawNode`),l=t((t,n=0)=>{c(e,t,r,n),t.children.forEach(e=>{l(e,n+1)});let{x:i,y:a,height:o}=t.BBox;if(t.children.length){let{y:n,height:s}=t.children[t.children.length-1].BBox;J(e,i+r.paddingX,a+o,i+r.paddingX,n+s/2+r.lineThickness/2,r.lineThickness)}},`processNode`);l(n);let u=s.filter(e=>e.node.description);if(u.length>0){let e=Math.max(...s.map(e=>e.labelRightEdge))+G;for(let t of u){let n=t.nodeGroup.append(`text`).text(t.node.description).attr(`dominant-baseline`,`middle`).attr(`class`,`treeView-node-description`).attr(`x`,e).attr(`y`,t.centerY).node().getBBox();o=Math.max(o,e+n.width+r.paddingX)}}for(let e of s)if(e.node.cssClass?.split(/\s+/).includes(`highlight`)){let t=e.nodeGroup.select(`.treeView-highlight-bg`);if(!t.empty()){let n=o-e.node.BBox.x+8;t.attr(`width`,n),o=Math.max(o,e.node.BBox.x+n+2)}}return{totalHeight:a,totalWidth:o}},`drawTree`),X={draw:t(async(e,t,r,i)=>{n.debug(`Rendering treeView diagram
|
|
4
4
|
`+e);let a=i.db,o=a.getRoot(),s=a.getConfig(),l=y(t),u=l.append(`g`);u.attr(`class`,`tree-view`);let{totalHeight:d,totalWidth:f}=Y(u,o,s,await K(o,s));l.attr(`viewBox`,`-${s.lineThickness/2} 0 ${f} ${d}`),c(l,d,f,s.useMaxWidth)},`draw`)},Z={labelFontSize:`16px`,labelColor:`black`,lineColor:`black`,iconColor:`#546e7a`,descriptionColor:`#6a9955`,highlightBg:`rgba(255, 193, 7, 0.15)`,highlightStroke:`#ffc107`},Q={db:I,renderer:X,parser:R,styles:t(({treeView:e})=>{let{labelFontSize:t,labelColor:n,lineColor:r,iconColor:i,descriptionColor:a,highlightBg:o,highlightStroke:s}=m(Z,e);return`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./mermaid-parser.core-BrXnuEs7.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as n}from"./src-BWF7jMDv.js";import{C as r,E as i,H as a,U as o,_ as s,a as c,c as l,f as u,q as d,v as f,y as p}from"./chunk-DSNLSHJZ-CSSZ0uRv.js";import{i as m}from"./chunk-7S6XSTFO-v9BVbuJB.js";import{t as h}from"./chunk-JWPE2WC7-DVXcaiue.js";import{o as g}from"./mermaid-diagram-
|
|
1
|
+
import{n as e}from"./mermaid-parser.core-BrXnuEs7.js";import{n as t}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as n}from"./src-BWF7jMDv.js";import{C as r,E as i,H as a,U as o,_ as s,a as c,c as l,f as u,q as d,v as f,y as p}from"./chunk-DSNLSHJZ-CSSZ0uRv.js";import{i as m}from"./chunk-7S6XSTFO-v9BVbuJB.js";import{t as h}from"./chunk-JWPE2WC7-DVXcaiue.js";import{o as g}from"./mermaid-diagram-DHR-LEin.js";var _={showLegend:!0,ticks:5,max:null,min:0,graticule:`circle`},v=32,y={axes:[],curves:[],options:_},b=structuredClone(y),x=u.radar,S=t(()=>m({...x,...p().radar}),`getConfig`),C=t(()=>b.axes,`getAxes`),w=t(()=>b.curves,`getCurves`),T=t(()=>b.options,`getOptions`),E=t(e=>{b.axes=e.map(e=>({name:e.name,label:e.label??e.name}))},`setAxes`),D=t(e=>{b.curves=e.map(e=>({name:e.name,label:e.label??e.name,entries:O(e.entries)}))},`setCurves`),O=t(e=>{if(e[0].axis==null)return e.map(e=>e.value);let t=C();if(t.length===0)throw Error(`Axes must be populated before curves for reference entries`);return t.map(t=>{let n=e.find(e=>e.axis?.$refText===t.name);if(n===void 0)throw Error(`Missing entry for axis `+t.label);return n.value})},`computeCurveEntries`),k={getAxes:C,getCurves:w,getOptions:T,setAxes:E,setCurves:D,setOptions:t(e=>{let t=e.reduce((e,t)=>(e[t.name]=t,e),{});b.options={showLegend:t.showLegend?.value??_.showLegend,ticks:t.ticks?.value??_.ticks,max:t.max?.value??_.max,min:t.min?.value??_.min,graticule:t.graticule?.value??_.graticule},b.options.ticks>v&&(n.warn(`Radar diagram ticks (${b.options.ticks}) exceeds maximum allowed (${v}). Using ${v} instead.`),b.options.ticks=v)},`setOptions`),getConfig:S,clear:t(()=>{c(),b=structuredClone(y)},`clear`),setAccTitle:o,getAccTitle:f,setDiagramTitle:d,getDiagramTitle:r,getAccDescription:s,setAccDescription:a},A=t(e=>{h(e,k);let{axes:t,curves:n,options:r}=e;k.setAxes(t),k.setCurves(n),k.setOptions(r)},`populate`),j={parse:t(async t=>{let r=await e(`radar`,t);n.debug(r),A(r)},`parse`)},M=t((e,t,n,r)=>{let i=r.db,a=i.getAxes(),o=i.getCurves(),s=i.getOptions(),c=i.getConfig(),l=i.getDiagramTitle(),u=N(g(t),c),d=s.max??Math.max(...o.map(e=>Math.max(...e.entries))),f=s.min,p=Math.min(c.width,c.height)/2;P(u,a,p,s.ticks,s.graticule),F(u,a,p,c),I(u,a,o,f,d,s.graticule,c),z(u,o,s.showLegend,c),u.append(`text`).attr(`class`,`radarTitle`).text(l).attr(`x`,0).attr(`y`,-c.height/2-c.marginTop)},`draw`),N=t((e,t)=>{let n=t.width+t.marginLeft+t.marginRight,r=t.height+t.marginTop+t.marginBottom,i={x:t.marginLeft+t.width/2,y:t.marginTop+t.height/2};return l(e,r,n,t.useMaxWidth??!0),e.attr(`viewBox`,`0 0 ${n} ${r}`).attr(`overflow`,`visible`),e.append(`g`).attr(`transform`,`translate(${i.x}, ${i.y})`)},`drawFrame`),P=t((e,t,n,r,i)=>{if(i===`circle`)for(let t=0;t<r;t++){let i=n*(t+1)/r;e.append(`circle`).attr(`r`,i).attr(`class`,`radarGraticule`)}else if(i===`polygon`){let i=t.length;for(let a=0;a<r;a++){let o=n*(a+1)/r,s=t.map((e,t)=>{let n=2*t*Math.PI/i-Math.PI/2;return`${o*Math.cos(n)},${o*Math.sin(n)}`}).join(` `);e.append(`polygon`).attr(`points`,s).attr(`class`,`radarGraticule`)}}},`drawGraticule`),F=t((e,t,n,r)=>{let i=t.length;for(let a=0;a<i;a++){let o=t[a].label,s=2*a*Math.PI/i-Math.PI/2,c=Math.cos(s),l=Math.sin(s);e.append(`line`).attr(`x1`,0).attr(`y1`,0).attr(`x2`,n*r.axisScaleFactor*c).attr(`y2`,n*r.axisScaleFactor*l).attr(`class`,`radarAxisLine`);let u=c>.01?`start`:c<-.01?`end`:`middle`,d=l>.01?`hanging`:l<-.01?`auto`:`central`;e.append(`text`).text(o).attr(`x`,n*r.axisLabelFactor*c+4*c).attr(`y`,n*r.axisLabelFactor*l+4*l).attr(`text-anchor`,u).attr(`dominant-baseline`,d).attr(`class`,`radarAxisLabel`)}},`drawAxes`);function I(e,t,n,r,i,a,o){let s=t.length,c=Math.min(o.width,o.height)/2;n.forEach((t,n)=>{if(t.entries.length!==s)return;let l=t.entries.map((e,t)=>{let n=2*Math.PI*t/s-Math.PI/2,a=L(e,r,i,c);return{x:a*Math.cos(n),y:a*Math.sin(n)}});a===`circle`?e.append(`path`).attr(`d`,R(l,o.curveTension)).attr(`class`,`radarCurve-${n}`):a===`polygon`&&e.append(`polygon`).attr(`points`,l.map(e=>`${e.x},${e.y}`).join(` `)).attr(`class`,`radarCurve-${n}`)})}t(I,`drawCurves`);function L(e,t,n,r){return r*(Math.min(Math.max(e,t),n)-t)/(n-t)}t(L,`relativeRadius`);function R(e,t){let n=e.length,r=`M${e[0].x},${e[0].y}`;for(let i=0;i<n;i++){let a=e[(i-1+n)%n],o=e[i],s=e[(i+1)%n],c=e[(i+2)%n],l={x:o.x+(s.x-a.x)*t,y:o.y+(s.y-a.y)*t},u={x:s.x-(c.x-o.x)*t,y:s.y-(c.y-o.y)*t};r+=` C${l.x},${l.y} ${u.x},${u.y} ${s.x},${s.y}`}return`${r} Z`}t(R,`closedRoundCurve`);function z(e,t,n,r){if(!n)return;let i=(r.width/2+r.marginRight)*3/4,a=-(r.height/2+r.marginTop)*3/4;t.forEach((t,n)=>{let r=e.append(`g`).attr(`transform`,`translate(${i}, ${a+n*20})`);r.append(`rect`).attr(`width`,12).attr(`height`,12).attr(`class`,`radarLegendBox-${n}`),r.append(`text`).attr(`x`,16).attr(`y`,0).attr(`class`,`radarLegendText`).text(t.label)})}t(z,`drawLegend`);var B={draw:M},V=t((e,t)=>{let n=``;for(let r=0;r<e.THEME_COLOR_LIMIT;r++){let i=e[`cScale${r}`];n+=`
|
|
2
2
|
.radarCurve-${r} {
|
|
3
3
|
color: ${i};
|
|
4
4
|
fill: ${i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as t,p as n}from"./src-BWF7jMDv.js";import{C as r,G as i,H as a,U as o,_ as s,a as c,at as l,b as u,d,et as f,q as p,s as m,v as h}from"./chunk-DSNLSHJZ-CSSZ0uRv.js";import{t as g}from"./channel-B8QjbMgK.js";import{_,c as v}from"./chunk-7S6XSTFO-v9BVbuJB.js";import"./chunk-YZO67HFG-DrH1RXFI.js";import"./chunk-AQDTSKZB-Bh2e4nVN.js";import{t as y}from"./chunk-5VM5RSS4-ZNzvKenW.js";import"./chunk-UHW7PFBP-FWZD9983.js";import{i as b,n as x,o as S,r as C}from"./chunk-J5ZVWO5B-oDCd-gWO.js";import{a as w}from"./chunk-HAGFOTED-CTCHAkn7.js";import"./chunk-ZAUX2LTX-slbBeHT4.js";import"./chunk-WQQL4CDK-V1ZC59EX.js";import{t as T}from"./chunk-55XCU76K-BdizGL-z.js";import{t as E}from"./chunk-XXDRQBXY-CnbRkih_.js";import{t as D}from"./chunk-VQ5W62QI-BxZNPUPp.js";import"./chunk-HNE4Q36P-SXol6mIL.js";import{a as O,i as k,n as A,r as j}from"./mermaid-diagram-
|
|
1
|
+
import{n as e}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as t,p as n}from"./src-BWF7jMDv.js";import{C as r,G as i,H as a,U as o,_ as s,a as c,at as l,b as u,d,et as f,q as p,s as m,v as h}from"./chunk-DSNLSHJZ-CSSZ0uRv.js";import{t as g}from"./channel-B8QjbMgK.js";import{_,c as v}from"./chunk-7S6XSTFO-v9BVbuJB.js";import"./chunk-YZO67HFG-DrH1RXFI.js";import"./chunk-AQDTSKZB-Bh2e4nVN.js";import{t as y}from"./chunk-5VM5RSS4-ZNzvKenW.js";import"./chunk-UHW7PFBP-FWZD9983.js";import{i as b,n as x,o as S,r as C}from"./chunk-J5ZVWO5B-oDCd-gWO.js";import{a as w}from"./chunk-HAGFOTED-CTCHAkn7.js";import"./chunk-ZAUX2LTX-slbBeHT4.js";import"./chunk-WQQL4CDK-V1ZC59EX.js";import{t as T}from"./chunk-55XCU76K-BdizGL-z.js";import{t as E}from"./chunk-XXDRQBXY-CnbRkih_.js";import{t as D}from"./chunk-VQ5W62QI-BxZNPUPp.js";import"./chunk-HNE4Q36P-SXol6mIL.js";import{a as O,i as k,n as A,r as j}from"./mermaid-diagram-DHR-LEin.js";var M={SHAPE_UNSUPPORTED:`SHAPE_UNSUPPORTED`,SHAPE_REMOVED:`SHAPE_REMOVED`,EDGE_OPERATOR_UNSUPPORTED:`EDGE_OPERATOR_UNSUPPORTED`,REFERENCE_EDGE_LABEL_REJECTED:`REFERENCE_EDGE_LABEL_REJECTED`,CONNECTOR_REF_UNRESOLVED:`CONNECTOR_REF_UNRESOLVED`,CONNECTOR_REF_NOT_A_CONNECTOR:`CONNECTOR_REF_NOT_A_CONNECTOR`,METADATA_KEY_MISAPPLIED:`METADATA_KEY_MISAPPLIED`,DUPLICATE_ID_NODE:`DUPLICATE_ID_NODE`,RESERVED_SYNTHETIC_ID:`RESERVED_SYNTHETIC_ID`,CONTAINMENT_VIOLATION:`CONTAINMENT_VIOLATION`,EDGE_SEMANTIC_CONTRADICTION:`EDGE_SEMANTIC_CONTRADICTION`,FLOW_NO_INPUT:`FLOW_NO_INPUT`},N=new Set([M.SHAPE_UNSUPPORTED,M.SHAPE_REMOVED,M.CONTAINMENT_VIOLATION]);new Set(Object.values(M).filter(e=>!N.has(e)));var P=new Map([[`task`,`roundedRect`],[`tool`,`subroutine`],[`input`,`lean-right`],[`decision`,`diamond`],[`refdoc`,`lin-doc`],[`action`,`hexagon`],[`round`,`rect`]]),ee=new Set(`doc.stadium.terminal.circle.trapezoid.inv_trapezoid.inv-trapezoid.doublecircle.double-circle.typeDeclaration.procs.lean_left.lean-left.in-out.cylinder.ellipse.odd.tag-rect.tagged-rectangle.delay.half-rounded-rectangle.lin-rect.lined-rectangle.win-pane.window-pane.curv-trap.curved-trapezoid`.split(`.`)),te=new Set([`roundedRect`,`subroutine`,`subprocess`,`subproc`,`framed-rectangle`,`lean-right`,`diamond`,`lin-doc`,`lined-document`,`hexagon`,`hex`,`connector`,`collapsedGroup`]),F=`roundedRect`;function I(e){return e&&(P.get(e)??e)}e(I,`resolveShapeAlias`);function ne(e,n){for(let r of e)if(!r.isGroup){if(r.shape&&r.shape!==`squareRect`&&r.shape!==`rect`||(r.shape=F),ee.has(r.shape)){let e=`shape "${r.shape}" was removed in v0.8.1, using "${F}"`;n?.emitError?n.emitError(`SHAPE_REMOVED`,e,{nodeId:r.id}):t.warn(`agentflow: ${e}`),r.shape=F}else if(!te.has(r.shape)){let e=`shape "${r.shape}" is not supported, using "${F}"`;n?.emitWarning?n.emitWarning(`SHAPE_UNSUPPORTED`,e,{nodeId:r.id}):t.warn(`agentflow: ${e}`),r.shape=F}}}e(ne,`normaliseNodeShapes`);var L=new Map([[`tool`,0],[`task`,1],[`decision`,2],[`input`,3],[`refdoc`,4],[`connector`,5],[`action`,6]]),R=L.size,z=e(e=>`af-kind-${e}`,`kindClass`),B=[...L.keys()],V=e(e=>Math.max(1,e-R),`containerSlotCount`),H=e((e,t)=>{let n=R+e%V(t);return t>0?n%t:n},`containerSlot`);function re(e,t,n){let r=u().themeVariables?.borderColorArray,i=Array.isArray(r)?r.length:0,a=n.size;for(let r of e??[]){if(r.isGroup||r.shape===`collapsedGroup`){r.colorIndex=H(n.get(String(r.id))??a++,i);continue}let e=t(String(r.id));e&&L.has(e)&&(r.cssClasses=`${r.cssClasses??``} ${z(e)}`.replace(/\s+/g,` `).trim())}}e(re,`assignColorSlots`);var ie=`agentflow-`,ae=new Set([`shape`,`view`,`icon`,`img`,`form`,`pos`,`w`,`h`,`class`,`style`,`labelType`]),oe=new Set([`subroutine`,`subprocess`,`subproc`,`framed-rectangle`,`tool`]),se={flow:`flowGroup`};function ce(e){if(Array.isArray(e))return e.map(e=>ce(e));if(typeof e!=`object`||!e)return e;let t={};for(let n of Object.keys(e))n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&(t[n]=ce(e[n]));return t}e(ce,`stripPrototypeKeys`);function le(e){let t=!1,n=!1,r=0,i,a=[];for(let o of e.split(`
|
|
2
2
|
`)){if(i!==void 0){let e=o.length-o.trimStart().length;if(o.trim()===``||e>i){a.push(o);continue}i=void 0}let e=-1;for(let i=0;i<o.length;i++){let a=o[i];if(n)a===`\\`?i++:a===`"`&&(n=!1);else if(t)a===`'`&&(t=!1);else if(a===`"`)n=!0;else if(a===`'`)t=!0;else if(a===`#`&&(i===0||o[i-1]===` `||o[i-1]===` `)){e=i;break}else a===`[`||a===`{`?r++:(a===`]`||a===`}`)&&(r=Math.max(0,r-1))}if(t||n||r>0){a.push(o);continue}let s=e>=0?o.slice(0,e):o,c=e>=0?o.slice(e):``;/:\s*[>|][\d+-]*\s*$/.test(s)?(i=o.length-o.trimStart().length,a.push(o)):a.push(s.replace(/,([\t ]*)$/,`$1`)+c)}return a.join(`
|
|
3
3
|
`)}e(le,`stripLineTrailingCommas`);var ue=class{constructor(){this.vertexCounter=0,this.config=u(),this.vertices=new Map,this.edges=[],this.classes=new Map,this.subGraphs=[],this.subGraphLookup=new Map,this.globalNodes=new Set,this.connectors=new Map,this.tooltips=new Map,this.subCount=0,this.firstGraphFlag=!0,this.secCount=-1,this.posCrossRef=[],this.diagramId=``,this.preserveCommentsWhenParsing=!0,this.frontmatterLineOffset=0,this.elementMappings=[],this.bareVertexMappings=new WeakSet,this.diagnostics=[],this.postParseValidationRun=!1,this.funs=[],this.setAccTitle=o,this.setAccDescription=a,this.setDiagramTitle=p,this.getAccTitle=h,this.getAccDescription=s,this.getDiagramTitle=r,this.funs.push(this.setupToolTips.bind(this)),this.addVertex=this.addVertex.bind(this),this.firstGraph=this.firstGraph.bind(this),this.setDirection=this.setDirection.bind(this),this.addSubGraph=this.addSubGraph.bind(this),this.addGlobal=this.addGlobal.bind(this),this.addConnector=this.addConnector.bind(this),this.addConnectorMapping=this.addConnectorMapping.bind(this),this.addLink=this.addLink.bind(this),this.setLink=this.setLink.bind(this),this.updateLink=this.updateLink.bind(this),this.addClass=this.addClass.bind(this),this.setClass=this.setClass.bind(this),this.destructLink=this.destructLink.bind(this),this.setClickEvent=this.setClickEvent.bind(this),this.setTooltip=this.setTooltip.bind(this),this.updateLinkInterpolate=this.updateLinkInterpolate.bind(this),this.setClickFun=this.setClickFun.bind(this),this.bindFunctions=this.bindFunctions.bind(this),this.setFrontmatterLineOffset=this.setFrontmatterLineOffset.bind(this),this.addVertexMapping=this.addVertexMapping.bind(this),this.extendVertexMapping=this.extendVertexMapping.bind(this),this.addEdgeMapping=this.addEdgeMapping.bind(this),this.addSubgraphMapping=this.addSubgraphMapping.bind(this),this.emitWarning=this.emitWarning.bind(this),this.emitError=this.emitError.bind(this),this.getDiagnostics=this.getDiagnostics.bind(this),this.lex={firstGraph:this.firstGraph.bind(this)},this.clear(),this.setGen(`gen-2`)}static{e(this,`AgentFlowDB`)}sanitizeText(e){return m.sanitizeText(e,this.config)}sanitizeNodeLabelType(e){switch(e){case`markdown`:case`string`:case`text`:return e;default:return`markdown`}}setDiagramId(e){this.diagramId=e}lookUpDomId(e){for(let t of this.vertices.values())if(t.id===e)return this.diagramId?`${this.diagramId}-${t.domId}`:t.domId;return this.diagramId?`${this.diagramId}-${e}`:e}addVertex(e,t,n,r,i,a,o={},s,c){if(!e||e.trim().length===0)return;let l;if(s!==void 0){let e;e=s.includes(`
|
|
4
4
|
`)?s+`
|