@codeyam-editor/codeyam-editor 0.1.6 → 0.1.7
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/npm/cloud.js +192 -29
- package/npm/compose-conflict.js +59 -0
- package/npm/fleet-add-failure.js +123 -14
- package/npm/fleet-cleanup.js +129 -0
- package/npm/fleet-job-badge.js +28 -12
- package/npm/fleet-memory.js +44 -0
- package/npm/fleet-probe-transport.js +155 -0
- package/npm/fleet-revision.js +104 -0
- package/npm/fleet-running-plan.js +37 -7
- package/npm/launch-config.js +120 -4
- package/npm/scenario-check.js +52 -18
- package/npm/scenario-playwright.js +44 -10
- package/package.json +5 -5
- package/ui/dist/assets/{ContainerInspector-DgM0pTAx.js → ContainerInspector-Cu1tSN-o.js} +1 -1
- package/ui/dist/assets/EditorShell--V2ExYQ6.js +260 -0
- package/ui/dist/assets/ProjectLauncherScreen-Dmm6Z0mv.js +1 -0
- package/ui/dist/assets/ScenarioDataPanel-DjprZq2L.js +9 -0
- package/ui/dist/assets/{ScenarioDataPanelFullPage-BLqRCxQX.js → ScenarioDataPanelFullPage-BqMxWVKW.js} +1 -1
- package/ui/dist/assets/ScenarioRenderer-DqLVVMYS.js +21 -0
- package/ui/dist/assets/index-CjxWhkSy.css +1 -0
- package/ui/dist/assets/{index-DCHqRrwO.js → index-VuyqBbGJ.js} +2 -2
- package/ui/dist/assets/useServerIdentity-BdXy8TQv.js +1 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/EditorShell-B7Q06uJ_.js +0 -252
- package/ui/dist/assets/ProjectLauncherScreen-BRrEr8Ng.js +0 -1
- package/ui/dist/assets/ScenarioDataPanel-BeQfa28g.js +0 -9
- package/ui/dist/assets/ScenarioRenderer-CIAxfHPh.js +0 -21
- package/ui/dist/assets/index-BygCiJSb.css +0 -1
- package/ui/dist/assets/useServerIdentity-B7rI0u3O.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./markdown-C9tbsVHX.js";import{b as o}from"./react-nrLBr15I.js";import{C as _,a as ce,c as le}from"./useServerIdentity-BdXy8TQv.js";function ie(t){return t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function de(t){if(!t)return{base:null,sep:"/"};const r=t.lastIndexOf("/"),n=t.lastIndexOf("\\"),a=Math.max(r,n);if(a<0)return{base:null,sep:"/"};const c=a===n?"\\":"/";return{base:t.slice(0,a),sep:c}}function R({suggestedNewProjectPath:t,creating:r=!1,createError:n=null,onCreate:a,onClose:c}){const[i,x]=o.useState(""),[l,f]=o.useState(""),j=o.useRef(!1),{base:y,sep:m}=de(t),p=y?`${y}${m}`:"",w=`${p}${ie(i)}`,g=j.current?l:w;o.useEffect(()=>{const b=S=>{S.key==="Escape"&&!r&&c()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[r,c]);const h=b=>{j.current=!0,f(b)},N=()=>{const b=i.trim(),S=g.trim();b.length>0&&S.length>0&&!r&&a(S,b)},P=i.trim().length>0&&!r;return e.jsx("div",{role:"presentation",onClick:()=>{r||c()},className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 px-6 backdrop-blur-sm",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create your first project",onClick:b=>b.stopPropagation(),className:"w-full max-w-md rounded-xl border border-[var(--border-default)] bg-[var(--bg-elevated,#141414)] p-6 text-[var(--text-primary)] shadow-2xl",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:"Create your first project"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--text-muted)]",children:"Name your project and choose where it lives. CodeYam will scaffold it and walk you through the rest."}),e.jsxs("label",{className:"mt-5 block text-xs font-medium text-[var(--text-secondary)]",children:["Project name",e.jsx("input",{type:"text",autoFocus:!0,value:i,onChange:b=>x(b.target.value),onKeyDown:b=>{b.key==="Enter"&&N()},placeholder:"My First App","aria-label":"Project name",className:"mt-1 w-full rounded border border-[var(--border-default)] bg-[var(--bg-input)] px-3 py-2 text-sm font-normal text-[var(--text-primary)] placeholder:text-[var(--text-dim)] focus:border-[var(--accent-active)] focus:outline-none"})]}),e.jsxs("label",{className:"mt-4 block text-xs font-medium text-[var(--text-secondary)]",children:["Location",e.jsx("input",{type:"text",value:g,onChange:b=>h(b.target.value),onKeyDown:b=>{b.key==="Enter"&&N()},placeholder:p||"/path/to/new/project","aria-label":"Project location",className:"mt-1 w-full rounded border border-[var(--border-default)] bg-[var(--bg-input)] px-3 py-2 font-mono text-sm font-normal text-[var(--text-primary)] placeholder:text-[var(--text-dim)] focus:border-[var(--accent-active)] focus:outline-none"})]}),n&&e.jsx("div",{className:"mt-3",children:e.jsx(_,{text:n,className:"whitespace-pre-line text-xs text-[var(--accent-red)]"})}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:c,disabled:r,className:"rounded border border-[var(--border-default)] px-4 py-2 text-sm text-[var(--text-secondary)] transition hover:text-[var(--text-primary)] disabled:cursor-not-allowed disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",onClick:N,disabled:!P,className:"rounded bg-[var(--accent-active)] px-4 py-2 text-sm font-semibold text-[var(--bg-deep)] transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40",children:r?"Creating…":"Create Project"})]})]})})}const ve=Object.freeze(Object.defineProperty({__proto__:null,CreateProjectModal:R},Symbol.toStringTag,{value:"Module"}));function I({projects:t,onClone:r,cloningRepoUrl:n=null,cloneError:a=null,defaultOpen:c=!1}){const[i,x]=o.useState(c),l=i||n!==null||a!==null;return e.jsxs("div",{className:"mt-6",children:[e.jsxs("button",{type:"button",onClick:()=>x(f=>!f),"aria-expanded":l,className:"flex w-full items-center justify-between rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] px-4 py-3 text-left transition hover:border-[var(--accent-active)]",children:[e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:"Open Source Projects"}),e.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:l?"▾":"▸"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-2 px-1 text-xs text-[var(--text-muted)]",children:"Clone one of codeyam's showcase apps and open it in the editor — nothing to configure."}),e.jsx("ul",{className:"mt-2 flex flex-col gap-3",children:t.map(f=>e.jsx(U,{project:f,busy:n===f.repoUrl,onClone:r},f.slug))}),a&&e.jsx("div",{role:"alert",className:"mt-3 rounded-lg border border-[var(--accent-red)]/40 bg-[var(--bg-card)] px-4 py-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 whitespace-pre-line font-mono text-xs text-[var(--accent-red)]",children:a}),e.jsx(ce,{variant:"subtle",text:a,label:"Copy"})]})})]})]})}function U({project:t,busy:r,onClone:n}){const{name:a,description:c,repoUrl:i,thumbnail:x}=t;return e.jsxs("li",{className:"flex items-center justify-between gap-4 rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(B,{src:x,name:a,size:"h-24 w-20"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium text-[var(--text-primary)]",children:a}),e.jsx("div",{className:"mt-1 text-xs text-[var(--text-muted)]",children:c})]})]}),e.jsx("button",{type:"button",disabled:r,onClick:()=>n(i),className:"shrink-0 rounded bg-[var(--accent-active)] px-3 py-1.5 text-sm font-medium text-[var(--bg-deep)] transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40",children:r?"Cloning…":"Clone & Open"})]})}const je=Object.freeze(Object.defineProperty({__proto__:null,OpenSourceProjectRow:U,OpenSourceProjectsSection:I},Symbol.toStringTag,{value:"Module"})),ue=[{slug:"tabcommand",name:"TabCommand",description:"A Chrome extension dashboard to control your browser (React + Vite, Manifest V3).",repoUrl:"https://github.com/codeyam-ai/tabcommand",thumbnail:"/open-source/tabcommand.png",thumbnailSource:{repo:"tabcommand",scenario:"home-grouped",dimension:"desktop"}},{slug:"codeyam-counter",name:"CodeYam Counter",description:"A native SwiftUI iOS counter app with a shared AppCore SwiftPM library.",repoUrl:"https://github.com/codeyam-ai/codeyam-counter",thumbnail:"/open-source/codeyam-counter.png",thumbnailSource:{repo:"codeyam-counter",scenario:"counter-active-count",dimension:"iphone-16"}},{slug:"el-carot",name:"El Carot",description:"AI-powered tarot readings through a one-of-a-kind deck (Next.js + Prisma + Anthropic API).",repoUrl:"https://github.com/codeyam-ai/el-carot",thumbnail:"/open-source/el-carot.png",thumbnailSource:{repo:"el-carot",scenario:"landing-english",dimension:"mobile"}}];function z(t){const r=t.filter(a=>a.isCurrent),n=t.filter(a=>!a.isCurrent);return[...r,...n]}function H({projects:t,loading:r=!1,error:n=null,openError:a=null,busyPath:c=null,onOpen:i,onStop:x,onScan:l,scanning:f=!1,scanResult:j=null,scanError:y=null,onCreate:m,creating:p=!1,createError:w=null,suggestedNewProjectPath:g=null,bootstrapping:h=!1,onClone:N,cloningRepoUrl:P=null,cloneError:b=null}){const[S,E]=o.useState(!1),{version:k}=le(),L=!r&&!n&&t.length===0,T=!!m&&!(L&&m);return e.jsxs("div",{className:"flex min-h-screen flex-col items-center bg-[var(--bg-deep)] px-6 py-16 text-[var(--text-primary)]",children:[e.jsxs("div",{className:"w-full max-w-2xl",children:[e.jsx(D,{}),T&&m&&e.jsx(K,{onCreate:m,creating:p,createError:w,suggestedNewProjectPath:g}),l&&e.jsx(Y,{onScan:l,scanning:f,scanResult:j,scanError:y}),h&&e.jsx(V,{}),a&&e.jsx(Z,{message:a}),r?e.jsx(Q,{}):n?e.jsx(X,{message:n}):t.length===0?e.jsx(ee,{onScan:l,scanning:f,onCreateFirst:m?()=>E(!0):void 0}):e.jsx("ul",{className:"flex flex-col gap-3",children:z(t).map(O=>e.jsx(J,{project:O,busy:c===O.path,onOpen:i,onStop:x},O.path))}),N&&e.jsx(I,{projects:ue,onClone:N,cloningRepoUrl:P,cloneError:b,defaultOpen:t.length===0}),k&&e.jsxs("div",{"data-testid":"launcher-version",className:"mt-8 text-center text-xs text-[var(--text-dim)]",children:["codeyam-editor v",k]})]}),S&&m&&e.jsx(R,{suggestedNewProjectPath:g,creating:p,createError:w,onCreate:m,onClose:()=>E(!1)})]})}function J({project:t,busy:r,onOpen:n,onStop:a}){const{name:c,path:i,exists:x,running:l,controlPort:f,tests:j,thumbnailUrl:y,isCurrent:m,protected:p}=t;return e.jsxs("li",{className:`flex items-center justify-between gap-4 rounded-lg border bg-[var(--bg-card)] px-4 py-3 ${m?"border-[var(--accent-active)]":"border-[var(--border-default)]"} ${x?"":"opacity-60"}`,children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(B,{src:x&&!p?y:null,name:c}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-[var(--text-primary)]",children:c}),m&&e.jsx(q,{}),l&&e.jsx(G,{controlPort:f})]}),e.jsx("div",{className:"truncate text-xs text-[var(--text-dim)]",title:i,children:i}),p?e.jsx("div",{className:"mt-1 text-xs text-[var(--text-dim)]",children:"OS-protected location — not scanned in the background"}):x?e.jsx(xe,{tests:j}):e.jsx("div",{className:"mt-1 text-xs text-[var(--accent-orange)]",children:"Folder missing — moved or deleted"})]})]}),e.jsx(W,{path:i,exists:x,running:l,busy:r,isCurrent:m,onOpen:n,onStop:a})]})}function D(){return e.jsxs("header",{className:"mb-8",children:[e.jsx("h1",{className:"text-2xl font-semibold text-[var(--text-primary)]",children:"Your projects"}),e.jsx("p",{className:"mt-1 text-sm text-[var(--text-muted)]",children:"Pick a project to open in the editor, or stop one that's running."})]})}function K({onCreate:t,creating:r=!1,createError:n=null,suggestedNewProjectPath:a=null,defaultOpen:c=!1}){const[i,x]=o.useState(c),[l,f]=o.useState(""),[j,y]=o.useState(""),m=o.useRef(!1);o.useEffect(()=>{m.current||a&&l===""&&f(a)},[a,l]);const p=h=>{m.current=!0,f(h)};if(!(i||r||n!==null))return e.jsx("div",{className:"mb-3",children:e.jsx("button",{type:"button",onClick:()=>x(!0),className:"text-sm text-[var(--text-secondary)] underline-offset-2 transition hover:text-[var(--text-primary)] hover:underline",children:"+ New project…"})});const g=()=>{const h=l.trim();h.length>0&&!r&&t(h,j.trim())};return e.jsxs("div",{className:"mb-3 rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:l,onChange:h=>p(h.target.value),onKeyDown:h=>{h.key==="Enter"&&g()},placeholder:"/path/to/new/project","aria-label":"Folder for the new project",className:"min-w-0 flex-1 rounded border border-[var(--border-default)] bg-[var(--bg-input)] px-3 py-1.5 text-sm text-[var(--text-primary)] placeholder:text-[var(--text-dim)] focus:border-[var(--accent-active)] focus:outline-none"}),e.jsx("button",{type:"button",disabled:r||l.trim().length===0,onClick:g,className:"shrink-0 rounded bg-[var(--accent-active)] px-3 py-1.5 text-sm font-medium text-[var(--bg-deep)] transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40",children:r?"Creating…":"Create"})]}),e.jsx("input",{type:"text",value:j,onChange:h=>y(h.target.value),onKeyDown:h=>{h.key==="Enter"&&g()},placeholder:"Project name (optional)","aria-label":"Project name (optional)",className:"mt-2 w-full rounded border border-[var(--border-default)] bg-[var(--bg-input)] px-3 py-1.5 text-sm text-[var(--text-primary)] placeholder:text-[var(--text-dim)] focus:border-[var(--accent-active)] focus:outline-none"}),n&&e.jsx("div",{className:"mt-2",children:e.jsx(_,{text:n,className:"whitespace-pre-line text-xs text-[var(--accent-red)]"})})]})}function Y({onScan:t,scanning:r=!1,scanResult:n=null,scanError:a=null}){const[c,i]=o.useState(!1),[x,l]=o.useState(""),[f,j]=o.useState(!0);if(!(c||r||n!==null||a!==null))return e.jsx("div",{className:"mb-6",children:e.jsx("button",{type:"button",onClick:()=>i(!0),className:"text-sm text-[var(--text-secondary)] underline-offset-2 transition hover:text-[var(--text-primary)] hover:underline",children:"+ Add projects from a folder…"})});const m=()=>{const p=x.trim();p.length>0&&!r&&t(p,f)};return e.jsxs("div",{className:"mb-6 rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] px-4 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:x,onChange:p=>l(p.target.value),onKeyDown:p=>{p.key==="Enter"&&m()},placeholder:"/path/to/your/workspace","aria-label":"Folder to scan for projects",className:"min-w-0 flex-1 rounded border border-[var(--border-default)] bg-[var(--bg-input)] px-3 py-1.5 text-sm text-[var(--text-primary)] placeholder:text-[var(--text-dim)] focus:border-[var(--accent-active)] focus:outline-none"}),e.jsx("button",{type:"button",disabled:r||x.trim().length===0,onClick:m,className:"shrink-0 rounded bg-[var(--accent-active)] px-3 py-1.5 text-sm font-medium text-[var(--bg-deep)] transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40",children:r?"Scanning…":"Scan"})]}),e.jsxs("label",{className:"mt-2 flex items-center gap-2 text-xs text-[var(--text-muted)]",children:[e.jsx("input",{type:"checkbox",checked:f,onChange:p=>j(p.target.checked)}),"Remember this folder and re-scan it next time"]}),a&&e.jsx(_,{text:a,className:"text-xs text-[var(--accent-red)]",rowClassName:"mt-2"}),n&&!a&&e.jsxs("div",{className:"mt-2 text-xs text-[var(--accent-green)]",children:["Found ",n.found," project",n.found===1?"":"s",", ",n.added," new"]}),(n==null?void 0:n.note)&&!a&&e.jsx("div",{className:"mt-1 text-xs text-[var(--text-dim)]",children:n.note})]})}function V(){return e.jsx("div",{className:"mb-6 rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] px-4 py-3 text-sm text-[var(--text-muted)]",children:"Looking for your projects…"})}function W({path:t,exists:r,running:n,busy:a,isCurrent:c=!1,onOpen:i,onStop:x}){const l=a?"Opening…":c?"Open this project":n?"Reopen":"Open";return e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n&&r&&e.jsx("button",{type:"button",disabled:a,onClick:()=>x(t),className:"rounded border border-[var(--border-default)] px-3 py-1.5 text-sm text-[var(--text-secondary)] transition hover:border-[var(--accent-red)] hover:text-[var(--accent-red)] disabled:cursor-not-allowed disabled:opacity-50",children:a?"Stopping…":"Stop"}),e.jsx("button",{type:"button",disabled:!r||a,onClick:()=>i(t),className:"rounded bg-[var(--accent-active)] px-3 py-1.5 text-sm font-medium text-[var(--bg-deep)] transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40",children:l})]})}function q(){return e.jsx("span",{className:"inline-flex items-center rounded-full bg-[var(--accent-active)]/15 px-2 py-0.5 text-xs font-medium text-[var(--accent-active)]",children:"Current"})}function B({src:t,name:r,size:n="h-12 w-16"}){const[a,c]=o.useState(!1);o.useEffect(()=>{c(!1)},[t]);const i=!!t&&!a;return e.jsx("div",{className:`flex ${n} shrink-0 items-center justify-center overflow-hidden rounded border border-[var(--border-subtle)] bg-[var(--bg-surface)]`,children:i?e.jsx("img",{src:t??void 0,alt:`${r} preview`,className:"max-h-full max-w-full object-contain",onError:()=>c(!0)}):e.jsx("div",{className:"flex h-full w-full items-center justify-center text-[10px] text-[var(--text-dim)]",children:"no preview"})})}function xe({tests:t}){return!t||t.total===0?e.jsx("div",{className:"mt-1 text-xs text-[var(--text-dim)]",children:"No tests yet"}):e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs",children:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:[t.total," tests"]}),t.passed>0&&e.jsxs("span",{className:"text-[var(--accent-green)]",children:[t.passed," passed"]}),t.failed>0&&e.jsxs("span",{className:"text-[var(--accent-red)]",children:[t.failed," failed"]})]})}function G({controlPort:t}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-[var(--accent-green)]/15 px-2 py-0.5 text-xs text-[var(--accent-green)]",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--accent-green)]"}),"running",t?` · :${t}`:""]})}function Q(){return e.jsx("div",{className:"rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] px-4 py-6 text-sm text-[var(--text-muted)]",children:"Loading projects…"})}function X({message:t}){return e.jsx("div",{className:"rounded-lg border border-[var(--accent-red)]/40 bg-[var(--bg-card)] px-4 py-6",children:e.jsx(_,{text:`Couldn't load projects: ${t}`,className:"whitespace-pre-line text-sm text-[var(--accent-red)]"})})}function Z({message:t}){return e.jsx("div",{className:"mb-3 rounded-lg border border-[var(--accent-red)]/40 bg-[var(--bg-card)] px-4 py-3",children:e.jsx(_,{text:t,className:"whitespace-pre-line font-mono text-xs text-[var(--accent-red)]"})})}function ee({onScan:t,scanning:r=!1,onCreateFirst:n}={}){return n?e.jsxs("div",{className:"flex flex-col items-center rounded-lg border border-[var(--border-default)] bg-[var(--bg-card)] px-6 py-16 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold text-[var(--text-primary)]",children:"Create Your First Project"}),e.jsx("p",{className:"mt-2 max-w-sm text-sm text-[var(--text-muted)]",children:"CodeYam will walk you through creating your first project. You just need an idea to get started"}),e.jsx("button",{type:"button",onClick:n,className:"mt-6 rounded bg-[var(--accent-active)] px-5 py-2.5 text-sm font-semibold text-[var(--bg-deep)] transition hover:opacity-90",children:"Create Project"})]}):e.jsx("div",{className:"rounded-lg border border-dashed border-[var(--border-default)] bg-[var(--bg-card)] px-4 py-10 text-center",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:t?e.jsxs(e.Fragment,{children:["No projects yet."," ",r?"Scanning for projects…":"Add a folder above to scan for projects already on disk, or run"," ",!r&&e.jsx("code",{className:"rounded bg-[var(--bg-input)] px-1.5 py-0.5 text-xs text-[var(--text-secondary)]",children:"codeyam-editor init"}),!r&&" in a project folder."]}):e.jsxs(e.Fragment,{children:["No projects yet. Run"," ",e.jsx("code",{className:"rounded bg-[var(--bg-input)] px-1.5 py-0.5 text-xs text-[var(--text-secondary)]",children:"codeyam-editor init"})," ","in a project folder to get started."]})})})}const ye=Object.freeze(Object.defineProperty({__proto__:null,CurrentBadge:q,ProjectBootstrapBanner:V,ProjectCreateForm:K,ProjectLauncher:H,ProjectLauncherEmpty:ee,ProjectLauncherError:X,ProjectLauncherHeader:D,ProjectLauncherLoading:Q,ProjectOpenError:Z,ProjectRow:J,ProjectRowActions:W,ProjectScanForm:Y,RunningBadge:G,Thumbnail:B,sortCurrentFirst:z},Symbol.toStringTag,{value:"Module"})),me=3e3,$=305e3;async function A(t,r,n){const a=new AbortController,c=setTimeout(()=>a.abort(),n);try{return await fetch(t,{...r,signal:a.signal})}finally{clearTimeout(c)}}function M(t,r){return t instanceof DOMException&&t.name==="AbortError"?"Opening timed out — the project may not be responding.":t instanceof Error?t.message:r}function pe(){const[t,r]=o.useState(null),[n,a]=o.useState(null),[c,i]=o.useState(null),[x,l]=o.useState(null),[f,j]=o.useState(!1),[y,m]=o.useState(null),[p,w]=o.useState(null),[g,h]=o.useState(!1),[N,P]=o.useState(null),[b,S]=o.useState(!1),[E,k]=o.useState(null),[L,T]=o.useState(null),[O,te]=o.useState(null),C=o.useCallback(async()=>{try{const d=await fetch("/api/projects");if(!d.ok)throw new Error(`HTTP ${d.status}`);const s=await d.json();r(Array.isArray(s.projects)?s.projects:[]),te(typeof s.suggestedNewProjectPath=="string"?s.suggestedNewProjectPath:null),a(null)}catch(d){a(d instanceof Error?d.message:"Failed to load projects")}},[]),F=o.useCallback(async()=>{try{const d=await fetch("/api/projects/scan-status");if(!d.ok)return;const u=!!(await d.json()).running;S(v=>(v&&!u&&C(),u))}catch{}},[C]);o.useEffect(()=>{C(),F();const d=setInterval(()=>{document.visibilityState==="visible"&&(C(),F())},me),s=()=>{document.visibilityState==="visible"&&(C(),F())};return document.addEventListener("visibilitychange",s),()=>{clearInterval(d),document.removeEventListener("visibilitychange",s)}},[C,F]);const re=o.useCallback(async(d,s)=>{j(!0),w(null),m(null);try{const u=await fetch("/api/projects/scan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({root:d,remember:s})}),v=await u.json().catch(()=>({}));if(!u.ok)throw new Error(typeof v.error=="string"?v.error:`HTTP ${u.status}`);r(Array.isArray(v.projects)?v.projects:[]),m({found:v.found??0,added:v.added??0,note:typeof v.note=="string"?v.note:void 0})}catch(u){w(u instanceof Error?u.message:"Scan failed")}finally{j(!1)}},[]),ae=o.useCallback(async(d,s)=>{h(!0),P(null);try{const u=await A("/api/projects/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s?{path:d,name:s}:{path:d})},$),v=await u.json().catch(()=>({}));if(!u.ok)throw new Error(typeof v.error=="string"?v.error:`HTTP ${u.status}`);if(typeof v.url=="string"){window.location.href=v.url;return}throw new Error("create did not return a url")}catch(u){P(M(u,"Failed to create project")),h(!1)}},[]),ne=o.useCallback(async d=>{k(d),T(null);try{const s=await A("/api/projects/clone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repoUrl:d})},$),u=await s.json().catch(()=>({}));if(!s.ok)throw new Error(typeof u.error=="string"?u.error:`HTTP ${s.status}`);if(typeof u.url=="string"){window.location.href=u.url;return}throw new Error("clone did not return a url")}catch(s){T(M(s,"Failed to clone project")),k(null)}},[]),oe=o.useCallback(async d=>{l(d),i(null);try{const s=await A("/api/projects/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d})},$),u=await s.json().catch(()=>({}));if(!s.ok)throw new Error(typeof u.error=="string"?u.error:`HTTP ${s.status}`);const{url:v}=u;if(typeof v=="string"){window.location.href=v;return}throw new Error("open did not return a url")}catch(s){i(M(s,"Failed to open project")),l(null)}},[]),se=o.useCallback(async d=>{l(d);try{const s=await fetch("/api/projects/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d})});if(!s.ok)throw new Error(`HTTP ${s.status}`);await C()}catch(s){a(s instanceof Error?s.message:"Failed to stop project")}finally{l(null)}},[C]);return e.jsx(H,{projects:t??[],loading:t===null&&n===null,error:n,openError:c,busyPath:x,onOpen:oe,onStop:se,onScan:re,scanning:f,scanResult:y,scanError:p,onCreate:ae,creating:g,createError:N,suggestedNewProjectPath:O,bootstrapping:b,onClone:ne,cloningRepoUrl:E,cloneError:L})}const ge=Object.freeze(Object.defineProperty({__proto__:null,ProjectLauncherScreen:pe},Symbol.toStringTag,{value:"Module"}));export{R as C,U as O,pe as P,G as R,B as T,ge as _,I as a,Z as b,ee as c,X as d,Q as e,D as f,q as g,V as h,K as i,Y as j,W as k,J as l,H as m,ye as n,je as o,ve as p};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{j as n}from"./markdown-C9tbsVHX.js";import{b as l}from"./react-nrLBr15I.js";import{d as cr,a as lr,c as dr,C as te,u as ur}from"./useServerIdentity-BdXy8TQv.js";import{u as fr}from"./useEvents-S3Qk1Y_d.js";import{r as pr,a as hr}from"./xterm--24IGk-x.js";import{l as Y,c as mr}from"./index-VuyqBbGJ.js";const ve=4e3;function Fe(e){let t;try{t=JSON.stringify(e,null,2)}catch{t=String(e)}return t.length>ve?`${t.slice(0,ve)}
|
|
2
|
+
… (truncated, ${t.length-ve} more chars)`:t}function xr({slug:e,scenarioName:t,seedTabs:r,mockEntries:a,selectedMock:s,selectedSeedTab:o,selectedSeedRows:c}){const i=[],p=t??e;if(i.push(`# Edit Scenario Data: "${p}"`),i.push(""),i.push(`**Slug**: ${e}`),i.push(`**Scenario file**: .codeyam/scenarios/${e}.json`),i.push(""),i.push("## Scenario overview"),r.length>0){i.push("### Seed & Local tables");for(const u of r){const b=u.category?` (${u.category})`:"";i.push(`- **${u.label}**${b} — dataKey \`${u.dataKey}\``)}i.push("")}if(a.length>0){i.push("### HTTP mocks");const u=new Map;for(const b of a){const h=u.get(b.source)??[];h.push(b),u.set(b.source,h)}for(const[b,h]of u){i.push(`**${b}** (${h.length}):`);for(const d of h)i.push(`- \`${d.method} ${d.pathPattern}\``)}i.push("")}if(s){const u=`${s.method} ${s.pathPattern}`;i.push(`## Currently viewing: mock \`${u}\``),i.push(`- **Source**: ${s.source}`),s.status!==void 0&&i.push(`- **Status**: ${s.status}`);const b=s.headers??{},h=Object.entries(b);if(h.length>0){i.push("- **Headers**:");for(const[d,x]of h)i.push(` - \`${d}: ${x}\``)}s.body!==void 0&&s.body!==null?(i.push("- **Body**:"),i.push("```json"),i.push(Fe(s.body)),i.push("```")):i.push("- **Body**: (empty)"),i.push("")}else if(o){if(i.push(`## Currently viewing: seed table **${o.label}**`),i.push(`- **dataKey**: \`${o.dataKey}\``),o.category&&i.push(`- **Category**: ${o.category}`),o.description&&i.push(`- **Description**: ${o.description}`),o.schemaFields&&o.schemaFields.length>0){i.push("- **Schema**:");for(const u of o.schemaFields){const b=u.isId?" (PK)":"";i.push(` - \`${u.name}\`: ${u.type}${b}`)}}c&&c.length>0?(i.push(`- **Rows** (${c.length}):`),i.push("```json"),i.push(Fe(c)),i.push("```")):i.push("- **Rows**: (none yet)"),i.push("")}return i.push("## Your task"),i.push("The user is looking at the Scenario Data Panel and wants your help adjusting its data. Ask what change they'd like to make."),i.push(""),i.push("Typical edits:"),i.push('- Tweak an HTTP mock body, status, or headers → update `mocks.http["METHOD /path"]` in the scenario JSON'),i.push("- Add or remove seed rows → update the `seed` section"),i.push("- Adjust `localStorage` values → update the `localStorage` section"),i.push(""),i.push("To save changes:"),i.push("1. Write the updated scenario JSON to `.codeyam/tmp/scenario.json`"),i.push("2. Run: `codeyam-editor editor register @.codeyam/tmp/scenario.json`"),i.push("3. The editor will reload automatically and the panel will reflect the new data."),i.join(`
|
|
3
|
+
`)}const Ne=new Set;let se=null;const br=150;function Ea(e){return Ne.add(e),()=>{Ne.delete(e)}}function G(){se&&clearTimeout(se),se=setTimeout(()=>{se=null;for(const e of Ne)e()},br)}const Ee=new Set;function Ta(e){for(const t of Ee)t(e)}function gr(e){return Ee.add(e),()=>{Ee.delete(e)}}function yr({onSelect:e,onFocus:t}){l.useEffect(()=>gr(({routeKey:r,jsonPath:a})=>{e(r),t(a)}),[e,t])}const Ae="claude";function vr(e){return e==="claude"}function re(e){switch(e){case"codex":return"Codex";case"gemini":return"Gemini";case"opencode":return"OpenCode";default:return"Claude"}}const jr=3e3;function et(){const[e,t]=l.useState(null),[r,a]=l.useState(!0),[s,o]=l.useState(null),c=l.useRef(null),i=l.useCallback(async()=>{try{const p=await fetch("/api/config");if(!p.ok)throw new Error(`HTTP ${p.status}`);const u=await p.json(),b={projectTitle:u.projectTitle??null,projectDescription:u.projectDescription??null,provider:u.provider??Ae,port:u.port??3e3,previewOrigin:u.previewOrigin??null,screenSizes:u.screenSizes??{},defaultScreenSize:u.defaultScreenSize??null,apps:u.apps??[],admin:u.admin??!1,mobileTerminalCommands:u.mobileTerminalCommands??[],launcherUrl:u.launcherUrl??null,projectCount:u.projectCount??0,setupBrowserEnabled:u.setupBrowserEnabled??!1,claudePermissionModeAuto:u.claudePermissionModeAuto??!0},h=JSON.stringify(b);h!==c.current&&(c.current=h,t(b)),o(null)}catch(p){o(p instanceof Error?p.message:"Failed to load config")}finally{a(!1)}},[]);return l.useEffect(()=>{i();const p=setInterval(()=>{i()},jr);return()=>clearInterval(p)},[i]),{config:e,apps:(e==null?void 0:e.apps)??[],loading:r,error:s,refetch:i}}async function ue(e){try{const t=await e.json();if(t.error)return t.error}catch{}return`Request failed (${e.status})`}async function _r(e,t=null){const r=t!=null?`?since_ms=${encodeURIComponent(t)}`:"",s=await(await fetch(`/api/mock-panel/${encodeURIComponent(e)}${r}`)).json();if("error"in s)throw new Error(s.error);return s}async function Ke(e,t){const r=`/api/scenarios/${encodeURIComponent(e)}/mocks/${encodeURIComponent(t.routeKey)}`,a=await fetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t.status,body:t.body,headers:t.headers})});if(!a.ok)throw new Error(await ue(a))}async function wr(e,t){const r=`/api/scenarios/${encodeURIComponent(e)}/mocks/${encodeURIComponent(t)}`,a=await fetch(r,{method:"DELETE"});if(!a.ok)throw new Error(await ue(a))}async function Sr(e,t){const r=`/api/scenarios/${encodeURIComponent(e)}/mocks/${encodeURIComponent(t)}/passthrough`,a=await fetch(r,{method:"POST"});if(!a.ok)throw new Error(await ue(a))}function X(e){return e.kind==="shared"?`shared:${e.slug}`:e.kind}async function kr(e){const t=await fetch("/api/mocks/save-scoped",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await t.json();if(!t.ok||"success"in r&&r.success===!1)throw new Error("error"in r?r.error:`Save failed (${t.status})`);return r}async function Cr(e,t,r){const a=new URLSearchParams({scenarioSlug:e,routeKey:t,scope:X(r)}),s=await fetch(`/api/mocks/save-scope-impact?${a.toString()}`);if(!s.ok)throw new Error(await ue(s));return(await s.json()).impactedScenarios??[]}function Nr(){const[e,t]=l.useState(null),[r,a]=l.useState(null),s=l.useRef(null),o=async()=>{try{const i=await fetch("/api/editor-dev-server");if(!i.ok)throw new Error(`Failed to fetch dev server status: ${i.statusText}`);const p=await i.json(),u=JSON.stringify(p);if(u===s.current){a(null);return}s.current=u,t(p),a(null)}catch(i){a(i instanceof Error?i.message:String(i))}};return l.useEffect(()=>{o();const i=setInterval(o,1e3);return()=>clearInterval(i)},[]),{status:e,error:r,restart:async()=>{try{const i=await fetch("/api/editor-dev-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restart"})});if(!i.ok)throw new Error(`Failed to restart dev server: ${i.statusText}`);o()}catch(i){a(i instanceof Error?i.message:String(i))}}}}function Er(e){const[t,r]=l.useState([]),[a,s]=l.useState(null),[o,c]=l.useState(!1),[i,p]=l.useState(null),{events:u}=fr(),{status:b}=Nr(),h=(b==null?void 0:b.lastIframeLoadedAtMs)??null,d=l.useCallback(async()=>{if(!e){r([]),s(null);return}c(!0),p(null);try{const f=await _r(e,h);r(f.entries),s(f.defaultSlug)}catch(f){p(f instanceof Error?f.message:"Failed to load mocks")}finally{c(!1)}},[e,h]);l.useEffect(()=>{d()},[d]),l.useEffect(()=>{const f=u[u.length-1];!f||f.type!=="http_request"||d()},[u,d]);const x=l.useCallback(async f=>{e&&(await Ke(e,f),await d())},[e,d]),m=l.useCallback(async f=>{e&&(f.scope.kind==="scenario"?await Ke(e,{routeKey:f.routeKey,status:f.status,body:f.body,headers:f.headers}):await kr({scenarioSlug:e,routeKey:f.routeKey,scope:f.scope,status:f.status,body:f.body,headers:f.headers}),await d())},[e,d]),g=l.useCallback(async f=>{e&&(await wr(e,f),await d())},[e,d]),y=l.useCallback(async f=>{e&&(await Sr(e,f),await d())},[e,d]);return{entries:t,defaultSlug:a,loading:o,error:i,refresh:d,upsert:x,upsertScoped:m,remove:g,setPassthrough:y}}function Tr(e){const t={};for(const[r,a]of Object.entries(e))if(typeof a=="string")try{const s=JSON.parse(a);Array.isArray(s)?t[r]=s:typeof s=="object"&&s!==null&&(t[r]=[s])}catch{}else Array.isArray(a)&&(t[r]=a);return t}function Or(e,t){return e.length===0||t.length===0?!1:e.filter(a=>t.includes(a)).length>=Math.min(e.length,t.length)*.5}function Mr(e){return e==null?"null":typeof e=="number"?Number.isInteger(e)?"int4":"float":typeof e=="boolean"?"bool":typeof e=="object"?Array.isArray(e)?"array":"json":"text"}function Ar(e,t){return e.length>0?Object.keys(e[0]):t?t.map(r=>r.name):[]}function Pr(e,t,r){const a=new Map((r||[]).map(o=>[o.name,o.type])),s={};for(const o of e)s[o]=a.get(o)||(t.length>0?Mr(t[0][o]):"text");return s}function Rr(e,t){var r;return((r=t==null?void 0:t.find(a=>a.isId))==null?void 0:r.name)||e.find(a=>a==="id")||null}function Dr(e,t){const{_metadata:r,...a}=t,s=a.localStorage&&typeof a.localStorage=="object"&&!Array.isArray(a.localStorage)?Tr(a.localStorage):{},o={};if(a.seed&&typeof a.seed=="object"&&!Array.isArray(a.seed))for(const[d,x]of Object.entries(a.seed))Array.isArray(x)&&(o[d]=x);const c={},i=[],p=new Set,u=new Set,b=new Set;for(const d of e){const x=d.name.charAt(0).toLowerCase()+d.name.slice(1),m=d.fields.map(f=>f.name);let g=null,y=[];for(const f of[d.name,x,`${x}s`])if(f in a&&Array.isArray(a[f])){g=f,y=a[f],u.add(f);break}if(!g){for(const f of[d.name,x,`${x}s`])if(f in o){g=f,y=o[f],b.add(f),f in s&&p.add(f);break}}if(!g){for(const f of[d.name,x,`${x}s`])if(f in s){g=x,y=s[f],p.add(f);break}}if(!g){for(const[f,v]of Object.entries(s))if(!p.has(f)&&v.length>0&&Or(m,Object.keys(v[0]))){g=x,y=v,p.add(f);break}}g||(g=x),c[g]=y,i.push({label:d.name,dataKey:g,category:d.category,description:d.description,schemaFields:d.fields.map(f=>({name:f.name,type:f.type,isId:f.isId??!1}))})}const h=new Set(["name","id","url","dimensions","componentName","scenarioType","pageFilePath","routeName","description","props","env"]);for(const[d,x]of Object.entries(a))d==="_metadata"||d==="localStorage"||d==="seed"||d==="type"||d==="mocks"||h.has(d)||u.has(d)||Ir(x)&&(c[d]=x,i.push({label:d,dataKey:d}));for(const[d,x]of Object.entries(o))b.has(d)||(c[d]=x,i.push({label:d,dataKey:d}));for(const[d,x]of Object.entries(s))p.has(d)||(c[d]=x,i.push({label:d,dataKey:d}));return{data:c,tabs:i}}function ze(e){return e==="null"?null:e==="true"?!0:e==="false"?!1:e===""?"":isNaN(Number(e))?e:Number(e)}function Ir(e){return Array.isArray(e)&&e.length>0&&typeof e[0]=="object"&&e[0]!==null}function Lr(e){if(typeof e!="object"||e===null||!("props"in e))return null;const t=e.props;return typeof t!="object"||t===null||Array.isArray(t)?null:t}function $r(e){if(typeof e!="object"||e===null||!("browserState"in e))return null;const t=e.browserState;return typeof t!="object"||t===null||Array.isArray(t)?null:t}function Br(e,t){const r=new Set;for(const a of t){const s=e[a.dataKey];Array.isArray(s)&&s.length>0&&r.add(a.dataKey)}return r}function Fr(e){if(typeof e=="object"&&e!==null&&"shares"in e){const t=e.shares;if(Array.isArray(t))return t.filter(r=>typeof r=="string")}return[]}function Kr(e){const[t,r]=l.useState({data:null,tableTabs:[],scenarioOwnedDataKeys:new Set,shares:[],props:null,browserState:null,loading:!0,error:null});return l.useEffect(()=>{r(a=>({...a,loading:!0,error:null})),Promise.all([fetch("/api/data-structure").then(a=>a.json()).catch(()=>[]),fetch(`/api/scenarios/${encodeURIComponent(e)}`).then(a=>{if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.json()})]).then(([a,s])=>{const o=Dr(Array.isArray(a)?a:[],s);r({data:o.data,tableTabs:o.tabs,scenarioOwnedDataKeys:Br(o.data,o.tabs),shares:Fr(s),props:Lr(s),browserState:$r(s),loading:!1,error:null})}).catch(a=>r({data:null,tableTabs:[],scenarioOwnedDataKeys:new Set,shares:[],props:null,browserState:null,loading:!1,error:a instanceof Error?a.message:"Failed to load"}))},[e]),t}function Pe(e,t=""){return`/api/scenarios/${encodeURIComponent(e)}/draft${t}`}async function zr(e){const t=await fetch(Pe(e,"/status"));if(!t.ok)return{isDirty:!1,diffSummary:null};const r=await t.json();return{isDirty:!!r.isDirty,diffSummary:r.diffSummary??null}}async function Hr(e){const t=await fetch(Pe(e,"/commit"),{method:"POST"});if(!t.ok)throw new Error(`Save failed (${t.status})`)}async function Vr(e){const t=await fetch(Pe(e),{method:"DELETE"});if(!t.ok)throw new Error(`Cancel failed (${t.status})`)}function Yr({slug:e,onPreviewReload:t}){const[r,a]=l.useState(!1),[s,o]=l.useState(null),[c,i]=l.useState(!1),[p,u]=l.useState(!1),[b,h]=l.useState(null),d=l.useRef(null),x=l.useCallback(async()=>{if(!e){a(!1),o(null);return}try{const v=await zr(e);a(v.isDirty),o(v.diffSummary)}catch{}},[e]);l.useEffect(()=>{x()},[x]),l.useEffect(()=>{if(!r)return;const v=k=>{k.preventDefault(),k.returnValue=""};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[r]);const m=l.useCallback(()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{x()},100)},[x]),g=l.useCallback(async()=>{if(e){i(!0),h(null);try{await Hr(e),a(!1),o(null),t&&t()}catch(v){h(v instanceof Error?v.message:"Save failed")}finally{i(!1)}}},[e,t]),y=l.useCallback(async()=>{if(e){u(!0),h(null);try{await Vr(e),a(!1),o(null),t&&t()}catch(v){h(v instanceof Error?v.message:"Cancel failed")}finally{u(!1)}}},[e,t]),f=l.useCallback(v=>r?window.confirm(v):!0,[r]);return{isDirty:r,saving:c,cancelling:p,error:b,diffSummary:s,save:g,cancel:y,markDirty:m,confirmIfDirty:f}}const Wr={scenario:"Scenario",shared:"Shared",default:"Defaults","catalog-only":"Observed only",passthrough:"Passthrough"},Ur={scenario:null,shared:null,default:null,"catalog-only":"Observed during live traffic but not mocked yet. Promote it to a scenario mock to capture and edit the response.",passthrough:null};function tt(e){return Wr[e]??e}function Xr(e){return Ur[e]??null}const Jr={scenario:"bg-emerald-500/15 text-emerald-300 border-emerald-500/40",shared:"bg-violet-500/15 text-violet-300 border-violet-500/40",default:"bg-[#D7FF63]/15 text-[#D7FF63] border-[#D7FF63]/40","catalog-only":"bg-slate-500/15 text-slate-300 border-slate-500/40",passthrough:"bg-zinc-500/15 text-zinc-300 border-zinc-500/40"};function Re({source:e}){const t=Xr(e);return n.jsx("span",{className:`px-1.5 py-0.5 rounded border ${Jr[e]}`,title:t??`source: ${e}`,children:tt(e)})}const Oa=Object.freeze(Object.defineProperty({__proto__:null,MockSourceBadge:Re},Symbol.toStringTag,{value:"Module"}));function rt({label:e,scenarioCount:t,inheritedCount:r,expanded:a,onToggle:s}){const o=r===0;return n.jsxs("h3",{className:"px-3 pb-1 text-[10px] font-semibold uppercase tracking-wider text-[var(--text-dim)]",children:[n.jsx("div",{className:"mb-0.5",children:e}),n.jsxs("div",{className:"flex items-center gap-1 normal-case tracking-normal font-normal",children:[n.jsxs("span",{children:[t," scenario-specific"]}),n.jsx("span",{"aria-hidden":!0,children:"·"}),n.jsxs("button",{type:"button",onClick:s,disabled:o,"aria-expanded":a,className:`inline-flex items-center gap-0.5 ${o?"cursor-default text-[var(--text-dim)]":"cursor-pointer hover:text-[var(--text-primary)]"}`,children:[n.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px]",children:o?"":a?"▾":"▸"}),n.jsxs("span",{children:[r," inherited from default"]})]})]})]})}const Ma=Object.freeze(Object.defineProperty({__proto__:null,SidebarGroupOverrideHeader:rt},Symbol.toStringTag,{value:"Module"}));function nt({children:e}){return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mx-3 my-1 border-t border-[var(--border-subtle)]"}),n.jsx("div",{className:"px-3 pb-1 text-[9px] uppercase tracking-wider text-[var(--text-dim)]",children:"Inherited from default"}),e]})}const Aa=Object.freeze(Object.defineProperty({__proto__:null,SidebarInheritedSection:nt},Symbol.toStringTag,{value:"Module"}));function at({slug:e}){return n.jsx("span",{className:"px-1 py-0.5 rounded border text-[9px] font-mono bg-violet-500/10 text-violet-300 border-violet-500/30",title:`from shared-data set: ${e}`,children:e})}const Pa=Object.freeze(Object.defineProperty({__proto__:null,MockSharedSlugBadge:at},Symbol.toStringTag,{value:"Module"})),qr={GET:"text-emerald-400",POST:"text-[#D7FF63]",PUT:"text-amber-400",PATCH:"text-purple-400",DELETE:"text-red-400"};function st({entry:e,routeKey:t,active:r,onSelect:a}){const s=qr[e.method]??"text-[var(--text-muted)]";return n.jsxs("button",{onClick:a,className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 transition-colors cursor-pointer ${r?"bg-[var(--accent-blue)]/10 border-[var(--accent-blue)] text-[var(--text-primary)]":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-primary)]"}`,title:t,children:[n.jsx("span",{className:`font-mono text-[9px] font-semibold ${s}`,children:e.method}),n.jsx("span",{className:"truncate flex-1 font-mono",children:e.pathPattern}),e.source==="shared"&&e.sharedSlug&&n.jsx(at,{slug:e.sharedSlug})]})}const Ra=Object.freeze(Object.defineProperty({__proto__:null,SidebarMockEntryRow:st},Symbol.toStringTag,{value:"Module"})),Gr=["scenario","shared","default","catalog-only","passthrough"];function J(e){return`${e.method} ${e.pathPattern}`}function ot({seedTabs:e,mockEntries:t,selection:r,onSelect:a,overrides:s}){const o=new Map;for(const c of t){const i=o.get(c.source)??[];i.push(c),o.set(c.source,i)}return n.jsxs("nav",{className:"w-56 shrink-0 border-r border-[var(--border-subtle)] bg-[var(--bg-deep)] overflow-y-auto",children:[n.jsxs(ie,{label:"Browser Environment",count:4,emptyHint:"",children:[n.jsx(ee,{label:"Cookies",active:(r==null?void 0:r.kind)==="browser"&&r.tab==="cookies",onSelect:()=>a({kind:"browser",tab:"cookies"})}),n.jsx(ee,{label:"Local Storage",active:(r==null?void 0:r.kind)==="browser"&&r.tab==="localStorage",onSelect:()=>a({kind:"browser",tab:"localStorage"})}),n.jsx(ee,{label:"Session Storage",active:(r==null?void 0:r.kind)==="browser"&&r.tab==="sessionStorage",onSelect:()=>a({kind:"browser",tab:"sessionStorage"})}),n.jsx(ee,{label:"Request Headers",active:(r==null?void 0:r.kind)==="browser"&&r.tab==="headers",onSelect:()=>a({kind:"browser",tab:"headers"})})]}),n.jsx(ie,{label:"Seed & Local",count:e.length,emptyHint:"No seed or localStorage data",override:s?{scenarioCount:s.scenarioSeedCount,inheritedCount:s.inheritedSeedCount,renderInherited:()=>He({tabs:s.inheritedSeedTabs,selection:r,onSelect:a})}:void 0,children:He({tabs:e,selection:r,onSelect:a})}),n.jsx(ie,{label:"Mock APIs",count:t.length,emptyHint:"No HTTP mocks registered",override:s?{scenarioCount:s.scenarioMockCount,inheritedCount:s.inheritedMockCount,renderInherited:()=>Ve({entries:s.inheritedMockEntries,selection:r,onSelect:a})}:void 0,children:Ve({entries:t,grouped:o,selection:r,onSelect:a})})]})}function He({tabs:e,selection:t,onSelect:r}){return e.map(a=>{const s=(t==null?void 0:t.kind)==="seed"&&t.dataKey===a.dataKey;return n.jsxs("button",{onClick:()=>r({kind:"seed",dataKey:a.dataKey}),className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 transition-colors cursor-pointer ${s?"bg-[var(--accent-active)]/10 border-[var(--accent-active)] text-[var(--text-primary)]":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-primary)]"}`,children:[n.jsx("span",{className:"truncate flex-1",children:a.label}),a.category&&n.jsx("span",{className:"text-[9px] uppercase tracking-wide text-[var(--text-dim)]",children:a.category==="mock-api"?"API":a.category})]},a.dataKey)})}function ee({label:e,active:t,onSelect:r}){return n.jsxs("button",{onClick:r,className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 transition-colors cursor-pointer ${t?"bg-[var(--accent-active)]/10 border-[var(--accent-active)] text-[var(--text-primary)]":"border-transparent text-[var(--text-muted)] hover:bg-[var(--bg-card)] hover:text-[var(--text-primary)]"}`,children:[n.jsx("span",{className:"truncate flex-1",children:e}),n.jsx("span",{className:"text-[9px] uppercase tracking-wide text-[var(--text-dim)]",children:"ENV"})]})}function Ve({entries:e,grouped:t,selection:r,onSelect:a}){const s=t??Qr(e);return Gr.flatMap(o=>{const c=s.get(o)??[];return c.length===0?[]:[n.jsxs("div",{className:"px-3 pt-2 pb-1 text-[9px] uppercase tracking-wider text-[var(--text-dim)] font-semibold flex items-center gap-1.5",children:[tt(o),n.jsx(Re,{source:o})]},`hdr-${o}`),...c.map(i=>{const p=J(i),u=(r==null?void 0:r.kind)==="mock"&&r.routeKey===p;return n.jsx(st,{entry:i,routeKey:p,active:u,onSelect:()=>a({kind:"mock",routeKey:p})},p)})]})}function Qr(e){const t=new Map;for(const r of e){const a=t.get(r.source)??[];a.push(r),t.set(r.source,a)}return t}function ie({label:e,count:t,emptyHint:r,children:a,override:s}){const[o,c]=l.useState(!1);if(s){const{scenarioCount:i,inheritedCount:p,renderInherited:u}=s,b=i+(o?p:0);return n.jsxs("section",{className:"py-2",children:[n.jsx(rt,{label:e,scenarioCount:i,inheritedCount:p,expanded:o,onToggle:()=>c(h=>!h)}),b===0?n.jsx("p",{className:"px-3 py-1 text-[10px] italic text-[var(--text-dim)]",children:r}):n.jsxs("div",{children:[a,o&&p>0&&n.jsx(nt,{children:u()})]})]})}return n.jsxs("section",{className:"py-2",children:[n.jsxs("h3",{className:"px-3 pb-1 text-[10px] font-semibold uppercase tracking-wider text-[var(--text-dim)] flex items-center justify-between",children:[n.jsx("span",{children:e}),n.jsx("span",{children:t})]}),t===0?n.jsx("p",{className:"px-3 py-1 text-[10px] italic text-[var(--text-dim)]",children:r}):n.jsx("div",{children:a})]})}const Da=Object.freeze(Object.defineProperty({__proto__:null,BrowserStateButton:ee,ScenarioDataPanelSidebar:ot,SidebarGroup:ie,routeKeyFor:J},Symbol.toStringTag,{value:"Module"}));function Zr({seedTabs:e,mockEntries:t,initialSection:r,selection:a,setSelection:s}){l.useEffect(()=>{if(a)return;const o=r==="mocks",c=r==="seed";if(o&&t.length>0){s({kind:"mock",routeKey:J(t[0])});return}if(c&&e.length>0){s({kind:"seed",dataKey:e[0].dataKey});return}e.length>0?s({kind:"seed",dataKey:e[0].dataKey}):t.length>0&&s({kind:"mock",routeKey:J(t[0])})},[r,t,e,a,s])}const Te={state:"unknown",provider:Ae,credsPresent:!0,cliInstalled:!0,scannedDirs:[],reason:null,expiresAt:null,probeInFlight:!1,probeAttempts:0,backendFieldAbsent:!1};function en(e){if(e==null)return{...Te,backendFieldAbsent:!0};if(typeof e!="object")return Te;const t=e,r=t.state==="authenticated"||t.state==="needs-login"||t.state==="unknown"?t.state:"unknown",a=t.provider==="claude"||t.provider==="codex"||t.provider==="gemini"||t.provider==="opencode"?t.provider:Ae,s=typeof t.credsPresent=="boolean"?t.credsPresent:!0,o=typeof t.cliInstalled=="boolean"?t.cliInstalled:!0,c=Array.isArray(t.scannedDirs)?t.scannedDirs.filter(h=>typeof h=="string"):[],i=t.reason==="token-expired"||t.reason==="api-401"||t.reason==="no-credentials"||t.reason==="probe-timeout"||t.reason==="config-corrupt"||t.reason==="cli-not-found"?t.reason:null,p=typeof t.tokenExpiresAt=="string"?t.tokenExpiresAt:typeof t.expiresAt=="string"?t.expiresAt:null,u=typeof t.probeInFlight=="boolean"?t.probeInFlight:!1,b=typeof t.probeAttempts=="number"&&Number.isFinite(t.probeAttempts)&&t.probeAttempts>=0?t.probeAttempts:0;return{state:r,provider:a,credsPresent:s,cliInstalled:o,scannedDirs:c,reason:i,expiresAt:p,probeInFlight:u,probeAttempts:b,backendFieldAbsent:!1}}const tn=1e3;function rn(){const[e,t]=l.useState(Te),r=l.useRef(e.state);r.current=e.state;const a=l.useCallback(async()=>{try{const s=await fetch("/api/config");if(!s.ok)return;const o=await s.json();t(en(o.providerAuth))}catch{}},[]);return l.useEffect(()=>{a()},[a]),l.useEffect(()=>{if(e.state!=="unknown")return;const s=window.setInterval(()=>{r.current==="unknown"&&a()},tn);return()=>window.clearInterval(s)},[e.state,a]),l.useEffect(()=>{const s=()=>{t(o=>({...o,state:"needs-login"})),a()};return window.addEventListener("agent-auth-required",s),()=>window.removeEventListener("agent-auth-required",s)},[a]),l.useEffect(()=>{const s=()=>{t(o=>({...o,state:"authenticated"})),a()};return window.addEventListener("agent-auth-resolved",s),()=>window.removeEventListener("agent-auth-resolved",s)},[a]),{state:e.state,provider:e.provider,credsPresent:e.credsPresent,cliInstalled:e.cliInstalled,scannedDirs:e.scannedDirs,reason:e.reason,expiresAt:e.expiresAt,probeInFlight:e.probeInFlight,probeAttempts:e.probeAttempts,backendFieldAbsent:e.backendFieldAbsent,refresh:a}}var nn=pr(),an=hr();function sn(e){const t=window.location.protocol==="https:"?"wss:":"ws:",r=new URL(`${t}//${window.location.host}/ws/terminal`);return e!=null&&e.provider&&r.searchParams.set("provider",e.provider),e!=null&&e.mode&&r.searchParams.set("mode",e.mode),e!=null&&e.sessionId&&r.searchParams.set("sessionId",e.sessionId),e!=null&&e.chatKey&&r.searchParams.set("chatKey",e.chatKey),e!=null&&e.launch&&r.searchParams.set("launch","1"),e!=null&&e.cols&&e.cols>0&&r.searchParams.set("cols",String(e.cols)),e!=null&&e.rows&&e.rows>0&&r.searchParams.set("rows",String(e.rows)),r.toString()}const on=20,cn=1;function ln(e,t){const r=t===cn?e:e/on;return Math.trunc(r)||Math.sign(r)}function dn(){if(typeof navigator>"u")return!1;const e=navigator.platform??"";return e?/Mac|iPhone|iPad|iPod/i.test(e):/Mac|iPhone|iPad|iPod/i.test(navigator.userAgent??"")}function un(e,t,r={}){const a=r.isMac??dn(),s=r.onError,o=r.onCopy;let c=null;async function i(m){if(!m)return!1;let g=!1;try{g=await cr(m)}catch(y){return s==null||s(Ye("copy",y)),!1}if(g){try{e.clearSelection()}catch{}o==null||o()}else s==null||s(pn("copy"));return g}async function p(){return e.hasSelection()?i(e.getSelection()):!1}async function u(){try{const m=await navigator.clipboard.readText();m&&e.paste(m)}catch(m){s==null||s(Ye("paste",m))}}function b(m){return m.type!=="keydown"?!0:a?(m.metaKey&&!m.ctrlKey&&!m.altKey&&m.key.toLowerCase()==="c"||m.ctrlKey&&!m.metaKey&&!m.altKey&&!m.shiftKey&&m.key.toLowerCase()==="c")&&e.hasSelection()?(p(),!1):!0:(m.ctrlKey&&m.shiftKey&&!m.metaKey&&!m.altKey&&m.key.toLowerCase()==="c"||m.ctrlKey&&!m.shiftKey&&!m.metaKey&&!m.altKey&&m.key.toLowerCase()==="c")&&e.hasSelection()?(p(),!1):!0}e.attachCustomKeyEventHandler(b);function h(){if(!c)return;const{root:m,onDocumentClick:g,onKeyDown:y}=c;document.removeEventListener("mousedown",g,!0),document.removeEventListener("keydown",y,!0),m.remove(),c=null}function d(m,g,y){h();const f=document.createElement("div");f.setAttribute("data-terminal-clipboard-menu","true"),f.style.position="fixed",f.style.left=`${m}px`,f.style.top=`${g}px`,f.style.zIndex="1000",f.style.minWidth="180px",f.style.padding="4px 0",f.style.background="var(--bg-card)",f.style.border="1px solid var(--border-subtle)",f.style.borderRadius="6px",f.style.boxShadow="0 8px 24px rgba(0, 0, 0, 0.35)",f.style.fontSize="12px",f.style.color="var(--text-primary)",f.style.userSelect="none";const v=a?"⌘C":"Ctrl+Shift+C",k=a?"⌘V":"Ctrl+Shift+V",_=je("Copy",v,!y,()=>{i(y),h()}),w=je("Paste",k,!1,()=>{u(),h()}),P=je("Select All","",!1,()=>{try{e.selectAll()}catch{}const j=e.hasSelection()?e.getSelection():"";i(j),h()});f.appendChild(_),f.appendChild(w),f.appendChild(P),document.body.appendChild(f),fn(f,m,g);const B=j=>{f.contains(j.target)||h()},E=j=>{j.key==="Escape"&&(j.preventDefault(),h())};document.addEventListener("mousedown",B,!0),document.addEventListener("keydown",E,!0),c={root:f,onDocumentClick:B,onKeyDown:E}}function x(m){m.preventDefault();const g=e.hasSelection()?e.getSelection():"";d(m.clientX,m.clientY,g)}return t.addEventListener("contextmenu",x),()=>{t.removeEventListener("contextmenu",x),h(),e.attachCustomKeyEventHandler(()=>!0)}}function je(e,t,r,a){const s=document.createElement("button");s.type="button",s.disabled=r,s.style.display="flex",s.style.justifyContent="space-between",s.style.alignItems="center",s.style.gap="16px",s.style.width="100%",s.style.padding="6px 12px",s.style.border="none",s.style.background="transparent",s.style.textAlign="left",s.style.fontSize="12px",s.style.cursor=r?"default":"pointer",s.style.color=r?"var(--text-dim)":"var(--text-primary)";const o=document.createElement("span");if(o.textContent=e,s.appendChild(o),t){const c=document.createElement("span");c.textContent=t,c.style.color="var(--text-dim)",c.style.fontSize="11px",s.appendChild(c)}return r||(s.addEventListener("mouseenter",()=>{s.style.background="var(--border-subtle)"}),s.addEventListener("mouseleave",()=>{s.style.background="transparent"}),s.addEventListener("click",()=>a())),s}function fn(e,t,r){const a=typeof window<"u"?window.innerWidth:0,s=typeof window<"u"?window.innerHeight:0;if(!a||!s)return;const o=e.getBoundingClientRect(),c=4;let i=t,p=r;o.width&&t+o.width+c>a&&(i=Math.max(c,a-o.width-c)),o.height&&r+o.height+c>s&&(p=Math.max(c,s-o.height-c)),e.style.left=`${i}px`,e.style.top=`${p}px`}function Ye(e,t){const r=t instanceof Error?t.message:String(t);return`Clipboard ${e} failed: ${r}`}function pn(e){return`Clipboard ${e} blocked by the browser.`}function hn(e,t,r,a,s,o){const c=e.leftBorderCol+1;if(t===a)return s-r;if(a<t){let u=r-c;u+=1;for(let h=a+1;h<t;h++){const d=o(h);if(d===null)return null;u+=Math.max(1,d-c+1)}const b=o(a);return b===null?null:(u+=Math.max(0,b-s),-u)}const i=o(t);if(i===null)return null;let p=Math.max(0,i-r)+1;for(let u=t+1;u<a;u++){const b=o(u);if(b===null)return null;p+=Math.max(1,b-c+1)}return p+=s-c,p}const oe=new Set(["│","┃","║","|"]);function mn(e,t,r,a){const s=e.baseY,o=(x,m)=>{const g=e.getLine(s+x);if(!g)return null;const y=g.getCell(m);return y?y.getChars():null},c=x=>{let m=-1;for(let y=0;y<r;y++){const f=o(x,y);if(f!==null&&oe.has(f)){m=y;break}}if(m===-1)return null;let g=-1;for(let y=r-1;y>m;y--){const f=o(x,y);if(f!==null&&oe.has(f)){g=y;break}}return g===-1?null:{leftBorderCol:m,rightBorderCol:g}};let i=t,p=c(t);if(!p){const x=c(t-1);if(x)i=t-1,p=x;else{const m=c(t+1);m&&(i=t+1,p=m)}}if(!p)return null;const{leftBorderCol:u,rightBorderCol:b}=p;let h=i;for(let x=i-1;x>=0;x--){const m=o(x,u);if(m===null)break;if(!(m===""||m===" ")){if(!oe.has(m))break;h=x}}let d=i;for(let x=i+1;x<a;x++){const m=o(x,u);if(m===null)break;if(!(m===""||m===" ")){if(!oe.has(m))break;d=x}}return{topRow:h,bottomRow:d,leftBorderCol:u,rightBorderCol:b}}function xn(e,t,r,a){const s=e.getLine(e.baseY+t);if(!s)return null;for(let o=a;o>=r;o--){const c=s.getCell(o);if(!c)continue;const i=c.getChars();if(i!==""&&i!==" ")return o}return r-1}const bn=200;function gn(e){const{click:t,terminal:r,cellSurface:a,debug:s}=e,o=r.buffer.active,c=_=>{s==null||s({cursorY:o.cursorY,cursorX:o.cursorX,originalTargetCol:_.originalTargetCol??_.targetCol,snapped:_.snapped??!1,..._})};if(o.type==="alternate")return c({targetRow:-1,targetCol:-1,box:null,rejected:"alt-screen",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;if(o.viewportY!==o.baseY)return c({targetRow:-1,targetCol:-1,box:null,rejected:"scrollback",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;const i=a.getBoundingClientRect();if(i.width===0||i.height===0)return c({targetRow:-1,targetCol:-1,box:null,rejected:"outside-grid",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;const p=t.clientX-i.left,u=t.clientY-i.top;if(p<0||u<0||p>=i.width||u>=i.height)return c({targetRow:-1,targetCol:-1,box:null,rejected:"outside-grid",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;const b=i.width/r.cols,h=i.height/r.rows,d=Math.floor(p/b),x=Math.floor(u/h),m=r.modes.applicationCursorKeysMode,g=m?"\x1BOC":"\x1B[C",y=m?"\x1BOD":"\x1B[D",f=mn(o,o.cursorY,r.cols,r.rows);if(f){if(x<f.topRow||x>f.bottomRow)return c({targetRow:x,targetCol:d,box:f,rejected:"out-of-box",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;if(d<=f.leftBorderCol||d>=f.rightBorderCol)return c({targetRow:x,targetCol:d,box:f,rejected:"border",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;const _=f.leftBorderCol+1,w=f.rightBorderCol-1,P=A=>xn(o,A,_,w),B=o.cursorY<f.topRow||o.cursorY>f.bottomRow,E=B?f.bottomRow:o.cursorY,j=B?w:o.cursorX,F=x!==E;let N=null;if(F&&(N=P(x),N===null))return c({targetRow:x,targetCol:d,originalTargetCol:d,snapped:!1,box:f,rejected:"unreadable-row",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;let D=d,T=!1;if(F&&N!==null){const A=Math.max(_,N);d>A&&(D=A,T=!0)}if(x===E&&D===j)return c({targetRow:x,targetCol:D,originalTargetCol:d,snapped:T,box:f,rejected:"same-cell",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;const O=hn(f,E,j,x,D,P);if(O===null)return c({targetRow:x,targetCol:D,originalTargetCol:d,snapped:T,box:f,rejected:"unreadable-row",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;if(O===0)return c({targetRow:x,targetCol:D,originalTargetCol:d,snapped:T,box:f,rejected:"same-cell",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;if(Math.abs(O)>bn)return c({targetRow:x,targetCol:D,originalTargetCol:d,snapped:T,box:f,rejected:"emit-cap",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;const I=O<0?y.repeat(-O):g.repeat(O);return c({targetRow:x,targetCol:D,originalTargetCol:d,snapped:T,box:f,rejected:null,emittedDirection:O<0?"left":"right",emittedByteCount:I.length,predictedCursorY:x,predictedCursorX:D}),I}if(x!==o.cursorY)return c({targetRow:x,targetCol:d,box:null,rejected:"out-of-box",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;const v=d-o.cursorX;if(v===0)return c({targetRow:x,targetCol:d,box:null,rejected:"same-cell",emittedDirection:null,emittedByteCount:0,predictedCursorY:null,predictedCursorX:null}),null;const k=v<0?y.repeat(-v):g.repeat(v);return c({targetRow:x,targetCol:d,box:null,rejected:null,emittedDirection:v<0?"left":"right",emittedByteCount:k.length,predictedCursorY:x,predictedCursorX:d}),k}const We=1;function yn(e,t){const{sendInput:r,pixelThreshold:a=3,timeThresholdMs:s=300,now:o=()=>Date.now(),onVerificationDisable:c}=t,i=e.element;if(!i)return()=>{};const p=i.querySelector(".xterm-screen")??i;let u=null,b=!1,h=null,d=null;const x=typeof e.onRender=="function"?e.onRender.bind(e):null;x&&(d=x(()=>{const y=h;if(!y)return;h=null;const f=e.buffer.active,v=Math.abs(f.cursorY-y.y),k=Math.abs(f.cursorX-y.x);if(v>We||k>We){b=!0;const _={predicted:y,actual:{y:f.cursorY,x:f.cursorX}};c?c(_):console.warn("[click-cursor] disabled — cursor diverged from prediction",_)}}));function m(y){if(y.button!==0||y.altKey||y.shiftKey||y.metaKey||y.ctrlKey){u=null;return}u={clientX:y.clientX,clientY:y.clientY,at:o()}}function g(y){var E;const f=u;if(u=null,!f)return;const v=y.clientX-f.clientX,k=y.clientY-f.clientY;if(Math.hypot(v,k)>a||o()-f.at>s)return;const _=typeof window<"u"&&((E=window.localStorage)==null?void 0:E.getItem("codeyam.terminalClickDebug"))==="1";if(_)try{const j=e.buffer.active,F=j.cursorY,N={};for(let D=-2;D<=2;D++){const T=F+D,O=j.getLine(j.baseY+T);if(!O)continue;const I=[];for(let A=0;A<e.cols;A++){const K=O.getCell(A);I.push(K?K.getChars():"")}N[`row${T}`]=I.join("|")}console.log("[click-cursor] buffer dump",{cursorY:F,cursorX:j.cursorX,viewportY:j.viewportY,baseY:j.baseY,rows:N})}catch{}let w=null;const P=j=>{w=j,_&&console.log("[click-cursor] result",j)},B=gn({click:{clientX:y.clientX,clientY:y.clientY},terminal:e,cellSurface:p,debug:P});if(B){if(w){const j=w,F=j.box!==null&&j.targetRow!==j.cursorY;if(F&&b){_&&console.log("[click-cursor] suppressed by verification-disabled");return}F&&j.predictedCursorY!==null&&j.predictedCursorX!==null&&(h={y:j.predictedCursorY,x:j.predictedCursorX})}r(B)}}return p.addEventListener("mousedown",m),p.addEventListener("mouseup",g),()=>{p.removeEventListener("mousedown",m),p.removeEventListener("mouseup",g),d==null||d.dispose()}}function vn(){window.focus()}function jn(e,t){vn(),e==null||e.focus({preventScroll:!0}),t()}async function it(e=1500){try{return(await fetch("/api/health",{signal:AbortSignal.timeout(e)})).ok}catch{return!1}}function _n(e,t){let r=!1,a=null;async function s(){if(!r){if(await it(1500)){r||t();return}r||(a=setTimeout(s,e))}}return a=setTimeout(s,e),()=>{r=!0,a&&(clearTimeout(a),a=null)}}const wn="The editor server closed the terminal connection with no further detail.";function Sn(e){if(e&&typeof e=="object"&&"message"in e){const t=e.message;if(typeof t=="string"&&t.length>0)return t}return wn}let ct=!1;function _e(e){ct=e}function Ia(){return ct}function lt(){return n.jsx("div",{"data-testid":"terminal-connecting-hint",className:"absolute top-2 right-3 text-xs font-mono text-[#aaa] pointer-events-none z-10 select-none",children:"Connecting…"})}const La=Object.freeze(Object.defineProperty({__proto__:null,TerminalConnectingHint:lt},Symbol.toStringTag,{value:"Module"}));function dt({attempt:e,maxAttempts:t,pulseKey:r}){return n.jsx("div",{"data-testid":"terminal-reconnecting-banner",className:"absolute inset-0 flex items-start justify-center pt-3 z-10 bg-black/40",children:n.jsxs("div",{"data-testid":"terminal-reconnecting-banner-label",className:"px-4 py-2 rounded font-mono text-sm shadow terminal-disconnect-pulse bg-amber-500/90 text-black",children:["Reconnecting… (attempt ",e," of ",t,")"]},r)})}const $a=Object.freeze(Object.defineProperty({__proto__:null,TerminalReconnectingBanner:dt},Symbol.toStringTag,{value:"Module"}));function ut({onRefresh:e}){return n.jsx("div",{"data-testid":"terminal-failed-banner",className:"absolute inset-0 flex items-start justify-center pt-3 z-10 bg-black/60",children:n.jsxs("div",{className:"px-4 py-2 rounded font-mono text-sm shadow flex items-center gap-3 terminal-disconnect-pulse bg-red-500/90 text-white",children:[n.jsx("span",{children:"Connection lost. The page must be refreshed to continue."}),n.jsx("button",{type:"button",onClick:e,"data-testid":"terminal-failed-banner-refresh",className:"px-2 py-1 rounded bg-white text-red-700 font-medium cursor-pointer hover:bg-red-50",children:"Refresh page"})]})})}const Ba=Object.freeze(Object.defineProperty({__proto__:null,TerminalFailedBanner:ut},Symbol.toStringTag,{value:"Module"}));function ft({onReload:e}){return n.jsx("div",{"data-testid":"terminal-server-stopped-banner",className:"absolute inset-0 flex items-start justify-center pt-3 z-10 bg-black/60",children:n.jsxs("div",{className:"px-4 py-2 rounded font-mono text-sm shadow flex items-center gap-3 terminal-disconnect-pulse bg-red-500/90 text-white",children:[n.jsx("span",{children:"Editor stopped — restart it from your terminal to continue."}),n.jsx("button",{type:"button",onClick:e,"data-testid":"terminal-server-stopped-banner-reload",className:"px-2 py-1 rounded bg-white text-red-700 font-medium cursor-pointer hover:bg-red-50",children:"Reload page"})]})})}const Fa=Object.freeze(Object.defineProperty({__proto__:null,TerminalServerStoppedBanner:ft},Symbol.toStringTag,{value:"Module"}));function pt({message:e,onRefresh:t}){return n.jsx("div",{"data-testid":"terminal-server-error-banner",className:"absolute inset-0 flex items-start justify-center pt-3 z-10 bg-black/60",children:n.jsxs("div",{className:"px-4 py-3 rounded font-mono text-sm shadow flex items-start gap-3 max-w-2xl bg-amber-500/95 text-black border border-amber-700",children:[n.jsx("pre",{"data-testid":"terminal-server-error-banner-message",className:"whitespace-pre-wrap break-words flex-1 m-0 font-mono text-xs leading-snug",children:e}),n.jsxs("div",{className:"flex items-start gap-2 self-start shrink-0",children:[n.jsx(lr,{variant:"subtle",text:e,label:"Copy",className:"px-2 py-1 rounded bg-white text-amber-900 font-medium cursor-pointer hover:bg-amber-50 disabled:opacity-50 disabled:cursor-not-allowed"}),n.jsx("button",{type:"button",onClick:t,"data-testid":"terminal-server-error-banner-refresh",className:"px-2 py-1 rounded bg-white text-amber-900 font-medium cursor-pointer hover:bg-amber-50",children:"Refresh"})]})]})})}const Ka=Object.freeze(Object.defineProperty({__proto__:null,TerminalServerErrorBanner:pt},Symbol.toStringTag,{value:"Module"}));function ht({onRefresh:e}){return n.jsx("div",{"data-testid":"terminal-edge-unreachable-banner",className:"absolute inset-0 flex items-start justify-center pt-3 z-10 bg-black/60",children:n.jsxs("div",{className:"px-4 py-3 rounded font-mono text-sm shadow flex items-start gap-3 max-w-2xl bg-amber-500/95 text-black border border-amber-700",children:[n.jsx("span",{className:"flex-1 leading-snug",children:"The editor is reachable and this session is valid, but the live terminal connection (WebSocket) still can't be established — the WebSocket path itself isn't carrying the connection, which usually means the VM's tunnel/ingress. Retry to reconnect; if it persists, the VM's ingress needs attention."}),n.jsx("button",{type:"button",onClick:e,"data-testid":"terminal-edge-unreachable-banner-retry",className:"px-2 py-1 rounded bg-white text-amber-900 font-medium cursor-pointer hover:bg-amber-50 self-start",children:"Retry"})]})})}const za=Object.freeze(Object.defineProperty({__proto__:null,TerminalEdgeUnreachableBanner:ht},Symbol.toStringTag,{value:"Module"}));function mt({canRetry:e=!1,onRefresh:t}){return n.jsx("div",{"data-testid":"terminal-session-stale-banner",className:"absolute inset-0 flex items-start justify-center pt-3 z-10 bg-black/60",children:n.jsxs("div",{className:"px-4 py-3 rounded font-mono text-sm shadow flex items-start gap-3 max-w-2xl bg-amber-500/95 text-black border border-amber-700",children:[n.jsx("span",{className:"flex-1 leading-snug",children:e?"The editor restarted and this tab's session couldn't be re-established automatically. Retry to pick up a fresh session; if it keeps failing, reload the page.":"The editor restarted, so this tab's session expired. Re-establishing it and reconnecting the terminal — no action needed."}),e&&n.jsx("button",{type:"button",onClick:t,"data-testid":"terminal-session-stale-banner-retry",className:"px-2 py-1 rounded bg-white text-amber-900 font-medium cursor-pointer hover:bg-amber-50 self-start",children:"Retry"})]})})}const Ha=Object.freeze(Object.defineProperty({__proto__:null,TerminalSessionStaleBanner:mt},Symbol.toStringTag,{value:"Module"}));function xt({status:e,pulseKey:t,onRefresh:r}){return e.kind==="open"||e.kind==="ended"?null:e.kind==="connecting"?n.jsx(lt,{}):e.kind==="reconnecting"?n.jsx(dt,{attempt:e.attempt,maxAttempts:e.maxAttempts,pulseKey:t}):e.kind==="server-stopped"?n.jsx(ft,{onReload:r}):e.kind==="server-error"?n.jsx(pt,{message:e.message,onRefresh:r}):e.kind==="edge-unreachable"?n.jsx(ht,{onRefresh:r}):e.kind==="session-stale"?n.jsx(mt,{canRetry:e.canRetry,onRefresh:r}):n.jsx(ut,{onRefresh:r})}const Va=Object.freeze(Object.defineProperty({__proto__:null,TerminalDisconnectOverlay:xt},Symbol.toStringTag,{value:"Module"}));function bt({status:e,onRetry:t}){return e==="retrying"?n.jsx("div",{"data-testid":"mini-agent-launch-retrying",className:"absolute inset-x-0 top-2 z-10 flex justify-center pointer-events-none",children:n.jsx("span",{className:"font-mono text-xs italic text-[var(--text-dim)] bg-black/40 px-2 py-1 rounded",children:"Launch slow — retrying…"})}):e==="failed"?n.jsx("div",{role:"alert","data-testid":"mini-agent-launch-failed-banner",className:"absolute inset-0 flex items-start justify-center pt-3 z-10 bg-black/60",children:n.jsxs("div",{className:"px-4 py-2 rounded font-mono text-sm shadow flex items-center gap-3 terminal-disconnect-pulse bg-red-500/90 text-white",children:[n.jsx("span",{children:"Couldn't launch the build agent — the shell prompt didn't respond in time."}),n.jsx("button",{type:"button",onClick:t,"data-testid":"mini-agent-launch-failed-retry",className:"px-2 py-1 rounded bg-white text-red-700 font-medium cursor-pointer hover:bg-red-50",children:"Retry"})]})}):null}const Ya=Object.freeze(Object.defineProperty({__proto__:null,MiniAgentLaunchOverlay:bt},Symbol.toStringTag,{value:"Module"})),kn=40;function Cn(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return t&&t.slice(0,kn).replace(/-+$/,"")||"session"}const ce=new Map;function De(e,t){const r=ce.get(e);if(!r){let a;try{a=t()}catch(s){return Promise.reject(s)}return a instanceof Promise?Ue(e,a):Promise.resolve()}return Ue(e,r.then(()=>t()))}function Ue(e,t){const r=t.catch(()=>{});return ce.set(e,r),r.then(()=>{ce.get(e)===r&&ce.delete(e)}),t}let Z=0,Q=[];function Wa(){if(Z+=1,Z===1&&Q.length>0){const e=Q;Q=[];for(const t of e)t()}}function Ua(){Z>0&&(Z-=1)}function Nn(){return Z>0}function En(e){return Z>0?Promise.resolve(!0):new Promise(t=>{let r=!1;const a=()=>{r||(r=!0,t(!0))};Q.push(a),setTimeout(()=>{r||(r=!0,Q=Q.filter(s=>s!==a),t(!1))},e)})}const fe="build",Xe="miniagent",Je=3e3;function Tn(e){return Nn()?e():En(Je).then(t=>{if(t)return e();console.warn(`[terminal] dropped programmatic injection: no terminal-send-input listener attached within ${Je}ms`)})}function Ie(e){window.dispatchEvent(new CustomEvent("terminal-send-input",{detail:e}))}function Xa(e){De(fe,()=>Tn(()=>Ie(e)))}const le=50;function On(e,t=Ie,r=fe){return De(r,()=>new Promise(a=>{t(e),setTimeout(()=>{t("\r"),a()},le)}))}const we=3e3;function Mn(e){return e==="codex"?"codex":e==="gemini"?"gemini":e==="opencode"?"opencode":"claude"}function gt(e,t){const r=Mn(e);return r==="claude"&&t?`${r} --permission-mode auto`:r}function An(e,t){return`'${e==="powershell"?t.replaceAll("'","''"):t.replaceAll("'","'\\''")}'`}function Pn(e,t,r=!0,a="posix"){const s=An(a,t);return e==="opencode"?`opencode${r?" --auto":""} --prompt ${s}\r`:`${gt(e,r)} ${s}\r`}async function Rn(e,t=Ie,r=fe){const a=Cn(e);await On(`/rename ${a}`,t,r)}function Dn(e,t,r,a=fe){Y("dispatch-rename",{phase:"queued",caller:t,label:e,delayMs:we}),setTimeout(()=>{Y("dispatch-rename",{phase:"fired",caller:t,label:e,delayMs:we}),Rn(e,r,a)},we)}const Le=".codeyam/tmp/inline-prompt.md";function In(e){return e.split(`
|
|
4
|
+
`).map(t=>t.startsWith("'@")?` ${t}`:t).join(`
|
|
5
|
+
`)}function Ln(e){return`mkdir -p .codeyam/tmp && cat > ${Le} << 'INLINE_PROMPT_EOF'
|
|
6
|
+
${e}
|
|
7
|
+
INLINE_PROMPT_EOF\r`}function $n(e){return`New-Item -ItemType Directory -Force -Path .codeyam/tmp | Out-Null; @'
|
|
8
|
+
${In(e)}
|
|
9
|
+
'@ | Set-Content -LiteralPath ${Le} -Encoding utf8\r`}function Bn(e,t,r=!0,a="posix"){const s=gt(e,r),o=a==="powershell"?$n(t):Ln(t),c=`${s} "Read the file at '${Le}' for your instructions."\r`;return[o,c]}function Fn({attempt:e,sawOutput:t}){return t?e===1?"extend":"confirm":e===1?"retry":"fail"}function Kn({idleMs:e,ceilingMs:t}){return new Promise(r=>{let a=null,s=null,o=!1;function c(){o||(o=!0,a!==null&&clearTimeout(a),s!==null&&clearTimeout(s),window.removeEventListener("miniagent-output",p),r())}function i(){a!==null&&clearTimeout(a),a=setTimeout(c,e)}function p(){i()}window.addEventListener("miniagent-output",p),s=setTimeout(c,t),i()})}const zn=350,Hn=4e3,qe=8e3,Vn=500,W={armed:"mini-agent-launch-armed",fired:"mini-agent-launch-fired",confirmed:"mini-agent-launch-confirmed",relaunch:"mini-agent-relaunch",failed:"mini-agent-launch-failed",reattached:"mini-agent-launch-reattached"};function Yn(e){const{provider:t,slashCommand:r,prompt:a,chatName:s,sendInput:o,permissionModeAuto:c=!0,shellDialect:i=null}=e,[p,u]=l.useState("idle"),b=l.useRef(o),h=l.useRef(r),d=l.useRef(a),x=l.useRef(s),m=l.useRef(t),g=l.useRef(c),y=l.useRef(i);l.useEffect(()=>{b.current=o},[o]),l.useEffect(()=>{g.current=c},[c]),l.useEffect(()=>{y.current=i},[i]),l.useEffect(()=>{h.current=r},[r]),l.useEffect(()=>{d.current=a},[a]),l.useEffect(()=>{x.current=s},[s]),l.useEffect(()=>{m.current=t},[t]);const f=l.useRef(0),v=l.useRef(!1),k=l.useRef(0),_=l.useRef(0),w=l.useRef(0);l.useEffect(()=>{const T=()=>{_.current+=1};return window.addEventListener("miniagent-output",T),()=>window.removeEventListener("miniagent-output",T)},[]);const P=l.useCallback((T,O)=>{const I=h.current,A=d.current;return De(Xe,()=>{const K=y.current??"posix";if(I){const z=Pn(m.current,I,g.current,K),q=Se(z);return T(q),new Promise(S=>{setTimeout(()=>{O()&&T("\r"),S()},le)})}const[R,V]=Bn(m.current,A??"",g.current,K),U=Se(R),H=Se(V);return T(U),new Promise(z=>{setTimeout(()=>{if(!O())return z();T("\r"),setTimeout(()=>{if(!O())return z();T(H),setTimeout(()=>{O()&&T("\r"),z()},le)},Vn)},le)})})},[]),B=l.useCallback(()=>{const T=++f.current,O=Date.now();k.current=O,w.current=_.current,u("armed"),Y(W.armed,{provider:m.current,slashCommand:h.current,chatName:x.current,hasPrompt:typeof d.current=="string"});function I(){return f.current===T}function A(R){I()&&(u(R===1?"firing":"retrying"),Y(R===1?W.fired:W.relaunch,{provider:m.current,slashCommand:h.current,chatName:x.current,attempt:R,elapsedMs:Date.now()-O}),P(b.current,I).then(()=>{I()&&(w.current=_.current)}),!v.current&&vr(m.current)&&(v.current=!0,Dn(x.current,"mini-agent-chat",V=>b.current(V),Xe)),setTimeout(()=>K(R),qe))}function K(R){if(!I())return;const V=_.current>w.current;switch(Fn({attempt:R,sawOutput:V})){case"retry":A(2);return;case"extend":Y(W.relaunch,{provider:m.current,slashCommand:h.current,attempt:2,sawOutput:!0,resent:!1,elapsedMs:Date.now()-O}),setTimeout(()=>K(2),qe);return;case"confirm":u("confirmed"),Y(W.confirmed,{provider:m.current,slashCommand:h.current,reason:"output-without-banner",sawOutput:!0,elapsedMs:Date.now()-O});return;case"fail":u("failed"),Y(W.failed,{provider:m.current,slashCommand:h.current,reason:"banner-timeout",sawOutput:!1,elapsedMs:Date.now()-O})}}Kn({idleMs:zn,ceilingMs:Hn}).then(()=>{I()&&A(1)})},[P]),E=l.useCallback(()=>{v.current=!1,B()},[B]),j=l.useCallback(()=>{B()},[B]),F=l.useCallback(()=>{f.current!==0&&(f.current++,u("confirmed"),Y(W.confirmed,{elapsedMs:Date.now()-k.current}))},[]),N=l.useCallback(()=>{f.current!==0&&(f.current++,u("failed"),Y(W.failed,{reason:"startup-failed",elapsedMs:Date.now()-k.current}))},[]),D=l.useCallback(()=>{f.current++,u("confirmed"),Y(W.reattached,{provider:m.current,chatName:x.current})},[]);return l.useEffect(()=>()=>{f.current++},[]),{status:p,arm:E,retry:j,onBannerReady:F,onStartupFailed:N,onReattached:D}}function Se(e){return e.endsWith("\r")?e.slice(0,-1):e}const pe=l.createContext({registerSender:()=>{},setReady:()=>{},sendToAgent:()=>!1,agentReady:!1});function Wn({children:e}){const t=l.useRef(null),[r,a]=l.useState(!1),s=l.useCallback(p=>{t.current=p},[]),o=l.useCallback(p=>{a(p)},[]),c=l.useCallback(p=>{const u=t.current;return u?u(p):!1},[]),i=l.useMemo(()=>({registerSender:s,setReady:o,sendToAgent:c,agentReady:r}),[s,o,c,r]);return n.jsx(pe.Provider,{value:i,children:e})}function Un(){const{sendToAgent:e,agentReady:t}=l.useContext(pe);return{sendToAgent:e,agentReady:t}}function Xn(e,t){const{registerSender:r,setReady:a}=l.useContext(pe);l.useEffect(()=>(r(e),()=>r(null)),[r,e]),l.useEffect(()=>(a(t),()=>a(!1)),[a,t])}function yt(){const{registerSender:e,setReady:t}=l.useContext(pe);return{registerSender:e,setReady:t}}const Ja=Object.freeze(Object.defineProperty({__proto__:null,AgentInputProvider:Wn,useAgentInput:Un,useAgentInputChannel:yt,useRegisterAgentInput:Xn},Symbol.toStringTag,{value:"Module"})),vt=l.createContext({openPicker:()=>{}});function Jn({openPicker:e,children:t}){const r=l.useMemo(()=>({openPicker:e}),[e]);return n.jsx(vt.Provider,{value:r,children:t})}function jt(){return l.useContext(vt)}const qa=Object.freeze(Object.defineProperty({__proto__:null,FilePickerProvider:Jn,useFilePicker:jt},Symbol.toStringTag,{value:"Module"}));function _t({className:e=""}){const{openPicker:t}=jt();return n.jsxs("button",{type:"button",onClick:t,title:"Attach a file","aria-label":"Attach a file","data-testid":"attach-file-button",className:`inline-flex items-center gap-1 text-xs font-medium cursor-pointer bg-transparent border-none text-[var(--text-dim)] hover:text-[var(--text-primary)] transition ${e}`,children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n.jsx("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})}),"Attach file"]})}const Ga=Object.freeze(Object.defineProperty({__proto__:null,AttachFileButton:_t},Symbol.toStringTag,{value:"Module"})),Ge=15;function wt({chatName:e,prompt:t,slashCommand:r,height:a=400,onClose:s}){const o=l.useRef(null),c=l.useRef(null),i=l.useRef(null);l.useRef(t);const{config:p}=et(),u=(p==null?void 0:p.provider)??"claude",[b,h]=l.useState({kind:"connecting"}),[d,x]=l.useState(0),m=l.useCallback(E=>{const j=c.current;(j==null?void 0:j.readyState)===WebSocket.OPEN&&j.send(JSON.stringify({type:"input",data:E}))},[]),{registerSender:g,setReady:y}=yt(),f=l.useCallback(E=>{var j;return((j=c.current)==null?void 0:j.readyState)===WebSocket.OPEN?(c.current.send(JSON.stringify({type:"input",data:E})),!0):!1},[]),v=b.kind==="open";l.useEffect(()=>(v&&g(f),()=>g(null)),[g,f,v]),l.useEffect(()=>(y(v),()=>y(!1)),[y,v]);const k=l.useCallback(()=>{var E;((E=c.current)==null?void 0:E.readyState)===WebSocket.OPEN&&(g(f),y(!0)),jn(o.current,()=>{var j;return(j=i.current)==null?void 0:j.focus()})},[g,y,f]),{shellDialect:_}=dr(),w=Yn({provider:u,slashCommand:r,prompt:t,chatName:e,sendInput:m,permissionModeAuto:(p==null?void 0:p.claudePermissionModeAuto)??!0,shellDialect:_}),P=l.useRef(w);l.useEffect(()=>{P.current=w});const B=l.useRef(e);return l.useEffect(()=>{B.current=e}),l.useEffect(()=>{const E=o.current;if(!E)return;const j=new nn.Terminal({theme:{background:"#1a1a1a",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78"},fontSize:12,fontFamily:"'IBM Plex Mono', 'Menlo', 'Monaco', monospace",cursorBlink:!0,scrollback:5e3,allowProposedApi:!0}),F=new an.FitAddon;j.loadAddon(F),j.open(E);const N=un(j,E,{onError:S=>console.warn("[MiniAgentChat]",S)}),D=yn(j,{sendInput:S=>{const C=c.current;(C==null?void 0:C.readyState)===WebSocket.OPEN&&C.send(JSON.stringify({type:"input",data:S}))}});requestAnimationFrame(()=>{try{F.fit()}catch{}}),i.current=j;const T={current:"inline"},O={current:null},I={current:!1},A={current:!1};let K=0,R=null;function V(){h({kind:"connecting"});const S=sn({mode:T.current,sessionId:O.current??void 0,chatKey:e,cols:j.cols,rows:j.rows}),C=new WebSocket(S);C.binaryType="arraybuffer",c.current=C,C.onopen=()=>{K=0,h({kind:"open"}),_e(!0),window.dispatchEvent(new CustomEvent("miniagent-ws-open")),C.send(JSON.stringify({type:"resize",cols:j.cols,rows:j.rows}))},C.onmessage=L=>{if(L.data instanceof ArrayBuffer){j.write(new Uint8Array(L.data)),window.dispatchEvent(new CustomEvent("miniagent-output"));return}try{const $=JSON.parse(L.data);if($.type==="error"){A.current=!0,h({kind:"server-error",message:Sn($)});return}if($.type==="session-id"){if($.sessionId&&(O.current=$.sessionId,T.current="resume"),$.reattached===!0){I.current=!0,P.current.onReattached();return}I.current||(I.current=!0,P.current.arm());return}if($.type==="agent-idle"||$.type==="claude-idle"){window.dispatchEvent(new CustomEvent("miniagent-agent-idle",{detail:{chatName:B.current}}));return}if($.type==="agent-active"||$.type==="claude-active"){window.dispatchEvent(new CustomEvent("miniagent-agent-active",{detail:{chatName:B.current}}));return}if($.type==="agent-banner-ready"){P.current.onBannerReady();return}if($.type==="agent-auth-required"){window.dispatchEvent(new CustomEvent("agent-auth-required"));return}if($.type==="startup-failed"){P.current.onStartupFailed();return}}catch{j.write(L.data),window.dispatchEvent(new CustomEvent("miniagent-output"))}},C.onerror=()=>{},C.onclose=async()=>{if(_e(!1),A.current){h($=>$.kind==="server-error"?$:{kind:"ended"});return}const L=await it();if(!A.current){if(!L){h({kind:"server-stopped"}),R==null||R(),R=_n(2e3,()=>{A.current||window.location.reload()});return}if(K<Ge){const $=K<4?1e3*Math.pow(2,K):1e4;K++,h({kind:"reconnecting",attempt:K,maxAttempts:Ge}),setTimeout(()=>{A.current||V()},$)}else h({kind:"failed"})}}}try{F.fit()}catch{}V(),j.onData(S=>{const C=c.current;(C==null?void 0:C.readyState)===WebSocket.OPEN?C.send(JSON.stringify({type:"input",data:S})):x(L=>L+1)});const U=new ResizeObserver(()=>{try{F.fit();const S=c.current;(S==null?void 0:S.readyState)===WebSocket.OPEN&&S.send(JSON.stringify({type:"resize",cols:j.cols,rows:j.rows}))}catch{}});U.observe(E);function H(S){const C=i.current;if(!C)return;const L=S.target;if(L!=null&&L.closest(".xterm-viewport")||C.buffer.active.length<=C.rows)return;const ae=ln(S.deltaY,S.deltaMode);ae!==0&&(C.scrollLines(ae),S.preventDefault(),S.stopPropagation())}E.addEventListener("wheel",H,{passive:!1});function z(){var S;(S=i.current)==null||S.focus()}window.addEventListener("terminal-focus",z);function q(S){const C=S.detail,L=c.current;typeof C=="string"&&(L==null?void 0:L.readyState)===WebSocket.OPEN&&L.send(JSON.stringify({type:"input",data:C}))}return window.addEventListener("miniagent-send-input",q),()=>{var C;A.current=!0,_e(!1),R==null||R(),R=null,window.removeEventListener("terminal-focus",z),window.removeEventListener("miniagent-send-input",q),E.removeEventListener("wheel",H),U.disconnect(),N(),D();const S=c.current;(S==null?void 0:S.readyState)===WebSocket.OPEN&&S.close(),(C=i.current)==null||C.dispose()}},[u]),n.jsxs("div",{"data-codeyam-hydrated":"MiniAgentChat",className:"mt-2 border border-[var(--border-subtle)] rounded-lg overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[var(--bg-card)]",children:[n.jsx("span",{className:"text-xs font-medium text-[var(--accent-active)]",children:re(u)}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(_t,{}),s&&n.jsx("button",{onClick:s,className:"text-[var(--text-dim)] hover:text-[var(--text-primary)] text-xs bg-transparent border-none cursor-pointer",children:"Close"})]})]}),n.jsxs("div",{ref:o,className:"mini-agent-terminal",tabIndex:-1,onPointerDown:k,onClick:k,style:{height:a,background:"#1a1a1a",padding:"6px 10px",position:"relative",overflow:"hidden",outline:"none"},children:[n.jsx(xt,{status:b,pulseKey:d,onRefresh:()=>window.location.reload()}),n.jsx(bt,{status:w.status,onRetry:w.retry})]})]})}const Qa=Object.freeze(Object.defineProperty({__proto__:null,MiniAgentChat:wt},Symbol.toStringTag,{value:"Module"}));function St(e){return e>=500?"transient":"rejected"}function kt({provider:e,onAuthenticated:t}){const[r,a]=l.useState(""),[s,o]=l.useState(!1),[c,i]=l.useState(null),[p,u]=l.useState(!1),b=re(e),h=l.useCallback(async()=>{if(r.trim()){o(!0),i(null),u(!1);try{const d=await fetch("/api/auth/api-key",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({provider:e,key:r.trim()})});if(!d.ok){if(St(d.status)==="transient"){u(!0),i(`The editor was briefly unreachable (HTTP ${d.status}). Your key wasn't rejected — try again.`);return}const x=await d.json().catch(()=>({}));i(x.error??`Could not save the key (HTTP ${d.status}).`);return}a(""),t()}catch{u(!0),i("Could not reach the editor to save the key. Try again.")}finally{o(!1)}}},[r,e,t]);return n.jsxs("div",{"data-testid":"api-key-flow",className:"space-y-3",children:[n.jsxs("p",{className:"text-sm text-[#8E8E8E]",children:["Paste your ",b," API key. It is stored locally in",n.jsx("code",{className:"mx-1 text-[#D7FF63]",children:".codeyam/editor.local.json"}),"and never committed."]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"password",value:r,onChange:d=>a(d.target.value),placeholder:`${b} API key`,className:"flex-1 min-w-0 px-2 py-1.5 rounded bg-black border border-[#3A3A3A] text-white text-sm"}),n.jsx("button",{onClick:()=>void h(),disabled:s||!r.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer disabled:opacity-50",children:s?"Saving…":"Save"})]}),c?n.jsxs("div",{className:"space-y-2",children:[n.jsx("p",{className:"text-sm text-[#FF8B43]",children:c}),p?n.jsx("button",{"data-testid":"api-key-flow-retry",onClick:()=>void h(),disabled:s||!r.trim(),className:"px-3 py-1.5 text-sm rounded-md border border-[#3A3A3A] text-white font-medium cursor-pointer disabled:opacity-50",children:s?"Saving…":"Retry"}):null]}):null]})}const Za=Object.freeze(Object.defineProperty({__proto__:null,ApiKeyFlow:kt,classifyApiKeySaveFailure:St},Symbol.toStringTag,{value:"Module"})),qn=500,Gn=75e3;function Ct({onAuthenticated:e}){const[t,r]=l.useState({state:"starting"}),[a,s]=l.useState(""),[o,c]=l.useState(!1),[i,p]=l.useState(!1),[u,b]=l.useState(!1),[h,d]=l.useState(!1),x=l.useRef(!1),m=l.useRef(e);m.current=e;const g=l.useCallback(async()=>{try{const w=await fetch("/api/auth/status");if(!w.ok)return;const P=await w.json();r(P),P.state==="authenticated"&&!x.current&&(x.current=!0,m.current())}catch{}},[]),y=l.useCallback(async()=>{x.current=!1,b(!1),r({state:"starting"});try{await fetch("/api/auth/start",{method:"POST"})}catch{r({state:"failed",error:"Could not start the login process."})}},[]);l.useEffect(()=>{y()},[y]),l.useEffect(()=>{const w=window.setInterval(()=>void g(),qn);return()=>window.clearInterval(w)},[g]),l.useEffect(()=>{if(t.state!=="starting"){b(!1);return}const w=window.setTimeout(()=>b(!0),Gn);return()=>window.clearTimeout(w)},[t.state]);const f=l.useCallback(async()=>{if(a.trim()){c(!0);try{const w=await fetch("/api/auth/code",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:a.trim()})});if(w.ok)s("");else{const P=await w.json().catch(()=>({}));r({state:"failed",error:P.error??"Code not accepted — check the value and try again."})}}catch{r({state:"failed",error:"Could not submit the code."})}finally{c(!1)}}},[a]),v=l.useCallback(async()=>{try{await fetch("/api/auth/cancel",{method:"POST"})}catch{}y()},[y]),k=l.useCallback(async()=>{d(!0);try{await fetch("/api/auth/refresh-cache",{method:"POST"}),e()}catch{}finally{d(!1)}},[e]),_=l.useCallback(()=>{var w;t.url&&((w=navigator.clipboard)==null||w.writeText(t.url),p(!0),window.setTimeout(()=>p(!1),1500))},[t.url]);return u&&t.state==="starting"?n.jsxs("div",{"data-testid":"claude-oauth-timeout",className:"space-y-3",children:[n.jsxs("p",{className:"text-sm text-[#FF8B43]",children:["Login link preparation timed out — the backend may be wedged. Try again, recheck if you already authenticated elsewhere, or open a terminal and run ",n.jsx("code",{className:"text-white",children:"claude /login"})," ","directly."]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{onClick:()=>void v(),"data-testid":"claude-oauth-timeout-retry",className:"px-3 py-2 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer",children:"Retry"}),n.jsx("button",{onClick:()=>void k(),"data-testid":"claude-oauth-timeout-recheck",disabled:h,className:"px-3 py-2 text-sm rounded-md border border-[#3A3A3A] text-white cursor-pointer disabled:opacity-50",children:h?"Rechecking…":"I already logged in — recheck"})]})]}):t.state==="failed"?n.jsxs("div",{"data-testid":"claude-oauth-failed",className:"space-y-3",children:[n.jsx("p",{className:"text-sm text-[#FF8B43]",children:t.error??"Login failed."}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{onClick:()=>void v(),className:"px-3 py-2 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer",children:"Try again"}),n.jsx("button",{onClick:()=>void k(),"data-testid":"claude-oauth-failed-recheck",disabled:h,className:"px-3 py-2 text-sm rounded-md border border-[#3A3A3A] text-white cursor-pointer disabled:opacity-50",children:h?"Rechecking…":"I already logged in — recheck"})]})]}):t.state==="authenticated"?n.jsx("p",{"data-testid":"claude-oauth-authenticated",className:"text-sm text-[#D7FF63]",children:"Connected. Opening Build…"}):t.state==="url-ready"&&t.url?n.jsxs("div",{"data-testid":"claude-oauth-url-ready",className:"space-y-3",children:[n.jsx("p",{className:"text-sm text-[#8E8E8E]",children:"Open this URL in your browser, approve access, then paste the code back here:"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("code",{className:"flex-1 min-w-0 truncate px-2 py-1.5 rounded bg-black text-[#D7FF63] text-xs",children:t.url}),n.jsx("button",{onClick:_,className:"px-2 py-1.5 text-xs rounded-md border border-[#3A3A3A] text-white cursor-pointer",children:i?"Copied":"Copy"}),n.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"px-2 py-1.5 text-xs rounded-md border border-[#3A3A3A] text-white cursor-pointer",children:"Open"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"text",value:a,onChange:w=>s(w.target.value),placeholder:"Paste the code from the browser here",className:"flex-1 min-w-0 px-2 py-1.5 rounded bg-black border border-[#3A3A3A] text-white text-sm"}),n.jsx("button",{onClick:()=>void f(),disabled:o||!a.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer disabled:opacity-50",children:o?"Submitting…":"Submit"})]})]}):n.jsx("p",{"data-testid":"claude-oauth-starting",className:"text-sm text-[#8E8E8E]",children:"Preparing the login link…"})}const es=Object.freeze(Object.defineProperty({__proto__:null,ClaudeOAuthFlow:Ct},Symbol.toStringTag,{value:"Module"}));function Nt({provider:e,onAuthenticated:t,onClose:r}){const a=re(e);return n.jsx("div",{"data-testid":"provider-auth-modal",className:"fixed inset-0 z-[100] flex items-center justify-center",style:{background:"rgba(30, 30, 30, 0.90)"},children:n.jsxs("div",{className:"w-[32rem] max-w-[90vw] rounded-lg border border-[#3A3A3A] bg-[#1E1E1E] p-6 space-y-4",children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("h2",{className:"text-base font-medium text-white",children:["Connect your ",a," account"]}),n.jsx("button",{onClick:r,"aria-label":"Close",className:"text-[#8E8E8E] hover:text-white cursor-pointer",children:"✕"})]}),e==="claude"?n.jsx(Ct,{onAuthenticated:t}):n.jsx(kt,{provider:e,onAuthenticated:t})]})})}const ts=Object.freeze(Object.defineProperty({__proto__:null,ProviderAuthModal:Nt},Symbol.toStringTag,{value:"Module"}));function Qn(e){const t=new Date(e).getTime()-Date.now(),r=Math.abs(Math.round(t/36e5));if(r<1)return t<0?"just now":"very soon";if(r<48)return t<0?`${r} h ago`:`in ${r} h`;const a=Math.round(r/24);return t<0?`${a} d ago`:`in ${a} d`}function Et({provider:e,credsPresent:t=!0,reason:r=null,expiresAt:a=null,sessionOngoing:s=!1,onAuthenticated:o,onAuthorized:c}){const[i,p]=l.useState(!1),[u,b]=l.useState(!1),h=re(e),d=l.useCallback(()=>{p(!1),o(),c==null||c()},[o,c]),x=l.useCallback(async()=>{b(!0);try{await fetch("/api/auth/refresh-cache",{method:"POST"}),o()}catch{}finally{b(!1)}},[o]),m=e==="claude"&&!t,g=a?` (token expired ${Qn(a)})`:"",y=m?`${h} credentials file is missing`:r==="token-expired"?`Your ${h} token has expired`:r==="api-401"?`${h} authentication rejected (401)`:`Connect your ${h} account`,f=s?" Your Build session stays open — you can finish logging in here or directly in the Build terminal.":"",v=m?"The editor couldn't find ~/.claude/.credentials.json on this machine — likely deleted between editor restarts (operator-side action, a Reconfigure, or a stale image). Re-seed by clicking Authenticate to run OAuth, or — on a fleet VM — copy the file from a donor VM through the dashboard.":r==="token-expired"?`Your ${h} token has expired${g} — click Authenticate to refresh it. On a fleet VM the dashboard can copy a fresh token from a donor VM.${f}`:r==="api-401"?`The ${h} server rejected your credentials (401)${g}. This usually means the token was revoked or expired. Click Authenticate to re-connect.${f}`:s?"You can finish logging in here or directly in the Build terminal — your session stays open either way. On a cloud VM the dashboard usually does this for you; locally you connect once here.":`Authentication used to happen inside the Build terminal. Now it lives here, out of your way. Connect ${h} to unlock the Build tab. On a cloud VM the dashboard usually does this for you; locally you connect once here.`;return n.jsxs("div",{"data-testid":"provider-auth-gate","data-auth-variant":m?"creds-missing":"needs-login","data-auth-card":!0,className:"m-4 rounded-lg border border-[#D7FF63]/40 bg-[#1E1E1E] p-5 space-y-3",children:[n.jsx("h2",{className:"text-base font-medium text-white",children:y}),n.jsx("p",{className:"text-sm text-[#8E8E8E]",children:v}),n.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[n.jsx("button",{onClick:()=>p(!0),className:"px-3 py-2 text-sm rounded-md bg-[#D7FF63] text-black font-medium cursor-pointer",children:"Authenticate"}),n.jsx("button",{onClick:()=>void x(),"data-testid":"provider-auth-gate-recheck",disabled:u,className:"px-3 py-2 text-sm rounded-md border border-[#3A3A3A] text-white cursor-pointer disabled:opacity-50",children:u?"Rechecking…":"Already logged in? Recheck"})]}),i?n.jsx(Nt,{provider:e,onAuthenticated:d,onClose:()=>p(!1)}):null]})}const rs=Object.freeze(Object.defineProperty({__proto__:null,ProviderAuthenticateCta:Et},Symbol.toStringTag,{value:"Module"}));let ke=!1;function Tt(e){const{state:t,provider:r,credsPresent:a,reason:s,expiresAt:o,refresh:c}=rn(),[i]=l.useState(()=>ke);return l.useEffect(()=>{t==="authenticated"?ke=!0:t==="needs-login"&&(ke=!1)},[t]),t==="needs-login"?n.jsx(Et,{provider:r,credsPresent:a,reason:s,expiresAt:o,onAuthenticated:()=>void c(),onAuthorized:()=>{}}):t==="authenticated"||i?n.jsx(wt,{...e}):n.jsxs("div",{"data-testid":"gated-agent-chat-checking",className:"mt-2 flex items-center gap-3 rounded-lg border border-[var(--border-subtle)] px-3 py-4",children:[n.jsx("span",{"aria-hidden":"true",className:"h-4 w-4 rounded-full border-2 border-[var(--text-dim)] border-t-transparent animate-spin"}),n.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"Checking your account…"})]})}const ns=Object.freeze(Object.defineProperty({__proto__:null,GatedAgentChat:Tt},Symbol.toStringTag,{value:"Module"}));function Ot(){return n.jsx("div",{className:"flex h-full items-center justify-center p-6",children:n.jsxs("div",{className:"max-w-xs text-center space-y-2",children:[n.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"No scenario data yet."}),n.jsx("p",{className:"text-xs text-[var(--text-dim)]",children:"Seed data and HTTP mocks will appear here as the scenario captures them, or add them with the scenario editor."})]})})}const as=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelEmptyState:Ot},Symbol.toStringTag,{value:"Module"}));function Mt({variant:e,onClose:t}){return e!=="slideOver"?null:n.jsx("button",{onClick:t,className:"rounded border border-[var(--border-default)] bg-transparent px-2 py-1 text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"Close"})}const ss=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelCloseButton:Mt},Symbol.toStringTag,{value:"Module"}));function At({variant:e,providerLabel:t,chatOpen:r,onToggleChat:a}){const s=e==="inline",o=s?"flex items-center gap-1.5 px-3 py-1.5 rounded border text-xs font-medium cursor-pointer transition-colors":"flex items-center gap-1.5 px-2.5 py-1 rounded border text-xs cursor-pointer transition-colors",c=r?"border-[var(--accent-active)] bg-[var(--accent-active)]/15 text-[var(--accent-active)]":s?"border-[var(--accent-active)] bg-[var(--accent-active)] text-black hover:bg-[var(--accent-active)]/90":"border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:border-[var(--accent-active)]/40";return n.jsxs("button",{type:"button",onClick:a,className:`${o} ${c}`,title:`Open a chat with ${t} seeded with this scenario's context`,children:[n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),"Edit with ",t]})}const os=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelEditChatButton:At},Symbol.toStringTag,{value:"Module"})),Oe=new Set,Me=new Set;let Pt={isActive:!1,previewSlug:null};function Zn(){for(const e of Oe)e()}function is(e){return Oe.add(e),()=>{Oe.delete(e)}}function cs(e){Pt=e;for(const t of Me)t(e)}function ea(e){return Me.add(e),()=>{Me.delete(e)}}function Qe(){return Pt}function ta(){const[e,t]=l.useState(()=>Qe());return l.useEffect(()=>(t(Qe()),ea(t)),[]),e}function Rt({panelSlug:e,scenarioState:t}){const r=ta(),{isActive:a,previewSlug:s}=t??r;return s!==e?null:n.jsxs("button",{type:"button","aria-pressed":a,onClick:()=>Zn(),title:a?"Exit inspect data source":"Inspect data source — click a value in the live preview to see its mock",className:a?"flex items-center gap-1.5 px-2.5 py-1 rounded border text-xs cursor-pointer transition-colors border-[var(--accent-active)] bg-[var(--accent-active)]/15 text-[var(--accent-active)]":"flex items-center gap-1.5 px-2.5 py-1 rounded border text-xs cursor-pointer transition-colors border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:border-[var(--accent-active)]/40",children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"11",cy:"11",r:"8"}),n.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),a?"Inspecting…":"Inspect data"]})}const ls=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelInspectButton:Rt},Symbol.toStringTag,{value:"Module"}));function Dt({variant:e,slug:t}){const r=()=>window.open(mr(t),"_blank");return e==="slideOver"?n.jsx("button",{type:"button",onClick:r,className:"p-1.5 rounded text-[var(--text-dim)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-card)] transition-colors cursor-pointer",title:"Open in new window",children:n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),n.jsx("polyline",{points:"15 3 21 3 21 9"}),n.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}):e==="inline"?n.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1.5 px-2.5 py-1 rounded border border-[var(--border-default)] bg-transparent text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:border-[var(--accent-active)]/40 transition-colors cursor-pointer",title:"Open the full data editor in a new browser tab",children:[n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),n.jsx("polyline",{points:"15 3 21 3 21 9"}),n.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Open in new tab"]}):null}const ds=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelOpenInNewButton:Dt},Symbol.toStringTag,{value:"Module"}));function It(e){if(!e)return"Unsaved changes";const t=[];e.mocks.length>0&&t.push(`${e.mocks.length} mock${e.mocks.length===1?"":"s"}`);const r=e.seed.length;return r>0&&t.push(`${r} seed ${r===1?"table":"tables"}`),t.length>0?`Unsaved changes (${t.join(", ")})`:"Unsaved changes"}function Lt({diff:e,saving:t,cancelling:r,error:a,onSave:s,onCancel:o}){return n.jsxs("div",{className:"flex items-center justify-between gap-2 rounded border border-amber-500/40 bg-amber-500/10 px-2 py-1.5","data-testid":"scenario-draft-bar",children:[n.jsx("span",{className:"text-xs text-amber-300 font-medium",children:It(e)}),n.jsxs("div",{className:"flex items-center gap-2",children:[a&&n.jsx(te,{text:a,className:"text-xs text-red-400"}),n.jsx("button",{type:"button",onClick:o,disabled:r||t,className:"px-2 py-0.5 text-xs rounded border border-[var(--border-default)] bg-[var(--bg-surface)] text-[var(--text-primary)] hover:bg-[var(--bg-input)] disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",children:r?"Discarding…":"Cancel"}),n.jsx("button",{type:"button",onClick:s,disabled:r||t,className:"px-3 py-0.5 text-xs rounded border border-[var(--accent-blue)] bg-[var(--accent-blue)]/20 text-[var(--accent-blue)] hover:bg-[var(--accent-blue)]/30 disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",children:t?"Saving…":"Save"})]})]})}const us=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDraftBar:Lt,summarizeDraftDiff:It},Symbol.toStringTag,{value:"Module"}));function $t({title:e,slug:t,provider:r,chatOpen:a,onToggleChat:s,variant:o,onClose:c,draftDirty:i,draftDiff:p,draftSaving:u,draftCancelling:b,draftError:h,onSave:d,onCancel:x}){const m=re(r),g=!!i&&!!d&&!!x;return n.jsxs("header",{className:"flex flex-col gap-2 border-b border-[var(--border-subtle)] bg-[var(--bg-deep)] px-4 py-3",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx("div",{className:"min-w-0",children:n.jsxs("h2",{className:"text-sm font-medium text-[var(--text-primary)] truncate",children:["Scenario data: ",e]})}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(At,{variant:o,providerLabel:m,chatOpen:a,onToggleChat:s}),n.jsx(Rt,{panelSlug:t}),n.jsx(Dt,{variant:o,slug:t}),c&&n.jsx(Mt,{variant:o,onClose:c})]})]}),g&&d&&x&&n.jsx(Lt,{diff:p??null,saving:u??!1,cancelling:b??!1,error:h??null,onSave:d,onCancel:x})]})}const fs=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelHeader:$t},Symbol.toStringTag,{value:"Module"}));function ra(e,t){const[r,a]=l.useState(e.status??200),[s,o]=l.useState(e.body??null),[c,i]=l.useState(()=>Object.entries(e.headers??{}).map(([h,d])=>({name:h,value:d})));l.useEffect(()=>{a(e.status??200),o(e.body??null),i(Object.entries(e.headers??{}).map(([h,d])=>({name:h,value:d})))},[t,e.status,e.body,e.headers]);const p=l.useMemo(()=>e.headers??{},[e.headers]),u=l.useMemo(()=>{if((e.status??200)!==r||JSON.stringify(e.body??null)!==JSON.stringify(s))return!0;const h={};for(const g of c)g.name.trim()&&(h[g.name.trim()]=g.value);const d=p,x=Object.keys(d),m=Object.keys(h);if(x.length!==m.length)return!0;for(const g of m)if(d[g]!==h[g])return!0;return!1},[r,s,c,e.status,e.body,p]);return{status:r,setStatus:a,body:s,setBody:o,headers:c,setHeaders:i,isDirty:u,buildPayload:()=>{const h={};for(const d of c)d.name.trim()&&(h[d.name.trim()]=d.value);return{status:r,body:s,headers:h}}}}function Bt({body:e,onBodyChange:t}){const{copied:r,copy:a}=ur();async function s(){try{const c=await navigator.clipboard.readText(),i=JSON.parse(c);t(i)}catch{}}function o(){a(JSON.stringify(e,null,2))}return n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:()=>void s(),className:"text-[10px] px-2 py-0.5 rounded border border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:"Paste"}),n.jsx("button",{type:"button",onClick:o,className:"text-[10px] px-2 py-0.5 rounded border border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer",children:r?"Copied":"Copy"})]})}const ps=Object.freeze(Object.defineProperty({__proto__:null,JsonBodyActions:Bt},Symbol.toStringTag,{value:"Module"}));function ne(e){return JSON.stringify(e)}function Ft(e,t){return e?e instanceof Set?e.has(t):e.includes(t):!1}function na(e){const t=new Set;function r(a,s){if(a!==null&&typeof a=="object")if(t.add(ne(s)),Array.isArray(a))a.forEach((o,c)=>r(o,[...s,c]));else for(const[o,c]of Object.entries(a))r(c,[...s,o])}return r(e,[]),t}function aa(e){return e===null?"text-slate-400 italic":typeof e=="string"?"text-emerald-300":typeof e=="number"?"text-amber-300":typeof e=="boolean"?"text-[#D7FF63]":"text-[var(--text-primary)]"}function sa(e){return e===null?"null":typeof e=="string"?`"${e}"`:String(e)}function oa(e){return e===null?"null":typeof e=="string"?e:String(e)}function ia(e){const t=e.trim();if(t==="")return"";if(t==="null")return null;if(t==="true")return!0;if(t==="false")return!1;try{return JSON.parse(t)}catch{return e}}function he(e){return JSON.parse(JSON.stringify(e))}function ca(e,t,r){if(t.length===0)return r;const a=he(e);let s=a;for(let o=0;o<t.length-1;o++)s=s[t[o]];return s[t[t.length-1]]=r,a}function $e(e,t){if(t.length===0)return e;const r=he(e);let a=r;for(let o=0;o<t.length-1;o++)a=a[t[o]];const s=t[t.length-1];return Array.isArray(a)?a.splice(s,1):delete a[s],r}function la(e,t){const r=he(e);let a=r;for(const s of t)a=a[s];return Array.isArray(a)&&a.push(null),r}function da(e,t,r){const a=he(e);let s=a;for(const o of t)s=s[o];return s&&typeof s=="object"&&!Array.isArray(s)&&(s[r]=""),a}function ua(e){if(typeof e!="string"||e.length===0||e!=="$"&&!e.startsWith("$.")&&!e.startsWith("$["))return null;const t=[];let r=e[0]==="$"?1:0;for(;r<e.length;){const a=e[r];if(a==="."){r+=1;const s=r;for(;r<e.length&&e[r]!=="."&&e[r]!=="[";)r+=1;const o=e.slice(s,r);if(o.length===0)return null;t.push(o)}else if(a==="["){const s=e.indexOf("]",r);if(s===-1)return null;const o=e.slice(r+1,s);if(o.length===0)return null;const c=Number(o);if(!Number.isInteger(c)||c<0)return null;t.push(c),r=s+1}else return null}return t}function fa(e,t){l.useEffect(()=>{if(!e)return;const r=ua(e);r&&t(a=>{const s=new Set(a);for(let o=0;o<r.length;o++)s.add(ne(r.slice(0,o)));return s})},[e,t])}function me({collapsible:e,isOpen:t,onToggle:r,parentKey:a,readOnly:s,onRemove:o,children:c}){return n.jsxs("div",{className:"group/row flex items-center gap-1 min-h-[1.5em] hover:bg-[var(--bg-card)]/30 rounded px-1",children:[e?n.jsx("button",{type:"button",onClick:r,className:"w-4 h-4 flex items-center justify-center text-[var(--text-dim)] hover:text-[var(--text-primary)] bg-transparent border-none cursor-pointer p-0","aria-label":t?"Collapse":"Expand",children:n.jsx("span",{className:"text-[10px]",children:t?"▾":"▸"})}):n.jsx("span",{className:"w-4"}),a!==null&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-cyan-300",children:typeof a=="number"?`[${a}]`:a}),n.jsx("span",{className:"text-[var(--text-dim)]",children:":"})]}),n.jsx("div",{className:"flex-1 min-w-0 flex items-center gap-1",children:c}),!s&&o&&n.jsx("button",{type:"button",onClick:o,className:"opacity-0 group-hover/row:opacity-100 text-[10px] text-[var(--text-dim)] hover:text-red-400 bg-transparent border-none cursor-pointer px-1",title:"Remove",children:"×"})]})}const hs=Object.freeze(Object.defineProperty({__proto__:null,JsonTreeNodeLine:me},Symbol.toStringTag,{value:"Module"}));function Kt(e){const{value:t,path:r,parentKey:a,expanded:s,onToggle:o,readOnly:c}=e,i=ne(r),p=Ft(s,i),u=t.length>0;return n.jsxs("div",{children:[n.jsxs(me,{collapsible:u,isOpen:p,onToggle:()=>o(i),parentKey:a,readOnly:c,onRemove:r.length>0?()=>e.onValueChange($e(e.rootValue,r)):null,children:[n.jsx("span",{className:"text-[var(--text-dim)]",children:"["}),!p&&n.jsxs(n.Fragment,{children:[u&&n.jsxs("span",{className:"text-[var(--text-dim)] italic",children:[" ","…",t.length," item",t.length===1?"":"s"," "]}),n.jsx("span",{className:"text-[var(--text-dim)]",children:"]"})]})]}),p&&n.jsxs("div",{className:"ml-4 border-l border-[var(--border-subtle)] pl-2",children:[t.map((b,h)=>l.createElement(xe,{...e,key:h,value:b,path:[...r,h],parentKey:h,isLast:h===t.length-1})),!c&&n.jsx("button",{type:"button",onClick:()=>e.onValueChange(la(e.rootValue,r)),className:"text-[10px] text-[var(--accent-blue)] hover:underline bg-transparent border-none cursor-pointer py-0.5",children:"+ Add item"})]}),p&&n.jsx("div",{className:"text-[var(--text-dim)]",children:"]"})]})}const ms=Object.freeze(Object.defineProperty({__proto__:null,JsonTreeArrayNode:Kt},Symbol.toStringTag,{value:"Module"}));function zt({onSave:e,onCancel:t}){const[r,a]=l.useState("");return n.jsxs("div",{className:"flex items-center gap-1 py-0.5",children:[n.jsx("span",{className:"text-[var(--text-dim)] text-[10px]",children:"+ key:"}),n.jsx("input",{autoFocus:!0,value:r,onChange:s=>a(s.target.value),onBlur:()=>e(r),onKeyDown:s=>{s.key==="Enter"?(s.preventDefault(),e(r)):s.key==="Escape"&&(s.preventDefault(),t())},placeholder:"keyName",className:"rounded border border-[var(--accent-active)]/50 bg-[var(--bg-surface)] px-1 py-0 text-xs font-mono text-[var(--text-primary)] min-w-[6rem]"})]})}const xs=Object.freeze(Object.defineProperty({__proto__:null,JsonTreeAddKeyInput:zt},Symbol.toStringTag,{value:"Module"}));function Ht(e){const{value:t,path:r,parentKey:a,expanded:s,onToggle:o,readOnly:c,addingKeyAtPath:i,onStartAddKey:p,onStopAddKey:u}=e,b=ne(r),h=Ft(s,b),d=Object.entries(t),x=d.length>0,m=i===b;return n.jsxs("div",{children:[n.jsxs(me,{collapsible:x,isOpen:h,onToggle:()=>o(b),parentKey:a,readOnly:c,onRemove:r.length>0?()=>e.onValueChange($e(e.rootValue,r)):null,children:[n.jsx("span",{className:"text-[var(--text-dim)]",children:"{"}),!h&&n.jsxs(n.Fragment,{children:[x&&n.jsxs("span",{className:"text-[var(--text-dim)] italic",children:[" ","…",d.length," key",d.length===1?"":"s"," "]}),n.jsx("span",{className:"text-[var(--text-dim)]",children:"}"})]})]}),h&&n.jsxs("div",{className:"ml-4 border-l border-[var(--border-subtle)] pl-2",children:[d.map(([g,y],f)=>l.createElement(xe,{...e,key:g,value:y,path:[...r,g],parentKey:g,isLast:f===d.length-1})),!c&&!m&&n.jsx("button",{type:"button",onClick:()=>p(b),className:"text-[10px] text-[var(--accent-blue)] hover:underline bg-transparent border-none cursor-pointer py-0.5",children:"+ Add key"}),!c&&m&&n.jsx(zt,{onSave:g=>{g.trim()&&e.onValueChange(da(e.rootValue,r,g.trim())),u()},onCancel:u})]}),h&&n.jsx("div",{className:"text-[var(--text-dim)]",children:"}"})]})}const bs=Object.freeze(Object.defineProperty({__proto__:null,JsonTreeObjectNode:Ht},Symbol.toStringTag,{value:"Module"}));function Vt({initial:e,onSave:t,onCancel:r}){const[a,s]=l.useState(e);return n.jsx("input",{autoFocus:!0,value:a,onChange:o=>s(o.target.value),onBlur:()=>t(a),onKeyDown:o=>{o.key==="Enter"?(o.preventDefault(),t(a)):o.key==="Escape"&&(o.preventDefault(),r())},className:"flex-1 min-w-[4rem] rounded border border-[var(--accent-active)]/50 bg-[var(--bg-surface)] px-1 py-0 text-xs font-mono text-[var(--text-primary)]"})}const gs=Object.freeze(Object.defineProperty({__proto__:null,JsonTreePrimitiveEditor:Vt},Symbol.toStringTag,{value:"Module"}));function Yt(e){const{value:t,path:r,parentKey:a,readOnly:s,editingPath:o,onStartEdit:c,onStopEdit:i}=e,p=ne(r),u=o===p;return n.jsx(me,{collapsible:!1,isOpen:!1,parentKey:a,readOnly:s,onToggle:()=>{},onRemove:r.length>0?()=>e.onValueChange($e(e.rootValue,r)):null,children:u?n.jsx(Vt,{initial:oa(t),onSave:b=>{const h=ia(b);e.onValueChange(ca(e.rootValue,r,h)),i()},onCancel:i}):n.jsx("button",{type:"button",onClick:s?void 0:()=>c(p),disabled:s,className:`${s?"":"hover:bg-[var(--bg-card)] cursor-pointer"} bg-transparent border-none px-1 py-0 rounded ${aa(t)} text-left font-mono`,title:s?void 0:"Click to edit",children:sa(t)})})}const ys=Object.freeze(Object.defineProperty({__proto__:null,JsonTreePrimitiveNode:Yt},Symbol.toStringTag,{value:"Module"}));function xe(e){const{value:t}=e;return Array.isArray(t)?n.jsx(Kt,{...e,value:t}):t!==null&&typeof t=="object"?n.jsx(Ht,{...e,value:t}):n.jsx(Yt,{...e})}const vs=Object.freeze(Object.defineProperty({__proto__:null,JsonTreeNode:xe},Symbol.toStringTag,{value:"Module"}));function be({value:e,onChange:t,readOnly:r=!1,focusJsonPath:a}){const[s,o]=l.useState(()=>na(e)),[c,i]=l.useState(null),[p,u]=l.useState(null);fa(a,o);function b(h){o(d=>{const x=new Set(d);return x.has(h)?x.delete(h):x.add(h),x})}return n.jsx("div",{className:"flex flex-col h-full min-h-0",children:n.jsx("div",{className:"flex-1 min-h-0 overflow-auto font-mono text-xs leading-relaxed text-[var(--text-primary)] bg-[var(--bg-input)] border border-[var(--border-default)] rounded p-3",children:n.jsx(xe,{value:e,path:[],parentKey:null,isLast:!0,readOnly:r,expanded:s,editingPath:c,addingKeyAtPath:p,onToggle:b,onStartEdit:i,onStopEdit:()=>i(null),onStartAddKey:u,onStopAddKey:()=>u(null),onValueChange:t,rootValue:e})})})}const js=Object.freeze(Object.defineProperty({__proto__:null,JsonTreeEditor:be},Symbol.toStringTag,{value:"Module"}));function Wt({headers:e,onChange:t}){function r(o,c){t(e.map((i,p)=>p===o?{...i,...c}:i))}function a(){t([...e,{name:"",value:""}])}function s(o){t(e.filter((c,i)=>i!==o))}return n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:"Headers"}),n.jsx("button",{type:"button",onClick:a,className:"text-xs text-[var(--accent-blue)] hover:underline bg-transparent border-none cursor-pointer",children:"+ Add"})]}),e.length===0&&n.jsx("p",{className:"text-xs text-[var(--text-dim)] italic",children:"No headers"}),e.map((o,c)=>n.jsxs("div",{className:"flex gap-2",children:[n.jsx("input",{value:o.name,onChange:i=>r(c,{name:i.target.value}),placeholder:"Name",className:"flex-1 rounded border border-[var(--border-default)] bg-[var(--bg-surface)] px-2 py-1 text-xs font-mono"}),n.jsx("input",{value:o.value,onChange:i=>r(c,{value:i.target.value}),placeholder:"Value",className:"flex-1 rounded border border-[var(--border-default)] bg-[var(--bg-surface)] px-2 py-1 text-xs font-mono"}),n.jsx("button",{type:"button",onClick:()=>s(c),className:"px-2 text-xs text-[var(--text-dim)] hover:text-red-400 bg-transparent border-none cursor-pointer",children:"×"})]},c))]})}const _s=Object.freeze(Object.defineProperty({__proto__:null,MockBodyHeadersEditor:Wt},Symbol.toStringTag,{value:"Module"})),Ce=5;function pa(e,t){if(e==="loading")return"Computing impact…";if(e==null)return"";if(t.kind==="scenario")return"Affects only this scenario.";if(e.length===0)return"Affects no other scenarios.";const r=e.length===1?"scenario":"scenarios",a=e.slice(0,Ce).join(", "),s=e.length>Ce?`, +${e.length-Ce} more`:"";return`Affects ${e.length} ${r}: ${a}${s}`}function ha(e){const t=[{label:"This scenario only",description:"Write to this scenario's mocks file. The row's source flips to scenario.",scope:{kind:"scenario"}}];return e.source==="shared"&&e.sharedSlug&&t.push({label:`Shared data set "${e.sharedSlug}"`,description:"Write to the shared set this row came from. Affects every scenario opted into it.",scope:{kind:"shared",slug:e.sharedSlug}}),(e.source==="default"||e.source==="shared")&&t.push({label:"Defaults",description:"Write to _default.json. Affects every scenario that falls through to defaults for this route.",scope:{kind:"default"}}),t}function ma(e,t){if(e.source==="default"){const r=t.findIndex(a=>a.scope.kind==="default");if(r>=0)return r}if(e.source==="shared"){const r=t.findIndex(a=>a.scope.kind==="shared"&&a.scope.slug===(e.sharedSlug??""));if(r>=0)return r}return 0}function xa(e,t,r){const[a,s]=l.useState({}),o=r.map(c=>X(c.scope)).join("|");return l.useEffect(()=>{let c=!1;return(async()=>{const p={};for(const u of r)p[X(u.scope)]="loading";s(p);for(const u of r)try{const b=await Cr(e,t,u.scope);if(c)return;s(h=>({...h,[X(u.scope)]:b}))}catch{if(c)return;s(b=>({...b,[X(u.scope)]:[]}))}})(),()=>{c=!0}},[e,t,o]),a}function Ut({choice:e,selected:t,impactLabel:r,onSelect:a}){return n.jsxs("label",{className:`flex cursor-pointer flex-col rounded border p-3 text-xs transition-colors ${t?"border-violet-500 bg-violet-500/10":"border-[var(--border-subtle)] hover:bg-[var(--bg-elevated)]"}`,children:[n.jsxs("span",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"radio",name:"save-scope",checked:t,onChange:a}),n.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:e.label})]}),n.jsx("span",{className:"mt-1 pl-6 text-[var(--text-muted)]",children:e.description}),n.jsx("span",{className:"mt-1 pl-6 text-[var(--text-dim)] italic",children:r})]})}const ws=Object.freeze(Object.defineProperty({__proto__:null,SaveScopeChoiceRow:Ut},Symbol.toStringTag,{value:"Module"}));function Xt({entry:e,scenarioSlug:t,routeKey:r,onCancel:a,onConfirm:s}){const o=ha(e),[c,i]=l.useState(()=>ma(e,o)),p=xa(t,r,o),[u,b]=l.useState(!1),[h,d]=l.useState(null),x=async()=>{const m=o[c];if(m){b(!0),d(null);try{await s(m.scope)}catch(g){d(g instanceof Error?g.message:"Save failed")}finally{b(!1)}}};return n.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"save-scope-modal-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:n.jsxs("div",{className:"w-[28rem] max-w-[90vw] rounded-lg border border-[var(--border-default)] bg-[var(--bg-surface)] p-5 shadow-xl",children:[n.jsx("h2",{id:"save-scope-modal-title",className:"text-sm font-semibold text-[var(--text-primary)]",children:"Where should this save land?"}),n.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:r}),n.jsx("div",{className:"mt-4 space-y-2",children:o.map((m,g)=>n.jsx(Ut,{choice:m,selected:c===g,impactLabel:pa(p[X(m.scope)],m.scope),onSelect:()=>i(g)},X(m.scope)))}),h&&n.jsx(te,{text:h,className:"text-xs text-red-400",rowClassName:"mt-3"}),n.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:a,disabled:u,className:"rounded border border-[var(--border-default)] px-3 py-1.5 text-xs text-[var(--text-primary)] hover:bg-[var(--bg-elevated)] disabled:opacity-50",children:"Cancel"}),n.jsx("button",{type:"button",onClick:()=>void x(),disabled:u,className:"rounded bg-violet-500 px-3 py-1.5 text-xs font-medium text-white hover:bg-violet-400 disabled:opacity-50",children:u?"Saving…":"Save"})]})]})})}const Ss=Object.freeze(Object.defineProperty({__proto__:null,SaveScopeModal:Xt},Symbol.toStringTag,{value:"Module"}));function Jt({entry:e,routeKey:t,scenarioSlug:r,onSave:a,focusJsonPath:s}){const o=ra(e,t),[c,i]=l.useState(null),[p,u]=l.useState(!1),[b,h]=l.useState(!1);l.useEffect(()=>{i(null),h(!1)},[t]);const d=async m=>{u(!0),i(null);try{const g=o.buildPayload();await a({routeKey:t,...g,scope:m})}catch(g){throw i(g instanceof Error?g.message:"Save failed"),g}finally{u(!1)}},x=async()=>{if(o.isDirty){if(e.source==="scenario"){try{await d({kind:"scenario"})}catch{}return}h(!0)}};return n.jsxs("div",{className:"flex flex-col gap-3 h-full min-h-0",children:[c&&n.jsx(te,{text:c,className:"text-xs text-red-400"}),n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[n.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:"Status"}),n.jsx("input",{type:"number",value:o.status,onChange:m=>o.setStatus(Number(m.target.value)),className:"w-20 rounded border border-[var(--border-default)] bg-[var(--bg-surface)] px-2 py-1 text-xs font-mono"}),n.jsx("div",{className:"flex-1"}),n.jsx("button",{type:"button",onClick:()=>void x(),disabled:!o.isDirty||p,className:"rounded bg-violet-500 px-3 py-1 text-xs font-medium text-white hover:bg-violet-400 disabled:opacity-50",children:p?"Saving…":o.isDirty?"Save changes":"Saved"})]}),n.jsx(Wt,{headers:o.headers,onChange:o.setHeaders}),n.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[n.jsxs("div",{className:"flex items-center gap-2 pb-1",children:[n.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:"Body"}),n.jsx(Bt,{body:o.body,onBodyChange:o.setBody})]}),n.jsx(be,{value:o.body,onChange:o.setBody,focusJsonPath:s},t)]}),b&&n.jsx(Xt,{entry:e,scenarioSlug:r,routeKey:t,onCancel:()=>h(!1),onConfirm:async m=>{await d(m),h(!1)}})]})}const ks=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelMainMockEditable:Jt},Symbol.toStringTag,{value:"Module"}));function ba(e,t){if(e==null)return"never";const r=Math.max(0,Math.floor((t-e)/1e3));if(r<60)return`${r}s ago`;const a=Math.floor(r/60);return a<60?`${a}m ago`:`${Math.floor(a/60)}h ago`}const Ze={GET:"text-emerald-400 border-emerald-400/40",POST:"text-[#D7FF63] border-[#D7FF63]/40",PUT:"text-amber-400 border-amber-400/40",PATCH:"text-purple-400 border-purple-400/40",DELETE:"text-red-400 border-red-400/40"};function ga(e){return Ze[e]??Ze.GET}function qt({entry:e,scenarioHasDefaultFallback:t,onSave:r,onRemove:a,onPassthrough:s}){const o=`${e.method} ${e.pathPattern}`,c=ga(e.method),i=e.status??e.lastObservedStatus,p=l.useMemo(()=>e.lastObservedMs?ba(e.lastObservedMs,Date.now()):null,[e.lastObservedMs]),u="px-3 py-1 rounded border border-[var(--border-default)] bg-transparent text-[var(--text-muted)] hover:text-[var(--text-primary)] cursor-pointer text-xs";return n.jsxs("header",{className:"border-b border-[var(--border-subtle)] bg-[var(--bg-deep)] px-4 py-3 space-y-2 flex-shrink-0",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:`px-2 py-0.5 rounded border font-mono text-xs ${c}`,children:e.method}),n.jsx("span",{className:"font-mono text-sm text-[var(--text-primary)] break-all",children:e.pathPattern}),n.jsx(Re,{source:e.source}),i!==void 0&&n.jsx("span",{className:"px-1.5 py-0.5 rounded border border-[var(--border-default)] text-[var(--text-muted)] font-mono text-xs",children:i}),e.observedCount>0&&n.jsxs("span",{className:"ml-auto text-xs text-[var(--text-dim)]",children:[e.observedCount,"× ",p?`· ${p}`:""]})]}),e.variants.length>1&&n.jsxs("div",{className:"text-[10px] text-[var(--text-dim)] font-mono",children:["variants: ",e.variants.filter(b=>b!==o).join(", ")]}),n.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[e.source==="scenario"&&t&&n.jsx("button",{onClick:()=>void a(o),className:u,title:"Remove this scenario mock and fall back to the default",children:"Revert to default"}),e.source==="scenario"&&n.jsx("button",{onClick:()=>void s(o),className:u,children:"Mark passthrough"}),e.source==="default"&&n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:()=>void r({routeKey:o,status:e.status??200,body:e.body,headers:e.headers??{},scope:{kind:"scenario"}}),className:"px-3 py-1 rounded border border-emerald-500/50 bg-emerald-500/10 text-emerald-300 hover:bg-emerald-500/20 cursor-pointer text-xs",title:"Copy default body into this scenario",children:"Promote to scenario"}),n.jsx("button",{onClick:()=>void s(o),className:u,children:"Mark passthrough"})]}),e.source==="passthrough"&&n.jsx("button",{onClick:()=>void a(o),className:u,children:"Undo passthrough"})]})]})}const Cs=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelMainMockHeader:qt},Symbol.toStringTag,{value:"Module"}));function Gt({entry:e}){const t=Object.entries(e.headers??{}),r=e.body!==void 0&&e.body!==null;return!r&&t.length===0?n.jsx("p",{className:"text-xs italic text-[var(--text-dim)]",children:e.source==="catalog-only"?"No mock body yet — this endpoint has only been observed, not mocked. Promote it to a scenario to start editing.":e.source==="passthrough"?"This endpoint passes through to the upstream service.":"No body configured."}):n.jsxs("div",{className:"space-y-3 h-full min-h-0 flex flex-col",children:[t.length>0&&n.jsxs("section",{className:"space-y-1 flex-shrink-0",children:[n.jsx("h4",{className:"text-xs font-medium uppercase tracking-wide text-[var(--text-dim)]",children:"Headers"}),n.jsx("dl",{className:"text-xs font-mono space-y-0.5",children:t.map(([a,s])=>n.jsxs("div",{className:"flex gap-2",children:[n.jsxs("dt",{className:"text-[var(--text-muted)]",children:[a,":"]}),n.jsx("dd",{className:"text-[var(--text-primary)] break-all",children:s})]},a))})]}),r&&n.jsxs("section",{className:"flex-1 min-h-0 flex flex-col",children:[n.jsx("h4",{className:"text-xs font-medium uppercase tracking-wide text-[var(--text-dim)] pb-1",children:"Body"}),n.jsx(be,{value:e.body,onChange:()=>{},readOnly:!0},`${e.method} ${e.pathPattern}`)]})]})}const Ns=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelMainMockReadOnly:Gt},Symbol.toStringTag,{value:"Module"}));function Qt({entry:e,scenarioSlug:t,scenarioHasDefaultFallback:r,onSave:a,onRemove:s,onPassthrough:o,focusJsonPath:c}){const i=`${e.method} ${e.pathPattern}`,p=e.source==="scenario"||e.source==="default"||e.source==="shared";return n.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[n.jsx(qt,{entry:e,scenarioHasDefaultFallback:r,onSave:a,onRemove:s,onPassthrough:o}),n.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-4",children:p?n.jsx(Jt,{entry:e,routeKey:i,scenarioSlug:t,onSave:a,focusJsonPath:c}):n.jsx(Gt,{entry:e})})]})}const Es=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelMainMock:Qt},Symbol.toStringTag,{value:"Module"}));function ya({slug:e,tab:t,initialRows:r,onCellEdited:a}){const[s,o]=l.useState(r),[c,i]=l.useState(null),[p,u]=l.useState(""),[b,h]=l.useState(""),d=l.useRef(null);l.useEffect(()=>{o(r),i(null)},[t.dataKey,r]);function x(v,k){const _=s[v];i({row:v,col:k});const w=_[k]===null?"":typeof _[k]=="object"?JSON.stringify(_[k]):String(_[k]);u(w),h(w)}function m(v){if(u(v),d.current&&clearTimeout(d.current),!c)return;const k=c;d.current=setTimeout(()=>{f(k.row,k.col,v)},600)}function g(){c&&(d.current&&clearTimeout(d.current),f(c.row,c.col,p),i(null))}function y(){if(d.current&&clearTimeout(d.current),!!c){if(p!==b){const v=[...s];v[c.row]={...v[c.row],[c.col]:ze(b)},o(v),fetch(`/api/scenarios/${encodeURIComponent(e)}/data`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:t.dataKey,rowIndex:c.row,column:c.col,value:b})}).then(()=>{G(),a&&a()}).catch(()=>{})}i(null)}}async function f(v,k,_){const w=[...s];w[v]={...w[v],[k]:ze(_)},o(w);try{await fetch(`/api/scenarios/${encodeURIComponent(e)}/data`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:t.dataKey,rowIndex:v,column:k,value:_})}),G(),a&&a()}catch{}}return{rows:s,editingCell:c,editValue:p,handleEditCell:x,handleEditValueChange:m,handleSave:g,handleCancelEdit:y}}function Zt({tab:e}){return!e.description&&!e.category?null:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-[var(--bg-deep)] border-b border-[var(--border-subtle)]",children:[e.category&&n.jsx("span",{className:`text-[9px] rounded px-1.5 py-0 border ${e.category==="datastore"?"text-[var(--accent-active)]/80 bg-[var(--accent-active)]/10 border-[var(--accent-active)]/30":e.category==="mock-api"?"text-[#D7FF63]/80 bg-[#D7FF63]/10 border-[#D7FF63]/30":"text-[var(--text-muted)] bg-[var(--bg-surface)]/30 border-[var(--text-dim)]/30"}`,children:e.category==="mock-api"?"API Mock":e.category}),e.description&&n.jsx("span",{className:"text-[10px] text-[var(--text-dim)]",children:e.description})]})}const Ts=Object.freeze(Object.defineProperty({__proto__:null,DataViewerCategoryBadge:Zt},Symbol.toStringTag,{value:"Module"}));function er({editingCell:e,editValue:t,onEditValueChange:r,onSave:a,onCancel:s}){return n.jsxs("div",{className:"border-t border-[var(--border-default)] bg-[var(--bg-deep)] px-3 py-2",children:[n.jsx("div",{className:"flex items-center gap-2 mb-1.5",children:n.jsxs("span",{className:"text-[10px] text-[var(--text-muted)]",children:["Editing"," ",n.jsx("strong",{className:"text-[var(--text-secondary)]",children:e.col})," ","in row ",e.row+1]})}),n.jsx("textarea",{value:t,onChange:o=>r(o.target.value),className:"w-full px-2 py-1.5 text-[11px] bg-[var(--bg-card)] text-[var(--text-primary)] border border-[var(--border-default)] rounded outline-none focus:border-[var(--accent-active)]/50 resize-y min-h-[60px] max-h-[200px] font-mono",autoFocus:!0,rows:t.length>100?4:2,onKeyDown:o=>{o.key==="Escape"&&s(),o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&a()}}),n.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[n.jsx("button",{onClick:a,className:"px-3 py-1 text-[10px] font-medium text-[var(--bg-deep)] bg-[var(--accent-active)] rounded cursor-pointer border-none hover:bg-[var(--accent-active)]/80 transition-colors",children:"Save"}),n.jsx("button",{onClick:s,className:"px-3 py-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text-primary)] bg-transparent border-none cursor-pointer",children:"Cancel"}),n.jsxs("span",{className:"text-[9px] text-[var(--text-dim)] ml-auto",children:["⌘","+Enter to save, Esc to cancel"]})]})]})}const Os=Object.freeze(Object.defineProperty({__proto__:null,DataViewerCellEditor:er},Symbol.toStringTag,{value:"Module"}));function tr({columns:e,colTypes:t,pkCol:r,rows:a,onEditCell:s}){return e.length===0?n.jsx("div",{className:"px-3 py-4 text-[10px] text-[var(--text-dim)] text-center",children:"No columns defined for this table"}):n.jsx("div",{className:"overflow-x-auto max-h-[300px] overflow-y-auto",children:n.jsxs("table",{className:"w-full text-[10px] border-collapse table-fixed",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"bg-[var(--bg-deep)] sticky top-0 z-10",children:[n.jsx("th",{className:"text-right text-[var(--text-dim)] font-normal px-2 py-1.5 border-b border-[var(--border-default)] w-8",children:"#"}),e.map(o=>n.jsx(rr,{name:o,type:t[o],isPk:o===r},o))]})}),n.jsx("tbody",{children:a.map((o,c)=>n.jsx(nr,{row:o,rowIndex:c,columns:e,pkCol:r,onEditCell:s},c))})]})})}function rr({name:e,type:t,isPk:r}){return n.jsxs("th",{className:"text-left px-2 py-1.5 border-b border-[var(--border-default)] whitespace-nowrap overflow-hidden",children:[r&&n.jsx("span",{className:"inline-block text-[8px] font-bold text-[var(--bg-deep)] bg-[var(--accent-active)] rounded px-1 py-0 mr-1.5 align-middle",children:"PK"}),n.jsx("span",{className:"text-[var(--text-secondary)] font-medium",children:e}),n.jsx("span",{className:"text-[var(--text-dim)] font-normal ml-1",children:t})]})}function nr({row:e,rowIndex:t,columns:r,pkCol:a,onEditCell:s}){return n.jsxs("tr",{className:"border-b border-[var(--border-subtle)] hover:bg-[var(--bg-card)] group/row",children:[n.jsx("td",{className:"text-right text-[var(--text-dim)] px-2 py-1.5 w-8 select-none",children:t+1}),r.map(o=>n.jsx(ar,{value:e[o],isPk:o===a,onEdit:()=>s(t,o)},o))]})}function ar({value:e,isPk:t,onEdit:r}){return n.jsxs("td",{className:`px-2 py-1.5 overflow-hidden relative group/cell ${t?"text-[var(--accent-active)] font-medium":"text-[var(--text-secondary)]"}`,title:String(e??""),children:[n.jsx("span",{className:"truncate block whitespace-nowrap",children:e===null?n.jsx("span",{className:"text-[var(--text-dim)] italic",children:"null"}):typeof e=="object"?n.jsx("span",{className:"text-[var(--text-dim)]",children:JSON.stringify(e)}):typeof e=="number"?n.jsx("span",{className:"text-amber-400",children:String(e)}):String(e)}),n.jsx("button",{onClick:a=>{a.stopPropagation(),r()},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover/cell:opacity-100 text-[var(--text-dim)] hover:text-[var(--text-primary)] bg-[var(--bg-card)] border border-[var(--border-default)] rounded cursor-pointer p-0.5 transition-opacity",title:"Edit",children:n.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),n.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]})}const Ms=Object.freeze(Object.defineProperty({__proto__:null,DataViewerCell:ar,DataViewerColumnHeader:rr,DataViewerRow:nr,DataViewerTable:tr},Symbol.toStringTag,{value:"Module"}));function sr({slug:e,tab:t,initialRows:r,onCellEdited:a}){const{rows:s,editingCell:o,editValue:c,handleEditCell:i,handleEditValueChange:p,handleSave:u,handleCancelEdit:b}=ya({slug:e,tab:t,initialRows:r,onCellEdited:a}),h=Ar(s,t.schemaFields),d=Pr(h,s,t.schemaFields),x=Rr(h,t.schemaFields);return n.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[n.jsx(Zt,{tab:t}),n.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:n.jsx(tr,{columns:h,colTypes:d,pkCol:x,rows:s,onEditCell:i})}),o&&n.jsx(er,{editingCell:o,editValue:c,onEditValueChange:p,onSave:u,onCancel:b})]})}const As=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelMainTable:sr},Symbol.toStringTag,{value:"Module"}));function va({slug:e,browserState:t,tab:r,onCellEdited:a}){const s=l.useMemo(()=>{if(!t)return{};switch(r){case"cookies":return t.cookies??{};case"localStorage":return t.localStorage??{};case"sessionStorage":return t.sessionStorage??{};case"headers":return t.requestHeaders??{};default:return{}}},[t,r]),o=l.useCallback(async p=>{const u=r==="headers"?"browserState.requestHeaders":`browserState.${r}`;try{await fetch(`/api/scenarios/${encodeURIComponent(e)}/data`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:u,value:JSON.stringify(p)})}),G(),a&&a()}catch{}},[e,r,a]),c=l.useMemo(()=>{switch(r){case"cookies":return"Cookies";case"localStorage":return"Local Storage";case"sessionStorage":return"Session Storage";case"headers":return"Request Headers"}},[r]),i=l.useMemo(()=>{switch(r){case"cookies":return"Cookies injected via Set-Cookie headers on the scenario's initial response.";case"localStorage":return"localStorage items set before the app's JavaScript executes.";case"sessionStorage":return"sessionStorage items set before the app's JavaScript executes.";case"headers":return"Custom headers added to every outbound HTTP request from the iframe."}},[r]);return{value:s,handleChange:o,label:c,description:i}}function or({slug:e,browserState:t,tab:r,onCellEdited:a}){const{value:s,handleChange:o,label:c,description:i}=va({slug:e,browserState:t,tab:r,onCellEdited:a});return n.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[n.jsxs("div",{className:"px-4 py-3 border-b border-[var(--border-subtle)]",children:[n.jsx("h2",{className:"text-sm font-semibold text-[var(--text-primary)]",children:c}),n.jsx("p",{className:"text-xs text-[var(--text-dim)] mt-1",children:i})]}),n.jsx("div",{className:"flex-1 min-h-0 p-4 overflow-auto",children:n.jsx(be,{value:s,onChange:o})})]})}const Ps=Object.freeze(Object.defineProperty({__proto__:null,BrowserStateTab:or},Symbol.toStringTag,{value:"Module"}));function de({label:e,active:t,onClick:r}){return n.jsx("button",{type:"button",onClick:r,className:`px-2 py-0.5 rounded-full border text-[10px] font-mono transition-colors cursor-pointer ${t?"bg-violet-500/25 text-violet-100 border-violet-400/70":"bg-violet-500/10 text-violet-300 border-violet-500/40 hover:bg-violet-500/20"}`,"aria-pressed":t,children:e})}const Rs=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelMockDataBadge:de},Symbol.toStringTag,{value:"Module"}));function ir({shares:e,activeBadge:t,onSelect:r}){return n.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap border-b border-[var(--border-subtle)] bg-[var(--bg-deep)] px-4 py-2","data-testid":"scenario-mock-data-strip",children:[n.jsx("span",{className:"text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-semibold",children:"Mock Data:"}),n.jsx(de,{label:"This Page",active:t.kind==="this-page",onClick:()=>r({kind:"this-page"})}),e.map(a=>n.jsx(de,{label:a,active:t.kind==="share"&&t.slug===a,onClick:()=>r({kind:"share",slug:a})},a)),n.jsx(de,{label:"Defaults",active:t.kind==="defaults",onClick:()=>r({kind:"defaults"})})]})}const Ds=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelMockDataStrip:ir},Symbol.toStringTag,{value:"Module"}));function ja({slug:e,scenarioName:t,initialSection:r,onClose:a,variant:s="slideOver"}){const{data:o,tableTabs:c,scenarioOwnedDataKeys:i,shares:p,browserState:u,loading:b,error:h}=Kr(e),{entries:d,loading:x,error:m,upsertScoped:g,remove:y,setPassthrough:f}=Er(e),{config:v}=et(),k=(v==null?void 0:v.provider)??"claude",_=Yr({slug:e,onPreviewReload:G}),w=l.useCallback(()=>{_.markDirty(),G()},[_]),P=l.useCallback(async M=>{await g(M),w()},[g,w]),B=l.useCallback(async M=>{await y(M),w()},[y,w]),E=l.useCallback(async M=>{await f(M),w()},[f,w]),j=l.useCallback(()=>{_.markDirty(),G()},[_]),F=l.useCallback(()=>{a&&_.confirmIfDirty("Discard unsaved changes to this scenario?")&&a()},[a,_]),[N,D]=l.useState(null),[T,O]=l.useState(null),[I,A]=l.useState(!1),K=l.useCallback(M=>D({kind:"mock",routeKey:M}),[]);yr({onSelect:K,onFocus:O});const[R,V]=l.useState({kind:"this-page"}),U=b||x,H=l.useMemo(()=>s==="inline"?c.filter(M=>i.has(M.dataKey)):c,[s,c,i]),z=l.useMemo(()=>{if(s!=="inline")return d;switch(R.kind){case"this-page":return d.filter(M=>M.consumedThisPageLoad);case"defaults":return d.filter(M=>M.source==="default");case"share":return d.filter(M=>M.source==="shared"&&M.sharedSlug===R.slug)}},[s,d,R]);Zr({seedTabs:H,mockEntries:z,initialSection:r,selection:N,setSelection:D});const q=l.useMemo(()=>{const M=new Set;for(const Be of d)Be.source==="default"&&M.add(J(Be));return M},[d]),S=(N==null?void 0:N.kind)==="seed"?H.find(M=>M.dataKey===N.dataKey)??null:null,C=(N==null?void 0:N.kind)==="mock"?z.find(M=>J(M)===N.routeKey)??null:null,L=S&&o?o[S.dataKey]??[]:[],$=l.useMemo(()=>xr({slug:e,scenarioName:t,seedTabs:H,mockEntries:z,selectedMock:C,selectedSeedTab:S,selectedSeedRows:L}),[e,t,H,z,C,S,L]),ae=t??e,ge=H.length>0||z.length>0,ye=n.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[n.jsx($t,{title:ae,slug:e,provider:k,chatOpen:I,onToggleChat:()=>A(M=>!M),variant:s,onClose:a?F:void 0,draftDirty:_.isDirty,draftDiff:_.diffSummary,draftSaving:_.saving,draftCancelling:_.cancelling,draftError:_.error,onSave:()=>void _.save(),onCancel:()=>void _.cancel()}),s==="inline"&&n.jsx(ir,{shares:p,activeBadge:R,onSelect:V}),I&&n.jsx("div",{className:"flex-shrink-0 border-b border-[var(--border-subtle)] bg-[var(--bg-deep)]",children:n.jsx(Tt,{chatName:`edit-data-${e}`,prompt:$,height:360,onClose:()=>A(!1)})}),n.jsxs("div",{className:"flex flex-1 min-h-0",children:[n.jsx(ot,{seedTabs:H,mockEntries:z,selection:N,onSelect:D}),n.jsx("main",{className:"flex-1 min-w-0 min-h-0 bg-[var(--bg-deep)] flex flex-col",children:n.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[h&&n.jsx(te,{text:`Seed error: ${h}`,className:"text-xs text-red-400",rowClassName:"p-4"}),m&&n.jsx(te,{text:`Mocks error: ${m}`,className:"text-xs text-red-400",rowClassName:"p-4"}),!U&&!ge&&n.jsx(Ot,{}),S&&n.jsx(sr,{slug:e,tab:S,initialRows:L,onCellEdited:j}),C&&n.jsx(Qt,{entry:C,scenarioSlug:e,scenarioHasDefaultFallback:q.has(J(C)),onSave:P,onRemove:B,onPassthrough:E,focusJsonPath:T}),(N==null?void 0:N.kind)==="browser"&&n.jsx(or,{slug:e,browserState:u,tab:N.tab,onCellEdited:j}),!S&&!C&&(N==null?void 0:N.kind)!=="browser"&&ge&&!U&&n.jsx("p",{className:"p-4 text-xs text-[var(--text-dim)] italic",children:"Select a data source from the left to view it."}),U&&!ge&&n.jsx("p",{className:"p-4 text-xs text-[var(--text-dim)]",children:"Loading scenario data…"})]})})]})]});return s==="fullPage"?n.jsx("div",{className:"fixed inset-0 bg-[var(--bg-deep)] text-[var(--text-primary)]",children:ye}):s==="inline"?n.jsx("div",{className:"rounded-md border border-[var(--border-subtle)] bg-[var(--bg-deep)] max-h-[min(640px,70vh)] min-h-0 flex flex-col overflow-hidden",children:ye}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-40 bg-black/40",onClick:F,"aria-label":"Close scenario data panel"}),n.jsx("aside",{className:"fixed right-0 top-0 z-50 h-full w-full max-w-4xl border-l border-[var(--border-default)] bg-[var(--bg-deep)] shadow-2xl",children:ye})]})}const Is=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanel:ja},Symbol.toStringTag,{value:"Module"}));export{nt as $,Wn as A,or as B,Bt as C,nr as D,Lt as E,at as F,st as G,Xt as H,Ut as I,Yt as J,ot as K,ir as L,Wt as M,de as N,Dt as O,qt as P,Qt as Q,Rt as R,ja as S,mt as T,$t as U,Ot as V,At as W,Mt as X,tr as Y,er as Z,Zt as _,Re as a,Os as a$,rt as a0,ft as a1,ut as a2,dt as a3,lt as a4,xt as a5,_t as a6,kt as a7,Ct as a8,Nt as a9,Es as aA,ls as aB,fs as aC,as as aD,os as aE,ss as aF,Is as aG,Ss as aH,ws as aI,rs as aJ,ts as aK,Oa as aL,Pa as aM,_s as aN,Ya as aO,Qa as aP,ys as aQ,gs as aR,bs as aS,hs as aT,vs as aU,js as aV,ms as aW,xs as aX,ps as aY,ns as aZ,Ms as a_,Tt as aa,Et as ab,qa as ac,Ja as ad,es as ae,Za as af,Ha as ag,Fa as ah,Ka as ai,$a as aj,Ba as ak,za as al,Va as am,La as an,Ra as ao,Aa as ap,Ma as aq,us as ar,Da as as,ds as at,Ds as au,Rs as av,As as aw,Ns as ax,Cs as ay,ks as az,sr as b,Ts as b0,Ps as b1,Ga as b2,et as b3,re as b4,Ie as b5,Rn as b6,vr as b7,we as b8,On as b9,Ae as bA,Jn as bB,Xa as ba,nn as bb,an as bc,un as bd,yn as be,Wa as bf,jn as bg,sn as bh,Sn as bi,it as bj,_n as bk,vn as bl,Ua as bm,St as bn,En as bo,Je as bp,Nn as bq,le as br,Nr as bs,Ea as bt,cs as bu,is as bv,Ta as bw,Ia as bx,Un as by,rn as bz,Jt as c,Gt as d,G as e,ba as f,Yr as g,Kr as h,Er as i,ht as j,pt as k,ie as l,rr as m,ar as n,ee as o,ze as p,bt as q,wt as r,Vt as s,Ht as t,Xn as u,me as v,xe as w,be as x,Kt as y,zt as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as c}from"./markdown-C9tbsVHX.js";import{b as o}from"./react-nrLBr15I.js";import{S as l}from"./ScenarioDataPanel-
|
|
1
|
+
import{j as c}from"./markdown-C9tbsVHX.js";import{b as o}from"./react-nrLBr15I.js";import{S as l}from"./ScenarioDataPanel-DjprZq2L.js";function m({slug:t}){const[r,i]=o.useState(void 0);return o.useEffect(()=>{let n=!1;return fetch(`/api/scenarios/${encodeURIComponent(t)}`).then(e=>e.ok?e.json():null).then(e=>{if(n||!e)return;const a=typeof e=="object"&&e!==null&&"name"in e?String(e.name):void 0;i(a),a&&(document.title=`${a} · data`)}).catch(()=>{}),()=>{n=!0}},[t]),c.jsx(l,{slug:t,scenarioName:r,variant:"fullPage"})}const p=Object.freeze(Object.defineProperty({__proto__:null,ScenarioDataPanelFullPage:m},Symbol.toStringTag,{value:"Module"}));export{m as S,p as _};
|